diff --git a/code/HDK/A4EXIF.ASM b/code/HDK/A4EXIF.ASM new file mode 100644 index 0000000..7f5c9a5 --- /dev/null +++ b/code/HDK/A4EXIF.ASM @@ -0,0 +1,1189 @@ + title A4EXIF -- Example ASIC4 Interface device driver + subttl Copyright (c) Psion PLC (1994) + name A4EXIF +; +; VER DATE BY DESCRIPTION +; ---------------------------------------- +; 1.00F 26/1/95 Mal Working Version + + +;BUILDSB=1 ;S3a build environment (channels=1) +S3c=0 ;Need to specify no s3c +;BUILDSC=1 ;S3c build environment (channels=3) +BUILDCH=1 ;HC build environment (channels=3) +;BUILDHH=1 ;S3 build environment (channels=1) + + include ..\inc\epoc.inc + include ..\inc\epoclib.inc + include ..\inc\epocsibo.inc + include ossibo.inc + include ospack.inc + +; Example Logical Device Driver for prototype LED-ASIC4 Interface +; circuit for Corporate/S3C/Consumer serial port. +; Written by Mal Dec 1994/Jan 1995. + +; A4EXIF CONSTANTS AND TYPES +; ========================== +; The following constants and type definitions +; are compiler directives used by the TCEP assembler +; when it is creating the LDD. + +if Consumer + numberofchannels equ 1 +else + if Corporate or S3c + numberofchannels equ 3 + else + numberofchannels equ 2 + endif +endif + +;Channel StatusEnt block accessed through CS:DI +A4ExifStatusEnt struc + A4ExifCSProcessId dw ? ;Channel parent process id + A4ExifCSChannelOpen db ? ;Channel open flag + A4ExifCSChannelRunning db ? ;Channel hardware running flag + A4ExifCSChanReadCompleted db ? ;Channel request completed flag + A4ExifCSChannelIntMask db ? ;Channel interrupt mask + A4ExifCSChannelIntNum db ? ;Channel interrupt number + A4ExifCSChannelSelect db ? ;SIBO Channel select + A4ExifCSChannelIntVec dw ? ;Channel int vector number + A4ExifCSTickHandle dw ? ;TCK channel handle + A4ExifCSA1Value db ? ;Channel strategy A1 parameter + A4ExifCSA2Value db ? ;Channel strategy A2 parameter +A4ExifStatusEnt ends + +;Open Channel Control block accessed through DS:BX +A4ExifEnt struc + A4ExifDSIo ChanEnt <> ;Open channel control block Ent + A4ExifDSHandlerPtr dw ? ;Cant touch when under + A4ExifDSStatusPtr dw ? ;Hold, Resume, Reset or + A4ExifDSA1Ptr dw ? ;interrupt routine + A4ExifDSA2Ptr dw ? + A4ExifDSStatusEntPtr dw ? +A4ExifEnt ends + + + A4PERIPH_MASK equ 0f0h ;11110000b + EXTENDED_INFO_BYTE equ 090h ;10010000b + U5_ENABLE_ON equ 080h ;Sets LBO for latch U5 + U5_ENABLE_OFF equ 000h ;Deselects LBO for U5 + +;Latch addresses for reading/writing + U5OUTPUT_LATCH equ 00000000b ;Selects A0 for writing + U3INPUT_BUFFER equ 00000000b ;Selects A0 for reading + U4STATUS_BUFFER equ 00000001b ;Selects cs:[di].A4ExifCsA1Valuefor reading + INTERRUPT_LATCH equ 00000001b ;Selects A1 for writing + +;Status byte masks + S2S3_ON equ 00000011b + S2S3_OFF equ 00000000b + S2_ONLY equ 00000001b + S3_ONLY equ 00000010b + INTERRUPT_STATUS_MASK equ 00000011b + +;LED bytes + SOME_LEDS_ON equ 01010101b + SOME_LEDS_OFF equ 10101010b + TOP_LEDS_ON equ 11110000b + BOTTOM_LEDS_ON equ 00001111b + ZERO_BYTE equ 00h + + dgroup group stack + assume ds:dgroup,es:dgroup,ss:dgroup + + CodeSeg + +; A4EXIF ENTRY TABLE +; ================== + +ProcBegin@ A4ExifLDD +; ========= + +dw LDDSignature +db 'LED',0,0,0,0,0 +dw (VectorEnd-Vector)/2 +Vector: + dw A4ExifInstall + dw A4ExifRemove + dw A4ExifHold + dw A4ExifResume + dw A4ExifReset + dw A4ExifUnits + dw A4ExifOpen + dw A4ExifStrategy +VectorHandler: + dw A4ExifHandler +if Asic9 +InterruptVectors: + dw A4ExifTickInt +endif +VectorEnd: + + +; A4EXIF INTERNAL DATA SPACE +; ========================== +; Device Driver global variables follow. +; These variables reside in the code segment +; and as such can always be accessed with +; the 'cs:' prefix. + +if Asic9 + if Consumer + Channel0 A4ExifStatusEnt<0,0,0,0,mask A9MSlave,HwIrq2Revector,SelectChannel5,IntVec0,0,0> + else + if Corporate or S3c + Channel0 A4ExifStatusEnt<0,0,0,0,mask A9MExpIntA,HwIrq4Revector,SelectChannel3,IntVec0,0,0> + Channel1 A4ExifStatusEnt<0,0,0,0,mask A9MExpIntB,HwIrq5Revector,SelectChannel4,IntVec1,0,0> + Channel2 A4ExifStatusEnt<0,0,0,0,mask A9MSlave,HwIrq2Revector,SelectChannel5,IntVec2,0,0> + else + Channel0 A4ExifStatusEnt<0,0,0,0,mask A9MExpIntA,HwIrq4Revector,SelectChannel3,IntVec0,0,0> + Channel1 A4ExifStatusEnt<0,0,0,0,mask A9MExpIntB,HwIrq5Revector,SelectChannel4,IntVec1,0,0> + endif + endif +else + if Consumer + Channel0 A4ExifStatusEnt<0,0,0,0,mask Asic2Int,HwIrq4Revector,SelectChannel7,IntVec0,0,0> + else + if Corporate + Channel0 A4ExifStatusEnt<0,0,0,0,mask ExpIntLeftA,HwIrq3Revector,ExpChannelLeftA,IntVec0,0,0> + Channel1 A4ExifStatusEnt<0,0,0,0,mask ExpIntRightB,HwIrq2Revector,ExpChannelRightB,IntVec1,0,0> + Channel2 A4ExifStatusEnt<0,0,0,0,mask Asic2Int,HwIrq4Revector,SelectChannel7,IntVec2,0,0> + else + Channel0 A4ExifStatusEnt<0,0,0,0,mask ExpIntLeftA,HwIrq3Revector,ExpChannelLeftA,IntVec0,0,0> + Channel1 A4ExifStatusEnt<0,0,0,0,mask ExpIntRightB,HwIrq2Revector,ExpChannelRightB,IntVec1,0,0> + endif + endif +endif + + HoldFlag db 0 ;Hold/Resume flag + SwitchStatus db ? ;Holds the masked status byte from U4 after interrupt + + ProcEnd noret + + + ProcBegin@ A4ExifInstall,far +; ============= +; Installs the device driver. +; Invoked after a PLIB 'p_loadldd("A4EXIF.LDD")' call to load the LDD +; All of the fields inside the CS control blocks are preloaded +; with the correct values at install time. Install therefore does +; not do any work. +; IN: +; Nothing +; OUT: +; Carry Clear - driver successfully installed +; + clc ;The ChannelOpen fields are set to zero + ret ;in the relevant ChannelStatusEnt headers + ProcEnd noret + + + ProcBegin@ A4ExifRemove,far +; ============ +; Removes the device driver. +; Invoked after a PLIB 'p_devdel("LED",E_LDD)'call to unload the +; device driver. +; A device driver cannot be removed if any of its channels +; are still open. +; IN: +; Nothing +; OUT: +; Carry clear - successfully removed +; Carry set - remove failed, error number in AL +; + mov cx, numberofchannels ;Check that each + mov di, offset Channel0 ;channel is closed + xor ax, ax +CheckAllChannelsClosedLoop: + cmp cs:[di].A4ExifCSChannelOpen, al ;Closed channels will + jne WeHaveAChannelOpenSoFail ;have the value 0 in + add di, (size A4ExifStatusEnt) ;their ChannelOpen + loop CheckAllChannelsClosedLoop ;flags + jmp FinishedOkay +WeHaveAChannelOpenSoFail: + mov al, InUseErr ;Fail if not all + stc ;closed + ret +FinishedOkay: + clc + ret + ProcEnd noret + + + ProcBegin@ A4ExifHold,far +; ========== +; Called by the operating system whenever the device driver is +; being moved or the machine is powering down. +; This will also be called by our pack door polling function when +; it sees that the doors have been opened and our peripheral has +; lost power. +; IN: +; Reason for the hold in AH +; OUT: +; Nothing +; + mov cx, 1 ;Hold can be called + xchg cl, HoldFlag ;when the driver is + cmp cl, 0 ;under a hold so + jne AlreadyHeld ;re-entrancy blocking +A4HoldFromTick: ;is required + mov cx, numberofchannels + mov di, offset Channel0 ;Loop because Hold +HoldAllTheChannelsLoop: ;must stop all the + cmp cs:[di].A4ExifCSChannelOpen, 0 ;channels + je DontHoldBecauseNotOpen ;Is the channel open? + push cx ;If it is then stop + call StopTheChannelRunning ;all interrupts + pop cx +DontHoldBecauseNotOpen: + add di, (size A4ExifStatusEnt) + loop HoldAllTheChannelsLoop +AlreadyHeld: + ret + ProcEnd noret + + + ProcBegin@ A4ExifResume,far +; ============ +; Called by the operating system when it has finished moving the +; device driver in memory or when the machine is switching back on. +; Also called by our door polling routine when it sees that the doors +; have been closed and we can resume communication with our peripheral. +; IN: +; Nothing +; OUT: +; Nothing +; + xor cx, cx ;Block in case of re-entrancy + xchg cl, HoldFlag + cmp cl, 0 + je AlreadyResumed +if Asic9 + GenDataSegment ;Check to see if the pack + HwGetSsdData ;doors are still closed + mov bx, ax + cmp es:[bx].SsdDoorStatus, DoorOpen + je DoorsAreOpen +endif +A4ResumeFromTick: + mov cx, numberofchannels ;Loop because resume must + mov di, offset Channel0 ;restart each open channel +ResumeAllTheChannelsLoop: + cmp cs:[di].A4ExifCSChannelOpen, 0 ;Is the channel open? + je DontResumeBecauseNotOpen + push cx + call StartTheChannelRunning + pop cx +DontResumeBecauseNotOpen: + add di, (size A4ExifStatusEnt) + loop ResumeAllTheChannelsLoop +AlreadyResumed: + ret +DoorsAreOpen: + mov HoldFlag, 2 + ret + ProcEnd noret + + + ProcBegin@ A4ExifReset,far +; =========== +; Called when an application which opened a channel terminates without +; closing the device driver. +; A device driver, for each open channel, has to request that the +; operating system calls this function when the application +; terminates abnormally (ie without closing an open channel). +; Reset can supply one piece of identifying data which will be +; passed in CX. This would usually be the channel's number or CS +; control block pointer. +; Reset just needs to clear interrupts, hardware reservations, and free +; the channel. Any allocated space will be cleaned up for you by the OS. +; IN: +; The device driver's handle in BX +; The address of the status struc identifying the channel in CX +; OUT: +; Nothing +; + mov di, cx + cmp cs:[di].A4ExifCSChannelOpen, 0 + je NotOpenToReset + call StopTheChannelRunning ;Stop interrupts + mov al, cs:[di].A4ExifCSChannelIntMask ;Free the reserved + HwFreeChannel ;hardware + mov cs:[di].A4ExifCSChannelOpen, 0 ;The channel is now +NotOpenToReset: ;free + ret + ProcEnd noret + + + ProcBegin@ A4ExifUnits,far +; =========== +; Called to find how many open channels the driver will support +; In: +; Nothing +; Out: +; The total number of channels supported in AX +; + mov ax, numberofchannels + ret + ProcEnd noret + + + ProcBegin@ A4ExifOpen,far +; ========== +; Opens a device driver channel. +; Invoked after the PLIB call 'p_open(&appHandle,"LED:*",-1)'to open a +; channel to the device driver. +; In: +; OS device handle of the device driver in DX +; Pointer to the OpenEnt struc in SI +; Pointer to the IntEnt struc in BP +; DS,ES,SS point to the applications data space +; Out: +; Carry clear - BX holds the address of the open channel +; Carry set - AL holds the error number +; + cld ;Interrupts off to + pushf ;prevent multiple apps + cli ;calling open + mov si, [si].OpenNamePtr ;simultaneously + mov al, [si+1] + CharToFoldedChar ;Read the unit no. + cmp al, 'A' ;part of device name + jb OpenNameErr ;to find which channel + sub al, 'A' ;to open. eg "LED:A" + cmp al, numberofchannels + jae OpenNameErr + xor ah, ah + push dx ;Map the channel no. + mov dx, (size A4ExifStatusEnt) ;to a channel control + mul dx ;block in our CS + pop dx ;space + mov di, ax + add di, offset Channel0 ;Offset in DI + cmp cs:[di].A4ExifCSChannelOpen, 0 + je GetATickChannel ;Check to see if + popf ;channel is already + mov ax, AlreadyOpenErr ;open + jmp ChannelAlreadyOpen +GetATickChannel: + mov cs:[di].A4ExifCSChannelOpen, 1 ;Obtain a TCK channel so + mov cs:[di].A4ExifCSChannelRunning,0 ;we can poll the door state + popf +ife Asic9 + jmp GetHardwareChannel ;If HC, we don't need +else ;to set up the TCK + push ax ;routine + mov ax, ((':' shl 8)+'K') + push ax + mov ax, (('C' shl 8)+'T') ;Try to open "TCK:" + push ax ;channel with "TCK:" + mov bx, sp ;string on stack + IoOpen + jnc GotATickChannel ;TCK will call our + add sp, 6 ;door-polling function + mov ax, LockedErr ;32 times a second + jmp OpenFailed +GotATickChannel: + add sp, 6 + mov cs:[di].A4ExifCSTickHandle, ax ;Start our + push dx ;door-polling function + mov bx, ax ;running by starting + mov ax, IoFuncStart ;the "TCK:" channel + mov cx, 1 + push cx ;Frequency 1 tick + push cx ;Data irrelevant + push dx ;Handle to driver + mov cx, (InterruptVectors-Vector)/2 ;TCK function to call + push cx + mov cx, sp + IoWithWait + add sp, 8 + pop dx + jmp GetHardwareChannel +endif +OpenNameErr: + popf + mov ax, NameErr + jmp ChannelAlreadyOpen +GetHardwareChannel: ;Check the hardware + mov al, cs:[di].A4ExifCSChannelIntMask ;is available then + HwGetChannel ;reserve it + jnc CheckHardwareNowThatSIBOChannelIsOpen ;Returns with carry + mov ax, InUseErr ;clear if OK + jmp FreeTckAndExit +FreeTckAndChannelHardware: + mov al, cs:[di].A4ExifCSChannelIntMask + HwFreeChannel + mov ax, DeviceErr +FreeTckAndExit: +if Asic9 + push ax + mov bx, cs:[di].A4ExifCSTickHandle + IoClose + pop ax +endif +OpenFailed: + mov cs:[di].A4ExifCSChannelOpen, 0 +ChannelAlreadyOpen: + stc +OpenExit: + ret +CheckHardwareNowThatSIBOChannelIsOpen: + ProcId ;Set up the calling + mov cs:[di].A4ExifCSProcessId, ax ;process ID + mov cs:[di].A4ExifCSChanReadCompleted, 0 + call CheckHardwarePresent ;Returns with carry + jc FreeTckAndChannelHardware ;clear if successful + mov cx, (size A4ExifEnt) ;Allocate a control + HeapAllocateCell ;block in our app's + jc FreeTckAndChannelHardware ;data space + mov bx, ax + push bx ;IoAddHandler trashes BX + mov al, (VectorHandler-Vector)/2 ;Set up our wait handler + IoAddHandler ;Leaves the address of + pop bx ;handler in AX + jnc GotHandler + push ax ;If no handler, open fails + HeapFreeCell + pop ax + jmp FreeTckAndChannelHardware +GotHandler: + mov [bx].A4ExifDSStatusEntPtr, di + mov [bx].A4ExifDSHandlerPtr, ax + mov [bx].A4ExifDSStatusPtr, 0 + mov [bx].A4ExifDSIo.ChanNext, bx + mov [bx].A4ExifDSIo.ChanSignature, IoChanSignature + mov [bx].A4ExifDSIo.ChanLibHandle, dx + mov cx, di ;IoRequestReset takes + xchg bx, dx ;the device handle in + IoRequestReset ;BX and the channel + xchg bx, dx ;handle in CX + xor ax, ax + call StartTheChannelRunning +ReturnCLC: + clc + ret + ProcEnd + + +if Asic9 + ProcBegin@ A4ExifTickInt,far +; ============= +; This function is called by the tick handler on every tick of +; the system clock. This happens 32 times a second. +; The operating system will call a device driver to hold when memory is +; being moved and when the machine is being powered down. It will not +; call the device driver when the pack doors are opened. +; Opening the pack doors will cause power to the peripheral to be cut, +; and therefore the driver needs to be held in the way it would be if +; the machine powered down. Only for Asic9 based machines. +; This function checks the state of the doors on every tick and calls +; Hold and resume when it sees the status of the doors change. +; IN: +; The state of the door in SI +; OUT: +; Nothing +; + cmp si, DoorOpen ;Is the door open + je TheDoorIsOpen ;or closed? + cmp HoldFlag, 2 ;Closed Door, HoldFlag=2 + je NeedToDoTheResume ;means we do a resume + ret ;Closed Door, HoldFlag!=2 +NeedToDoTheHold: + mov HoldFlag, 2 + jmp A4HoldFromTick +NeedToDoTheResume: + mov HoldFlag, 0 + jmp A4ResumeFromTick +TheDoorIsOpen: + xor ax, ax + cmp HoldFlag, al + je NeedToDoTheHold + ret + ProcEnd noret +endif + + + ProcBegin@ A4ExifHandler,far +; ============= +; When an application is waiting within an iowait and a signal is +; generated then before passing that signal to the application the +; OS first runs any wait handlers belonging to the device driver +; channels that the application has open. +; The interrupt routine can generate a signal but cannot fill in any +; status words or pass values back to the application because the +; applications DS space is not available. The handler can consume a +; signal generated by an interrupt and then fill any status words +; before re-signalling the application. A handler always has access +; to the application's DS space. The wait handler can consume the +; signal which is then no longer passed back to the application. +; IN: +; Pointer to our control block in applications DS space in BX +; DS,ES,SS point at application's data space +; OUT: +; Carry clear - do not consume the signal, signal not for us +; Carry set - consume the signal, re-enable handler if AL +; non-zero else don't re-enable handler if AL=0. +; + cld + pushf + cli + mov di, [bx].A4ExifDSStatusEntPtr ;Is the signal for us? + cmp cs:[di].A4ExifCSChanReadCompleted, 1 + jne ExitHandlerSignalNotForUs ;If it is, copy + mov cs:[di].A4ExifCSChanReadCompleted, 0 ;the values read in + mov al, cs:[di].A4ExifCSA1Value ;the interrupt + mov ah, cs:[di].A4ExifCSA2Value ;routine back to + mov di, [bx].A4ExifDSA1Ptr ;the application + mov [di], al ;Asynchronous read + mov di, [bx].A4ExifDSA2Ptr ;has been completed + mov [di], ah + xor di, di + xchg [bx].A4ExifDSStatusPtr, di ;Clear the status + mov word ptr [di], 0 ;word + popf + IoSignal + xor ax, ax + stc ;STC and AL!=0 => + ret ;consume signal and +ExitHandlerSignalNotForUs: ;don't re-enable + popf ;handler + clc + ret + ProcEnd + + +StrategyVectorTable label word + dw offset A4ExifDefault ;StrategyPanic + dw offset A4ExifRead ;StrategyRead ie P_FREAD + dw offset A4ExifWrite ;StrategyWrite ie P_FWRITE + dw offset A4ExifClose ;StrategyClose ie P_FCLOSE + dw offset A4ExifCancel ;StrategyCancel ie P_FCANCEL + dw offset A4ExifDefault ;StrategyAttach + dw offset A4ExifDefault ;StrategyDetach + dw offset A4ExifSet ;StrategySet ie P_FSET + dw offset A4ExifSense ;StrategySense ie P_FSENSE + + + ProcBegin@ A4ExifStrategy,far +; ============== +; Called by the operating system when an I/O request is made on +; the device driver. +; Calls to this funcion from an owning application will usually take +; the form p_ioc(pcb,func,&Stat,&A1,&A2); +; The strategy function is called with a function number specifying +; the action which the driver is to take, a status word to fill when +; the action is complete, and two arguments A1 and A2. +; All strategy functions must complete with a signal to the application. +; Functions can be asynchronous and need not complete immediately. +; IN: +; Pointer to our control block in the applications DS in BX +; Device driver handle in DX +; Pointer to the RqEnt struct in SI +; Pointer to a IntEnt struct in BP +; DS,ES,SS point at the applications data space +; OUT: +; Returned value in AX +; Must call IoSignal somewhere to signal completion +; of the I/O request. +; + mov ax, [si].RqFunction ;Get the function number + mov dx, [si].RqA1Ptr ;DX holds the first argument + mov di, [si].RqStatusPtr ;for convenience + mov word ptr [di], PendingErr ;Status word holds + shl ax, 1 ;E_FILE_PENDING + mov di, ax + push StrategyVectorTable[di] ;Jump to required function + mov di, [bx].A4ExifDSStatusEntPtr ;with our CS control block + retn ;pointer in DI +A4ExifDefault: + IoRoot + ret +ExitWithCompletionStatusZero: + xor ax, ax ;Common exit points +ExitWithOtherCompletionStatus: + mov di, [si].RqStatusPtr + mov word ptr [di], ax + IoSignal +ExitStillPending: + xor ax, ax + clc + ret + ProcEnd noret + + +; STRATEGY VECTOR TABLE FUNCTIONS +; =============================== +;IN: +; DX holds the pointer to the first argument in 'p_iow(...)' call +; BX holds the address of the open channel control block +; CS:DI holds the address of status struc identifying the open channel +; + + ProcBegin@ A4ExifRead,far +; ========== +; Strategy vector table function that handles asynchronous byte reads +; from the LEDs and switches. +; The corresponding PLIB call is p_ioc(pcb,P_FREAD,&Stat,&Arg1,&Arg2); +; The request is completed when the interrupt routine signals the +; handler which in turn signals the application passing back the values +; read at the time of the interrupt through the A1Ptr and A2Ptr. +; IN: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; A1 (pointer to Arg1) in DX +; OUT: +; Jumps to common exit point +; Panics if multiple requests +; + cmp [bx].A4ExifDSStatusPtr, 0 ;Panic if we already + jne PanicPending ;have an I/O read request + pushf ;pending on the channel + cli ;Disable interrupts + mov cs:[di].A4ExifCSChanReadCompleted, 2 + mov ax, [si].RqA1Ptr + mov [bx].A4ExifDSA1Ptr, ax ;Store the locations to + mov ax, [si].RqA2Ptr ;put the data when we get it + mov [bx].A4ExifDSA2Ptr, ax + mov di, [si].RqStatusPtr + mov [bx].A4ExifDSStatusPtr, di ;DI holds the address + mov word ptr [di], PendingErr ;of status word and we + popf ;signal that we are waiting + mov bx, [bx].A4ExifDSHandlerPtr ;for completion of read + mov cl, 1 + IoEnableHandler ;Enable Wait Handler + jmp short ExitStillPending ;No IoSignal because +PanicPending: ;we are still waiting + mov al, PanicIoPending + ProcPanic + ProcEnd noret + + + ProcBegin@ A4ExifWrite,far +; =========== +; This function sets the state of the LEDs. +; It completes immediately after setting the state as it has nothing +; to wait for. +; Write is the same as set. +; IN: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; A1 in DX +; OUT: +; Jumps to Set +; + jmp WriteAndSetAreTheSame + ProcEnd noret + + + ProcBegin@ A4ExifClose,far +; =========== +; Handles the request to close a channel. +; called by the PLIB call p_iow(pcb,P_FCLOSE) or p_close(pcb) +; IN: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; OUT: +; Jumps to common exit point +; + call StopTheChannelRunning ;Stop interrupts +if Asic9 + push bx ;Close down the + mov bx, cs:[di].A4ExifCSTickHandle ;"TCK:" channel + IoClose + pop bx +endif + push bx + mov ax, [bx].A4ExifDSIo.ChanLibHandle ;Remove the wait + push ax ;handler + mov bx, [bx].A4ExifDSHandlerPtr + IoRemoveHandler + cmp cs:[di].A4ExifCSChanReadCompleted, 0 ;If the interrupt + je NoSignalToConsumeFromInterrupt ;has signalled the + IoWaitForSignal ;handler we need to +NoSignalToConsumeFromInterrupt: ;consume its signal + pop bx ;now the handler + mov cx, di ;has been removed + IoRequestResetCancel + pop bx ;No longer need reset + HeapFreeCell ;Free our control + mov al, cs:[di].A4ExifCSChannelIntMask ;block in app's DS + HwFreeChannel + mov cs:[di].A4ExifCSChannelOpen, 0 + jmp ExitWithCompletionStatusZero ;To signal completion + ProcEnd noret ;of close request + + + ProcBegin@ A4ExifCancel,far +; ============ +; Cancel any pending asynchronous read. +; Called by the PLIB function p_iow(pcb,P_FCANCEL); +; In: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; Out: +; Jumps to common exit point +; + pushf + cli + cmp [bx].A4ExifDSStatusPtr, 0 ;Check that there is + je NothingToCancel ;a request pending + push bx + mov bx, [bx].A4ExifDSHandlerPtr + sub cl, cl + IoEnableHandler ;Disable Wait Handler + pop bx + cmp cs:[di].A4ExifCSChanReadCompleted, 1 + jne NoSignalFromInterrupt ;To consume any stray + IoWaitForSignal ;signal from the +NoSignalFromInterrupt: ;interrupt routine + mov cs:[di].A4ExifCSChanReadCompleted, 0 + xor di, di ;To signal completion + xchg di, [bx].A4ExifDSStatusPtr ;of the outstanding + mov word ptr [di], CancelErr ;async read request + IoSignal ;Signal to p_waitstat +NothingToCancel: + popf + jmp ExitWithCompletionStatusZero ;To signal completion + ProcEnd noret ;of the cancel request + + + ProcBegin@ A4ExifSet,far +; ========= +; Write a value to the LED latch. +; Can be called by the PLIB call p_iow(pcb,P_FSET,&Arg1); where A1 +; is an unsigned byte. +; Write is the same as set. +; IN: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; A1 (pointer to Arg1) in DX +; OUT: +; Jumps to common exit point +; +WriteAndSetAreTheSame: + pushf + cli + mov al, cs:[di].A4ExifCSChannelSelect ;Select our SIBO + HwSelectChannel ;serial channel + push ax ;Store old channel + mov bx, dx + mov dl, U5OUTPUT_LATCH ;DX (now BX) points + mov al, [bx] ;to the value to + call OutputByte ;output to our + pop ax ;peripheral + HwSelectChannel ;Return old channel + popf + jmp ExitWithCompletionStatusZero ;To signal completion + ProcEnd noret ;of set request + + + ProcBegin@ A4ExifSense,far +; =========== +; Reads the state of the LEDS and Switches. +; Can be called from PLIB using p_iow(pcb,P_FSENSE,&Arg1,&Arg2) +; Where Arg1 and Arg2 are unsigned bytes. +; In: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; A1 (pointer to Arg1) in DX +; Out: +; Jumps to common exit point +; + pushf + cli ;Select our SIBO + mov al, cs:[di].A4ExifCSChannelSelect ;serial channel + HwSelectChannel ;Store old channel + push ax + mov bx, dx ;DX (now BX) points + mov dl, U4STATUS_BUFFER ;to the variable in + call InputByte ;which to place the + mov [bx], al ;value read from U4. + mov bx, [si].RqA2Ptr ;BX now points to + mov dl, U3INPUT_BUFFER ;the variable in + call InputByte ;which to place the + mov [bx], al ;value read from U3. + pop ax + HwSelectChannel ;Return old channel + popf + jmp ExitWithCompletionStatusZero ;To signal completion + ProcEnd noret ;of a sense request + + +; LOCAL DEVICE DRIVER FUNCTIONS +; ============================= + + ProcBegin@ InputByte +; ========= +; Interrupts must be off prior to the call to this function. +; IN: +; DL has address to which Asic4 is to write +; AL holds the value to output +; + mov al, (SerialWriteSingle or A4Address) + SBUSY + SCONTOUT + mov al, dl + SBUSY + SDATAOUT + mov al, (SerialReadSingle or A4Data) + SBUSY + SCONTOUT + SBUSY + SDATAIN + ret + ProcEnd noret + + + ProcBegin@ OutputByte +; ========== +; Interrupts must be off prior to the call to this function. +; IN: +; DL has address to which Asic4 is to write +; AL has the value to output +; + push ax + mov al, (SerialWriteSingle or A4Address) + SBUSY + SCONTOUT + mov al, dl + SBUSY + SDATAOUT + mov al, (SerialWriteSingle or A4Data) + SBUSY + SCONTOUT + SBUSY + XNOP + pop ax + SDATAOUT + ret + ProcEnd noret + + + ProcBegin@ IntVec0,far +; =========== +; Interrupt on serial channel0 +; Calls Comint with channel control block pointer in DI +; + mov di, offset Channel0 + jmp ComInt + ProcEnd noret + + +if Corporate or S3c + ProcBegin@ IntVec1,far +; =========== +; Interrupt on serial channel1 +; Calls Comint with channel control block pointer in DI +; + mov di, offset Channel1 + jmp ComInt + ProcEnd noret + + + ProcBegin@ IntVec2,far +; =========== +; Interrupt on serial channel2 +; Calls Comint with channel control block pointer in DI +; + mov di, offset Channel2 +; FALL THROUGH + ProcEnd noret +endif + + + ProcBegin@ ComInt,far +; ========== +; The common interrupt service routine code. +; When an interrupt occurs, the first task is to read the status +; buffer of latch U4. The subsequent action is dependent on the +; postion of switches S1 and S2. For the purposes of this example, +; the four posibilities for the switch values correspond somewhat +; arbitrarily to four different byte values that are written to U5. +; in the 8086, interrupts cannot occur while in an interrupt routine. +; If an asynchronous read is pending then the handler is signalled. +; IN: +; Channel's CS based control block pointer in DI +; + cmp cs:[di].A4ExifCSChanReadCompleted, 2 ;Only if 2 do we have + jne NotAsynchronousRead ;asynch read completed + mov cs:[di].A4ExifCSChanReadCompleted, 1 + mov bx, cs:[di].A4ExifCSProcessId ;Signals completion + IoSignalByPidNoReSched ;of read to OS so as +NotAsynchronousRead: ;to invoke handler + mov al, cs:[di].A4ExifCSChannelSelect + HwSelectChannel + push ax + mov dl, U3INPUT_BUFFER + call InputByte + mov cs:[di].A4ExifCSA2Value, al ;LED byte + mov dl, U4STATUS_BUFFER + call InputByte + mov cs:[di].A4ExifCSA1Value, al ;Status byte + and al, INTERRUPT_STATUS_MASK + xchg al, SwitchStatus + cmp SwitchStatus, S2S3_ON ;S2 and S3 on => turn + je AllLEDsOn ;on alternate LEDs + cmp SwitchStatus, S2S3_OFF ;S2 and S3 off => not + je AllLEDsOff ;the alternate LEDs + cmp SwitchStatus, S2_ONLY ;S2 on, S3 off => turn + je TopLEDsOn ;on top four LEDs + cmp SwitchStatus, S3_ONLY ;S3 on, S2 off => turn + je BottomLEDsOn ;on bottom four LEDs +ErrorInSwitchStatusByte: + jmp ClearInterruptAndReschedule +AllLEDsOn: + mov al, SOME_LEDS_ON + jmp OutputLEDByte +AllLEDsOff: + mov al, SOME_LEDS_OFF + jmp OutputLEDByte +TopLEDsOn: + mov al, TOP_LEDS_ON + jmp OutputLEDByte +BottomLEDsOn: + mov al, BOTTOM_LEDS_ON +OutputLEDByte: + mov dl, U5OUTPUT_LATCH + call OutputByte +ClearInterruptAndReschedule: + mov dl, INTERRUPT_LATCH + call OutputByte +if Asic9 ;A write to this location + out A9BNonSpecificEoiW, al ;informs the interrupt +else ;controller that the + out A1NonSpecificEoi, al ;installed interrupt +endif ;service routine has + pop ax ;finished + HwSelectChannel + clc ;Reschedule if necessary + ret + ProcEnd noret + + + ProcBegin@ StartInterrupts +; =============== +; Start interrupts assuming interrupts are +; off prior to call. +; The EPOC GenSetRevector service loads in +; a user-specified interrupt service routine +; located at the address given in cx:bx +; (segment cx, offset bx) for the interrupt +; vector number given in AL. Note that the +; variable A4ExifCSChannelIntVec holds the +; name of the appropriate required interrupt +; vector routine for the channel. +; IN: +; Our CS control block pointer in DI +; OUT: +; Nothing +; + mov al, cs:[di].A4ExifCSChannelIntNum ;Get the OS to call + mov cx, cs ;the function in + push bx ;CS:BX every time + mov bx, cs:[di].A4ExifCSChannelIntVec ;that the interrupt + GenSetRevector ;whose number is in + pop bx ;AL occurs +ife Asic9 + in al, A1InterruptMask + or al, cs:[di].A4ExifCSChannelIntMask ;Set the mask + out A1InterruptMask, al ;location so as ;interrupt +else ;to enable that + in al, A9BInterruptMaskRW ;interrupt + or al, cs:[di].A4ExifCSChannelIntMask + out A9BInterruptMaskRW, al + +endif + ret + ProcEnd noret + + + ProcBegin@ StopInterrupts +; ============== +; Stop interrupts assuming that interrupts are off +; The EPOC GenResetRevector OS service +; replaces the previously loaded user-specified +; interrupt service routine with the original +; routine and interrupt mask for the vector +; given in AL. +; IN: +; Our CS control block pointer in DI +; OUT: +; Nothing +; +ife Asic9 + in al, A1InterruptMask ;Disable the + mov ah, cs:[di].A4ExifCSChannelIntMask ;interrupt + not ah + and al, ah + out A1InterruptMask, al +else + in al, A9BInterruptMaskRW + mov ah, cs:[di].A4ExifCSChannelIntMask + not ah + and al, ah + out A9BInterruptMaskRW, al +endif + mov al, cs:[di].A4ExifCSChannelIntNum ;Return the interrupt + GenResetRevector ;vector to the OS + ret ;default + ProcEnd noret + + + ProcBegin@ StartTheChannelRunning +; ====================== +; Starts the hardware and interrupts going +; If the hardware is aready running then there is nothing to do +; Must check that the hardware has not vanished before restarting it +; IN: +; Our CS control block pointer in DI +; OUT: +; Nothing +; + pushf + cli + cmp byte ptr cs:[di].A4ExifCSChannelRunning, 0 + jne ChannelAlreadyRunning + call CheckHardwarePresent + jc HardwareNotPresent + mov al, cs:[di].A4ExifCSChannelSelect + HwSelectChannel + push ax + mov al, (SerialWriteSingle or A4Control) ;Switch on the + SBUSY ;output latch U5 + SCONTOUT ;by asserting + mov al, U5_ENABLE_ON ;the ASIC4 LBO line + SBUSY ;(LBO is inverted) + SDATAOUT + xor ax,ax + mov dl, INTERRUPT_LATCH ;Clear any pending + call OutputByte ;interrupt on the + mov dl, U5OUTPUT_LATCH ;peripheral + call OutputByte ;Preset the LEDs + pop ax ;to all off + HwSelectChannel + call StartInterrupts + mov cs:[di].A4ExifCSChannelRunning, 1 +ChannelAlreadyRunning: + popf + clc + ret +HardwareNotPresent: + popf + stc + ret + ProcEnd noret + + + ProcBegin@ StopTheChannelRunning +; ===================== +; Stops the hardware and interrupts +; Checks to see if the hardware is really running to start with +; IN: +; Our CS control block pointer in DI +; OUT: +; Nothing +; + pushf + cli + cmp byte ptr cs:[di].A4ExifCSChannelRunning, 0 + je ChannelNotRunning + mov al, cs:[di].A4ExifCSChannelSelect + HwSelectChannel + push ax + mov al, (SerialWriteSingle or A4Control) + SBUSY + SCONTOUT + mov al, U5_ENABLE_OFF + SBUSY + SDATAOUT + xor ax, ax + mov dl, U5OUTPUT_LATCH + call OutputByte + pop ax + HwSelectChannel + call StopInterrupts + mov cs:[di].A4ExifCSChannelRunning, 0 +ChannelNotRunning: + popf + ret + ProcEnd noret + + + ProcBegin@ CheckHardwarePresent +; ==================== +; Used to determine whether the correct hardware is present +; on the successfully procured serial channel. +; IN: +; CS control block pointer in DI +; OUT: +; Carry clear - correct hardware is there +; Carry set - wrong or no hardware +; + pushf + cli ;Select the correct + mov al, cs:[di].A4ExifCSChannelSelect ;SIBO channel that + HwSelectChannel ;the peripheral is + push ax ;attached to + HwNullFrame + mov al,(SerialSelect or Asic4Id) + SBUSY ;First look for an + SCONTOUT ;ASIC4 at the other + XNOP ;end of the link + SBUSY + SDATAIN ;If the returned + test al,al ;value is non-zero + je ConnectionFailedA4NotPresent ;we have an ASIC4 + mov al,(SerialReadSingle or A4InfoR) + SBUSY ;Now see if we have + SCONTOUT ;the right peripheral + XNOP ;XNOP allows the busy + SBUSY ;signal to come + SDATAIN ;through for the wait + and al, A4PERIPH_MASK + cmp al, EXTENDED_INFO_BYTE ;Mask out the bottom + jne ConnectionFailed ;four bits as the + pop ax ;upper four contain + HwSelectChannel ;the peripheral ID + popf + clc ;If it is our hardware + ret ;exit with carry clear +ConnectionFailedA4NotPresent: + mov al,(SerialSelect or Asic5NormalId) ;Its not an ASIC4 + SBUSY ;peripheral + SCONTOUT ;By selecting a non + XNOP ;ASIC4 as an ASIC4, + SDATAIN ;we effectively + test al,al ;disable whatever is + jne ConnectionFailed ;out there so we do + mov al,(SerialSelect or Asic5PackId) ;a select for all + SBUSY ;possibilities so + SCONTOUT ;that we don't end + XNOP ;up disabling + SDATAIN ;anything that we + test al,al ;can't control. + jne ConnectionFailed + mov al,(SerialSelect or Asic8Id) ;Modem chip id + SBUSY + SCONTOUT + XNOP + SDATAIN +ConnectionFailed: + pop ax + HwSelectChannel + popf + stc + ret + ProcEnd noret + + EndCodeSeg + stack segment stack para 'data' + stack ends + end A4ExifLDD + + + + + diff --git a/code/HDK/A4TEST.C b/code/HDK/A4TEST.C new file mode 100644 index 0000000..fe02339 --- /dev/null +++ b/code/HDK/A4TEST.C @@ -0,0 +1,411 @@ +/* + A4TEST.C - Testing the functionality ASIC4 Example + Interface Board device driver A4Exif.ldd + A comprehensive test program which checks + I/O request functionality of A4Exif.ldd + + Written by Mal, January 31, 1995 +*/ + +#include +#include + +#define BUFLEN 1 +#define MAXBUF 8 +#define SERREAD_TIMEOUT 20L +#define FLASH_TIME 1L + +GLREF_D TEXT *DatCommandPtr; +GLREF_D VOID *winHandle; +LOCAL_D VOID *serH; /* serial channel handle */ +LOCAL_D VOID *timH; /* timer channel handle */ +LOCAL_D WORD serReadStat; /* serial channel status word */ +LOCAL_D WORD timStat; /* timer channel status word */ +LOCAL_D WORD keyStat; /* console channel status word */ +LOCAL_D P_CON_KBREC kbrec; +LOCAL_D TEXT buf[40]; +LOCAL_D UBYTE wowbuf[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; +LOCAL_D TEXT *head="LED: "; + + +LOCAL_C VOID PrintHeader(VOID) +/* Prints the title at the start of the program */ + { + p_printf("*********************"); + p_printf("Welcome to the ASIC 4"); + p_printf("Example IF board test"); + p_printf("program"); + p_printf("*********************"); + p_printf(".....\n"); + p_getch(); + } + +LOCAL_C VOID PrintInstructions(VOID) + { + p_printf("Type in the test number"); + p_printf(" 0 => Alternate flash"); + p_printf(" 1 => Asynchronous read"); + p_printf(" 2 => Sense"); + p_printf(" 3 => Set"); + p_printf(" 4 => Memory"); + p_printf(" q => Quit"); + p_printf(" ....."); + } + +LOCAL_C VOID LoadLdd(VOID) +/* Loads the LDD A4Exif.ldd from anywhere and exits on failure */ + { + TEXT filename[128]; + INT ret; + + p_printf("\nLOADLDD=>"); + p_fparse("A4EXIF.LDD",DatCommandPtr,&filename[0],NULL); + if ((ret=p_loadldd(&filename[0]))<0) + { + p_printf("A4Exif.ldd failed to load"); + if (ret==E_FILE_NXIST) + { + p_printf("Device does not exist"); + p_getch(); + p_exit(0); + } + else if (ret==E_FILE_EXIST) + { + p_printf("Device is already loaded"); + p_getch(); + } + else if (ret==E_GEN_NOMEMORY) + { + p_printf("Not enough memory available"); + p_getch(); + p_exit(0); + } + else + { + p_printf("Unknown error %d on p_loadldd",ret); + p_getch(); + p_exit(0); + } + } + else + { + p_printf("Successfully loaded A4Exif.ldd\n"); + p_getch(); + } + } + +LOCAL_C VOID UnloadLdd(VOID) +/* Removes the LDD A4Exif.ldd */ + { + INT ret; + + p_printf("\nUNLOADLDD=>"); + if ((ret=p_devdel("LED",E_LDD))!=0) + { + p_printf("A4Exif.ldd failed to unload"); + if (ret==E_FILE_DEVICE) + p_printf("The device driver is not loaded"); + else if (ret==E_GEN_INUSE) + p_printf("Driver is open and cannot be deleted"); + else + p_printf("Unknown error %d on p_devdel",ret); + p_getch(); + } + else + { + p_printf("Successfully deleted A4Exif.ldd"); + p_getch(); + } + } + +LOCAL_C VOID OpenPort(VOID) +/*Opens a serial port of the A4Example IF on the host machine*/ + { + INT ret, seropen; + + p_printf("\nOPENPORT=>"); +DoAgain: + p_printf("Type in the serial\r\nport to open"); + p_printf("eg A => port A"); + p_printf(".....\n"); + ret=p_toupper(p_getch()); + *(head+4)=ret; + p_printf("%s",head); + p_sleep(5L); + if ((seropen=p_open(&serH,head,-1))<0) + {/* Failed to open */ + p_atos(&buf[0],"p_open on port %c has failed",ret); + p_printf("%s\n",&buf[0],seropen); + p_errs(buf,seropen); + p_printf("%s\n",&buf[0]); + p_getch(); + goto DoAgain; + } + else + {/* Succeeded in opening */ + p_atos(&buf[0],"Successfully opened port %c",ret); + p_printf("%s",&buf[0]); + p_printf(".....\n"); + p_getch(); + } + } + +LOCAL_C VOID ClosePort(VOID) + { + INT ret; + + p_printf("\nCLOSEPORT=>"); + if ((ret=p_close(serH))!=0) + p_printf("Error in closing port"); + else + p_printf("Successfully closed port"); + p_getch(); + } + +LOCAL_C VOID SensePort(VOID) + { + UBYTE A1,A2; + + p_printf("\nSENSEPORT=>"); + p_iow(serH,P_FSENSE,&A1,&A2); + p_printf("Status byte: 0x%x",A1); + p_printf("LED byte: 0x%x",A2); + p_getch(); + } + +LOCAL_C INT SetPort(VOID) + { + UBYTE key; + + p_printf("\nSETPORT=>"); + p_printf("Type a key"); + p_printf("ESCAPE to exit\r\n"); + if ((key=p_getch())==E_KEY_ESCAPE) + { + key=0x00; + p_iow(serH,P_FSET,&key); + return(-1); + } + else + { + p_printf("Output byte is 0x%x",key); + p_iow(serH,P_FSET,&key); + return(0); + } + } + +LOCAL_C VOID OpenTimer(VOID) + { + if (p_open(&timH,"TIM:",-1)<0) + {/* Error in opening timer */ + p_printf("Cannot open timer channel\n"); + p_getch(); + } + } + +LOCAL_C VOID QueueTimer(ULONG timeouttime) + { + p_ioc4(timH,P_FRELATIVE,&timStat,&timeouttime); + } + +LOCAL_C VOID CancelTimer(VOID) + { + p_iow(timH,P_FCANCEL); + p_waitstat(&timStat); + } + +LOCAL_C VOID QueueSerRead(UBYTE *statusptr,UBYTE *ledptr) + { + p_ioc5(serH,P_FREAD,&serReadStat,statusptr,ledptr); + } + +LOCAL_C VOID CancelSerRead(VOID) + { + p_iow(serH,P_FCANCEL); + p_waitstat(&serReadStat); + } + +LOCAL_C VOID QueueKeypress(P_CON_KBREC *keybrec) + { + p_ioc4(winHandle,P_FREAD,&keyStat,keybrec); + } + +LOCAL_C VOID AsynchRead(VOID) + { + UBYTE b_led; + UBYTE b_status; + + p_printf("ASYNCH READ\r\n"); + OpenTimer(); + QueueTimer(SERREAD_TIMEOUT); + QueueSerRead(&b_status,&b_led); + QueueKeypress(&kbrec); + FOREVER + { + p_iowait(); + if (keyStat!=E_FILE_PENDING) + {/* Keypress received */ + p_printf("KEYPRESS"); + if (kbrec.keycode==E_KEY_ESCAPE) + { + CancelSerRead(); + CancelTimer(); + b_led=0x00; + p_iow(serH,P_FWRITE,&b_led); + break; + } + else + { + /* Do nothing - requeue keypress */ + QueueKeypress(&kbrec); + continue; + } + } + else if (serReadStat!=E_FILE_PENDING) + { + p_printf("SERIAL READ COMPLETED"); + CancelTimer(); + p_printf("Status byte is => 0x%x",b_status); + p_printf("LED byte is => 0x%x",b_led); + QueueTimer(SERREAD_TIMEOUT); + QueueSerRead(&b_status,&b_led); + continue; + } + else if (timStat!=E_FILE_PENDING) + { + p_printf("TIMEOUT"); + CancelSerRead(); + QueueSerRead(&b_status,&b_led); + QueueTimer(SERREAD_TIMEOUT); + continue; + } + else + {/* Error - missing status word so fatal error */ + p_printf("***Stray status word***"); + break; + } + } + p_close(timH); + } + +LOCAL_C VOID AlternateFlash(VOID) + { + UBYTE b_led; + INT i=0; + + p_printf("ALTERNATE FLASH\r\n"); + p_printf("Hit ESCAPE to exit"); + OpenTimer(); + QueueTimer(FLASH_TIME); + QueueKeypress(&kbrec); + FOREVER + { + p_iowait(); + if (keyStat!=E_FILE_PENDING) + {/* Keypress received */ + if (kbrec.keycode==E_KEY_ESCAPE) + { + CancelTimer(); + b_led=0x00; + p_iow(serH,P_FWRITE,&b_led); + break; + } + else + { + /* Do nothing - requeue keypress */ + QueueKeypress(&kbrec); + continue; + } + } + else if (timStat!=E_FILE_PENDING) + {/* Timer finished */ + if (i\r\n\t%x bytes\r\n",fbytes); + p_print("Free Segments =>\r\n\t%d\r\n",p_sgfree()); + p_getch(); + } + +LOCAL_C VOID MemoryTest(VOID) + { + CheckMemory("OpenPort"); + ClosePort(); + CheckMemory("ClosedPort"); + UnloadLdd(); + CheckMemory("UnoadedLdd"); + LoadLdd(); + CheckMemory("LoadLdd"); + OpenPort(); + CheckMemory("OpenPort"); + p_printf("End of Memory Test"); + } + +GLDEF_C VOID main(VOID) +/* +*/ + { + INT ret,set=0; + + PrintHeader(); + LoadLdd(); + OpenPort(); +Start: + PrintInstructions(); + if ((ret=p_getch())=='0') + AlternateFlash(); + else if (ret=='1') + AsynchRead(); + else if (ret=='2') + SensePort(); + else if (ret=='3') + { + while (set>=0) + set=SetPort(); + set=0; + } + else if (ret=='4') + MemoryTest(); + else if (ret=='q') + { + ClosePort(); + UnloadLdd(); + p_exit(0); + } + else + goto Start; + goto Start; + } + + + + + + + diff --git a/code/HDK/A4TEST.PR b/code/HDK/A4TEST.PR new file mode 100644 index 0000000..b250926 --- /dev/null +++ b/code/HDK/A4TEST.PR @@ -0,0 +1,6 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile a4test +#link a4test diff --git a/code/HDK/EPOC.INC b/code/HDK/EPOC.INC new file mode 100644 index 0000000..4f3d8c3 --- /dev/null +++ b/code/HDK/EPOC.INC @@ -0,0 +1,15 @@ + .xlist +; Include file - EPOC.INC +; Epoc/Os standard include file +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +EPOC_INC equ 1 +; + include ..\inc\epocdef.inc + include ..\inc\epocmac.inc + include ..\inc\epocpan.inc + .list diff --git a/code/HDK/EPOCLIB.INC b/code/HDK/EPOCLIB.INC new file mode 100644 index 0000000..62e98e8 --- /dev/null +++ b/code/HDK/EPOCLIB.INC @@ -0,0 +1,284 @@ + .xlist +; Include file - EPOCLIB.INC +; Epoc/Os plib standard include file. +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +EPOCLIB_INC equ 1 +; +_TANDW = 0 +ifdef LATTICE +CodeSeg macro +pgroup group prog +PGROUP equ +prog segment byte public 'prog' + assume cs:pgroup + endm +EndCodeSeg macro +prog ends + endm +DataSeg macro +dgroup group data,udata +DGROUP equ +data segment word public 'data' + assume ds:dgroup,es:dgroup,ss:dgroup + endm +EndDataSeg macro +data ends + endm +UDataSeg macro +udata segment word public 'data' + endm +EndUDataSeg macro +udata ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN NAME:TYPE + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC NAME +NAME label TYPE + ENDM +GLREF_C MACRO NAME + EXTRN NAME:NEAR + ENDM +endif +; +ifdef TURBOC +_TANDW = 1 +CodeSeg macro +PGROUP group _TEXT +pgroup equ +_TEXT segment byte public 'CODE' + assume cs:PGROUP + endm +EndCodeSeg macro +_TEXT ends + endm +DataSeg macro +DGROUP group _DATA,_BSS +dgroup equ +_DATA segment word public 'DATA' + assume ds:DGROUP,es:DGROUP,ss:DGROUP + endm +EndDataSeg macro +_DATA ends + endm +UDataSeg macro +_BSS segment word public 'BSS' + endm +EndUDataSeg macro +_BSS ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN _&NAME:TYPE +NAME EQU _&NAME + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC _&NAME +_&NAME label TYPE +NAME EQU _&NAME + ENDM +GLREF_C MACRO NAME + EXTRN _&NAME:NEAR +NAME EQU _&NAME + ENDM +endif +ifdef WATCOMC +REG_PARAM equ 1 +ifdef _MSC +_TANDW = 1 +endif +CodeSeg macro +PGROUP group _TEXT +pgroup equ +_TEXT segment byte public 'CODE' + assume cs:PGROUP + endm +EndCodeSeg macro +_TEXT ends + endm +DataSeg macro +DGROUP group _DATA,_BSS +dgroup equ +_DATA segment word public 'DATA' + assume ds:DGROUP,es:DGROUP,ss:DGROUP + endm +EndDataSeg macro +_DATA ends + endm +UDataSeg macro +_BSS segment word public 'BSS' + endm +EndUDataSeg macro +_BSS ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN NAME&_:TYPE +NAME EQU NAME&_ + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC NAME&_ +NAME&_ label TYPE +NAME EQU NAME&_ + ENDM +GLREF_C MACRO NAME + EXTRN NAME&_:NEAR +NAME EQU NAME&_ + ENDM +endif +ifdef JPIC +REG_PARAM equ 1 +ifdef _MSC +_TANDW = 1 +endif +CodeSeg macro +_TEXT segment byte public 'CODE' + assume cs:_TEXT + endm +EndCodeSeg macro +_TEXT ends + endm +DataSeg macro +DGROUP group _DATA,_BSS +dgroup equ +_DATA segment word public 'DATA' + assume ds:DGROUP,es:DGROUP,ss:DGROUP + endm +EndDataSeg macro +_DATA ends + endm +UDataSeg macro +_BSS segment word public 'BSS' + endm +EndUDataSeg macro +_BSS ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN _&NAME:TYPE +NAME EQU _&NAME + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC _&NAME +_&NAME label TYPE +NAME EQU _&NAME + ENDM +GLREF_C MACRO NAME + EXTRN _&NAME:NEAR +NAME EQU _&NAME + ENDM +endif +; +LOCAL_D MACRO NAME,TYPE +NAME label TYPE + ENDM +; +ProcBegin macro _Name,_Type,_Registers +ifdef TURBOC + ProcBeginBody _&_Name,_Type,_Registers +endif +ifdef JPIC + ProcBeginBody _&_Name,_Type,_Registers +endif +ifdef WATCOMC + ProcBeginBody _Name&_,_Type,_Registers +_Name EQU _Name&_ +endif +ifdef LATTICE + ProcBeginBody _Name,_Type,_Registers +endif + endm +ProcBegin@ macro _Name,_Type,_Registers + ProcBeginBody _Name,_Type,_Registers + endm +ProcBeginBody macro _Name,_Type,_Registers +_DI = 0 +_SI = 0 +if _TANDW +ifnb <_Registers> + irpc _flags,_Registers +ifidni <_flags>, +_DI = 1 +endif +ifidni <_flags>, +_SI = 1 +endif + endm +endif +endif +; +ProcEnd macro _flag +ifb <_flag> +if _DI + pop di +endif +if _SI + pop si +endif +if _TANDW +ifidni <_Type>, + pop bp +endif +endif +ifdef LATTICE +ifidni <_Type>, + pop bp +endif +endif + ret +endif +&_Name endp + endm +; + public _Name +ifidni <_Type>, +_Name proc far +else +_Name proc near +endif +ifidni <_Type>, +if _TANDW + push bp + mov bp, sp +endif +ifdef LATTICE + push bp + mov bp, sp +endif +Arg1 equ <[bp+4]> +Arg2 equ <[bp+6]> +Arg3 equ <[bp+8]> +Arg4 equ <[bp+10]> +Arg5 equ <[bp+12]> +Arg6 equ <[bp+14]> +Arg7 equ <[bp+16]> +Arg8 equ <[bp+18]> +endif +ifidni <_Type>, +if _TANDW + mov bx, sp +endif +ifdef LATTICE + mov bx, sp +endif +Arg1 equ <[bx+2]> +Arg2 equ <[bx+4]> +Arg3 equ <[bx+6]> +Arg4 equ <[bx+8]> +Arg5 equ <[bx+10]> +Arg6 equ <[bx+12]> +Arg7 equ <[bx+14]> +Arg8 equ <[bx+16]> +endif +if _SI + push si +endif +if _DI + push di +endif + endm +; + .list diff --git a/code/HDK/EPOCSER.INC b/code/HDK/EPOCSER.INC new file mode 100644 index 0000000..d0c9c12 --- /dev/null +++ b/code/HDK/EPOCSER.INC @@ -0,0 +1,297 @@ + .xlist +; Include file - EPOCSER.INC +; Epoc/Os standard Serial Driver defines +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 JH Final release +; 2.01F 05/10/90 JH Added a define for Constant speed DTE modems +; +EPOCSER_INC equ 1 +; Serial port characteristics +SerialCharEnt struc + SerialCharTbaud db ? ; transmit Baud rate selector + SerialCharRbaud db ? ; receive Baud rate selector + SerialCharFrame db ? ; number of data, parity and stop bits + SerialCharParity db ? ; parity selector + SerialCharHandshake db ? ; handshake flags + SerialCharXon db ? ; XON character + SerialCharXoff db ? ; XOFF character + SerialCharFlags db ? ; control flags + SerialCharTmask dd ? ; terminator mask +SerialCharEnt ends + +; Function numbers to use to call PDD functions +SerPDDFuncOpen equ 0 +SerPDDFuncClose equ 2 +SerPDDFuncStart equ 4 +SerPDDFuncStop equ 6 +SerPDDFuncSet equ 8 +SerPDDFuncSense equ 10 +SerPDDFuncControl equ 12 +SerPDDFuncEnquire equ 14 +SerPDDFuncEnable equ 16 +SerPDDFuncSetHandlerCS equ 18 + +; +SERPARITY_ERR equ 0ffh +SERFRAME_ERR equ 0feh +SEROVERRUN_ERR equ 0fdh + +SERNOCHAR equ 0ffffh + +; Baud rates +P_BAUD_50 equ 01h +P_BAUD_75 equ 02h +P_BAUD_110 equ 03h +P_BAUD_134 equ 04h +P_BAUD_150 equ 05h +P_BAUD_300 equ 06h +P_BAUD_600 equ 07h +P_BAUD_1200 equ 08h +P_BAUD_1800 equ 09h +P_BAUD_2000 equ 0Ah +P_BAUD_2400 equ 0Bh +P_BAUD_3600 equ 0Ch +P_BAUD_4800 equ 0Dh +P_BAUD_7200 equ 0Eh +P_BAUD_9600 equ 0Fh +P_BAUD_19200 equ 10h +P_BAUD_38400 equ 11h +P_BAUD_56000 equ 12h + +; allocation of frame bits +P_DATA_FRM equ 0fh ; number of data bits mask +P_DATA_5 equ 0h ; 5 data bits +P_DATA_6 equ 1h ; 6 data bits +P_DATA_7 equ 2h ; 7 data bits +P_DATA_8 equ 3h ; 8 data bits +P_TWOSTOP equ 10h ; 2 stop bits if set, 1 if clear +P_PARITY equ 20h ; 1 parity bit if set, 0 if clear + +; parity - ignored unless P_PARITY is set +P_PAR_EVEN equ 1h ; even parity +P_PAR_ODD equ 2h ; odd parity +P_PAR_MARK equ 3h ; mark parity +P_PAR_SPACE equ 4h ; space parity + +; handshaking control +P_OBEY_XOFF equ 01h ; respond to received XOFF (and XON) if set +P_SEND_XOFF equ 02h ; send XOFF/XON to control receive buf if set +P_IGN_CTS equ 04h ; ignore the state of CTS if set +P_OBEY_DSR equ 08h ; obey the state of DSR if set +P_FAIL_DSR equ 10h ; fail if DSR goes OFF if set +P_OBEY_DCD equ 20h ; obey the state of DCD if set +P_FAIL_DCD equ 40h ; fail if DCD goes OFF if set + +; flags control +P_IGNORE_PARITY equ 01h ; ignore parity errors + +; For P_FCTRL function +P_SRCTRL_CTS equ 01h +P_SRCTRL_DSR equ 02h +P_SRCTRL_DCD equ 04h +P_SRCTRL_DTR equ 08h +P_SRCTRL_RTS equ 10h + +P_SRDTR_ON equ 1h ; to set DTR to MARK +P_SRDTR_OFF equ 2h ; to set DTR to SPACE + +; Bit masks for P_FINQ function +P_SRINQ_50 equ 0001h +P_SRINQ_75 equ 0002h +P_SRINQ_110 equ 0004h +P_SRINQ_134 equ 0008h +P_SRINQ_150 equ 0010h +P_SRINQ_300 equ 0020h +P_SRINQ_600 equ 0040h +P_SRINQ_1200 equ 0080h +P_SRINQ_1800 equ 0100h +P_SRINQ_2000 equ 0200h +P_SRINQ_2400 equ 0400h +P_SRINQ_3600 equ 0800h +P_SRINQ_4800 equ 1000h +P_SRINQ_7200 equ 2000h +P_SRINQ_9600 equ 4000h +P_SRINQ_19200 equ 8000h +; second baud rate word +P_SRINQ_38400 equ 0001h +P_SRINQ_56000 equ 0002h + +; 2nd set of info +P_SRINQ_DATA5 equ 0001h ; supports 5 data bits +P_SRINQ_DATA6 equ 0002h ; supports 6 data bits +P_SRINQ_DATA7 equ 0004h ; supports 7 data bits +P_SRINQ_DATA8 equ 0008h ; supports 8 data bits +P_SRINQ_STOP2 equ 0010h ; supports 2 stop bits (as well as 1) +P_SRINQ_PAREVEN equ 0020h ; supports even parity +P_SRINQ_PARODD equ 0040h ; supports odd parity +P_SRINQ_PARMARK equ 0080h ; supports mark parity +P_SRINQ_PARSPACE equ 0100h ; supports space parity +P_SRINQ_SETDTR equ 0200h ; can set DTR +P_SRINQ_SPLIT equ 0400h ; supports split Baud rates +P_SRINQ_XONXOFF equ 0800h ; Supports soft xon/xoff characters + +; CRC generator section +; The Low and High bytes of the 16 bit CRC +CrcEnt struc + CrcLow db ? ; CRC low byte + CrcHigh db ? ; CRC high byte +CrcEnt ends + +;Serial Driver Media Access Control section (LLMAC) +; +P_MAXILEN equ 300 ; maximum length of information field + +;Frame type codes +LA_LPDU equ 0 ; The Link Acknowledge PDU +LD_LPDU equ 1 ; The Link disconnect PDU +LR_LPDU equ 2 ; The Link Request PDU +LT_LPDU equ 3 ; The Link Data PDU +P_FRM_BROKEN equ 4 ; A broken frame + +FrameEnt struc + FrameType db ? ; frame type + FrameSeq db ? ; frame sequence + FrameLen dw ? ; length of information field + FramePbuf dw ? ; ptr to data buffer +FrameEnt ends + +; LLMAC layer characteristics +LlmacEnt struc + LlmacIlen dw ? ; maximum information field length + LlmacSpeed dw ? ; nominal speed in characters per second + LlmacRtint dw ? ; suggested retransmission interval +LlmacEnt ends + +; LINK layer structures and defines +; IoFuncConnect service connection modes */ +P_LINK_ACCP equ 0 ; want link as acceptor +P_LINK_INIT equ 1 ; want link as initiator + +; Link layer states +P_LINK_IDLE equ 0 ; no connection - idle +P_LINK_IDLE_LR equ 1 ; no connection - awaiting LR +P_LINK_DATA_IDLE equ 2 ; connected - idle +P_LINK_DATA_LA equ 3 ; connected - awaiting LA +P_LINK_IDLE_LA equ 4 ; not connected - awaiting LA (or LT) to LR + +;State and event log record +LinkLogEnt struc + LinkLogState db ? ; Link layer state (as defined above) + LinkLogEvent db ? ; Event that occured +LinkLogEnt ends + +P_LINK_NLOG equ 32 ; Max number of debug events,states we record +P_LINK_LOG_MASK equ 0C0h +P_LINK_LOG_PANIC equ 0C0h ; panic number +P_LINK_LOG_MAC equ 0 ; MAC request or timer +P_LINK_LOG_REQ equ 80h ; User request +P_LINK_LOG_COMP equ 40h ; User completion + +LinkDataEnt struc + LinkDataLlmac LlmacEnt <> + LinkDataBrokenCount dw ? ; count of broken frames + LinkDataRetranCount dw ? ; re-transmission count +LinkDataEnt ends + +; Comms I/O drivers shared code header structs +; Flag defines +RQ_TIMER equ 01h ; a timer has been started +RQ_SUPER equ 02h ; a supervisory read has been started +RQ_WRITE equ 04h ; a write has been started +RQ_READ equ 08h ; a data read has been started +RQ_DISABLE_HANDLER equ 10h ; set to disable handers +RQ_ANY equ (RQ_TIMER or RQ_SUPER or RQ_WRITE or RQ_READ) + +;Flag bits to indicate various features of the link layer event. +QUEUE_XMIT_LA equ 20h ; queue an LA when the transmit completes +LINK_ACTIVE equ 40h ; set between a P_FCONNECT and a disconnect +USER_DATA_PENDING equ 80h + +; DONT CHANGE THE ORDER OF THIS !! +IoRequestEnt struc + IoRequestChan ChanEnt <> ; I/O control block + IoRequestWaitHandler dw ? ; wait handler vector number + IoRequestRqRead RqEnt <> ; Read request packet + IoRequestRqWrite RqEnt <> ; Write request packet + IoRequestRqSuper RqEnt <> ; Supervisorry request packet + IoRequestTimerPcb dw ? ; open Timer cb + IoRequestTimerStat dw ? ; timer completion status + IoRequestReadStat dw ? ; read completion status + IoRequestWriteStat dw ? ; write completion status + IoRequestSuperStat dw ? ; supervisory completion status + IoRequestFlags db ? ; controlling flags + IoRequestState db ? ; current internal state +IoRequestEnt ends + +LnkEnt struc + LnkIoRequest IoRequestEnt <> ; I/O header + LnkLinkData LinkDataEnt <> ; Link layer data + LnkNumberLog dw ? ; current log table event no. + LnkLogTable db (size LinkLogEnt)*P_LINK_NLOG dup (?) +LnkEnt ends + +; XMODEM structures and defines +; IoFuncConnect service connection modes */ +P_XMDM_ACCP equ 0 ; want link as acceptor +P_XMDM_INIT equ 1 ; want link as initiator + +; Xmodem link types +P_XMDM_CRCORCHECKSUM equ 0 +P_XMDM_CRCMODE equ 1 +P_XMDM_CHECKSUMMODE equ 2 +P_YMODEM_MODE equ 3 +P_YMODEM_G_MODE equ 4 +P_XMDM_ONE_K equ 8000h + +;Xmodem/Ymodem supported flags +P_FXMDM_SENSE equ 0ffh ; I/O function number +P_XSUP_XMODEM equ 01h ; original Xmodem checksum +P_XSUP_XMODEM_CRC equ 02h ; Xmodem with CRC +P_XSUP_ONE_K_OPTION equ 04h ; 1k frames +P_XSUP_YMODEM equ 08h ; Ymodem +P_XSUP_YMODEM_G equ 10h ; Ymodem-G + +; Xmodem State defines +P_XMDM_IDLE equ P_LINK_IDLE ; idle state (no connection) +P_XMDM_CONNECT_RECEIVE equ 1 ; receive connect state +P_XMDM_CONNECT_TRANSMIT equ 2 ; Transmit connect state +P_XMDM_DATA_RECEIVE equ 3 ; receive data state +P_XMDM_DATA_TRANSMIT equ 4 ; transmit data state +P_XMDM_DATA_TRANSMIT_ACK equ 5 ; awaiting ACK to transmitted data + +;State and event log record +XmdmLogEnt struc + LinkLogEnt <> +XmdmLogEnt ends + +P_XMDM_NLOG equ P_LINK_NLOG ; Max number of debug events,states we record +P_XMDM_LOG_MASK equ P_LINK_LOG_MASK +P_XMDM_LOG_PANIC equ P_LINK_LOG_PANIC ; panic number +P_XMDM_LOG_REQ equ P_LINK_LOG_REQ ; User request +P_XMDM_LOG_COMP equ P_LINK_LOG_COMP ; User completion + +; Modem driver info +; what options are selected +P_MDM_TONE equ 01h +P_MDM_BELL equ 02h +P_MDM_NO_MODULATION equ 04h +P_MDM_CONSTANT_SPEED equ 08h ; modem provides constant speed interface if set + +; error correction types +P_MDM_ERRCORRECT_NONE equ 00h +P_MDM_ERRCORRECT equ 01h +P_MDM_ERRCORRECT_MNP equ 02h +P_MDM_ERRCORRECT_V42 equ 03h + +ModemCharEnt struc + ModemCharSupport dw ? ; flags saying what supported + ModemCharOptions dw ? ; Selected options + ModemCharBaudRate dw ? ; Baud rate running at + ModemCharConnHand db ? ; Connected handshaking + ModemCharCallHand db ? ; Wait for call handshaking +ModemCharEnt ends + + .list diff --git a/code/HDK/EPOCSIBO.INC b/code/HDK/EPOCSIBO.INC new file mode 100644 index 0000000..69b03a5 --- /dev/null +++ b/code/HDK/EPOCSIBO.INC @@ -0,0 +1,86 @@ + .xlist +; Include file - EPOCSIBO.INC +; Epoc/Os SIBO specific include file +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +EPOCSIBO_INC equ 1 +; +SupplyEnt struc +MainBatteryReading dw ? +LithiumBatteryReading dw ? +MainsPresent dw ? +SupplyEnt ends +; +SupplyWarningsEnt struc +MainBatteryWarning dw ? +LithiumBatteryWarning dw ? +MainBatteryMaxValue dw ? +LithiumBatteryMaxValue dw ? +SupplyWarningsEnt ends +; +MainBatZero equ 0 +MainBatVeryLow equ 1 +MainBatLow equ 2 +MainBatGood equ 3 +; +SupplySoundWarning equ 0001h +SupplyFlashWarning equ 0002h +SupplySystemTimeChanged equ 0004h +; +SupplyInfoEnt struc +SuMainBatLevel db ? +SuMainBatStatus db ? +SuBackupBatLevel db ? +SuDcLevel db ? +SuWarningFlags dw ? +SuInsertionDate dd ? +SuTicksInUseBattery dd ? +SuTicksInUseDc dd ? +SuMilliampTicks dd ? +SupplyInfoEnt ends +; +SsdUnitInfo struc +SsdUnitStatus db ? +SsdUnitType db ? +SsdUnitDevices db ? +SsdUnitAsicType db ? +SsdUnitChanged db ? +SsdUnitReadCmd db ? +SsdUnitTotalSectors dw ? +SsdUnitMask dw ? +SsdUnitSectorsPerDevice dw ? +SsdUnitSpare db ? +SsdUnitShift db ? +SsdUnitDoReadCmd dw ? +SsdUnitInfo ends +; +SsdData struc +SsdUnitInfoBuffer SsdUnitInfo 4 dup(<>) +SsdDoorStatus db ? +SsdDoorDelay db ? +SsdPakCritical db ? +SsdDoorOpened db ? +SsdOldFrcVector dd ? +SsdFrcFlag dw ? +SsdPakChannel db ? +SsdWriteFlag db ? +SsdFlashCount dw ? +SsdFlashVector dw ? +SsdFlashAddress dw ? +SsdFlashOffset dw ? +SsdFlashMaxProgramPulses dw ? +SsdSaveStack dw ? +SsdNeedSerialResume db ? +SsdBackTo4 db ? +SsdA9DoorNmiEnabled db ? +SsdSpare db ? +SsdFlashProgram dw ? +SsdNewPddSpareBuffer db 400h dup (?) +SsdData ends +; + .list + diff --git a/code/HDK/OSPACK.INC b/code/HDK/OSPACK.INC new file mode 100644 index 0000000..301e85f --- /dev/null +++ b/code/HDK/OSPACK.INC @@ -0,0 +1,125 @@ + .xlist +; Include file - OSPACK.INC +; Epoc/Os Sibo packs include file. +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 CJ Final release +; 2.50A 24/01/93 NSM Changed to support S3B/C +; +DoorOpen equ 001h +DoorClosed equ 000h +; +; ASIC4 STRUCTURES AND REGISTER BITS +; ================================== +; +ASIC5TYPE equ 0 +ASIC4TYPE equ 1 +; +ASIC4R struc +A4Data db ? +A4Portb db ? +A4IncAddress db ? +A4Address db ? +A4Dum4 db ? +A4Dum5 db ? +A4Dum6 db ? +A4Control db ? +ASIC4R ends +; +A4PortbMode equ A4IncAddress +A4InfoR equ A4Portb +A4CsSetupW equ A4Portb +A4XInfo record A4MXPeriph:1,A4MXType:1,A4MXDevices:1,A4MXBlocks:1, \ + A4MXCheat:1,A4MXExtra:2,A4MXLowBat:1 +; +A4SpecialMode equ 2 +A4NormalMode equ 0 +; +A4LBO equ 080h ; Enable low battery check +SetVppOn equ 010h ; Enable VPP bit in A4CONTROL +SetVppOff equ 000h ; Disable VPP +VppOnDelay equ 5 ; i.e. 5ms. +BatteryDelay equ 1 ; 1 ms +; +; INTEL FLASH EPROM COMMANDS +; ========================== +; +ReadCmd equ 0 ; Set into read mode when VPP is on +EraseCmd equ 020h ; Start erase cycle +EraseVerifyCmd equ 0a0h ; Erase verify byte +ProgramCmd equ 040h ; Start program cycle +ProgramVerifyCmd equ 0c0h ; Program verify byte +MaxProgramPulses equ 25 ; Number of programs per byte +MaxErasePulses equ 1000 ; Number of erase cycles +EraseDelay equ 10 ; Erase program delay 10mS +; +; INTEL TYPE2 FLASH EPROM COMMANDS +; ================================ +; +Type2ReadCmd equ 0FFh ; Read byte with VPP on +Type2EraseCmd equ 0D0h ; Start erase cycle +Type2EraseSetup equ 020h ; Erase verify byte +Type2ProgramCmd equ 040h ; Start program cycle +Type2ClearStatus equ 050h ; Clear status byte +Type2ReadStatus equ 070h ; Read status byte +Type2MaxProgramPulses equ 1 ; Number of programs per byte +Type2ProgramTimeout equ 150 ; 150 frames at 3.2 us is >450 us. +Type2EraseTimeout equ 321 ; 320 ticks is 10 seconds. +; Status Register Format +Type2StatusBusy equ 80h +Type2EraseSuspended equ 40h +Type2EraseSuccess equ 20h +Type2WriteSuccess equ 10h +Type2VPPFail equ 08h +; +if HandHeld + if Corporate or S3c +Max01Units equ 2 + else +Max01Units equ 3 + endif +else +Max01Units equ 4 +endif +; +; DATA STRUCTURES +; =============== +; +InfoRec record PackType:3,NumberOfChips:2,BlocksPerChip:3 +; +TypeRam equ 0 +TypeIntelFlash equ 1 +Type2IntelFlash equ 2 +TypeUnknown equ 3 +TypeRom equ 6 +TypeWriteProtected equ 7 +; +UnitShiftNumber equ 4 ; 2^UnitShift must equal size of UnitInfo +; +UnitInfo struc ; This must be an whole power of 2 +UnitStatus db ? +UnitType db ? +UnitDevices db ? +UnitAsicType db ? +UnitChanged db ? +UnitReadCmd db ? +UnitTotalSectors dw ? +UnitMask dw ? +UnitSectorsPerDevice dw ? +UnitSpare db ? +UnitShift db ? +UnitDoReadCmd dw ? +UnitInfo ends +; +UnitBufferInBxFromBl macro + xor bh, bh + rept UnitShiftNumber + shl bx, 1 + endm + add bx, offset OsDataGroup:OsUnitInfoBuffer + endm +; + .list + diff --git a/code/HDK/OSSIBO.INC b/code/HDK/OSSIBO.INC new file mode 100644 index 0000000..ba652df --- /dev/null +++ b/code/HDK/OSSIBO.INC @@ -0,0 +1,620 @@ + .xlist +; Include file - OSSIBO.INC +; Epoc/Os Sibo include file. +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +NoNullFrames equ 1 +; +if Asic1 +A1Ent struc +A1Dummy dw ? +A1Control dw ? +A1LcdSize dw ? +A1LcdControl dw ? +A1InterruptMask dw ? +A1NonSpecificEoi dw ? +A1TimerEoi dw ? +A1FrcEoi dw ? +A1ResetWatchDog dw ? +A1FrcControl dw ? +A1ProtectionOn dw ? +A1ProtectionUpper dw ? +A1ProtectionLower dw ? +A1SoundLsw dw ? +A1SoundMsw dw ? +A1SoundControl dw ? +A1Ent ends +; +A1Status equ A1Control +A1ProtectionOff equ A1ProtectionOn +A1InterruptStatus equ A1LcdControl +; +A1StatusR record LcdData:2,Rtc4Hz:1,SldMsw:1,ComboBusy:1,Rtc32Hz:1,ExternalNmi:1,WatchDogNmi:1,SldTx:1,A1SldEnable:1,LcdEnable:1,Ram512:1,Ram128:1,FrcSource:1,TickRate:1,FrcMode:1 +A1LcdSizeR record LcdMLineEnable:1,LcdNumberOfPixels:5,LcdEndOfFrame:10 +A1LcdControlR record LcdMode:2,LcdMLineRate:5,LcdRate:5 +A1InterruptMaskR record SldTransmit:1,SldReceive:1,FrcExpired:1,Asic2Int:1,ExpIntLeftA:1,ExpIntRightB:1,Mains:1,Timer:1 +ExpAddressLeftA equ 0200h +ExpAddressRightB equ 0100h +ExpChannelLeftA equ SelectChannel6 +ExpChannelRightB equ SelectChannel5 +; +; Asic1 dependent constants +; +ResetWatchDog equ A1ResetWatchDog +; +A2Ent struc +A2Dummy db 080h dup(?) +A2Index dw ? +A2Control dw ? +A2Control1 dw ? +A2Control2 dw ? +A2Control3 dw ? +A2SerialData dw ? +A2SerialControl dw ? +A2ChannelControl dw ? +A2Ent ends +; +A2External equ A2Control1 +A2InterruptStatus equ A2Control2 +A2Status equ A2Control3 +A2KeyData equ A2SerialControl +A2SlaveData equ A2ChannelControl +A2IControl0 equ 0 +A2IControl1 equ 1 +A2IWrite equ 2 +A2IDDR equ 3 +; +A2InterruptStatusR record SlaveDataOverrun:1,SlaveDataControl:1,SlaveDataValid:1,ExpansionInterrupt:1,DoorInterrupt:1 +A2StatusR record A2RevId:1,A2XExt:1,A2Sdis:1,SerialBusy:1,SerialClockState:1,A1ResetFlag:1,WakeUp:1,A1OnKey:1 +A2Control1R record SerialClockRate:2,KeyScan:4 +A2Control2R record ClockEnable7:1,ClockEnable6:1,ClockEnable5:1,BuzzerMode:1,BuzzerVolume:1,BuzzerToggle:1,XySwitch:1,DigitizerEnable:1 +A2Control3R record ElEnable:1,VhControl:1,ExpansionEnable:1,DoorEnable:1,SerialEnable:1,A2SldEnable:1,Ps34Acknowledge:1,SerialNull:1 +A2ChannelControlR record MultiplexEnable:1,ChannelSelect:3,Pack4Enable:1,Pack3Enable:1,Pack2Enable:1,Pack1Enable:1 +; +ClockRateSlow equ 2 +ClockRateMedium equ 0 +ClockRateFast equ 3 +SelectChannel0 equ (4 shl ChannelSelect) +SelectChannel1 equ (mask Pack1Enable) +SelectChannel2 equ (mask Pack2Enable) +SelectChannel3 equ (mask Pack3Enable) +SelectChannel4 equ (mask Pack4Enable) +SelectChannel5 equ (5 shl ChannelSelect) +SelectChannel6 equ (6 shl ChannelSelect) +SelectChannel7 equ (7 shl ChannelSelect) +; +SCONTOUT macro + out A2SerialControl, al + endm +; +SDATAOUT macro + out A2SerialData, al + endm +; +SDATAIN macro + in al, A2SerialData + endm +; +SBUSY macro + wait + endm +; +SREAD macro _REG + mov al, SerialReadSingle or _REG + out A2SerialControl, al + nop + SBUSY + in al, A2SerialData + endm +; +SREADM macro _REG + mov al, SerialReadMulti or _REG + out A2SerialControl, al + nop + SBUSY + in al, A2SerialData + endm +; +SWRITE macro _REG,_VAL + mov al, SerialWriteSingle or _REG + out A2SerialControl, al + SBUSY + mov al, _VAL + out A2SerialData, al + endm +; +SWRITEM macro _REG,_VAL + mov al, SerialWriteMulti or _REG + out A2SerialControl, al + SBUSY + mov al, _VAL + out A2SerialData, al + endm +; +SETSPEED macro _SPEED + pushf + cli + mov al, OsA2Control1 + and al, not mask SerialClockRate + ifidni <_SPEED>, + or al, ClockRateFast shl SerialClockRate + endif + ifidni <_SPEED>, + or al, ClockRateMedium shl SerialClockRate + endif + ifidni <_SPEED>, + or al, ClockRateSlow shl SerialClockRate + endif + mov OsA2Control1, al + out A2Control1, al + popf + endm +; + if LapTop +XPUSHFCLI macro + pushf + cli + endm +XPOPF macro + popf + endm + else +XPUSHFCLI macro + endm +XPOPF macro + endm + endif +; +XNOP macro + endm +; +@HwNullFrame macro + call OsHwNullFrame + endm +; +A3Ent struc +A3Adc db ? +A3Control1 db ? +A3Setup db ? +A3Control2 db ? +A3Dummy1 db 3 dup (?) +A3Control3 db ? +A3Dummy2 db 5 dup (?) +A3Status db ? +A3Dummy3 db ? +A3Ent ends +; +A3AdcLsbR record InvertedBit:1,OtherBits:7 +A3AdcMsbR record Polarity:1,Overrange:1,AdcBits:4 +A3Control1R record Vcc5Enable:1,Vcc4Enable:1,Vcc3Enable:1,DtoaBits:5 +A3Control2R record AnalogueMultiplex:2,VhSoftStart:1,Vee2SoftStart:1,Vee1SoftStart:1,VhEnable:1,Vee2Enable:1,Vee1Enable:1 +A3Control3R record AdcReadHighEnable:1,OffEnable:1,xDummy1:1 +Ps34ControlR record Ps34Vcc3:1,xDummy2:1,Ps34Vcc4:1,xDummy3:1,Ps34Vcc5:1,xDummy4:3 +; +AdcDigitizer equ 0 +AdcVh equ 1 +AdcMainBattery equ 2 +AdcLithiumBattery equ 3 +A3SetupValue equ 2 +A3SelectId equ (SerialSelect or Asic5NormalId) +A3InfoByte equ 080h +; +Vee1SoftStartDelay equ (30*128) +Vee2SoftStartDelay equ (30*128) +VhSoftStartDelay equ (100*128) +Vee1OffDelay equ (100*128) +Vee2OffDelay equ (100*128) +VhOffDelay equ (100*128) +Vcc3Delay equ (25*128) +Vcc4Delay equ (25*128) +Vcc5Delay equ (25*128) +Vcc4OffFrames equ (25) +Vcc1_4To5Delay equ (3) ; Pan only in ms. +Vcc1_4to5OffFrames equ (20) ; Gives 392 frames = 6.0 ms +Vcc1_4to5OnTime equ 4 ; Gives 4 ms +; +PS34R_ADC equ 0 +PS34R_STATUS equ 1 +PS34W_CONTROL equ 0 +PS34W_DTOA equ 1 +PS34W_OFF equ 0eh +; +PS34STATR record pPowerFail:1,pColdStart:1,pVhready:1,pPenup:1,pNc:1,pAdmsb:3 +PS34CONTR record pVcc3:1,pVee1:1,pVcc4:1,pVee2:1,pVcc5:1,pVh:1,pVhpower:2 +PS34DTOAR record pNcc:1,pAdcsel:2,pDac:5 +; +ADCSEL_ADCIN equ 0 +ADCSEL_VIN equ 1 +ADCSEL_VH equ 2 +ADCSEL_VBATT equ 3 +; +VHP1TO8 equ 0 +VHP1TO4 equ 1 +VHP1TO2 equ 2 +VHP1TO1 equ 3 +; +PPowerControl equ 0100h +PPowerControlR record PVcc5Enable:1,PSoundEnable:1,PVee1Enable:1,PDropVoltage:1,PDac:4 +PPia record PSoundVol:2,PClearCold:1,PDcPresent:1,PColdFlag:1,PLithiumWarn:1,PVinWarn:1 +PSoundControl equ 0200h +endif +; +A3StatusR record PowerFail:1,ColdStart:1 +AIntfR record ResetFlag:1,DummyWakeUp:1,OnKey:1 +if Asic1 + if ((mask ResetFlag) ne (mask A1ResetFlag)) or \ + ((mask OnKey) ne (mask A1OnKey)) + .err Reset or OnKey flags are not equal + endif +endif +; +SerialWriteSingle equ 10000000b +SerialWriteMulti equ 10010000b +SerialReadSingle equ 11000000b +SerialReadMulti equ 11010000b +SerialReset equ 00000000b +SerialSelect equ 01000000b +; +Asic4Id equ 006h +Asic5PackId equ 002h +Asic5NormalId equ 003h +Asic6Id equ 004h +Asic8Id equ 005h +Asic2SlaveId equ 01fh +; +; Asic5 info byte structure +; +A5InfoByteR record A5TTL:1,A5Modem:1,A5MultiDrop:1,A5Barcode:1,A5Other:2,A5Parallel:1,A5Rs232:1 +A5OtherRom equ (1 shl A5Other) +A5OtherMCRTTL equ (3 shl A5Other) +A5MCR equ (2 shl A5Other) +; +if Consumer + if S3b +DefaultLcdContrast equ 9 + else +DefaultLcdContrast equ 7 + endif +else +if S3c +DefaultLcdContrast equ 9 +else +DefaultLcdContrast equ 15 +endif +endif +; +InterruptBase equ 078h +; +if Asic9 +KeyPollColumns equ 8 +else +KeyPollColumns equ 10 +endif +KeyInitialDelay equ 24 +if Consumer or S3c +KeyRepeatDelay equ 2 +else +KeyRepeatDelay equ 4 +endif +PenUpDelay equ 16 +MouseDownDelay equ 8 +KeySettleDelay equ 24 +KeyCntrlMask equ 00000001b +KeyLeftShiftMask equ 00000010b +KeyPsionMask equ 00000100b +KeyCapsMask equ 00001000b +KeyRightShiftMask equ 00010000b +DigitizerRowMask equ 00010000b +PsionScanCode equ 6 +CapsScanCode equ 5 +PsionUpScanCode equ 65 +; +PostRomTest equ 010h +PostSystemRamTest equ 020h +PostVideoRamTest equ 030h +PostComplete equ 0f0h +if Consumer or S3c +PostPort equ 0h +else +PostPort equ 01ffh +endif +; +if HandHeld + VideoRamSegment equ 00040h + VideoRamBase equ 00000h + if Corporate + VideoRamWords equ 00320h + else + if S3b + VideoRamWords equ 02580h + else + if S3c + VideoRamWords equ 00C80h + else + VideoRamWords equ 00500h + endif + endif + endif +else + VideoRamSegment equ 0b800h + VideoRamBase equ 00000h + VideoRamWords equ 04000h +endif +; +CalSeg equ 0fffeh +CalEnt struc +CalVsupCLsw dw ? +CalVsupCMsw dw ? +CalVsupM dw ? +CalVlthCLsw dw ? +CalVlthCMsw dw ? +CalVlthM dw ? +CalType dw ? +CalEnt ends +; +CHKeyDataR record CHInSled:1,CHMains:1,CHDummy:2 +; +IntBXHw equ -2 +; +if Asic9 +A9WControlRW equ 0002h + A9RControl record A9MFrc2Is512KHzOr1KHz:1,A9MFrc2PreScale:1,\ + A9MFrc1Is512KHzOr1Hz:1,A9MFrc1PreScale:1,\ + A9MSoundEnable:1,A9MLcdEnable:1,\ + A9MLowBatNMIEnable:1,A9MDoorNMIEnable:1,\ + A9MZeroIsGrayMode:1,A9MArmStandBy:1,\ + A9MDisableDMADivide:1,A9MRamDeviceSize:2,\ + A9MDisableMemWait:1,A9MDisableIoWait:1,\ + A9MDisableClockDivide:1 + A9VRam256KBits equ (0 shl A9MRamDeviceSize) + A9VRam1MBits equ (1 shl A9MRamDeviceSize) + A9VRam4MBits equ (2 shl A9MRamDeviceSize) + A9VRam16MBits equ (3 shl A9MRamDeviceSize) + A9XRamDeviceSizeMask equ (3 shl A9MRamDeviceSize) +A9WStatusR equ 0004h + A9RStatus record A9MCold:1,A9MPowerFail:1,\ + A9MReset:1,A9MNoBattery:1,\ + A9MFifoFull:1,A9MSlaveOverrun:1,\ + A9MSlaveControlFrame:1,A9MSlaveDataValid:1,\ + A9MKeyboard:1,A9MSlaveClock:1,\ + A9MMainsPresent:1,A9MDoorSwitch:1,\ + A9MLowBatNMI:1,A9MDoorNMI:1,\ + A9MProtectedModeNMI:1,A9MWatchDogNMI:1 + A9MLcdType equ 8 + A9XLcdType equ 0000111100000000b +A9WLcdSizeW equ 0004h + A9RLcdSize record A9MLcdLineLength:5,A9MLcdNumberOfPixels:11 +A9WLcdControlW equ 0006h + A9RLcdControl record A9MLcdMode:2,A9MLcdACLineRate:5,A9MLcdPixelRate:5 + A9VSinglePage1 equ (0 shl A9MLcdMode) + A9VSinglePage2 equ (1 shl A9MLcdMode) + A9VSinglePage1And2 equ (2 shl A9MLcdMode) + A9VDualPage1And2 equ (3 shl A9MLcdMode) +A9BInterruptStatusR equ 0006h +A9BInterruptMaskRW equ 0008h + A9RInterrupts record A9MFrc2:1,A9MFrc1:1,\ + A9MExpIntB:1,A9MExpIntA:1,A9MExpIntC:1,\ + A9MSlave:1,A9MTimer:1,A9MSound:1 +A9BNmiClearW equ 0009h +A9BNonSpecificEoiW equ 000ah +A9BStartFlagClearW equ 000bh +A9BTimerEoiW equ 000ch +A9BSerialSlaveEoiW equ 000dh +A9BFrc1EoiW equ 000eh +A9BFrc2EoiW equ 000fh +A9WResetWatchDogW equ 0010h +A9WFrc1DataRW equ 0012h +A9BProtectionOnW equ 0014h +A9BProtectionOffR equ 0014h +A9BProtectionOffW equ 0015h +A9WProtectionUpperW equ 0016h +A9WProtectionLowerW equ 0018h +A9BSoundDataRW equ 001ah +A9BSoundEoiW equ 001ch +A9WFrc2DataRW equ 001eh +A9WPortABDataRW equ 0020h +if S3b + A9RPortABData record A9MKeyId0:1,A9MSleepDoorNmiDisabled:1,\ + A9MBatLevel2:1,A9MBatLevel1:1,A9MLiBatLevel:1,\ + A9MKeyRow:11 +endif +if S3c + A9RPortABData record A9MKeyIdX2:1,A9MNiCdDetect:1,\ + A9MBatLevel2:1,A9MBatLevel1:1,A9MLiBatLevel:1,\ + A9MKeyIdX1:1,A9MKeyIdX0:0,A9MKeyRowX8:1,\ + A9MCradle:1,A9MKeyRowX:7 +endif +A9BPortADataRW equ 0020h +A9BPortBDataRW equ 0021h +A9WPortABDDRRW equ 0022h + A9VPortABDDR equ 0000000000000000b +A9BPortADDRRW equ 0022h +A9BPortBDDRRW equ 0023h +A9WPortCDDataRW equ 0024h +if S3b + A9RPortCDData record A9MVccPacksEnable:1,A9MCodecEnable:1,\ + A9MVccLcdEnable:1,A9MLcdPanelEnable:1,\ + A9MLcdContrast:4,A9MVolume:2,\ + A9MReproEnable:1,A9MAltDoorNMIEnable:1,\ + A9MAmplifierEnable:1,A9MKeyIdEnable:1,\ + A9MKeyId2:1,A9MKeyId1:1 + A9VVolumeLow equ (mask A9MVolume) + A9VPortCDData equ 0000111100000000b + A9VPortCDDDR equ not (1111000011111100b) +endif +if S3c + A9RPortCDData record A9MVccPacksEnable:1,A9MCodecEnable:1,\ + A9MVccLcdEnable:1,A9MLcdPanelEnable:1,\ + A9MLcdContrast:4,A9MVolume:2,\ + A9MReproEnable:1,A9MAltDoorNMIEnable:1,\ + A9MAmplifierEnable:1,A9MKeyIdEnable:1,\ + A9MBuzVolX:1,A9MBacklightEnableX:1 + A9VVolumeLow equ (mask A9MVolume) + A9VPortCDData equ 0000111100000000b + A9VPortCDDDR equ not (1111000011111111b) +endif +A9BPortCDataRW equ 0024h +A9BPortDDataRW equ 0025h +A9WPortCDDDRRW equ 0026h +A9BPortCDDRRW equ 0026h +A9BPortDDDRRW equ 0027h +A9BPageSelect6000RW equ 0028h +A9BPageSelect7000RW equ 0029h +A9BPageSelect8000RW equ 002ah +A9BPageSelect9000RW equ 002bh +A9WControlExtraRW equ 002ch + A9RControlExtraRW record A9MSlaveIntEnable:1,A9MClkDiv:2,\ + A9MClockEnable5:1,A9MClockEnable4:1,\ + A9MClockEnable3:1,A9MClockEnable2:1,\ + A9MClockEnable1:1,A9MSoundDir:1,\ + A9MExonDisable:1,A9MBuzzFromFrc1OrTog:1,\ + A9MBuzzTog:1,A9MKeyCol:4 + A9VKeyColHigh equ 0 + A9VKeyColLow equ 1 + A9VKeyCol0 equ 8 + A9VClkDiv1 equ (3 shl A9MClkDiv) + A9VClkDiv2 equ (2 shl A9MClkDiv) + A9VClkDiv3 equ (1 shl A9MClkDiv) + A9VClkDiv4 equ (0 shl A9MClkDiv) +A9WPumpControlRW equ 002eh + A9RPumpControl record A9MVhPumpDc:4,A9MVhPumpBat:4,\ + A9MLcdPump:4,A9MPump2:4 + A9VVhPumpBat equ (14 shl A9MVhPumpBat) + A9VVhPumpBatSoft equ (4 shl A9MVhPumpBat) + A9VVhPumpBatMedium equ (8 shl A9MVhPumpBat) + A9VVhPumpDC equ (2 shl A9MVhPumpDc) + A9VVhPumpDCSoft equ (1 shl A9MVhPumpDc) + A9VLcdPump equ (7 shl A9MLcdPump) + A9VLcdPumpSoft equ (1 shl A9MLcdPump) + A9VPacksPumpSoft equ (15 shl A9MPump2) + A9VVhPumpDelay equ 100 ; Milliseconds + A9VLcdPumpDelay equ 5 ; Milliseconds + A9VCC3OnDelay equ 1 ; Milliseconds + A9VCCPacksDelay equ 20 ; Milliseconds + A9VCC2Delay equ 10 ; Milliseconds +A9WRtcLSWRW equ 0080h +A9WRtcMSWRW equ 0082h +A9WNullFrameW equ 0084h +A9BSlaveDataR equ 0088h +A9BSerialDataRW equ 008ah +A9BSerialControlW equ 008ch +A9BChannelSelectRW equ 008eh + A9RChannelSelect record A9MMultiplexEnable:1,A9MSerialClockRate:2,\ + A9MPack5Enable:1,A9MPack4Enable:1,\ + A9MPack3Enable:1,A9MPack2Enable:1,\ + A9MPack1Enable:1 + A9VSClkRateMedium equ (0 shl A9MSerialClockRate) + A9VSClkRateSpecial equ (1 shl A9MSerialClockRate) + A9VSClkRateSlow equ (2 shl A9MSerialClockRate) + A9VSClkRateFast equ (3 shl A9MSerialClockRate) +; +; Asic9 Dependent constants +; +ResetWatchDog equ A9WResetWatchDogW +SelectChannel1 equ (mask A9MPack1Enable) +SelectChannel2 equ (mask A9MPack2Enable) +SelectChannel3 equ (mask A9MPack3Enable) +SelectChannel4 equ (mask A9MPack4Enable) +SelectChannel5 equ (mask A9MPack5Enable) +; +; Current usage values +; +IdleCurrent equ 23 +RunCurrent equ 51 +Asic5SerialCurrent equ 54 +Flash1ProgramCurrent equ 76 +Flash2ProgramCurrent equ 99 +Flash1EraseCurrent equ 94 +Flash2EraseCurrent equ 129 +; +; We add 26 because most of the work is under the NULL process. +; The value is 26 and not 28 because 10% of the time we are +; under the sound server. +; +SoundCurrentPlayV3 equ (25+20) +SoundCurrentPlayV2 equ (30+20) +SoundCurrentPlayV1 equ (55+20) +SoundCurrentPlayV0 equ (120+20) +; +; The value here must never equal one of the play values. +; It won't anyway in practise so this is not a big deal. +; +SoundCurrentRecord equ 5 +; +SCONTOUT macro + out A9BSerialControlW, al + endm +; +SDATAOUT macro + out A9BSerialDataRW, al + endm +; +SDATAIN macro + in al, A9BSerialDataRW + endm +; +SBUSY macro + endm +; +SREAD macro _REG + mov al, SerialReadSingle or _REG + out A9BSerialControlW, al + in al, A9BSerialDataRW + endm +; +SREADM macro _REG + mov al, SerialReadMulti or _REG + out A9BSerialControlW, al + in al, A9BSerialDataRW + endm +; +SWRITE macro _REG,_VAL + mov al, SerialWriteSingle or _REG + out A9BSerialControlW, al + mov al, _VAL + out A9BSerialDataRW, al + endm +; +SWRITEM macro _REG,_VAL + mov al, SerialWriteMulti or _REG + out A9BSerialControlW, al + mov al, _VAL + out A9BSerialDataRW, al + endm +; +SETSPEED macro _SPEED + pushf + cli + in al, A9BChannelSelectRW + and al, not (mask A9MSerialClockRate) + ifidni <_SPEED>, + or al, A9VSClkRateFast + endif + ifidni <_SPEED>, + or al, A9VSClkRateMedium + endif + ifidni <_SPEED>, + or al, A9VSClkRateSlow + endif + out A9BChannelSelectRW, al + popf + endm +; +XPUSHFCLI macro + endm +XPOPF macro + endm +XNOP macro + endm +; +@HwNullFrame macro + out A9WNullFrameW, ax + endm +endif +; + .list + diff --git a/code/HDK/Psion SIBO HDK 1.0 Source.zip b/code/HDK/Psion SIBO HDK 1.0 Source.zip new file mode 100755 index 0000000..6f6d60b Binary files /dev/null and b/code/HDK/Psion SIBO HDK 1.0 Source.zip differ diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0.pdf b/code/HDK/Psion SIBO Hardware Development Kit 1.0.pdf new file mode 100755 index 0000000..84018a7 Binary files /dev/null and b/code/HDK/Psion SIBO Hardware Development Kit 1.0.pdf differ diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_chocr.html.gz b/code/HDK/Psion SIBO Hardware Development Kit 1.0_chocr.html.gz new file mode 100755 index 0000000..8b2c8a9 Binary files /dev/null and b/code/HDK/Psion SIBO Hardware Development Kit 1.0_chocr.html.gz differ diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_djvu.txt b/code/HDK/Psion SIBO Hardware Development Kit 1.0_djvu.txt new file mode 100755 index 0000000..4ca98b6 --- /dev/null +++ b/code/HDK/Psion SIBO Hardware Development Kit 1.0_djvu.txt @@ -0,0 +1,10692 @@ +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +THE PSION SIBO HARDWARE DEVELOPMENT KIT + + +Version 1.00 + + +May 26 1995 + + +Revision 1.00 Page i + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +(c) Copyright Psion PLC 1990-93 + + +All rights reserved. This manual and the programs referred to herein are copyrighted works of Psion +PLC, London, England. Reproduction in whole or part, including utilisation in machines capable of +reproduction or retrieval, without express written permission of Psion PLC, is prohibited. Reverse +engineering is also prohibited. + + +The information in this document is subject to change without notice. + + +Psion and the Psion logo are registered trademarks, and Psion, Psion MC, Psion HC, Psion Series 3, +Psion Series 3a and Psion Workabout are trademarks of Psion PLC. + + +TopSpeed is a registered trademark of Clarion Software Corporation. Intel 8086 and 80286 are +registered trademarks of Intel Corporation. IBM, IBM XT and IBM AT are registered trademarks of +International Business Machines Corp. Microsoft and MS-DOS are registered trademarks of +Microsoft Corporation. Apple and Macintosh are registered trademarks of Digital Equipment +Corporation. Brief is a registered trademark of Underware Inc. Psion PLC acknowledges that some +other names referred to are registered trademarks. + + +Revision 1.00 Page ii + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Contents + + +‘ +De IMGrOMUCUON sec ioiciescccetisshicattxstcathaslicatixssdcstenslacatenstecatenslicatinssdesvenslacevinswdvatensldcsvisatibiteislacibedse + + +2. System Overview..........scccccscssccssssscscsscsseccsscssecssccsesssscssesssscsssesscssesssssesssscssssssscssssssscsessssesesseeees + + +3. Hardware Overview .........sssccssssssssssscssscssscsssssssesssesssesssesssesssssssssessscssscsssessesssesssnssseesscseoeeees +The Psion SIBO serial protocol .... +Psion ASICs and what they do.. +Interrupts . +The current range of Psion periphera + + +4. The Psion SIBO Serial Protocol . +Hardware Interface ... +The Physical layer . +The Transport layer .. + + +5. Mechanical Overview ...........sscssscsssssrscsssssessscessecssessessssesseessessscesssessesscssssssscsssessccssesssessosees LD +The Psion Series 3/3a range ... +The Psion Workabout +The Psion HC range + + +6. ASIC 4......... +ASIC4 Addressing and Modes +Reset and configuration +ASIC4 Pin-out + + +7. ASIC 5.......scesee +ASICS Mode +Reset and configuration +ASICS Pin-out + + +8. Example Peripheralls................cccssccssssssssssssseccsscscccssssscsssscccesssscscesssssesssscsssssssssesscsssssscsseeesess OO +The ASIC4 Example Interface Board.. +The Psion 3-Link + + +9. Device Driver Overview...........cccsrsercesssserscersserecssecssesscesssesesssessssessesssesscsscssscsssssssesssessosees OT +Introduction +Device Names and Channel: +Loadable Logical Device Driver Structure +Mandatory LDD Functions ............... +Interrupts and Interrupt Service Routines at +Loadable Physical Device Driver Structure... ccscecesesesseesssesssesesssesesesescseseseenenesesesesesesenenesseesesesusueasaeaeseeessecacaeaeaeenenssesecasaseeeeeneeeeeaeaes + + +10. ASIC4/ASIC5 Based Device Drivers + + +Introduction +SIBO Hardware Expansion Channels +Talking to ASIC4.. +ASIC4 Registers +Talking to ASICS .. +ASICS Registers... +Communicating with ASIC4 +Sending and Receiving data using ASIC4. +Obtaining and using a channel... +Controlling ASICS's UART +Hold and Resumes. +Example Device Driver: + + +11. An Example Device Driver for ASIC4: A4EXIF.LDD.. + + +Introduction + + +oo TO eR UU RS gs pad + + +Mandatory LDD Function: +The Non-Mandatory LDD Functions..........cceee +The handling of synchronous and asynchronous I/O +Interrupts and Interrupt Service Routines +Other important local device driver functions +Structures and Include files «0... cee + + +12. An Example Device Driver for ASIC5: SYS$AS5.PDD.............ssssssssssssssessessessssesscsessessesseee 77 + + +Introduction +The LDD-PDD interface. + + +13. Debugging and Testing Device Drivers +Introduction .... +Debugging Techniqu +Further Testing Strategies ae +Memory Lestitng seiscs lech easch oiece siscn Sates losecdestecwcsautsse sean tosevaleslosedtracepudtesiiensdertoanioenteoisebeensse bait es ieettaus adanus teats a a tanta eae + + +APPENDIX: Source Code Files.. +A4EXIF.ASM oo +SYS$AS5.ASM .... 102 +Assembler Macros. 1S + + +Revision 1.00 + + +Page iii + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +1. INTRODUCTION + + +This document is intended to provide guidance to anyone wishing to construct peripherals for the +Psion SIBO (sixteen bit organiser) range of computers. It describes in detail all aspects of Psion +peripheral hardware development and the structure of the software required to drive such peripherals. +It is the aim of this document to aid third party development engineers in producing production ready +peripherals for any of the following Psion products: Series 3/3a, Workabout, HC and HCDOS. +Mechanical and plastic moulding information and information on how to develop production test +equipment is therefore also included. The emphasis throughout is on the two key Psion peripheral +chips ASIC4 and ASIC5. Detailed information regarding their functionality is provided. The +structure of Psion hardware device drivers is examined both in general outline and then with regard to +two specific examples whose source code is provided in the appendix to this document. It has been +assumed that the reader has some knowledge of a Psion computer such as the Series 3/3a and an +understanding of how such a machine is programmed. A good understanding of electronics, the C +programming language and 8086 assembler is also assumed. + + +Due to the continuous nature of development, information in this manual may change without notice. + + +Developers are advised to contact Psion Support to confirm critical details prior to committing +products to manufacture. + + +Revision 1.00 Page | of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +2. SYSTEM OVERVIEW + + +All present Psion computers are based around the proprietary SIBO architecture. A SIBO machine is +a battery-powered, 8086-based, computer system. SIBO stands for SIxteen Bit Organiser. The +architecture has been designed with the size, weight and power consumption of computers designed +for the portable environment in mind. The key components of the SIBO architecture are: + + +e —_ An 8086 class processor . + +e A sophisticated power management system that selectively powers subsystems under software +control. + +e — Asynchronous, high speed, serial protocol (the Psion SIBO serial interface) for communication +between a machine and its peripherals. + +e —_ Solid State Disks (SSDs) that provide fast, low-power, silicon-based mass storage with no +moving parts. + +e Hardware protection of the system from aberrant software processes (trapping of out of range + +addressing and a watch-dog timer on interrupts being disabled). + +Real-time clock. + +ROM-resident system software. + +Graphics LCD display. + +A touch sensitive digitising pad that provides a pointing device (only available on some models). + +ISDN-8bit standard combo sound system (only available on some models). + + +The SIBO architecture has primarily been implemented in custom ICs called ASICs. At the time of +writing there are ten different SIBO ASICs. Some of these ASICs have been designed for use inside +peripherals and these will discussed in detail throughout this document. All SIBO ASICs have been +implemented in surface mount packages and are based on a static CMOS technology. Current SIBO +products in the MC, HC and Series 3 range are based on the same three principal chips. These are +the V30H (an 8086-compatible processor) and two Psion custom chips known as ASIC1 and ASIC2. +Later SIBO products including the Series 3a and Workabout have these three devices integrated into a +single Psion custom chip known as ASIC9. The V30H is an enhanced 16-bit CMOS version of the +8088 found in the original IBM PC. It is software compatible with the 8088. The V30H is a fully +static design which means that all the internal storage elements (i.e. its registers) are made from static +rather than dynamic storage components. This in turn means that there is no minimum clock speed +required to refresh the storage elements and the system clock can be stopped at any time with no loss +of internal state. This technique is used extensively in the SIBO architecture to save power while the +processor is idle (i.e. waiting for an event). + + +The Psion SIBO serial protocol is a proprietary synchronous two wire serial standard by which host +Psion handhelds communicate with external devices. These devices will typically be Memory Packs +(usually referred to as Solid State Disks or SSDs), RS232 and Centronics printer interfaces, fax +modems, bar-code scanners, and so on. The SIBO architecture provides for two basic forms of +expansion device, namely the extended internal expansion connection (as with SSDs) and the reduced +external expansion connection (the 6-pin S3a serial port or the 11-pin LIF connector). The MC and +HC range of computers have two SSD ports and two separate independent single row 25-way +extended internal expansion ports. These ports have in addition to a Psion SIBO Channel, direct, +parallel I/O from the processor. Direct connection to these machines 7.2 volt battery is included to +support high power peripherals such as Printers and Barcode readers. The Series 3 range of +computers have two ports for SSDs and a single, reduced, 6-pin expansion port, which provides only a +Psion SIBO serial channel and limited power (<25mA). The Psion Workabout has two SSD ports, +two internal expansion points, and one external expansion port. The single external expansion port +uses an | 1-pin Low Insertion Force (LIF) socket which provides a Psion SIBO channel, 25mA of +current and additional lines required for detecting the presence of the Workabout cradle. Each +internal expansion port consists of a single row 26-way connector carrying two high speed serial +ports. + + +Revision 1.00 Page 2 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +A range of Psion peripherals have been produced for connection to the Psion handhelds outlined +above. These peripherals currently incorporate one of two custom integrated circuits (ASIC4 and +ASICS) that convert SIBO serial protocol signals to data bus TTL level voltages which enable +memory and memory-mapped peripherals to be addressed. ASIC4 is used in SSDs and for memory- +mapped peripherals. A typical ASIC4 peripheral for a Psion S3a would consist of an ASIC4 +connected to port C of the host machine and a peripheral chip/device mapped into ASIC4's addressing +space. ASICS is a general purpose I/O chip with a UART on board that can be run in several +different modes. For example ASICS can be used for MCRs (magnetic card readers) or Centronics +interfaces thereby simplifying peripheral design. Psion extended internal expansion ports carries an +active low interrupt input line to the host controller circuitry. The reduced external expansion ports +has an active high interrupt input line. The function of the interrupt can thus be programmed into the +host machine's ASIC1 or ASIC9. + + +The low-level programming interface to a Psion handheld peripheral is encapsulated within an +appropriate device driver. Psion device drivers are written in 8086 assembler and follow a prescribed +pattern outlined later in this document. The construction of a peripheral and the coding of its +complimentary device driver enable the developer to access its functionality through the means of +library calls in a C program. Examples of such calls are p_loadldd(), p_open() and p_close(). +I/O requests are routed through the device driver's strategy vector which maps to the PLIB p_iow () +call. The device driver is built using the Borland Turbo Assembler and resides in a single code +segment. The device driver can be stored in either RAM or a ROM on board the peripheral or can be +supplied on an SSD (solid state disk). + + +Revision 1.00 Page 3 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +3. HARDWARE OVERVIEW + + +The Psion SIBO serial protocol + + +The Psion SIBO serial protocol is a general purpose method of bi-directional serial data transfer. It +has been designed for synchronous communication between a host controlling device and a number of +slave devices. On a hardware level, the SIBO serial protocol is implemented through Psion ASICs. +The controlling device must contain an ASIC2 (or ASIC9) and the slave devices an ASIC4 or ASICS. +The various Psion ASICs are described in more detail below. + +The synchronous SIBO serial protocol interface consists of 2 wires: + +CLK ~ - Aclock output from the controller to the slaves. Nominally 3.84 MHz. + +DATA - A bi-directional synchronous data line. + +The data is transferred using a series of 12 bit frames including 8 data bits each. This equates to a +theoretical maximum data transfer rate of approximately 312 Kbytes/second. Other bits of the frame +contain control information. The "system" is generically defined by 2 protocol layers, namely the +Physical layer and the Transport layer. These layers are described in detail in the next chapter. + + +Psion ASICs and what they do + + +ASIC stands for Application Specific Integrated Circuit and as previously indicated, these devices are +widely used within Psion hardware. Summaries of the functionality of each ASIC that is relevant to +peripheral development are presented below: + + +ASIC1: ASIC1 is the main system controller chip for the SIBO architecture. It connects directly to +the 8086-based processor (i.e. the V30H) controlling all bus cycles to and from the processor. This +configuration effectively forms a micro-controller like device that executes 8086 instruction codes. +ASIC 1 is made up of a number of functional blocks including a bus controller, a programmable +timer, an eight input interrupt controller, an LCD controller and the memory decoding circuitry. + + +ASIC2: ASIC2 is the peripheral controller chip for the SIBO architecture. It contains the system +clock oscillator and controls switching between the standby and operating states. ASIC2 provides an +interface to the power supply, keyboard, buzzer and SSDs. ASIC 2 includes the eight-channel SIBO +serial protocol controller and provides interface circuitry to both the reduced external and extended +internal peripheral expansion ports. + + +ASIC4: ASIC4 is a serial protocol slave IC for addressing memory and general memory-mapped +peripherals. It is used in SSDs to convert SIBO serial protocol signals into addresses within the +memory range of the memory pack. ASIC4 was designed to be a cut-down version of ASICS which +was the original SIBO serial protocol slave chip. + + +ASICS: ASICS is a general purpose I/O chip with a built-in UART that can be set to run in a number +of different modes thereby simplifying the task of peripheral design. For example, it is possible to set +up ASICS to run as a Centronics parallel port interface, an 8-bit parallel I/O port, a serial bar code +controller or a serial RS232 converter. + + +ASIC9: ASIC9 is a composite chip comprising of a V30H processor, ASIC1, ASIC2 and general I/O +and PSU control logic all on one IC. ASIC9 thus integrates all the digital logic required to produce a +SIBO architecture computer less the memory onto one chip. ASIC9 has a few additional features +such as an extra free-running clock (FRC) and a codec interface for sound. + + +Revision 1.00 Page 4 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Interrupts + + +Psion peripherals usually incorporate some circuitry to generate hardware interrupts. Both reduced +external expansion ports (such as the LIF connector on the Workabout or the 6-pin serial port +connector on the S3a) and extended internal expansion ports (such as the two single row 25-way HC +connectors) carry an interrupt line. This is an active high input to the host machine's interrupt +controller circuitry which resides on the logical equivalent of ASIC1. The OS intercepts all interrupts +and can be requested to call a particular function within a controlling device driver. Eight hardware +interrupts are supported by SIBO hardware. IRQO is the highest priority and IRQ7 the lowest. All +interrupts are level triggered and must be serviced in the following order: + +e Device asserts the appropriate interrupt request line. + +e The interrupt controller unit within either ASIC2 or ASIC9 places onto the data bus the vector of +the highest priority device with an interrupt pending. This enables the CPU to jump to the +correct interrupt service routine code. + +e During the interrupt service routine, the software clears the interrupt line by some action specific +to the device. + +e The interrupt service routine then informs the interrupt controller that the interrupt has been +cleared by writing to the non-specific end of interrupt (NSEOD) location. + +e If another interrupt is pending then go back to the second step. + +With 8086-based processors, it is not possible to have nested interrupts. + + +The current range of Psion peripherals + + +There are currently a number of Psion peripherals in use and some of the key ones are outlined below +in order to provide the developer with a feel for peripheral design issues: + +SSDs: Solid State Disks (or Memory Packs) use a built-in ASIC4 to decode SIBO serial protocol +signals into memory addresses within the memory range of the SSD. + +Psion 3-link: The 3-link translates the high speed SIBO serial protocol channel on the S3a 6-pin +reduced external expansion socket into a serial RS232 format. This enables the host machine to +communicate with a PC for example by means of connecting the 3-link unit from the handheld's 6-pin +port to the PC's COM1 or COM2 port. The 3-link contains an ASICS which uses its on-board UART +to convert SIBO serial protocol signals to RS232 format TTL level voltages. + +The HC Printer: The HC Printer translates SIBO serial protocol signals transmitted across the single +row 25-way extended internal expansion socket of the host HC into a parallel 8-bit format that is +compatible with the universal Centronics printer interface standard. The HC Printer unit contains an +ASICS running in Centronics interface mode which acts as the serial protocol slave and requires a +small number of support chips. + +Psion 3-Fax: The 3-Fax contains an ASIC4 and a memory-mapped modem chip set which permits the +host machine to transmit (but not receive) fax messages. + +Barcode: The Psion Barcode reader employs an ASICS running in serial mode to read the data +received from the barcode decoder chip into a SIBO serial protocol format that can be transmitted to +the host ASIC2/ASIC9. + +Workabout RS232 Interface: This peripheral connects to the single row 26-way extended internal +expansion port of the Workabout. It incorporates an ASICS running in its default mode to translate +SIBO serial protocol signals into a TTL level (+/-5v) serial RS232 format using ASIC5's on-board +UART. The TTL level RS232 signals are converted into the standard EIA format (+/-12v) before +coming out on the conventional RS232 9-pin D-type connector. + + +Revision 1.00 Page 5 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +4. THE PSION SIBO SERIAL PROTOCOL + + +Introduction + + +The Psion SIBO serial protocol is a proprietary standard for bi-directional serial data transfer between + +a controlling device and a number of slave devices. The synchronous interface consists of 2 wires + +CLK and DATA as mentioned earlier: + +CLK _~ - Aclock output from the controller to the slaves. Nominally 3.84 Mhz for memory + +interfaces or 1.536.Mhz continuous for peripherals. + +DATA - A bi-directional synchronous data line. + +The data is transferred using a series of 12 bit frames including 8 data bits each. This equates to a + +theoretical maximum data transfer rate of approximately 312 Kbytes/second. Other bits of the frame + +contain control information. The "system" is generically defined by 2 protocol layers:- + +e The Physical layer defining the hardware interface and frame structure. + +e The Transport layer defines system control and register transfers between the controller and the +slaves. + +Using this system, a large number of higher level implementations can be defined. In normal use the + +controller will communicate to slaves in a point to point configuration. Multidrop configurations with + +a number of slaves attached to one channel of the controller are also supported. + + +As indicated in the previous chapter, the SIBO serial protocol controller circuitry resides in either an +ASIC2 or an ASIC9 depending on the particular Psion hardware platform. The S3a and Workabout +employ ASIC9 whereas the HC, MC and S3 use ASIC2. + + +Hardware Interface + + +As indicated above, the SIBO serial protocol consists of two lines that switch at 5V CMOS voltage +levels: + + +Clock Line + + +This line is used to synchronously clock data between the controller and slaves. It is always output +from the controller circuitry that resides in ASIC2/ASIC9. The clock should only be active during the +transfer of data or when the serial channel is continuous clocking mode (used by ASICS). At all other +times it is tri-state pulled low. + + +Clock Timing Parameters + + +Parameter +Width of Clock High + + +Width of Clock Low +Cycle time of clock +Clock Frequency + + +Data Line + + +This is a bi-directional line used to transfer data synchronously between the controller and slaves. +The direction of the data line is not determined by the physical layer but by the control information in +the transport layer. This is described in the next section. When no data transfers are in progress the +data line is always set to input on both the controller and slaves. This line is pulled low. Data is +changed on the falling edge of clock by the transmit device and latched into the receiving device on +the rising edge of the clock. + + +Revision 1.00 Page 6 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The Physical layer + + +This section specifies the low level protocol of the SIBO serial protocol. The physical layer protocol +consists of a series of 12 bit frames. There are four types of frames:- + +Null frames - Transmitted by controller to synchronise slaves. + +Control frames - Control information transmitted by controller to slaves. + +Data output frames - Data frame transmitted by controller to slaves. + +Data input frames - Data frame received by controller from a slave. + + +Frame structure + + +All 12 bit frames have the following structure:- + + +Bit + +Name ST + +ST Start bit. This bit goes high to indicate the start of a valid frame. + +CTL ~~ Control bit. When low indicates this is a control frame. High indicates a data frame. +Il Idle bit. Used to turn around direction of data line. Normally Low. + +DO-D7 Data bits. + +12 Idle bit. Used to turn around direction of data line. Normally low. + +Null Frame + + +This is a special frame transmitted by the controller to ensure all slaves are synchronised. It is +generated by transmitting 12 clock pulses with the data line set to input. Since the data line is pulled +low this results in 12 zeroes being transmitted. + + +Control frame + + +This frame is transmitted from the controller to one or more slaves. The data line is an output from +the controller throughout the whole frame. The bits in the frame have the following value in a control +frame: + + +ST Start bit. This bit goes high to indicate the start of a valid frame. +CTL Control bit. Low to indicate this is a control frame. + +I1 Idle bit Set low. + +DO-D7 Data bits. 8 bits of control information. + +I2 Idle bit Set low. + + +Data Output Frame + + +This frame is transmitted from the controller to one or more slaves. The data line is an output from +the controller throughout the whole frame. The bits in the frame have the following value in a data +output frame: + + +ST Start bit. This bit goes high to indicate the start of a valid frame. +CTL Control bit. High to indicate this is a data frame. + +Il Idle bit Set low. + +DO-D7 Data bits. 8 bits of transmitted data. + +12 Idle bit Set low. + + +Data Input Frame + + +This frame is received by the controller from a slave. The data line is an output from the controller +for cycles 1 and 2 and input to the controller for cycles 4 to 11. The bits in the frame have the +following value in a data input frame: + + +ST Start bit. Output from controller. This bit goes high to indicate the start of a valid +frame. + +CTL Control bit. Output from controller. High to indicate this is a data frame. + +Il Idle bit. Used to turn around direction of data line. Both controller and slave + +should tri-state the data line during this bit. This bit should be low due to pull + +down resistor on data line. The controller changes the data line from output to + + +Revision 1.00 Page 7 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +input at the end of cycle 2. The slave changes the data line from input to +output at the start of cycle 4. + + +DO-D7 Data bits. Output from slave 8 bits of data transmitted by slave. Controller sets data +line to input during these bits. + +12 Idle bit. Used to turn around direction of data line. Both controller and slave + +should tri-state the data line during this bit. Should be low due to pull down + +resistor on data line. The slave changes data line from output to input at the end of +cycle 11. + + +Data line direction + + +The following table summarises the direction of the data line. + + +CONTROLLER SLAVE +Condition CK DATA CK + + +Outside Frame + +Null frame + +Control Frame + +Data output from controller + +Data input to controller:- +Cycles 1-2 +Cycle 3 +Cycles 4-11 +Cycle 12 + + +OO000 0004 + + +Key T Tri-state +I Input +O Output + + +The Transport layer + + +This section specifies the transport level protocol that operates above the SIBO serial communication +physical layer. The transport layer protocol controls the serial communication between the SIBO +Protocol Controller (SPC) and a number of SIBO Protocol Slave (SPS) devices. The following rules +apply:- + +1) The interface is controlled by the writing of control bytes from the controller to the slaves. Control +bytes cannot be written by the slaves. + +Unsolicited data cannot be sent from the slave to the controller. + +2) The controlling device contains two registers to communicate to the slaves. These are the control +register (byte, write only) and the Data register (byte or word, read/write). + +Control bytes are transmitted to the slaves by writing to the control register. + +The format of the control byte is as follows:- + + +The control word can have 2 distinct formats depending on the setting of bit 7 the Select (S) bit:- +Select = 0 This is the slave select mode. This mode is for selecting, deselecting and resetting slaves. +Select = 1 This is the slave control mode. This mode is for communicating with a slave which has +been previously selected using the select slave command. + + +Revision 1.00 Page 8 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Slave select mode + + +The format of the slave select byte is as follows:- + + +Key:- +R single reset bit. +TU 6 bit ID field. + + +The 6 bit ID field is a property only of the slave. No slave may have an ID of zero, hence there can be +63 different slaves connected to one controller. The reset bit (R) controls whether the slave(s) are +selected or reset. If R = 0 slave(s) are reset, R = | slave(s) are selected. Slave select control bytes can +be summarised by the following table:- + + +Description +Reset all slaves + + +Reset specific slave with ID = xx +Deselect slave (does not reset slave) +Select slave with ID=xx and read slave info (see below). + + +The Reset function is dependant on the slave. It would normally put the slave into a known passive +reset state. + +Select Slave with ID=xx (S=0,R=1) + +This is a special command that causes a slave with ID=xx to transmit to the controller an 8 bit +information field. This field depends entirely on the slave but must be non zero. A reply of 0 +indicates that there is no slave of the requested ID present. + + +Slave control mode + + +This mode is for communicating with a slave which has been previously selected using the select +slave command described above. +The format of the control word in slave select mode is as follows:- + + +R/W Read/write select. 0 = write, 1 = read + +B/W Data transfer size. 0 = 1 byte transfer, 1 = word (2 byte transfer). +S/M Single/Multi transfer mode. 0 = single, 1 = multibyte. + +XXXX = 4 bits of data to slave. + + +Note the meaning of the 4 bits of data (XX XX) is entirely dependent on the slave. + + +The settings of R/W,B/W,S/M bits in the control word determine the size, type and direction of +subsequent data transfers in the following manner:- + + +Revision 1.00 Page 9 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +R/W B/W _ S/M + +0 0 0 write a single byte to slave + +0 0 1 write a number of single bytes to slave + +0 1 0 write a byte pair to slave (not implemented) + +0 1 1 write a number of byte pairs to slave (not implemented) + +1 0 0 read a single byte from slave + +1 0 1 read a number of single bytes from slave + +1 1 0 read a byte pair from slave (not implemented) + +1 1 1 read a number of byte pairs from slave (not implemented) +Write a single byte + + +This command readies the currently selected slave to receive a byte of data and sets up the controller +so that the next byte (or the LSB of a word) written to its data register will be transmitted to that +slave. Anything further written to the controller's data register will have no effect. + + +Write a number of single bytes + + +This command readies the currently selected slave to receive a number of sequential bytes of data. +The slave will expect to receive data bytes until another control byte is received. The controller is set +up so that the next byte (or the LSB of a word) written to its data register will be transmitted to that +slave. All subsequent bytes written to the controller's data register will be transmitted to the slave. +This will continue until another byte is written to the controller's control register. + + +Write a byte pair + + +This command readies the currently selected slave to receive two bytes of data and sets up the +controller so that the next word written to its data register will be transmitted to that slave (LSB first). +Anything further written to the controller's data register will have no effect. + + +Write a number of byte pairs + + +This command readies the currently selected slave to receive a number of sequential byte pairs of +data. The slave will expect to receive byte pairs until another control byte is received. The controller +is set up so that the next word written to its data register will be transmitted to that slave (LSB first). +All subsequent words written to the controller's data register will be transmitted to the slave. This +will continue until another byte is written to the controller's control register. + + +Read a single byte + + +This command triggers a byte to be transmitted from the selected slave to the controller. This byte +can then be read from the LSB of the controller's data register. Further reads of the controller's data +register will return the same data but have no effect on the protocol. + + +Read a number of single bytes + + +This command triggers a byte to be transmitted from the selected slave to the controller. This byte +can then be read from the LSB of the data register. This read will trigger the next byte to be +transmitted to the data register of the controller. All subsequent reads of the controller's data register +will trigger further bytes to be transmitted to the controller. This will continue until another byte is +written to the controller's control register. + + +Read a byte pair + +This command triggers a byte pair to be transmitted from the selected slave to the controller. This +word can then be read from the controller's data register. Further reads of the controller's data +register will return the same data but have no effect on the protocol. + +Read a number of byte pairs + + +This command triggers a byte pair to be transmitted from the selected slave to the controller. This +word can then be read from the controller's data register. This read will trigger the next byte pair to + + +Revision 1.00 Page 10 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +be transmitted to the data register of the controller. All subsequent reads of the controller's data +register will trigger further byte pairs to be transmitted to the controller. This will continue until +another byte is written to the controller's control register. + + +Timing +The time taken for commands to be processed and data sent is shown below. The time is given in + + +SIBO pack protocol clock cycles. The length of a clock cycle is nominally 260 nanoseconds for a +clock frequency of 3.84 MHz. + + +Receive and process the control byte 12 cycles +Byte transfer to or from slave 12 cycles +Byte pair transfer to or from slave 24 cycles + + +When writing to the controller's data and control registers the following rules apply:- + +e After writing to the control register there must be a delay of at least 12 cycles before the data +register is accessed or another control word is written. + +e Toread a word from the data register after the command to read byte pair is issued there must a +delay of at least 12 (for control byte)+24 (for the byte pair transfer)= 36 cycles. + +e To perform a multiple byte pair write there must be a delay of at least 12 cycles after the +command is written to the control register before the first word can be written to the data register +and a delay of at least 24 cycles between subsequent writes to the data register. + + +States + +A slave can be in one of 5 states. Note a control byte can be received and interpreted at any time. +1) Waiting to receive a data byte or control byte + +2) Waiting to receive a data byte pair or control byte + +3) Waiting to transmit a data byte or control byte + +4) Waiting to transmit a data byte pair or control byte + +5) Waiting to receive control byte only + + +Revision 1.00 Page 11 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +5. MECHANICAL OVERVIEW + + +This section will contain information regarding mechanical and plastic moulding for Series 3/3a, +Workabout and HC machines that is deemed to be of especial importance to developers who are +considering producing peripherals for these particular Psion platforms. + + +The Psion Series 3/3a range + + +S3a/Series 3 Reduced External Expansion Port + + +The Psion Series 3/S3a personal digital assistants have two SSD slots and provide access to external +peripheral units through a single reduced internal expansion port, port C, on the left edge of the +machine. The reduced external serial interface expansion port from the Series 3/3a forms six wires. +The purpose of each is described in the table below. In addition to data, clock and power an active +high interrupt line is provided. This allows the peripheral device to generate an interrupt within the +host series 3/3a. The level of interrupt that is generated depends on both the machine and the +expansion port that is used. Either ASIC4 or ASICS can act as the other end of the Psion Serial +Interface. With exception of the interrupt line all used signals should be connected directly to the +appropriate pins on ASIC4/5. + + +ASIC4/5 SDAT +MCLK Serial clock ASIC4/5 SCLK + + +| 6 | SCK/EXON | Not used in this scenario | Donot Connect____| + + +Signal Definition + + +MSD and MCLK form a single master SIBO serial protocol channel. This is normally channel 7 on a +Series 3 and channel 5 on an S3a. The serial channel clock can be continuously enabled to provide a +free running clock for expansion devices. The frequency is fixed at 1.536MHz regardless of the +system clock frequency. SDKs/INT and SCK/EXON are both dual function pins. SDKS and SCK +form a single slave SIBO serial protocol channel. This can be combined with MSD and MCLK to +form a bi-directional high speed data link. SDS/INT can also be used to as an active high interrupt +input. The function of SDS/INT can be programmed in ASIC2 or ASIC9. A rising edge on the +SCK/EXON input will bring the system out of the standby state into the operating state. VCC is a +5 +volt supply that is switched off when the system is in the standby state and is switched on when the +system is in the operating or idle state. The maximum current that can be drawn is 25mA. Opening +the pack doors on either an S3a or a Workabout will cut power to external peripherals. + + +Physical Connector + + +The reduced expansion port is made up of a 6-way two row connector spaced on a 2x3 way 0.1 inch +pitch. The diagram below shows the physical connector numbering: + + +Revision 1.00 Page 12 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Looking into Series 3 / 3a + + +The male plug is connected to a 0.5m long plastic moulded 3-link cable assembly (part no. 25020013) +which is terminated in a six-pin in-line connector which connects to a 6-way 1.5mm pitch transition +header (part no. 47000106). + + +The Psion Workabout + + +The Workabout Expansion Interfaces + + +The Psion Workabout provides a rugged and easy-to-use computer system for a wide range of mobile +corporate needs. The machine can be readily adapted to support various peripheral units such as +barcode scanners and modems attached to the expansion ports. The Workabout has a 26-way +extended internal expansion interface and a special 11-pin reduced external expansion interface. + + +Workabout Extended Internal Expansion Interface + + +The pin-out of the Workabout 26-way internal Torson connector is outlined below: + + +Torson 26 way connector pin Workabout Signal name +NICD (not used) + + +THM (not used) +VIN (not used) + + +Revision 1.00 Page 13 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +e = Vccl is 3.0V nominal power supply. Current available from Workabout is limited to 100mA. + +e =Vcc2 is 5V nominal power supply. Current available from Workabout is limited to 200mA. + +e RUN is low when powered down and high when powered up. It is used to power down or reset +the peripheral module. + +e SCK2 and SCK3 are serial data clocks. The clocks are left running continuously at 1.536MHz +when the serial port is in use. They are used to clock the UART in ASICS in the RS232 AT/TTL +and AT/Barcode modules respectively. + +e SD2 and SD3 are bi-directional serial data lines used in the RS232 AT/TTL and AT/Barcode + +modules respectively. + +EINT1 and EINT2 are active low signals for interrupt input. + +EXON is an active high signal used to turn on the Workabout. + +All of the above logic signals are at 3.0V or 3.3V levels, depending upon the logic supply Vcc1. + +Lines currently described as unused relate to a yet unspecified codec interface. + + +Workabout Reduced External Expansion Interface + + +For the Workabout reduced external expansion interface, a new | 1-pin Low Insertion Force (LIF) +connector has been designed for connecting the computer to the Cradle System. The computer +mounted male LIF may be weather proofed, the cable mounted female LIF cannot. Currently the LIF +connector cover can be moulded with a polarising pin in one of two positions. The facility exists to +manufacture the cover with the polarising pin in two more positions, giving four possible variants. If +more than four versions are required it is possible to have the cover and the socket bezel moulded in a +range of colours to differentiate between variants. The polarising options are presented below: + + +Pin numbers +1st (1 GROUND 9 +2nd (________] SIGNALS 2,3,4,5,8,10 +1,6,7,11 + + +The step arrangement of the LIF Connector pins + + +Cable mounted LIF (Female plug) Computer mounted LIF (Male socket) + + +Revision 1.00 Page 14 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +3S 310 + + +@e0000 08 +ODOOOO + + +Cable mounted LIF (Female plug) Computer mounted LIF (Male socket) + + +Type A and Type B polarisation of the LIF Connector + + +Revision 1.00 Page 15 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Pin Definition for LIF - PFS Connector +LIF Connector Polarisation Type B + + +Pin Pin Name Wire Colour Contact Direction Standard Function Cradle usage +No Gauge (Cradle's +perspective) + +1 LCA 710.1 Brown third Input Local’ Computer Active. High when the Used as an enable for the cradle +computer is on. (The Workabout can source resident Xmod 5V supply. +100mA from this pin and the HC/HCDOS +5mA to power remote circuitry) + + +EXON 710.1 Blue second Output EXternal switch ON, active high (+5V). May be asserted by a cradle resident +Asserted by a remote” device to switch on Xmod. +the computer. +Xmod. + + +se He 1 a eee eet Battery thermistor terminal. Allows remote“ function +eae of the battery temperature. + + +meal 1 Bead ie Output Disconnect Local” ASIC, active high (+5V). Asserted by the Cradle ASIC, +(does not apply to Workabout). When this connects the cradle resident Xmod to +signal is asserted the serial channel is the serial channel. +disconnected from the local? ASIC4/5 in the +HC resident Xmod (if present) and instead +connected to a remote ASIC4/5 (if present). + + +FN Te +| 7 | vin | 28SwG Power supply to computer (+10V) +| 8 | SCLK 710.1 | SerialchannelCLocK. + + +GND 28 SWG White “fiat Power, [Seval channel Chev —_____ ground and -ve battery Standard function +terminal (1 amp) + + +SDATA 710.1 Serial channel DATA. + + +11 STATUS 710.1 Pink third Cai STATUS. Connected to a pull-up resistor to Driven low by an open collector driver +allow connection to an open-collector/drain when LCA is high and the cradle is +driver. Normal usage is: low indicates the powered-up to allow the computer to +presence of a remote” device. sense whether or not the cradle is + +connected. + + +LIF Connector Polarisation Type A + + +Pin Wire Colour Contact Direction Function +No eine Gauge (Computer's +perspective) +ee oe RS2I2 signal +a a RS232 signal + + +77 Output | RS232 signal +THERM [7101 [Yellow [ second_[ =] Battery thermistor terminal + + +[svar [2sswo [Red [tind [- | tvebattery terminal ——SSSSSCSCSCSCSCSCSCSCC~C~* +[3 [pe 701 [Grey [second [Input [ RS232signal OSS +[9 [exp eswo [white [fist [= | Power, signal ground and ve battery terminal —____——SS—~S + + +Definitions + +Computer HC, HCDOS or Workabout + +Cradle resident Xmod Expansion module fitted to the cradle, may or may not be present. + +HC resident Xmod Expansion module fitted to the HC, which contains the cradle interface and possibly another peripheral. +HC peripheral A peripheral, located in the HC resident Xmod which is connected to the same serial channel as the cradle. +Cradle ASIC An ASICS located on the main cradle PCB which remains connected to the serial channel + + +irrespective of the state of DLA. + + +1. | The term "local computer" implies the computer local to the LIF connector, i.e. the HC, HCDOS or Workabout, as opposed to +a "remote" computer which might be connected via a cradle resident Xmod for example. + +2. The term "remote" implies something on the other side of the LIF connector to the computer. + +3. | The term "local" implies something on the computer side of the LIF connector including devices on an HC resident Xmod. + + +Revision 1.00 Page 16 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Exploded view of the Psion Workabout + + +Below is an exploded view of a complete Psion Workabout showing part numbers for various +components and illustrating the positioning of the expansion interfaces. + + +4 +g y +o # ” +4 a § 8 +Ss 8 +4 gy Fa i +f a Of i +a 8 a a +a « +a 2 +8G +Roo +ae +38 +a3 +3 +a @ ¢ +me oON Sgt +3 +ROS +a 3 g +® S +8 +Be $3 +$s $8 +a 8 28 += +o +j z +a 3 +a3 F | +8 +a 4 9 Boa ey +3 a a 9 3 +a g 4g 1 o +& & a9 3 4 2 +# 8 . p 3 3 +zh ae 6 ¢ a +3 i 3 f é i 3 " +3 a8 a 8 2 3 § +goa +3 BS +g a 8 Poa +3 +5 : +a 8 a 9 +a oF a + +& § +ff 42 +Oo oN bos +ng +a 3 +al +a +«38 +i +hoon +2 8 > +f 9° a 38 +ag eg +2 as +& +a +$3 +Gc @ +aa +4 +a og +3 +4 +o § +8 +g 8 +& +g 3 +a +a S$ +0 y +8 3 +4 +8 +d +1 a +3 ages +a Be, gy ee! +8 g 3 +ae +a +3 +8 & +4 +9 2 3 +p t ° ib +a oO © +3 Re eS +3 y § 3 +4 3 +3 +ae oe: +n oc = «© +x +» +zg a3 +xg +é +a3 28 +4 a 3 6 +4 4 +s 3 ¢ 2 3 os 3 +a a 8 § +a 4 hoa gs 4 $ +3 ROS * +§ a & aoa +g +g 8 i 3 +a 3 5 3 +3 i rf +g +Son +8 38 +4 og +F 2 9 +* 3 +8 +a a 4 +j 4:8 +8 ‘ +a5 +3 +a + + +Revision 1.00 Page 17 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The Psion HC range + + +HC Extended Internal Expansion Port + + +The Psion HC range of computers are intended to provide a rugged and powerful mobile computer +system for a wide variety of demanding application requirements. As part of its adaptability, every +element of the hardware is configurable from the plug-in SSDs to the expansion ports for peripheral +devices such as bar code scanners, modems and magnetic card readers. There are two independent +extended internal expansion ports at either end of an HC unit. The top port is termed the "A" port +and the bottom one the "B" port. Each expansion port provides direct I/O with the processor, a SIBO +serial channel, and connection to the power supply. It allows for higher powered expansion devices to +be added by including a direct connection to the main 7.2 volt battery. + + +Physical Connector + + +The expansion port is made up of a 25 way single row connector spaced on a 0.1 inch pitch. The 26th +position is a polarising key and should be left blank. The correct mating connector on the expansion +device is made up from a number of Molex C-Grid series 90148 connectors. Pins | and 2 are ground +and should have there own connector placed nearer the board edge to ensure the ground connection is +made first when the expansion device is inserted. The required connectors are Molex 90148-1102 for +the GND contacts and Molex 90148-1123 for the signal contacts. The diagram below shows the +physical position of the connectors. + + +=$f ene 98148-1182 3 + +Se : EXPANSION D +=e + +sad Abe COMPONENT SID + + +fet + +feu) +HHDE +eorn +AEM +on + + +38148-1125 + + +raftats afte ++ [o}:o loo) en] +Heonwnm +Zuaorom +Scteorn +aa ne + + +raftofea +Lsfosfra +wn +Ox +ol +Fr! + + +wi +Zo +OR + + +ge + + +voce +(SPACE? + + +SIBO COMPUTER + + +Revision 1.00 Page 18 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Signal definition + + +The following table defines the 25 way expansion connector:- + + +Pin No. Name _ Sig. type Comments + +GND Power Should mate first when device inserted + +GND Power Should mate first when device inserted + +ADO BCMOS 8 bit multiplexed address and data bus pulled low with 100 K resistors +ADI BCMOS + +AD2 BCMOS + +AD3 BCMOS + +AD4 BCMOS + +ADS BCMOS + +AD6 BCMOS + +AD7 BCMOS + +ALE OCMOS Address latch enable - high when valid address on ADO-AD7 + +IOWR OCMOS I/O write strobe - active high, data valid on falling edge of IOWR +IORD OCMOS I/O read strobe - high when device can place valid data on ADO-AD7 +EES OCMOS External Expansion Select - high during I/O cycles to expansion device +SCLX TCMOS 512 KHz SCL signal for SLD bus - usually Hi-Z and pulled low + +DNC N/A For future expansion - do not use. + +THERM Resistor Connected to thermistor (bottom slot only - top slot DNC) + +VBI Battery Connected to the internal NiCd battery (bottom slot only - top slot DNC) +Vsup Power Unregulated battery voltage - present all the time + +INTR ICMOS Active high interrupt input + +_EXON ICMOS Active low input pulled up to Vccl - pull low to switch machine on + +SD B CMOS SIBO serial protocol data line - pulled low + +SCLK TCMOS SIBO serial protocol clock line - Hi-Z in standby needs a pull down +GND Power + +Vcc2 Power +5 volt supply, switched off in standby. Max current available = 50 mA + + +AADNKRWN KH + + +DNC (Do Not Connect) indicates that the pin should not be connected. The signal types are:- + + +O CMOS CMOS output to the expansion device. + +B CMOS CMOS bi-directional line to the expansion device. +T CMOS CMOS tri-state output to the expansion device. + +I CMOS CMOS input from the expansion device. + + +All the CMOS signals including the ADO-AD7 bus are buffered from the main system busses and so +present a load of one HC series logic gate. + + +Direct I/O + + +Expansion devices can be connected to direct processor I/O space using the following signals; ADO- +AD7, ALE, IOWR, IORD, EES and INTR. + + +ADO-AD7 is the least significant half of the multiplexed address and data bus, this means that up to +128 I/O addresses are available for each expansion device. As only the least significant half of the +bus is available and no bus conversion is done only even addresses can be used. + + +ALE must be used to latch the address from ADO-AD7 for devices that require a stable address. The +address is valid on the falling edge of ALE. Note that AO will always be low for valid writes to the +expansion device and as such should not be used as an address line, Al should be used as the lowest +order address line. AO can be used as an additional enable signal to stop odd I/O accesses disturbing +the expansion device. + + +EES is the External Expansion Select and is high during all I/O accesses to the expansion device, i.e. + + +for I/O reads and writes to address range 100 to 1FF hex. for expansion port 1, and 200 to 2FF for +expansion port 2. + + +Revision 1.00 Page 19 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +IOWR is an active high signal which is high during all I/O write bus cycles. The data on ADO-AD7 +is guaranteed to be stable before the rising edge of IOWR and after the falling edge of IOWR. IORD +is an active high signal which is high during all I/O read bus cycles. The ADO-AD7 bus is +guaranteed to be tri-state before the rising edge of IORD and after the falling edge of IORD. The +expansion device must present valid data on the bus when IORD is high, see the timing details below. + + +INTR is an active high interrupt input to ASIC1. T his can be used as a directly readable bit or as a +dedicated interrupt input. It must not be driven high when the system is in the standby state as this +input is pulled down and will cause excessive standby current consumption. The diagram below +shows the timing of the I/O write and read cycles. + + +T/0 WRITE CYCLE + + +ADS-ADT VALID ADDR + + +VALID WwW + + +QOD + + +FES q_Tadstp _ plyTadhidy, + + +| Tudstp | Tudhld | + + +IYO READ CYCLE + + +ADS-ADT VALID ADDR> + + +} Tadetp fel adhd ,, + + +| Thztd Trdste Trdhid + + +Parameter + +Address set up time +Address hold time +Write data set up time +Write cycle pulse width + + +Write data hold time + +Time from Hi-Z to data active +Read cycle pulse width + +Read data set up time + +Read data hold time + + +Note the typical values given are for an HC with a system oscillator of 7.68 MHz. + + +The SIBO serial channel + + +A single SIBO serial protocol channel is provided on each expansion port. Expansion port | is +connected to serial channel 5, expansion port 2 is connected to serial channel 6. The serial channel +clock can be continuously enabled to provide a free running clock for expansion devices. The +frequency is fixed at 1.536 MHz regardless of the system clock frequency. This frequency is a +multiple of the SLD clock rate and of all normal RS232 baud rates. + + +High Speed Side Port + + +Port C on an HC houses an 8-pin in-line connector that allows access to a high speed SIBO serial +interface. This interface is currently used only by the HC cradle peripheral. Its pin-out is outlined in +the table overleaf: + + +Revision 1.00 Page 20 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +[Pin | Signal | Type | Description, + + +fo | Sb7_ | InOut__| Bi-directional Serial Data line- Side portC +[8 TSEN Input Battery temperature sensor + + +Power supplies + + +Two power supplies are available for expansion devices these are Vcc2 and Vsup. Vcc2 is a +5 volt +supply that is derived from Vsup. Vcc2 is switched off when the system is in the standby state and is +switched on when the operating or idle state is entered. Each expansion device can draw up to 50 mA +from Vcc2. If an expansion device requires more than 50 mA or cannot be powered down when the +system is in the standby state the Vsup power supply must be used. Vsup is the unregulated supply +directly from the main system batteries or from the DC jack input. It will be in the range 5.5 to 12 +volts under normal conditions. To use Vsup the expansion device must regulate Vsup to 5 volts with +a low drop-out linear regulator. Care must be taken to not be active and driving any signals high +when the system is in the standby state as Vsup is always present. This can be achieved either in +software or by using Vcc2 as a signal indicating the active state. + + +Mechanical Information + + +Mechanical details regarding the numerous build variants and accessories that currently exist for the +HC are presented overleaf. The peripheral expansion boards for these build variants are housed in a +special plastic casing that can be machined to hold the requisite connectors. In the matrix, ae +indicates that the relevant combination of HC and accessory are compatible and an X indicates that +the combination is not compatible. Following the build variant table are two diagrams that display +exploded views of the HC expansion connector and the HC Expansion Board complete with part +numbers and dimensions. + + +Revision 1.00 Page 21 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Build Variants + + +With EL Backlighting +Without EL Backlighting + + +Industrial + + +Non-Industrial + + +Keypad Variants + + +53 Key A/N UK 2401-0026 +A/N European 2401-0051 +A/N Scandinavian 2401-0050 +Numeric only UK 2401-0046 +DOS Keypad 2401-0147 +53 Key A/N USA 2400-0026 +HC Expansion Modules + + +RS232 / Parallel (Printer) 1502-0001 +25 way D type (F) + 9 way Mini DIN +Certified FCC Class B / Passed VDE Class B + + +RS232 / TTL + +1502-0039 (IP64), 1502-0040 (NON IP64) + +9 way D type (F) + 9 way D type (M) + +Passed FCC Class B / Passed EN55022 Class B + + +UK Modem (Asic 8) 1502-0010 +RJ 11 connector +BABT Approved in UK, BS6301 (Safety) + + +Barcode Only + +HP Wand HBCS-A207 + Plug + EXMOD 1502-0020 +Wand Welch Allen + Plug + EXMOD 1502-0021 +FCC Class A/ Passed VDE Class B + + +RS232 / Barcode 1502-0044 +9 way D type Quick Loc(F) + 9 way D type (M) +Complies with FCC Class A + + +MCR / Scanner / RS232 1502-0003 +Scanner NipDenso + Plug 1502-0022 +Scanner DigVision + Plug 1502-0023 +Magnetic Card Reader + Plug 1502-0024 +Certified FCC Class B / Passed VDE Class B + + +LIF / RS232 (Under development) +9 way D type (M) + 9 way LIF- PFS (M) + + +LIF / TTL (Under development) +9 way D type (F) + 9 way LIF- PFS (M) + + +LIF / BARCODE 1502-0043 +9 way D type Quick Loc(F) + 9 way LIF- PFS (M) + + +Vehicle / TTL +9 way D type (F) + 9 way LIF- RS232 (M) + + +16550 RS232 / TTL (Under development) +9 way D type (F) + 9 way D type (M) +Complies with FCC Class A + + +Printer (High Res.) 1502-0037 +Laser Scanner 1503-0012 + + +Fast Charger Variants + + +Fast Charger with Holster (Due Jan 95) +Fast Charger without Holster (Due Jan 95) + + +Additional Accessories +Nicad Battery Pack 500 mA 1503-0005 + + +Revision 1.00 + + +Psion PLC (c) May 1995 + + +CHARGER + + +a a a Ee +i ie IE a a +ee ee +Re ca Da ca + + +ans he ae Ss eee +FS a a a a + + +Page 22 of 115 pages + + +Psion PLC (c) May 1995 + + +The Psion SIBO Hardware Development Kit + + +Corporate Hand Held (CHH) + + +Expansion Module Exploded Assembly Drawing + + +(yovig) Sso0-zoz9 + + +(USENNN LYVd YSLINO OSTY) (A3N9) £000-20z9 + + +YANVIG NOISNVdX4d 138V1 + + +(440 2) 2000-z0¢g +WSO IZOd WWOXZZ% MINIS + + +(OV1E) 9107-2018 + + +(AJN9) 9101-2018 +ONITINOW Y3LNO NOISNVdxX3 OLS HHO + + +(wov1d) $10Z-Z018 +(AIUD) SLOL-ZOL8 +ONIGINOW YSNNI NOISNYdX3 HHO | + + +6000-0072 +ANVIG dd + + +SNOISNSNIG YSLLNS +ANVIG NOISNVdX3 138V1 + + +Page 23 of 115 pages + + +Revision 1.00 + + +Psion PLC (c) May 1995 + + +t + + +The Psion SIBO Hardware Development + + +QrOr o22 ILD :xW4 +008! 802 120 “7131 +1G) HIM + + +NOONOT N/OIl + + +AS 18NOQYVH 61-21 +Jd NOd + + +MSV LENOd Ni dl +JNWOS ION OG + + +(SOs 2) ONDOEL =O +w300 34 OL G3U0Y vey + + +26, + + +94 01 GMQy SFI NOILWOOT + + +26/1/91 + + +Sa @ SINSNOGNOD 40 +wa) 38 OL G200V vw + + +26/0178 + + +‘Gadd NOWOWISIS +AHOIBH LN3NOEWOD W207 + + +06 /c0/zal + + +108 X3T0K +a300¥ $89 8ou93~N09 + + +oss 9792 + + +SSI Sas + + +SONVHO, + + +SmAOVd NOISNVdx4 + + +SH T1¥ A044 GssyINGS + + +NOILYWAOSANI 4H + + +L SMOHS SONIMVAC Sit + + +LH513H LN3SNOdWOD +X¥W ONIMOHS 311 408d + + +216 + + +cay) Y_NOISN3WIC + + +C30N31LX3 + + +CAVONVLS + + +JdWwOS aNv + + +qa.0N3d vaav + + +A11V901 NO3IaLS34 + + +COMPONENT HEIGHT RESTRICTION + + +(SEE PLAN VIEW) + + +(SOd 2) ONIMDVYL ANY +WOS4 3384 38 O1 voav + + +CAVA 92 WiOL) SYOLO3NNO9 + + +LTO + + +SOd 2) SIN3NOdWOD ANY +WOSs 3384 34 OL vaav + + +: @szaze @ S3143S 8y106 X370N + + +a2 + + +4.5 BOTH SIDES + + +1 +| +31.75 CRS l 31.75 CRS + + +Page 24 of 115 pages + + +Revision 1.00 + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +6. ASIC 4 + + +What is ASIC 4? + + +ASIC4 is custom integrated circuit designed for use in Memory Packs (called SSDs) and peripheral +devices. Its primary purpose is to convert the PSION Serial protocol into the signals required to +address memory and memory-mapped peripherals. A typical Series 3/3a ASIC4 peripheral will +consist of an ASIC4 connected to port C of the host machine and a peripheral chip/device mapped +into ASIC4's addressing space. An example could be an ASIC4 connected to a simple 1k memory +device: + + +Chip select + + +To write a value, , to address , the appropriate control codes must be sent along the port +C Psion Serial link to assert on ASIC4's address outputs and on ASIC4's data outputs. + + +ASIC4 Addressing and Modes + + +ASIC4 has an 8 bit data bus and a 28 bit address bus. Also provided are eight chip select lines that +form selectable addressing blocks each of a size defined by software. The default is 32Kbyte/block. +The filing system will set this to the appropriate size while accessing memory in the upper portion of +the address space. + + +ASIC4 has two basic modes of operation, namely ASIC5 Compatibility (or SSD) mode and ASIC4 +Extended mode. To select the mode, ASIC4 must be selected with an appropriate ID. This is +achieved by writing a SIBO serial protocol slave control frame, as detailed in chapter four, to the +ASIC prior to sending any read or write requests. After sending this frame, the so-called Info Byte is +read off the data bus. Details concerning the meaning of the various Info Byte bits are provided in the +following section. In the case of SSD mode, the ID is 2 and for ASIC4 Extended mode, the ID is 6. + + +Putting ASIC4 into SSD mode makes the chip compatible with all current versions of existing SSD +software in production by Psion including all HC, series 3/3a and MC software. In this mode, ASIC4 +mimics an ASICS in pack mode (see next chapter). This is because ASIC4 was originally designed to +be a cut-down version of ASICS and so from the outset it was necessary to make previously existing +ASICS software run on the new chip. The maximum address space in SSD mode is 21 address bits +and 4 chip selects (which comes to 4 x 2Mb). In ASIC4 Extended mode, ASIC4 is capable of +addressing up to 28 address bits (256Mb). In this mode, in addition to the Info Byte, a further 4 bits +of information can be elicited from the state of the address lines A27-A24 during reset. Of these bits, +the state of A27 (bit M) determines whether ASIC4 is going to be used as a standard SSD (M=0) or in +a mixed mode (M=1) comprising of memory devices and peripherals. It is only the latter case which +is of interest to the potential developer since this is the mode intended specifically for peripheral type +expansion. In mixed mode ASIC4's address space is split into two equal halves. The lower half of +the addressing range is set aside for memory-mapped peripherals and can be used for any purpose. +The upper portion of the address space is reserved for pure memory. The Series 3/3a, Workabout and + + +Revision 1.00 Page 25 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +HC filing system is able to use this memory (which does not have to be present) as an additional +storage medium. Typically it will be a ROM containing the software that controls the peripheral. On +reset, configuration data is supplied to ASIC4 on its data bus lines which the filing system can read +in order to determine what form of and how much memory it has available in this upper region. + + +In mixed mode chip selects are split into four selectable peripheral blocks and four selectable memory +blocks. CSO-CS3 are for peripheral access. CS4-CS7 select memory devices one to four. This set-up +is illustrated below: + + +Peripherals +S1 +$2 +$3 +Total +Addressing S4 +Range Memory +(256Mb) SS +S6 +S7 + + +Reset and configuration + + +As indicated earlier, in mixed mode, following a reset or power up ASIC4 will read the form in which +to configure itself from the data on data lines DO-D7 (the Info Byte) and address lines A24, A25, A26, +A27 (most significant nibble of the Extended Info Byte). The table below shows the meaning of each +of these lines during reset. + + +| A27 | A26 | A25 | A24 | D7 | Do | Ds | D4 | D3 | D2 | Di | DO | + + +Don't care, some 000 RAM 00 1 device No memory +codes are reserved. | 001 Typel Flash | 01 2 32Kbyte +000 No peripheral | 010 Type2 Flash | 10 3 64Kbyte + + +001 T3Link 110 ROM 114 128Kbyte +010 3Fax 256Kbyte +Contact Psion for 512Kbyte +an official code. 1Mbyte + + +Pull up, pull down resisters would usually be used to place these lines in the desired state on reset. +High value resisters of typically 100k would be used to allow ASIC4 and bus devices to drive these +lines to other levels during normal operation. + + +ASIC4 should be powered from its host Series 3/3a/HC. High current peripheral chips or volatile +memories should have their own supply. Whenever the Series 3/3a/HC is powered down, has its +batteries removed, or has it's pack doors open, any attached ASIC4 will be powered down and reset +upon resumption of power. Taking the 3Fax as an example with one Read Only Memory device of +512k the required configuration is: + + +Revision 1.00 Page 26 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +ASIC4 Pin-out + + +Pin No Pin Name +50 DO +49 D1 +48 D2 +47 D3 +46 D4 +45 D5 +44 D6 +43 D7 + +13 AO +12 Al + +11 A2 + +8 A3 + +7 A4 + +6 AS + +5 A6 + +4 AT + +3 A8 + +2 AQ + +1 Al0 +64 All +63 Al2 +62 Al3 +61 Al4 +60 Al5 +29 Al6 +28 Al7 +27 Al8 +25 Al9 +24 A20 +23 A21 +22 A22 +21 A23 +20 A24 +19 A25 +18 A26 +17 A27 +37 CSO +36 CS1 +35 CS2 +34 CS3 +33 CS4 +32 CS5 +31 CS6 +30 CS7 +16 OE +14 WR +15 VPS +39 POR +40 SCLK +38 SDAT +59 SDIR +51 LBO +56 MCSD +52 INO +53 INI +54 IN2 +55 X2D2 +57 ATST +10 VDD +42 VDD +9 GND +26 GND +41 GND +58 GND + + +Revision 1.00 + + +Direction +VO +vO + + +fe) + + +~*=“O0O000000000 + + +fo) + + +PWR +PWR +PWR +PWR +PWR +PWR + + +Pin Description + +Databus + +Databus + +Databus + +Databus + +Databus + +Databus + +Databus + +Databus + +Address bus - register ATO +Address bus - register ATO +Address bus - register ATO +Address bus - register ATO +Address bus - register ATO +Address bus - register ATO +Address bus - register ATO +Address bus - register ATO +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT 1 +Address bus - register AT2 +Address bus - register AT2 +Address bus - register AT2 +Address bus - register AT2 +Address bus - register AT2 +Address bus - register AT2 +Address bus - register AT2 + + +Address bus - register AT2/Oscillator Output in PSPRAM Mode + + +Address bus - register AT3 Inputs to set device size on reset +Address bus - register AT3 Inputs to set device size on reset +Address bus - register AT3 Inputs to set device size on reset +Address bus - register AT3 Inputs to set device size on reset +Device chip selects + +Device chip selects + +Device chip selects + +Device chip selects + +Device chip selects + +Device chip selects + +Device chip selects + +Device chip selects + +Output Enable/Refresh in PSRAM Mode + +Write pulse + +VPP control + +Reset input + +Serial clock input + +Serial Data input + +Protocol Direction indication Bit + +Low Battery detect driver output (Open drain) + +PSRAM Mode Select + +General Purpose inputs + +General Purpose inputs + +General Purpose inputs/Refresh Disable in PSRAM Mode +Oscillator Input for PSRAM Mode + +Test input (pull high to put device into address test mode) +Power inputs + +Power inputs + +Ground + +Ground + +Ground + +Ground + + +Psion PLC (c) May 1995 + + +Page 27 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +A11 A12 A13 A14 A15 SDIR GND ATST PS OSCIN IN2. IN1 INO LBO DO D1 + + +- LU Li Lt Ly ae L Ls LI Li + + +62 61 60 57 56 54 53 52 51 + + +64 + + +A10 48 D2 +AQ 47 D3 +A8 46 D4 +A7 45 D5 +A6 44 D6 +AS 43 D7 +A4 42 VDD +AS ASIC4 41} —J GNo + +GND 40 SCLK +VDD 39 POR +A2 38 SDAT +Al 37 cso +AO 36 cs1 +WR 35 cs2 +VPS 34 CS3 +OE 33 cs4 + + +17° 18 «#19 20 21 22 23 24 25 26 27 28 29 30 31° 32 + + +Rigizipininigiolgipinipimdeig + + +A27 A26 A25 A24 A23 A22 A21 A20 A19 GND A18 A17 A16 CS7 CS6 CS5 +OSCOUT + + +Diagram of ASIC4 Pin-out (NEC) + + +Revision 1.00 + + +Psion PLC (c) May 1995 + + +Page 28 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +7. ASIC 5 + + +What is ASIC 5? + + +ASICS is custom integrated circuit designed for use in Memory Packs (called SSDs) and peripheral +devices. ASICS provides three primary functions. A built in UART provides for serial +communication at baud rates of up to 48000 baud. General purpose I/O pins provide for a wide range +of control and communication applications. Finally ASIC5 provides address and data lines for access +to memory devices and memory mapped peripherals. A typical ASICS peripheral such as the 3Link +consists of an ASICS connected to port C of a series 3/3a, a ROM memory device mapped into +ASICS's addressing space and line drivers to convert the UART signals from ASICS into standard +RS232 levels. + + +Chip select + + +ASIC5 rea Memory + + +RS232 Line Drivers + + +Psion Serial link + + +ASIC5 Modes + + +ASICS can operate in two modes. In pack mode ASICS generates all the address, data, and control +signals necessary to access memory devices. No peripheral functions are available in this mode. In +peripheral mode ASICS has only limited memory address capabilities as some or all address and +control lines are reused for I/O purposes. ASICS is placed into peripheral mode by setting the +peripheral bit in ASIC5's PBMODE register. + + +ASIC5 as a UART + + +ASICS contains a full function UART which supports baud rates of up to 48000 bits per second. In +order to use ASIC5 as a UART, ASICS5 must be placed into peripheral mode. In this mode the input +signals PAO, PAI, PA2, PA3 become the UART inputs RX, CTS, DSR, and DCD respectively. The +output signals PDO, PD1, PD2 become the UART signals TX, RTS, and DTR. Serial data is +transmitted from the TX line. Incoming serial data is received by the RX line. RTS and DTR can be +used for handshaking or as general purpose outputs and need to be set high or low explicitly by +software. CTS, DSR, and DCD can be used for handshaking or as general purpose inputs. + + +The Psion SIBO serial link which connects ASIC5 to a host computer is a two wire interface +consisting of a data and a clock line. ASICS generates it's baud rate clocks from this clock line. +Under normal operation, clock pulses along a Psion SIBO serial link only accompany data frames. To +be able to generate baud rate clocks ASICS requires a steady clock from the Hosts Psion port. To +facilitate this, Psion serial links can be put into a mode called continuous clocking where clock pulses +are generated regardless of whether there is any actual data to be transferred. Continuous clocking + + +Revision 1.00 Page 29 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +increases power consumption and Psion serial links should not be left in this mode unnecessarily. +The UART portion of ASICS is capable of generating interrupts when characters are received, when +the transmitter is awaiting a character to send and when there is a change of state on the handshaking +lines. ASICS has only one, active high, interrupt line. This line is shared between these interrupt +sources. When an interrupt is generated it is the responsibility of software to determine the cause of +the interrupt. + + +A character to be transmitted should be written to the Transmitter Holding Register where ASICS will +convert it to serial form for transmission. The register will be emptied once the character has been +transmitted. ASIC5 contains no internal buffering. The Transmitter Holding Register must be empty +before writing a character to it. The state of the Transmitter Holding Register is reflected in the +Transmitter Empty bit in the UART status register. Enabling the Transmitting Holding Register +interrupt will cause ASICS to generate an interrupt every time that the Transmitting Holding Register +becomes empty. Reading the UART Status Register will clear the interrupt. Received characters are +copied into the Receive Character Register. If the Receive Character Interrupt is enabled, ASICS +generates an interrupt on each character received. If the character is received in error due either +parity, framing or overrun errors, appropriate bits in the UART Status Register are set to reflect this. + + +ASIC5 for parallel I/O + + +Lines PAO-PA7 form a general purpose, non latched, 8 bit input/output port. All access to this port +take a total of twelve clock cycles. The clock is generated from the Psion Serial Link. Actual +memory access cycles only last for one clock cycle. Twelve cycles are required because data being +sent or received needs to be converted to or from the Psion serial format. Because of the conversion +read accesses occur on the third cycle, write cycles on the twelfth. This is usually of no real +consequence to the peripheral designer + + +In peripheral mode CSO will be taken low for one clock period each time Port A is accessed. Data +outputted from this port will remain valid for only the period that CSO is low. In pack mode Port A +forms the data bus in memory mapped systems. A read from or write to Port A in this mode will +result in one of the lines CSO-CS3, being taken low for one clock period. The line which will be +taken low will depend on the address being generated for the access. During read cycles OE line will +be taken low and remain so for 10 cycles. Data present on PAO-PA7 must remain stable for the last +nine cycles. During write cycles the WR_B line will be taken low for the second half of the cycle over +which one of CSO-CS3 is low. If port B is set to counter mode, accessing port A will result in the +counter being incremented upon completion of the access. + + +ASICS can be programmed to generate an interrupt whenever the state of line PA4 changes. Reading +port A will clear this interrupt. One use of PA4 is as the BUSY line in a Centronics port +implementation. + + +The Lines PBO-PB7 can be programmed to operate in four different modes. Two of these modes are +for testing purposes and will not be discussed further. In latched mode, data written to the Port B +resister is latched onto the Lines PBO-PB7 and will remain there until a following write to Port B or a +reset condition occurs. In counter mode, the binary value on lines PBO-PB7 is incremented following +any access to port A. With ASICS in pack mode lines PBO-PB7 form the address lines AO-A7. +Placing port B into counter mode allows 256 consecutive memory locations to be read without need to +set-up the address of each access. + + +Lines PDO-PD7 are general purpose outputs. In pack mode these form the address lines A8-A15. In +peripheral mode lines PDO, PD1, PD2 become UART outputs. + + +Lines PCO-PC4 in pack mode form the address lines A16-A20. In peripheral mode lines PC4 and +PC7 become inverted inputs and can be used as edge triggered interrupt lines. PC5 becomes the +interrupt output line. PC6 becomes a general purpose latched output. PCO-PC3 become a dual +synchronous serial port for use in magnetic card systems. + + +Revision 1.00 Page 30 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +ASIC5 for Barcodes + + +Psion barcode peripherals use the UART functionality of ASICS to receive data from a dedicated +barcode scanner IC. + + +ASIC5 for Card readers + + +Magnetic card readers generate clocked serial data. ASIC5 contains two synchronous serial ports for +connection to card readers or other peripherals which generate clocked serial data. + + +Reset and configuration + + +Following a reset or power up ASIC5 will read the form in which to configure itself from the data on +data lines PAO-PA7. Line PC6 is used to select whether ASICS is to operate in pack or peripheral +mode. The table below shows the meaning of each of these lines during reset. In peripheral mode +lines PAO-PA7 should be set to give an indication of the type peripheral the ASICS is forming. +combinations of types can be used. + + +000 RAM 00 1 device No memory + +001 Typel Flash | 01 2 32Kbyte + +010 Type2 Flash | 10 3 64Kbyte + +110 ROM 114 128Kbyte + +1 1 1 Write protect 256Kbyte +512Kbyte +1Mbyte + + +Peripheral Mode Type + + +RS232 port +Centronics (Parallel) port + + +Hx KK KK XX +xo KKM KK XX + + +0 +0 +0 +0 +0 +0 +0 +0 + + +Pull up, pull down resisters would usually be used to place these lines in the desired state on reset. +High value resisters of typically 100k would be used to allow ASICS and bus devices to drive these +lines to other levels during normal operation. + + +ASICS should be powered from its host Series 3/3a, Workabout or HC. High current peripheral chips +or volatile memories should have their own supply. Whenever the Series 3/3a/HC is powered down, +has its batteries removed or has its pack doors open, any attached ASICS will be powered down and +will be reset upon resumption of power. + + +Revision 1.00 Page 31 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +ASIC5 Pin-out + + +A10 Ali A1l2 Ai3 NC A14 A15 DO D1 D2 + + +DONO o net + + +ASIC5 + + +14 15 16 17 18 19 20 21 + + +MAMAMAAMMo + + +WR VPS OE A20 A19 NC A18 A17 A116 CS3 CS2 + + +ASIC 5 current pin-out (TI version CF30179) + + +Revision 1.00 Page 32 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +8. EXAMPLE PERIPHERALS + + +The ASIC4 Example Interface Board + + +The ASIC4 Example Interface Board detailed in this chapter is intended to provide the developer with +a simple example of a Psion ASIC4 peripheral. To this end, the actual practical usefulness of the +hardware is of secondary importance. In fact, the board essentially consists of eight LEDs connected +via some latches to an ASIC4. Using a device driver, the host machine is able to control the status of +the LEDs. Specifically, the board translates SIBO serial protocol signals into a parallel 8-way data +bus format that can be used to set the various 74HC series latches and gates. It is intended that the +board can be readily adapted to run on all currently available Psion machines. The only physical +change that need be made concerns connection to the host machine's external expansion interface. + + +In the following circuit, an eight-bit tri-state data buffer, U3, and an eight-bit output data latch, US, +are commoned together to the eight LEDs thereby enabling their status to be sensed and set. In +addition, a facility for generating hardware interrupts is provided by means of a suitably connected +switch, S1, and a third eight-way buffer, U4. U4 is the interrupt switch status buffer. It holds the +values of the two input switches S2 and S3 which are read as part of the interrupt service routine. +Depending on the value of the switch positions, a different response can be output to the LEDs from +the set buffer, US. One of the D-type flip-flops in U6 is used to latch hardware interrupt signals into +the INT line (pin 5) of the reduced external expansion interface connector. On completion of the +interrupt routine code, it is necessary to reset this flip-flop and hence the interrupt hardware by means +of a write to address Al. Address decoding is provided by two 2-to-4 decoders on chip U1 paralleled +to address lines AO and Al. A circuit diagram of the ASIC4 Example Interface Board is presented +overleaf for the case of a host S3a. + + +Note that it is possible to construct this circuit with or without the compiled driver code in an on- +board ROM. The developer merely has to set the resistors on the three data bus lines DO-D2 such that +the corresponding info byte conveys the appropriate information. The meaning of the various bits in +an ASIC4 info byte was discussed earlier in chapter 6. If a ROM is to be used, then the info byte read +off DO-D7 on reset should include bits 001 on lines D2-D0. This requires the R1/R2 optional resistor +to be connected to Vcc. If a ROM is not used, as was the case with the constructed test circuit, the +data bus lines D2-D0 should be set to 000. This is done by choosing the resistors connected to ground +from the three R1/R2, R3/R4 and R5/R6 pairs. + + +Revision 1.00 Page 33 of 115 pages + + +Psion PLC (c) May 1995 + + +The Psion SIBO Hardware Development Kit + + +VOD +voc voc voc voc +3 +cs ca cio _|+ caa For 128K Bute ROM fit option resistors Ri, R4, RG, RE and Rio eibe +idon toon ioon Our evs For no ROM fit option resistors RZ, R4, RE bo 2 +ue ve ve as VOD +SNC GND GND GND +1 +3 +Xf RE-/R4 +vor GND +res Di 2g 100K +ag voo | 338 +bo = ae base es Do +Di 14 Bd 1 +AS Bi +DE Be be (45 De +veo DS ce be Cie mE v Biel +Da 18 ba SNC +oS aé ba Te DS +az BS +R22 [ery AS be 20 [T= 3 +100K Br aS BS [ei isk RE RE +aio fa 100K +ort ze | 22 bz z +Al2 +ails oe [24 +7 ate 1 +aaa oe awe hae +Aiz L +ae GND +eto nigga | ao +vor voc +ZEK—ine ROM DS R16 100K +Ss Is +RT-RE RS/RL0 +vos z z +7 FaHcT4a +ja oR oR +R26 +Rea 100K 1 1 DF R20. 100K +LooR +GND +GND +Ree SND +aoe t R27 ba +voc LED GND +CONNL +sp7 bo * 0 +sck7 b-# = Bo 18/ivi = 1ai +329 += Di is a_i LED ND +sDSs/INT iv2 0 1Az +SCKS/“EXON a Wie D2 14 is. 1AS & P2 +z z Ds iz = Ps +Wor * a vo ava iaa +4 z bas ii_F4 +She , a. be revi 281 Ge re LED GND +YE 2Yz ZAz +CON COMMS CONN be oer te be S| S02 282 (re Pe +bre) S)5: Soy bere +FPS4HC1sg +GND te het LED GND +vor 28 brs +DL uza +1 OE 4 ae FaHceas FaHCETS +z 3 ORD LED ND +2 cso 2 FaHca4d +A t ua +WF Baves clr Se T4Hese DO 18 Tyg LAL +GND 1006F El tel ge: {ee LED GND +1B a De 14 +ive 9 1az +Mee Nf 14) 4 vo BS tetiva iad +D2 GND U2B is ba 3 +B vi Zvi ZAL +4 WR 4 oS + LED GND +Y2 2vz BAZ += 6 Lor 15 bss +Gc YS 2yYe 2As +=P = Dre 3/oy4q Baa +FaHCLss +yo OBAYSS FaHese ee 470 LED GND +GND Vos a Si voc ¥ v +vos J" GND SND DATA OUTPUT +vor FaHCe44 +DOS la Us6Al Lk Interrupt Sw +a: += Ne Saal = a B Db 2 CC? 1993 (PSIOS PLS. +aa ADDRESS R-M FUNC 3 Interrupt In ++ Bava fal RYH Read & write to latch SLK Eiki Sp ee) omnes +GND rs Md Clear Interrupt els; = R25 +1 R Read status 100K Poe REY : oO +status Bit Func F4HCr4 Title +a Ineut a +L Tneut 1 > ASICS Example IF +2-5 Not Used GND GND Size Pocument Number REV +6 Interrupt Line B 7 lo.s +? Interrupt Latch : +Date: Aerial 19, 1995|[Sheet i_of Z + + +Page 34 of 115 pages + + +1.00 + + +1S10n + + +Rev + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The Psion 3-Link + + +The Psion 3-Link is an ASIC5-based peripheral that enables the user to transform SIBO serial +protocol signals into RS232 format data so that a host Psion machine can communicate with a PC or +printer. The diagram below shows the schematic of a TTL level RS232 based expansion device. The +interface is based around ASICS and allows the standard RS232 device driver contained in EPOC to +be used. + + +Transistor Q1 provides a switched power rail for any other expansion device. This rail will +automatically be switched off when the RS232 port is closed. D1 is required to isolate the supply so +that the external device does not back power the SIBO computer when it enters the standby state. If +the additional device does not require a supply or only uses a few microamps then Q1 and D1 can be +omitted. Vcc and the supply for the expansion device can be directly connected to Vcc2. + + +If CMOS level RS232 signals are required then IC1 can be replaced with a 74HC244 device. If +inverted sense RS232 signals are required, IC1 can be replaced with a 74HC241 device. + + +The diagram overleaf shows the circuitry for an ASICS-based 3-link with ROM. + + +Revision 1.00 Page 35 of 115 pages + + +Psion PLC (c) May 1995 + + +The Psion SIBO Hardware Development Kit + + +vec +Rig +Icz vec 100K +64/128K PROM SITE E +B +ag 12Tag wy po Laz ba +ta ¥ 14 Di +AL D1 +To é TS Be +Az Dz +g id Da +as DS +3 tg ba +Aa ba +id 15 DS +aS DS +20 DE +AS De }s¢ = +ay DF +ae voc voc +ag +Alo vec +AlL - +A1lz ne |S? +ars ver 4 i +Ais Pst [22 +08 ce cz +$3 rea Our /25v idon io0n +Ale. + +N +B +* +T +le t GND +GND +ND Fs +ey eee 2g +Re 100K TRL + +BCH 1 cs cz ++ 1ur/50¥ LuF/so¥ +GND vee +mS 1 | s +aL +rs +82 (ita 1 ies +veo 22 [aa i wees +23 i 19° + iOurv2sy +D1 Fi 14 + ¢ 13 +" 24s ex i ca +| 1 4 aa c += vor 15 | coy yo LAZ ayes +2 t 16 7 SKT1 CASE +za 2- Fi +Teu uF 7254 +BAYS? I FaHorS 7d TitN taout 2 GND SKTL +36 e _DTR +PBO Y¥ PAD TBIN TZOUT RLSD/bco| +ba PBL © pai }32 294 7 SIN TzouT 2 rs RX +4 tad Sa ei ze _Tx +x * PBZ paz [3 T4IN T40UT Tx +2 PES paz = 3 Pare DIR +PB4 paa [22 £4 R1OuIT R1IN p32 _RX__§_+ t GND +a ee PBS pas fed eno se] RZOUT R2IN Pst—Bek . DSR +PES Pas pse 25) REOUT RSIN bee—GeR 4 RTS +PE? PA? R4ouT RaIN * cts +DS, ig Te RI +* a WEE — RS0UT . RSIN * RI +PDO poco i at S| += a PDL pci H2 24 eR ql sp }25 SIBO RS2S2 CONNECTOR +PDE pez He ibe Ria L c +BAYSS co: pea fas REG Too 100K a mMaxzan GND +12 ciolesilcizicizicis4 +PDS pes +SMB PDS roe 3S +PD? pe? L414 L GND in Jin Jin Jain Jain +| 1008 R4 25 /ep zen b24 GND vovVoov¥ vo +1O5R at 27 €39 Pox GND GND GND GND GND +' CLK eSi +26 2 +FOR cs2 +i7q Fo s T +3g N53 PIL +cs NG BD ¢np PL2 fh +100pF iz +veo asics [8 4 +GND +GND ND R? +RL 100R +100K Sue +o——___| +cL SH SPDT +vee 100n +CONNI +cer GND +SRT ee RG RS +SDS/INT BS Copuriaht CC) Psion PLO 1991 +ScKS/ExON PS +Vee bs File name! CONHH DRAFT RS232.5CH +yee Bg ioorR is a 10k Braun: MG +CON COMMS CONN R20 B2xe4—Cay7 PCB Rey 1.4 +100K Title +¥ 2|a +GND Rev 1.2 Move SD (pin 25 IC2> from pin 23 to 21 of Ici : EONSUMER Bases ExCeL on +Rev 1.3 Alter Ri? from 100K to 10K Size Pocument Number REV +Rev 114 Added C1io—c14 = +Rev 1.5 Moved C3 to CLK input GND GND is 6500.0008 cata +Date: June i0, i953 Sheet i oF L + + +Page 36 of 115 pages + + +1.00 + + +1S10n + + +Rev + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +9. DEVICE DRIVER OVERVIEW + + +Introduction + + +Once a piece of peripheral hardware has been designed the appropriate software must be written to +control it. All hardware on Series 3/3a, Workabout and HC machines is controlled by logical and +physical device drivers. These act as the logical low-level software interface between a piece of +hardware and an application that uses it. The remainder of this document is concerned with the +methods by which a device driver is able to communicate with and thereby control an ASIC4 or +ASICS-based peripheral. + + +APPLICA TION SOFTW ARE + + +Psion C PLIB call interface +LOGICAL DEVICE DRIVER + + +PHYSICAL DEVICE DRIVER + + +PHYSICAL HARDW ARE + + +This chapter is intended to guide the programmer through the central issues involved in writing +device drivers for peripherals that attach to the family of Psion host machines based around the +proprietary SIxteen-Bit Organiser (SIBO) architecture. The purpose of a device driver is to abstract +away the hardware details required to conduct communication between a peripheral and a software +application that uses that peripheral. The device driver therefore performs the logical processing +required to translate low level hardware instructions into high level application services. Psion device +drivers are written in 8086 assembler and following convention are divided into a logical layer +residing over a physical layer. A physical device driver (PDD) contains the code required for talking +directly with the hardware device and provides a set of low level hardware specific services. A logical +device driver (LDD) performs the logical processing that transforms these low level services into the +high level services used by an application. This two-layer nature of device drivers at Psion can be +illustrated by the following example. An application using the serial driver decides that it requires +RTS/CTS handshaking. It calls an LDD which decides whether or not a line should be driven. If the +answer is yes, the LDD calls the appropriate PDD and asks for a particular line to be driven to a +specific state. The PDD duly carries out the requested service. Psion SIBO machines often use the +same LDD with a PDD written specifically for each version of the hardware device. In such a +situation, splitting the device driver is highly desirable. In the example given above, however, the +LDD could have talked directly with the hardware negating the requirement for a separate PDD. +Similarly, most external peripherals would normally use an LDD. + + +An LDD must provide a minimum of eight functions for use by the operating system. The functions +are passed to the OS via a table of function offsets (referred to as the vector function table). These +functions are mandatory. Similarly, a PDD must provide two functions for use by the operating +system and may provide more if required. An LDD will usually provide further services/functions for +use by an application. The form these take is dependent on the LDD requirements and the functions +supplied by the associated PDD(s). + + +Revision 1.00 Page 37 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Psion SIBO machines are supplied with a set of resident device drivers built into the ROM each of +which can be replaced with an installable device driver having the same name. Installable device +drivers can also be added to increase the number of available device drivers. Installing a device driver +is carried out dynamically without resetting the machine (this is not the case with many operating +systems). + + +Device Names and Channels + + +The name of a device driver is the mechanism by which an application can obtain a channel to that +device driver. A logical device driver name always has three characters followed by a colon. For +example, "TTy:" is the serial LDD. This name is required to uniquely identify the LDD to the EPOC +OS when attempting to open a channel on it. A physical device driver name always has the three +characters of its owning LDD followed by a period, a further three characters and a colon. For +example "TTy.UAR" is the ASICS UART driver and "TTy.srRx" is the 16450/16550 driver. The first +three characters of a PDD name are the name of the LDD to which the PDD belongs. The second set +of three characters uniquely identify the PDD. Thus in the above examples, both PDDs belong to the +"tty:" LDD. + + +A channel can be opened on an LDD by calling the PLIB library function p_open. EPOC uses the +driver name passed through an application p_open call to invoke the IoOpen operating system +service. This service in turn calls the associated driver ‘open vector’ which can decide whether or not +to open a channel on the driver. The assembled ASIC4 Example Interface Board logical device +driver, A4EXIF.LDD, for example, has the three-character device name "LED" so a channel with its +handle in pcb may be obtained on it by means of the following call: + + +p_open(&pcb, "LED:", -1) + + +In this call, the third argument refers to the open mode and a value of -1 indicates that the mode +parameter is to be ignored. To obtain a channel on a PDD, an application should call the DevopenPpp +OS service. Typically, only LDDs open PDDs though the p_open library function can be used to open +a PDD indirectly as illustrated in the following example: + + +p_open(&pcb, “"TTY.UAR:", -1) + + +For a device driver configuration consisting of an LDD and a PDD, the application will usually open +a channel to the LDD only: the LDD as part of its initialisation would open a channel to the required +PDD. If an LDD requires a PDD and none is specified, it is up to the LDD to either fail the open +request or hunt for a loaded PDD that it can use. An LDD uses the DevFind OS service to search for +a PDD as for instance in the case of the "TTy:" device. + + +A device driver may be capable of supporting more than one open expansion channel at a time. In +order to distinguish the channels, a qualifier can be added to the open request as part of the device +name. It is then up to the device driver to specify the format of the qualifier. By convention, +channels are allocated a single character sequentially from the character 'A'. For example, the +parallel port driver can support two open channel, 'A' and 'B'. The LDD requires one of these +qualifiers in order to open a parallel driver channel: + + +p_open(&pcb, "PAR:A", -1) +p_open(&pcb, "PAR:B", -1) + + +The number of channels that can be thus supported will in general be dependent on the host SIBO +hardware. In the case of the serial port on the S3a, for instance, only one SIBO channel can +legitimately be opened corresponding to expansion port C. With the Workabout and HC, however, it +is possible to open up to three separate SIBO channels on ports A through to C where A refers to the +top port of the host machine, B to the bottom port and C to the side (or cradle) port. + + +LDDs have been designed to be accessed via the I/O system. I/O requests on the opened channel will +reach the 'strategy vector' of the device driver. PDDs have been designed to be accessed by an LDD + + +Revision 1.00 Page 38 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +either via far calls or the Devvector OS system service. Once a channel has been obtained on a +device driver, the operating system can send it events not sent to other applications. Examples are +events generated by the machine being switched on or off, memory segments being moved about and +the owning application being panicked. The EPOC OS can handle a maximum of 32 device drivers +on a Series3 machine and 48 on other machines. + + +Loadable Logical Device Driver Structure + + +Common features of the structure of loadable LDDs + + +All loadable LDDs must conform to the following rules: + +e There must be a single code segment and no data segments. The code segment is encapsulated in +the assembler .asm file by calls to the codeSeg and EndCodeSeg defines respectively. + +e The code segment must begin with a LibEnt structure which indicates the LDD name or +signature which is used to identify the driver when trying to open and close channels. + +e There must be at least eight supported functions which are listed in the LibEnt struc. + + +LibEnt Structure + + +The first field of the LibEnt structure consists of a two-byte signature containing the define +‘LDDSignature’ or 'PDDSignature’ in the case of a PDD. The remaining fields consist of an eight +byte name which holds the device driver name stored as a zero terminated string (note that the +trailing colon is omitted), a two byte vector count which must be at least eight and a vector table +listing the supported device driver functions. The relevant code in the case of a hypothetical DevFunc +LDD (DEVFUNC.LDD) with the device name of "TES:" is listed below: + + +CodeSeg + + +ProcBegin@ DevFuncLDD + + +dw LDDSignature +db 'TES',0,0,0,0,0 +dw (VectorEnd-Vector) /2 +Vector: +dw DevFuncInstall +dw DevFuncRemove +dw DevFuncHold +dw DevFuncResume ; Mandatory LDD vectors +dw DevFuncReset ; must be in this order +dw DevFuncUnits +dw DevFuncOpen +dw DevFuncStrategy +VectorHandler: +dw DevFuncHandler ; Optional LDD vectors +InterruptVectors: +dw DevFuncTickInt +VectorEnd: + + +ProcEnd noret +The vector table contains the offsets within the device drivers code segment for the functions required + + +by the EPOC operating system which must be entered in the order shown. Note that in this +document, the terms vector and function are used interchangeably. + + +Mandatory LDD Functions + + +All LDDs must support the following eight functions: + + +@ DevFuncInstall called on device installation + +@ DevFuncRemove called on device removal + +@ DevFuncHold called to temporarily disable the driver + +@ DevFuncResume called to enable the driver after it has been temporarily disabled + + +Revision 1.00 Page 39 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +@ DevFuncReset called when an application terminates without closing the channel +@ DevFuncUnits called to query the number of supported units (i.e. channels) + +@ DevFuncOpen called to open a channel to an LDD + +@ DevFuncStrategy called to access the driver's functionality from the I/O system + + +All of the eight mandatory routines pointed at by the function vector table will be called FAR by the +operating system and should therefore use a FAR return machine code instruction to return control +back to the OS. Since the FAR return address is to the OS it does not matter if the OS moves memory +whilst code in the LDD is being executed: the OS cannot move its own code. + + +DevFunclinstall + + +This function is called by the operating system when the device driver is loaded in order to initialise +any internal variables. It should not be called directly by an application process. The DevInstall +operating system service will cause this function to be called. Applications should not call this service +directly and should call instead the DevLoadLDD service. + + +An installable device driver may have the same name as a resident device driver. When the operating +system loads a device driver, it places it at the end of the device driver table. The operating system +will search this table for the appropriate device driver when it wishes to establish a channel. The +search starts at the end and thus will locate the most recently installed device driver (if any) or if not, +the resident driver. By this mechanism an installable driver can replace any resident driver. + +When called, the DS and ES segment registers are in an unknown state. The device driver should +take whatever steps necessary to obtain direct addressability to its data. For loadable device drivers +this involves setting the DS and ES registers to the CS register or more commonly just using the CS +override. The operating system will not move memory whilst in this function, thus the normal rules +governing DS and ES may be ignored. All operating system services may be called, except those +concerning file or device access. + +PASSED + +No values are passed to the install vector. + +RETURN + +If the installation was successful, return with the carry flag clear. + +If the installation failed, return with the carry flag set and the error number in the AL register. +PANIC + +The install vector must not panic: it will cause an operating system kernel fault if it does. +PRESERVE + +The SS, SP and BP registers must be preserved by the install function. + + +DevFuncRemove + + +This function will be called by the operating system when the device driver is requested to be +unloaded. It should not be called directly by an application process. The DevRemove operating system +service will cause this function to be called. Applications should not call this directly, they should use +the DevDelete service. Before the remove function is requested, the device driver will have received +a hold request. Thus devices will only ever be removed when in a held state. If the device driver is +currently busy serving a client, the remove request should return an error. Note that all resident +device drivers will return an error since there is no mechanism by which they can be re-installed. + + +When called, the DS and ES segment registers are in an unknown state; the device driver should take +whatever steps necessary to obtain direct addressability to its data. For loadable device drivers this +involves setting the DS and ES registers to the CS register. The operating system will not move +memory whilst in this function, thus the normal rules governing DS and ES may be ignored. All +operating system services may be called inside the remove vector, except those concerning file or +device access. + +PASSED + +No values are passed to the remove vector. + +RETURN + +If the remove was successful, return with the carry flag clear. + +If the remove failed, return with the carry flag set and the error number in the AL register. + + +Revision 1.00 Page 40 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +PANIC + +The remove vector must not panic: it will cause an operating system kernel fault if it does. +PRESERVE + +The SS, SP and BP registers must be preserved by the remove vector. + + +DevFuncHold + + +This vector will be called by the operating system when a logical device driver is requested to be held. +The hold vector is called in the context of the operating system so DS and ES are not available. The +DevHold operating system service will cause this vector to be called. Applications should not call this +service. Physical device drivers cannot invoke holds and resumes. The operating system will call the +hold vector under three conditions: + +e Device memory segments are about to be moved. + + +e The machine is about to switch off due to the auto switch off time-out or user request, it +enters the standby state. + + +e The machine is about to switch off due to the power source being removed. + + +It should be noted that holds and resumes are called on a per driver basis and so the corresponding +driver code must deal with all the currently open channels. In all cases the device driver must +respond to the request as quickly as possible. It must also ensure that ALL interrupts from the +hardware device that it is driving are disabled. Device memory segments can only be moved if an +installable device driver is being installed or removed. If the LDD uses an attached PDD and uses the +faster FAR call mechanism to call the PDD strategy vector, the PDD strategy vector address will +potentially move, thus the FAR address will be wrong. This address can be resolved in the resume +vector. The LDD must not call the PDD between a hold and resume. Typically, the device driver +only needs to disable its interrupts. When a resume occurs, the device driver should continue as +though nothing had happened. + + +If the machine is about to switch off due to the auto switch off or user request mechanisms (enter the +standby state), the device driver should make an orderly shut down of the device such that the state +before the shut down can be recovered when the system powers up again. The device driver should +also attempt to ensure that no data is lost. For example, in the serial driver the current state of the +hardware handshaking lines should be noted so that each state can be restored on power up. For this +type of power down the hold vector is allowed to take a significant length of time to shut down a +device. For example in a serial driver the hold vector should wait until the remote end stops +transmitting data after any hardware handshaking has been applied. Of course, the time taken should +be kept to a minimum: in the case of the serial driver above the time is roughly equivalent to 3 +character transmission times. When a resume occurs the device driver should continue as though +nothing had happened. + + +If the machine is about to switch off due to the power source being removed, the device driver should +reset the device in the minimum possible time: no attempt should be made to perform an orderly shut- +down. The device driver is not expected to be able to recover the hardware state. When a resume +occurs, the device driver would typically fail any outstanding application requests. If the hold vector +takes too long the voltage will fall below the threshold to hold the state of the internal RAM. If this +occurs the machine will perform a warm re-boot when powering up, all data in the internal memory +of the machine will be lost including the device driver code! On power fail there is about 2ms +available to power down all devices. + + +On a power failure hold, the operating system will already have sent a 'reset' to all the SIBO serial +channels. Any device drivers using these channels need only record the hold reason for the resume +vector. Any other peripherals should be designed to allow a power fail mechanism with the minimum +amount of code. It must be noted that the power fail type hold can occur whilst the device driver is in +the memory move hold state. In this case, the device driver will receive two hold requests before +seeing a resume request. A device driver must be capable of handling this. In this case, the device +driver will also receive two resume requests. A device driver will not get a power fail hold whilst in + + +Revision 1.00 Page 41 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +power down hold. A call to the hold vector will always be followed by a call to the resume vector +(except when a device is requested to be removed). + + +Note that with the Series 3a and Workabout, there is an additional case when hold and resume must +be invoked and that is on opening/closing of the pack doors. In this case, the LDD must generate its +own Hold and Resume. This situation is examined in more depth in the context of the specific +example drivers presented later in this document. + + +When called, the DS and ES segment registers are in an unknown state; the device driver should take +whatever steps necessary to obtain direct addressability to its data. For loadable device drivers this +involves setting the DS and ES registers to the CS register. The device driver should not call any +operating system services in the hold vector code due to the time taken, especially on power failure. +PASSED + +The AH register takes one of the following + + +@ DevHoldNormal Device memory is about to be moved. +@ DevHoldPowerDown The system is about to enter the standby state. +@ DevHoldPowerFail The system has lost its power supply. +RETURN +None. +PANIC + + +The hold vector must not panic: it will cause an operating system kernel fault if it does. +PRESERVE +The SS, SP and BP registers must be preserved by the hold vector. + + +DevFuncResume + + +This vector will be called by the operating system when the device driver is requested to be resumed. +The resume vector is called in the context of the operating system. The DevResume operating system +service will cause this vector to be called. Applications should not call this service. The resume +vector will be called either when memory has finished being moved or when the machine powers back +up. In both cases the hold vector will have been called before this vector is called. The device driver +is expected to recover from the previous hold request (except power fail) and resume any I/O that was +suspended. If the device driver has an interrupt service routine, it should reset the interrupt service +routine's address since the device driver may have moved in memory; its absolute segment address +will be different. + + +If the hold was a device memory segment move type hold, interrupts should be re-enabled. If the +LDD uses an attached PDD and uses the FAR call mechanism to access the PDD strategy vector, the +address of the PDD should be reset by using the DevGet PDDAddress operating system service before +enabling interrupts. Typically, the PDD will have a call back to the LDD and it needs to be informed +of the change of address of the LDD call back function, the LDD-PDD interface definition should +allow such a function request. + + +If the hold was a power down type hold, the resume vector needs to power up the peripheral and set it +to the state that it was in before the power down occurred. If this is not possible or data has been lost, +the device driver should inform any outstanding requests of this fact. It is also possible that the +hardware device that the driver is associated with has been removed. The driver should be able to +handle this properly. If the device driver is expected to generate events due to an external state +change, the driver should check the external state and generate appropriate events. For example, the +serial driver may be requested to inform an application when the DTR line changes state. The remote +end may have changed the state of DTR whilst the driver is held. + + +If the hold was a power failure type hold, the resume vector should power up the peripheral and put it + + +into a known state, preferably the state that the application software thinks that the device is in and +fail any outstanding requests as data is quite likely to have been lost. + + +Revision 1.00 Page 42 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +When called, the DS and ES segment registers are in an unknown state. The device driver should +take whatever steps necessary to obtain direct addressability to its data. For loadable device drivers +this involves setting the DS and ES registers to the CS register. All operating system services may be +called, except those concerning file or device access. + +PASSED + +None + +RETURN + +None. + +PANIC + +The resume vector must not panic, it will cause an operating system kernel fault if it does. +PRESERVE + +The SS, SP and BP registers must be preserved by the resume vector. + + +DevFuncReset + + +This function will be called by the operating system when the device driver is requested to reset a +channel. The reset function is called in the context of the operating system so DS and ES are not +available. The device driver must request that the operating system call the reset function. This is +achieved by calling the IoRequestReset system service, usually in the open vector. To cancel this +request, the device driver should call the IoRequestResetCancel system service. The cancel service +is usually called as part of the close functionality in the strategy vector. The reset vector will be called +when the operating system is tidying up resources owned by a process that has terminated. Ifa +process terminated before it closed the device driver channel and no reset service is requested, that +channel would remain allocated; no process will ever close the channel. The reset vector allows a +device driver to reset itself and allow the channel to be opened again. Any data required to perform +the reset must be stored in the device driver. The data space belonging to the process that originally +opened the channel has been returned to the operating system memory pool and is no longer valid. If +a device driver can handle multiple channels then the data passed to the IoRequestReset system +service should identify the channel. This data will be passed in the CX register to the reset vector. +The device driver should only have a reset request outstanding with the operating system while a +process has a channel open. + + +When called, the DS and ES segment registers are in an unknown state; the device driver should take +whatever steps necessary to obtain direct addressability to its data. For loadable device drivers this +involves setting the DS and ES registers to the CS register or using CS override. All operating system +services may be called, except those concerning file or device access. + +PASSED + +This function is passed data in the CX register that the device driver requested it be sent to determine +which channel should be reset. + +RETURN + +None. + +PANIC + +The reset vector must not panic; it will cause an operating system kernel fault if it does. + +PRESERVE + +The SS, SP and BP registers must be preserved by the reset vector. + + +DevFuncUnits + + +This function will be called by the operating system when the device driver is requested to report the +number of units (i.e. channels) the device driver can support. This function is called in the context of +the operating system. The operating system places no significance on the number of channels a +device driver can support. It is primarily used for informational purposes. An application may use +the number of units to attempt to open any available channel on that device driver. + + +When called, the DS and ES segment registers are in an unknown state; the device driver should take +whatever steps necessary to obtain direct addressability to its data. For loadable device drivers this +involves setting the DS and ES registers to the CS register. All operating system services may be +called, except those concerning file or device access. + +PASSED + + +Revision 1.00 Page 43 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +None. + + +RETURN + +The AX register should contain the number of channels supported. If a device driver can support +multiple channels (limited only by memory constraints) then the driver may return -1. A serial device +driver, for example, might only support two channels (TTY:a and TTy:8) whereas the file device +driver can open an unlimited number of files. + +PANIC + +The channels units vector must not panic; it will cause an operating system kernel fault if it does. +PRESERVE + +The SS, SP and BP registers must be preserved by the units vector. + + +DevFuncOpen + + +This function will be called by the operating system when a channel to the device driver is required to +be opened. This function is called in the context of the process that called the Ioopen system service. +This means that DS and ES point to the application data space. The device driver is passed two +parameters, its device handle and a pointer to an OpenEnt structure. The device handle is the entry in +the system device table of this device driver. The device driver is required to place this handle in the +ChanLibHandle field of the ChanEnt structure which must be allocated in the user's data space. The +operating system uses the device handle to route any I/O requests on the opened channel to the correct +device driver. + + +The OpenEnt structure contains three fields, openNamePtr, OpenMode and OpenChan. + +The openNamePt r field contains a pointer to the character that exists after the device name as passed +to the ToOpen system service. For example, if the ToOpen service was passed a name of PAR:A, the +OpenNamePtr field would point to the colon. If the ToOpen service was passed a name of TTY.AS5:B +the OpenNamePtr field would point to the full stop. The device driver should process the name +appropriately, opening the correct PDD as required. + +The OpenMode field contains the mode for opening the device driver. The available modes are +specified by the device driver writers. For example, a combined Xmodem and Ymodem device driver +could use the mode to specify whether the Xmodem or the Ymodem protocol is to be used. + +The Openchan field contains the I/O channel handle of the device that this driver is required to +‘attach’ to. Attached device drivers are dealt with later in the chapter. + +The code in a device driver open vector tends to follow a very similar pattern. This is demonstrated +by the following code fragments and associated comments. The first stage is to allocate some data +space in the calling process' heap space. This will contain the I/O channel control block: + + +mov cx, (size DeviceEnt) + +HeapAllocateCell + +jc noMemory + +mov bx, ax ; cell handle + + +If the device driver requires a WaitHandler (described later): + + +mov al, (VectorHandler-Vector) /2 +ToAddHandler + +jc endFreeMemory + +mov [bx].DriverHandler, ax + + +If the device driver's DevFuncReset vector is required to be called: + + +push bx + +mov cx, ChannelIndicator 7 unique per channel +mov bx, ax ; the device handle +ToRequestReset + +pop bx ; restore alloc cell + + +The chanEnt field of the DriverEnt structure must be initialised: + + +mov [bx] .DriverIo.ChanNext, bx +mov [bx] .DriverIo.ChanSignature, IoChanSignature +mov [bx] .DriverIo.ChanLibHandle, dx + + +The ChanNext field is used by attached drivers and will usually be set to be the allocated cell handle +of the device driver being opened. The IoFuncattach and IoFuncDetach functions manipulate these +fields. The I/O system uses this field to direct the I/O request to the correct driver. + + +Revision 1.00 Page 44 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The ChanSignature field is checked by the operating system during any I/O requests for the value +IoChanSignature. If it does not contain that value, the process calling the I/O service will be +panicked for having passed an invalid I/O channel handle. + +The ChanLibHandle field is used by the operating system to route an application's I/O request to this +device. The I/O request will call the DevFuncstrategy vector of the device driver. + +If the driver is an attached driver the following is required: + + +mov cx, bx ; allocated channel + +mov bx, [si] .OpenChan ; channel attaching to +mov al, IoFuncAttach ; return in BX the +ToWithWait ; channel attached to + + +Finally, if the channel has been successfully opened: +ele Opened Ok +ret return BX and DX + + +’ + + +’ + + +The error recovery code typically follows the following pattern: + + +endFreeReset: +push ax +push bx +mov cx, ChannelIndicator +mov bx, ax +ToRequestResetCancel +pop bx +pop ax +endFreeHandler: +push ax +push bx +mov bx, [bx] .DriverHandler +ToRemoveHandler +pop bx +pop ax +endFreeMemory: +push ax +HeapFreeCell +pop ax +stc +noMemory: +ret + + +If a device driver supports a fixed number of channels, it typically contains static control blocks. In +order to determine if a requested channel is currently open, a field should be interrogated. The device +driver should ensure that interrupts are disabled during this sort of check since a context switch could +occur and another process request the opening of the same channel. This is the classic 'test and set' +problem encountered in multi-tasking environments. + + +When called, the DS and ES segment registers point to the data segment of the application process +attempting to open a device channel. The application should ensure that the DS and ES segment +registers do in fact point to its data segment. The device driver must obey the normal rules +concerning segment register manipulation. The DS and ES segment registers can be reloaded if +required from the IntEnt structure pointed at by the BP register. All operating system services may +be called. + +PASSED + +DX contains the device handle of the device driver. + +SI is a pointer to the OpenEnt structure + +BP is a pointer to the IntEnt structure. + +RETURN + +If the channel open was successful, return with the carry flag clear and the BX register containing the +open channel. + +If the open failed, return with the carry flag set and the error number in the AL register. + +PANIC + +The open vector can panic; it will cause the process requesting the device open to terminate. It is +however more usual to return an error to the calling process. + +PRESERVE + +The DS, ES, SS, SP, BP and DX registers must be preserved by the open vector. + + +Revision 1.00 Page 45 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +DevFuncStrategy + + +When an application makes an I/O request on the opened device driver channel the request is routed +to this vector by the operating system. A device driver defines the set of functions that it supports. +These typically include IoFuncSet, IoFuncSense, IoFuncRead, IoFuncWrite and IoFuncClose. A +device driver does not have to support any particular function, as it is a matter of design between a +device driver writer and application writer as to what functions and associated parameters are +provided. To obtain the power of attached device drivers, however, it is recommended that the device +driver use the system defines with their appropriate functionality, for example, the loFuncWrite +function number should always be associated with writing data. + + +The strategy function is passed the channel handle as allocated in the open vector in the BX register. +This typically contains control information concerning the current state of the I/O channel. + +The SI register contains a pointer to a RgEnt structure. This structure contains four fields, +RqFunction, RqStatusPtr, RqA1Ptr and RqA2Ptr. + +The RgFunction field contains the function number as passed to the IowithWait (or +IoAsynchronous) I/O request by the application. If a device driver does not support the specified +function, it should pass the request on to its 'parent' device driver. + +The RqStatus pointer contains a pointer to a memory location in the application process's data space +that receives the I/O requests completion status. The device driver must set this memory location to +the value PendingErr whilst the I/O request is outstanding and a completion code when the I/O +request completes. An I/O request may complete within the strategy vector or it may complete some +time in the future, presumably from some interrupt. + +The RgA1Ptr and RqA2Ptr fields contain the argument | and 2 parameters as passed to the +IoWithWait (or IoAsynchronous) system services. The device driver is free to specify what these +parameters are (if any). + + +The operating system defines a set of common function numbers used by device drivers referred to as +the IoFuncxxx set of defines. By convention, a device driver should select from this list, particularly +if some of the more advanced features of the I/O system are to be used, such as attached device +drivers. The more common defines are listed below: + + +@ ToFuncRead ; read from the device. + +® TfoFuncWrite ; write to the device. + +@ TloFuncClose ; close device channel. + +@ = =ToFuncCancel ; cancel an I/O request. + +® ToFuncSet ; set driver characteristics. + +® tloFuncSense ; sense driver characteristics. +e lIoFuncFlush ; flush any buffers. + + +The PLIB library functions p_read, p_write and p_close will call the device driver with the +IoFuncRead, IoFuncWrite and IoFuncClose function numbers. Thus, if the device driver chooses +an alternative function number set, an application will not be able to use the supplied library +functions. All resident device drivers obey the following conventions: +e Acancel request will cancel any outstanding requests. A cancel request will not return any +error. + + +e Aclose request will ensure that any outstanding requests are completed before closing the +channel. A close request will not return any error. + + +e Only one request of a particular type can be outstanding at any one time. If a second request +is made the device driver will panic the calling application. + + +Any functions that the strategy function does not support should be passed on to the next driver down +the driver hierarchy. If the driver is a root driver (attached driver), this is achieved using the IoRoot + + +Revision 1.00 Page 46 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +(IoSuper)system service. If the requested function is not supported by any driver, the operating +system will return a Not Supported error. + + +When called, the DS and ES segment registers point to the data segment of the application process +making the I/O function request. The application should ensure that the DS and ES segment registers +do in fact point to its data segment. The device driver must obey the normal rules concerning +segment register manipulation. The DS and ES segment registers can be reloaded if required from +the IntEnt structure pointed at by the BP register. All operating system services may be called. +PASSED + +BX contains the allocated channel control block. + +DX contains the device handle of the device driver. + +SI is a pointer to the RqEnt structure. + +BP is a pointer to the IntEnt structure. + +RETURN + +If the function request is successful, the strategy vector should return with carry clear. A request +typically causes some I/O. If the I/O is completed by the strategy vector (i.e. the request is for a +synchronous function such as close), the completion status should be written back to the RqStatusPtr +location and the I/O semaphore signalled (using the IoSignal system service). If the request has not +yet completed (i.e. the request is for an asynchronous function), the RqStatusPtr location should +contain the value PendingErr and the I/O semaphore should not be signalled. + +If the function request failed the strategy vector should return with carry set and the error code in AL. +In this case, typically no I/O requests will be completed. + +PANIC + +The strategy vector can panic; it will cause the process making the I/O request to terminate. In most +cases it is usual to return an error to the calling process. A major exception to this is if the calling +process makes an I/O request of the same type as one that is currently outstanding and the device +driver only supports one I/O request of a particular type at a time; by convention the device driver +should panic the calling process with the PanicIoPending panic code. + +PRESERVE + +The DS, ES, SS, SP and BP registers must be preserved by the strategy vector. + + +Interrupts and Interrupt Service Routines + + +Device drivers that talk to hardware tend to have interrupt service routines associated with them, +especially if they are receiving data from an external source. The EPOC operating system provides a +framework within which an interrupt service routine can be written relatively easily. An interrupt +service routine is a code section that is called by the OS in response to a particular hardware event. +As indicated in the Hardware Overview, the SIBO architecture allows for eight independent hardware +interrupt sources, some of which are pre-allocated to system components. The operating system +provides the GenSetRevector service to allow a device driver to install an interrupt service routine +for any of the eight hardware interrupt sources. This call passes the interrupt vector (the address of +the interrupt service routine) and the interrupt number (which is dependent on the host hardware) to +the OS so that it knows where to jump to when the interrupt occurs. A device driver should use this +system service and not poke directly into the 8086 interrupt vector table. The address passed to the +GenSetRevector Service is not written into the interrupt vector table but to an internal table. After +invoking this service, the desired interrupts must be masked in by writing the appropriate mask to the +mask register. Initially, of the eight interrupt sources, only the tick interrupt is masked in. + + +When an interrupt occurs, the microprocessor could be running any currently active process. The OS +handles the servicing of interrupts by building a mandatory operating system call frame. All CPU +registers are preserved on route. The interrupt service routine is then called as a FAR routine. Since +the operating system preserves all registers the interrupt service routine is free to use any register. As +with all interrupt service routines various rules apply: + + +e Interrupt service routines should execute as fast as possible. Operating system interrupt +service routines are tuned to last no longer than one millisecond. + + +Revision 1.00 Page 47 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +e Typically, interrupt service routines do not enable interrupts unless the routine can handle re- +entrancy. + + +e Interrupt service routines run in the context of whatever process is running at the time of the +interrupt. An interrupt service routine should not attempt to obtain admissibility to the +process that opened the channel but access the internal driver space only which in general is +its own code space. + + +e An interrupt service routine must not directly cause the OS to reschedule the running process +as this would significantly delay its completion. It must use the IoSignalByPidNoReSched system +service in order to indicate to the handler that an event has occurred to the owning process. +The handler function of the device driver must pick up the event and inform the owning +process. + + +e An interrupt service routine should return with the carry flag clear if it requires a reschedule +to occur (it has called IoSignalByPidNoReSched) otherwise return with the carry flag set. This +will cause the operating system to reschedule if the internal state allows such an action +otherwise the reschedule request is effectively queued until such time that the operating +system can reschedule. + + +At some stage during the course of an interrupt service routine, it is necessary to clear the interrupt +line with some hardware-specific action. Then the interrupt controller inside the host ASIC1 or +ASIC9 has to be cleared with a write to the NonSpecificEoi location. To remove the interrupt service +routine address, the operating system service GenResetRevector should be used. This will reset the +internal table entry to the default held in the ROM. Additionally, the interrupt mask should be reset +to the original value. + + +Device Driver I/O Semaphore Wait Handlers + + +An LDD may nominate one of its functions to be called by the operating system every time the I/O +semaphore of the process that opened the channel is signalled. The nominated function, known as the +wait handler, will only be called if the application is waiting for an outstanding I/O request to +complete. For well written applications this is practically all the time. By convention the vector table +entry after the mandatory vectors contains the handler vector. A handler routine is similar to an +interrupt service routine in that it appears to run ‘from nowhere’. Comparing handlers and interrupt +services routines shows that: + + +e A handler will always run in the context of the process that has opened a channel. An +interrupt service routine will run in the context of whatever process happens to be running at +the time of the interrupt. + + +e A handler can access the data space of the process that opened the channel. The interrupt +service routine must not. An interrupt service routine should only access the data space in +the driver which is usually its own CS space. + + +e A handler can cause a reschedule. An interrupt service routine must not cause a reschedule. +If it did, the interrupt would not be fully serviced (the rest of the interrupt service routine +would not be executed until a reschedule back to the process running at the time of the +interrupt, which may not happen for a significant length of time). The interrupt service +routine must only use the IoSignalByPidNoReSched to signal the channel owner. + + +The handler is the mechanism by which hardware interrupt events can be filtered through to the +process using the I/O channel. Typically, it is in the handler code that the 1oSignal signifying +completion of an asynchronous I/O request is invoked. + + +Loadable Physical Device Driver Structure + + +A loadable PDD must obey the following rules: +e There must be a single code segment and no data segments. + + +Revision 1.00 Page 48 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +e The code segment must start with a LibEnt structure. +e There must be at least two supported functions, with typically a further two defined. + + +Single Code Segment + + +A PDD must be written to contain any internal variables within its own code segment. Typically, +these variables are only concerned with unit (i.e. channel) allocation and hardware state. Data space +for a particular open channel can be allocated in the heap space of the process that opens the device. +This data space will however disappear if the process terminates, thus any variables required for +‘freeing’ the hardware after a process terminates must exist in the code space of the device driver. + + +The LibEnt Structure + + +A LibEnt structure has the following format: +e =A two byte signature + + +e §=6©An eight byte name +e A two byte vector count +e A vector table + + +The two byte signature should contain the 'PDDSignature' define. The eight byte name contains a +zero terminated name, being that of the device driver. Note that there is no trailing colon. The two +byte vector count contains the number of vectors that follow immediately after the count. There +should be at least two. For example: + + +dw PDDSignature ; Its an PDD driver + +db "DVR.HW1',0 ; Name of the driver + +dw (VectorEnd-Vector)/2 ; Number of vectors +Vector: + +dw DvriInstall ; Install vector + +dw DvrRemove ; Remove vector +VectorEnd: + + +Most PDDs also define a further two vectors: +dw DvrOpen , Open Vector +dw DvrStrategy ; Strategy vector + + +The table of vectors is a table of offsets within the device drivers code segment of the routines that +implement the required functionality. The vector table must have the entries in the order shown in +the example. + + +Mandatory PDD functions + + +All PDDs must support the following two functions: +@ DevFuncInstallppp called on device installation. + + +@ DevFuncRemovePDD called on device removal. + + +Most PDDs will support the following two additional functions: +@ DevFuncOpenPDD called to open a PDD. + + +@ DevFuncStrategyPDD called to provide PDD functionality. + + +All of the routines pointed at by the function vector table will be called FAR by the operating system +and should consequently use a FAR return machine code instruction to return back to the operating +system. Since the FAR return address is to the operating system, it does not matter if the operating +system moves memory whilst code in the LDD is being executed; the operating system cannot move. + + +DevFunclnstallPDD + + +This vector will be called by the operating system when the device driver is loaded to initialise any of +its internal variables. The install vector is called in the context of the operating system and not the +process that is loading the device driver. The DevInstall operating system service will cause this + + +Revision 1.00 Page 49 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +vector to be called. Applications should not call this directly, they should use the DevLoadPDD +service. + + +An installable device driver may have the same name as a currently installed device driver. When +installed, the driver is added to the end of the device driver table. When a channel to a device driver +is being established by the operating system, it searches the device table from the end first, thus the +latest installed device driver with the required name will be asked first for a channel. So as with +LDDs by this mechanism installable device drivers can replace any of the resident drivers. + + +When called, the DS and ES segment registers are in an unknown state. The device driver should +take whatever steps necessary to obtain direct addressability to its data. For loadable device drivers +this involves setting the DS and ES registers to the CS register. The operating system will not move +memory whilst in this function, thus the normal rules governing DS and ES may be ignored. All +operating system services may be called except those concerning file or device access. + +PASSED + +No values are passed to the install vector. + +RETURN + +If the installation was successful, return with the carry flag clear. + +If the installation failed, return with the carry flag set and the error number in the AL register. +PANIC + +The install vector must not panic; it will cause an operating system kernel fault if it does. +PRESERVE + +The SS, SP and BP registers must be preserved by the install vector. + + +DevFuncRemovePDD + + +This vector will be called by the operating system when the device driver is requested to be unloaded. +The remove vector is called in the context of the operating system and not the process that requests +the unload. The DevRemove operating system service will cause this vector to be called. Applications +should not call this service directly; instead, they should call the DevDelete service. Before the +remove function is requested, the operating system will send a DevFuncHold request to all LDDs. +The LDD is responsible for ensuring that no activity will occur during the remove. Note that any +device driver that handles hardware interrupts must contain an LDD since only LDDs receive a hold +request. If the device driver is currently busy serving a client, the remove request should return an +error. All resident device drivers will return an error since there is no mechanism by which they can +be re-installed. + + +When called, the DS and ES segment registers are in an unknown state; the device driver should take +whatever steps necessary to obtain direct addressability to its data. For loadable device drivers this +involves setting the DS and ES registers to the CS register. The operating system will not move +memory whilst in this function, thus the normal rules governing DS and ES may be ignored. All +operating system services may be called except those concerning file or device access. + +PASSED + +No values are passed to the remove vector. + +RETURN + +If the remove was successful, return with the carry flag clear. + +If the remove failed, return with the carry flag set and the error number in the AL register. +PANIC + +The remove vector must not panic; it will cause an operating system kernel fault if it does. +PRESERVE + +The SS, SP and BP registers must be preserved by the remove vector. + + +DevFuncOpenPDD + + +This function is defined as a convenience function for the LDD-PDD interface. When an application +opens a channel to an LDD, it normally uses the Ioopen system service. If the name specifies, or the +LDD requires, a PDD then it needs to open a channel toa PDD. The Devopenppp system service will +call this PDD vector to establish a channel. The LDD now has a choice of calling a PDD vector using +the DevVector system service or calling the fourth vector in the vector table directly. The fourth + + +Revision 1.00 Page 50 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +vector is assumed to be a strategy vector to which any parameters as required by the LDD-PDD +interface can be passed. The FAR address of the strategy vector is returned by the +DevGetPDDAddress. When an LDD receives a DevFuncResume it should call DevGet PDDAddress +again to ensure that if the PDD has moved the LDD still has its correct address. As a design, a PDD +could provide many vectors, one for each required function. The LDD would then use the Devvector +system service to access each of these functions. The DevGetPDDAddress will only return the FAR +address of the fourth vector. + + +When called, the DS and ES segment registers point to the data segment of the application process +making the open function request. The application should ensure that this is indeed the case. The +device driver must obey the normal rules concerning segment register manipulation. All operating +system services may be called. + +PASSED + +The BX register contains a pointer to the PDD unit name. The pointer passed to the DevOpenPDD +service is used to find the PDD device to open. The BX register is loaded with a pointer to the +trailing colon (if any) in the PDD unit name. For example if the name "TTy.AS5:A" was passed to +the DevOpenPDD service, BX would contain a pointer to :A upon calling the open vector. +RETURN + +If the open was successful, return with the carry flag clear. + +If the open failed, return with the carry flag set and the error number in the AL register. + +PANIC + +The open vector can panic; it will cause the process requesting the device open to terminate. It is +however more usual to return an error to the calling process. + +PRESERVE + +The SS, SP and BP registers must be preserved by the open vector. + + +DevFuncStrategyPDD + + +This function is defined as a convenience function for the LDD-PDD interface. Typically, all +application function requests are routed through the strategy vector. To speed the calling interface, +the DevGet PDDAddress operating system function will return a FAR address of this vector. The +device driver writer defines all the functions and return values as required. + + +When called, the DS and ES segment registers point to the data segment of the application process +making the function request. The application should ensure that the DS and ES segment registers do +in fact point to its data segment. The device driver must obey the normal rules concerning segment +register manipulation. All operating system services may be called. + +PASSED + +The parameters passed are defined by the device driver write. + +RETURN + +All returns are defined by the device driver writer. + +PANIC + +The strategy vector can panic; it will cause the process requesting the function to terminate. It is +however more usual to return an error to the calling process. + +PRESERVE + +Which registers are preserved is defined by the device driver writer. + + +Revision 1.00 Page 51 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +10. ASIC4/ASIC5 BASED DEVICE DRIVERS + + +Introduction + + +This chapter describes the rules and problems involved in writing a device driver that controls some +form of ASIC4 or ASICS based hardware. Details concerning the internal organisation of these +ASICs were presented earlier in chapters 6 and 7. The emphasis is on their use for Series 3a +applications, though most issues that will be discussed also apply to the Series 3, MC and HC range of +Psion products. + + +In addition to the eight mandatory functions already detailed in the Device Driver Overview chapter, +an LDD will usually provide additional functionality in the form of further vector table entries +dependent upon the requirements of its application. Wherever possible, these functions should make +use of the various pre-defined system defines for services such as reading (p_read) and writing +(p_write) etc. It should be noted that there is no particular requirement to implement a device +driver as a separate PDD and LDD and in the case of the example logical device driver +A4EXIF.LDD, the approach taken is to incorporate both aspects into the one LDD. + + +SIBO Hardware Expansion Channels + + +The number of SIBO expansion channels supported by the host machine will vary according to the +particular Psion hardware present. So that a single device driver may be compiled for the different +host machine possibilities, a number of build flags can be used to set various constants within the +include files. The hardware options are outlined in the table below: + + +SIBO Machine Flags | Number of SIBO serial channels supported Machine Build Flag + + +Consumer (S3a) Refers to $3a with ASIC9 only. Supports 1 SIBO channel +(A) + + +ES ae Mat AST lysed SPS PTT + + +It should be noted that Psion device drivers should be designed to be easily adapted from machine to +machine. For a well-written driver, the only change that needs to be made in adapting it for use on +another Psion machine is the alteration of the build flag at the start of the code. This flag indicates to +the compiler which SIBO machine flags as well as other variables should be set for the host machine. +The four most important SIBO machine variables are the channel interrupt mask, the channel +interrupt number, the channel interrupt vector and the hardware SIBO channel. The channel +interrupt mask is an eight bit value or'd with the contents of either AlInterruptMask or +A9BInterruptMask (the mask registers) to initiate interrupts on the relevant channel depending on +whether the interrupt controller resides in ASIC1 or ASIC9. If this mask is then used in a +HwGetChannel call, any hardware interrupts on the selected expansion channel will be directed to the +appropriately coded interrupt service routine. The channel interrupt mask is also required in the +subsequent HwFreeChannel OS service call and when stopping hardware interrupts. The channel +interrupt number is a sixteen-bit quantity required by the GenSetRevector and GenResetRevector +OS system services to indicate to the OS which default interrupt service routine is to be replaced by +the suitably coded device driver interrupt vector. The channel interrupt vector is a sixteen-bit +pointer to the location of that interrupt vector in the device driver code. Finally, the hardware SIBO +channel is used by the HwSelectChannel OS service to direct any SIBO serial control or data frames + + +Revision 1.00 Page 52 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +along the appropriate channel. The situation regarding the value of these variables for the expansion +ports on all current SIBO platforms is illustrated in the table overleaf: + + +IW orkabout (Series3) +a en en an +Channels + + +Controller ASIC |ASIC? ASICO +Mask Register A9BInterruptMaskRW a a a ae + + +IHwIrq2Revector + + +mask A9MExpIntA +(Expansion Port A) +mask A9MExpIntB +(Expansion Port B) +Imask AOMSlave + +(Expansion Port C) + + +IHwIrq4Revector +IHwIrgq5Revector +IHwIrq2Revector + + +ASIC2 + + +mask ExpIntLeftA +(Expansion Port A) +mask ExpIntRightB +(Expansion Port B) +mask Asic2Int +(Expansion Port C) + + +IHwIrgq3Revector +IHwIrq2Revector +IHwIrq4Revector + + +ASIC2 ASIC2 + + +mask Asic2Int +(Expansion Port C) + + +mask ExpIntLeftA + +(Expansion Port A) +mask ExpIntRightB +(Expansion Port B) + + +IHwIrgq3Revector +IHwIrq2Revector + + +IHwIrq4Revector + + +Ptr +Channel SelectChannel5. SelectChannel3 IExpChannelLeftA IExpChannelLeftA SelectChannel7 +Hard Select SelectChannel4 ExpChannelRightB = |ExpChannelRightB + +arOWAre Dre’ SelectChannel5 SelectChannel7 + + +Talking to ASIC4 + + +All communication to an ASIC4 is via a Psion Serial Link. As explained in the chapter on the SIBO +serial protocol, two forms of data can be sent and received along this channel. These are control and +data bytes. Control bytes give specific instructions to ASIC4 and data bytes can either be data sent to +or from ASIC4 or data given to or taken from peripheral chips in ASIC4's address space. Sending +and receiving control and data frames down a Psion Serial Channel from a Series 3/HC host is simply +a matter of IN and OUT instructions to various fixed I/O addresses. Various assembler macros have +been set up to ease this task and provide machine independence and they are detailed in the appendix. +These include: + + +SCONTOUT Output the control byte held in the AL register +SDATAIN Input a byte of data and place it in AL + +SDATAOUT Output the data byte in the AL register + +XNOP Wait a short while + +SBUSY Wait while the Psion Serial Link is busy + + +Once a piece of peripheral hardware has been designed the appropriate software must be written to +control it. All hardware devices on Series 3/3a, Workabout and HC machines are controlled by device +drivers. These act as an interface between a piece of hardware and an application that uses it. The +following section goes into further detail regarding the methods by which a device driver is able to +communicate with and thereby control an ASIC4 and ASICS based peripheral. + + +ASIC4 Registers + + +ASIC4 has eight registers and their functions in mixed (i.e. peripheral) mode are outlined below: + + +Register 0: This register is the read/write Data Register that controls the data lines DO-D7 which are +normally in tri-state mode. Data written to the Data Register is output on DO-D7 during a write cycle +and data input to the DO-D7 may be read from the register during a read cycle. On reset, this register +holds the Info Byte and its bits have the following meanings: + + +Revision 1.00 Page 53 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Bit No. D7 D6 DS D4 D3 D2 DI DO +DD DN N S S _ S + + +D D_ OD i _ Device type + +0 0 O RAM SSD + +0 oO 1 Intel Flash type 1 + +0 1 O Intel Flash type 2 + +Oo 1 1 TBS + +1 0 O TBS + +1 0 1 TBS + +1 1 0 Read only SSD (ROM OTP etc.) +1 1 1 Hardware Write protected SSD +N N Number of devices + +0 O 1 + +0 1 2 + +1 0O 3 + +| ae | 4 + +S S_ S__ Device Size + +0 O O Illegal (Indicates no SSD present) +0 0 1 32Kbyte + +0 1 O 64Kbyte + +Oo 1 1 128Kbyte + +1 0 O 256Kbyte + +1 0 1 512Kbyte + +1 1 O 1Mbyte + +1 1 1 2Mbyte + + +Register 1: This register is both a read and write register. In read mode, it is termed the Input +Register. The eight bits of this register are then defined as follows: + + +The Se, De and Ne bits hold, on reset, the Extended Info Byte which is used in ASIC4 Extended mode +to define the type of peripheral device as explained later in the section on ASIC4 reset and +configuration and outlined below: + + +M De Ne Se +1 0 0 90 No peripheral devices +1 0 O 1 Turbo RS232 serial (16550) +1 oO 1 O 3Fax +1 oO 1 1 T.B.S. +1 1 0O 0 T.B.S. +1 1 OO 1 T.B.S. +1 1 1 O T.B.S. +1 1 1 1 Extended info contained in ROM. + + +The X2 bit sets the state of the X2D2 input which is used to indicate whether the device size is +correct. In M=0 mixed mode, the X2 bit must be low. Inputs In0-In2 hold the current status of the +three correspondingly named general input lines to ASIC4. + + +In write mode, Register 1 is termed the Device Size Register where bits 3-0 (S3-SO) map to the +settings of the decoder inputs (and hence the peripheral device size) as follows overleaf: + + +Revision 1.00 Page 54 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Size Register Decoder Inputs Device Size (bytes) +S3 S2 S1 SO DCO DC1 DC2 + +0 0 0 0 A15 Al6 Al7 32k + +0 0 0 1 Al15 Al6 Al7 32k + +0 0 1 =O Al6 Al7 A18 64k + +0 oO 1 1 Al7 Al18 A19 128k +0 1 0 0 Al8 Al19 A20 256k +0 1 0 1 A19 A20 A21 512k +0 1 1 =O A20 A21 A22 1M + +0 1 1 1 A21 A22 A23 2M + +1 0 0 0 A22 A23 A24 4M + +1 0 O 1 A23 A24 A25 8M + +1 0 1 O A24 A25 A26 16M + +1 oO 1 1 A25 A26 A27 32M + +1 1 0 0 A26 A27 0 64M + +1 1 0 1 A27 0 O 128M +1 1 1 = O 0 0 O 256M +1 1 1 1 0 oO O Not Used + + +This register defaults to OxOf on reset (i.e. not used). + + +Register 2: A write to this register , the Address Increment Register, will increment the addresses +AO-A3. + + +Register3: This register is the write-only Address Register which controls all 28 address lines (AO- +A27) directly and the eight chip selects (CSO-CS7) indirectly. The address register is written to in +multi-transfer mode LSByte (ATO) first. There can be up to four bytes written: + + +Byte Address lines +ATO AQ - A7 +ATI A8& - Al5 +AT2 Al6 - A23 +AT3 A24 - A27 + + +When the first byte is written, all the higher address lines (A8-A27) are reset to 0. Bits 4-6 of AT3 +may be used by the internal address decoder to control the CS outputs CSO-CS3 if appropriate. On +reset, all bits of this register are cleared. + + +Register 4, 5 and 6: Not implemented. +Register 7: This register is the write only ASIC4 Control Register and holds the following bits: + + +Bit: 7 6 5 4 3 2 1 0 +Label: LBO TSTA LTM VPS EDA CSS WRS OES + + +Setting the LBO and VPS bits causes the corresponding lines on ASIC4 to be set high enabling them +to be used as general purpose outputs for peripheral development. OES and WRS control R/W +accesses. + + +Additional ASIC4 Signals + + +InO, In1, In2 are general purpose digital inputs. LBO, VPS are general purpose digital outputs. OE, +WR control Read/Write bus accesses. MCSD, X2D2 should be tied to ground via a 100k resister. +POR is the reset line. + + +Revision 1.00 Page 55 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Talking to ASIC5 + + +The Psion serial protocol was designed to allow many different peripheral ASICs to lie on the same +serial channel. Before software can communicate with an ASICS it must first be selected. ASICS +must be selected in different ways depending on whether it has been configured (in hardware) to +operate in either Pack or Peripheral mode. In addition to selecting ASICS when it is first used, +ASICS must be re-selected whenever a hold and resume is generated due to power down, pack doors +opening or when the peripheral is inserted or removed. ASIC5 will always respond to a select with a +byte indicating what type of peripheral or pack it is. If there is no ASICS connected to the Psion +serial link there will obviously be no response (zero is returned) and software must then take the +appropriate action. To select a peripheral mode ASICS the following code can be used: + + +HwNullFrame + +mov al, (SerialSelect or Asic5NormallId) +SBUSY + +SCONTOUT + +XNOP + +SBUSY + +SDATAIN + +test al,al + +je NoASIC5PeripheralOutThere + + +To select a pack mode ASICS the following code can be used. + + +HwNullFrame + +mov al, (SerialSelect or Asic5PackId) +SBUSY + +SCONTOUT + +XNOP + +SBUSY + +SDATAIN + +test al,al + +je NoASIC5PackOut There + + +Note that an ASIC4 can pretend to be an ASICS in pack mode and will respond appropriately. + + +ASIC5 Registers + + +ASICS has sixteen internal registers. To read or write from an ASICS register takes two steps. First +a control byte must be sent along the Psion serial link to select which register. This should be +followed by a read or write of the appropriate data value. The sixteen registers are listed in the table +below. Some can be read and written to and some are read or write only. + + +| oO | URW PortAreadandwritedata +| 6 | RW Interrupt Maskread and write +| 8 | RW __| UART Status/UART Control register +| 9 | R/W_| UART Receive/UART transmit holding register_| +UART Baud rate LSB + +| 13) | OR Barcodereaddata +| 4 {| ER Synchronous Port2read + + +Revision 1.00 Page 56 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Reading from the Port A register causes ASICS to generate a memory access cycle. The value read +from port A will be the value retrieved from any attached memory or memory mapped peripheral. +Writing to Port A will cause ASICS to generate a write cycle and write the supplied value to attached +memory. In both cases the address used for the access will depend on ASICS's mode and the +configuration of ports B, C, and D. If the UART is enabled (Bit 0 of the port B mode register) +memory cannot be accessed because port A lines are reused. + + +Writing to port B will cause the value written to be latched onto the output lines PBO-PB7 (which +form address lines AO-A7 for memory access cycles). Reading from this register will return the last +value written. + + +Writing to the port B mode controls various aspects of ASIC5 behaviour. The table below indicates +the meanings of each bit in the register. When set to operate in counter mode the value output on +lines PBO-PB7 can be incremented by reading from the port B mode register, post-incremented by +reading or writing to the port A register or cleared to zero by writing to the Port D and C register. + + +| 0 _| 0, Memory mode. 1, Peripheral mode -enables UART____| +| 6 NotUsed +— a + + +7 Not Used + + +POT | Countermode +POT Latch mode +Pot | Baud rate outon portB + + +When ASICS is in pack mode the first write to the port D and C register will be latched onto lines +PDO-PD7. In multiwrite mode the second and subsequent data writes will be latched onto port C with +the following bits in the register forming the following functions. + + +| Databit_ | Pin, | Function _| +a | + + +The bit SELO and SEL1 determine which chip select is used when a memory access cycle is generated +by accessing port A. CSO-CS3 are selected as follows. + + +CSO + + +CS2 + + += + + +Revision 1.00 Page 57 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +In peripheral mode a write to the port D and C register will latch the value written onto lines PD1- +PD7. In peripheral mode the line PDO forms the UART TX line. Setting bit zero in the port C and D +register therefore has no effect. + + +ASICS is capable of generating an interrupt due to various external events. The interrupt mask +register is used to select which events will generate an interrupt. Writing to the interrupt mask +register will set the mask to the value written. Reading the interrupt mask register will return the +current mask. The meanings of each bit in this register is given in the table below. Setting an +appropriate bit to 1 will enable that events interrupt, clearing to 0 will stop that event from causing an +interrupt. On reset all events are disabled. + + +Bit +| OP UART CT UART character received + + +Synchronous port] character received +Synchronous port2 character received +| 6 [PCA Barcode data/general interrupt + + +When an interrupt occurs reading the Interrupt Status register will indicate the source of the interrupt. +The meaning of each bit corresponds directly to each bit in the interrupt mask (see table above). A +high bit indicates an active interrupt event. + + +Reading the Barcode data register returns a byte representing the states of the following lines. + + +Communicating with ASIC4 + + +ASIC4 is capable of operating in several modes. Attached peripherals can contain an ASICS chip +instead of an ASIC4. Before talking to an ASIC4 you must first ensure that there is an ASIC4 at the +end of your serial link and you must set ASIC4 into the correct operating mode. You must do this +when the channel is first obtained to ensure you have the right peripheral to start with, and also +whenever you get a Hold and Resume due to a power down, Pack doors opening, or the peripheral +being removed. You should also check the peripherals ID to check what peripheral it is. The user is +more than likely to pull out your I/O port and replace it with a 3Fax in mid operation. You select +ASIC4 in the correct mode by sending a special control code. If there is an ASIC4 out there it will +respond by sending back a non zero value. The peripherals ID can be read back from ASIC4's info +register. This register also returns the state of the input lines INO, IN1, IN2. The coding example +below shows how ASIC4 can be checked for, selected and the peripheral ID checked: + + +HwNullFrame + +mov al, (SerialSelect or Asic4Id) ; First look for an +SBUSY ; ASIC4 at the other +SCONTOUT ; end of the link +XNOP + + +Revision 1.00 Page 58 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +SBUSY +SDATAIN +test al,al +je NoAnASIC4IsItAnASIC5 +mov al, (SerialReadSingle or A4InfoR) ; Now see if we +SBUSY ; have the right +SCONTOUT ; peripheral +XNOP +SBUSY +SDATAIN ; Mask out the unwanted +and al,0Of0h ; bits +cmp al,PERIPHERAL_ID ; check for correct ID +jne IsASIC4ButNotRightPeripheral ; Got our peripheral +ele ; Connection Okay! +ret +IsASIC4ButNotRightPeripheral: + Is an ASIC4 but not +popt ; the right peripheral +stc ; Connection Failed! +ret +NoAnASIC4IsItAnASIC5: ; No ASIC4 +mov al, (SerialSelect or Asic5NormallId) +SBUSY ; Could have been an +SCONTOUT ; ASIC5 so try to put +XNOP stc ; back in the +right mode +ret ; Connection Failed + + +Bits in ASIC4’s info register have the following definitions: + + +Pot | Dmsb | DT Wiss | TN? TN NO +Sending and Receiving data using ASIC4 + + +All ASIC4 peripherals are memory mapped into that ASIC's address space. To access a peripheral or +a particular peripheral's register the ASIC must first be told to set its address bus to the appropriate +location. Once it has been informed of the address which it is to access that location can be read from +or written to as many times as required. The value to be written is held in the data register. To read +or write to another location the address that the ASIC is accessing must be changed. To read from a +random address within the ASIC's address space the sequence would be: + +1) Send a control code to inform the ASIC that it is to set its address bus to the following address. + +2) Send the address to position to. + +3) Send a control frame to inform the ASIC that we wish to read from this address. + +4) Read back the byte. + + +To write a random value to and address within the ASIC's address space the sequence would be: + + +1) Send a control code to inform the ASIC that it is to set its address bus to the following address. +2) Send the address to position to. + +3) Send a control frame to inform the ASIC that we wish to write to this address. + +4) Send the byte. + + +Overleaf are two 8086 assembler functions Input and Output which read from or write to an address +within the ASIC's address space. These functions only give access to the bottom 256 addresses. For +peripheral devices this is usually more than adequate. Interrupts should always be off during calls to +these functions to prevent the S3/S3a/HC from multitasking. Note that in the following routines, +A4Address and A4Data refer to the value of the respective ASIC4 registers. SerialWriteSingle has +the value corresponding to a single frame write in the SIBO serial protocol format. These system +defines can be found in the important include files ospack.inc and ossibo.inc. + + +ProcBegin@ Output + + +; +; + +; Output byte to ASIC4-based peripheral + +; IN: DL holds the hardware address ASIC4 is to write to + + +Revision 1.00 Page 59 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +; AL holds the byte to be output to that address + +push ax + +mov al, (SerialWriteSingle or A4Address) ;CTRL=Write to A4 address +reg + +SBUSY + +SCONTOUT ;Send this control +frame + +mov al,dl ;DATA=Hardware address + +SBUSY + +SDATAOUT ;Send this data +frame + +mov al, (SerialWriteSingle or A4Data) ;CTRL=Writing data +now + +SBUSY + +SCONTOUT ;Send this control +frame + +pop ax ;DATA=Data to write + +SBUSY + +SDATAOUT ;Send this data +frame + +ret + + +ProcEnd noret + + +ProcBegin@ Input + + +; Input byte from ASIC4-based peripheral +7 IN: DL holds the hardware address ASIC4 is to read from +; OUT:AL holds the value read from that address + +mov al, (SerialWriteSingle or A4Address) ;CTRL=Write to A4 address +reg + +SBUSY + +SCONTOUT ;Send this control +frame + +mov al,dl ;DATA=Hardware address + +SBUSY + +SDATAOUT ;Send this data +frame + +mov al, (SerialReadSingle or A4Data) ;CTRL=Reading data +now + +SBUSY + +SCONTOUT ;Send above +control frame + +SBUSY + +XNOP + +SDATAIN ;Receive data frame + +ret ;AL holds the data + + +ProcEnd noret + + +Obtaining and using a channel + + +The s3/S3a/HC have three Psion serial links. Only one of these channels can be selected for +communication at any one time. Two of these channels form the SSD slots. The third forms the +expansion port. Before a device driver is able to talk to a peripheral it must both own and have this +third channel selected. Many device drivers can exist in memory and more than one may access the +peripheral. To prevent multiple access to a single peripheral a device driver must first own a serial +channel before it is free to communicate to the ASIC4/S peripheral at the end of it. To check if a +channel is free and then reserve it call the operating system function HwGetChannel. This will return +with carry clear if the attempt to capture the channel was successful, carry set otherwise. + + +mov al, InterruptMaskForDesiredChannel +HwGetChannel +jc CouldntGetTheChannel + + +Obtaining the desired channel will usually be performed by a device drivers open vector. Open +should fail if the channel is unavailable. If a device drivers takes possession of a channel it is its duty + + +Revision 1.00 Page 60 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +to free it again once it is finished. This would normally be done when the device drivers is closed and +is performed by the operating system function HwFreeChannel. + + +mov al, InterruptMaskForDesiredChannel +HwF reeChannel + + +As illustrated in the above table, on a series 3a the interrupt mask for the expansion port (Port C) is +defined by A9MSlave, on a series 3 Asic2Int. Interrupts are IRQ2 and IRQ4 respectively. Only one +serial link can ever be selected at one moment in time. Selecting a particular channel means that you +are unable to speak to another without selecting it instead. To select a channel the operating system +call HwSelectChannel is used. + + +mov al, SelectForDesiredChannel +HwSelectChannel +push ax + + +HwSelectChannel will return in al the channel that was previously selected. Device drivers should +select the correct channel on entry to any vector or interrupt service routine that needs to +communicate down that channel. On exit the previously selected channel should be restored. +Between the time when the channel is first selected and when the old channel is restored multitasking +should be disabled. this will usually mean switching off interrupts. Because of the watchdog timer, +interrupts cannot be left off for an indeterminate length of time. Communications down channels +therefore will usually be restricted to short bursts. For the expansion port the channel to select on an +S3a is defined by Select Channel5 on an $3 SelectChannel7. + + +pushf + +eli + +mov al, SelectChannel5 +hwSelectChannel + +push ax + +mov dl, AddressOfInputBuffer +call Input + +mov dl, AddressOfOutputBuffer + + +call Output + + +pop ax +hwSelectChannel +popf + + +Controlling ASIC5's UART + + +Before data can be sent or received from ASIC5's UART continuous clocking from the host must be +enabled and a baud rate selected. The UART must be enabled by setting bit 0 in the port B mode +register. The selected baud rate value is related to the result of dividing the required baud rate into +the input clock frequency from the host of 1.536 MHz. The value generated from the equation given +below forms a sixteen bit word. ASICS has two registers for selecting the baud rate. Register 10 +should contain the least significant byte and register 11 the most significant byte of the calculated +word value. The table below lists the divisor values for some of the more commonly required baud +rates: + + +Divisor = 1-(96000/Desired Baud Rate) + + +9600 a ee ae ee +7200 fff +4800 + + +Revision 1.00 Page 61 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The format of data communicated, stop bits, data bits, parity checking, is controlled by writing to the +UART status/control Register. Bits in the UART status/control register have the following meanings: + + +| 0 | Stateof the CTS line (PAI) ___| Generate break character +iar + + +A character to be transmitted should be written to the Transmitter Holding Register where ASICS will +convert it to serial form for transmission. The register will be emptied once the character has been +transmitted. ASIC5 contains no internal buffering. The Transmitter Holding Register must be empty +before writing a character to it. The state of the Transmitter Holding Register is reflected in the +Transmitter Empty bit in the UART status register. Enabling the Transmitting Holding Register +interrupt will cause ASICS to generate an interrupt every time that the Transmitting Holding Register +becomes empty. Reading the UART Status Register will clear the interrupt. Received characters are +copied into the Receive Character Register. If the Receive Character Interrupt is enabled ASICS +generates an interrupt on each character received. If the character is received in error due either +parity, framing or overrun errors, appropriate bits in the UART Status Register are set to reflect this. + + +Hold and Resumes + + +There are three types of hold and resume. The first occurs when memory is being moved. An LDDs +hold and resume vectors will always be called when this occurs. The second is a On/Off Hold and +resume. An LDD will always be held and resumed when this occurs although it is not guaranteed that +power will have been restored to the expansion ports when the resume is issued. The third type +occurs when one of the pack doors is opened or a peripheral inserted. Only certain internal LDDs +receive a Hold and Resume under these circumstances. Any loaded LDD will definitely not receive a +Hold or Resume. To get around these problem, the TcK: device driver is used to provide a regular +call to a routine within your driver. This call monitors the power to the expansion port and issues its +own holds and resumes as appropriate. Holds and resumes can become nested and the whole situation +can become rather complicated. The correct procedure for dealing with holds and resumes for an +ASIC4 peripheral device driver (LDD) is given below. + + +When a hold is received through the normal route the channel is marked as being under a normal +hold. If the polling routine sees that the power has vanished and the channel is not already under a + + +Revision 1.00 Page 62 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +normal hold then it holds the channel and marks it as being under a special hold. If a normal resume +is issued channel can be resumed but only if power is present. If power is not present then the +channel is marked as being under a special hold and the resume is put off. If the polling routine sees +that the power is present and that the channel is under a special hold then it should resume the +channel. + + +Alternatively of course each time you read and write to your peripheral you could do a quick pre- +check to see if the hardware is available and set-up correctly. This would dispense with the need to +handle power up/down or pack door holds and resumes. You would still have to start and stop +interrupts though when appropriate. + + +Example Device Drivers + + +An example device driver which will control the ASIC4 Example Interface Board described earlier +can be found in the file A4EXIF.ASM. The device driver is a fully comprehensive multi-channel +implementation. It supports all the mandatory logical device driver functions. Open will fail if the +Interface Board hardware is not present. It has an interrupt service routine and handles Holds and +Resumes correctly in all the distinct cases outlined earlier. In addition, asynchronous reads of the +LED status are possible so a special routine to handle this case, the Wait Handler, is included. The +driver has been made as fully comprehensive as possible both in terms of functionality and the choice +of host machine. To this end, the code given can be compiled for the entire range of Psion machines +simply by changing the appropriate machine Build Flag at the head of the file which then causes the +correct interrupt masks to be selected for the machine. Chapter 11 of this document details the +structure of A4EXIF.LDD a logical device driver constructed for the ASIC4 Example Interface Board. + + +Chapter 12 details the functionality of a physical device driver for the ASIC5-based Psion 3-link +peripheral that enables the host hardware to communicate with a PC by converting SIBO serial +protocol signals into RS232 signals. Once again, this driver contains various build flags to facilitate +conditional compilation. Common interrupt routine code is included and the LDD-PDD interface is +specified. + + +The source code for both A4ZEXIF.LDD and SYS$AS5.PDD is presented in the appendix to this +document. + + +Revision 1.00 Page 63 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +11. AN EXAMPLE DEVICE DRIVER FOR ASIC4: +A4EXIF.LDD + + +Introduction + + +In this chapter, the functionality and code structure an example installable logical device driver, +A4EXIF.LDD, is presented in some depth. Circuit details of the corresponding Psion peripheral for +this driver, the ASIC4 Example Interface board, were outlined in chapter 8. A4EXIF.LDD enables +software written using the Psion SDK to communicate with the prototype ASIC4 Example Interface +board through means of standard PLIB calls such as ‘p_open' and 'p_write’. The description of +A4EXIF.LDD is intended to provide a clear insight into the generalised structure of logical device +drivers for peripherals based around the SIBO architecture. To this end the actual usefulness of the +combined hardware-driver interface is of secondary importance. As shown earlier, the ASIC4 +Interface Board translates SIBO serial protocol signals into a parallel 8-way data bus format which +can be used to set various 74HC series latches and gates. An eight-bit buffer and latch are commoned +to eight LEDs. The latch is write-only and is used for setting the state of the LEDs. The buffer is +read-only and is used to sense the state of the LEDs. In addition, a facility for generating hardware +interrupts is provided by means of a suitably connected switch and third 8-way buffer (the status +buffer). Address decoding is provided by two 2-to-4 decoders attached to address lines AO and Al. + + +Code Structure + + +Loading A4EXIF.LDD and Device Names + + +A4EXIF.LDD is loaded into the RAM of the host machine by means of the following PLIB call in the +application code: + + +p_loadldd ("A4EXIF.LDD") ; + + +The name of a device driver is the mechanism by which an application can obtain a channel to that +device driver. LDDs all have three character names which are stored in the second field of the +driver's LibEnt structure followed by a colon. This name is required to uniquely identify the LDD to +the OS when attempting to open a channel on it. The A4EXIF LDD has the three character name +"LED" so a channel with its handle in pcb may be obtained on it by means of the following call: + + +p_open (&pcb, "LED:",-1); + + +EPOC used the driver name in the p_open call to invoke the ToOpen system service which in turn +invokes the Open vector on the associated device driver. + + +The Single Code Segment and Data Storage + + +As indicated earlier, loadable Psion device drivers have a single code segment and no data segment. +Data associated with the driver is stored in one of two distinct ways dependent on its nature. Global +data associated with the driver is stored in its code segment. Examples of such data are the channel +interrupt masks and numbers have to be visible to all processes that may be using A4EXIF.LDD. +Data local to the application invoking the driver, however, is stored in the heap space of that +application. An example in A4EXIF.LDD would be the pointers to the open channel strategy vector +parameters. + +The overall structure of the code segment is typical of Psion logical device drivers. The code segment +begins with a CodeSeg directive followed by the LibEnt structure which defines the mandatory device +driver functions as well as two non-mandatory ones. These are the Wait Handler and the replacement + + +Revision 1.00 Page 64 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Tick Interrupt Vector. Before entering the code for these functions, all global variables are declared +in what is termed the device driver's internal data space. Following the code for the Lib Ent functions +comes the code for all the local driver functions. After these are the EndCodeSeg and end A4ExifLDD +directives. + + +Channel Status Ent and Open Channel Control Block + + +At the head of the driver's assembler source file A4EXIF.ASM, various constants, compiler defines +and type definitions are listed. It is here that templates are declared for the global structures that hold +the key driver variables. In view of the above discussion, most device drivers employ at least one +globally defined structure to hold the various important flags and masks that relate to the status of +each separate channel on that driver. In the case of A4EXIF.LDD, two different structure types are +employed, namely A4ExifStatusEnt and A4ExifEnt. The former is referred to in this chapter as the +StatusEnt struc and is instantiated later on in the device driver code segment with each separate +permissible channel of the main Psion host machines being assigned its own StatusEnt struc. A +channel's StatusEnt struc is generally accessed through CS:DI and holds important channel-related +information such as the A4ExifChannelOpen and A4ExifChannelRunning flags and the channel +interrupt masks and interrupt numbers. The StatusEnt structure resides in the driver code segment +whereas the A4ExifEnt struc is held in the heap space of the application invoking the driver and so is +accessed through DS:BX. The A4ExifEnt structure contains a number of variables that are logically +associated with a successfully opened channel and as such should be distinguished from the StatusEnt +variables. An A4ExifEnt struc instantiated by invoking the device driver's open vector is referred to +as the open channel control block and it is generally accessed through DS:BX. + + +The layout of both the StatusEnt struc and the A4ExifEnt open channel control block struc are +presented later in this chapter along with various other important pre-defined structs that were used in +the construction of A4EXIF.LDD. Both of these structures were extensively used in the coding of the +LDD functions described in the following pages. + + +SIBO hardware and conditional compilation + + +The number of expansion channels supported by a host SIBO machine is dependent on the hardware. +In the case of the S3a, only one SIBO channel can legitimately be opened corresponding to expansion +port A. With the HC and Workabout, it is possible to open up to three separate SIBO channels on +ports A through to C. In A4EXIF.LDD, a global constant numberofchannels 1s set at the start of the +device driver code segment to indicate the number of serial SIBO channels supported by the different +machines. This will vary according to the Psion hardware present and in order to aid conditional +compilation of the A4EXIF driver for the different host machine possibilities, a number of build flags +can be used to set various constants within the include files. The hardware options with regard to +these flags were outlined in the previous chapter. + + +It should be noted that Psion device drivers should be designed to be easily adapted from machine to +machine. With the A4EXIF driver, for instance, the only change that needs to be made in adapting it +for use on another Psion machine is the alteration of the build flag at the start of the code segment. +This flag indicates to the compiler which SIBO machine flags as well as other variables should be set. +The SIBO machine flags are in turn used later in the code segment header to set the global +numberofchannels variable mentioned above. For example, in A4EXIF.LDD, we have the +following: + + +if Corporate or Workabout +numberofchannels equ 3 +else + + +endif + + +This type of code is used extensively in the conditional instantiation of A4ExifStatusEnts in the +device driver's internal data space. Here different interrupt masks and SIBO channels are invoked for +the different machines according to the host controller ASIC. For instance, in the case of a consumer +(S3a), the hardware interrupt mask corresponding to expansion port C on an ASIC9 is mask +A9MsSlave and the interrupt number is HwIrq2Revector. On an Workabout, the masks for expansion + + +Revision 1.00 Page 65 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +ports A, B and C are A9MExpIntA, A9MExpIntB and A9MSlave respectively. The corresponding +interrupt numbers are HwIrq4Revector, HwIrq5Revector and HwIrq2Revector. This conditional +compilation code in A4EXIF.LDD outlined here is worthy of some study because it encapsulates all +the information regarding masks and SIBO hardware channels required by the prospective developer +interested in constructing a multi-platform Psion peripheral and driver. + + +Mandatory LDD Functions + + +The eight mandatory LDD functions are the Install, Remove, Hold, Resume, Reset, Units, Open and +Strategy and they are all discussed in the context of the example device driver A4EXIF.LDD below. + + +A4Exifinstall +IN: No values are passed to the install vector. +OUT: If successful return with carry clear. +If installation unsuccessful, return with the carry flag set and error number in the +AL register. + + +PRESERVE: SS, SP and BP + + +The install vector is called by the operating system when the device driver is loaded in order to +initialise any internal variables. It should not be called directly by an application process but invoked +indirectly by a 'p_loadldd("A4EXIF.LDD")' call. Typically at this stage the various open channel +flags would be initialised to zero but in the case of the A4EXIF.LDD, this has already been done in +the appropriate A4ExifStatusEnt struc headers. As a result, the install vector merely clears the carry +flag and returns. + + +A4ExifRemove +IN: No values are passed to the remove vector +OUT: If successful return with carry clear. + + +If installation unsuccessful, return with carry set and error number in the AL +register. +PRESERVE: SS, SP and BP + + +The remove vector is called by the operating system whenever the device driver is requested to be +unloaded which is usually indirectly as the result of a call to 'p_devdel ("LED", E_LDD)'. ROM- +resident drivers cannot be deleted so any attempt to invoke this vector on them will result in an error +being returned. The code for the remove vector checks to see that all the device driver channels are +closed and returns carry clear if this is the case. In the case of A4EXIF.LDD, a closed channel will +hold a zero in its corresponding StatusEnt open channel flag. If any of the open channel flags is non- +zero then the carry flag is set before returning indicating that an attempt has been made to unload a +device driver that still holds at least one open channel. In the case of A4EXIF.LDD, the +numberofchannels flag is used as a loop counter for the different hardware channel possibilities in a +similar manner to the corresponding code in the open vector. + + +A4ExifHold + +IN: AH register holds one of the following values: +DevHoldNormal, DevHoldPowerDown Or DevHoldPowerFail + +OUT: None + + +PRESERVE: SS, SP and BP + +The hold vector is called by the operating system whenever the device driver is requested to be held. +This can occur as a result of three conditions which result in the three different possibilities for the +value held in AH: + +1. Device memory segments about to be moved. AH holds DevHoldNormal. + + +Revision 1.00 Page 66 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +2. Machine about to switch off due to power-save time-out or the off switch being pressed. AH holds +DevHoldPowerDown. + +3. Machine about to switch off due to power source being removed or the batteries failing. AH holds +DevHoldPowerFail. + +The hold vector code must be able to conduct a rapid shut down of the device driver because in the +case of DevHoldPowerFail, the driver may only have a couple of ms before internal voltages fall to an +unworkable level. The EPOC OS automatically handles the three cases highlighted above but in +Series 3a machines and the Workabout, in addition to these there is another situation that requires the +invocation of the hold vector, namely the opening/closing of the SSD pack doors on an S3a or +Workabout. This is an action which can only be detected by means of software polling which requires +the setting up of the ROM-resident "TcK:" device driver so that the door status can be checked each +system tick (i.e. 32 times a second). The section on A4ExifTickInt provides a more detailed outline of +the TCK interrupt code required to handle pack door opening and closing. It is this latter routine that +polls for the open or closed status of the host machine doors, setting the global HoldFlag accordingly. +The Hold vector code thus includes a check on the status of the HoldFlag and is generally optimised +to be as efficient as possible. An outline of the structure of A4ExifHold presented below. It follows +the pattern for a typical device driver: + + +e Check the state of the global HoldFlag. + +e If the flag is non-zero, then the driver is already held and the function returns without taking +any further action. + +e = If the HoldFlag is zero, then the function checks the status of all the channels that the driver +is permitted to open. If any of these channels have their open channel flags cleared, it is not +necessary to do anything as part of the process of holding the channel. Only in the case when +the flags are set is the 'stopChannelRunning’ function invoked. As with the similar loop in +the Reset vector, the global numberofchannels is used as the loop counter as each of the +possible channels has to be checked. + + +A4ExifResume +IN: None +OUT: None + + +PRESERVE: SS, SP and BP + + +The resume vector is called by the operating system to restart a held device driver. Resume will be +called after a hold caused by any of the four possibilities indicated above in the section on A4ExifHold +but it should be noted that in some cases, ASIC4 will only be switched on after the call to resume. +The device driver is expected to recover from the previous hold and resume any suspended I/O except +in the case of power failure where the resume vector ought to power up the peripheral and put it into a +known state indicating to the user that data may have been lost. The resume vector will also have to +handle the reinstallation of any interrupt service routines by checking the status of the open channel +flag. + + +e Check the state of the global HoldFlag. + +e If the flag is zero, then the driver has already resumed so return without further action. + +e If the flag is non-zero, then check the door status of the host machine with a call to the OS +HwGetSsdData service. If the doors are open, then set HoldFlag to 2 to signal this position +to the driver. If the doors are closed, then numberofchannels is used as a loop counter while +the open channel flags of each of the permissible channels for the host hardware are checked. +Only if these flags are set is the 'start TheChannelRunning’ function invoked. + + +A4ExifReset +IN: BX holds the device driver device handle +CX holds user specified channel identification data. In this case, holds the address +of the status struc identifying the open channel to be reset. +OUT: None + + +Revision 1.00 Page 67 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +PRESERVE: SS, SP and BP + + +The reset vector enables a device driver to reset itself when the application which owns the device +driver terminates abnormally before closing one or more open channels on that driver. The vector is +only invoked by the operating system if it has been primed by means of a call to the ToRequestReset +operating system service in the open vector. Such a call must be balanced by a corresponding call to +IoRequestResetCancel in the close function code of the strategy vector. Registers BX and CX are +required to be set up by the user prior to invocation of either of these services. BX should contain the +device driver handle which is passed through DX in the open vector. CX should hold any suitable +open channel identification data that can be accessed in the driver's internal data space (i.e. through +CS:DI). In the case of A4EXIF.LDD, this information is the address of the channel StatusEnt +structure. If a device driver is only capable of opening one channel, then it is irrelevant what CX +holds. A reset should only be outstanding while some process has a channel open on the device +driver. The format of A4ExifReset is similar to that of a typical reset vector and can be summarised +as follows: + + +e Move the address of the channel status Ent from CX into DI. + +e Check the value of the corresponding cs:[di].A4ExifChannelOpen flag. + +e If channel is not open to reset, then return from the vector otherwise call +"StopTheChannelRunning’ and use HwFreeChannel to release the SIBO serial channel. Set +the ChannelOpen flag to zero. + + +A4ExifUnits +IN: None +OUT: AX holds the number of channels supported. + + +PRESERVE: SS, SP and BP + + +The A4ExifUnits function is called by the operating system when the device driver is requested to +report the number of units (or channels) that it can support. This is primarily useful for purposes of +information. + + +A4ExifOpen + + +IN: DX contains the device handle of the device driver +SL is a pointer to an OpenEnt struc +BP is a pointer to an IntEnt struc +DS, ES point to the application process's data segment +OUT: If successful return with carry clear and the address of the open channel in BX. +i.e. BX holds the address of an A4ExifEnt struc which contains various fields of +information concerning the open channel. +If installation unsuccessful, return with carry set and error number in the AL +register. +PRESERVE: DS, ES, SS, SP, BP and DX + + +The open vector is called by the operating system when a channel to the device driver is required to be +opened. The device handle, which is passed through DX, is used by the operating system to route any +I/O requests on the opened channel to the correct device driver. An LDD must place this handle in +the ChanLibHandle field of the ChanEnt struc of the open channel structure allocated within the +application's data segment. In the case of A4EXIF.LDD, this structure is the A4ExifEnt struc +described in the Appendix to this document. The open vector of a device driver runs in the context of +the process that has called p_open to open a serial port on that device driver. + + +The OpenEnt struc consists of three fields , OpenNamePtr, OpenMode and OpenChan. The +OpenNamefPtr points to the character immediately following the device name as passed in the +p_open call. For instance, in the case of A4EXIF.LDD, the OpenNamePtr would point to the colon +after LED in the name "LED:". The OpenMode field contains the mode for opening the device driver + + +Revision 1.00 Page 68 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +which is not used in this example. The OpenChan field holds the I/O channel handle of the device +that the driver is required to 'attach' to. Attached drivers add functionality to, or replace, a service +provided by an underlying device driver. The IntEnt struc pointed to by BP can be used to reload the +various segment registers if their contents have been altered. The A4ExifEnt struc requires further +elaboration. It consists of four fields: A4Exiflo, A4ExifHandlerPtr, A4ExifStatusPtr and +A4ExifA1Ptr. A4ExifHandlerPtr contains a handle to the driver's WaitHandler, A4ExifHandler. +This is the routine required to handle the completion of asynchronous I/O requests and is described in +more detail later on in this chapter. Of the remaining fields, A4ExifStatusPtr holds the location of the +completion status word for I/O requests and A4ExifA1Ptr is a user-defined parameter. These two +values are passed to the strategy vector through the RqEnt structure. A4Exiflo is itself a ChanEnt +struc with sub fields ChanSignature, ChanNext and ChanLibHandle. After initialisation of this +structure, [bx]. A4Exiflo.ChanSignature must hold 'TochanSignature’ and +[bx].A4Exiflo.ChanLibHandle holds the handle to the device driver (stored in DX). Both of these +values are again required by the strategy vector. The [bx].A4Exiflo.ChanNext field is used by +attached drivers and is set to 0 for root drivers like A4EXIF.LDD. + + +The code in an open vector follows a similar pattern in many LDDs and is presented in outline form +below: + + +e Determine the channel to be opened using the pointer to the device name held in +[si]. OpenNamePtr. + +e If OK, disable interrupts and invoke the OS HwGet Channel call. + +e If OK, then set A4ExifChannelOpen flag to non-zero. + +e In order to poll for door-opening and closing, it is necessary to open a "TcK:" channel at this +stage and initialise it by means of using the OS IowithWait service to call the TickInt vector +on each system tick. + +e Re-enable interrupts and set up the calling process id using the ProcId service. + +e Check for the presence of the required hardware. If present return with carry clear. + +e Allocate space in calling process' heap (i.e. the application data space) to contain the I/O +channel control block (an A4ExifEnt struc in the case of A4AEXIF.LDD) and set its base +address to BX (thus BX holds the address of the open channel control block). + +e If OK, install the device driver Wait Handler using the IoAddHandler system service. A +Wait Handler is required only if there are any asynchronous I/O requests to be handled. + +e If OK, initialise the fields inside the I/O channel control block that were outlined above. + +e Invoke IoRequestReset system service to handle unexpected termination of main program +by invoking the driver's Reset vector. + +e Before leaving the Open vector, if the call succeeded, BX must hold the open channel control + + +block handle. +A4ExifStrategy +IN: BX holds the allocated channel control block initialised in the open vector + + +DX contains device handle of the device driver in the case of an LDD + +SL is pointer to RqEnt struc + +BP is pointer to IntEnt struc + +DS, ES point to data segment of application making the I/O function request + + +OUT: If successful return with carry clear. Furthermore, in this case, if the strategy +vector is meant to complete the I/O request (as is the case with IoClose for +instance) then the completion status should be written back to RqStatusPtr location +and the I/O semaphore signalled by calling IoSignal. If the I/O request is not completed +by the strategy vector (as is the case with the asynchronous functions IoFuncRead +and IoFuncWrite) then PendingErr should be written back to the location pointed to by + + +RqStatusPtr and the I/O semaphore should not be signalled. + +If installation unsuccessful, return with carry set and error number in the AL +register. +PRESERVE: DS, ES, SS, SP and BP + + +Revision 1.00 Page 69 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +When an application makes a I/O request on the opened device driver channel, the request is routed +to this vector by the operating system. A device driver defines the set of strategy functions that it +supports such as IoFuncSet, IoFuncSense, IoFuncWrite and IoFuncClose. The functions of a +device driver are usually dependent on its purpose and there is no requirement to support any +particular function. The ordering of these functions in the strategy vector table is defined in p_file.h +and presented in A4EXIF.ASM. + + +The SI register contains a pointer to an RqEnt struc which consists of four fields: RqFunction, +RqStatusPtr, RgA1Ptr and RqA2Ptr. RqFunction contains the function number passed to the I/O +request by the application. In the device driver strategy vector code, the value held in RqFunction is +compared against the supported function numbers held in ToFuncClose, IoFuncRead etc. If the +function number is not one of those supported then a call to IoRoot is necessary in the case of a root +device driver such as A4EXIF.LDD. toRoot chains the I/O request through to the operating system +which runs some default code to handle it. RqStatusPtr is a pointer to a memory location in the +application data space which holds the value of the I/O request's completion status word. While a +request is outstanding, this value is set to PendingErr and only when it completes does a completion +code get written to this location. I/O requests can complete within the strategy vector or later after an +interrupt. Often as is the case with A4EXIF.LDD, only a single request of any one kind can be +outstanding at any time otherwise the application is panicked. RqA1Ptr and RqA2Ptr hold the values +of two parameters that are passed to the IoAsynchronous EPOC service. Each synchronous strategy +function has a similar pattern with explicit I/O being conducted whilst interrupts are disabled and a +completed request being signalled with an OS ToSignal call prior to exit from the function. This call +signals to the OS the completion of the particular I/O request entailed by the function call. The +situation with regard to the one asynchronous strategy function is somewhat more complicated and is +dealt with in greater detail in a later section. + + +The structure of the strategy vector of A4EXIF.ASM is outlined below: + + +e Determine the strategy function number using [si].RqFunction and compare with the below: + +e JIOFUNCREAD: Asynchronous read of latches U4 and U3. Panic if [bx].A4ExifStatusPtr != +0. Update [bx].A4ExifA1Ptr and [bx].A4ExifStatusPtr with [si].RqA1Ptr and +[si].RqStatusPtr respectively as the locations to be accessed on receipt of interrupt. Move +PendingErr into the location pointed to by [bx].A4ExifStatusPtr to signal that the request is +awaiting completion. Allow handler to be enabled through the IoEnableHandler OS call +and exit without signalling completion of the request. + +e IOFUNCWRITE: Identical behaviour to that of IoFUNCSET which it calls. + +e TIOFUNCCANCEL: Used to cancel any pending asynchronous reads. This involves +disabling the wait handler, consuming any stray signal from the interrupt routine by means of +an OS IoWaitForSignal call and then storing cancelErr in the channel I/O request status +word. + +e IOFUNCCLOSE: Close down the TCK channel and remove handler. Disable interrupts +and HwFreeChannel setting A4ExifPid to 0 before re-enabling interrupts. Invoke +IoRequestResetCancel system service and HeapFreeCell. Signal completion of I/O +request by calling IoSignal system service. + +e IOFUNCSENSE: Reads the status and LED bytes from latches U4 and U3 respectively +storing the results at the addresses pointed to by RgA1Ptr and RqA2Ptr. + +e IOFUNCSET: Sets latch U5 to contain the value pointed to by the sole argument in the +call to P_FSENSE. + +e If not supported then call IoRoot system service. + + +The Non-Mandatory LDD Functions + + +The eight functions described above must be supported by all device driver. Typical Psion LDDs +employ at least two other LDD functions. The first of these is a pseudo-interrupt routine which is +invoked by the OS on each system tick. In A4EXIF.LDD, this function is represented by +A4ExifTickInt and an outline of its purpose was presented earlier in the discussion on holding and + + +Revision 1.00 Page 70 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +resuming device drivers. As was indicated then, the minimum functionality required by this routine +is to poll the status of the host machine doors and if appropriate call the driver's Hold and Resume +vectors. If in addition the LDD is intended to service any asynchronous I/O requests, a wait handler +and common interrupt service routine are required. With A4EXIF.LDD, these two additional +functions are represented by A4ExifHandler and ComInt respectively. The former function +constitutes the second of the additional LDD functions as can be seen by examining the LibEnt +structure for A4EXIF.LDD. The latter function is set up so that it replaces the default interrupt +service routine code invoked by the OS on the receipt of hardware interrupts on the peripheral's SIBO +channels. A4ExifHandler is invoked by the OS every time the I/O semaphore of the process that +opened the channel is signalled with through an IoSignalByPidNoResched call indicating that an +interrupt has been received and an outstanding I/O request has completed. The function of the wait +handler is to deal with I/O semaphore signalling and to update the appropriate open channel control +block field variables. The common interrupt service routine code in ComInt cannot do this because it +is not permitted to access the application data space. This in turn is because the routine runs in the +context of the process which was running when the interrupt occurred. A4ExifTickInt, the wait +handler and the common interrupt service routine for A4EXIF.LDD as well further details as to how +the latter two interact to handle asynchronous I/O requests are described below. + + +A4ExifTicklint + + +As was explained earlier in discussing the A4ExifHold vector, it is necessary to utilise the "TcK:" +system tick device driver in order to handle the particular case of invoking a hold on A4EXIF.LDD +when the host machine SSD pack doors are opened. Such an action automatically causes power to be +removed from any peripherals. The TCK driver is opened via an OS Toopen call in the A4ExifOpen +vector which returns with carry clear and a non-zero handle in AX if successful. In this case, the +IoWithWait function is called to request an synchronous I/O service from the TCK driver. Prior to +this call, the service number requested is held in AL and the I/O handle procured from the previous +call to ToOpen is loaded into BX. The interrupt number of the tick poll routine, A4ExifTickInt, is +loaded into CX so that as its parent driver is invoked on each system tick, the OS enters this vector. +The reason the TickInt routine is required in A4EXIF.LDD is solely to handle the problem of +recognising a sudden removal of power from the host machine. The OS has no way of testing for this +condition other than polling its global 'Doorstatus' variable every system tick and taking the +requisite course of action. As such, the outline of the code for the tick poll routine which is required +in all Psion LDDs can be presented below. This outline should be carefully compared with the +structure of the Hold and Resume vectors shown earlier in order to see how they interact: + + +e Check the current status of doors which is held in SI. +e¢ If DoorlsOpen then if global HoldFlag is zero, force a call to A4ExifHold, set HoldFlag to 2 +and return far +else do a far ret +e = Else if DoorIsClosed then +if global HoldFlag is 2, force a call to A4ExifResume and return far +else do a far ret + + +It should be emphasised that A4ExifTickInt is only a pseudo interrupt service routine in that it does +not preserve the status of the registers which is something that the device driver writer must +undertake to ensure is done explicitly. + + +The handling of synchronous and asynchronous I/O + + +The provision of synchronous and asynchronous I/O services are an important aspect of writing any +device driver. In the case of Psion drivers, all such services are the provided through the Strategy +vector which is typically preceded by a Strategy Vector Table listing the complete set of I/O services +that can be invoked on the driver. The strategy vector table for A4EXIF.LDD is presented below to +provide an indication as to the kind of service routines that can be written: + + +StrategyVectorTable label word + + +Revision 1.00 Page 71 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +dw offset A4ExifDefault 7StrategyPanic + +dw offset A4ExifRead ;StrategyRead (function define is P_FREAD) + +dw offset A4ExifWrite ;StrategyWrite (function define is P_FWRITE) +dw offset A4ExifClose ;StrategyClose (function define is P_FCLOSE) +dw offset A4ExifCancel ;StrategyCancel (function define is P_FCANCEL) + +dw offset A4ExifDefault 7StrategyAttach + +dw offset A4ExifDefault 7 StrategyDetach + +dw offset A4ExifSet ;StrategySet (function define is P_FSET) + +dw offset A4ExifSense ;StrategySense (function define is P_FSENSE) + + +Both synchronous and asynchronous I/O requests can be made on the driver through means of the +PLIB 'p_iow (pcb, , &A1, &A2)' call where pcb is the open channel handle, is one of +the above function defines and Al and A2 are two optional parameters required for the servicing of +the request. The routing of an I/O request to the correct service code is done by the common code at +the head of the strategy vector. Each time this vector is entered, BX holds the address of the open +channel control block, DX the device handle of the device driver and SI a pointer to the strategy +RqEnt struc used by the OS to follow the course of the I/O request. Using this information, it is +possible to access all the relevant flags in the channel StatusEnt by moving [bx].A4ExifStatusEntPtr +into DI. This leaves us with the open channel control block in DS:BX and the channel StatusEnt in +CS:DI. + + +Armed with the above information, it is possible to outline the general pattern of both synchronous +and asynchronous I/O requests at an OS level. The case of synchronous requests is particularly +straightforward since the servicing of the request can be completed entirely within the relevant +strategy vector table function. It should be emphasised that in the outline presented below, disabling +and re-enabling of interrupts only actually has to be done around any I/O. + + +SYNCHRONOUS I/O REQUEST STRATEGY VECTOR TABLE FUNCTION + + +pushf +cli ;Disable interrupts +< request service code > ;Relevant synchr. I/O processing + + +ExitWithCompletionStatusZero: +< set I/O request status word to zero > + + +IoSignal ;Signals completion of I/O to OS +XOr ax, ax + +onl ol ;Tells OS that strategy exited OK +popf ;Re-enable interrupts + +ret + + +ProcEnd noret + + +Note that in the above outline, the single ToSignal call is made after completion of the I/O request in +order to signal this fact to the OS. The situation is somewhat more complicated in the case of an +asynchronous request because the I/O request strategy vector table function has to interact with both a +wait handler function and an interrupt service routine. Of the I/O request services outlined above for +A4EXIF.LDD, only one, namely A4ExifRead, is asynchronous and it serves as a good illustration of +the nature of programming for asynchroneity. The steps taken in the A4ExifRead vector are outlined +below: + + +e = Set the ChannelReadCompleted flag to 0 (stored in cs:[di]. A4ExifChanReadCompleted) +e If the address of the I/O request status word is non-zero then panic (i.e. there is an +outstanding read request) + +e Update the open channel control block variables using the RqEnt struc + +e Load I/O request status word with PendingErr + +e Enable the wait handler by using the To—EnableHandler OS service +The read request is now in a pending state waiting for completion via receipt of a hardware interrupt. +When such an interrupt is received, the OS switches into the appropriately configured common +interrupt routine ComInt. Here, the channelReadCompleted flag is set to indicate to the handler that +the read request has completed. An IoSignalByPidNoReSched OS service call is also made to +indicate to the OS that an as yet unspecified I/O request has terminated. This signal is consumed by +the OS which means that at this stage, an IoSignal for completion of the original asynchronous +request has yet to be made. The interrupt service routine exits after sensing the status and LED byte +values from the ASIC4 Example Interface Board and loading the appropriate response bytes into the +relevant locations in the device driver code segment. More details as to the functionality of the +interrupt service routine are provided in the section on interrupts. The OS now invokes all the +currently active wait handlers in order to determine which application is responsible for consuming + + +Revision 1.00 Page 72 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +the completed read. The wait handler code includes the all-important IoSignal call that indicates to +the OS that the original asynchronous read request has finally been accounted for. Receipt of this +signal by the OS constitutes completion of the request. The outline code for the A4EXIF.LDD wait +handler A4ExifHandler is outlined in the next section. + + +A4ExifHandler + + +A WaitHandler is a special function of the LDD which is nominated to be called by the operating +system every time the I/O semaphore of the process that opened the channel is signalled. It will only +actually be called if the application is already waiting for an outstanding I/O request to complete (1.e. +while the application is hung in p_iowait). The handler function is the means by which hardware +interrupts can be filtered through to the process which opened the I/O channel since it permits the +rescheduling of processes. + + +The WaitHandler is invoked in the open vector by using the IoAddHandler system service. When an +application makes an I/O request, the I/O semaphore is signalled and the operating system calls the +Wait Handler function while the application is waiting for the request to complete. The wait handler +returns with CLC if no outstanding request has completed. Otherwise the wait handler returns with +STC and zero in AL. The wait handler can include within it synchronous I/O requests to cancel or +use up signals but it is not entered recursively (i.e. re-enterently) by the operating system. A wait +handler is best viewed as a necessary requirement in dealing with the I/O semaphore signalling which +cannot entirely be addressed in the appropriate interrupt service routine because the latter is not able +to access the open channel's control block. + + +Interrupts and Interrupt Service Routines + + +The SIBO architecture allows for eight separate hardware interrupt sources. The EPOC operating +system provides a GenSetRevector service to enable a device driver to install an interrupt service +routine for any of these eight interrupt sources. When an interrupt occurs, the operating system +preserves the state of all the registers before calling the appropriately-installed interrupt service +routine. As a result of this, the interrupt service routine is free to employ any register it sees fit to use. +A few important points ought to be made concerning the code within an interrupt service routine: + + +e On an 8086 processor, interrupts cannot be nested so their is no requirement to disable +interrupts whilst inside the interrupt service routine. + +e Interrupt service routines should operate as fast as possible. In general, operating system +service routines are tuned to be of less than Ims duration. + +e Interrupt service routines run in the context of the process that was running at the time of the +interrupt and should access only the device driver data space which, as with A4EXIF.LDD, +typically resides in its own CS space. + +e Interrupt service routines should not cause a process rescheduling. To indicate that an event +has occurred to the interrupted process, the ToSignalByPidNoResched system service +should be called. If a call is made to this service, the interrupt service routine should exit +with CLC otherwise it returns with STC. + + +The interrupt routines called require knowledge as to the particular hardware SIBO channel being +used by the driver at the time an interrupt occurs. This information is passed through to the +GenSetRevector function in StartInterrupts by loading the address of the appropriate Int Vec routine +from the A4ExifChannelIntVec field of the channel StatusEnt struc. As a result, when an interrupt +occurs, the currently loaded IntVec routine is invoked. All the Intvec routines reload DI with the +appropriate address of the channel StatusEnt in the device driver code segment before falling through +to the common interrupt routine service code held in ComInt. + + +Comint + + +Revision 1.00 Page 73 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The common interrupt service routine code resides in the ComInt vector. The structure of this code is +presented below. It should be emphasised that no data in the application data space and hence in the +open channel control block can be accessed from ComInt. This explains why it is necessary for the +OS to invoke a wait handler to clean up after the interrupt service routine code for a particular +asynchronous I/O request has been run. + + +e Check the value held in the chanReadCompleted flag + +e If this value is 2 then we do not have an asynchronous read completed but rather the +interrupt line has been pulled low outside of an asynchronous I/O request. + +e If this value is 1 then we have an asynchronous I/O request completed and so +IoSignalByPidNoResched must be invoked to signal to the OS that a read has completed. + +e In both cases, sense the status and LED bytes from the Example Interface hardware and load +these values in the device driver's code segment A4ExifStatusEnt struc. + +e There are four possibilities of status byte corresponding to the four combinations offered by +the two input switches, S1 and S2. These are used to output one of four separate LED bytes +to the LEDs. + +e Awrite to AlNonSpecificEoi register (or A9BNonSpecificEoiW in the case of an ASIC9 +machine) must be done prior to exiting to let the OS know that the installed interrupt service +routine has terminated. + + +Other important local device driver functions + + +The functions presented in this section are local to A4EXIF.LDD and perform various important tasks +relating to the peripheral hardware such as groping the hardware and setting interrupts running. +Since these tasks have to be undertaken by most device drivers, the relevant functions are outlined in +greater detail. + + +A4ExifCheckHardwarePresent + + +Every Psion device driver has a characteristic 'CheckHardwarePresent’ or 'GropeHardware" function +that usually involves checking for the presence of the required peripheral device by means of +comparing a couple of ASIC4 identification bytes returned by the peripheral in response to a SIBO +serial protocol identification message with the expected answers. The specific value of the InfoByte is +unimportant as long asa "test al, al" call is made which will always return a non-zero answer if +ASIC4 is present. In that case, the extended info byte should be tested for against what is expected +from address lines A23-A27. + + +Psion Workabout/HC machines have three physical serial links and two of these are accessed via the +SSD slots. The third link corresponds to the serial expansion port. In order for a driver to talk to a +peripheral connected to this port, it must specifically select this serial link. In order to prevent +multiple access to a single peripheral, it is necessary in the first instance to check whether the serial +channel is free or not. A call to the operating system function HwGet Channel with the appropriate +interrupt mask in AL returns with CLC if the channel was captured successfully. Logically this call +should be made in the Open vector but since it can only sensibly be made after the hardware has been +successfully located it can be placed at the end of the GropeHardware function. A corresponding call +to HwFreeChannel must be made when closing the channel. To actually select a channel prior to +communication along it, a call to HwSelectChannel Is necessary. + + +A4ExifStartChannelRunning + + +This function is called at the end of the Open vector to set the ASIC4 Example Interface hardware +running. It can also be invoked by the Hold vector. The function first checks the status of the global +StatusEnt ChannelRunning flag. If this flag is clear, CheckHardware is called to determine whether +the hardware is still connected and then StartInterrupts is called before the channelRunning flag is + + +Revision 1.00 Page 74 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +set to indicate that the channel hardware has been started. The function returns with CLC on +successful completion or with STC if no hardware was located. + + +A4ExifStopChannelRunning + + +This function simply clears the channelRunning flag if set and calls StopInterrupts unless the +channel already has its ChannelRunning flag clear. The StopChannelRunning function will be called +by Strategy vector when trying to close a channel and can also be called by the Resume vector. + + +A4ExifStartinterrupts + + +StartInterrupts is called whenever a call is made to StartChannelRunning. At the heart of the +function is a call to the OS GenSetRevector function which is used to install a specified interrupt +service routine in the place of the default routine held in the interrupt vector table. GenSetRevector +is called with the interrupt vector number of the service to be replaced in AX and the offset and code +segment of the replacement interrupt vector service in BX and CX respectively. BX is loaded from +the ChannelIntVec field of the channel StatusEnt which holds the name of the specific interrupt +service routine code (i.e. IntVecO, IntVec1 etc.). The latter functions set up the appropriate channel- +specific variables before falling through to the common ComInt routine. The channel interrupt mask +which is machine and channel dependent is written to the appropriate register on the host ASIC. In +the case of ASIC9, this register will be A9BInterruptMaskRW. For ASIC1 it will be +AlInterruptMask. + + +A4ExifStopInterrupts + + +StopInterrupts reinstalls the original interrupt service routine by invoking the GenResetRevector OS +system service and signalling the interrupt mask to the corresponding host ASIC register. + + +Structures and Include files + + +Epocdef.inc and device driver strucs + + +Epocdef.inc is an important header file that contains the definitions of various strucs extensively used +in the construction of device drivers. It also contains the definitions of all the OS error values such as +DeviceErr and NameErr that are used in A4EXIF.LDD to communicate an error to the application +via AX. Listed below and overleaf are the key strucs defined in Epocdef.inc that were used in the +coding of A4EXIF.LDD. + + +LibEnt struc Start of device driver +LibSignature dw ? + +LibInfo dw 2 + +LibCount dw ? + +LibBase dw ? + +LibEnt ends + + +OpenEnt struc Pointed to by SI in Open vector +OpenNamePtr dw ? + +OpenMode dw ? + +OpenChan dw ? + +OpenEnt ends + +ChanEnt struc Used in open channel control block +ChanSignature dw 2 + +ChanNext dw ? + +ChanLibHandle dw ? + +ChanEnt ends + + +IntEnt struc Pointed to by BP in Open and Strategy vectors +IntFrame dw ? + +IntBP dw ? + +IntES dw 2 + +IntDS dw ? + + +Revision 1.00 Page 75 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +IntPC dw ? +IntCs dw 2 +IntFLAGS dw ? + + +IntEnt struc ends + + +RqEnt struc Pointed to by SI in strategy vector +RqFunction dw 2 +RqA1Ptr dw ? +RqA2Ptr dw ? +RqStatusPtr dw ? + + +RqEnt struc ends + + +A4EXIF channel strucs + + +These are defined at the start of the A4EXIF.LDD code segment. The open channel control block is +held in a structure of type A4ExifEnt and is allocated space from the heap of the process invoking the +device driver's open vector. As such, it cannot be accessed from the Hold, Resume and Reset vectors +or from the interrupt service routine, ComInt. The channel StatusEnt holds various key channel +related flags. Each hardware channel has its own StatusEnt which is instantiated in a header in the +device driver code segment following the LibEnt structure. This header block is usually held in +CS:DI which is how the StatusEnt variables are accessed. The structure of both A4EXIF channel +strucs is shown below: + + +A4ExifEnt struc OPEN CHANNEL CONTROL BLOCK +A4xifIo ChanEnt<> + +A4ExifHandlerPtr dw ? Pointer to the Wait Handler +A4ExifStatus dw ? Address of I/O request status word +A4ExifAlPtr dw ? Pointer to first argument + +A4ExifA2Ptr dw 2. Pointer to second argument +A4ExifStatusEntPtr dw ? Pointer to channel's StatusEnt +A4ExifTickHandle dw ? Handle to the TCK device channel + + +A4ExifEnt ends + + +A4ExifStatusEnt struc CHANNEL STATUS_ENT + +A4ExifChannelPid db ? Process id of process holding +channel open + +A4ExifChannelOpen db 2 Is the channel open or not? +A4ExifChannelRunning db ? Is the channel running? +A4ExifChanReadCompleted db ? Flag used to indicate to handler +when + +A4ExifChanneliIntMask db ? Contains the HW channel interrupt mask +A4ExifChannelIntNum db ? Holds no. of interrupt vector to be +replaced + +A4ExifChannelSelect db 2 SIBO channel select flag +A4ExifChannelDummy db 2 Spare + +A4ExifChanneliIntVec dw ? Holds replacement int. vector routine +name + + +A4ExifStatusEnt ends + + +Ossibo.inc and Ospack.inc + + +Ossibo.inc is an important header file that contains the defines for all the ASIC2 and ASIC9 register +addresses. Ospack.inc contains similar information but for ASIC4. + + +Revision 1.00 Page 76 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +12. AN EXAMPLE DEVICE DRIVER FOR ASIC5: +SYS$AS5.PDD + + +Introduction + + +In this chapter, the functionality and code structure an example installable physical device driver, +SYS$AS5.PDD, is presented in some depth. Circuit details of the corresponding Psion peripheral for +this driver, the Psion 3-link, were outlined in chapter 8. SYS$AS5.PDD enables software written +using the Psion SDK to communicate with the 3-link peripheral through means of standard PLIB +calls such as ‘p_open' and 'p_write'. This peripheral incorporates an ASICS as the SIBO serial +protocol slave device. As explained earlier in chapter 7, ASICS has an on-board 16550 UART which +means that it can be used in conjunction with the standard serial LDD provided an appropriate PDD +is loaded. SYS$AS5 is a PDD intended for this purpose and its description in this chapter provides a +clear insight into the generalised structure and construction of physical device drivers for peripherals +based around the SIBO architecture. + + +The LDD-PDD interface + + +All Psion device drivers have a LibEnt structure at the head of their code segment which includes a +vector table defining the functionality of the driver. In the case of SYS$AS5, four vectors are defined. +These are: Install, Remove, Open and Strategy. The structure of the first three of these are fixed for +most device drivers but the fourth can be specified in any way. This fourth vector defines the LDD- +PDD interface and is constructed to allow the two drivers to best communicate with each other. In the +case of serial PDDs, the approach taken is modelled on the LDD strategy vector with the +corresponding strategy vector table and function numbers. This is a logical choice but it is important +to emphasise that the LDD-PDD interface is completely user-definable and that the approach +described in this chapter is optional. + + +The key feature of any LDD-PDD interface is that the LDD must have no explicit concept of +hardware. In the case of the serial LDD, for instance, it knows that it has a serial port that it can read +data bytes from or write data bytes to but it is ignorant of the explicit implementation of the hardware +at this port. That aspect is handled by the corresponding PDD which handles all the specifics of data +byte I/O. In the case of an application writing a buffer to the serial port by means of a +p_iow(P_FWRITE....) call, for instance, the LDD will first copy the data in the application's DS into +a local CS buffer. It will then call the PDD to indicate that it intends to start sending data bytes when +the PDD is ready to start receiving. When the PDD is ready to commence sending a byte out of the +serial port, it calls a function (TransmitByte) in the LDD. This function reads the next byte to be +transmitted from its local buffer and hands it to the PDD. The PDD duly transmits the byte and again +calls TransmitByte until all the bytes are completed. The LDD then sends a special 'NothingToSend' +signal to the PDD which indicates that transmission is finished. The LDD also sends an +IoSignalByPidNoResched which causes its wait handler to be invoked by the OS. In this way, the +IoSignal that signifies completion of the original write request is invoked by the LDD. Note that the +LDD has no concept of interrupts, merely of sending a byte at a time and registering completion or +otherwise of I/O requests. Futhermore, the PDD never takes the initiative from the LDD and merely +undertakes one function at a time before returning control back to the LDD. The LDD-PDD interface +is examined in greater depth later in this chapter when the structure of the PDD strategy vector is +presented. + + +Revision 1.00 Page 77 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Code Structure + + +Device Names and Loading SYS$AS5.PDD + + +SYS$AS5.PDD is loaded into the RAM of the host machine by means of the following PLIB call in +the application code: + + +p_loadldd("SYSS$AS5.PDD") ; + + +The name of a device driver is the mechanism by which an application can obtain a channel to that +device driver. LDDs all have three character names followed by a period, a further three characters +and acolon. The first three characters of a PDD name are the name of the LDD to which the PDD +belongs. The second set of three characters uniquely identify the PDD. The device name is required +to uniquely identify the LDD to the OS when attempting to open a channel on it. The SYS$AS5 PDD +belongs to the "TTY:" LDD. Its name as defined in its LibEnt structure is 'TTY.SR5'. Thus a +channel with its handle in pcb may be obtained on it at the application level by means of the +following call: + + +p_open (&pcb, "TTY.SR5:A",-1); + + +The qualifier after the colon indicates that the driver can support more than one channel. Channels +are allocated a single character sequentially from the character 'A' up to the character 'C'. The +number of channels that can be supported in this way is dependent upon the host hardware. Only one +expansion port can be opened on the S3a for instance whereas three are possible on the Workabout +and HC. EPOC uses the driver name in the p_open call to invoke the ToOpen system service which in +turn invokes the Open vector on the associated device driver. + + +The Single Code Segment and Data Storage + + +All data associated with a physical device driver must be stored in its code segment. Examples of +such data are the channel interrupt masks and numbers that have to be visible to all processes that +may be using SYS$AS5.PDD. + + +The overall structure of the code segment is typical of Psion physical device drivers. The segment +begins with a CodeSeg directive followed by the LibEnt structure which defines all the device driver +functions. Before entering the code for these functions, all global variables are declared in the +internal (CS) data space. Following the code for the LibEnt functions comes the code for all the local +driver functions, After these are the EndCodeSeg and end OsAs5PDD directives. + + +The Channel struct and A5Ent struct + + +At the head of the driver's assembler source file, SYS$AS5.ASM, various constants, compiler defines +and types are listed. It is here that templates are declared for the global structures that hold the key +driver variables. in the case of SYS$AS5, one main structure, the Sr5ChannelStruct, is employed to +hold the various important flags and masks that relate to the status of each separate channel on the +driver. This structure is termed the Channel struct and its fields are filled in during the course of +running the PDD install and open vectors. Whenever the serial LDD invokes one of the PDD +functions, the application must ensure that CS holds the address of the PDD's code segment which is +where the Channel struc resides. The channel's Channel struct is usually accessed through DI or BX +depending on preference. Its layout is presented later in this chapter along with other important +defines that were used in the construction of SYS$AS5.PDD. + + +SIBO hardware and conditional compilation + + +As indicated previously, the number of expansion channels supported by a host Psion machine is +dependent on the hardware. In the case of the S3a, only one SIBO channel can legitimately be +opened corresponding to expansion port A. With the HC and the Workabout, it is possible to open up +to three separate SIBO channels on ports A through to C. SYS$AS5.PDD is constructed to enable it +to run on any host Psion platform. In its internal data space, the various hardware options for the +SIBO channels, interrupt masks and interrupt numbers are coded in a large if statement thereby + + +Revision 1.00 Page 78 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +permitting conditional compilation of the driver for the required host hardware. The only change that +need be made in adapting it for use on another Psion machine is the alteration of the build flag at the +start of the code segment. This flag indicates to the compiler which SIBO machine flags as well as +other variables should be set. The conditional compilation table outlined here is worthy of some study +because it encapsulates all the information regarding masks and SIBO hardware channels required by +the prospective developer interested in constructing a multi-platform peripheral and accompanying +PDD. + + +The PDD Functions + + +OsAS5install +IN: Nothing +OUT: If successful, return with carry clear +If installation unsuccessful, return with the carry flag set and error number in the +AL register + + +PRESERVE: SS, SP, BP + + +The install vector is called by the parent LDD whenever the PDD is required to be loaded. It cannot +be called directly be an application only indirectly through the LDD in its Install vector. The install +vector is called in the context of the OS with DS and ES in an unknown state. Memory will not be +moved while in this function so the normal rules governing the use of ES and DS may be ignored. + + +OsAS5Remove + + +IN: Nothing +OUT: If successful, return with carry clear + +If installation unsuccessful, return with the carry flag set and error number in the +AL register + + +PRESERVE: SS, SP, BP + + +The remove vector is called by the parent LDD whenever the PDD is required to be unloaded. It +cannot be called directly by an application and only indirectly through the LDD in its Remove vector. +The remove vector is called in the context of the OS with DS and ES in an unknown state. Memory +will not be moved while in this function so the normal rules governing the use of ES and DS may be +ignored. + + +OsAS5Open +IN: SS:SI points to the OpenEnt structure +ES, DS point to the DS of the application process. +OUT: If successful, return with carry clear and control block in BX +If installation unsuccessful, return with the carry flag set and error number in the +AL register + + +PRESERVE: SS, SP, BP + + +The open vector is called by the parent LDD whenever a channel to the PDD is required to be opened. +It cannot be called directly by an application and is typically invoked in the higher level LDD Open +vector code by means of the DevOpenPpp OS system call. On invoking the open vector, SI points to +the OpenEnt structure which contains three fields, namely OpenNamePtr, OpenMode and OpenChan. +The OpenNamePtr points to the qualifier immediately following the device name in the call to +p_open. In the case of SYS$ASS5, for instance, the OpenNamePtr would point to the 'a' in the name +"TTY.SR5:A". This corresponds to an attempt to open the first hardware SIBO channel on the host +machine which if successful will leave the address of the ChanO Sr5ChannelStruct in BX. The PDD +open vector finally includes a call to the OS service HwGet Channel to obtain the requested SIBO +channel. + + +Revision 1.00 Page 79 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +The order of action undertaken by the parent serial LDD's open vector is generally fairly complicated +and includes various calls to the PDD strategy vector routines. The situation is outlined overleaf: + + +e Ensure that the LDD itself can be opened. + +e Call the PDD open vector using the OS DevOpenPDD OS call. + +e = If successful, call the OS service DevGet PDDAddress which returns the full segment:offset +address of the PDD's fourth strategy vector in BX:AX. These values are loaded into the +dword Channel struct field SerialPDDEntry. + +e Invoke the PDD strategy Open and SetHandlerCS functions to set up offsets and segments +respectively to locations in the LDD above. + +e Invoke strategy Set to initialise the transmission baud rate. + +e Invoke strategy Start to set-up and then enable interrupts + + +Once the DevGetPDDAddress service has been used to load the LDD's SerialPDDEntry field, it may +be used to load in the address of any of the PDD's strategy functions. The DevGetPDDAddress OS +call invoked in the LDD open vector must also be invoked in the LDD resume vector code since +memory may have been moved while the LDD was held. The PDD is ignorant of such activity since +the serial LDD is responsible for handling all holds and resumes. + + +OsAS5Strategy +IN: AX holds the vector number +ES, DS point to the DS of the application process. +OUT: If successful, return with carry clear and control block in BX +If installation unsuccessful, return with the carry flag set and error number in the +AL register + + +PRESERVE: SS, SP, BP + + +The strategy functions are invoked directly from the various serial LDD vectors to provide hardware- +specific services. For instance, in order to set up the baud rate, it is necessary to invoke strategy Set. +The strategy vector table for OsAS5Strategy is presented below and then the functionality of the +important component vectors is outlined: + + +AS5StrategyJumpTable label word + + +dw offset AS5Open ;Load Handler offsets + +dw offset AS5Close ;Close the channel + +dw offset AS5Start ;Start the channel + +dw offset AS5Stop ;Stop the channel + +dw offset AS5Set ;Set the channel status + +dw offset AS5Sense ,;Return channel status +dw offset AS5Control ;Drive the handshaking lines +dw offset ASS5Enquire ;Returns baud rate + +dw offset AS5Enable ;Begin sending output +dw offset ASS5SetHandlercCs ;Load Handler segments + + +Open and SetHandlerCS go together and are invoked from the LDD open and resume vector code. +Both are required to let the PDD know the address at which its LDD resides. The four full addresses +passed through to Open and SetHandlerCS are of the LDD's control block and the LDD StatusInt, +RecvInt and XmitInt vectors. Close is called in order to close an opened channel. Start and Stop are +used to enable/disable interrupts and are invoked from the LDD open, hold/resume and set vectors. +The order of action in the PDD Start vector is as follows: +e Initialise PDD variables +e Check H/W present +e Start the hardware running. In the case of SYS$ASS5, part of this process involves starting a +continuous clock from the host controller ASIC in order to trigger the UART clock on the 3- +link's ASICS. In addition to this clock, the RTS and DTR lines must be driven low. +e = Start interrupts. +The common interrupt service routine code resides in the PDD ComInt function. This code is patched +into the interrupt vector via the GenSetRevector system service. The interrupt mask contains bits to + + +Revision 1.00 Page 80 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +generate the following interrupts: Receive character, Ready to send next character and Modem line +change character. In SYS$ASS, all three interrupts are enabled in Start. It is important to realise +that after masking in these bits, a Ready to send next character interrupt is almost immediately +generated so the corresponding ComInt code must be able to handle this. + + +CheckHardwarePresent + + +This non-mandatory function is called from the Open vector and follows the lines of previously +discussed CheckHardwarePresent code. After checking for an ASICS at the end of the serial link, the +function returns with the carry flag clear if one is found. If a non-zero info byte is returned with an +Asic5Normalld, then various other IDs are tried (Asic4Id, Asic8Id, Asic5PackId) before returning +with the carry flag set. + + +CheckHardwarePresentFromStart + + +This is a non-mandatory function called only from the PDD Start vector. After checking that we have +an ASICS at the end of the SIBO channel, the function sets the S_PERIPHERALMODE bit of the +A5PortBMode register. This then puts ASICS into UART mode. + + +Comint + + +The common interrupt routine code is entered with DI holding the address of the appropriate channel +struct. ASICS's control register (A5CtrlReg) is read first to determine which interrupt has occurred. +The byte read from the register is compared against S_ MDINT (Modem lines interrupt), S_RXINT +(Receive character interrupt) and S_TXINT (Transmit interrupt). The code to handle each of these +cases is then entered prior to returning control back to the LDD via the Channel struct fields that were +filled by a previous LDD calls to the PDD strategy Open and SetHandlersCS vectors. The LDD has +no knowledge of interrupts and the purpose of ComInt is therefore to hide the hardware details of +handling interrupts from the LDD. Once the interrupt has been serviced, a write is made to +A9BNonSpecificEoiW in the case of ASIC9 or AlNonSpecificEoi for an ASIC1/ASIC2 based system +to indicate to the OS that the interrupt has been serviced. + + +Revision 1.00 Page 81 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +13. DEBUGGING AND TESTING DEVICE DRIVERS + + +Introduction + + +This chapter will detail the techniques that can be used by the developer to first debug and then test +device drivers. The emphasis will be on the software methods such as: +e¢ Good use of variables. e.g. Starting all the fields in the CS Channel Status structure with +CS. +e Debugging by eye. Even more important with regard to device drivers. +e Using SDBG. The pitfalls and benefits. Working your way around the strategy vector calls +with SDBG. +e Construction of C test harness programs. Catching all the error flags that can be returned by +device driver functions. +e The comprehensive memory check program mem.c. + + +Debugging Techniques + + +A Psion device driver is written in 8086 assembler as an asm file and built using the Borland Turbo +Assembler compiler. The subsequent debugging process centres around the construction of an +appropriate PLIB test harness. The purpose of a test harness is to check a number of the device driver +vectors to ensure that they do not return errors or cause panics. The majority of PLIB calls that would +be used in this context return a negative integer that is used to ascertain the cause of the problem in +the corresponding device driver vector. The code below, for instance, would be used to test the install, +open, strategy close and remove vectors of the A4EXIF LDD: + + +GLDEF_C VOID main(VOID) +{ + +VOID *serH; + +INT ret; + + +if ((ret=p_loadldd("A4EXIF.LDD") ) <0) +{ +p_printf ("Error %d on p_loadldd", ret); +p_getch () +p_exit (0) +} + + +else +p_printf ("Successfully loaded A4EXIF.LDD"); + +if ((ret=p_open(&serH, "LED:",-1) ) <0) +{ +p_printf ("Error %d on p_open", ret); +p_getch(); + + +x + + +else + + +p_printf ("Successfully opened LED: channel"); +p_close(serH) ; +p_printf ("Successfully closed LED: channel"); +} + +p_devdel ("LED",E_LDD) ; + +p_getch(); + +p_exit (0); + +} + + +Revision 1.00 Page 82 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +If as often happens at this stage, a bug in the device driver causes the test harness program to crash, it +is necessary to debug the driver code either by eye or using SDBG. Debugging by eye should always +be the first resort, however, whenever the bug can be readily pinned down to a particular vector. +Things to look out for include: + + +e ~=An unbalanced stack: Check that the number of 'pushes' equals the number of 'pops' in the +appropriate vector code. + +e Addressing the wrong location: Ensure that all the Channel status fields (stored in CS) are +offset using the correct register and that that register holds the right value. The following +code for instance requires DI to hold the address of the channel status struct prior to + + +invocation: +mov al, cs: [di].ChannelOpenFlag + + +e Consistency: With regard to the last point, it is important to be consistent if possible and try +and use the same register (i.e. DI) to hold the channel status structure. A different one +(usually BX) should also be used to hold the address of the open channel control block. + +e Trashing BX and DI: If these registers are used in the vector code for anything other than +addressing, check that their value is not being trashed by the operation. + + +Debugging using SDBG is an extension of debugging by eye. The SIBO debugger allows the +programmer to trace through the driver's source code instruction by instruction and observe the +contents of the CPU registers in the process. In this way it is possible to discover any discrepancies in +terms of the values stored in the various registers. Furthermore, tracing with SDBG will enable the +user to pinpoint the source of panics. The first objective of the device driver debugging process +should be to get the code outlined on the previous page to work OK. + + +Further Testing Strategies + + +Once installing, opening, closing and unloading are dealt with, a test harness can be expanded to +include p_iow or p_ioc calls which map onto the LDD's strategy vector. At this stage, SDBG is +particularly useful for testing purposes as breakpoints can be set and jumped to. In this way for any +p_ioc(serH, , &serStat, &Al,&A2) call, the contents of the status word, serStat, and the A1 +and a2 parameters can be tracked through the LDD's strategy vector. The value held by the status +word at the end of a particular strategy call is the value returned by the corresponding PLIB +p_iow/p_ioc call. Thus negative errors within the strategy code can be picked up by the test harness. +A good test harness should be able to catch all the possible errors and at the least invoke p_printf to +let the user know when one of them is returned. The file p_file.h contains a list of all the current +return error values and the corresponding PLIB level error name. The entry for PendingErr, for +instance is as follows: + + +#define PendingErr (-46) +#define E_FILE_PENDING PendingErr + + +In order to induce the return of these error values it is necessary to extend the basic test harness +outline to allow the user to undertake various pathological actions. For instance, the harness may +include code that tries to open a channel twice which should result in InUseErr being invoked. By +such means it is possible to ensure that a driver is not only operating as it should in normal +circumstances but returning the correct error value when relevant. + + +Memory Testing + + +The final process that should be undertaken to fully test a device driver consists of the construction of +an appropriate memory test harness. Three functions are presented on the next two pages which +provide the core of such a comprehensive memory test program. The first function, CheckMemory, +uses the PLIB routines p_allspce and p_sgfree to print out the current free bytes on the heap and the +number of free segments in the host RAM. This function can be invoked after installing, opening, +closing or removing a device driver to ensure that memory is not going to ‘alloc heaven’. The +GobbleMemory function is first used to determine the amount of free memory available in segments + + +Revision 1.00 Page 83 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +through calling p_sgfree. The PLIB p_sgcreate function is then invoked to create a new segment, +"Test", that consists of all of this free memory. Finally, the p_sgcopyto PLIB function is called to fill +"Test" with Ox55's. By using up all free memory in this way, it is possible to use segment "Test" to +determine whether a particular driver vector is writing to the wrong location. TestGobble, presented +overleaf, is the third function outlined. It uses the PLIB function p_sgcopyfr to check the values of +the bytes in the segment "Test". If any of the 0x55's have been overwritten then we know that we +have a problem. These three functions should be incorporated within the standard test harness +functions already presented in this chapter. In this way, it is possible to generate a powerful generic +test program that can be used as the basis for all device driver testing. + + +LOCAL_C VOID CheckMemory (VOID) +{ + +VOID *Heap; + +INT fbytes; + + +fbytes=p_allspc (&Heap) ; + +p_printf ("Free Heap Memory =>%x bytes", fbytes) ; +p_printf ("Free Segments =>%d",p_sgfree()); +p_getch(); + +} + + +[KR KR KK KR KK KI KK IK I I I I / + + +LOCAL_C VOID GobbleMemory (VOID) +{ +UINT nParas, segSize; +INT 3; + +LONG pos,i; + +UBYTE buf [256]; + + +p_printf(" System RAM size = %d",p_getram()); +p_printf ("Internal RAM usage = %d",p_sgramdisk())j; +nParas=p_sgfree()j; +p_printf ("Amount of free RAM = %d",nParas); +segH=p_sgcreate("Test",nParas, E_SEGMENT_HIGH) ; +if (segH) + +p_printf ("Created segment \"test\""); + + +else +{ +p_printf ("Error in creating segment"); +p_getch(); +p_exit (0); +} +segSize=p_sgsize(segH) ; +p_printf("Size of segment is %d",segSize); +p_printf("In 16-byte paragraphs"); +p_sleep(5L); +for (j=0; j<16; j++) +buf [j]=0x55; + + +i=0; +while (i 7;Open channel control block Ent +A4ExifDSHandlerPtr dw 2 ;Cant touch when under +A4ExifDSStatusPtr dw ? ;Hold, Resume, Reset or +A4ExifDSA1Ptr dw ? ;interrupt routine +A4ExifDSA2Ptr dw es +A4ExifDSStatusEntPtr dw ? + +A4ExifEnt ends +A4PERIPH MASK equ Of0h 711110000b + + +Revision 1.00 Page 86 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +EXTENDED_INFO_BYTE equ 090h +U5_ENABLE_ON equ 080h +U5_ENABLE_OFF equ 000h +;Latch addresses for reading/writing +USOUTPUT_LATCH equ 00000000b +U3INPUT_BUFFER equ 00000000b +U4STATUS_BUFFER equ 00000001b +cs: [di] .A4ExifCsAlValuefor +INTERRUPT_LATCH equ 00000001b +;Status byte masks +S2S3_ON equ 00000011b +S2S3_OFF equ 00000000b +S2_ONLY equ 00000001b +S3_ONLY equ 00000010b +INTERRUPT_STATUS_MASK equ 00000011b +7; LED bytes +SOME_LEDS_ON equ 01010101b +SOME_LEDS_OFF equ 10101010b +TOP_LEDS_ON equ 11110000b +BOTTOM_LEDS_ON equ 00001111b +ZERO_BYTE equ 00h +dgroup group stack +assume ds:dgroup,es:dgroup,ss:dgroup +CodeSeg +7 A4EXIF ENTRY TABLE +; Seseseo eee ee sececs +ProcBegin@ A4ExifLDD +; ssieceees +dw LDDSignature +db 'LED',0,0,0,0,0 +dw (VectorEnd-Vector) /2 +Vector: +dw A4ExifInstall +dw A4ExifRemove +dw A4ExifHold +dw A4ExifResume +dw A4ExifReset +dw A4ExifUnits +dw A4ExifOpen +dw A4ExifStrategy +VectorHandler: +dw A4ExifHandler +if Asic9 +InterruptVectors: +dw A4ExifTickInt +endif +VectorEnd: +H A4EXIF INTERNAL DATA SPACE +, +; Device Driver global variables follow. +; These variables reside in the code segment +; and as such can always be accessed with +7 the 'cs:' prefix. + + +if Asic9 +if Consumer + + +Channel0O A4ExifStatusEnt<0,0,0,0,mask + + +Psion PLC (c) May 1995 + + +710010000b +7;Sets LBO for latch U5 +;Deselects LBO for U5 + + +;Selects +;Selects +;Selects + + +;Selects + + +A9MSlave, HwIrq2Revector, SelectChannel5, IntVec0O,0,0> + + +else +if Corporate or S3c + + +Channel0 A4ExifStatusEnt<0,0,0,0,mask + + +AOMExpIntA, HwIrq4Revector, SelectChannel3, IntVec0O,0,0> + + +Channell A4ExifStatusEnt<0,0,0,0,mask + + +AQMExpIntB, HwIrq5Revector, SelectChannel4, IntVec1,0,0> + + +Channel2 A4ExifStatusEnt<0,0,0,0,mask + + +A9MSlave, HwIrq2Revector, SelectChannel5, IntVec2,0,0> + + +Revision 1.00 + + +AO for writing +AO for reading + + +; reading +Al for writing + + +Page 87 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +else +Channel0 A4ExifStatusEnt<0,0,0,0,mask + + +AOMExpIntA, HwIrq4Revector, SelectChannel3, IntVec0O,0,0> +Channell A4ExifStatusEnt<0,0,0,0,mask + + +AQ9MExpIntB, HwIrq5Revector, SelectChannel4, IntVec1,0,0> +endif +endif +else +if Consumer +Channel0O A4ExifStatusEnt<0,0,0,0,mask + + +Asic2Int, HwIrq4Revector, SelectChannel7, IntVec0,0,0> + + +else +if Corporate +ChannelO A4ExifStatusEnt<0,0,0,0,mask +ExpIntLeftA, HwIrq3Revector, ExpChannelLeftA, IntVec0O,0,0> +Channell A4ExifStatusEnt<0,0,0,0,mask +ExpIntRightB, HwIrq2Revector, ExpChannelRightB, IntVecl1,0,0> +Channel2 A4ExifStatusEnt<0,0,0,0,mask +Asic2Int, HwIrq4Revector, SelectChannel7, IntVec2,0,0> +else +ChannelO A4ExifStatusEnt<0,0,0,0,mask +ExpIntLeftA, HwIrq3Revector, ExpChannelLeftA, IntVec0O,0,0> +Channell A4ExifStatusEnt<0,0,0,0,mask +ExpIntRightB, HwIrq2Revector, ExpChannelRightB, IntVecl1,0,0> +endif +endif +endif +HoldFlag db 0 ;Hold/Resume flag +SwitchStatus db ? ;Holds the masked status byte from U4 after +interrupt +ProcEnd noret +ProcBegin@ A4ExifInstall, far +; eee +; Installs the device driver. +7 Invoked after a PLIB 'p_loadldd("A4EXIF.LDD")' call to load the LDD +; All of the fields inside the CS control blocks are preloaded +; with the correct values at install time. Install therefore does +; not do any work. +7 IN: +; Nothing +7 OUT: +; Carry Clear - driver successfully installed +7 +cle ;The ChannelOpen fields are set to zero +ret ;in the relevant ChannelStatusEnt headers +ProcEnd noret +ProcBegin@ A4ExifRemove, far +; eSeseces eee +; Removes the device driver. +; Invoked after a PLIB 'p_devdel("LED",E_LDD) 'call to unload the +H device driver. +; A device driver cannot be removed if any of its channels +i are still open. +H IN: +; Nothing +H OUT: +; Carry clear - successfully removed +7 Carry set - remove failed, error number in AL +7 +mov cx, numberofchannels ;Check that each +mov di, offset Channel0O ;channel is closed +xor ax, ax +CheckAl1lChannelsClosedLoop: +cmp cs: [di] .A4ExifCSChannelOpen, al ;Closed channels will +jne WeHaveAChannelOpenSoFail ;have the value 0 in +add di, (size A4ExifStatusEnt) ;their ChannelOpen + + +Revision 1.00 Page 88 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +loop CheckAl1ChannelsClosedLoop ;flags +jmp FinishedOkay +WeHaveAChannelOpenSoFail: +mov al, InUseErr ;Fail if not all +stc ;closed +ret +FinishedOkay: +cle +ret +ProcEnd noret + + +ProcBegin@ A4ExifHold, far + + +v + +; Called by the operating system whenever the device driver is + +; being moved or the machine is powering down. + +; This will also be called by our pack door polling function when + +; it sees that the doors have been opened and our peripheral has + +; lost power. + +; IN: + +7 Reason for the hold in AH + +7 OUT: + +7 Nothing + +13 +mov cx, 1 ;Hold can be called +xchg cl, HoldFlag ;when the driver is +cmp cl, 0 ;under a hold so +jne AlreadyHeld ;re-entrancy blocking + +A4HoldFromTick: ;is required +mov cx, numberofchannels +mov di, offset Channel0 ; Loop because Hold + + +HoldAllTheChannelsLoop: + + +;must stop all the + + +cmp cs: [di] .-A4ExifCSChannelOpen, ; channels +je DontHoldBecauseNotOpen ;Is the channel open? +push cx ;If it is then stop +call StopTheChannelRunning yall interrupts +pop cx +DontHoldBecauseNotOpen: +add di, (size A4ExifStatusEnt) +loop HoldAl1lTheChannelsLoop +AlreadyHeld: +ret + + +ProcEnd noret + + +ProcBegin@ A4ExifResume, far + + +3 Called by the operating system when it has finished moving the +- device driver in memory or when the machine is switching back on. +; Also called by our door polling routine when it sees that the doors +; have been closed and we can resume communication with our peripheral. +; IN: +iH Nothing +; OUT: +7 Nothing +is +xor CX, cx ;Block in case of re-entrancy +xchg cl, HoldFlag +cmp cl, 0 +je AlreadyResumed +if Asic9 +GenDataSegment ;Check to see if the pack +HwGetSsdData ;doors are still closed +mov bx, ax +cmp es: [bx] .SsdDoorStatus, DoorOpen +je DoorsAreOpen +endif +A4ResumeFromTick: +mov cx, numberofchannels ; Loop because resume must +mov di, offset Channel0 ;restart each open channel +ResumeAllTheChannelsLoop: +cmp cs: [di] .A4ExifCSChannelOpen, 0 ;Is the channel open? +je DontResumeBecauseNotOpen +push Cx +call StartTheChannelRunning +pop cx +DontResumeBecauseNotOpen: +add di, (size A4ExifStatusEnt) +loop ResumeAl1lTheChannelsLoop +AlreadyResumed: + + +Revision 1.00 Page 89 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Psion PLC (c) May 1995 + + +ret + + +DoorsAreOpen: + + +mov HoldFlag, 2 +ret +ProcEnd noret + + +ProcBegin@ A4ExifReset, far + + +Called when an application which opened a channel terminates without +closing the device driver. +A device driver, for each open channel, has to request that the +operating system calls this function when the application +terminates abnormally (ie without closing an open channel). +Reset can supply one piece of identifying data which will be +passed in CX. This would usually be the channel's number or CS +control block pointer. +Reset just needs to clear interrupts, hardware reservations, and free +the channel. Any allocated space will be cleaned up for you by the OS. +IN: + +The device driver's handle in BX + +The address of the status struc identifying the channel in CX + + +7 OUT: +; Nothing +, +mov di, cx +cmp cs: [di] .A4ExifCSChannelOpen, 0 +je NotOpenToReset +call StopTheChannelRunning 7Stop interrupts +mov al, cs: [di] .A4ExifCSChannelIntMask ;Free the reserved +HwF reeChannel ;hardware +mov cs: [di] .A4ExifCSChannelOpen, 0 ;The channel is now +NotOpenToReset: ;free +ret + + +ProcEnd noret + + +ProcBegin@ A4ExifUnits, far + + +Called to find how many open channels the driver will support + + +- In: +; Nothing +- Out: +H The total number of channels supported in AX +, +mov ax, numberofchannels +ret + + +~ + + +ProcEnd noret + + +ProcBegin@ A4ExifOpen, far + + +Opens a device driver channel. +Invoked after the PLIB call 'p_open(é&appHandle, "LED:*",-1)'to open a +channel to the device driver. + + +, + +, + +7 + +H Tn: + +; OS device handle of the device driver in DX + +; Pointer to the OpenEnt struc in SI + +; Pointer to the IntEnt struc in BP + +; DS,ES,SS point to the applications data space + +i Out: + +; Carry clear - BX holds the address of the open channel + +7 Carry set - AL holds the error number + +is +cld ;Interrupts off to +pushf ;prevent multiple apps +oli ;calling open +mov si, [si] .OpenNamePtr ; Simultaneously +mov al, [sitl] +CharToFoldedChar ;Read the unit no. +cmp al, 'A' ;part of device name +jb OpenNameErr ;to find which channel +sub al, 'A' ;to open. eg "LED:A" +cmp al, numberofchannels +jae OpenNameErr +xor ah, ah +push ax ;Map the channel no. +mov dx, (size A4ExifStatusEnt) ;to a channel control +mul dx ;block in our CS +pop ax 7; space + + +Revision 1.00 + + +Page 90 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +mov di, ax +add di, offset Channel0O +cmp cs: [di] .A4ExifCSChannelOpen, 0 +je GetATickChannel +popft +mov ax, AlreadyOpenErr +jmp ChannelAlreadyOpen +GetATickChannel: +mov cs: [di] .A4ExifCSChannelOpen, 1 +mov cs: [di] .-A4ExifCSChannelRunning, 0 +popft +ife Asic9 +jmp GetHardwareChannel +else +push ax +mov ax, ((':' shl 8)+'K') +push ax +mov ax, (('C' shl 8)+'T') +push ax +mov bx, sp +ToOpen +jne GotATickChannel +add sp, 6 +mov ax, LockedErr +jmp OpenFailed +GotATickChannel: +add sp, 6 +mov cs: [di] .A4ExifCSTickHandle, ax +push ax +mov bx, ax +mov ax, IoFuncStart +mov ex, 1 +push cx +push cx +push ax +mov cx, (InterruptVectors-Vector) /2 +push cx +mov cx, sp +ToWithWait +add sp, 8 +pop dx +jmp GetHardwareChannel +endif +OpenNameErr: +popft +mov ax, NameErr +jmp ChannelAlreadyOpen +GetHardwareChannel: +mov al, cs: [di] .A4ExifCSChannelIntMask +HwGetChannel +jne CheckHardwareNowThatSIBOChannellIsOpen +mov ax, InUseErr +jmp FreeTckAndExit +FreeTckAndChannelHardware: +mov al, cs: [di] .A4ExifCSChannelIntMask +HwF reeChannel +mov ax, DeviceErr +FreeTckAndExit: +if Asic9 +push ax +mov bx, cs: [di] .A4ExifCSTickHandle +IoClose +pop ax +endif +OpenFailed: +mov cs: [di] .A4ExifCSChannelOpen, 0 +ChannelAlreadyOpen: +stc +OpenExit: +ret +CheckHardwareNowThatSIBOChannellIsOpen: +Proclid +mov cs: [di].A4ExifCSProcessId, ax +mov cs: [di] .A4ExifCSChanReadCompleted, 0 +call CheckHardwarePresent +jc FreeTckAndChannelHardware +mov cx, (size A4ExifEnt) +HeapAllocateCell +jc FreeTckAndChannelHardware +mov bx, ax + + +Revision 1.00 + + +Psion PLC (c) May 1995 + + +;Offset in DI + + +;Check to see if +;channel is already +;open + + +,Obtain a TCK channel so +;we can poll the door state + + +7;If HC, we don't need +;to set up the TCK +; routine + + +;Try to open "TCK:" +;channel with "TCK:" +; string on stack + + +;TCK will call our +,door-polling function +732 times a second + + +7Start our +,door-polling function +;running by starting +;the "TCK:" channel + + +7Frequency 1 tick +;Data irrelevant +;Handle to driver +;TCK function to call + + +7;Check the hardware +;is available then +;reserve it +;Returns with carry +;clear if OK + + +7Set up the calling +;process ID + + +;Returns with carry +;clear if successful +;Allocate a control +;block in our app's +;data space + + +Page 91 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +push bx ;IloAddHandler trashes BX +mov al, (VectorHandler-Vector) /2 ;Set up our wait handler +ToAddHandler ;Leaves the address of +pop bx ;handler in AX +jne GotHandler +push ax ;If no handler, open fails +HeapFreeCell +pop ax +jmp FreeTckAndChannelHardware +GotHandler: +mov [bx] .A4ExifDSStatusEntPtr, di +mov [bx] .A4ExifDSHandlerPtr, ax +mov [bx] .A4ExifDSStatusPtr, 0 +mov [bx] .A4ExifDSIo.ChanNext, bx +mov [bx] .A4ExifDSIo.ChanSignature, IoChanSignature +mov [bx] .A4ExifDSIo.ChanLibHandle, dx +mov cx, al ; loRequestReset takes +xchg bx, dx ;the device handle in +IoRequestReset 7BX and the channel +xchg bx, dx ;handle in CX +xor ax, ax +call StartTheChannelRunning +ReturnCLc: +cle +ret +ProcEnd +if Asic9 + + +ProcBegin@ A4ExifTickInt, far + + +This function is called by the tick handler on every tick of + +; the system clock. This happens 32 times a second. + +; The operating system will call a device driver to hold when memory is +; being moved and when the machine is being powered down. It will not + +; call the device driver when the pack doors are opened. + +Opening the pack doors will cause power to the peripheral to be cut, + + +; +; and therefore the driver needs to be held in the way it would be if +; the machine powered down. Only for Asic9 based machines. +; This function checks the state of the doors on every tick and calls +iH Hold and resume when it sees the status of the doors change. +H IN: +; The state of the door in SI +; OUT: +; Nothing +; +cmp si, DoorOpen 7Is the door open +je TheDoorIsOpen 7or closed? +cmp HoldFlag, 2 7Closed Door, HoldFlag=2 +je NeedToDoTheResume ;means we do a resume +ret 7Closed Door, HoldFlag!=2 +NeedToDoTheHold: +mov HoldFlag, 2 +jmp A4HoldFromTick +NeedToDoTheResume: +mov HoldFlag, 0 +jmp A4ResumeFromTick +TheDoorIsOpen: +xor ax, ax +cmp HoldFlag, al +je NeedToDoTheHold +ret +ProcEnd noret +endif +ProcBegin@ A4ExifHandler, far +; +; When an application is waiting within an iowait and a signal is +; generated then before passing that signal to the application the +: OS first runs any wait handlers belonging to the device driver +; channels that the application has open. +; The interrupt routine can generate a signal but cannot fill in any +; status words or pass values back to the application because the +; applications DS space is not available. The handler can consume a +; signal generated by an interrupt and then fill any status words +7 before re-signalling the application. A handler always has access +; to the application's DS space. The wait handler can consume the +7 signal which is then no longer passed back to the application. +Hi IN: + + +Revision 1.00 Page 92 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Ne Ne Ne Ne + + +Psion PLC (c) May 1995 + + +Pointer to our control block in applications DS space in BX +DS,ES,SS point at application's data space + + +OUT: +Carry clear - do not consume the signal, signal not for us +7 Carry set - consume the signal, re-enable handler if AL +; non-zero else don't re-enable handler if AL=0. +7 +cld +pushf +cli +mov di, [bx].A4ExifDSStatusEntPtr ;Is the signal for us? +cmp cs: [di] .A4ExifCSChanReadCompleted, 1 +jne ExitHandlerSignalNotForuUs ;If it is, copy +mov cs: [di] .A4ExifCSChanReadCompleted, 0 ;the values read in +mov al, cs: [di] .A4ExifCSA1Value ;the interrupt +mov ah, cs: [di] .A4ExifCSA2Value ;routine back to +mov di, [bx].A4ExifDSA1Ptr ;the application +mov [di], al ;Asynchronous read +mov di, [bx].A4ExifDSA2Ptr ;has been completed +mov [di], ah +xor di, di +xchg [bx] .A4ExifDSStatusPtr, di ;Clear the status +mov word ptr [di], 0 ;word +popft +ToSignal +xor ax, ax +stc ;STC and AL!=0 => +ret ;consume signal and +ExitHandlerSignalNotForus: ;don't re-enable +popft ;handler +elec +ret +ProcEnd +StrategyVectorTable label word +dw offset A4ExifDefault ;StrategyPanic +dw offset A4ExifRead 7 StrategyRead ie P_FREAD +dw offset A4ExifWrite ;StrategyWrite ie P_FWRITE +dw offset A4ExifClose ;StrategyClose ie P_FCLOSE +dw offset A4ExifCancel 7 StrategyCancel ie P_FCANCEL +dw offset A4ExifDefault ;StrategyAttach +dw offset A4ExifDefault ;StrategyDetach +dw offset A4ExifSet ;StrategySet ie P_FSET +dw offset A4ExifSense ;StrategySense ie P_FSENSE +ProcBegin@ A4ExifStrategy, far +Called by the operating system when an I/O request is made on + + +the device driver. + +Calls to this funcion from an owning application will usually take +the form p_ioc(pcb, func, &Stat, &Al, &A2) ; + +The strategy function is called with a function number specifying +the action which the driver is to take, a status word to fill when +the action is complete, and two arguments Al and A2. + + +Nee Ne Ne + + +Se ee + + +All strategy functions must complete with a signal to the application. +Functions can be asynchronous and need not complete immediately. +IN: +Pointer to our control block in the applications DS in BX +7 Device driver handle in DX +; Pointer to the RqEnt struct in SI +; Pointer to a IntEnt struct in BP +; DS,ES,SS point at the applications data space +i OUT: +; Returned value in AX +; Must call IoSignal somewhere to signal completion +; of the I/O request. +v +mov ax, [si].RqFunction ;Get the function number +mov dx, [si].RqAlPtr ;DX holds the first argument +mov di, [si].RqStatusPtr ;for convenience +mov word ptr [di], PendingErr 7Status word holds +shl ax, 1 ; E_FILE_PENDING +mov di, ax +push StrategyVectorTable[di] ;Jump to required function +mov di, [bx] .A4ExifDSStatusEntPtr ;with our CS control block +retn ;pointer in DI +A4ExifDefault: +ToRoot + + +Revision 1.00 + + +Page 93 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +ret +ExitWithCompletionStatusZero: + +xor ax, ax ;Common exit points +ExitWithOtherCompletionStatus: + +mov di, [si].RqStatusPtr + +mov word ptr [di], ax + +ToSignal +ExitStillPending: + +xOr ax, ax + +cle + +ret + + +ProcEnd noret + + +STRATEGY VECTOR TABLE FUNCTIONS + + +IN: +DX holds the pointer to the first argument in 'p_iow(...)' call +BX holds the address of the open channel control block +CS:DI holds the address of status struc identifying the open channel + + +See eee Ty + + +ProcBegin@ A4ExifRead, far + + +H Strategy vector table function that handles asynchronous byte reads +7 from the LEDs and switches. + +i; The corresponding PLIB call is p_ioc(pcb,P_FREAD, &Stat, &Argl, &Arg2) ; +; The request is completed when the interrupt routine signals the + +; handler which in turn signals the application passing back the values +; read at the time of the interrupt through the AlPtr and A2Ptr. + +H IN: + +; Pointer to control block in applications data space in BX + +i Pointer to control block in our CS space in DI + +; Al (pointer to Argl) in DX + +, + +v + + +OUT: +Jumps to common exit point +. Panics if multiple requests +, +cmp [bx] .A4ExifDSStatusPtr, 0 ;Panic if we already +jne PanicPending ;have an I/O read request +pushf ;pending on the channel +cli ;Disable interrupts +mov cs: [di] .A4ExifCSChanReadCompleted, 2 +mov ax, [si].RqA1Ptr +mov [bx] .A4ExifDSA1Ptr, ax ; Store the locations to +mov ax, [si].RqA2Ptr ;put the data when we get it +mov [bx] .A4ExifDSA2Ptr, ax +mov di, [si].RqStatusPtr +mov [bx] .A4ExifDSStatusPtr, di ;DI holds the address +mov word ptr [di], PendingErr 7of status word and we +popf ;Signal that we are waiting +mov bx, [bx] .A4ExifDSHandlerPtr ;for completion of read +mov cl, +ToEnableHandler ;Enable Wait Handler +jmp short ExitStillPending 7No IoSignal because +PanicPending: ;we are still waiting +mov al, PaniclIoPending +ProcPanic + + +ProcEnd noret + + +ProcBegin@ A4ExifWrite, far + + +This function sets the state of the LEDs. + +It completes immediately after setting the state as it has nothing +to wait for. + +Write is the same as set. + + +Ne Ne Ne Ne Ne te + + +IN: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +. Al in DX +- OUT: +- Jumps to Set +, +jmp WriteAndSetAreTheSame + + +ProcEnd noret + + +ProcBegin@ A4ExifClose, far + + +Revision 1.00 Page 94 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Handles the request to close a channel. +called by the PLIB call p_iow(pcb,P_FCLOSE) or p_close (pcb) + + +Ne Ne Ne Ne + + +IN: +Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; OUT: +; Jumps to common exit point +, +call StopTheChannelRunning 7Stop interrupts +if Asic9 +push bx ;Close down the +mov bx, cs: [di] .A4ExifCSTickHandle 7;"TCK:" channel +IoClose +pop bx +endif +push bx +mov ax, [bx] .A4ExifDSIo.ChanLibHandle ;Remove the wait +push ax ;handler +mov bx, [bx] .A4ExifDSHandlerPtr +IoRemoveHandler +cmp cs: [di] .A4ExifCSChanReadCompleted, 0 ;If the interrupt +je NoSignalToConsumeFromInterrupt ;has signalled the +ToWaitForSignal ;handler we need to +NoSignalToConsumeFromInterrupt: ;consume its signal +pop bx ;now the handler +mov cx, di ;has been removed +ToRequestResetCancel +pop bx 7No longer need reset +HeapFreeCell ;Free our control +mov al, cs: [di] .-A4ExifCSChannelIntMask ;block in app's DS +HwFreeChannel +mov cs: [di] .A4ExifCSChannelOpen, 0 +jmp ExitWithCompletionStatusZero 7To signal completion +ProcEnd noret 7,of close request +ProcBegin@ A4ExifCancel, far +v +; Cancel any pending asynchronous read. +; Called by the PLIB function p_iow(pcb,P_FCANCEL) ; +i In: +; Pointer to control block in applications data space in BX +; Pointer to control block in our CS space in DI +; Out: +; Jumps to common exit point +7 +pushf +cli +cmp [bx] .A4ExifDSStatusPtr, 0 ;Check that there is +je NothingToCancel ya request pending +push bx +mov bx, [bx] .A4ExifDSHandlerPtr +sub cl ol +ToEnableHandler ;Disable Wait Handler +pop bx +cmp cs: [di] .A4ExifCSChanReadCompleted, 1 +jne NoSignalFromInterrupt ;TO consume any stray +ToWaitForSignal ;Signal from the +NoSignalFromInterrupt: ;interrupt routine +mov cs: [di] .A4ExifCSChanReadCompleted, 0 +xor fomcramre be ;To signal completion +xchg di, [bx].A4ExifDSStatusPtr ;of the outstanding +mov word ptr [di], CancelErr pasync read request +ToSignal ;Signal to p_waitstat +NothingToCancel: +popft +jmp ExitWithCompletionStatusZero 7To signal completion +ProcEnd noret 7of the cancel request +ProcBegin@ A4ExifSet, far +, +7 Write a value to the LED latch. +; Can be called by the PLIB call p_iow(pcb,P_FSET, &Argl); where Al +; is an unsigned byte. +; Write is the same as set. +7 IN: +; Pointer to control block in applications data space in BX +7 Pointer to control block in our CS space in DI +7 Al (pointer to Argl) in DX + + +Revision 1.00 Page 95 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +’ + + +’ + + +OUT: +Jumps to common exit point + + +, +WriteAndSetAreTheSame: + + +Steere Ty + + +Ne Ne Ne Ne + + +seo + + +pushf + +cli + +mov al, cs: [di] .-A4ExifCSChannelSelect +HwSelectChannel + +push ax + +mov bx, dx + +mov dl, U50UTPUT_LATCH + +mov al, [bx] + +call OutputByte + +pop ax + +HwSelectChannel + +popft + +jmp ExitWithCompletionStatusZero + + +ProcEnd noret + + +ProcBegin@ A4ExifSense, far + + +Reads the state of the LEDS and Switches. + + +Psion PLC (c) May 1995 + + +7Select our SIBO +; serial channel +7Store old channel + + +;DX (now BX) points +;to the value to +output to our +;peripheral + +;Return old channel + + +;To signal completion + + +7of set request + + +Can be called from PLIB using p_iow(pcb, P_FSENSE, éArgl, &Arg2) + + +Where Argl and Arg2 are unsigned bytes. +In: + + +Pointer to control block in applications data space in BX +Pointer to control block in our CS space in DI + + +Al (pointer to Argl) in DX + + +Out: +Jumps to common exit point +pushf +cli +mov al, cs: [di] .-A4ExifCSChannelSelect +HwSelectChannel +push ax +mov bx, dx +mov dl, U4STATUS_BUFFER +call InputByte +mov [bx], al +mov bx, [si] .RqA2Ptr +mov dl, U3INPUT_BUFFER +call InputByte +mov [bx], al +pop ax +HwSelectChannel +popft +jmp ExitWithCompletionStatusZero + + +ProcEnd noret + + +LOCAL DEVICE DRIVER FUNCTIONS + + +7Select our SIBO +;serial channel +7 Store old channel + + +;DX (now BX) points +;to the variable in +;which to place the +;value read from U4. +7BX now points to + +;the variable in + +;which to place the +;value read from U3. + + +;Return old channel + + +;To signal completion + + +;of a sense request + + +Interrupts must be off prior to the call to this function. + + +IN: + + +DL has address to which Asic4 is to write + + +AL holds the value to output + + +mov al, (SerialWriteSingle or A4Address) + + +SBUSY +SCONTOUT +mov al, dl +SBUSY +SDATAOUT +mov al, (SerialReadSingle or A4Data) +SBUSY + +SCONTOUT + +SBUSY + +SDATAIN + +ret + +ProcEnd noret + + +ProcBegin@ OutputByte + + +Interrupts must be off prior to the call to this function. + + +Revision 1.00 + + +Page 96 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +H IN: +; DL has address to which Asic4 is to write +; AL has the value to output + + +mov al, (SerialWriteSingle or A4Address) + + +mov al, dl + + +mov al, (SerialWriteSingle or A4Data) +SBUSY +SCONTOUT +SBUSY +XNOP +pop ax +SDATAOUT +ret +ProcEnd noret + + +ProcBegin@ IntVecO, far + + +- Interrupt on serial channel0 +3 Calls Comint with channel control block pointer in DI +, + +mov di, offset Channel0O + +jmp ComIint + + +ProcEnd noret + + +if Corporate or S3c +ProcBegin@ IntVecl1, far + + +Sat + + +Interrupt on serial channell + + +; Calls Comint with channel control block pointer in DI +, + +mov di, offset Channell + +jmp ComInt + + +ProcEnd noret + + +ProcBegin@ IntVec2,far + + +Interrupt on serial channel2 +Calls Comint with channel control block pointer in DI + + +Ne Ne Ne Ne + + +mov di, offset Channel2 +7 FALL THROUGH +ProcEnd noret +endif +ProcBegin@ ComInt, far +, +; The common interrupt service routine code. +; When an interrupt occurs, the first task is to read the status +7 buffer of latch U4. The subsequent action is dependent on the +; postion of switches Sl and S2. For the purposes of this example, +; the four posibilities for the switch values correspond somewhat +; arbitrarily to four different byte values that are written to U5. +; in the 8086, interrupts cannot occur while in an interrupt routine. +; If an asynchronous read is pending then the handler is signalled. +7 IN: +; Channel's CS based control block pointer in DI +, +cmp cs: [di] .A4ExifCSChanReadCompleted, 2 ;Only if 2 do we have +jne NotAsynchronousRead ;asynch read completed +mov cs: [di] .A4ExifCSChanReadCompleted, 1 +mov bx, cs: [di] .A4ExifCSProcessId ;Signals completion +ToSignalByPidNoReSched 7Of read to OS so as +NotAsynchronousRead: ;to invoke handler +mov al, cs: [di] .-A4ExifCSChannelSelect +HwSelectChannel +push ax +mov dl, U3INPUT_BUFFER +call InputByte +mov cs: [di] .A4ExifCSA2Value, al ;LED byte +mov dl, U4STATUS_BUFFER + + +Revision 1.00 Page 97 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +call InputByte +mov cs: [di] .A4ExifCSAlValue, al ; Status byte +and al, INTERRUPT_STATUS_MASK +xchg al, SwitchStatus +cmp SwitchStatus, S2S3_ON 7;S2 and S3 on => turn +je A11LEDsOn 7on alternate LEDs +cmp SwitchStatus, S2S3_OFF 7S2 and S3 off => not +je A11LEDsOff ;the alternate LEDs +cmp SwitchStatus, S2_ONLY 782 on, S3 off => turn +je TopLEDsOn 7on top four LEDs +cmp SwitchStatus, S3_ONLY 753 on, S2 off => turn +je BottomLEDsOn 7on bottom four LEDs +ErroriInSwitchStatusByte: +jmp ClearInterruptAndReschedule +A11LEDsOn: +mov al, SOME_LEDS_ON +jmp Output LEDByte +A11LEDsOff: +mov al, SOME_LEDS_OFF +jmp Output LEDByte +TopLEDsOn: +mov al, TOP_LEDS_ON +jmp Output LEDByte +BottomLEDsOn: +mov al, BOTTOM_LEDS_ON +OutputLEDByte: +mov dl, US50UTPUT_LATCH +call OutputByte +ClearInterruptAndReschedule: +mov dl, INTERRUPT_LATCH +call OutputByte +if Asic9 ;A write to this location +out A9BNonSpecificEoiw, al ;informs the interrupt +else ;controller that the +out AlNonSpecificEoi, al ;installed interrupt +endif ;service routine has +pop ax ; finished +HwSelectChannel +onlkres ;Reschedule if necessary +ret +ProcEnd noret +ProcBegin@ StartInterrupts +po SSS SES +; Start interrupts assuming interrupts are +; off prior to call. +; The EPOC GenSetRevector service loads in +; a user-specified interrupt service routine +; located at the address given in cx:bx +; (segment cx, offset bx) for the interrupt +; vector number given in AL. Note that the +7 variable A4ExifCSChannelIntVec holds the +; name of the appropriate required interrupt +; vector routine for the channel. +H IN: +; Our CS control block pointer in DI +H OUT: +i; Nothing +is +mov al, cs: [di] .-A4ExifCSChannelIntNum 7Get the OS to call +mov cx, CS ;the function in +push bx 7CS:BX every time +mov bx, cs: [di] .A4ExifCSChannelIntVec ;that the interrupt +GenSetRevector ;whose number is in +pop bx 7;AL occurs +ife Asic9 +in al, AlInterruptMask +or al, cs: [di] .A4ExifCSChannelIntMask ;Set the mask +out AlInterruptMask, al ;location so as +; interrupt +else ;to enable that +in al, A9BInterruptMaskRW ; interrupt +or al, cs: [di] .A4ExifCSChannelIntMask +out A9BInterruptMaskRW, al +endif +ret + + +ProcEnd noret + + +Revision 1.00 Page 98 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +ProcBegin@ StopInterrupts + + +; Stop interrupts assuming that interrupts are off + + +The EPOC GenResetRevector OS service + + +interrupt service routine with the original +routine and interrupt mask for the vector +given in AL. +IN: + +Our CS control block pointer in DI + + +Se ee Te + + +OUT: +; Nothing + + +ife Asic9 + + +replaces the previously loaded user-specified + + +Psion PLC (c) May 1995 + + +in al, AlInterruptMask ;Disable the +mov ah, cs: [di] .A4ExifCSChannelIntMask ; interrupt +not ah +and al, ah +out AlInterruptMask, al +else +in al, A9BInterruptMaskRW +mov ah, cs: [di] .A4ExifCSChannelIntMask +not ah +and al, ah +out A9BInterruptMaskRW, al +endif +mov al, cs: [di] .-A4ExifCSChannelIntNum ;Return the interrupt +GenResetRevector ;vector to the OS +ret ; default +ProcEnd noret +ProcBegin@ StartTheChannelRunning +Fo eee eeeeeeea= +; Starts the hardware and interrupts going +; If the hardware is aready running then there is nothing to do +; Must check that the hardware has not vanished before restarting it +H IN: +; Our CS control block pointer in DI +7 OUT: +i Nothing +7 +pushf +cli +cmp byte ptr cs: [di].A4ExifCSChannelRunning, 0 +jne ChannelAlreadyRunning +call CheckHardwarePresent +jc HardwareNotPresent +mov al, cs: [di] .-A4ExifCSChannelSelect +HwSelectChannel +push ax +mov al, (SerialWriteSingle or A4Control) ; Switch on the +SBUSY output latch U5 +SCONTOUT ;by asserting +mov al, U5_ENABLE_ON ;the ASIC4 LBO line +SBUSY ; (LBO is inverted) +SDATAOUT +xor ax,ax +mov dl, INTERRUPT_LATCH 7Clear any pending +call OutputByte ;interrupt on the +mov dl, US5OUTPUT_LATCH ;peripheral +call OutputByte 7Preset the LEDs +pop ax ;to all off +HwSelectChannel +call StartInterrupts +mov cs: [di] .A4ExifCSChannelRunning, 1 +ChannelAlreadyRunning: +popft +cle +ret +HardwareNotPresent: +popft +stc +ret + + +ProcEnd noret + + +ProcBegin@ StopTheChannelRunning + + +Revision 1.00 + + +Page 99 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Ne Ne Ne Ne + + +Stops the hardware and interrupts + + +Psion PLC (c) May 1995 + + +Checks to see if the hardware is really running to start with + + +IN: +Our CS control block pointer in DI + +i OUT: +; Nothing +7 + +pushf + +cli + +cmp byte ptr cs:[di].A4ExifCSChannelRunning, 0 + +je ChannelNotRunning + +mov al, cs: [di] .-A4ExifCSChannelSelect + +HwSelectChannel + +push ax + +mov al, (SerialWriteSingle or A4Control) + +SBUSY + +SCONTOUT + +mov al, U5_ENABLE_OFF + +SBUSY + +SDATAOUT + +xor ax, ax + +mov dl, US50OUTPUT_LATCH + +call OutputByte + +pop ax + +HwSelectChannel + +call StopInterrupts + +mov cs: [di] .A4ExifCSChannelRunning, 0 +ChannelNotRunning: + +popft + +ret + + +Se eT + + +ProcEnd noret + + +ProcBegin@ CheckHardwarePresent + + +Used to determine whether the correct hardware is present + + +on the successfully procured serial channel. + + +IN: + +CS control block pointer in DI +OUT: + +Carry clear - correct hardware is there + +Carry set - wrong or no hardware +pushf +cli ;Select the correct +mov al, cs: [di] .A4ExifCSChannelSelect ;SIBO channel that +HwSelectChannel ;the peripheral is +push ax ;attached to +HwNullFrame +mov al, (SerialSelect or Asic4Id) +SBUSY ;First look for an +SCONTOUT 7;ASIC4 at the other +XNOP ;end of the link +SBUSY +SDATAIN ;Ilf the returned +test al,al ;value is non-zero +je ConnectionFailedA4NotPresent ;we have an ASIC4 +mov al, (SerialReadSingle or A4InfoR) +SBUSY ;Now see if we have +SCONTOUT ;the right peripheral +XNOP 7;XNOP allows the busy +SBUSY 7Signal to come +SDATAIN ;through for the wait +and al, A4PERIPH_MASK +cmp al, EXTENDED_INFO_BYTE ;Mask out the bottom +jne ConnectionFailed ;four bits as the +pop ax yupper four contain +HwSelectChannel ;the peripheral ID +popft +cle ;If it is our hardware +ret 7exit with carry clear + +ConnectionFailedA4NotPresent: + +mov al, (SerialSelect or Asic5Normalld) ;Its not an ASIC4 +SBUSY ;peripheral +SCONTOUT 7By selecting a non +XNOP 7;ASIC4 as an ASIC4, +SDATAIN ;we effectively + + +test al,al + + +Revision 1.00 + + +;disable whatever is + + +Page 100 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +jne ConnectionFailed yout there so we do +mov al, (SerialSelect or Asic5PackId) ja select for all +SBUSY ;possibilities so +SCONTOUT ;that we don't end +XNOP ;up disabling +SDATAIN yanything that we + + +test al,al ;can't control. +jne ConnectionFailed + + +mov al, (SerialSelect or Asic8Id) 7Modem chip id + +SBUSY + +SCONTOUT + +XNOP + +SDATAIN +ConnectionFailed: + +pop ax + +HwSelectChannel + +popft + +stc + +ret + +ProcEnd noret + + +EndCodeSeg + +stack segment stack para 'data' +stack ends + +end A4ExifLDD + + +Revision 1.00 Page 101 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +SYSS$AS5.ASM + + +title ASSPDD Epoc Serial physical device driver for the 16550 +subttl Copyright Psion PLC 1993 +name SYSSAS5 + +i VERSION DATE DESCRIPTION + +me MEE ee ee ee eee + +; Lat 08/12/94 Initial version + +7 Written by Jason December 1994 + +: Serial Driver for Epoc based around ASIC5 + +Sr5s3 = 0 + +Sr5S3a = 1 + +ifdef BUILDS3 + +Sr5S3 = 1. + +Sr5S3a = 0 + +BUILDHH equ 1 + +endif + +a Sr5S3a + +BUILDSB equ 1 + +endif +include ..\inc\epoc.inc +include ..\inc\epocser.inc +include ..\inc\epoclib.inc +include ..\inc\epocsibo.inc +include ..\srcs\ossibo.inc +include ..\srces\ospack.inc + + +Sr5ChannelStruct struc + + +Sr50pen db ? ; Is the channel open +SrKSCtY1L db ? ; State of control lines +Sr5IntVector db 2 ; The Vector number +Sr5Channel db ? ; Which channel are we +Sr5Mask db ? ; InterruptMask +Sr5Running db ; Are we running +Sr5IntRoutineVec dw cs ; Vector to Interrupt +Sr5Baud dw ? ; The baud rate +Sr5LddData dw ? ; Info from Ldd above +Sr5StatusInt dd ? ; Vectors in serial +Sr5Recvint dd 2 ; Above to be called +Sr5XmitInt dd ? ; On input/output +Sr5ClockEnable db ? ; Reason to stop + +Sr5TheLines db ? ; State of the modem lines + + +Sr5ChannelStruct ends + + +A5Ent struc +A5PortA +A5PortB +A5PortBMode +A5PortD +A5Swipel +A5Swipe2 +A5IntMask +A5CtrlReg +A5USR +A5RHR +A5BDLSB +A5SBDMSB +A5MCRIEoi +A5MCRPresentEoi +A5MCR2Eoi +ASDUMMYF + +A5Ent ends + + +Lt Consumer +NumberOfChannels +else +NumberOfChannels +endif +OsActivityMeter +StopTimeOut + + +S_RS2320N + + +Revision 1.00 + + +db +db +db +db +db +db +db +db + + +db +db + + +db +db +db +db +db +db + + +equ + + +equ + + +equ + + +equ + + +equ + + +VVV Vv vw + + +YN vn vv + + +158ch +1000 + + +00000001b + + +at + + +ASIC5 Read/Write +Port A R/W + +Port B R/W +Inc/Mode + +Port CD Write only + + +Ne Ne Ne Ne Ne + + +Interrupt mask R/W +IntType/Ctrl register +UART Status/Ctrl +Receive/Transmit + +Baud Rate write only +Baud Rate write only +MCR shift register +Barcode data&ints + + +’ +’ + + +Ne Ne Ne Ne + + +; S3 Single Channel +, HC,S3C Three Channel + + +; Activity Channel +; w~ls (1000ms) wait + + +7 RS232 on + + +Page 102 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Psion PLC (c) May 1995 + + +S_RSTTLON equ 00000100b ; Line drivers on +S_CENTON equ 00010000b ; Line drivers enable +S_RXENB equ 00000001b ; Receive interrupt on +S_TXENB equ 00000010b ; Transmit interrupt on +S_TXEMPTY equ 00010000b ; transmit buffer empty +S_RXINT equ 00000001b ; Receive interrupt? +S_TXINT equ 00000010b ; transmit interrupt? +S_MDINT equ 00000100b ; Modem status interrupt +S_CTS equ 00000001b # CLS +S_RTS equ 00000010b ; RTS +S_DCD equ 00000100b DCD +S_DSR equ 00000010b ; DCR +S_DTR equ 00000100b ; DIR +OVERRUN_ERROR equ 01000000b ; Character overrun +PARITY_ERROR equ 10000000b ; Parity error +S_PERIPHERALMODE equ 00000011b ; ASIC5 RS232 mode +S_UART_OFF equ 00000010b ; ASIC5 peripheral mode +dgroup group stack +assume ds:dgroup,es:dgroup,ss:dgroup +CodeSeg +ProcBegin@ OsAS5PDD +; SiS SeSe Sees Ses eceses +dw PDDSignature +db 'TTY.SR5',0 +dw (VectorEnd-Vector) /2 +Vector: +dw OsAS5SInstall +dw OsAS5Remove +dw OsAS50Open +dw OsAS5Strategy +VectorEnd: + + +BaudRateTable dw + + +-077f£h, -04£fh, -0368h, -02cch, -027£h, -013fh + + +dw -009fh, -004fh, -0035h, -0030h, -0027h, -0019h +dw -—0013h, -000ch, -0009h, -0004h + + +DataBitsTable db 0,2,4,6 + + +’ + + +5,6,7,8 bits per char frame + + +ParityTable db 08h,18h, 0h, 0h ; Even,Odd,Mark, Space parity +Chan0O Sr5ChannelStruct <> +Chanl Sr5ChannelStruct <> +Chan2 Sr5ChannelStruct <> + + +if Consumer + + +if Asic9 +SetupTable dw offset AS5Int1l +db HwIrq2Revector,mask A9MSlave +db SelectChannel5, (mask A9MClockEnable5 shr 8) +else +SetupTable dw offset AS5Intl +db HwIrq4Revector,mask Asic2Int +db SelectChannel7, (mask ClockEnable7 shr 8) +endif +else +if Asic9 +SetupTable dw offset AS5Int1l +db HwIrq4Revector,mask A9MExpIntA +db SelectChannel3, (mask A9MClockEnable3 shr 8) +dw offset AS5Int2 +db HwIrq5Revector,mask A9MExpIntB +db SelectChannel4, (mask A9MClockEnable4 shr 8) +dw offset ASSInt3 +db HwIrq2Revector,mask A9MSlave +db SelectChannel5, (mask A9MClockEnable5 shr 8) +else +SetupTable dw offset AS5Int1l +db HwIrq3Revector,mask ExpIntLeftA +db ExpChannelLeftA, (mask ClockEnableé shr 8) +dw offset AS5Int2 +db HwIlrq2Revector,mask ExpIntRightB +db ExpChannelRightB, (mask ClockEnable5 shr 8) +dw offset AS5Int3 +db HwIrq4Revector,mask Asic2Int +db SelectChannel7, (mask ClockEnable7 shr 8) +endif +endif + + +ProcEnd noret + + +Revision 1.00 + + +Page 103 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +ProcBegin@ OsAS5Install, far + + +Install the device driver +Out: Carry clear -happy to install + + +cld +mov cx, NumberOfChannels +mov di, offset Chan0od +mov si, offset SetupTable +pushf +cli +push ds +mov ax, Cs +mov ds, ax +ResetAllChannelsLoop: +mov di].Sr50pen, 0 +lodsw +mov di].Sr5IntRoutineVec, ax +lodsb +mov di].Sr5IntVector, al +lodsb +mov di].Sr5Mask, al +lodsb +mov di].Sr5Channel, al +lodsb +mov di].Sr5ClockEnable, al +add di, size Sr5ChannelStruct +loop ResetAllChannelsLoop +pop ds +popft +AllChannelsOkay: +cle +ret + + +Mee Ne + + +Ne Ne Ne Ne + + +GotChan: + + +Revision + + +ProcEnd noret + + +ProcBegin@ OsAS5Remove, far + + +Remove the device driver +Out: Carry clear -happy to remove + + +’ +’ + + +~ + + +Ne Ne Ne Ne + + +Psion PLC (c) May 1995 + + +Clear the channels +and set up fixed +parameters such + +as the interrupt +vectors and masks +for each channel + + +Channel not open + + +Set the interrupt +handler to call +hich Interrupt + + += + + +Mask for that +interrupt + +Which Psion serial +channel + +Baud rate clocking +enable + + +Returns with +Carry clear + + +Carry set -we have an open channel and cant be removed. + + +xor ax, ax +or al, Chan0O.Sr50pen +or al, Chanl.Sr50pen +or al, Chan2.Sr50pen +jz AllChannelsOkay +mov ax, InUseErr + +stc + +ret + + +ProcEnd noret + + +ProcBegin@ OsAS5Open, far + + +Open a serial channel + + +see + + +In: SS:SI is a pointer to the open Ent Structure + + +Out: Carry clear, control block in BX + + +Carry set, error in AX + + +cld + +mov si, [si] .OpenNamePtr +mov al, [sitl] +CharToFoldedChar + +cmp al, 'A' + +jb ErrorInOpen + +sub al, ‘'A' + +cmp al, NumberOfChannels +jae ErrorInOpen + +xoOr ah, ah + +mov bx, offset Chan0O + +cmp al, 1 + +jb GotChan + +mov bx, offset Chan2 + +ja GotChan + +mov bx, offset Chanl + +mov al, 1 + +1.00 + + +If we have a +channel Still open +then return a can't +do error else +complete okay + + +Open the channel +Get the channel +Make Upper Case +Indicator which is +Part of the name +Should be A,B,C + + +What Channel are +We Openning +Pointer to Control +Block in bx + + +Page 104 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +xchg al, cs: [bx].Sr50Open +cmp al, 0 +je OkayToOpen +CantOpen: +mov ax, InUseErr +CantOpenDiffErr: +stc +ret +ErroriInOpen: +mov ax, NameErr +stc +ret +OkayToOpen: +xor al, al +mov cs: [bx].Sr5Running, al +mov cs: [bx].Sr5TheLines, al +mov cs: [bx].Sr5Ctrl, al +mov al, cs: [bx].Sr5Mask +HwGetChannel +jc CantOpenSoClose +call CheckHardwarePresent +jne OpenedOkay +mov al, cs: [bx].Sr5Mask +HwF reeChannel +CantOpenSoClose: +mov cs: [bx].Sr50pen, 0 +mov ax, DeviceErr +jmp short CantOpenDiffErr +OpenedOkay: +xor ax, ax +ret + + +ProcEnd noret + + +AS5StrategyJumpTable label word + + +dw offset AS50Open + +dw offset AS5Close + +dw offset AS5Start +channel + +dw offset AS5Stop + +dw offset AS5Set + +dw offset AS5Sense + +dw offset AS5Control + +dw offset ASS5Enquire + +dw offset AS5Enable + +dw offset AS5SetHandlerCs + + +ProcBegin@ OsAS5Strategy, far + + +Strategy functions entry point + + +Psion PLC (c) May 1995 + + +7 Now try to Open +; That channel + + +; Check that we have +; The right Hardware + + +Return with the +Offset of our +Control Block +In bx + + +Ne Ne Ne Ne + + +; Load Handler offsets +; Close the channel +; Start the + + +7 Stop the channel +; Does nothing +; Returns chan status +; Drive the lines +; Returns baud rate +; Begin Output +; Get Handler segments + + +In: vector number in AX + various data in other registers + + +; Select the correct + +; Output channel +Then Call the right +Function to deal + +; With the strategy + +7; request + + +’ +’ + + +; Interrupts off +;, and flags are on +; the stack + + +7 +7 Warning! This can be called from within Interrupt +7 +iH DS is OsDataGroup (and MUST be preserved) +; Out: DI is pointer to control block +H Old channel and flags on stack + +cld + +mov bx, sp + +mov bx, ss: [bx+4] + +mov bl, cs: [bx].Sr5Channel + +xchg bx, ax + +pushf + +cli + +HwSelectChannel + +mov ah, bh + +xOr bh, bh + +push ax + +mov ax, di + +mov di, sp + +mov di, ss: [dit+8] + +jmp AS5StrategyJumpTable [bx] + + +ProcEnd noret + + +ProcBegin@ AS5Open, far + + +; Old channel and flags on the stack, +mov cs: [di].Sr5LddData, cx +mov word ptr cs: [di].Sr5StatusInt, + + +Revision 1.00 + + +interrupts off + + +; Load the offsets of + + +ax ; the data send and + + +Page 105 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +if + + +else + + +endif + + +mov word ptr cs:[di].Sr5RecvInt, si +mov word ptr cs:[di].Sr5XmitInt, dx +xor ax, ax + +pop ax + +HwSelectChannel + +popft + +ret + + +ProcEnd noret + + +ProcBegin@ AS5Close, far + + +Old channel and flags on the stack, + + +and cs:[di].Sr50Open, 0 +mov al, cs: [di].Sr5Mask +HwF reeChannel + +pop ax + +HwSelectChannel + +popft + +ret + + +ProcEnd noret + + +ProcBegin@ AS5Start, far + + +Old channel and flags on the stack, + + +call CheckHardwareFromStart + +mov dx, 0 + +je CantStartSomethingWhichIsntThere +Asic9 + +in ax, AQWControlExtraRW + +or ah, cs: [di].Sr5ClockEnable + +out A9QWControlExtraRW, ax + +mov al, cs: [di].Sr5ClockEnable +HwSetA2Control2Bits + +mov al, SerialWriteSingle or A5USR +SBUSY + +SCONTOUT + +mov al, cs: [di].Sr5Ctrl + +SBUSY + +SDATAOUT + +mov al, SerialWriteSingle or A5BDLSB +SBUSY + +SCONTOUT + +mov al, byte ptr cs: [di].Sr5Baud +SBUSY + +SDATAOUT + +mov al, SerialWriteSingle or A5BDMSB +SBUSY + +SCONTOUT + +mov al, byte ptr cs: [dit+1].Sr5Baud +SBUSY + +SDATAOUT + +call Get TheInterrupt + +xor CX), Cx + +call DriveRts + +mov al, SerialWriteSingle or A5CtrlReg +SBUSY + +SCONTOUT + +mov al, (S_CENTON or S_RS2320N or +SBUSY + +SDATAOUT + +mov cx, 8 ; 8 ms + +pop dx + +call WaitTimer + +push dx + +mov ah, (S_RXENB or S_TXENB or S_MDINT) +call EnableTheInterrupt + +mov cs:[di].Sr5Running, 1 + +mov bx, Asic5SerialCurrent +HwSetPCurrent + +call Status + + +Revision 1.00 + + +interrupts + + +Psion PLC (c) May 1995 + + +; veceive routines in +; the Ldd above us +; DX=0 —-We don't support +7; power management +; Return the old +; Channel + + +interrupts off + + +; Close the Channel + +; Free up our channel +; And the Hardware + +; Channel + +; Return the old + +; channel + + +off + + +; Start the S3s clock +; Generator + + +; Set the baud rate +; and other +; Characteristics + + +Get the interrupt +and clear down + +the RTS line (DTR +stays at the state +; it was set) + + +’ +’ + + +’ +’ + + +S_RSTTLON) + + +; Switch on the line +; QGrivers and wait +; for them to power up + + +; Start all interrupts + + +Page 106 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +CantStartSomethingWhichIsntThere: + + +pop ax +HwSelectChannel +popft +ret + + +ProcEnd noret + + +ProcBegin@ AS5Stop, far + + +Psion PLC (c) May 1995 + + +; Return the old +; Channel + + +; Old channel and flags on the stack, interrupts off +xor CX, CX ; Clear the state of +call DriveRts ; the modem lines +mov al, SerialReadSingle or A5IntMask ; Stop all of the +SBUSY ; interrupts +SCONTOUT +XNOP +SBUSY +SDATAIN +and al, not (S_TXENB or S_RXENB or S_MDINT) +mov ah, al +mov al, SerialWriteSingle or A5IntMask +SBUSY +SCONTOUT +mov al, ah +SBUSY +SDATAOUT +pop ax +cmp dh, DevHoldPowerFail +je Dont StopHardware +cmp cs:[di].Sr5Running, 1 +jne DontWait +mov cx, StopTimeOut +jmp short CompareNow +WaitForEmpty: +call TickTimer +CompareNow: +mov al, SerialReadSingle or A5USR +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +test al, S_TXEMPTY +loopne WaitForEmpty +DontWait: +cmp bh, DevHoldNormal +je Dont StopHardware +if Asic9 +mov cl, cs: [di].Sr5ClockEnable ; Turn off baud rate +not cl ; Clocking from the +in ax, A9WControlExtraRW } S3y3a +and ah, cl +out A9WControlExtraRW, ax +else +mov al, cs: [di].Sr5ClockEnable +HwClearA2Control2Bits +endif +mov al, SerialWriteSingle or A5CtrlReg ; Stop the drivers +SBUSY , and stuff +SCONTOUT +sub al, al ; Clear S_CENTON, +SBUSY 7 S_RS2320N, S_RSTTLON +SDATAOUT +Dont StopHardware: +mov al, dl ; Return the old +HwSelectChannel ; Channel +popft +xor bx, bx +HwSetPCurrent +ret +ProcEnd noret +ProcBegin@ AS5Set, far +; Se SeSeees ees Sees +; Old channel and flags on the stack, interrupts off + + +Revision 1.00 + + +Page 107 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +; In: Information required is on the stack +pop ax +HwSelectChannel +popft +mov ah, ss:[si].SerialCharTbaud +cmp ah, ss: [si] .SerialCharRbaud +jnz ErrorInSet +cmp ah, P_BAUD_50 +jb ErroriInSet +cmp ah, P_BAUD_19200 +ja ErroriInSet +Got TheSpecialBaud: +dec ah +mov cl, ss:[si].SerialCharFrame +mov al, ss:[si].SerialCharParity +dec al +xor ch, ch +push bx +test cl, P_TWOSTOP +jz OnlyOneStopBit +or ch, 020h +OnlyOneStopBit: +test cl, P_PARITY +jz NoParity +mov bx, offset ParityTable +xlat cs: [ParityTable] +or ch, al +NoParity: +mov bx, offset DataBitsTable +and cl, P_DATA_FRM +mov al, cl +xlat cs: [DataBitsTable] +Or ch, al +mov bx, offset BaudRateTable +mov al, ah +xOr ah, ah +shl ax, 1 +add bx, ax +mov ax, cs: [bx] +pop bx +mov es? [dt] .Sractrl; ch +mov cs:[di].Sr5Baud, ax +xOr al, al +ret +ErroriInSet: +mov al, NotSupportedErr +stc +ret + + +ProcEnd noret + + +ProcBegin@ AS5Sense, far + + +seo + + +’ + + +’ + + +’ + + +’ + + +~ + + +Psion PLC (c) May 1995 + + +Return the old +channel + + +Set the Recieve, +Transmit characteristics +First set the Baud + +Rate + + +Then the number of +Stop bits + + +The Parity + + +And finally the +Number of data bits +Per frame + + +; Old channel and flags on the stack, interrupts off +; Out: The state of the DCD,CTS,DSR lines returned in DX +call Status +pop ax ; Return the old +HwSelectChannel ; Channel +popft +ret + + +ProcEnd noret + + +ProcBegin@ Status + + +i Out: State of modem lines in DX +mov al, SerialReadSingle or A5USR +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +and al, (S_CTS or S_DSR or S_DCD) +xor al, (S_CTS or S_DSR or S_DCD) +xOr ah, ah + + +Revision 1.00 + + +see + + +Get the current +Modem status +Lines and return +With the result +In dx + + +Get the lines we want +Invert signals + + +Page 108 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +mov ax, ax +ret +ProcEnd noret + + +ProcBegin@ AS5Control, far + + +; Old channel and flags on the stack, interrupts off + +7 In: Lines to drive and state to drive them in DX +mov onl emo ie ; Set the state of one +test dh, P_SRCTRL_DTR ; of the modem Lines +jz DriveRtsNow ; DH is the line to +call DriveDtr ; Drive and DL is the +pop ax ; Stateto drive it to +HwSelectChannel ; Return the old +popft ; channel +ret + +DriveRtsNow: +call DriveRts +pop ax ; Return the old +HwSelectChannel ; channel +popft +ret + + +ProcEnd noret + + +ProcBegin@ DriveDtr + + +mov ah, S_DTR ; Set/Reset the DTR +jmp short DriveTheLine ; Line +ProcEnd noret + + +ProcBegin@ DriveRts + + +mov ah, S_RTS ; Set/Reset RTS +DriveTheLine: +mov al, SerialWriteSingle or A5PortD ; Common code to set +SBUSY ; and reset either +SCONTOUT ; line while +mov al, cs:[di].Sr5TheLines ; preserving the +test cl, cl ; states of the other +IZ ClearLine ; lines +or al, ah +jmp DoTheOutput +ClearLine: +not ah +and al, ah +DoTheOutput: +mov cs:[di].Sr5TheLines, al +SBUSY +SDATAOUT +ret + + +ProcEnd noret + + +ProcBegin@ AS5Enquire, far + + +7 Old channel and flags on the stack, interrupts off +- Out: DX,AX are the supported baud rates AX for 50 to 19200 DX for above +; CX says what data bits, parity, etc we support +pop ax ; Return the old +HwSelectChannel ; Channel +popf +if Asic9 +mov ax, —-1 +else +mov ax, O7fffh +endif +xor dx, ax +mov cx, (Offffh AND (NOT (P_SRINQ_SPLIT OR P_SRINQ_PARSPACE OR +P_SRINQ_PARMARK) ) ) +ret + + +ProcEnd noret + + +ProcBegin@ AS5Enable, far + + +Revision 1.00 Page 109 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Psion PLC (c) May 1995 + + +- Old channel and flags on the stack, interrupts off +mov ah, S_TXENB ; Begin Output by +call EnableTheInterrupt ; enabling transmit +pop ax ; interrupts +HwSelectChannel ; Return the old +popft ; channel +ret + + +ProcEnd noret + + +ProcBegin@ AS5SetHandlerCs, far + + +CX is CS of above LDD + + +sew + + +mov word ptr cs: [di]. (Sr5StatusInt+2), cx +mov word ptr cs:[di].(Sr5RecvInt+2), cx +mov word ptr cs: [di]. (Sr5XmitInt+2), cx +pop ax + +HwSelectChannel + +popft + +ret + + +ProcEnd noret + + +ProcBegin@ AS5Int3, far + + +mov di, offset Chan2 +mov ax, PortCActive +jmp ComInt + + +ProcEnd noret + + +ProcBegin@ AS5Int2,far + + +mov di, offset Chanl +mov ax, PortBActive +jmp ComIint + + +ProcEnd noret + + +ProcBegin@ AS5Int1,far + + +mov di,offset Chan0 +mov ax, PortAActive +4 FALL THROUGH + + +ProcEnd noret + + +ProcBegin@ ComInt, far + + +The common interrupt handler +DS points to OS data space +DI is our control block + + +Mee Ne + + +; AX is the Active channel +ab S3b or S3c + +or ds: [OsActivityMeter], ax +endif + +mov al, cs: [di].Sr5Channel + +HwSelectChannel + +push ax + +mov bx, cs: [di].Sr5LddData +TheInterruptLoop: + +mov al, SerialReadSingle or A5CtrlReg + +SBUSY + +SCONTOUT + +XNOP + +SBUSY + +SDATAIN + +test al, al + +je NothingToDo +HaveWeGotAModemStatusLineInterrupt: + +test al, S_MDINT + +4z HaveWeGotARecievelInterrupt + +mov al, SerialReadSingle or A5USR + +SBUSY + +SCONTOUT + + +Revision 1.00 + + +~ + + +Mee Ne + + +Old channel and flags on the stack, interrupts off + + +; Load the Segment + +; Within which the +The Ldd above us +Return the old +channel + +; Resides + + +Channel 3 interrupt +vector +Jumps to Comint + + +see + + +~ + + +Channel 2 interrupt +vector +Jumps to Comint + + +seo + + +~ + + +Channel 1 interrupt +7; vector + +; Falls through + +7 to Comint + + +; Set active state + + +; Select our +; Channel + + +; Data for LDD above +; in bx + +; Find out what + +; caused the + +; interrupt + + +Page 110 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +Psion PLC (c) May 1995 + + +; Something has been +; recieved in error + + +; Establish the error + + +; Get the character +; in question + + +; invert signals + + +XNOP +SBUSY +SDATAIN +test al, (OVERRUN_ERROR or PARITY_ERROR) +jz ModemStatusInterruptOnly +push ax +mov ah, SERPARITY_ERR +test al, PARITY_ERROR +jnz IsAParityError +mov ah, SEROVERRUN_ERR +IsAParityError: +mov al, SerialReadSingle or A5RHR +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +push di +call dword ptr cs: [di] .Sr5RecvInt +pop di +pop ax +ModemStatusInterruptOnly: +and ax, (S_CTS or S_DSR or S_DCD) +xor al, (S_CTS or S_DSR or S_DCD) +mov ax, ax +push di +call dword ptr cs: [di].Sr5StatusInt +pop di +jmp short TheInterruptLoop + + +HaveWeGotARecievelInterrupt: + + +; AX has character received + + +Resced if neccessary + + +; Gisable TX interrupts + + +test al, S_RXINT +jz HaveWeGotATransmitInterrupt +mov al, SerialReadSingle or A5RHR +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +xOr ah, ah +push di +call dword ptr cs: [di] .Sr5RecvInt +pop di +jmp short TheInterruptLoop +HaveWeGotATransmitInterrupt: +test al, S_TXINT +jz NothingToDo +push di +call dword ptr cs: [di] .Sr5XmitInt +pop di +test ax, ax ; —-l1 if disable +js DisableTransmitInts +mov ah, al +mov al, SerialWriteSingle or A5RHR +SBUSY +SCONTOUT +mov al, ah +SBUSY +SDATAOUT +jmp TheInterrupt Loop +NothingToDo: +if Asic9 +out A9BNonSpecificEoiwW, al +else +out AlNonSpecificEoi, al +endif +pop ax +HwSelectChannel +cle ; +ret +DisableTransmitInts: +mov al, SerialReadSingle or A5IntMask +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +and al, not S_TXENB +mov ah, al +mov al, SerialWriteSingle or A5IntMask +SBUSY + + +Revision 1.00 + + +Page 111 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +SCONTOUT +mov +SBUSY +SDATAOUT +jmp TheInterrupt Loop +ProcEnd noret + + +al, ah + + +ProcBegin@ GetTheInterrupt + + +mov al, cs:[di].Sr5IntVector H +mov Cx, CS F +mov bx, cs:[di].Sr5IntRoutineVec ; +GenSetRevector A +ret , + + +ProcEnd noret + + +ProcBegin@ EnableTheInterrupt + + +mov al, SerialReadSingle or A5IntMask +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +or ah, al +mov al, SerialWriteSingle or A5IntMask +SBUSY +SCONTOUT +mov al, ah +SBUSY +SDATAOUT +if Asic9 +in al, A9BInterruptMaskRW ; +or al, cs: [di].Sr5Mask ; +out A9BInterruptMaskRwW, al +else +in al, AlInterruptMask +or al, cs: [di] .Sr5Mask +out AlInterruptMask, al +endif +ret +ProcEnd noret +ProcBegin@ StopInterrupts +; StessSeSesee—e-Seeeseeese +mov al, SerialReadSingle or A5IntMask H +SBUSY ; +SCONTOUT +XNOP +SBUSY +SDATAIN +and al, not (S_RXENB or S_TXENB or S_MDINT) +mov ah, al +mov al, SerialWriteSingle or A5IntMask +SBUSY +SCONTOUT +mov al, ah +SBUSY +SDATAOUT +mov ah, cs: [di].Sr5Mask +not ah +if Asic9 +in al, A9BInterruptMaskRW ; +and al,ah ; +out A9BInterruptMaskRW, al ; +else ; +in al, AlInterruptMask +and al,ah +out AlInterruptMask, al +endif +mov al, cs:[di].Sr5IntVector +GenResetRevector +ret + + +Revision 1.00 + + +Psion PLC (c) May 1995 + + +Load the address of +the appropriate +interrupt routine +into the correct +vector + + +Set the mask +to enable Interrupts + + +Stop interrupts +from Asic5 + + +Stop Interrupts +By clearing the + + +Mask and resetting +The Vector + + +Page 112 of 115 pages + + +The Psion SIBO Hardware Development Kit + + +ProcEnd noret + + +ProcBegin@ CheckHardwarePresent + + +mov al, cs: [bx] .Sr5Channel +HwSelectChannel +HwNullFrame +mov al, (SerialSelect or Asic5Normalld) +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +test al,al +je ConnectionFailed +GotConnection: +popft +ous) +ret +ConnectionFailed: +mov al, +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +test +jne +mov +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +test +jne +mov +SBUSY +SCONTOUT +XNOP +SBUSY +SDATAIN +ConnectionFailedExit: +popft +stc +ret +ProcEnd noret + + +SerialSelect or Asic4Id + + +al, al +ConnectionFailedExit +al, SerialSelect or Asic8Id + + +al, al +ConnectionFailedExit +al, SerialSelect or Asic5PackId + + +ProcBegin@ CheckHardwareFromStart + + +pushf + +HwNullFrame + +mov al, (SerialSelect or Asic5Normalld) +SBUSY + +SCONTOUT + +XNOP + +SBUSY + +SDATAIN + +test al,al + +je ConnectionFailed + +test al, mask A5MultiDrop + +jne ConnectionFailedExit + +popft +mov +SBUSY +SCONTOUT +mov +SBUSY +SDATAOUT +cle + +ret +ProcEnd noret + + +al, + + +al, S_PERIPHERALMODE + + +ProcBegin@ WaitTimer + + +Revision 1.00 + + +SerialWriteSingle or A5PortBMode + + +Ne Ne Ne Ne te + + +Ne Ne Ne Ne Ne + + +’ + + +Psion PLC (c) May 1995 + + +Check that the +; Harware is there + + +And that it is what +It should be + +First look for An +ASIC4 at the other +End of the link + + +’ + + +’ + + +’ + + +Asic4 Id + + +Modem chip Id + + +Asic5Spack Id + + +Check that the +Harware is there +First look for An +ASIC5 at the other +End of the link + + +’ +’ +’ + + +If not a 3link or +if in multidrop +mode then we are +in trouble + + +Put the 3Link in +peripheral mode + + +Page 113 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +In: CX number of ms to wait for +Channel store in DL +Out: Channel store in DL + + +Wait for a given + + +inc cx i + +WaitTickLoop: ; Number of ms +call TickTimer ; Plus one to guarantee +loop WaitTickLoop ; That at least cx ms +ret 7 Go by +ProcEnd + + +WaiterLoop: + + +stack +stack + + +ProcBegin@ TickTimer + + +Uses writes down our channel to simulate tick timer waits + +Must allow interrupts so other things can run -we will be here +for 1/1000 of a second and may be called many times +ChannelStore in/out in DL + + +mov al, dl ; Return the old +HwSelectChannel ; Channel + +mov ah, al +pushf + +sez + +push Cx + +mov cx, 12 ims + +128 frames =1lms + +pushf about 12 times + +cli 7 round the loop + +out ResetWatchDog, al + +mov al, ah + +HwSelectChannel + +mov dl, al ; Get Correct channel +mov al, (SerialWriteSingle or 0) Do a write to + +SBUSY nowhere and + +SCONTOUT waste some time + + +See Ne + + +See Ne + + +SCONTOUT ; Do it eight times + + +SBUSY +SCONTOUT +SBUSY +mov al, dl +HwSelectChannel +mov ah, al +popft + +loop WaiterLoop +pop CX + +popft + +mov al, ah +HwSelectChannel +mov dl, al +ret + +ProcEnd + + +Return the old +channel + + +’ +’ + + +EndCodeSeg + + +segment stack para 'data' +ends + + +end OsAS5PDD + + +Revision 1.00 Page 114 of 115 pages + + +The Psion SIBO Hardware Development Kit Psion PLC (c) May 1995 + + +Assembler Macros + + +Excerpts from the include file ossibo.inc. + + +if ASIC1 +SCONTOUT macro +out A2SerialControl, al +endm +SDATAOUT macro +out A2SerialData, al +endm +SBUSY macro +wait +endm +SREAD macro _REG +mov al, SerialReadSingle or _REG +out A2SerialControl, al +nop +SBUSY +in al, A2SerialData +endm +SREADM macro _REG +mov al, SerialReadMulti or _REG +out A2SerialControl, al +nop +SBUSY +in al, A2SerialData +endm +SWRITE macro _REG,_VAL +mov al, SerialWriteSingle or _REG +out A2SerialControl, al +SBUSY +mov al, _VAL +out A2SerialData, al +endm +SWRITEM macro _REG,_VAL +mov al, SerialWriteMulti, _REG +out A2SerialControl, al +SBUSY +mov al, _VAL +out A2SerialData, al +endm +endif +ach ASIC9 +SCONTOUT macro +out A9BSerialControlW, al +endm +SDATAOUT macro +out A9BSerialDataRW, al +endm +SDATAIN macro +in al, A9BSerialDataRW +endm +SBUSY macro +endm +SREAD macro _REG +mov al, SerialReadSingle or _REG +out A9BSerialControlwW, al +in al, A9BSerialDataRW +endm +SREADM macro _REG +mov al, SerialReadMulti or _REG +out A9BSerialControlwW, al +in al, A9BSerialDataRW +endm +SWRITE macro _REG,_VAL +mov al, SerialWriteSingle or _REG +out A9BSerialControlwW, al +mov al, _VAL +out A9BSerialDataRW, al +endm +SWRITEM macro _REG,_VAL +mov al, SerialWriteMulti or _REG +out A9BSerialControlwW, al +mov al, _VAL +out A9BSerialDataRW, al +endm +endif + + +Revision 1.00 Page 115 of 115 pages + + diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_djvu.xml b/code/HDK/Psion SIBO Hardware Development Kit 1.0_djvu.xml new file mode 100755 index 0000000..697808e --- /dev/null +++ b/code/HDK/Psion SIBO Hardware Development Kit 1.0_djvu.xml @@ -0,0 +1,74702 @@ + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + THE + PSION + SIBO + HARDWARE + DEVELOPMENT + KIT + + + + + + + + + Version + 1.00 + + + + + + + + + May + 26 + 1995 + + + + + + + + + Revision + 1.00 + Page + i + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + (c) + Copyright + Psion + PLC + 1990-93 + + + + + + + + + All + rights + reserved. + This + manual + and + the + programs + referred + to + herein + are + copyrighted + works + of + Psion + + + PLC, + London, + England. + Reproduction + in + whole + or + part, + including + utilisation + in + machines + capable + of + + + reproduction + or + retrieval, + without + express + written + permission + of + Psion + PLC, + is + prohibited. + Reverse + + + engineering + is + also + prohibited. + + + + + + + + + The + information + in + this + document + is + subject + to + change + without + notice. + + + + + + + + + Psion + and + the + Psion + logo + are + registered + trademarks, + and + Psion, + Psion + MC, + Psion + HC, + Psion + Series + 3, + + + Psion + Series + 3a + and + Psion + Workabout + are + trademarks + of + Psion + PLC. + + + + + + + + + TopSpeed + is + a + registered + trademark + of + Clarion + Software + Corporation. + Intel + 8086 + and + 80286 + are + + + registered + trademarks + of + Intel + Corporation. + IBM, + IBM + XT + and + IBM + AT + are + registered + trademarks + of + + + International + Business + Machines + Corp. + Microsoft + and + MS-DOS + are + registered + trademarks + of + + + Microsoft + Corporation. + Apple + and + Macintosh + are + registered + trademarks + of + Digital + Equipment + + + Corporation. + Brief + is + a + registered + trademark + of + Underware + Inc. + Psion + PLC + acknowledges + that + some + + + other + names + referred + to + are + registered + trademarks. + + + + + + + + + Revision + 1.00 + Page + ii + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Contents + + + + + + + + + + + + De + IMGrOMUCUON + sec + ioiciescccetisshicattxstcathaslicatixssdcstenslacatenstecatenslicatinssdesvenslacevinswdvatensldcsvisatibiteislacibedse + + + + + + + + + 2. + System + Overview..........scccccscssccssssscscsscsseccsscssecssccsesssscssesssscsssesscssesssssesssscssssssscssssssscsessssesesseeees + + + + + + + + + 3. + Hardware + Overview + .........sssccssssssssssscssscssscsssssssesssesssesssesssesssssssssessscssscsssessesssesssnssseesscseoeeees + + + The + Psion + SIBO + serial + protocol + .... + + + Psion + ASICs + and + what + they + do.. + + + Interrupts + . + + + The + current + range + of + Psion + periphera + + + + + + + + + 4. + The + Psion + SIBO + Serial + Protocol + . + + + Hardware + Interface + ... + + + The + Physical + layer + . + + + The + Transport + layer + .. + + + + + + + + + 5. + Mechanical + Overview + ...........sscssscsssssrscsssssessscessecssessessssesseessessscesssessesscssssssscsssessccssesssessosees + LD + + + The + Psion + Series + 3/3a + range + ... + + + The + Psion + Workabout + + + The + Psion + HC + range + + + + + + + + + 6. + ASIC + 4......... + + + ASIC4 + Addressing + and + Modes + + + Reset + and + configuration + + + ASIC4 + Pin-out + + + + + + + + + 7. + ASIC + 5.......scesee + + + ASICS + Mode + + + Reset + and + configuration + + + ASICS + Pin-out + + + + + + + + + 8. + Example + Peripheralls................cccssccssssssssssssseccsscscccssssscsssscccesssscscesssssesssscsssssssssesscsssssscsseeesess + OO + + + The + ASIC4 + Example + Interface + Board.. + + + The + Psion + 3-Link + + + + + + + + + 9. + Device + Driver + Overview...........cccsrsercesssserscersserecssecssesscesssesesssessssessesssesscsscssscsssssssesssessosees + OT + + + Introduction + + + Device + Names + and + Channel: + + + Loadable + Logical + Device + Driver + Structure + + + Mandatory + LDD + Functions + ............... + + + Interrupts + and + Interrupt + Service + Routines + at + + + Loadable + Physical + Device + Driver + Structure... + ccscecesesesseesssesssesesssesesesescseseseenenesesesesesesenenesseesesesusueasaeaeseeessecacaeaeaeenenssesecasaseeeeeneeeeeaeaes + + + + + + + + + 10. + ASIC4/ASIC5 + Based + Device + Drivers + + + + + + + + + Introduction + + + SIBO + Hardware + Expansion + Channels + + + Talking + to + ASIC4.. + + + ASIC4 + Registers + + + Talking + to + ASICS + .. + + + ASICS + Registers... + + + Communicating + with + ASIC4 + + + Sending + and + Receiving + data + using + ASIC4. + + + Obtaining + and + using + a + channel... + + + Controlling + ASICS's + UART + + + Hold + and + Resumes. + + + Example + Device + Driver: + + + + + + + + + 11. + An + Example + Device + Driver + for + ASIC4: + A4EXIF.LDD.. + + + + + + + + + Introduction + + + + + + + + + oo + TO + eR + UU + RS + gs + pad + + + + + + + + + Mandatory + LDD + Function: + + + The + Non-Mandatory + LDD + Functions..........cceee + + + The + handling + of + synchronous + and + asynchronous + I/O + + + Interrupts + and + Interrupt + Service + Routines + + + Other + important + local + device + driver + functions + + + Structures + and + Include + files + «0... + cee + + + + + + + + + 12. + An + Example + Device + Driver + for + ASIC5: + SYS$AS5.PDD.............ssssssssssssssessessessssesscsessessesseee + 77 + + + + + + + + + Introduction + + + The + LDD-PDD + interface. + + + + + + + + + 13. + Debugging + and + Testing + Device + Drivers + + + Introduction + .... + + + Debugging + Techniqu + + + Further + Testing + Strategies + ae + + + Memory + Lestitng + seiscs + lech + easch + oiece + siscn + Sates + losecdestecwcsautsse + sean + tosevaleslosedtracepudtesiiensdertoanioenteoisebeensse + bait + es + ieettaus + adanus + teats + a + a + tanta + eae + + + + + + + + + APPENDIX: + Source + Code + Files.. + + + A4EXIF.ASM + oo + + + SYS$AS5.ASM + .... + 102 + + + Assembler + Macros. + 1S + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + iii + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 1. + INTRODUCTION + + + + + + + + + This + document + is + intended + to + provide + guidance + to + anyone + wishing + to + construct + peripherals + for + the + + + Psion + SIBO + (sixteen + bit + organiser) + range + of + computers. + It + describes + in + detail + all + aspects + of + Psion + + + peripheral + hardware + development + and + the + structure + of + the + software + required + to + drive + such + peripherals. + + + It + is + the + aim + of + this + document + to + aid + third + party + development + engineers + in + producing + production + ready + + + peripherals + for + any + of + the + following + Psion + products: + Series + 3/3a, + Workabout, + HC + and + HCDOS. + + + Mechanical + and + plastic + moulding + information + and + information + on + how + to + develop + production + test + + + equipment + is + therefore + also + included. + The + emphasis + throughout + is + on + the + two + key + Psion + peripheral + + + chips + ASIC4 + and + ASIC5. + Detailed + information + regarding + their + functionality + is + provided. + The + + + structure + of + Psion + hardware + device + drivers + is + examined + both + in + general + outline + and + then + with + regard + to + + + two + specific + examples + whose + source + code + is + provided + in + the + appendix + to + this + document. + It + has + been + + + assumed + that + the + reader + has + some + knowledge + of + a + Psion + computer + such + as + the + Series + 3/3a + and + an + + + understanding + of + how + such + a + machine + is + programmed. + A + good + understanding + of + electronics, + the + C + + + programming + language + and + 8086 + assembler + is + also + assumed. + + + + + + + + + Due + to + the + continuous + nature + of + development, + information + in + this + manual + may + change + without + notice. + + + + + + + + + Developers + are + advised + to + contact + Psion + Support + to + confirm + critical + details + prior + to + committing + + + products + to + manufacture. + + + + + + + + + Revision + 1.00 + Page + | + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 2. + SYSTEM + OVERVIEW + + + + + + + + + All + present + Psion + computers + are + based + around + the + proprietary + SIBO + architecture. + A + SIBO + machine + is + + + a + battery-powered, + 8086-based, + computer + system. + SIBO + stands + for + SIxteen + Bit + Organiser. + The + + + architecture + has + been + designed + with + the + size, + weight + and + power + consumption + of + computers + designed + + + for + the + portable + environment + in + mind. + The + key + components + of + the + SIBO + architecture + are: + + + + + + + + + e + —_ + An + 8086 + class + processor + . + + + + + e + A + sophisticated + power + management + system + that + selectively + powers + subsystems + under + software + + + control. + + + + + e + + Asynchronous, + high + speed, + serial + protocol + (the + Psion + SIBO + serial + interface) + for + communication + + + between + a + machine + and + its + peripherals. + + + + + e + —_ + Solid + State + Disks + (SSDs) + that + provide + fast, + low-power, + silicon-based + mass + storage + with + no + + + moving + parts. + + + + + e + Hardware + protection + of + the + system + from + aberrant + software + processes + (trapping + of + out + of + range + + + + + addressing + and + a + watch-dog + timer + on + interrupts + being + disabled). + + + + + Real-time + clock. + + + + + ROM-resident + system + software. + + + + + Graphics + LCD + display. + + + + + A + touch + sensitive + digitising + pad + that + provides + a + pointing + device + (only + available + on + some + models). + + + + + ISDN-8bit + standard + combo + sound + system + (only + available + on + some + models). + + + + + + + + + The + SIBO + architecture + has + primarily + been + implemented + in + custom + ICs + called + ASICs. + At + the + time + of + + + writing + there + are + ten + different + SIBO + ASICs. + Some + of + these + ASICs + have + been + designed + for + use + inside + + + peripherals + and + these + will + discussed + in + detail + throughout + this + document. + All + SIBO + ASICs + have + been + + + implemented + in + surface + mount + packages + and + are + based + on + a + static + CMOS + technology. + Current + SIBO + + + products + in + the + MC, + HC + and + Series + 3 + range + are + based + on + the + same + three + principal + chips. + These + are + + + the + V30H + (an + 8086-compatible + processor) + and + two + Psion + custom + chips + known + as + ASIC1 + and + ASIC2. + + + Later + SIBO + products + including + the + Series + 3a + and + Workabout + have + these + three + devices + integrated + into + a + + + single + Psion + custom + chip + known + as + ASIC9. + The + V30H + is + an + enhanced + 16-bit + CMOS + version + of + the + + + 8088 + found + in + the + original + IBM + PC. + It + is + software + compatible + with + the + 8088. + The + V30H + is + a + fully + + + static + design + which + means + that + all + the + internal + storage + elements + (i.e. + its + registers) + are + made + from + static + + + rather + than + dynamic + storage + components. + This + in + turn + means + that + there + is + no + minimum + clock + speed + + + required + to + refresh + the + storage + elements + and + the + system + clock + can + be + stopped + at + any + time + with + no + loss + + + of + internal + state. + This + technique + is + used + extensively + in + the + SIBO + architecture + to + save + power + while + the + + + processor + is + idle + (i.e. + waiting + for + an + event). + + + + + + + + + The + Psion + SIBO + serial + protocol + is + a + proprietary + synchronous + two + wire + serial + standard + by + which + host + + + Psion + handhelds + communicate + with + external + devices. + These + devices + will + typically + be + Memory + Packs + + + (usually + referred + to + as + Solid + State + Disks + or + SSDs), + RS232 + and + Centronics + printer + interfaces, + fax + + + modems, + bar-code + scanners, + and + so + on. + The + SIBO + architecture + provides + for + two + basic + forms + of + + + expansion + device, + namely + the + extended + internal + expansion + connection + (as + with + SSDs) + and + the + reduced + + + external + expansion + connection + (the + 6-pin + S3a + serial + port + or + the + 11-pin + LIF + connector). + The + MC + and + + + HC + range + of + computers + have + two + SSD + ports + and + two + separate + independent + single + row + 25-way + + + extended + internal + expansion + ports. + These + ports + have + in + addition + to + a + Psion + SIBO + Channel, + direct, + + + parallel + I/O + from + the + processor. + Direct + connection + to + these + machines + 7.2 + volt + battery + is + included + to + + + support + high + power + peripherals + such + as + Printers + and + Barcode + readers. + The + Series + 3 + range + of + + + computers + have + two + ports + for + SSDs + and + a + single, + reduced, + 6-pin + expansion + port, + which + provides + only + a + + + Psion + SIBO + serial + channel + and + limited + power + (<25mA). + The + Psion + Workabout + has + two + SSD + ports, + + + two + internal + expansion + points, + and + one + external + expansion + port. + The + single + external + expansion + port + + + uses + an + | + 1-pin + Low + Insertion + Force + (LIF) + socket + which + provides + a + Psion + SIBO + channel, + 25mA + of + + + current + and + additional + lines + required + for + detecting + the + presence + of + the + Workabout + cradle. + Each + + + internal + expansion + port + consists + of + a + single + row + 26-way + connector + carrying + two + high + speed + serial + + + ports. + + + + + + + + + Revision + 1.00 + Page + 2 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + A + range + of + Psion + peripherals + have + been + produced + for + connection + to + the + Psion + handhelds + outlined + + + above. + These + peripherals + currently + incorporate + one + of + two + custom + integrated + circuits + (ASIC4 + and + + + ASICS) + that + convert + SIBO + serial + protocol + signals + to + data + bus + TTL + level + voltages + which + enable + + + memory + and + memory-mapped + peripherals + to + be + addressed. + ASIC4 + is + used + in + SSDs + and + for + memory- + + + mapped + peripherals. + A + typical + ASIC4 + peripheral + for + a + Psion + S3a + would + consist + of + an + ASIC4 + + + connected + to + port + C + of + the + host + machine + and + a + peripheral + chip/device + mapped + into + ASIC4's + addressing + + + space. + ASICS + is + a + general + purpose + I/O + chip + with + a + UART + on + board + that + can + be + run + in + several + + + different + modes. + For + example + ASICS + can + be + used + for + MCRs + (magnetic + card + readers) + or + Centronics + + + interfaces + thereby + simplifying + peripheral + design. + Psion + extended + internal + expansion + ports + carries + an + + + active + low + interrupt + input + line + to + the + host + controller + circuitry. + The + reduced + external + expansion + ports + + + has + an + active + high + interrupt + input + line. + The + function + of + the + interrupt + can + thus + be + programmed + into + the + + + host + machine's + ASIC1 + or + ASIC9. + + + + + + + + + The + low-level + programming + interface + to + a + Psion + handheld + peripheral + is + encapsulated + within + an + + + appropriate + device + driver. + Psion + device + drivers + are + written + in + 8086 + assembler + and + follow + a + prescribed + + + pattern + outlined + later + in + this + document. + The + construction + of + a + peripheral + and + the + coding + of + its + + + complimentary + device + driver + enable + the + developer + to + access + its + functionality + through + the + means + of + + + library + calls + in + a + C + program. + Examples + of + such + calls + are + p_loadldd(), + p_open() + and + p_close(). + + + I/O + requests + are + routed + through + the + device + driver's + strategy + vector + which + maps + to + the + PLIB + p_iow + () + + + call. + The + device + driver + is + built + using + the + Borland + Turbo + Assembler + and + resides + in + a + single + code + + + segment. + The + device + driver + can + be + stored + in + either + RAM + or + a + ROM + on + board + the + peripheral + or + can + be + + + supplied + on + an + SSD + (solid + state + disk). + + + + + + + + + Revision + 1.00 + Page + 3 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 3. + HARDWARE + OVERVIEW + + + + + + + + + The + Psion + SIBO + serial + protocol + + + + + + + + + The + Psion + SIBO + serial + protocol + is + a + general + purpose + method + of + bi-directional + serial + data + transfer. + It + + + has + been + designed + for + synchronous + communication + between + a + host + controlling + device + and + a + number + of + + + slave + devices. + On + a + hardware + level, + the + SIBO + serial + protocol + is + implemented + through + Psion + ASICs. + + + The + controlling + device + must + contain + an + ASIC2 + (or + ASIC9) + and + the + slave + devices + an + ASIC4 + or + ASICS. + + + The + various + Psion + ASICs + are + described + in + more + detail + below. + + + + + The + synchronous + SIBO + serial + protocol + interface + consists + of + 2 + wires: + + + + + CLK + ~ + - + Aclock + output + from + the + controller + to + the + slaves. + Nominally + 3.84 + MHz. + + + + + DATA + - + A + bi-directional + synchronous + data + line. + + + + + The + data + is + transferred + using + a + series + of + 12 + bit + frames + including + 8 + data + bits + each. + This + equates + to + a + + + theoretical + maximum + data + transfer + rate + of + approximately + 312 + Kbytes/second. + Other + bits + of + the + frame + + + contain + control + information. + The + "system" + is + generically + defined + by + 2 + protocol + layers, + namely + the + + + Physical + layer + and + the + Transport + layer. + These + layers + are + described + in + detail + in + the + next + chapter. + + + + + + + + + Psion + ASICs + and + what + they + do + + + + + + + + + ASIC + stands + for + Application + Specific + Integrated + Circuit + and + as + previously + indicated, + these + devices + are + + + widely + used + within + Psion + hardware. + Summaries + of + the + functionality + of + each + ASIC + that + is + relevant + to + + + peripheral + development + are + presented + below: + + + + + + + + + ASIC1: + ASIC1 + is + the + main + system + controller + chip + for + the + SIBO + architecture. + It + connects + directly + to + + + the + 8086-based + processor + (i.e. + the + V30H) + controlling + all + bus + cycles + to + and + from + the + processor. + This + + + configuration + effectively + forms + a + micro-controller + like + device + that + executes + 8086 + instruction + codes. + + + ASIC + 1 + is + made + up + of + a + number + of + functional + blocks + including + a + bus + controller, + a + programmable + + + timer, + an + eight + input + interrupt + controller, + an + LCD + controller + and + the + memory + decoding + circuitry. + + + + + + + + + ASIC2: + ASIC2 + is + the + peripheral + controller + chip + for + the + SIBO + architecture. + It + contains + the + system + + + clock + oscillator + and + controls + switching + between + the + standby + and + operating + states. + ASIC2 + provides + an + + + interface + to + the + power + supply, + keyboard, + buzzer + and + SSDs. + ASIC + 2 + includes + the + eight-channel + SIBO + + + serial + protocol + controller + and + provides + interface + circuitry + to + both + the + reduced + external + and + extended + + + internal + peripheral + expansion + ports. + + + + + + + + + ASIC4: + ASIC4 + is + a + serial + protocol + slave + IC + for + addressing + memory + and + general + memory-mapped + + + peripherals. + It + is + used + in + SSDs + to + convert + SIBO + serial + protocol + signals + into + addresses + within + the + + + memory + range + of + the + memory + pack. + ASIC4 + was + designed + to + be + a + cut-down + version + of + ASICS + which + + + was + the + original + SIBO + serial + protocol + slave + chip. + + + + + + + + + ASICS: + ASICS + is + a + general + purpose + I/O + chip + with + a + built-in + UART + that + can + be + set + to + run + in + a + number + + + of + different + modes + thereby + simplifying + the + task + of + peripheral + design. + For + example, + it + is + possible + to + set + + + up + ASICS + to + run + as + a + Centronics + parallel + port + interface, + an + 8-bit + parallel + I/O + port, + a + serial + bar + code + + + controller + or + a + serial + RS232 + converter. + + + + + + + + + ASIC9: + ASIC9 + is + a + composite + chip + comprising + of + a + V30H + processor, + ASIC1, + ASIC2 + and + general + I/O + + + and + PSU + control + logic + all + on + one + IC. + ASIC9 + thus + integrates + all + the + digital + logic + required + to + produce + a + + + SIBO + architecture + computer + less + the + memory + onto + one + chip. + ASIC9 + has + a + few + additional + features + + + such + as + an + extra + free-running + clock + (FRC) + and + a + codec + interface + for + sound. + + + + + + + + + Revision + 1.00 + Page + 4 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Interrupts + + + + + + + + + Psion + peripherals + usually + incorporate + some + circuitry + to + generate + hardware + interrupts. + Both + reduced + + + external + expansion + ports + (such + as + the + LIF + connector + on + the + Workabout + or + the + 6-pin + serial + port + + + connector + on + the + S3a) + and + extended + internal + expansion + ports + (such + as + the + two + single + row + 25-way + HC + + + connectors) + carry + an + interrupt + line. + This + is + an + active + high + input + to + the + host + machine's + interrupt + + + controller + circuitry + which + resides + on + the + logical + equivalent + of + ASIC1. + The + OS + intercepts + all + interrupts + + + and + can + be + requested + to + call + a + particular + function + within + a + controlling + device + driver. + Eight + hardware + + + interrupts + are + supported + by + SIBO + hardware. + IRQO + is + the + highest + priority + and + IRQ7 + the + lowest. + All + + + interrupts + are + level + triggered + and + must + be + serviced + in + the + following + order: + + + + + e + Device + asserts + the + appropriate + interrupt + request + line. + + + + + e + The + interrupt + controller + unit + within + either + ASIC2 + or + ASIC9 + places + onto + the + data + bus + the + vector + of + + + the + highest + priority + device + with + an + interrupt + pending. + This + enables + the + CPU + to + jump + to + the + + + correct + interrupt + service + routine + code. + + + + + e + During + the + interrupt + service + routine, + the + software + clears + the + interrupt + line + by + some + action + specific + + + to + the + device. + + + + + e + The + interrupt + service + routine + then + informs + the + interrupt + controller + that + the + interrupt + has + been + + + cleared + by + writing + to + the + non-specific + end + of + interrupt + (NSEOD) + location. + + + + + e + If + another + interrupt + is + pending + then + go + back + to + the + second + step. + + + + + With + 8086-based + processors, + it + is + not + possible + to + have + nested + interrupts. + + + + + + + + + The + current + range + of + Psion + peripherals + + + + + + + + + There + are + currently + a + number + of + Psion + peripherals + in + use + and + some + of + the + key + ones + are + outlined + below + + + in + order + to + provide + the + developer + with + a + feel + for + peripheral + design + issues: + + + + + SSDs: + Solid + State + Disks + (or + Memory + Packs) + use + a + built-in + ASIC4 + to + decode + SIBO + serial + protocol + + + signals + into + memory + addresses + within + the + memory + range + of + the + SSD. + + + + + Psion + 3-link: + The + 3-link + translates + the + high + speed + SIBO + serial + protocol + channel + on + the + S3a + 6-pin + + + reduced + external + expansion + socket + into + a + serial + RS232 + format. + This + enables + the + host + machine + to + + + communicate + with + a + PC + for + example + by + means + of + connecting + the + 3-link + unit + from + the + handheld's + 6-pin + + + port + to + the + PC's + COM1 + or + COM2 + port. + The + 3-link + contains + an + ASICS + which + uses + its + on-board + UART + + + to + convert + SIBO + serial + protocol + signals + to + RS232 + format + TTL + level + voltages. + + + + + The + HC + Printer: + The + HC + Printer + translates + SIBO + serial + protocol + signals + transmitted + across + the + single + + + row + 25-way + extended + internal + expansion + socket + of + the + host + HC + into + a + parallel + 8-bit + format + that + is + + + compatible + with + the + universal + Centronics + printer + interface + standard. + The + HC + Printer + unit + contains + an + + + ASICS + running + in + Centronics + interface + mode + which + acts + as + the + serial + protocol + slave + and + requires + a + + + small + number + of + support + chips. + + + + + Psion + 3-Fax: + The + 3-Fax + contains + an + ASIC4 + and + a + memory-mapped + modem + chip + set + which + permits + the + + + host + machine + to + transmit + (but + not + receive) + fax + messages. + + + + + Barcode: + The + Psion + Barcode + reader + employs + an + ASICS + running + in + serial + mode + to + read + the + data + + + received + from + the + barcode + decoder + chip + into + a + SIBO + serial + protocol + format + that + can + be + transmitted + to + + + the + host + ASIC2/ASIC9. + + + + + Workabout + RS232 + Interface: + This + peripheral + connects + to + the + single + row + 26-way + extended + internal + + + expansion + port + of + the + Workabout. + It + incorporates + an + ASICS + running + in + its + default + mode + to + translate + + + SIBO + serial + protocol + signals + into + a + TTL + level + (+/-5v) + serial + RS232 + format + using + ASIC5's + on-board + + + UART. + The + TTL + level + RS232 + signals + are + converted + into + the + standard + EIA + format + (+/-12v) + before + + + coming + out + on + the + conventional + RS232 + 9-pin + D-type + connector. + + + + + + + + + Revision + 1.00 + Page + 5 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 4. + THE + PSION + SIBO + SERIAL + PROTOCOL + + + + + + + + + Introduction + + + + + + + + + The + Psion + SIBO + serial + protocol + is + a + proprietary + standard + for + bi-directional + serial + data + transfer + between + + + + + a + controlling + device + and + a + number + of + slave + devices. + The + synchronous + interface + consists + of + 2 + wires + + + + + CLK + and + DATA + as + mentioned + earlier: + + + + + CLK + _~ + - + Aclock + output + from + the + controller + to + the + slaves. + Nominally + 3.84 + Mhz + for + memory + + + + + interfaces + or + 1.536.Mhz + continuous + for + peripherals. + + + + + DATA + - + A + bi-directional + synchronous + data + line. + + + + + The + data + is + transferred + using + a + series + of + 12 + bit + frames + including + 8 + data + bits + each. + This + equates + to + a + + + + + theoretical + maximum + data + transfer + rate + of + approximately + 312 + Kbytes/second. + Other + bits + of + the + frame + + + + + contain + control + information. + The + "system" + is + generically + defined + by + 2 + protocol + layers:- + + + + + e + The + Physical + layer + defining + the + hardware + interface + and + frame + structure. + + + + + e + The + Transport + layer + defines + system + control + and + register + transfers + between + the + controller + and + the + + + slaves. + + + + + Using + this + system, + a + large + number + of + higher + level + implementations + can + be + defined. + In + normal + use + the + + + + + controller + will + communicate + to + slaves + in + a + point + to + point + configuration. + Multidrop + configurations + with + + + + + a + number + of + slaves + attached + to + one + channel + of + the + controller + are + also + supported. + + + + + + + + + As + indicated + in + the + previous + chapter, + the + SIBO + serial + protocol + controller + circuitry + resides + in + either + an + + + ASIC2 + or + an + ASIC9 + depending + on + the + particular + Psion + hardware + platform. + The + S3a + and + Workabout + + + employ + ASIC9 + whereas + the + HC, + MC + and + S3 + use + ASIC2. + + + + + + + + + Hardware + Interface + + + + + + + + + As + indicated + above, + the + SIBO + serial + protocol + consists + of + two + lines + that + switch + at + 5V + CMOS + voltage + + + levels: + + + + + + + + + Clock + Line + + + + + + + + + This + line + is + used + to + synchronously + clock + data + between + the + controller + and + slaves. + It + is + always + output + + + from + the + controller + circuitry + that + resides + in + ASIC2/ASIC9. + The + clock + should + only + be + active + during + the + + + transfer + of + data + or + when + the + serial + channel + is + continuous + clocking + mode + (used + by + ASICS). + At + all + other + + + times + it + is + tri-state + pulled + low. + + + + + + + + + Clock + Timing + Parameters + + + + + + + + + Parameter + + + Width + of + Clock + High + + + + + + + + + Width + of + Clock + Low + + + Cycle + time + of + clock + + + Clock + Frequency + + + + + + + + + Data + Line + + + + + + + + + This + is + a + bi-directional + line + used + to + transfer + data + synchronously + between + the + controller + and + slaves. + + + The + direction + of + the + data + line + is + not + determined + by + the + physical + layer + but + by + the + control + information + in + + + the + transport + layer. + This + is + described + in + the + next + section. + When + no + data + transfers + are + in + progress + the + + + data + line + is + always + set + to + input + on + both + the + controller + and + slaves. + This + line + is + pulled + low. + Data + is + + + changed + on + the + falling + edge + of + clock + by + the + transmit + device + and + latched + into + the + receiving + device + on + + + the + rising + edge + of + the + clock. + + + + + + + + + Revision + 1.00 + Page + 6 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + Physical + layer + + + + + + + + + This + section + specifies + the + low + level + protocol + of + the + SIBO + serial + protocol. + The + physical + layer + protocol + + + consists + of + a + series + of + 12 + bit + frames. + There + are + four + types + of + frames:- + + + + + Null + frames + - + Transmitted + by + controller + to + synchronise + slaves. + + + + + Control + frames + - + Control + information + transmitted + by + controller + to + slaves. + + + + + Data + output + frames + - + Data + frame + transmitted + by + controller + to + slaves. + + + + + Data + input + frames + - + Data + frame + received + by + controller + from + a + slave. + + + + + + + + + Frame + structure + + + + + + + + + All + 12 + bit + frames + have + the + following + structure:- + + + + + + + + + Bit + + + + + Name + ST + + + + + ST + Start + bit. + This + bit + goes + high + to + indicate + the + start + of + a + valid + frame. + + + + + CTL + ~~ + Control + bit. + When + low + indicates + this + is + a + control + frame. + High + indicates + a + data + frame. + + + Il + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Normally + Low. + + + + + DO-D7 + Data + bits. + + + + + 12 + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Normally + low. + + + + + Null + Frame + + + + + + + + + This + is + a + special + frame + transmitted + by + the + controller + to + ensure + all + slaves + are + synchronised. + It + is + + + generated + by + transmitting + 12 + clock + pulses + with + the + data + line + set + to + input. + Since + the + data + line + is + pulled + + + low + this + results + in + 12 + zeroes + being + transmitted. + + + + + + + + + Control + frame + + + + + + + + + This + frame + is + transmitted + from + the + controller + to + one + or + more + slaves. + The + data + line + is + an + output + from + + + the + controller + throughout + the + whole + frame. + The + bits + in + the + frame + have + the + following + value + in + a + control + + + frame: + + + + + + + + + ST + Start + bit. + This + bit + goes + high + to + indicate + the + start + of + a + valid + frame. + + + CTL + Control + bit. + Low + to + indicate + this + is + a + control + frame. + + + + + I1 + Idle + bit + Set + low. + + + + + DO-D7 + Data + bits. + 8 + bits + of + control + information. + + + + + I2 + Idle + bit + Set + low. + + + + + + + + + Data + Output + Frame + + + + + + + + + This + frame + is + transmitted + from + the + controller + to + one + or + more + slaves. + The + data + line + is + an + output + from + + + the + controller + throughout + the + whole + frame. + The + bits + in + the + frame + have + the + following + value + in + a + data + + + output + frame: + + + + + + + + + ST + Start + bit. + This + bit + goes + high + to + indicate + the + start + of + a + valid + frame. + + + CTL + Control + bit. + High + to + indicate + this + is + a + data + frame. + + + + + Il + Idle + bit + Set + low. + + + + + DO-D7 + Data + bits. + 8 + bits + of + transmitted + data. + + + + + 12 + Idle + bit + Set + low. + + + + + + + + + Data + Input + Frame + + + + + + + + + This + frame + is + received + by + the + controller + from + a + slave. + The + data + line + is + an + output + from + the + controller + + + for + cycles + 1 + and + 2 + and + input + to + the + controller + for + cycles + 4 + to + 11. + The + bits + in + the + frame + have + the + + + following + value + in + a + data + input + frame: + + + + + + + + + ST + Start + bit. + Output + from + controller. + This + bit + goes + high + to + indicate + the + start + of + a + valid + + + frame. + + + + + CTL + Control + bit. + Output + from + controller. + High + to + indicate + this + is + a + data + frame. + + + + + Il + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Both + controller + and + slave + + + + + should + tri-state + the + data + line + during + this + bit. + This + bit + should + be + low + due + to + pull + + + + + down + resistor + on + data + line. + The + controller + changes + the + data + line + from + output + to + + + + + + + + + Revision + 1.00 + Page + 7 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + input + at + the + end + of + cycle + 2. + The + slave + changes + the + data + line + from + input + to + + + output + at + the + start + of + cycle + 4. + + + + + + + + + DO-D7 + Data + bits. + Output + from + slave + 8 + bits + of + data + transmitted + by + slave. + Controller + sets + data + + + line + to + input + during + these + bits. + + + + + 12 + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Both + controller + and + slave + + + + + should + tri-state + the + data + line + during + this + bit. + Should + be + low + due + to + pull + down + + + + + resistor + on + data + line. + The + slave + changes + data + line + from + output + to + input + at + the + end + of + + + cycle + 11. + + + + + + + + + Data + line + direction + + + + + + + + + The + following + table + summarises + the + direction + of + the + data + line. + + + + + + + + + CONTROLLER + SLAVE + + + Condition + CK + DATA + CK + + + + + + + + + Outside + Frame + + + + + Null + frame + + + + + Control + Frame + + + + + Data + output + from + controller + + + + + Data + input + to + controller:- + + + Cycles + 1-2 + + + Cycle + 3 + + + Cycles + 4-11 + + + Cycle + 12 + + + + + + + + + OO000 + 0004 + + + + + + + + + Key + T + Tri-state + + + I + Input + + + O + Output + + + + + + + + + The + Transport + layer + + + + + + + + + This + section + specifies + the + transport + level + protocol + that + operates + above + the + SIBO + serial + communication + + + physical + layer. + The + transport + layer + protocol + controls + the + serial + communication + between + the + SIBO + + + Protocol + Controller + (SPC) + and + a + number + of + SIBO + Protocol + Slave + (SPS) + devices. + The + following + rules + + + apply:- + + + + + 1) + The + interface + is + controlled + by + the + writing + of + control + bytes + from + the + controller + to + the + slaves. + Control + + + bytes + cannot + be + written + by + the + slaves. + + + + + Unsolicited + data + cannot + be + sent + from + the + slave + to + the + controller. + + + + + 2) + The + controlling + device + contains + two + registers + to + communicate + to + the + slaves. + These + are + the + control + + + register + (byte, + write + only) + and + the + Data + register + (byte + or + word, + read/write). + + + + + Control + bytes + are + transmitted + to + the + slaves + by + writing + to + the + control + register. + + + + + The + format + of + the + control + byte + is + as + follows:- + + + + + + + + + The + control + word + can + have + 2 + distinct + formats + depending + on + the + setting + of + bit + 7 + the + Select + (S) + bit:- + + + Select + = + 0 + This + is + the + slave + select + mode. + This + mode + is + for + selecting, + deselecting + and + resetting + slaves. + + + Select + = + 1 + This + is + the + slave + control + mode. + This + mode + is + for + communicating + with + a + slave + which + has + + + been + previously + selected + using + the + select + slave + command. + + + + + + + + + Revision + 1.00 + Page + 8 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Slave + select + mode + + + + + + + + + The + format + of + the + slave + select + byte + is + as + follows:- + + + + + + + + + Key:- + + + R + single + reset + bit. + + + TU + 6 + bit + ID + field. + + + + + + + + + The + 6 + bit + ID + field + is + a + property + only + of + the + slave. + No + slave + may + have + an + ID + of + zero, + hence + there + can + be + + + 63 + different + slaves + connected + to + one + controller. + The + reset + bit + (R) + controls + whether + the + slave(s) + are + + + selected + or + reset. + If + R + = + 0 + slave(s) + are + reset, + R + = + | + slave(s) + are + selected. + Slave + select + control + bytes + can + + + be + summarised + by + the + following + table:- + + + + + + + + + Description + + + Reset + all + slaves + + + + + + + + + Reset + specific + slave + with + ID + = + xx + + + Deselect + slave + (does + not + reset + slave) + + + Select + slave + with + ID=xx + and + read + slave + info + (see + below). + + + + + + + + + The + Reset + function + is + dependant + on + the + slave. + It + would + normally + put + the + slave + into + a + known + passive + + + reset + state. + + + + + Select + Slave + with + ID=xx + (S=0,R=1) + + + + + This + is + a + special + command + that + causes + a + slave + with + ID=xx + to + transmit + to + the + controller + an + 8 + bit + + + information + field. + This + field + depends + entirely + on + the + slave + but + must + be + non + zero. + A + reply + of + 0 + + + indicates + that + there + is + no + slave + of + the + requested + ID + present. + + + + + + + + + Slave + control + mode + + + + + + + + + This + mode + is + for + communicating + with + a + slave + which + has + been + previously + selected + using + the + select + + + slave + command + described + above. + + + The + format + of + the + control + word + in + slave + select + mode + is + as + follows:- + + + + + + + + + R/W + Read/write + select. + 0 + = + write, + 1 + = + read + + + + + B/W + Data + transfer + size. + 0 + = + 1 + byte + transfer, + 1 + = + word + (2 + byte + transfer). + + + S/M + Single/Multi + transfer + mode. + 0 + = + single, + 1 + = + multibyte. + + + + + XXXX + = + 4 + bits + of + data + to + slave. + + + + + + + + + Note + the + meaning + of + the + 4 + bits + of + data + (XX + XX) + is + entirely + dependent + on + the + slave. + + + + + + + + + The + settings + of + R/W,B/W,S/M + bits + in + the + control + word + determine + the + size, + type + and + direction + of + + + subsequent + data + transfers + in + the + following + manner:- + + + + + + + + + Revision + 1.00 + Page + 9 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + R/W + B/W + _ + S/M + + + + + 0 + 0 + 0 + write + a + single + byte + to + slave + + + + + 0 + 0 + 1 + write + a + number + of + single + bytes + to + slave + + + + + 0 + 1 + 0 + write + a + byte + pair + to + slave + (not + implemented) + + + + + 0 + 1 + 1 + write + a + number + of + byte + pairs + to + slave + (not + implemented) + + + + + 1 + 0 + 0 + read + a + single + byte + from + slave + + + + + 1 + 0 + 1 + read + a + number + of + single + bytes + from + slave + + + + + 1 + 1 + 0 + read + a + byte + pair + from + slave + (not + implemented) + + + + + 1 + 1 + 1 + read + a + number + of + byte + pairs + from + slave + (not + implemented) + + + Write + a + single + byte + + + + + + + + + This + command + readies + the + currently + selected + slave + to + receive + a + byte + of + data + and + sets + up + the + controller + + + so + that + the + next + byte + (or + the + LSB + of + a + word) + written + to + its + data + register + will + be + transmitted + to + that + + + slave. + Anything + further + written + to + the + controller's + data + register + will + have + no + effect. + + + + + + + + + Write + a + number + of + single + bytes + + + + + + + + + This + command + readies + the + currently + selected + slave + to + receive + a + number + of + sequential + bytes + of + data. + + + The + slave + will + expect + to + receive + data + bytes + until + another + control + byte + is + received. + The + controller + is + set + + + up + so + that + the + next + byte + (or + the + LSB + of + a + word) + written + to + its + data + register + will + be + transmitted + to + that + + + slave. + All + subsequent + bytes + written + to + the + controller's + data + register + will + be + transmitted + to + the + slave. + + + This + will + continue + until + another + byte + is + written + to + the + controller's + control + register. + + + + + + + + + Write + a + byte + pair + + + + + + + + + This + command + readies + the + currently + selected + slave + to + receive + two + bytes + of + data + and + sets + up + the + + + controller + so + that + the + next + word + written + to + its + data + register + will + be + transmitted + to + that + slave + (LSB + first). + + + Anything + further + written + to + the + controller's + data + register + will + have + no + effect. + + + + + + + + + Write + a + number + of + byte + pairs + + + + + + + + + This + command + readies + the + currently + selected + slave + to + receive + a + number + of + sequential + byte + pairs + of + + + data. + The + slave + will + expect + to + receive + byte + pairs + until + another + control + byte + is + received. + The + controller + + + is + set + up + so + that + the + next + word + written + to + its + data + register + will + be + transmitted + to + that + slave + (LSB + first). + + + All + subsequent + words + written + to + the + controller's + data + register + will + be + transmitted + to + the + slave. + This + + + will + continue + until + another + byte + is + written + to + the + controller's + control + register. + + + + + + + + + Read + a + single + byte + + + + + + + + + This + command + triggers + a + byte + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + byte + + + can + then + be + read + from + the + LSB + of + the + controller's + data + register. + Further + reads + of + the + controller's + data + + + register + will + return + the + same + data + but + have + no + effect + on + the + protocol. + + + + + + + + + Read + a + number + of + single + bytes + + + + + + + + + This + command + triggers + a + byte + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + byte + + + can + then + be + read + from + the + LSB + of + the + data + register. + This + read + will + trigger + the + next + byte + to + be + + + transmitted + to + the + data + register + of + the + controller. + All + subsequent + reads + of + the + controller's + data + register + + + will + trigger + further + bytes + to + be + transmitted + to + the + controller. + This + will + continue + until + another + byte + is + + + written + to + the + controller's + control + register. + + + + + + + + + Read + a + byte + pair + + + + + This + command + triggers + a + byte + pair + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + + + word + can + then + be + read + from + the + controller's + data + register. + Further + reads + of + the + controller's + data + + + register + will + return + the + same + data + but + have + no + effect + on + the + protocol. + + + + + Read + a + number + of + byte + pairs + + + + + + + + + This + command + triggers + a + byte + pair + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + + + word + can + then + be + read + from + the + controller's + data + register. + This + read + will + trigger + the + next + byte + pair + to + + + + + + + + + Revision + 1.00 + Page + 10 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + be + transmitted + to + the + data + register + of + the + controller. + All + subsequent + reads + of + the + controller's + data + + + register + will + trigger + further + byte + pairs + to + be + transmitted + to + the + controller. + This + will + continue + until + + + another + byte + is + written + to + the + controller's + control + register. + + + + + + + + + Timing + + + The + time + taken + for + commands + to + be + processed + and + data + sent + is + shown + below. + The + time + is + given + in + + + + + + + + + SIBO + pack + protocol + clock + cycles. + The + length + of + a + clock + cycle + is + nominally + 260 + nanoseconds + for + a + + + clock + frequency + of + 3.84 + MHz. + + + + + + + + + Receive + and + process + the + control + byte + 12 + cycles + + + Byte + transfer + to + or + from + slave + 12 + cycles + + + Byte + pair + transfer + to + or + from + slave + 24 + cycles + + + + + + + + + When + writing + to + the + controller's + data + and + control + registers + the + following + rules + apply:- + + + + + e + After + writing + to + the + control + register + there + must + be + a + delay + of + at + least + 12 + cycles + before + the + data + + + register + is + accessed + or + another + control + word + is + written. + + + + + e + Toread + a + word + from + the + data + register + after + the + command + to + read + byte + pair + is + issued + there + must + a + + + delay + of + at + least + 12 + (for + control + byte)+24 + (for + the + byte + pair + transfer)= + 36 + cycles. + + + + + e + To + perform + a + multiple + byte + pair + write + there + must + be + a + delay + of + at + least + 12 + cycles + after + the + + + command + is + written + to + the + control + register + before + the + first + word + can + be + written + to + the + data + register + + + and + a + delay + of + at + least + 24 + cycles + between + subsequent + writes + to + the + data + register. + + + + + + + + + States + + + + + A + slave + can + be + in + one + of + 5 + states. + Note + a + control + byte + can + be + received + and + interpreted + at + any + time. + + + 1) + Waiting + to + receive + a + data + byte + or + control + byte + + + + + 2) + Waiting + to + receive + a + data + byte + pair + or + control + byte + + + + + 3) + Waiting + to + transmit + a + data + byte + or + control + byte + + + + + 4) + Waiting + to + transmit + a + data + byte + pair + or + control + byte + + + + + 5) + Waiting + to + receive + control + byte + only + + + + + + + + + Revision + 1.00 + Page + 11 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 5. + MECHANICAL + OVERVIEW + + + + + + + + + This + section + will + contain + information + regarding + mechanical + and + plastic + moulding + for + Series + 3/3a, + + + Workabout + and + HC + machines + that + is + deemed + to + be + of + especial + importance + to + developers + who + are + + + considering + producing + peripherals + for + these + particular + Psion + platforms. + + + + + + + + + The + Psion + Series + 3/3a + range + + + + + + + + + S3a/Series + 3 + Reduced + External + Expansion + Port + + + + + + + + + The + Psion + Series + 3/S3a + personal + digital + assistants + have + two + SSD + slots + and + provide + access + to + external + + + peripheral + units + through + a + single + reduced + internal + expansion + port, + port + C, + on + the + left + edge + of + the + + + machine. + The + reduced + external + serial + interface + expansion + port + from + the + Series + 3/3a + forms + six + wires. + + + The + purpose + of + each + is + described + in + the + table + below. + In + addition + to + data, + clock + and + power + an + active + + + high + interrupt + line + is + provided. + This + allows + the + peripheral + device + to + generate + an + interrupt + within + the + + + host + series + 3/3a. + The + level + of + interrupt + that + is + generated + depends + on + both + the + machine + and + the + + + expansion + port + that + is + used. + Either + ASIC4 + or + ASICS + can + act + as + the + other + end + of + the + Psion + Serial + + + Interface. + With + exception + of + the + interrupt + line + all + used + signals + should + be + connected + directly + to + the + + + appropriate + pins + on + ASIC4/5. + + + + + + + + + ASIC4/5 + SDAT + + + MCLK + Serial + clock + ASIC4/5 + SCLK + + + + + + + + + | + 6 + | + SCK/EXON + | + Not + used + in + this + scenario + | + Donot + Connect____| + + + + + + + + + Signal + Definition + + + + + + + + + MSD + and + MCLK + form + a + single + master + SIBO + serial + protocol + channel. + This + is + normally + channel + 7 + on + a + + + Series + 3 + and + channel + 5 + on + an + S3a. + The + serial + channel + clock + can + be + continuously + enabled + to + provide + a + + + free + running + clock + for + expansion + devices. + The + frequency + is + fixed + at + 1.536MHz + regardless + of + the + + + system + clock + frequency. + SDKs/INT + and + SCK/EXON + are + both + dual + function + pins. + SDKS + and + SCK + + + form + a + single + slave + SIBO + serial + protocol + channel. + This + can + be + combined + with + MSD + and + MCLK + to + + + form + a + bi-directional + high + speed + data + link. + SDS/INT + can + also + be + used + to + as + an + active + high + interrupt + + + input. + The + function + of + SDS/INT + can + be + programmed + in + ASIC2 + or + ASIC9. + A + rising + edge + on + the + + + SCK/EXON + input + will + bring + the + system + out + of + the + standby + state + into + the + operating + state. + VCC + is + a + +5 + + + volt + supply + that + is + switched + off + when + the + system + is + in + the + standby + state + and + is + switched + on + when + the + + + system + is + in + the + operating + or + idle + state. + The + maximum + current + that + can + be + drawn + is + 25mA. + Opening + + + the + pack + doors + on + either + an + S3a + or + a + Workabout + will + cut + power + to + external + peripherals. + + + + + + + + + Physical + Connector + + + + + + + + + The + reduced + expansion + port + is + made + up + of + a + 6-way + two + row + connector + spaced + on + a + 2x3 + way + 0.1 + inch + + + pitch. + The + diagram + below + shows + the + physical + connector + numbering: + + + + + + + + + Revision + 1.00 + Page + 12 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Looking + into + Series + 3 + / + 3a + + + + + + + + + The + male + plug + is + connected + to + a + 0.5m + long + plastic + moulded + 3-link + cable + assembly + (part + no. + 25020013) + + + which + is + terminated + in + a + six-pin + in-line + connector + which + connects + to + a + 6-way + 1.5mm + pitch + transition + + + header + (part + no. + 47000106). + + + + + + + + + The + Psion + Workabout + + + + + + + + + The + Workabout + Expansion + Interfaces + + + + + + + + + The + Psion + Workabout + provides + a + rugged + and + easy-to-use + computer + system + for + a + wide + range + of + mobile + + + corporate + needs. + The + machine + can + be + readily + adapted + to + support + various + peripheral + units + such + as + + + barcode + scanners + and + modems + attached + to + the + expansion + ports. + The + Workabout + has + a + 26-way + + + extended + internal + expansion + interface + and + a + special + 11-pin + reduced + external + expansion + interface. + + + + + + + + + Workabout + Extended + Internal + Expansion + Interface + + + + + + + + + The + pin-out + of + the + Workabout + 26-way + internal + Torson + connector + is + outlined + below: + + + + + + + + + Torson + 26 + way + connector + pin + Workabout + Signal + name + + + NICD + (not + used) + + + + + + + + + THM + (not + used) + + + VIN + (not + used) + + + + + + + + + Revision + 1.00 + Page + 13 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + e + = + Vccl + is + 3.0V + nominal + power + supply. + Current + available + from + Workabout + is + limited + to + 100mA. + + + + + e + =Vcc2 + is + 5V + nominal + power + supply. + Current + available + from + Workabout + is + limited + to + 200mA. + + + + + e + RUN + is + low + when + powered + down + and + high + when + powered + up. + It + is + used + to + power + down + or + reset + + + the + peripheral + module. + + + + + e + SCK2 + and + SCK3 + are + serial + data + clocks. + The + clocks + are + left + running + continuously + at + 1.536MHz + + + when + the + serial + port + is + in + use. + They + are + used + to + clock + the + UART + in + ASICS + in + the + RS232 + AT/TTL + + + and + AT/Barcode + modules + respectively. + + + + + e + SD2 + and + SD3 + are + bi-directional + serial + data + lines + used + in + the + RS232 + AT/TTL + and + AT/Barcode + + + + + modules + respectively. + + + + + EINT1 + and + EINT2 + are + active + low + signals + for + interrupt + input. + + + + + EXON + is + an + active + high + signal + used + to + turn + on + the + Workabout. + + + + + All + of + the + above + logic + signals + are + at + 3.0V + or + 3.3V + levels, + depending + upon + the + logic + supply + Vcc1. + + + + + Lines + currently + described + as + unused + relate + to + a + yet + unspecified + codec + interface. + + + + + + + + + Workabout + Reduced + External + Expansion + Interface + + + + + + + + + For + the + Workabout + reduced + external + expansion + interface, + a + new + | + 1-pin + Low + Insertion + Force + (LIF) + + + connector + has + been + designed + for + connecting + the + computer + to + the + Cradle + System. + The + computer + + + mounted + male + LIF + may + be + weather + proofed, + the + cable + mounted + female + LIF + cannot. + Currently + the + LIF + + + connector + cover + can + be + moulded + with + a + polarising + pin + in + one + of + two + positions. + The + facility + exists + to + + + manufacture + the + cover + with + the + polarising + pin + in + two + more + positions, + giving + four + possible + variants. + If + + + more + than + four + versions + are + required + it + is + possible + to + have + the + cover + and + the + socket + bezel + moulded + in + a + + + range + of + colours + to + differentiate + between + variants. + The + polarising + options + are + presented + below: + + + + + + + + + Pin + numbers + + + 1st + (1 + GROUND + 9 + + + 2nd + (________] + SIGNALS + 2,3,4,5,8,10 + + + 1,6,7,11 + + + + + + + + + The + step + arrangement + of + the + LIF + Connector + pins + + + + + + + + + Cable + mounted + LIF + (Female + plug) + Computer + mounted + LIF + (Male + socket) + + + + + + + + + Revision + 1.00 + Page + 14 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 3S + 310 + + + + + + + + + @e0000 + 08 + + + ODOOOO + + + + + + + + + Cable + mounted + LIF + (Female + plug) + Computer + mounted + LIF + (Male + socket) + + + + + + + + + Type + A + and + Type + B + polarisation + of + the + LIF + Connector + + + + + + + + + Revision + 1.00 + Page + 15 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Pin + Definition + for + LIF + - + PFS + Connector + + + LIF + Connector + Polarisation + Type + B + + + + + + + + + Pin + Pin + Name + Wire + Colour + Contact + Direction + Standard + Function + Cradle + usage + + + No + Gauge + (Cradle's + + + perspective) + + + + + 1 + LCA + 710.1 + Brown + third + Input + Local’ + Computer + Active. + High + when + the + Used + as + an + enable + for + the + cradle + + + computer + is + on. + (The + Workabout + can + source + resident + Xmod + 5V + supply. + + + 100mA + from + this + pin + and + the + HC/HCDOS + + + 5mA + to + power + remote + circuitry) + + + + + + + + + EXON + 710.1 + Blue + second + Output + EXternal + switch + ON, + active + high + (+5V). + May + be + asserted + by + a + cradle + resident + + + Asserted + by + a + remote” + device + to + switch + on + Xmod. + + + the + computer. + + + Xmod. + + + + + + + + + se + He + 1 + a + eee + eet + Battery + thermistor + terminal. + Allows + remote“ + function + + + eae + of + the + battery + temperature. + + + + + + + + + meal + 1 + Bead + ie + Output + Disconnect + Local” + ASIC, + active + high + (+5V). + Asserted + by + the + Cradle + ASIC, + + + (does + not + apply + to + Workabout). + When + this + connects + the + cradle + resident + Xmod + to + + + signal + is + asserted + the + serial + channel + is + the + serial + channel. + + + disconnected + from + the + local? + ASIC4/5 + in + the + + + HC + resident + Xmod + (if + present) + and + instead + + + connected + to + a + remote + ASIC4/5 + (if + present). + + + + + + + + + FN + Te + + + | + 7 + | + vin + | + 28SwG + Power + supply + to + computer + (+10V) + + + | + 8 + | + SCLK + 710.1 + | + SerialchannelCLocK. + + + + + + + + + GND + 28 + SWG + White + “fiat + Power, + [Seval + channel + Chev + —_____ + ground + and + -ve + battery + Standard + function + + + terminal + (1 + amp) + + + + + + + + + SDATA + 710.1 + Serial + channel + DATA. + + + + + + + + + 11 + STATUS + 710.1 + Pink + third + Cai + STATUS. + Connected + to + a + pull-up + resistor + to + Driven + low + by + an + open + collector + driver + + + allow + connection + to + an + open-collector/drain + when + LCA + is + high + and + the + cradle + is + + + driver. + Normal + usage + is: + low + indicates + the + powered-up + to + allow + the + computer + to + + + presence + of + a + remote” + device. + sense + whether + or + not + the + cradle + is + + + + + connected. + + + + + + + + + LIF + Connector + Polarisation + Type + A + + + + + + + + + Pin + Wire + Colour + Contact + Direction + Function + + + No + eine + Gauge + (Computer's + + + perspective) + + + ee + oe + RS2I2 + signal + + + a + a + RS232 + signal + + + + + + + + + 77 + Output + | + RS232 + signal + + + THERM + [7101 + [Yellow + [ + second_[ + =] + Battery + thermistor + terminal + + + + + + + + + [svar + [2sswo + [Red + [tind + [- + | + tvebattery + terminal + ——SSSSSCSCSCSCSCSCSCSCC~C~* + + + [3 + [pe + 701 + [Grey + [second + [Input + [ + RS232signal + OSS + + + [9 + [exp + eswo + [white + [fist + [= + | + Power, + signal + ground + and + ve + battery + terminal + —____——SS—~S + + + + + + + + + Definitions + + + + + Computer + HC, + HCDOS + or + Workabout + + + + + Cradle + resident + Xmod + Expansion + module + fitted + to + the + cradle, + may + or + may + not + be + present. + + + + + HC + resident + Xmod + Expansion + module + fitted + to + the + HC, + which + contains + the + cradle + interface + and + possibly + another + peripheral. + + + HC + peripheral + A + peripheral, + located + in + the + HC + resident + Xmod + which + is + connected + to + the + same + serial + channel + as + the + cradle. + + + Cradle + ASIC + An + ASICS + located + on + the + main + cradle + PCB + which + remains + connected + to + the + serial + channel + + + + + + + + + irrespective + of + the + state + of + DLA. + + + + + + + + + 1. + | + The + term + "local + computer" + implies + the + computer + local + to + the + LIF + connector, + i.e. + the + HC, + HCDOS + or + Workabout, + as + opposed + to + + + a + "remote" + computer + which + might + be + connected + via + a + cradle + resident + Xmod + for + example. + + + + + 2. + The + term + "remote" + implies + something + on + the + other + side + of + the + LIF + connector + to + the + computer. + + + + + 3. + | + The + term + "local" + implies + something + on + the + computer + side + of + the + LIF + connector + including + devices + on + an + HC + resident + Xmod. + + + + + + + + + Revision + 1.00 + Page + 16 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Exploded + view + of + the + Psion + Workabout + + + + + + + + + Below + is + an + exploded + view + of + a + complete + Psion + Workabout + showing + part + numbers + for + various + + + components + and + illustrating + the + positioning + of + the + expansion + interfaces. + + + + + + + + + 4 + + + g + y + + + o + # + + + + 4 + a + § + 8 + + + Ss + 8 + + + 4 + gy + Fa + i + + + f + a + Of + i + + + a + 8 + a + a + + + a + « + + + a + 2 + + + 8G + + + Roo + + + ae + + + 38 + + + a3 + + + 3 + + + a + @ + ¢ + + + me + oON + Sgt + + + 3 + + + ROS + + + a + 3 + g + + + ® + S + +8 + + + Be + $3 + + + $s + $8 + + + a + 8 + 28 + + + = + + + o + + + j + z + + + a + 3 + + + a3 + F + | + + + 8 + + + a + 4 + 9 + Boa + ey + + + 3 + a + a + 9 + 3 + + + a + g + 4g + 1 + o + + + & + & + a9 + 3 + 4 + 2 + + + # + 8 + . + p + 3 + 3 + + + zh + ae + 6 + ¢ + a + + + 3 + i + 3 + f + é + i + 3 + " + + + 3 + a8 + a + 8 + 2 + 3 + § + + + goa + + + 3 + BS + + + g + a + 8 + Poa + + + 3 + + + 5 + : + + + a + 8 + a + 9 + + + a + oF + a + + + + + & + § + + + ff + 42 + + + Oo + oN + bos + + + ng + + + a + 3 + + + al + + + a + + + «38 + + + i + + + hoon + + + 2 + 8 + > + + + f + + a + 38 + + + ag + eg + + + 2 + as + + + & + + + a + + + $3 + + + Gc + @ + + + aa + + + 4 + + + a + og + + + 3 + + + 4 + + + o + § + + + 8 + + + g + 8 + + + & + + + g + 3 + + + a + + + a + S$ + + + 0 + y + + + 8 + 3 + + + 4 + + + 8 + + + d + + + 1 + a + + + 3 + ages + + + a + Be, + gy + ee! + + + 8 + g + 3 + + + ae + + + a + + + 3 + + + 8 + & + + + 4 + + + 9 + 2 + 3 + + + p + t + ° + ib + + + a + oO + © + + + 3 + Re + eS + + + 3 + y + § + 3 + + + 4 + 3 + + + 3 + + + ae + oe: + + + n + oc + = + «© + + + x + + + » + + + zg + a3 + + + xg + + + é + + + a3 + 28 + + + 4 + a + 3 + 6 + + + 4 + 4 + + + s + 3 + ¢ + 2 + 3 + os + 3 + + + a + a + 8 + § + + + a + 4 + hoa + gs + 4 + $ + + + 3 + ROS + * + + + § + a + & + aoa + + + g + + + g + 8 + i + 3 + + + a + 3 + 5 + 3 + + + 3 + i + rf + + + g + + + Son + + + 8 + 38 + + + 4 + og + + + F + 2 + 9 + + + * + 3 + + + 8 + + + a + a + 4 + + + j + 4:8 + + + 8 + + + + a5 + + + 3 + + + a + + + + + + + + + Revision + 1.00 + Page + 17 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + Psion + HC + range + + + + + + + + + HC + Extended + Internal + Expansion + Port + + + + + + + + + The + Psion + HC + range + of + computers + are + intended + to + provide + a + rugged + and + powerful + mobile + computer + + + system + for + a + wide + variety + of + demanding + application + requirements. + As + part + of + its + adaptability, + every + + + element + of + the + hardware + is + configurable + from + the + plug-in + SSDs + to + the + expansion + ports + for + peripheral + + + devices + such + as + bar + code + scanners, + modems + and + magnetic + card + readers. + There + are + two + independent + + + extended + internal + expansion + ports + at + either + end + of + an + HC + unit. + The + top + port + is + termed + the + "A" + port + + + and + the + bottom + one + the + "B" + port. + Each + expansion + port + provides + direct + I/O + with + the + processor, + a + SIBO + + + serial + channel, + and + connection + to + the + power + supply. + It + allows + for + higher + powered + expansion + devices + to + + + be + added + by + including + a + direct + connection + to + the + main + 7.2 + volt + battery. + + + + + + + + + Physical + Connector + + + + + + + + + The + expansion + port + is + made + up + of + a + 25 + way + single + row + connector + spaced + on + a + 0.1 + inch + pitch. + The + 26th + + + position + is + a + polarising + key + and + should + be + left + blank. + The + correct + mating + connector + on + the + expansion + + + device + is + made + up + from + a + number + of + Molex + C-Grid + series + 90148 + connectors. + Pins + | + and + 2 + are + ground + + + and + should + have + there + own + connector + placed + nearer + the + board + edge + to + ensure + the + ground + connection + is + + + made + first + when + the + expansion + device + is + inserted. + The + required + connectors + are + Molex + 90148-1102 + for + + + the + GND + contacts + and + Molex + 90148-1123 + for + the + signal + contacts. + The + diagram + below + shows + the + + + physical + position + of + the + connectors. + + + + + + + + + =$f + ene + 98148-1182 + 3 + + + + + Se + : + EXPANSION + D + + + =e + + + + + sad + Abe + COMPONENT + SID + + + + + + + + + fet + + + + + feu) + + + HHDE + + + eorn + + + AEM + + + on + + + + + + + + + 38148-1125 + + + + + + + + + raftats + afte + + + + + [o}:o + loo) + en] + + + Heonwnm + + + Zuaorom + + + Scteorn + + + aa + ne + + + + + + + + + raftofea + + + Lsfosfra + + + wn + + + Ox + + + ol + + + Fr! + + + + + + + + + wi + + + Zo + + + OR + + + + + + + + + ge + + + + + + + + + voce + + + (SPACE? + + + + + + + + + SIBO + COMPUTER + + + + + + + + + Revision + 1.00 + Page + 18 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Signal + definition + + + + + + + + + The + following + table + defines + the + 25 + way + expansion + connector:- + + + + + + + + + Pin + No. + Name + _ + Sig. + type + Comments + + + + + GND + Power + Should + mate + first + when + device + inserted + + + + + GND + Power + Should + mate + first + when + device + inserted + + + + + ADO + BCMOS + 8 + bit + multiplexed + address + and + data + bus + pulled + low + with + 100 + K + resistors + + + ADI + BCMOS + + + + + AD2 + BCMOS + + + + + AD3 + BCMOS + + + + + AD4 + BCMOS + + + + + ADS + BCMOS + + + + + AD6 + BCMOS + + + + + AD7 + BCMOS + + + + + ALE + OCMOS + Address + latch + enable + - + high + when + valid + address + on + ADO-AD7 + + + + + IOWR + OCMOS + I/O + write + strobe + - + active + high, + data + valid + on + falling + edge + of + IOWR + + + IORD + OCMOS + I/O + read + strobe + - + high + when + device + can + place + valid + data + on + ADO-AD7 + + + EES + OCMOS + External + Expansion + Select + - + high + during + I/O + cycles + to + expansion + device + + + SCLX + TCMOS + 512 + KHz + SCL + signal + for + SLD + bus + - + usually + Hi-Z + and + pulled + low + + + + + DNC + N/A + For + future + expansion + - + do + not + use. + + + + + THERM + Resistor + Connected + to + thermistor + (bottom + slot + only + - + top + slot + DNC) + + + + + VBI + Battery + Connected + to + the + internal + NiCd + battery + (bottom + slot + only + - + top + slot + DNC) + + + Vsup + Power + Unregulated + battery + voltage + - + present + all + the + time + + + + + INTR + ICMOS + Active + high + interrupt + input + + + + + _EXON + ICMOS + Active + low + input + pulled + up + to + Vccl + - + pull + low + to + switch + machine + on + + + + + SD + B + CMOS + SIBO + serial + protocol + data + line + - + pulled + low + + + + + SCLK + TCMOS + SIBO + serial + protocol + clock + line + - + Hi-Z + in + standby + needs + a + pull + down + + + GND + Power + + + + + Vcc2 + Power + +5 + volt + supply, + switched + off + in + standby. + Max + current + available + = + 50 + mA + + + + + + + + + AADNKRWN + KH + + + + + + + + + DNC + (Do + Not + Connect) + indicates + that + the + pin + should + not + be + connected. + The + signal + types + are:- + + + + + + + + + O + CMOS + CMOS + output + to + the + expansion + device. + + + + + B + CMOS + CMOS + bi-directional + line + to + the + expansion + device. + + + T + CMOS + CMOS + tri-state + output + to + the + expansion + device. + + + + + I + CMOS + CMOS + input + from + the + expansion + device. + + + + + + + + + All + the + CMOS + signals + including + the + ADO-AD7 + bus + are + buffered + from + the + main + system + busses + and + so + + + present + a + load + of + one + HC + series + logic + gate. + + + + + + + + + Direct + I/O + + + + + + + + + Expansion + devices + can + be + connected + to + direct + processor + I/O + space + using + the + following + signals; + ADO- + + + AD7, + ALE, + IOWR, + IORD, + EES + and + INTR. + + + + + + + + + ADO-AD7 + is + the + least + significant + half + of + the + multiplexed + address + and + data + bus, + this + means + that + up + to + + + 128 + I/O + addresses + are + available + for + each + expansion + device. + As + only + the + least + significant + half + of + the + + + bus + is + available + and + no + bus + conversion + is + done + only + even + addresses + can + be + used. + + + + + + + + + ALE + must + be + used + to + latch + the + address + from + ADO-AD7 + for + devices + that + require + a + stable + address. + The + + + address + is + valid + on + the + falling + edge + of + ALE. + Note + that + AO + will + always + be + low + for + valid + writes + to + the + + + expansion + device + and + as + such + should + not + be + used + as + an + address + line, + Al + should + be + used + as + the + lowest + + + order + address + line. + AO + can + be + used + as + an + additional + enable + signal + to + stop + odd + I/O + accesses + disturbing + + + the + expansion + device. + + + + + + + + + EES + is + the + External + Expansion + Select + and + is + high + during + all + I/O + accesses + to + the + expansion + device, + i.e. + + + + + + + + + for + I/O + reads + and + writes + to + address + range + 100 + to + 1FF + hex. + for + expansion + port + 1, + and + 200 + to + 2FF + for + + + expansion + port + 2. + + + + + + + + + Revision + 1.00 + Page + 19 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + IOWR + is + an + active + high + signal + which + is + high + during + all + I/O + write + bus + cycles. + The + data + on + ADO-AD7 + + + is + guaranteed + to + be + stable + before + the + rising + edge + of + IOWR + and + after + the + falling + edge + of + IOWR. + IORD + + + is + an + active + high + signal + which + is + high + during + all + I/O + read + bus + cycles. + The + ADO-AD7 + bus + is + + + guaranteed + to + be + tri-state + before + the + rising + edge + of + IORD + and + after + the + falling + edge + of + IORD. + The + + + expansion + device + must + present + valid + data + on + the + bus + when + IORD + is + high, + see + the + timing + details + below. + + + + + + + + + INTR + is + an + active + high + interrupt + input + to + ASIC1. + T + his + can + be + used + as + a + directly + readable + bit + or + as + a + + + dedicated + interrupt + input. + It + must + not + be + driven + high + when + the + system + is + in + the + standby + state + as + this + + + input + is + pulled + down + and + will + cause + excessive + standby + current + consumption. + The + diagram + below + + + shows + the + timing + of + the + I/O + write + and + read + cycles. + + + + + + + + + T/0 + WRITE + CYCLE + + + + + + + + + ADS-ADT + VALID + ADDR + + + + + + + + + VALID + WwW + + + + + + + + + QOD + + + + + + + + + FES + q_Tadstp + _ + plyTadhidy, + + + + + + + + + | + Tudstp + | + Tudhld + | + + + + + + + + + IYO + READ + CYCLE + + + + + + + + + ADS-ADT + VALID + ADDR> + + + + + + + + + } + Tadetp + fel + adhd + ,, + + + + + + + + + | + Thztd + Trdste + Trdhid + + + + + + + + + Parameter + + + + + Address + set + up + time + + + Address + hold + time + + + Write + data + set + up + time + + + Write + cycle + pulse + width + + + + + + + + + Write + data + hold + time + + + + + Time + from + Hi-Z + to + data + active + + + Read + cycle + pulse + width + + + + + Read + data + set + up + time + + + + + Read + data + hold + time + + + + + + + + + Note + the + typical + values + given + are + for + an + HC + with + a + system + oscillator + of + 7.68 + MHz. + + + + + + + + + The + SIBO + serial + channel + + + + + + + + + A + single + SIBO + serial + protocol + channel + is + provided + on + each + expansion + port. + Expansion + port + | + is + + + connected + to + serial + channel + 5, + expansion + port + 2 + is + connected + to + serial + channel + 6. + The + serial + channel + + + clock + can + be + continuously + enabled + to + provide + a + free + running + clock + for + expansion + devices. + The + + + frequency + is + fixed + at + 1.536 + MHz + regardless + of + the + system + clock + frequency. + This + frequency + is + a + + + multiple + of + the + SLD + clock + rate + and + of + all + normal + RS232 + baud + rates. + + + + + + + + + High + Speed + Side + Port + + + + + + + + + Port + C + on + an + HC + houses + an + 8-pin + in-line + connector + that + allows + access + to + a + high + speed + SIBO + serial + + + interface. + This + interface + is + currently + used + only + by + the + HC + cradle + peripheral. + Its + pin-out + is + outlined + in + + + the + table + overleaf: + + + + + + + + + Revision + 1.00 + Page + 20 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + [Pin + | + Signal + | + Type + | + Description, + + + + + + + + + fo + | + Sb7_ + | + InOut__| + Bi-directional + Serial + Data + line- + Side + portC + + + [8 + TSEN + Input + Battery + temperature + sensor + + + + + + + + + Power + supplies + + + + + + + + + Two + power + supplies + are + available + for + expansion + devices + these + are + Vcc2 + and + Vsup. + Vcc2 + is + a + +5 + volt + + + supply + that + is + derived + from + Vsup. + Vcc2 + is + switched + off + when + the + system + is + in + the + standby + state + and + is + + + switched + on + when + the + operating + or + idle + state + is + entered. + Each + expansion + device + can + draw + up + to + 50 + mA + + + from + Vcc2. + If + an + expansion + device + requires + more + than + 50 + mA + or + cannot + be + powered + down + when + the + + + system + is + in + the + standby + state + the + Vsup + power + supply + must + be + used. + Vsup + is + the + unregulated + supply + + + directly + from + the + main + system + batteries + or + from + the + DC + jack + input. + It + will + be + in + the + range + 5.5 + to + 12 + + + volts + under + normal + conditions. + To + use + Vsup + the + expansion + device + must + regulate + Vsup + to + 5 + volts + with + + + a + low + drop-out + linear + regulator. + Care + must + be + taken + to + not + be + active + and + driving + any + signals + high + + + when + the + system + is + in + the + standby + state + as + Vsup + is + always + present. + This + can + be + achieved + either + in + + + software + or + by + using + Vcc2 + as + a + signal + indicating + the + active + state. + + + + + + + + + Mechanical + Information + + + + + + + + + Mechanical + details + regarding + the + numerous + build + variants + and + accessories + that + currently + exist + for + the + + + HC + are + presented + overleaf. + The + peripheral + expansion + boards + for + these + build + variants + are + housed + in + a + + + special + plastic + casing + that + can + be + machined + to + hold + the + requisite + connectors. + In + the + matrix, + ae + + + indicates + that + the + relevant + combination + of + HC + and + accessory + are + compatible + and + an + X + indicates + that + + + the + combination + is + not + compatible. + Following + the + build + variant + table + are + two + diagrams + that + display + + + exploded + views + of + the + HC + expansion + connector + and + the + HC + Expansion + Board + complete + with + part + + + numbers + and + dimensions. + + + + + + + + + Revision + 1.00 + Page + 21 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Build + Variants + + + + + + + + + With + EL + Backlighting + + + Without + EL + Backlighting + + + + + + + + + Industrial + + + + + + + + + Non-Industrial + + + + + + + + + Keypad + Variants + + + + + + + + + 53 + Key + A/N + UK + 2401-0026 + + + A/N + European + 2401-0051 + + + A/N + Scandinavian + 2401-0050 + + + Numeric + only + UK + 2401-0046 + + + DOS + Keypad + 2401-0147 + + + 53 + Key + A/N + USA + 2400-0026 + + + HC + Expansion + Modules + + + + + + + + + RS232 + / + Parallel + (Printer) + 1502-0001 + + + 25 + way + D + type + (F) + + + 9 + way + Mini + DIN + + + Certified + FCC + Class + B + / + Passed + VDE + Class + B + + + + + + + + + RS232 + / + TTL + + + + + 1502-0039 + (IP64), + 1502-0040 + (NON + IP64) + + + + + 9 + way + D + type + (F) + + + 9 + way + D + type + (M) + + + + + Passed + FCC + Class + B + / + Passed + EN55022 + Class + B + + + + + + + + + UK + Modem + (Asic + 8) + 1502-0010 + + + RJ + 11 + connector + + + BABT + Approved + in + UK, + BS6301 + (Safety) + + + + + + + + + Barcode + Only + + + + + HP + Wand + HBCS-A207 + + + Plug + + + EXMOD + 1502-0020 + + + Wand + Welch + Allen + + + Plug + + + EXMOD + 1502-0021 + + + FCC + Class + A/ + Passed + VDE + Class + B + + + + + + + + + RS232 + / + Barcode + 1502-0044 + + + 9 + way + D + type + Quick + Loc(F) + + + 9 + way + D + type + (M) + + + Complies + with + FCC + Class + A + + + + + + + + + MCR + / + Scanner + / + RS232 + 1502-0003 + + + Scanner + NipDenso + + + Plug + 1502-0022 + + + Scanner + DigVision + + + Plug + 1502-0023 + + + Magnetic + Card + Reader + + + Plug + 1502-0024 + + + Certified + FCC + Class + B + / + Passed + VDE + Class + B + + + + + + + + + LIF + / + RS232 + (Under + development) + + + 9 + way + D + type + (M) + + + 9 + way + LIF- + PFS + (M) + + + + + + + + + LIF + / + TTL + (Under + development) + + + 9 + way + D + type + (F) + + + 9 + way + LIF- + PFS + (M) + + + + + + + + + LIF + / + BARCODE + 1502-0043 + + + 9 + way + D + type + Quick + Loc(F) + + + 9 + way + LIF- + PFS + (M) + + + + + + + + + Vehicle + / + TTL + + + 9 + way + D + type + (F) + + + 9 + way + LIF- + RS232 + (M) + + + + + + + + + 16550 + RS232 + / + TTL + (Under + development) + + + 9 + way + D + type + (F) + + + 9 + way + D + type + (M) + + + Complies + with + FCC + Class + A + + + + + + + + + Printer + (High + Res.) + 1502-0037 + + + Laser + Scanner + 1503-0012 + + + + + + + + + Fast + Charger + Variants + + + + + + + + + Fast + Charger + with + Holster + (Due + Jan + 95) + + + Fast + Charger + without + Holster + (Due + Jan + 95) + + + + + + + + + Additional + Accessories + + + Nicad + Battery + Pack + 500 + mA + 1503-0005 + + + + + + + + + Revision + 1.00 + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + CHARGER + + + + + + + + + a + a + a + Ee + + + i + ie + IE + a + a + + + ee + ee + + + Re + ca + Da + ca + + + + + + + + + ans + he + ae + Ss + eee + + + FS + a + a + a + a + + + + + + + + + Page + 22 + of + 115 + pages + + + + + + + + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Corporate + Hand + Held + (CHH) + + + + + + + + + Expansion + Module + Exploded + Assembly + Drawing + + + + + + + + + (yovig) + Sso0-zoz9 + + + + + + + + + (USENNN + LYVd + YSLINO + OSTY) + (A3N9) + £000-20z9 + + + + + + + + + YANVIG + NOISNVdX4d + 138V1 + + + + + + + + + (440 + 2) + 2000-z0¢g + + + WSO + IZOd + WWOXZZ% + MINIS + + + + + + + + + (OV1E) + 9107-2018 + + + + + + + + + (AJN9) + 9101-2018 + + + ONITINOW + Y3LNO + NOISNVdxX3 + OLS + HHO + + + + + + + + + (wov1d) + $10Z-Z018 + + + (AIUD) + SLOL-ZOL8 + + + ONIGINOW + YSNNI + NOISNYdX3 + HHO + | + + + + + + + + + 6000-0072 + + + ANVIG + dd + + + + + + + + + SNOISNSNIG + YSLLNS + + + ANVIG + NOISNVdX3 + 138V1 + + + + + + + + + Page + 23 + of + 115 + pages + + + + + + + + + Revision + 1.00 + + + + + + + + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + t + + + + + + + + + The + Psion + SIBO + Hardware + Development + + + + + + + + + QrOr + o22 + ILD + :xW4 + + + 008! + 802 + 120 + “7131 + + + 1G) + HIM + + + + + + + + + NOONOT + N/OIl + + + + + + + + + AS + 18NOQYVH + 61-21 + + + Jd + NOd + + + + + + + + + MSV + LENOd + Ni + dl + + + JNWOS + ION + OG + + + + + + + + + (SOs + 2) + ONDOEL + =O + + + w300 + 34 + OL + G3U0Y + vey + + + + + + + + + 26, + + + + + + + + + 94 + 01 + GMQy + SFI + NOILWOOT + + + + + + + + + 26/1/91 + + + + + + + + + Sa + @ + SINSNOGNOD + 40 + + + wa) + 38 + OL + G200V + vw + + + + + + + + + 26/0178 + + + + + + + + + ‘Gadd + NOWOWISIS + + + AHOIBH + LN3NOEWOD + W207 + + + + + + + + + 06 + /c0/zal + + + + + + + + + 108 + X3T0K + + + a300¥ + $89 + 8ou93~N09 + + + + + + + + + oss + 9792 + + + + + + + + + SSI + Sas + + + + + + + + + SONVHO, + + + + + + + + + SmAOVd + NOISNVdx4 + + + + + + + + + SH + T1¥ + A044 + GssyINGS + + + + + + + + + NOILYWAOSANI + 4H + + + + + + + + + L + SMOHS + SONIMVAC + Sit + + + + + + + + + LH513H + LN3SNOdWOD + + + X¥W + ONIMOHS + 311 + 408d + + + + + + + + + 216 + + + + + + + + + cay) + Y_NOISN3WIC + + + + + + + + + C30N31LX3 + + + + + + + + + CAVONVLS + + + + + + + + + JdWwOS + aNv + + + + + + + + + qa.0N3d + vaav + + + + + + + + + A11V901 + NO3IaLS34 + + + + + + + + + COMPONENT + HEIGHT + RESTRICTION + + + + + + + + + (SEE + PLAN + VIEW) + + + + + + + + + (SOd + 2) + ONIMDVYL + ANY + + + WOS4 + 3384 + 38 + O1 + voav + + + + + + + + + CAVA + 92 + WiOL) + SYOLO3NNO9 + + + + + + + + + LTO + + + + + + + + + SOd + 2) + SIN3NOdWOD + ANY + + + WOSs + 3384 + 34 + OL + vaav + + + + + + + + + : + @szaze + @ + S3143S + 8y106 + X370N + + + + + + + + + a2 + + + + + + + + + 4.5 + BOTH + SIDES + + + + + + + + + 1 + + + | + + + 31.75 + CRS + l + 31.75 + CRS + + + + + + + + + Page + 24 + of + 115 + pages + + + + + + + + + Revision + 1.00 + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 6. + ASIC + 4 + + + + + + + + + What + is + ASIC + 4? + + + + + + + + + ASIC4 + is + custom + integrated + circuit + designed + for + use + in + Memory + Packs + (called + SSDs) + and + peripheral + + + devices. + Its + primary + purpose + is + to + convert + the + PSION + Serial + protocol + into + the + signals + required + to + + + address + memory + and + memory-mapped + peripherals. + A + typical + Series + 3/3a + ASIC4 + peripheral + will + + + consist + of + an + ASIC4 + connected + to + port + C + of + the + host + machine + and + a + peripheral + chip/device + mapped + + + into + ASIC4's + addressing + space. + An + example + could + be + an + ASIC4 + connected + to + a + simple + 1k + memory + + + device: + + + + + + + + + Chip + select + + + + + + + + + To + write + a + value, + <v>, + to + address + <addr>, + the + appropriate + control + codes + must + be + sent + along + the + port + + + C + Psion + Serial + link + to + assert + <addr> + on + ASIC4's + address + outputs + and + <v> + on + ASIC4's + data + outputs. + + + + + + + + + ASIC4 + Addressing + and + Modes + + + + + + + + + ASIC4 + has + an + 8 + bit + data + bus + and + a + 28 + bit + address + bus. + Also + provided + are + eight + chip + select + lines + that + + + form + selectable + addressing + blocks + each + of + a + size + defined + by + software. + The + default + is + 32Kbyte/block. + + + The + filing + system + will + set + this + to + the + appropriate + size + while + accessing + memory + in + the + upper + portion + of + + + the + address + space. + + + + + + + + + ASIC4 + has + two + basic + modes + of + operation, + namely + ASIC5 + Compatibility + (or + SSD) + mode + and + ASIC4 + + + Extended + mode. + To + select + the + mode, + ASIC4 + must + be + selected + with + an + appropriate + ID. + This + is + + + achieved + by + writing + a + SIBO + serial + protocol + slave + control + frame, + as + detailed + in + chapter + four, + to + the + + + ASIC + prior + to + sending + any + read + or + write + requests. + After + sending + this + frame, + the + so-called + Info + Byte + is + + + read + off + the + data + bus. + Details + concerning + the + meaning + of + the + various + Info + Byte + bits + are + provided + in + the + + + following + section. + In + the + case + of + SSD + mode, + the + ID + is + 2 + and + for + ASIC4 + Extended + mode, + the + ID + is + 6. + + + + + + + + + Putting + ASIC4 + into + SSD + mode + makes + the + chip + compatible + with + all + current + versions + of + existing + SSD + + + software + in + production + by + Psion + including + all + HC, + series + 3/3a + and + MC + software. + In + this + mode, + ASIC4 + + + mimics + an + ASICS + in + pack + mode + (see + next + chapter). + This + is + because + ASIC4 + was + originally + designed + to + + + be + a + cut-down + version + of + ASICS + and + so + from + the + outset + it + was + necessary + to + make + previously + existing + + + ASICS + software + run + on + the + new + chip. + The + maximum + address + space + in + SSD + mode + is + 21 + address + bits + + + and + 4 + chip + selects + (which + comes + to + 4 + x + 2Mb). + In + ASIC4 + Extended + mode, + ASIC4 + is + capable + of + + + addressing + up + to + 28 + address + bits + (256Mb). + In + this + mode, + in + addition + to + the + Info + Byte, + a + further + 4 + bits + + + of + information + can + be + elicited + from + the + state + of + the + address + lines + A27-A24 + during + reset. + Of + these + bits, + + + the + state + of + A27 + (bit + M) + determines + whether + ASIC4 + is + going + to + be + used + as + a + standard + SSD + (M=0) + or + in + + + a + mixed + mode + (M=1) + comprising + of + memory + devices + and + peripherals. + It + is + only + the + latter + case + which + + + is + of + interest + to + the + potential + developer + since + this + is + the + mode + intended + specifically + for + peripheral + type + + + expansion. + In + mixed + mode + ASIC4's + address + space + is + split + into + two + equal + halves. + The + lower + half + of + + + the + addressing + range + is + set + aside + for + memory-mapped + peripherals + and + can + be + used + for + any + purpose. + + + The + upper + portion + of + the + address + space + is + reserved + for + pure + memory. + The + Series + 3/3a, + Workabout + and + + + + + + + + + Revision + 1.00 + Page + 25 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + HC + filing + system + is + able + to + use + this + memory + (which + does + not + have + to + be + present) + as + an + additional + + + storage + medium. + Typically + it + will + be + a + ROM + containing + the + software + that + controls + the + peripheral. + On + + + reset, + configuration + data + is + supplied + to + ASIC4 + on + its + data + bus + lines + which + the + filing + system + can + read + + + in + order + to + determine + what + form + of + and + how + much + memory + it + has + available + in + this + upper + region. + + + + + + + + + In + mixed + mode + chip + selects + are + split + into + four + selectable + peripheral + blocks + and + four + selectable + memory + + + blocks. + CSO-CS3 + are + for + peripheral + access. + CS4-CS7 + select + memory + devices + one + to + four. + This + set-up + + + is + illustrated + below: + + + + + + + + + Peripherals + + + S1 + + + $2 + + + $3 + + + Total + + + Addressing + S4 + + + Range + Memory + + + (256Mb) + SS + + + S6 + + + S7 + + + + + + + + + Reset + and + configuration + + + + + + + + + As + indicated + earlier, + in + mixed + mode, + following + a + reset + or + power + up + ASIC4 + will + read + the + form + in + which + + + to + configure + itself + from + the + data + on + data + lines + DO-D7 + (the + Info + Byte) + and + address + lines + A24, + A25, + A26, + + + A27 + (most + significant + nibble + of + the + Extended + Info + Byte). + The + table + below + shows + the + meaning + of + each + + + of + these + lines + during + reset. + + + + + + + + + | + A27 + | + A26 + | + A25 + | + A24 + | + D7 + | + Do + | + Ds + | + D4 + | + D3 + | + D2 + | + Di + | + DO + | + + + + + + + + + Don't + care, + some + 000 + RAM + 00 + 1 + device + No + memory + + + codes + are + reserved. + | + 001 + Typel + Flash + | + 01 + 2 + 32Kbyte + + + 000 + No + peripheral + | + 010 + Type2 + Flash + | + 10 + 3 + 64Kbyte + + + + + + + + + 001 + T3Link + 110 + ROM + 114 + 128Kbyte + + + 010 + 3Fax + 256Kbyte + + + Contact + Psion + for + 512Kbyte + + + an + official + code. + 1Mbyte + + + + + + + + + Pull + up, + pull + down + resisters + would + usually + be + used + to + place + these + lines + in + the + desired + state + on + reset. + + + High + value + resisters + of + typically + 100k + would + be + used + to + allow + ASIC4 + and + bus + devices + to + drive + these + + + lines + to + other + levels + during + normal + operation. + + + + + + + + + ASIC4 + should + be + powered + from + its + host + Series + 3/3a/HC. + High + current + peripheral + chips + or + volatile + + + memories + should + have + their + own + supply. + Whenever + the + Series + 3/3a/HC + is + powered + down, + has + its + + + batteries + removed, + or + has + it's + pack + doors + open, + any + attached + ASIC4 + will + be + powered + down + and + reset + + + upon + resumption + of + power. + Taking + the + 3Fax + as + an + example + with + one + Read + Only + Memory + device + of + + + 512k + the + required + configuration + is: + + + + + + + + + Revision + 1.00 + Page + 26 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + ASIC4 + Pin-out + + + + + + + + + Pin + No + Pin + Name + + + 50 + DO + + + 49 + D1 + + + 48 + D2 + + + 47 + D3 + + + 46 + D4 + + + 45 + D5 + + + 44 + D6 + + + 43 + D7 + + + + + 13 + AO + + + 12 + Al + + + + + 11 + A2 + + + + + 8 + A3 + + + + + 7 + A4 + + + + + 6 + AS + + + + + 5 + A6 + + + + + 4 + AT + + + + + 3 + A8 + + + + + 2 + AQ + + + + + 1 + Al0 + + + 64 + All + + + 63 + Al2 + + + 62 + Al3 + + + 61 + Al4 + + + 60 + Al5 + + + 29 + Al6 + + + 28 + Al7 + + + 27 + Al8 + + + 25 + Al9 + + + 24 + A20 + + + 23 + A21 + + + 22 + A22 + + + 21 + A23 + + + 20 + A24 + + + 19 + A25 + + + 18 + A26 + + + 17 + A27 + + + 37 + CSO + + + 36 + CS1 + + + 35 + CS2 + + + 34 + CS3 + + + 33 + CS4 + + + 32 + CS5 + + + 31 + CS6 + + + 30 + CS7 + + + 16 + OE + + + 14 + WR + + + 15 + VPS + + + 39 + POR + + + 40 + SCLK + + + 38 + SDAT + + + 59 + SDIR + + + 51 + LBO + + + 56 + MCSD + + + 52 + INO + + + 53 + INI + + + 54 + IN2 + + + 55 + X2D2 + + + 57 + ATST + + + 10 + VDD + + + 42 + VDD + + + 9 + GND + + + 26 + GND + + + 41 + GND + + + 58 + GND + + + + + + + + + Revision + 1.00 + + + + + + + + + Direction + + + VO + + + vO + + + + + + + + + fe) + + + + + + + + + ~*=“O0O000000000 + + + + + + + + + fo) + + + + + + + + + PWR + + + PWR + + + PWR + + + PWR + + + PWR + + + PWR + + + + + + + + + Pin + Description + + + + + Databus + + + + + Databus + + + + + Databus + + + + + Databus + + + + + Databus + + + + + Databus + + + + + Databus + + + + + Databus + + + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + + + + + + + Address + bus + - + register + AT2/Oscillator + Output + in + PSPRAM + Mode + + + + + + + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Device + chip + selects + + + + + Output + Enable/Refresh + in + PSRAM + Mode + + + + + Write + pulse + + + + + VPP + control + + + + + Reset + input + + + + + Serial + clock + input + + + + + Serial + Data + input + + + + + Protocol + Direction + indication + Bit + + + + + Low + Battery + detect + driver + output + (Open + drain) + + + + + PSRAM + Mode + Select + + + + + General + Purpose + inputs + + + + + General + Purpose + inputs + + + + + General + Purpose + inputs/Refresh + Disable + in + PSRAM + Mode + + + Oscillator + Input + for + PSRAM + Mode + + + + + Test + input + (pull + high + to + put + device + into + address + test + mode) + + + Power + inputs + + + + + Power + inputs + + + + + Ground + + + + + Ground + + + + + Ground + + + + + Ground + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Page + 27 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + A11 + A12 + A13 + A14 + A15 + SDIR + GND + ATST + PS + OSCIN + IN2. + IN1 + INO + LBO + DO + D1 + + + + + + + + + - + LU + Li + Lt + Ly + ae + L + Ls + LI + Li + + + + + + + + + 62 + 61 + 60 + 57 + 56 + 54 + 53 + 52 + 51 + + + + + + + + + 64 + + + + + + + + + A10 + 48 + D2 + + + AQ + 47 + D3 + + + A8 + 46 + D4 + + + A7 + 45 + D5 + + + A6 + 44 + D6 + + + AS + 43 + D7 + + + A4 + 42 + VDD + + + AS + ASIC4 + 41} + —J + GNo + + + + + GND + 40 + SCLK + + + VDD + 39 + POR + + + A2 + 38 + SDAT + + + Al + 37 + cso + + + AO + 36 + cs1 + + + WR + 35 + cs2 + + + VPS + 34 + CS3 + + + OE + 33 + cs4 + + + + + + + + + 17° + 18 + «#19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31° + 32 + + + + + + + + + Rigizipininigiolgipinipimdeig + + + + + + + + + A27 + A26 + A25 + A24 + A23 + A22 + A21 + A20 + A19 + GND + A18 + A17 + A16 + CS7 + CS6 + CS5 + + + OSCOUT + + + + + + + + + Diagram + of + ASIC4 + Pin-out + (NEC) + + + + + + + + + Revision + 1.00 + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Page + 28 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 7. + ASIC + 5 + + + + + + + + + What + is + ASIC + 5? + + + + + + + + + ASICS + is + custom + integrated + circuit + designed + for + use + in + Memory + Packs + (called + SSDs) + and + peripheral + + + devices. + ASICS + provides + three + primary + functions. + A + built + in + UART + provides + for + serial + + + communication + at + baud + rates + of + up + to + 48000 + baud. + General + purpose + I/O + pins + provide + for + a + wide + range + + + of + control + and + communication + applications. + Finally + ASIC5 + provides + address + and + data + lines + for + access + + + to + memory + devices + and + memory + mapped + peripherals. + A + typical + ASICS + peripheral + such + as + the + 3Link + + + consists + of + an + ASICS + connected + to + port + C + of + a + series + 3/3a, + a + ROM + memory + device + mapped + into + + + ASICS's + addressing + space + and + line + drivers + to + convert + the + UART + signals + from + ASICS + into + standard + + + RS232 + levels. + + + + + + + + + Chip + select + + + + + + + + + ASIC5 + rea + Memory + + + + + + + + + RS232 + Line + Drivers + + + + + + + + + Psion + Serial + link + + + + + + + + + ASIC5 + Modes + + + + + + + + + ASICS + can + operate + in + two + modes. + In + pack + mode + ASICS + generates + all + the + address, + data, + and + control + + + signals + necessary + to + access + memory + devices. + No + peripheral + functions + are + available + in + this + mode. + In + + + peripheral + mode + ASICS + has + only + limited + memory + address + capabilities + as + some + or + all + address + and + + + control + lines + are + reused + for + I/O + purposes. + ASICS + is + placed + into + peripheral + mode + by + setting + the + + + peripheral + bit + in + ASIC5's + PBMODE + register. + + + + + + + + + ASIC5 + as + a + UART + + + + + + + + + ASICS + contains + a + full + function + UART + which + supports + baud + rates + of + up + to + 48000 + bits + per + second. + In + + + order + to + use + ASIC5 + as + a + UART, + ASICS5 + must + be + placed + into + peripheral + mode. + In + this + mode + the + input + + + signals + PAO, + PAI, + PA2, + PA3 + become + the + UART + inputs + RX, + CTS, + DSR, + and + DCD + respectively. + The + + + output + signals + PDO, + PD1, + PD2 + become + the + UART + signals + TX, + RTS, + and + DTR. + Serial + data + is + + + transmitted + from + the + TX + line. + Incoming + serial + data + is + received + by + the + RX + line. + RTS + and + DTR + can + be + + + used + for + handshaking + or + as + general + purpose + outputs + and + need + to + be + set + high + or + low + explicitly + by + + + software. + CTS, + DSR, + and + DCD + can + be + used + for + handshaking + or + as + general + purpose + inputs. + + + + + + + + + The + Psion + SIBO + serial + link + which + connects + ASIC5 + to + a + host + computer + is + a + two + wire + interface + + + consisting + of + a + data + and + a + clock + line. + ASICS + generates + it's + baud + rate + clocks + from + this + clock + line. + + + Under + normal + operation, + clock + pulses + along + a + Psion + SIBO + serial + link + only + accompany + data + frames. + To + + + be + able + to + generate + baud + rate + clocks + ASICS + requires + a + steady + clock + from + the + Hosts + Psion + port. + To + + + facilitate + this, + Psion + serial + links + can + be + put + into + a + mode + called + continuous + clocking + where + clock + pulses + + + are + generated + regardless + of + whether + there + is + any + actual + data + to + be + transferred. + Continuous + clocking + + + + + + + + + Revision + 1.00 + Page + 29 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + increases + power + consumption + and + Psion + serial + links + should + not + be + left + in + this + mode + unnecessarily. + + + The + UART + portion + of + ASICS + is + capable + of + generating + interrupts + when + characters + are + received, + when + + + the + transmitter + is + awaiting + a + character + to + send + and + when + there + is + a + change + of + state + on + the + handshaking + + + lines. + ASICS + has + only + one, + active + high, + interrupt + line. + This + line + is + shared + between + these + interrupt + + + sources. + When + an + interrupt + is + generated + it + is + the + responsibility + of + software + to + determine + the + cause + of + + + the + interrupt. + + + + + + + + + A + character + to + be + transmitted + should + be + written + to + the + Transmitter + Holding + Register + where + ASICS + will + + + convert + it + to + serial + form + for + transmission. + The + register + will + be + emptied + once + the + character + has + been + + + transmitted. + ASIC5 + contains + no + internal + buffering. + The + Transmitter + Holding + Register + must + be + empty + + + before + writing + a + character + to + it. + The + state + of + the + Transmitter + Holding + Register + is + reflected + in + the + + + Transmitter + Empty + bit + in + the + UART + status + register. + Enabling + the + Transmitting + Holding + Register + + + interrupt + will + cause + ASICS + to + generate + an + interrupt + every + time + that + the + Transmitting + Holding + Register + + + becomes + empty. + Reading + the + UART + Status + Register + will + clear + the + interrupt. + Received + characters + are + + + copied + into + the + Receive + Character + Register. + If + the + Receive + Character + Interrupt + is + enabled, + ASICS + + + generates + an + interrupt + on + each + character + received. + If + the + character + is + received + in + error + due + either + + + parity, + framing + or + overrun + errors, + appropriate + bits + in + the + UART + Status + Register + are + set + to + reflect + this. + + + + + + + + + ASIC5 + for + parallel + I/O + + + + + + + + + Lines + PAO-PA7 + form + a + general + purpose, + non + latched, + 8 + bit + input/output + port. + All + access + to + this + port + + + take + a + total + of + twelve + clock + cycles. + The + clock + is + generated + from + the + Psion + Serial + Link. + Actual + + + memory + access + cycles + only + last + for + one + clock + cycle. + Twelve + cycles + are + required + because + data + being + + + sent + or + received + needs + to + be + converted + to + or + from + the + Psion + serial + format. + Because + of + the + conversion + + + read + accesses + occur + on + the + third + cycle, + write + cycles + on + the + twelfth. + This + is + usually + of + no + real + + + consequence + to + the + peripheral + designer + + + + + + + + + In + peripheral + mode + CSO + will + be + taken + low + for + one + clock + period + each + time + Port + A + is + accessed. + Data + + + outputted + from + this + port + will + remain + valid + for + only + the + period + that + CSO + is + low. + In + pack + mode + Port + A + + + forms + the + data + bus + in + memory + mapped + systems. + A + read + from + or + write + to + Port + A + in + this + mode + will + + + result + in + one + of + the + lines + CSO-CS3, + being + taken + low + for + one + clock + period. + The + line + which + will + be + + + taken + low + will + depend + on + the + address + being + generated + for + the + access. + During + read + cycles + OE + line + will + + + be + taken + low + and + remain + so + for + 10 + cycles. + Data + present + on + PAO-PA7 + must + remain + stable + for + the + last + + + nine + cycles. + During + write + cycles + the + WR_B + line + will + be + taken + low + for + the + second + half + of + the + cycle + over + + + which + one + of + CSO-CS3 + is + low. + If + port + B + is + set + to + counter + mode, + accessing + port + A + will + result + in + the + + + counter + being + incremented + upon + completion + of + the + access. + + + + + + + + + ASICS + can + be + programmed + to + generate + an + interrupt + whenever + the + state + of + line + PA4 + changes. + Reading + + + port + A + will + clear + this + interrupt. + One + use + of + PA4 + is + as + the + BUSY + line + in + a + Centronics + port + + + implementation. + + + + + + + + + The + Lines + PBO-PB7 + can + be + programmed + to + operate + in + four + different + modes. + Two + of + these + modes + are + + + for + testing + purposes + and + will + not + be + discussed + further. + In + latched + mode, + data + written + to + the + Port + B + + + resister + is + latched + onto + the + Lines + PBO-PB7 + and + will + remain + there + until + a + following + write + to + Port + B + or + a + + + reset + condition + occurs. + In + counter + mode, + the + binary + value + on + lines + PBO-PB7 + is + incremented + following + + + any + access + to + port + A. + With + ASICS + in + pack + mode + lines + PBO-PB7 + form + the + address + lines + AO-A7. + + + Placing + port + B + into + counter + mode + allows + 256 + consecutive + memory + locations + to + be + read + without + need + to + + + set-up + the + address + of + each + access. + + + + + + + + + Lines + PDO-PD7 + are + general + purpose + outputs. + In + pack + mode + these + form + the + address + lines + A8-A15. + In + + + peripheral + mode + lines + PDO, + PD1, + PD2 + become + UART + outputs. + + + + + + + + + Lines + PCO-PC4 + in + pack + mode + form + the + address + lines + A16-A20. + In + peripheral + mode + lines + PC4 + and + + + PC7 + become + inverted + inputs + and + can + be + used + as + edge + triggered + interrupt + lines. + PC5 + becomes + the + + + interrupt + output + line. + PC6 + becomes + a + general + purpose + latched + output. + PCO-PC3 + become + a + dual + + + synchronous + serial + port + for + use + in + magnetic + card + systems. + + + + + + + + + Revision + 1.00 + Page + 30 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + ASIC5 + for + Barcodes + + + + + + + + + Psion + barcode + peripherals + use + the + UART + functionality + of + ASICS + to + receive + data + from + a + dedicated + + + barcode + scanner + IC. + + + + + + + + + ASIC5 + for + Card + readers + + + + + + + + + Magnetic + card + readers + generate + clocked + serial + data. + ASIC5 + contains + two + synchronous + serial + ports + for + + + connection + to + card + readers + or + other + peripherals + which + generate + clocked + serial + data. + + + + + + + + + Reset + and + configuration + + + + + + + + + Following + a + reset + or + power + up + ASIC5 + will + read + the + form + in + which + to + configure + itself + from + the + data + on + + + data + lines + PAO-PA7. + Line + PC6 + is + used + to + select + whether + ASICS + is + to + operate + in + pack + or + peripheral + + + mode. + The + table + below + shows + the + meaning + of + each + of + these + lines + during + reset. + In + peripheral + mode + + + lines + PAO-PA7 + should + be + set + to + give + an + indication + of + the + type + peripheral + the + ASICS + is + forming. + + + combinations + of + types + can + be + used. + + + + + + + + + 000 + RAM + 00 + 1 + device + No + memory + + + + + 001 + Typel + Flash + | + 01 + 2 + 32Kbyte + + + + + 010 + Type2 + Flash + | + 10 + 3 + 64Kbyte + + + + + 110 + ROM + 114 + 128Kbyte + + + + + 1 + 1 + 1 + Write + protect + 256Kbyte + + + 512Kbyte + + + 1Mbyte + + + + + + + + + Peripheral + Mode + Type + + + + + + + + + RS232 + port + + + Centronics + (Parallel) + port + + + + + + + + + Hx + KK + KK + XX + + + xo + KKM + KK + XX + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + Pull + up, + pull + down + resisters + would + usually + be + used + to + place + these + lines + in + the + desired + state + on + reset. + + + High + value + resisters + of + typically + 100k + would + be + used + to + allow + ASICS + and + bus + devices + to + drive + these + + + lines + to + other + levels + during + normal + operation. + + + + + + + + + ASICS + should + be + powered + from + its + host + Series + 3/3a, + Workabout + or + HC. + High + current + peripheral + chips + + + or + volatile + memories + should + have + their + own + supply. + Whenever + the + Series + 3/3a/HC + is + powered + down, + + + has + its + batteries + removed + or + has + its + pack + doors + open, + any + attached + ASICS + will + be + powered + down + and + + + will + be + reset + upon + resumption + of + power. + + + + + + + + + Revision + 1.00 + Page + 31 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + ASIC5 + Pin-out + + + + + + + + + A10 + Ali + A1l2 + Ai3 + NC + A14 + A15 + DO + D1 + D2 + + + + + + + + + DONO + o + net + + + + + + + + + ASIC5 + + + + + + + + + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + + + + + + + + + MAMAMAAMMo + + + + + + + + + WR + VPS + OE + A20 + A19 + NC + A18 + A17 + A116 + CS3 + CS2 + + + + + + + + + ASIC + 5 + current + pin-out + (TI + version + CF30179) + + + + + + + + + Revision + 1.00 + Page + 32 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 8. + EXAMPLE + PERIPHERALS + + + + + + + + + The + ASIC4 + Example + Interface + Board + + + + + + + + + The + ASIC4 + Example + Interface + Board + detailed + in + this + chapter + is + intended + to + provide + the + developer + with + + + a + simple + example + of + a + Psion + ASIC4 + peripheral. + To + this + end, + the + actual + practical + usefulness + of + the + + + hardware + is + of + secondary + importance. + In + fact, + the + board + essentially + consists + of + eight + LEDs + connected + + + via + some + latches + to + an + ASIC4. + Using + a + device + driver, + the + host + machine + is + able + to + control + the + status + of + + + the + LEDs. + Specifically, + the + board + translates + SIBO + serial + protocol + signals + into + a + parallel + 8-way + data + + + bus + format + that + can + be + used + to + set + the + various + 74HC + series + latches + and + gates. + It + is + intended + that + the + + + board + can + be + readily + adapted + to + run + on + all + currently + available + Psion + machines. + The + only + physical + + + change + that + need + be + made + concerns + connection + to + the + host + machine's + external + expansion + interface. + + + + + + + + + In + the + following + circuit, + an + eight-bit + tri-state + data + buffer, + U3, + and + an + eight-bit + output + data + latch, + US, + + + are + commoned + together + to + the + eight + LEDs + thereby + enabling + their + status + to + be + sensed + and + set. + In + + + addition, + a + facility + for + generating + hardware + interrupts + is + provided + by + means + of + a + suitably + connected + + + switch, + S1, + and + a + third + eight-way + buffer, + U4. + U4 + is + the + interrupt + switch + status + buffer. + It + holds + the + + + values + of + the + two + input + switches + S2 + and + S3 + which + are + read + as + part + of + the + interrupt + service + routine. + + + Depending + on + the + value + of + the + switch + positions, + a + different + response + can + be + output + to + the + LEDs + from + + + the + set + buffer, + US. + One + of + the + D-type + flip-flops + in + U6 + is + used + to + latch + hardware + interrupt + signals + into + + + the + INT + line + (pin + 5) + of + the + reduced + external + expansion + interface + connector. + On + completion + of + the + + + interrupt + routine + code, + it + is + necessary + to + reset + this + flip-flop + and + hence + the + interrupt + hardware + by + means + + + of + a + write + to + address + Al. + Address + decoding + is + provided + by + two + 2-to-4 + decoders + on + chip + U1 + paralleled + + + to + address + lines + AO + and + Al. + A + circuit + diagram + of + the + ASIC4 + Example + Interface + Board + is + presented + + + overleaf + for + the + case + of + a + host + S3a. + + + + + + + + + Note + that + it + is + possible + to + construct + this + circuit + with + or + without + the + compiled + driver + code + in + an + on- + + + board + ROM. + The + developer + merely + has + to + set + the + resistors + on + the + three + data + bus + lines + DO-D2 + such + that + + + the + corresponding + info + byte + conveys + the + appropriate + information. + The + meaning + of + the + various + bits + in + + + an + ASIC4 + info + byte + was + discussed + earlier + in + chapter + 6. + If + a + ROM + is + to + be + used, + then + the + info + byte + read + + + off + DO-D7 + on + reset + should + include + bits + 001 + on + lines + D2-D0. + This + requires + the + R1/R2 + optional + resistor + + + to + be + connected + to + Vcc. + If + a + ROM + is + not + used, + as + was + the + case + with + the + constructed + test + circuit, + the + + + data + bus + lines + D2-D0 + should + be + set + to + 000. + This + is + done + by + choosing + the + resistors + connected + to + ground + + + from + the + three + R1/R2, + R3/R4 + and + R5/R6 + pairs. + + + + + + + + + Revision + 1.00 + Page + 33 + of + 115 + pages + + + + + + + + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + VOD + + + voc + voc + voc + voc + + + 3 + + + cs + ca + cio + _|+ + caa + For + 128K + Bute + ROM + fit + option + resistors + Ri, + R4, + RG, + RE + and + Rio + eibe + + + idon + toon + ioon + Our + evs + For + no + ROM + fit + option + resistors + RZ, + R4, + RE + bo + 2 + + + ue + ve + ve + as + VOD + + + SNC + GND + GND + GND + + + 1 + + + 3 + + + Xf + RE-/R4 + + + vor + GND + + + res + Di + 2g + 100K + + + ag + voo + | + 338 + + + bo + = + ae + base + es + Do + + + Di + 14 + Bd + 1 + + + AS + Bi + + + DE + Be + be + (45 + De + + + veo + DS + ce + be + Cie + mE + v + Biel + + + Da + 18 + ba + SNC + + + oS + + ba + Te + DS + + + az + BS + + + R22 + [ery + AS + be + 20 + [T= + 3 + + + 100K + Br + aS + BS + [ei + isk + RE + RE + + + aio + fa + 100K + + + ort + ze + | + 22 + bz + z + + + Al2 + + + ails + oe + [24 + + + 7 + ate + 1 + + + aaa + oe + awe + hae + + + Aiz + L + + + ae + GND + + + eto + nigga + | + ao + + + vor + voc + + + ZEK—ine + ROM + DS + R16 + 100K + + + Ss + Is + + + RT-RE + RS/RL0 + + + vos + z + z + + + 7 + FaHcT4a + + + ja + oR + oR + + + R26 + + + Rea + 100K + 1 + 1 + DF + R20. + 100K + + + LooR + + + GND + + + GND + + + Ree + SND + + + aoe + t + R27 + ba + + + voc + LED + GND + + + CONNL + + + sp7 + bo + * + 0 + + + sck7 + b-# + = + Bo + 18/ivi + = + 1ai + +329 + + + = + Di + is + a_i + LED + ND + + + sDSs/INT + iv2 + 0 + 1Az + + + SCKS/“EXON + a + Wie + D2 + 14 + is. + 1AS + & + P2 + + + z + z + Ds + iz + = + Ps + + + Wor + * + a + vo + ava + iaa + + + 4 + z + bas + ii_F4 + + + She + , + a. + be + revi + 281 + Ge + re + LED + GND + + + YE + 2Yz + ZAz + + + CON + COMMS + CONN + be + oer + te + be + S| + S02 + 282 + (re + Pe + + + bre) + S)5: + Soy + bere + + + FPS4HC1sg + + + GND + te + het + LED + GND + + + vor + 28 + brs + + + DL + uza + + + 1 + OE + 4 + ae + FaHceas + FaHCETS + + + z + 3 + ORD + LED + ND + + + 2 + cso + 2 + FaHca4d + + + A + t + ua + + + WF + Baves + clr + Se + T4Hese + DO + 18 + Tyg + LAL + + + GND + 1006F + El + tel + ge: + {ee + LED + GND + + + 1B + a + De + 14 + + + ive + 9 + 1az + + + Mee + Nf + 14) + 4 + vo + BS + tetiva + iad + + + D2 + GND + U2B + is + ba + 3 + + + B + vi + Zvi + ZAL + + + 4 + WR + 4 + oS + + + LED + GND + + + Y2 + 2vz + BAZ + + + = + 6 + Lor + 15 + bss + + + Gc + YS + 2yYe + 2As + + + =P + = + Dre + 3/oy4q + Baa + + + FaHCLss + + + yo + OBAYSS + FaHese + ee + 470 + LED + GND + + + GND + Vos + a + Si + voc + ¥ + v + + + vos + J" + GND + SND + DATA + OUTPUT + + + vor + FaHCe44 + + + DOS + la + Us6Al + Lk + Interrupt + Sw + + + a: + + + = + Ne + Saal + = + a + B + Db + 2 + CC? + 1993 + (PSIOS + PLS. + + + aa + ADDRESS + R-M + FUNC + 3 + Interrupt + In + + + + + Bava + fal + RYH + Read + & + write + to + latch + SLK + Eiki + Sp + ee) + omnes + + + GND + rs + Md + Clear + Interrupt + els; + = + R25 + + + 1 + R + Read + status + 100K + Poe + REY + : + oO + + + status + Bit + Func + F4HCr4 + Title + + + a + Ineut + a + + + L + Tneut + 1 + > + ASICS + Example + IF + + + 2-5 + Not + Used + GND + GND + Size + Pocument + Number + REV + + + 6 + Interrupt + Line + B + 7 + lo.s + + + ? + Interrupt + Latch + : + + + Date: + Aerial + 19, + 1995|[Sheet + i_of + Z + + + + + + + + + Page + 34 + of + 115 + pages + + + + + + + + + 1.00 + + + + + + + + + 1S10n + + + + + + + + + Rev + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + Psion + 3-Link + + + + + + + + + The + Psion + 3-Link + is + an + ASIC5-based + peripheral + that + enables + the + user + to + transform + SIBO + serial + + + protocol + signals + into + RS232 + format + data + so + that + a + host + Psion + machine + can + communicate + with + a + PC + or + + + printer. + The + diagram + below + shows + the + schematic + of + a + TTL + level + RS232 + based + expansion + device. + The + + + interface + is + based + around + ASICS + and + allows + the + standard + RS232 + device + driver + contained + in + EPOC + to + + + be + used. + + + + + + + + + Transistor + Q1 + provides + a + switched + power + rail + for + any + other + expansion + device. + This + rail + will + + + automatically + be + switched + off + when + the + RS232 + port + is + closed. + D1 + is + required + to + isolate + the + supply + so + + + that + the + external + device + does + not + back + power + the + SIBO + computer + when + it + enters + the + standby + state. + If + + + the + additional + device + does + not + require + a + supply + or + only + uses + a + few + microamps + then + Q1 + and + D1 + can + be + + + omitted. + Vcc + and + the + supply + for + the + expansion + device + can + be + directly + connected + to + Vcc2. + + + + + + + + + If + CMOS + level + RS232 + signals + are + required + then + IC1 + can + be + replaced + with + a + 74HC244 + device. + If + + + inverted + sense + RS232 + signals + are + required, + IC1 + can + be + replaced + with + a + 74HC241 + device. + + + + + + + + + The + diagram + overleaf + shows + the + circuitry + for + an + ASICS-based + 3-link + with + ROM. + + + + + + + + + Revision + 1.00 + Page + 35 + of + 115 + pages + + + + + + + + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + vec + + + Rig + + + Icz + vec + 100K + + + 64/128K + PROM + SITE + E + + + B + + + ag + 12Tag + wy + po + Laz + ba + + + ta + ¥ + 14 + Di + + + AL + D1 + + + To + é + TS + Be + + + Az + Dz + + + g + id + Da + + + as + DS + + + 3 + tg + ba + + + Aa + ba + + + id + 15 + DS + + + aS + DS + + + 20 + DE + + + AS + De + }s¢ + = + + + ay + DF + + + ae + voc + voc + + + ag + + + Alo + vec + + + AlL + - + + + A1lz + ne + |S? + + + ars + ver + 4 + i + + + Ais + Pst + [22 + +08 + ce + cz + + + $3 + rea + Our + /25v + idon + io0n + + + Ale. + + + + + N + + + B + + + * + + + T + + + le + t + GND + + + GND + + + ND + Fs + + + ey + eee + 2g + + + Re + 100K + TRL + + + + + BCH + 1 + cs + cz + + + + + 1ur/50¥ + LuF/so¥ + + + GND + vee + + + mS + 1 + | + s + + + aL + + + rs + + + 82 + (ita + 1 + ies + + + veo + 22 + [aa + i + wees + + + 23 + i + 19° + + + iOurv2sy + + + D1 + Fi + 14 + + + ¢ + 13 + + + " + 24s + ex + i + ca + + + | + 1 + 4 + aa + c + + + = + vor + 15 + | + coy + yo + LAZ + ayes + + + 2 + t + 16 + 7 + SKT1 + CASE + + + za + 2- + Fi + + + Teu + uF + 7254 + + + BAYS? + I + FaHorS + 7d + TitN + taout + 2 + GND + SKTL + + + 36 + e + _DTR + + + PBO + + PAD + TBIN + TZOUT + RLSD/bco| + + + ba + PBL + © + pai + }32 + 294 + 7 + SIN + TzouT + 2 + rs + RX + + + 4 + tad + Sa + ei + ze + _Tx + + + x + * + PBZ + paz + [3 + T4IN + T40UT + Tx + + + 2 + PES + paz + = + 3 + Pare + DIR + + + PB4 + paa + [22 + £4 + R1OuIT + R1IN + p32 + _RX__§_+ + t + GND + + + a + ee + PBS + pas + fed + eno + se] + RZOUT + R2IN + Pst—Bek + . + DSR + + + PES + Pas + pse + 25) + REOUT + RSIN + bee—GeR + 4 + RTS + + + PE? + PA? + R4ouT + RaIN + * + cts + + + DS, + ig + Te + RI + + + * + a + WEE + + RS0UT + . + RSIN + * + RI + + + PDO + poco + i + at + S| + + + = + a + PDL + pci + H2 + 24 + eR + ql + sp + }25 + SIBO + RS2S2 + CONNECTOR + + + PDE + pez + He + ibe + Ria + L + c + + + BAYSS + co: + pea + fas + REG + Too + 100K + a + mMaxzan + GND + + + 12 + ciolesilcizicizicis4 + + + PDS + pes + + + SMB + PDS + roe + 3S + + + PD? + pe? + L414 + L + GND + in + Jin + Jin + Jain + Jain + + + | + 1008 + R4 + 25 + /ep + zen + b24 + GND + vovVoov¥ + vo + + + 1O5R + at + 27 + €39 + Pox + GND + GND + GND + GND + GND + + + ' + CLK + eSi + + + 26 + 2 + + + FOR + cs2 + + + i7q + Fo + s + T + + + 3g + N53 + PIL + + + cs + NG + BD + ¢np + PL2 + fh + + + 100pF + iz + + + veo + asics + [8 + 4 + + + GND + + + GND + ND + R? + + + RL + 100R + + + 100K + Sue + + + o——___| + + + cL + SH + SPDT + + + vee + 100n + + + CONNI + + + cer + GND + + + SRT + ee + RG + RS + + + SDS/INT + BS + Copuriaht + CC) + Psion + PLO + 1991 + + + ScKS/ExON + PS + + + Vee + bs + File + name! + CONHH + DRAFT + RS232.5CH + + + yee + Bg + ioorR + is + a + 10k + Braun: + MG + + + CON + COMMS + CONN + R20 + B2xe4—Cay7 + PCB + Rey + 1.4 + + + 100K + Title + + + ¥ + 2|a + + + GND + Rev + 1.2 + Move + SD + (pin + 25 + IC2> + from + pin + 23 + to + 21 + of + Ici + : + EONSUMER + Bases + ExCeL + on + + + Rev + 1.3 + Alter + Ri? + from + 100K + to + 10K + Size + Pocument + Number + REV + + + Rev + 114 + Added + C1io—c14 + = + + + Rev + 1.5 + Moved + C3 + to + CLK + input + GND + GND + is + 6500.0008 + cata + + + Date: + June + i0, + i953 + Sheet + i + oF + L + + + + + + + + + Page + 36 + of + 115 + pages + + + + + + + + + 1.00 + + + + + + + + + 1S10n + + + + + + + + + Rev + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 9. + DEVICE + DRIVER + OVERVIEW + + + + + + + + + Introduction + + + + + + + + + Once + a + piece + of + peripheral + hardware + has + been + designed + the + appropriate + software + must + be + written + to + + + control + it. + All + hardware + on + Series + 3/3a, + Workabout + and + HC + machines + is + controlled + by + logical + and + + + physical + device + drivers. + These + act + as + the + logical + low-level + software + interface + between + a + piece + of + + + hardware + and + an + application + that + uses + it. + The + remainder + of + this + document + is + concerned + with + the + + + methods + by + which + a + device + driver + is + able + to + communicate + with + and + thereby + control + an + ASIC4 + or + + + ASICS-based + peripheral. + + + + + + + + + APPLICA + TION + SOFTW + ARE + + + + + + + + + Psion + C + PLIB + call + interface + + + LOGICAL + DEVICE + DRIVER + + + + + + + + + PHYSICAL + DEVICE + DRIVER + + + + + + + + + PHYSICAL + HARDW + ARE + + + + + + + + + This + chapter + is + intended + to + guide + the + programmer + through + the + central + issues + involved + in + writing + + + device + drivers + for + peripherals + that + attach + to + the + family + of + Psion + host + machines + based + around + the + + + proprietary + SIxteen-Bit + Organiser + (SIBO) + architecture. + The + purpose + of + a + device + driver + is + to + abstract + + + away + the + hardware + details + required + to + conduct + communication + between + a + peripheral + and + a + software + + + application + that + uses + that + peripheral. + The + device + driver + therefore + performs + the + logical + processing + + + required + to + translate + low + level + hardware + instructions + into + high + level + application + services. + Psion + device + + + drivers + are + written + in + 8086 + assembler + and + following + convention + are + divided + into + a + logical + layer + + + residing + over + a + physical + layer. + A + physical + device + driver + (PDD) + contains + the + code + required + for + talking + + + directly + with + the + hardware + device + and + provides + a + set + of + low + level + hardware + specific + services. + A + logical + + + device + driver + (LDD) + performs + the + logical + processing + that + transforms + these + low + level + services + into + the + + + high + level + services + used + by + an + application. + This + two-layer + nature + of + device + drivers + at + Psion + can + be + + + illustrated + by + the + following + example. + An + application + using + the + serial + driver + decides + that + it + requires + + + RTS/CTS + handshaking. + It + calls + an + LDD + which + decides + whether + or + not + a + line + should + be + driven. + If + the + + + answer + is + yes, + the + LDD + calls + the + appropriate + PDD + and + asks + for + a + particular + line + to + be + driven + to + a + + + specific + state. + The + PDD + duly + carries + out + the + requested + service. + Psion + SIBO + machines + often + use + the + + + same + LDD + with + a + PDD + written + specifically + for + each + version + of + the + hardware + device. + In + such + a + + + situation, + splitting + the + device + driver + is + highly + desirable. + In + the + example + given + above, + however, + the + + + LDD + could + have + talked + directly + with + the + hardware + negating + the + requirement + for + a + separate + PDD. + + + Similarly, + most + external + peripherals + would + normally + use + an + LDD. + + + + + + + + + An + LDD + must + provide + a + minimum + of + eight + functions + for + use + by + the + operating + system. + The + functions + + + are + passed + to + the + OS + via + a + table + of + function + offsets + (referred + to + as + the + vector + function + table). + These + + + functions + are + mandatory. + Similarly, + a + PDD + must + provide + two + functions + for + use + by + the + operating + + + system + and + may + provide + more + if + required. + An + LDD + will + usually + provide + further + services/functions + for + + + use + by + an + application. + The + form + these + take + is + dependent + on + the + LDD + requirements + and + the + functions + + + supplied + by + the + associated + PDD(s). + + + + + + + + + Revision + 1.00 + Page + 37 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Psion + SIBO + machines + are + supplied + with + a + set + of + resident + device + drivers + built + into + the + ROM + each + of + + + which + can + be + replaced + with + an + installable + device + driver + having + the + same + name. + Installable + device + + + drivers + can + also + be + added + to + increase + the + number + of + available + device + drivers. + Installing + a + device + driver + + + is + carried + out + dynamically + without + resetting + the + machine + (this + is + not + the + case + with + many + operating + + + systems). + + + + + + + + + Device + Names + and + Channels + + + + + + + + + The + name + of + a + device + driver + is + the + mechanism + by + which + an + application + can + obtain + a + channel + to + that + + + device + driver. + A + logical + device + driver + name + always + has + three + characters + followed + by + a + colon. + For + + + example, + "TTy:" + is + the + serial + LDD. + This + name + is + required + to + uniquely + identify + the + LDD + to + the + EPOC + + + OS + when + attempting + to + open + a + channel + on + it. + A + physical + device + driver + name + always + has + the + three + + + characters + of + its + owning + LDD + followed + by + a + period, + a + further + three + characters + and + a + colon. + For + + + example + "TTy.UAR" + is + the + ASICS + UART + driver + and + "TTy.srRx" + is + the + 16450/16550 + driver. + The + first + + + three + characters + of + a + PDD + name + are + the + name + of + the + LDD + to + which + the + PDD + belongs. + The + second + set + + + of + three + characters + uniquely + identify + the + PDD. + Thus + in + the + above + examples, + both + PDDs + belong + to + the + + + "tty:" + LDD. + + + + + + + + + A + channel + can + be + opened + on + an + LDD + by + calling + the + PLIB + library + function + p_open. + EPOC + uses + the + + + driver + name + passed + through + an + application + p_open + call + to + invoke + the + IoOpen + operating + system + + + service. + This + service + in + turn + calls + the + associated + driver + ‘open + vector’ + which + can + decide + whether + or + not + + + to + open + a + channel + on + the + driver. + The + assembled + ASIC4 + Example + Interface + Board + logical + device + + + driver, + A4EXIF.LDD, + for + example, + has + the + three-character + device + name + "LED" + so + a + channel + with + its + + + handle + in + pcb + may + be + obtained + on + it + by + means + of + the + following + call: + + + + + + + + + p_open(&pcb, + "LED:", + -1) + + + + + + + + + In + this + call, + the + third + argument + refers + to + the + open + mode + and + a + value + of + -1 + indicates + that + the + mode + + + parameter + is + to + be + ignored. + To + obtain + a + channel + on + a + PDD, + an + application + should + call + the + DevopenPpp + + + OS + service. + Typically, + only + LDDs + open + PDDs + though + the + p_open + library + function + can + be + used + to + open + + + a + PDD + indirectly + as + illustrated + in + the + following + example: + + + + + + + + + p_open(&pcb, + “"TTY.UAR:", + -1) + + + + + + + + + For + a + device + driver + configuration + consisting + of + an + LDD + and + a + PDD, + the + application + will + usually + open + + + a + channel + to + the + LDD + only: + the + LDD + as + part + of + its + initialisation + would + open + a + channel + to + the + required + + + PDD. + If + an + LDD + requires + a + PDD + and + none + is + specified, + it + is + up + to + the + LDD + to + either + fail + the + open + + + request + or + hunt + for + a + loaded + PDD + that + it + can + use. + An + LDD + uses + the + DevFind + OS + service + to + search + for + + + a + PDD + as + for + instance + in + the + case + of + the + "TTy:" + device. + + + + + + + + + A + device + driver + may + be + capable + of + supporting + more + than + one + open + expansion + channel + at + a + time. + In + + + order + to + distinguish + the + channels, + a + qualifier + can + be + added + to + the + open + request + as + part + of + the + device + + + name. + It + is + then + up + to + the + device + driver + to + specify + the + format + of + the + qualifier. + By + convention, + + + channels + are + allocated + a + single + character + sequentially + from + the + character + 'A'. + For + example, + the + + + parallel + port + driver + can + support + two + open + channel, + 'A' + and + 'B'. + The + LDD + requires + one + of + these + + + qualifiers + in + order + to + open + a + parallel + driver + channel: + + + + + + + + + p_open(&pcb, + "PAR:A", + -1) + + + p_open(&pcb, + "PAR:B", + -1) + + + + + + + + + The + number + of + channels + that + can + be + thus + supported + will + in + general + be + dependent + on + the + host + SIBO + + + hardware. + In + the + case + of + the + serial + port + on + the + S3a, + for + instance, + only + one + SIBO + channel + can + + + legitimately + be + opened + corresponding + to + expansion + port + C. + With + the + Workabout + and + HC, + however, + it + + + is + possible + to + open + up + to + three + separate + SIBO + channels + on + ports + A + through + to + C + where + A + refers + to + the + + + top + port + of + the + host + machine, + B + to + the + bottom + port + and + C + to + the + side + (or + cradle) + port. + + + + + + + + + LDDs + have + been + designed + to + be + accessed + via + the + I/O + system. + I/O + requests + on + the + opened + channel + will + + + reach + the + 'strategy + vector' + of + the + device + driver. + PDDs + have + been + designed + to + be + accessed + by + an + LDD + + + + + + + + + Revision + 1.00 + Page + 38 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + either + via + far + calls + or + the + Devvector + OS + system + service. + Once + a + channel + has + been + obtained + on + a + + + device + driver, + the + operating + system + can + send + it + events + not + sent + to + other + applications. + Examples + are + + + events + generated + by + the + machine + being + switched + on + or + off, + memory + segments + being + moved + about + and + + + the + owning + application + being + panicked. + The + EPOC + OS + can + handle + a + maximum + of + 32 + device + drivers + + + on + a + Series3 + machine + and + 48 + on + other + machines. + + + + + + + + + Loadable + Logical + Device + Driver + Structure + + + + + + + + + Common + features + of + the + structure + of + loadable + LDDs + + + + + + + + + All + loadable + LDDs + must + conform + to + the + following + rules: + + + + + e + There + must + be + a + single + code + segment + and + no + data + segments. + The + code + segment + is + encapsulated + in + + + the + assembler + .asm + file + by + calls + to + the + codeSeg + and + EndCodeSeg + defines + respectively. + + + + + e + The + code + segment + must + begin + with + a + LibEnt + structure + which + indicates + the + LDD + name + or + + + signature + which + is + used + to + identify + the + driver + when + trying + to + open + and + close + channels. + + + + + e + There + must + be + at + least + eight + supported + functions + which + are + listed + in + the + LibEnt + struc. + + + + + + + + + LibEnt + Structure + + + + + + + + + The + first + field + of + the + LibEnt + structure + consists + of + a + two-byte + signature + containing + the + define + + + ‘LDDSignature’ + or + 'PDDSignature’ + in + the + case + of + a + PDD. + The + remaining + fields + consist + of + an + eight + + + byte + name + which + holds + the + device + driver + name + stored + as + a + zero + terminated + string + (note + that + the + + + trailing + colon + is + omitted), + a + two + byte + vector + count + which + must + be + at + least + eight + and + a + vector + table + + + listing + the + supported + device + driver + functions. + The + relevant + code + in + the + case + of + a + hypothetical + DevFunc + + + LDD + (DEVFUNC.LDD) + with + the + device + name + of + "TES:" + is + listed + below: + + + + + + + + + CodeSeg + + + + + + + + + ProcBegin@ + DevFuncLDD + + + + + + + + + dw + LDDSignature + + + db + 'TES',0,0,0,0,0 + + + dw + (VectorEnd-Vector) + /2 + + + Vector: + + + dw + DevFuncInstall + + + dw + DevFuncRemove + + + dw + DevFuncHold + + + dw + DevFuncResume + ; + Mandatory + LDD + vectors + + + dw + DevFuncReset + ; + must + be + in + this + order + + + dw + DevFuncUnits + + + dw + DevFuncOpen + + + dw + DevFuncStrategy + + + VectorHandler: + + + dw + DevFuncHandler + ; + Optional + LDD + vectors + + + InterruptVectors: + + + dw + DevFuncTickInt + + + VectorEnd: + + + + + + + + + ProcEnd + noret + + + The + vector + table + contains + the + offsets + within + the + device + drivers + code + segment + for + the + functions + required + + + + + + + + + by + the + EPOC + operating + system + which + must + be + entered + in + the + order + shown. + Note + that + in + this + + + document, + the + terms + vector + and + function + are + used + interchangeably. + + + + + + + + + Mandatory + LDD + Functions + + + + + + + + + All + LDDs + must + support + the + following + eight + functions: + + + + + + + + + @ + DevFuncInstall + called + on + device + installation + + + + + @ + DevFuncRemove + called + on + device + removal + + + + + @ + DevFuncHold + called + to + temporarily + disable + the + driver + + + + + @ + DevFuncResume + called + to + enable + the + driver + after + it + has + been + temporarily + disabled + + + + + + + + + Revision + 1.00 + Page + 39 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + @ + DevFuncReset + called + when + an + application + terminates + without + closing + the + channel + + + @ + DevFuncUnits + called + to + query + the + number + of + supported + units + (i.e. + channels) + + + + + @ + DevFuncOpen + called + to + open + a + channel + to + an + LDD + + + + + @ + DevFuncStrategy + called + to + access + the + driver's + functionality + from + the + I/O + system + + + + + + + + + All + of + the + eight + mandatory + routines + pointed + at + by + the + function + vector + table + will + be + called + FAR + by + the + + + operating + system + and + should + therefore + use + a + FAR + return + machine + code + instruction + to + return + control + + + back + to + the + OS. + Since + the + FAR + return + address + is + to + the + OS + it + does + not + matter + if + the + OS + moves + memory + + + whilst + code + in + the + LDD + is + being + executed: + the + OS + cannot + move + its + own + code. + + + + + + + + + DevFunclinstall + + + + + + + + + This + function + is + called + by + the + operating + system + when + the + device + driver + is + loaded + in + order + to + initialise + + + any + internal + variables. + It + should + not + be + called + directly + by + an + application + process. + The + DevInstall + + + operating + system + service + will + cause + this + function + to + be + called. + Applications + should + not + call + this + service + + + directly + and + should + call + instead + the + DevLoadLDD + service. + + + + + + + + + An + installable + device + driver + may + have + the + same + name + as + a + resident + device + driver. + When + the + operating + + + system + loads + a + device + driver, + it + places + it + at + the + end + of + the + device + driver + table. + The + operating + system + + + will + search + this + table + for + the + appropriate + device + driver + when + it + wishes + to + establish + a + channel. + The + + + search + starts + at + the + end + and + thus + will + locate + the + most + recently + installed + device + driver + (if + any) + or + if + not, + + + the + resident + driver. + By + this + mechanism + an + installable + driver + can + replace + any + resident + driver. + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state. + The + device + driver + should + + + take + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + + + this + involves + setting + the + DS + and + ES + registers + to + the + CS + register + or + more + commonly + just + using + the + CS + + + override. + The + operating + system + will + not + move + memory + whilst + in + this + function, + thus + the + normal + rules + + + governing + DS + and + ES + may + be + ignored. + All + operating + system + services + may + be + called, + except + those + + + concerning + file + or + device + access. + + + + + PASSED + + + + + No + values + are + passed + to + the + install + vector. + + + + + RETURN + + + + + If + the + installation + was + successful, + return + with + the + carry + flag + clear. + + + + + If + the + installation + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + PANIC + + + + + The + install + vector + must + not + panic: + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + install + function. + + + + + + + + + DevFuncRemove + + + + + + + + + This + function + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + be + + + unloaded. + It + should + not + be + called + directly + by + an + application + process. + The + DevRemove + operating + system + + + service + will + cause + this + function + to + be + called. + Applications + should + not + call + this + directly, + they + should + use + + + the + DevDelete + service. + Before + the + remove + function + is + requested, + the + device + driver + will + have + received + + + a + hold + request. + Thus + devices + will + only + ever + be + removed + when + in + a + held + state. + If + the + device + driver + is + + + currently + busy + serving + a + client, + the + remove + request + should + return + an + error. + Note + that + all + resident + + + device + drivers + will + return + an + error + since + there + is + no + mechanism + by + which + they + can + be + re-installed. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + operating + system + will + not + move + + + memory + whilst + in + this + function, + thus + the + normal + rules + governing + DS + and + ES + may + be + ignored. + All + + + operating + system + services + may + be + called + inside + the + remove + vector, + except + those + concerning + file + or + + + device + access. + + + + + PASSED + + + + + No + values + are + passed + to + the + remove + vector. + + + + + RETURN + + + + + If + the + remove + was + successful, + return + with + the + carry + flag + clear. + + + + + If + the + remove + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + + + + + + + Revision + 1.00 + Page + 40 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + PANIC + + + + + The + remove + vector + must + not + panic: + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + remove + vector. + + + + + + + + + DevFuncHold + + + + + + + + + This + vector + will + be + called + by + the + operating + system + when + a + logical + device + driver + is + requested + to + be + held. + + + The + hold + vector + is + called + in + the + context + of + the + operating + system + so + DS + and + ES + are + not + available. + The + + + DevHold + operating + system + service + will + cause + this + vector + to + be + called. + Applications + should + not + call + this + + + service. + Physical + device + drivers + cannot + invoke + holds + and + resumes. + The + operating + system + will + call + the + + + hold + vector + under + three + conditions: + + + + + e + Device + memory + segments + are + about + to + be + moved. + + + + + + + + + e + The + machine + is + about + to + switch + off + due + to + the + auto + switch + off + time-out + or + user + request, + it + + + enters + the + standby + state. + + + + + + + + + e + The + machine + is + about + to + switch + off + due + to + the + power + source + being + removed. + + + + + + + + + It + should + be + noted + that + holds + and + resumes + are + called + on + a + per + driver + basis + and + so + the + corresponding + + + driver + code + must + deal + with + all + the + currently + open + channels. + In + all + cases + the + device + driver + must + + + respond + to + the + request + as + quickly + as + possible. + It + must + also + ensure + that + ALL + interrupts + from + the + + + hardware + device + that + it + is + driving + are + disabled. + Device + memory + segments + can + only + be + moved + if + an + + + installable + device + driver + is + being + installed + or + removed. + If + the + LDD + uses + an + attached + PDD + and + uses + the + + + faster + FAR + call + mechanism + to + call + the + PDD + strategy + vector, + the + PDD + strategy + vector + address + will + + + potentially + move, + thus + the + FAR + address + will + be + wrong. + This + address + can + be + resolved + in + the + resume + + + vector. + The + LDD + must + not + call + the + PDD + between + a + hold + and + resume. + Typically, + the + device + driver + + + only + needs + to + disable + its + interrupts. + When + a + resume + occurs, + the + device + driver + should + continue + as + + + though + nothing + had + happened. + + + + + + + + + If + the + machine + is + about + to + switch + off + due + to + the + auto + switch + off + or + user + request + mechanisms + (enter + the + + + standby + state), + the + device + driver + should + make + an + orderly + shut + down + of + the + device + such + that + the + state + + + before + the + shut + down + can + be + recovered + when + the + system + powers + up + again. + The + device + driver + should + + + also + attempt + to + ensure + that + no + data + is + lost. + For + example, + in + the + serial + driver + the + current + state + of + the + + + hardware + handshaking + lines + should + be + noted + so + that + each + state + can + be + restored + on + power + up. + For + this + + + type + of + power + down + the + hold + vector + is + allowed + to + take + a + significant + length + of + time + to + shut + down + a + + + device. + For + example + in + a + serial + driver + the + hold + vector + should + wait + until + the + remote + end + stops + + + transmitting + data + after + any + hardware + handshaking + has + been + applied. + Of + course, + the + time + taken + should + + + be + kept + to + a + minimum: + in + the + case + of + the + serial + driver + above + the + time + is + roughly + equivalent + to + 3 + + + character + transmission + times. + When + a + resume + occurs + the + device + driver + should + continue + as + though + + + nothing + had + happened. + + + + + + + + + If + the + machine + is + about + to + switch + off + due + to + the + power + source + being + removed, + the + device + driver + should + + + reset + the + device + in + the + minimum + possible + time: + no + attempt + should + be + made + to + perform + an + orderly + shut- + + + down. + The + device + driver + is + not + expected + to + be + able + to + recover + the + hardware + state. + When + a + resume + + + occurs, + the + device + driver + would + typically + fail + any + outstanding + application + requests. + If + the + hold + vector + + + takes + too + long + the + voltage + will + fall + below + the + threshold + to + hold + the + state + of + the + internal + RAM. + If + this + + + occurs + the + machine + will + perform + a + warm + re-boot + when + powering + up, + all + data + in + the + internal + memory + + + of + the + machine + will + be + lost + including + the + device + driver + code! + On + power + fail + there + is + about + 2ms + + + available + to + power + down + all + devices. + + + + + + + + + On + a + power + failure + hold, + the + operating + system + will + already + have + sent + a + 'reset' + to + all + the + SIBO + serial + + + channels. + Any + device + drivers + using + these + channels + need + only + record + the + hold + reason + for + the + resume + + + vector. + Any + other + peripherals + should + be + designed + to + allow + a + power + fail + mechanism + with + the + minimum + + + amount + of + code. + It + must + be + noted + that + the + power + fail + type + hold + can + occur + whilst + the + device + driver + is + in + + + the + memory + move + hold + state. + In + this + case, + the + device + driver + will + receive + two + hold + requests + before + + + seeing + a + resume + request. + A + device + driver + must + be + capable + of + handling + this. + In + this + case, + the + device + + + driver + will + also + receive + two + resume + requests. + A + device + driver + will + not + get + a + power + fail + hold + whilst + in + + + + + + + + + Revision + 1.00 + Page + 41 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + power + down + hold. + A + call + to + the + hold + vector + will + always + be + followed + by + a + call + to + the + resume + vector + + + (except + when + a + device + is + requested + to + be + removed). + + + + + + + + + Note + that + with + the + Series + 3a + and + Workabout, + there + is + an + additional + case + when + hold + and + resume + must + + + be + invoked + and + that + is + on + opening/closing + of + the + pack + doors. + In + this + case, + the + LDD + must + generate + its + + + own + Hold + and + Resume. + This + situation + is + examined + in + more + depth + in + the + context + of + the + specific + + + example + drivers + presented + later + in + this + document. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + device + driver + should + not + call + any + + + operating + system + services + in + the + hold + vector + code + due + to + the + time + taken, + especially + on + power + failure. + + + PASSED + + + + + The + AH + register + takes + one + of + the + following + + + + + + + + + @ + DevHoldNormal + Device + memory + is + about + to + be + moved. + + + @ + DevHoldPowerDown + The + system + is + about + to + enter + the + standby + state. + + + @ + DevHoldPowerFail + The + system + has + lost + its + power + supply. + + + RETURN + + + None. + + + PANIC + + + + + + + + + The + hold + vector + must + not + panic: + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + hold + vector. + + + + + + + + + DevFuncResume + + + + + + + + + This + vector + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + be + resumed. + + + The + resume + vector + is + called + in + the + context + of + the + operating + system. + The + DevResume + operating + system + + + service + will + cause + this + vector + to + be + called. + Applications + should + not + call + this + service. + The + resume + + + vector + will + be + called + either + when + memory + has + finished + being + moved + or + when + the + machine + powers + back + + + up. + In + both + cases + the + hold + vector + will + have + been + called + before + this + vector + is + called. + The + device + driver + + + is + expected + to + recover + from + the + previous + hold + request + (except + power + fail) + and + resume + any + I/O + that + was + + + suspended. + If + the + device + driver + has + an + interrupt + service + routine, + it + should + reset + the + interrupt + service + + + routine's + address + since + the + device + driver + may + have + moved + in + memory; + its + absolute + segment + address + + + will + be + different. + + + + + + + + + If + the + hold + was + a + device + memory + segment + move + type + hold, + interrupts + should + be + re-enabled. + If + the + + + LDD + uses + an + attached + PDD + and + uses + the + FAR + call + mechanism + to + access + the + PDD + strategy + vector, + the + + + address + of + the + PDD + should + be + reset + by + using + the + DevGet + PDDAddress + operating + system + service + before + + + enabling + interrupts. + Typically, + the + PDD + will + have + a + call + back + to + the + LDD + and + it + needs + to + be + informed + + + of + the + change + of + address + of + the + LDD + call + back + function, + the + LDD-PDD + interface + definition + should + + + allow + such + a + function + request. + + + + + + + + + If + the + hold + was + a + power + down + type + hold, + the + resume + vector + needs + to + power + up + the + peripheral + and + set + it + + + to + the + state + that + it + was + in + before + the + power + down + occurred. + If + this + is + not + possible + or + data + has + been + lost, + + + the + device + driver + should + inform + any + outstanding + requests + of + this + fact. + It + is + also + possible + that + the + + + hardware + device + that + the + driver + is + associated + with + has + been + removed. + The + driver + should + be + able + to + + + handle + this + properly. + If + the + device + driver + is + expected + to + generate + events + due + to + an + external + state + + + change, + the + driver + should + check + the + external + state + and + generate + appropriate + events. + For + example, + the + + + serial + driver + may + be + requested + to + inform + an + application + when + the + DTR + line + changes + state. + The + remote + + + end + may + have + changed + the + state + of + DTR + whilst + the + driver + is + held. + + + + + + + + + If + the + hold + was + a + power + failure + type + hold, + the + resume + vector + should + power + up + the + peripheral + and + put + it + + + + + + + + + into + a + known + state, + preferably + the + state + that + the + application + software + thinks + that + the + device + is + in + and + + + fail + any + outstanding + requests + as + data + is + quite + likely + to + have + been + lost. + + + + + + + + + Revision + 1.00 + Page + 42 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state. + The + device + driver + should + + + take + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + + + this + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + All + operating + system + services + may + be + + + called, + except + those + concerning + file + or + device + access. + + + + + PASSED + + + + + None + + + + + RETURN + + + + + None. + + + + + PANIC + + + + + The + resume + vector + must + not + panic, + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + resume + vector. + + + + + + + + + DevFuncReset + + + + + + + + + This + function + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + reset + a + + + channel. + The + reset + function + is + called + in + the + context + of + the + operating + system + so + DS + and + ES + are + not + + + available. + The + device + driver + must + request + that + the + operating + system + call + the + reset + function. + This + is + + + achieved + by + calling + the + IoRequestReset + system + service, + usually + in + the + open + vector. + To + cancel + this + + + request, + the + device + driver + should + call + the + IoRequestResetCancel + system + service. + The + cancel + service + + + is + usually + called + as + part + of + the + close + functionality + in + the + strategy + vector. + The + reset + vector + will + be + called + + + when + the + operating + system + is + tidying + up + resources + owned + by + a + process + that + has + terminated. + Ifa + + + process + terminated + before + it + closed + the + device + driver + channel + and + no + reset + service + is + requested, + that + + + channel + would + remain + allocated; + no + process + will + ever + close + the + channel. + The + reset + vector + allows + a + + + device + driver + to + reset + itself + and + allow + the + channel + to + be + opened + again. + Any + data + required + to + perform + + + the + reset + must + be + stored + in + the + device + driver. + The + data + space + belonging + to + the + process + that + originally + + + opened + the + channel + has + been + returned + to + the + operating + system + memory + pool + and + is + no + longer + valid. + If + + + a + device + driver + can + handle + multiple + channels + then + the + data + passed + to + the + IoRequestReset + system + + + service + should + identify + the + channel. + This + data + will + be + passed + in + the + CX + register + to + the + reset + vector. + + + The + device + driver + should + only + have + a + reset + request + outstanding + with + the + operating + system + while + a + + + process + has + a + channel + open. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register + or + using + CS + override. + All + operating + system + + + services + may + be + called, + except + those + concerning + file + or + device + access. + + + + + PASSED + + + + + This + function + is + passed + data + in + the + CX + register + that + the + device + driver + requested + it + be + sent + to + determine + + + which + channel + should + be + reset. + + + + + RETURN + + + + + None. + + + + + PANIC + + + + + The + reset + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + reset + vector. + + + + + + + + + DevFuncUnits + + + + + + + + + This + function + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + report + the + + + number + of + units + (i.e. + channels) + the + device + driver + can + support. + This + function + is + called + in + the + context + of + + + the + operating + system. + The + operating + system + places + no + significance + on + the + number + of + channels + a + + + device + driver + can + support. + It + is + primarily + used + for + informational + purposes. + An + application + may + use + + + the + number + of + units + to + attempt + to + open + any + available + channel + on + that + device + driver. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + All + operating + system + services + may + be + + + called, + except + those + concerning + file + or + device + access. + + + + + PASSED + + + + + + + + + Revision + 1.00 + Page + 43 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + None. + + + + + + + + + RETURN + + + + + The + AX + register + should + contain + the + number + of + channels + supported. + If + a + device + driver + can + support + + + multiple + channels + (limited + only + by + memory + constraints) + then + the + driver + may + return + -1. + A + serial + device + + + driver, + for + example, + might + only + support + two + channels + (TTY:a + and + TTy:8) + whereas + the + file + device + + + driver + can + open + an + unlimited + number + of + files. + + + + + PANIC + + + + + The + channels + units + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + units + vector. + + + + + + + + + DevFuncOpen + + + + + + + + + This + function + will + be + called + by + the + operating + system + when + a + channel + to + the + device + driver + is + required + to + + + be + opened. + This + function + is + called + in + the + context + of + the + process + that + called + the + Ioopen + system + service. + + + This + means + that + DS + and + ES + point + to + the + application + data + space. + The + device + driver + is + passed + two + + + parameters, + its + device + handle + and + a + pointer + to + an + OpenEnt + structure. + The + device + handle + is + the + entry + in + + + the + system + device + table + of + this + device + driver. + The + device + driver + is + required + to + place + this + handle + in + the + + + ChanLibHandle + field + of + the + ChanEnt + structure + which + must + be + allocated + in + the + user's + data + space. + The + + + operating + system + uses + the + device + handle + to + route + any + I/O + requests + on + the + opened + channel + to + the + correct + + + device + driver. + + + + + + + + + The + OpenEnt + structure + contains + three + fields, + openNamePtr, + OpenMode + and + OpenChan. + + + + + The + openNamePt + r + field + contains + a + pointer + to + the + character + that + exists + after + the + device + name + as + passed + + + to + the + ToOpen + system + service. + For + example, + if + the + ToOpen + service + was + passed + a + name + of + PAR:A, + the + + + OpenNamePtr + field + would + point + to + the + colon. + If + the + ToOpen + service + was + passed + a + name + of + TTY.AS5:B + + + the + OpenNamePtr + field + would + point + to + the + full + stop. + The + device + driver + should + process + the + name + + + appropriately, + opening + the + correct + PDD + as + required. + + + + + The + OpenMode + field + contains + the + mode + for + opening + the + device + driver. + The + available + modes + are + + + specified + by + the + device + driver + writers. + For + example, + a + combined + Xmodem + and + Ymodem + device + driver + + + could + use + the + mode + to + specify + whether + the + Xmodem + or + the + Ymodem + protocol + is + to + be + used. + + + + + The + Openchan + field + contains + the + I/O + channel + handle + of + the + device + that + this + driver + is + required + to + + + ‘attach’ + to. + Attached + device + drivers + are + dealt + with + later + in + the + chapter. + + + + + The + code + in + a + device + driver + open + vector + tends + to + follow + a + very + similar + pattern. + This + is + demonstrated + + + by + the + following + code + fragments + and + associated + comments. + The + first + stage + is + to + allocate + some + data + + + space + in + the + calling + process' + heap + space. + This + will + contain + the + I/O + channel + control + block: + + + + + + + + + mov + cx, + (size + DeviceEnt) + + + + + HeapAllocateCell + + + + + jc + noMemory + + + + + mov + bx, + ax + ; + cell + handle + + + + + + + + + If + the + device + driver + requires + a + WaitHandler + (described + later): + + + + + + + + + mov + al, + (VectorHandler-Vector) + /2 + + + ToAddHandler + + + + + jc + endFreeMemory + + + + + mov + [bx].DriverHandler, + ax + + + + + + + + + If + the + device + driver's + DevFuncReset + vector + is + required + to + be + called: + + + + + + + + + push + bx + + + + + mov + cx, + ChannelIndicator + 7 + unique + per + channel + + + mov + bx, + ax + ; + the + device + handle + + + ToRequestReset + + + + + pop + bx + ; + restore + alloc + cell + + + + + + + + + The + chanEnt + field + of + the + DriverEnt + structure + must + be + initialised: + + + + + + + + + mov + [bx] + .DriverIo.ChanNext, + bx + + + mov + [bx] + .DriverIo.ChanSignature, + IoChanSignature + + + mov + [bx] + .DriverIo.ChanLibHandle, + dx + + + + + + + + + The + ChanNext + field + is + used + by + attached + drivers + and + will + usually + be + set + to + be + the + allocated + cell + handle + + + of + the + device + driver + being + opened. + The + IoFuncattach + and + IoFuncDetach + functions + manipulate + these + + + fields. + The + I/O + system + uses + this + field + to + direct + the + I/O + request + to + the + correct + driver. + + + + + + + + + Revision + 1.00 + Page + 44 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + ChanSignature + field + is + checked + by + the + operating + system + during + any + I/O + requests + for + the + value + + + IoChanSignature. + If + it + does + not + contain + that + value, + the + process + calling + the + I/O + service + will + be + + + panicked + for + having + passed + an + invalid + I/O + channel + handle. + + + + + The + ChanLibHandle + field + is + used + by + the + operating + system + to + route + an + application's + I/O + request + to + this + + + device. + The + I/O + request + will + call + the + DevFuncstrategy + vector + of + the + device + driver. + + + + + If + the + driver + is + an + attached + driver + the + following + is + required: + + + + + + + + + mov + cx, + bx + ; + allocated + channel + + + + + mov + bx, + [si] + .OpenChan + ; + channel + attaching + to + + + mov + al, + IoFuncAttach + ; + return + in + BX + the + + + ToWithWait + ; + channel + attached + to + + + + + + + + + Finally, + if + the + channel + has + been + successfully + opened: + + + ele + Opened + Ok + + + ret + return + BX + and + DX + + + + + + + + + + + + + + + + + + + + + + + + + + + The + error + recovery + code + typically + follows + the + following + pattern: + + + + + + + + + endFreeReset: + + + push + ax + + + push + bx + + + mov + cx, + ChannelIndicator + + + mov + bx, + ax + + + ToRequestResetCancel + + + pop + bx + + + pop + ax + + + endFreeHandler: + + + push + ax + + + push + bx + + + mov + bx, + [bx] + .DriverHandler + + + ToRemoveHandler + + + pop + bx + + + pop + ax + + + endFreeMemory: + + + push + ax + + + HeapFreeCell + + + pop + ax + + + stc + + + noMemory: + + + ret + + + + + + + + + If + a + device + driver + supports + a + fixed + number + of + channels, + it + typically + contains + static + control + blocks. + In + + + order + to + determine + if + a + requested + channel + is + currently + open, + a + field + should + be + interrogated. + The + device + + + driver + should + ensure + that + interrupts + are + disabled + during + this + sort + of + check + since + a + context + switch + could + + + occur + and + another + process + request + the + opening + of + the + same + channel. + This + is + the + classic + 'test + and + set' + + + problem + encountered + in + multi-tasking + environments. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + attempting + to + open + a + device + channel. + The + application + should + ensure + that + the + DS + and + ES + segment + + + registers + do + in + fact + point + to + its + data + segment. + The + device + driver + must + obey + the + normal + rules + + + concerning + segment + register + manipulation. + The + DS + and + ES + segment + registers + can + be + reloaded + if + + + required + from + the + IntEnt + structure + pointed + at + by + the + BP + register. + All + operating + system + services + may + + + be + called. + + + + + PASSED + + + + + DX + contains + the + device + handle + of + the + device + driver. + + + + + SI + is + a + pointer + to + the + OpenEnt + structure + + + + + BP + is + a + pointer + to + the + IntEnt + structure. + + + + + RETURN + + + + + If + the + channel + open + was + successful, + return + with + the + carry + flag + clear + and + the + BX + register + containing + the + + + open + channel. + + + + + If + the + open + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + + + PANIC + + + + + The + open + vector + can + panic; + it + will + cause + the + process + requesting + the + device + open + to + terminate. + It + is + + + however + more + usual + to + return + an + error + to + the + calling + process. + + + + + PRESERVE + + + + + The + DS, + ES, + SS, + SP, + BP + and + DX + registers + must + be + preserved + by + the + open + vector. + + + + + + + + + Revision + 1.00 + Page + 45 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + DevFuncStrategy + + + + + + + + + When + an + application + makes + an + I/O + request + on + the + opened + device + driver + channel + the + request + is + routed + + + to + this + vector + by + the + operating + system. + A + device + driver + defines + the + set + of + functions + that + it + supports. + + + These + typically + include + IoFuncSet, + IoFuncSense, + IoFuncRead, + IoFuncWrite + and + IoFuncClose. + A + + + device + driver + does + not + have + to + support + any + particular + function, + as + it + is + a + matter + of + design + between + a + + + device + driver + writer + and + application + writer + as + to + what + functions + and + associated + parameters + are + + + provided. + To + obtain + the + power + of + attached + device + drivers, + however, + it + is + recommended + that + the + device + + + driver + use + the + system + defines + with + their + appropriate + functionality, + for + example, + the + loFuncWrite + + + function + number + should + always + be + associated + with + writing + data. + + + + + + + + + The + strategy + function + is + passed + the + channel + handle + as + allocated + in + the + open + vector + in + the + BX + register. + + + This + typically + contains + control + information + concerning + the + current + state + of + the + I/O + channel. + + + + + The + SI + register + contains + a + pointer + to + a + RgEnt + structure. + This + structure + contains + four + fields, + + + RqFunction, + RqStatusPtr, + RqA1Ptr + and + RqA2Ptr. + + + + + The + RgFunction + field + contains + the + function + number + as + passed + to + the + IowithWait + (or + + + IoAsynchronous) + I/O + request + by + the + application. + If + a + device + driver + does + not + support + the + specified + + + function, + it + should + pass + the + request + on + to + its + 'parent' + device + driver. + + + + + The + RqStatus + pointer + contains + a + pointer + to + a + memory + location + in + the + application + process's + data + space + + + that + receives + the + I/O + requests + completion + status. + The + device + driver + must + set + this + memory + location + to + + + the + value + PendingErr + whilst + the + I/O + request + is + outstanding + and + a + completion + code + when + the + I/O + + + request + completes. + An + I/O + request + may + complete + within + the + strategy + vector + or + it + may + complete + some + + + time + in + the + future, + presumably + from + some + interrupt. + + + + + The + RgA1Ptr + and + RqA2Ptr + fields + contain + the + argument + | + and + 2 + parameters + as + passed + to + the + + + IoWithWait + (or + IoAsynchronous) + system + services. + The + device + driver + is + free + to + specify + what + these + + + parameters + are + (if + any). + + + + + + + + + The + operating + system + defines + a + set + of + common + function + numbers + used + by + device + drivers + referred + to + as + + + the + IoFuncxxx + set + of + defines. + By + convention, + a + device + driver + should + select + from + this + list, + particularly + + + if + some + of + the + more + advanced + features + of + the + I/O + system + are + to + be + used, + such + as + attached + device + + + drivers. + The + more + common + defines + are + listed + below: + + + + + + + + + @ + ToFuncRead + ; + read + from + the + device. + + + + + ® + TfoFuncWrite + ; + write + to + the + device. + + + + + @ + TloFuncClose + ; + close + device + channel. + + + + + @ + = + =ToFuncCancel + ; + cancel + an + I/O + request. + + + + + ® + ToFuncSet + ; + set + driver + characteristics. + + + + + ® + tloFuncSense + ; + sense + driver + characteristics. + + + e + lIoFuncFlush + ; + flush + any + buffers. + + + + + + + + + The + PLIB + library + functions + p_read, + p_write + and + p_close + will + call + the + device + driver + with + the + + + IoFuncRead, + IoFuncWrite + and + IoFuncClose + function + numbers. + Thus, + if + the + device + driver + chooses + + + an + alternative + function + number + set, + an + application + will + not + be + able + to + use + the + supplied + library + + + functions. + All + resident + device + drivers + obey + the + following + conventions: + + + e + Acancel + request + will + cancel + any + outstanding + requests. + A + cancel + request + will + not + return + any + + + error. + + + + + + + + + e + Aclose + request + will + ensure + that + any + outstanding + requests + are + completed + before + closing + the + + + channel. + A + close + request + will + not + return + any + error. + + + + + + + + + e + Only + one + request + of + a + particular + type + can + be + outstanding + at + any + one + time. + If + a + second + request + + + is + made + the + device + driver + will + panic + the + calling + application. + + + + + + + + + Any + functions + that + the + strategy + function + does + not + support + should + be + passed + on + to + the + next + driver + down + + + the + driver + hierarchy. + If + the + driver + is + a + root + driver + (attached + driver), + this + is + achieved + using + the + IoRoot + + + + + + + + + Revision + 1.00 + Page + 46 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + (IoSuper)system + service. + If + the + requested + function + is + not + supported + by + any + driver, + the + operating + + + system + will + return + a + Not + Supported + error. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + making + the + I/O + function + request. + The + application + should + ensure + that + the + DS + and + ES + segment + registers + + + do + in + fact + point + to + its + data + segment. + The + device + driver + must + obey + the + normal + rules + concerning + + + segment + register + manipulation. + The + DS + and + ES + segment + registers + can + be + reloaded + if + required + from + + + the + IntEnt + structure + pointed + at + by + the + BP + register. + All + operating + system + services + may + be + called. + + + PASSED + + + + + BX + contains + the + allocated + channel + control + block. + + + + + DX + contains + the + device + handle + of + the + device + driver. + + + + + SI + is + a + pointer + to + the + RqEnt + structure. + + + + + BP + is + a + pointer + to + the + IntEnt + structure. + + + + + RETURN + + + + + If + the + function + request + is + successful, + the + strategy + vector + should + return + with + carry + clear. + A + request + + + typically + causes + some + I/O. + If + the + I/O + is + completed + by + the + strategy + vector + (i.e. + the + request + is + for + a + + + synchronous + function + such + as + close), + the + completion + status + should + be + written + back + to + the + RqStatusPtr + + + location + and + the + I/O + semaphore + signalled + (using + the + IoSignal + system + service). + If + the + request + has + not + + + yet + completed + (i.e. + the + request + is + for + an + asynchronous + function), + the + RqStatusPtr + location + should + + + contain + the + value + PendingErr + and + the + I/O + semaphore + should + not + be + signalled. + + + + + If + the + function + request + failed + the + strategy + vector + should + return + with + carry + set + and + the + error + code + in + AL. + + + In + this + case, + typically + no + I/O + requests + will + be + completed. + + + + + PANIC + + + + + The + strategy + vector + can + panic; + it + will + cause + the + process + making + the + I/O + request + to + terminate. + In + most + + + cases + it + is + usual + to + return + an + error + to + the + calling + process. + A + major + exception + to + this + is + if + the + calling + + + process + makes + an + I/O + request + of + the + same + type + as + one + that + is + currently + outstanding + and + the + device + + + driver + only + supports + one + I/O + request + of + a + particular + type + at + a + time; + by + convention + the + device + driver + + + should + panic + the + calling + process + with + the + PanicIoPending + panic + code. + + + + + PRESERVE + + + + + The + DS, + ES, + SS, + SP + and + BP + registers + must + be + preserved + by + the + strategy + vector. + + + + + + + + + Interrupts + and + Interrupt + Service + Routines + + + + + + + + + Device + drivers + that + talk + to + hardware + tend + to + have + interrupt + service + routines + associated + with + them, + + + especially + if + they + are + receiving + data + from + an + external + source. + The + EPOC + operating + system + provides + a + + + framework + within + which + an + interrupt + service + routine + can + be + written + relatively + easily. + An + interrupt + + + service + routine + is + a + code + section + that + is + called + by + the + OS + in + response + to + a + particular + hardware + event. + + + As + indicated + in + the + Hardware + Overview, + the + SIBO + architecture + allows + for + eight + independent + hardware + + + interrupt + sources, + some + of + which + are + pre-allocated + to + system + components. + The + operating + system + + + provides + the + GenSetRevector + service + to + allow + a + device + driver + to + install + an + interrupt + service + routine + + + for + any + of + the + eight + hardware + interrupt + sources. + This + call + passes + the + interrupt + vector + (the + address + of + + + the + interrupt + service + routine) + and + the + interrupt + number + (which + is + dependent + on + the + host + hardware) + to + + + the + OS + so + that + it + knows + where + to + jump + to + when + the + interrupt + occurs. + A + device + driver + should + use + this + + + system + service + and + not + poke + directly + into + the + 8086 + interrupt + vector + table. + The + address + passed + to + the + + + GenSetRevector + Service + is + not + written + into + the + interrupt + vector + table + but + to + an + internal + table. + After + + + invoking + this + service, + the + desired + interrupts + must + be + masked + in + by + writing + the + appropriate + mask + to + the + + + mask + register. + Initially, + of + the + eight + interrupt + sources, + only + the + tick + interrupt + is + masked + in. + + + + + + + + + When + an + interrupt + occurs, + the + microprocessor + could + be + running + any + currently + active + process. + The + OS + + + handles + the + servicing + of + interrupts + by + building + a + mandatory + operating + system + call + frame. + All + CPU + + + registers + are + preserved + on + route. + The + interrupt + service + routine + is + then + called + as + a + FAR + routine. + Since + + + the + operating + system + preserves + all + registers + the + interrupt + service + routine + is + free + to + use + any + register. + As + + + with + all + interrupt + service + routines + various + rules + apply: + + + + + + + + + e + Interrupt + service + routines + should + execute + as + fast + as + possible. + Operating + system + interrupt + + + service + routines + are + tuned + to + last + no + longer + than + one + millisecond. + + + + + + + + + Revision + 1.00 + Page + 47 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + e + Typically, + interrupt + service + routines + do + not + enable + interrupts + unless + the + routine + can + handle + re- + + + entrancy. + + + + + + + + + e + Interrupt + service + routines + run + in + the + context + of + whatever + process + is + running + at + the + time + of + the + + + interrupt. + An + interrupt + service + routine + should + not + attempt + to + obtain + admissibility + to + the + + + process + that + opened + the + channel + but + access + the + internal + driver + space + only + which + in + general + is + + + its + own + code + space. + + + + + + + + + e + An + interrupt + service + routine + must + not + directly + cause + the + OS + to + reschedule + the + running + process + + + as + this + would + significantly + delay + its + completion. + It + must + use + the + IoSignalByPidNoReSched + system + + + service + in + order + to + indicate + to + the + handler + that + an + event + has + occurred + to + the + owning + process. + + + The + handler + function + of + the + device + driver + must + pick + up + the + event + and + inform + the + owning + + + process. + + + + + + + + + e + An + interrupt + service + routine + should + return + with + the + carry + flag + clear + if + it + requires + a + reschedule + + + to + occur + (it + has + called + IoSignalByPidNoReSched) + otherwise + return + with + the + carry + flag + set. + This + + + will + cause + the + operating + system + to + reschedule + if + the + internal + state + allows + such + an + action + + + otherwise + the + reschedule + request + is + effectively + queued + until + such + time + that + the + operating + + + system + can + reschedule. + + + + + + + + + At + some + stage + during + the + course + of + an + interrupt + service + routine, + it + is + necessary + to + clear + the + interrupt + + + line + with + some + hardware-specific + action. + Then + the + interrupt + controller + inside + the + host + ASIC1 + or + + + ASIC9 + has + to + be + cleared + with + a + write + to + the + NonSpecificEoi + location. + To + remove + the + interrupt + service + + + routine + address, + the + operating + system + service + GenResetRevector + should + be + used. + This + will + reset + the + + + internal + table + entry + to + the + default + held + in + the + ROM. + Additionally, + the + interrupt + mask + should + be + reset + + + to + the + original + value. + + + + + + + + + Device + Driver + I/O + Semaphore + Wait + Handlers + + + + + + + + + An + LDD + may + nominate + one + of + its + functions + to + be + called + by + the + operating + system + every + time + the + I/O + + + semaphore + of + the + process + that + opened + the + channel + is + signalled. + The + nominated + function, + known + as + the + + + wait + handler, + will + only + be + called + if + the + application + is + waiting + for + an + outstanding + I/O + request + to + + + complete. + For + well + written + applications + this + is + practically + all + the + time. + By + convention + the + vector + table + + + entry + after + the + mandatory + vectors + contains + the + handler + vector. + A + handler + routine + is + similar + to + an + + + interrupt + service + routine + in + that + it + appears + to + run + ‘from + nowhere’. + Comparing + handlers + and + interrupt + + + services + routines + shows + that: + + + + + + + + + e + A + handler + will + always + run + in + the + context + of + the + process + that + has + opened + a + channel. + An + + + interrupt + service + routine + will + run + in + the + context + of + whatever + process + happens + to + be + running + at + + + the + time + of + the + interrupt. + + + + + + + + + e + A + handler + can + access + the + data + space + of + the + process + that + opened + the + channel. + The + interrupt + + + service + routine + must + not. + An + interrupt + service + routine + should + only + access + the + data + space + in + + + the + driver + which + is + usually + its + own + CS + space. + + + + + + + + + e + A + handler + can + cause + a + reschedule. + An + interrupt + service + routine + must + not + cause + a + reschedule. + + + If + it + did, + the + interrupt + would + not + be + fully + serviced + (the + rest + of + the + interrupt + service + routine + + + would + not + be + executed + until + a + reschedule + back + to + the + process + running + at + the + time + of + the + + + interrupt, + which + may + not + happen + for + a + significant + length + of + time). + The + interrupt + service + + + routine + must + only + use + the + IoSignalByPidNoReSched + to + signal + the + channel + owner. + + + + + + + + + The + handler + is + the + mechanism + by + which + hardware + interrupt + events + can + be + filtered + through + to + the + + + process + using + the + I/O + channel. + Typically, + it + is + in + the + handler + code + that + the + 1oSignal + signifying + + + completion + of + an + asynchronous + I/O + request + is + invoked. + + + + + + + + + Loadable + Physical + Device + Driver + Structure + + + + + + + + + A + loadable + PDD + must + obey + the + following + rules: + + + e + There + must + be + a + single + code + segment + and + no + data + segments. + + + + + + + + + Revision + 1.00 + Page + 48 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + e + The + code + segment + must + start + with + a + LibEnt + structure. + + + e + There + must + be + at + least + two + supported + functions, + with + typically + a + further + two + defined. + + + + + + + + + Single + Code + Segment + + + + + + + + + A + PDD + must + be + written + to + contain + any + internal + variables + within + its + own + code + segment. + Typically, + + + these + variables + are + only + concerned + with + unit + (i.e. + channel) + allocation + and + hardware + state. + Data + space + + + for + a + particular + open + channel + can + be + allocated + in + the + heap + space + of + the + process + that + opens + the + device. + + + This + data + space + will + however + disappear + if + the + process + terminates, + thus + any + variables + required + for + + + ‘freeing’ + the + hardware + after + a + process + terminates + must + exist + in + the + code + space + of + the + device + driver. + + + + + + + + + The + LibEnt + Structure + + + + + + + + + A + LibEnt + structure + has + the + following + format: + + + e + =A + two + byte + signature + + + + + + + + + e + §=6©An + eight + byte + name + + + e + A + two + byte + vector + count + + + e + A + vector + table + + + + + + + + + The + two + byte + signature + should + contain + the + 'PDDSignature' + define. + The + eight + byte + name + contains + a + + + zero + terminated + name, + being + that + of + the + device + driver. + Note + that + there + is + no + trailing + colon. + The + two + + + byte + vector + count + contains + the + number + of + vectors + that + follow + immediately + after + the + count. + There + + + should + be + at + least + two. + For + example: + + + + + + + + + dw + PDDSignature + ; + Its + an + PDD + driver + + + + + db + "DVR.HW1',0 + ; + Name + of + the + driver + + + + + dw + (VectorEnd-Vector)/2 + ; + Number + of + vectors + + + Vector: + + + + + dw + DvriInstall + ; + Install + vector + + + + + dw + DvrRemove + ; + Remove + vector + + + VectorEnd: + + + + + + + + + Most + PDDs + also + define + a + further + two + vectors: + + + dw + DvrOpen + , + Open + Vector + + + dw + DvrStrategy + ; + Strategy + vector + + + + + + + + + The + table + of + vectors + is + a + table + of + offsets + within + the + device + drivers + code + segment + of + the + routines + that + + + implement + the + required + functionality. + The + vector + table + must + have + the + entries + in + the + order + shown + in + + + the + example. + + + + + + + + + Mandatory + PDD + functions + + + + + + + + + All + PDDs + must + support + the + following + two + functions: + + + @ + DevFuncInstallppp + called + on + device + installation. + + + + + + + + + @ + DevFuncRemovePDD + called + on + device + removal. + + + + + + + + + Most + PDDs + will + support + the + following + two + additional + functions: + + + @ + DevFuncOpenPDD + called + to + open + a + PDD. + + + + + + + + + @ + DevFuncStrategyPDD + called + to + provide + PDD + functionality. + + + + + + + + + All + of + the + routines + pointed + at + by + the + function + vector + table + will + be + called + FAR + by + the + operating + system + + + and + should + consequently + use + a + FAR + return + machine + code + instruction + to + return + back + to + the + operating + + + system. + Since + the + FAR + return + address + is + to + the + operating + system, + it + does + not + matter + if + the + operating + + + system + moves + memory + whilst + code + in + the + LDD + is + being + executed; + the + operating + system + cannot + move. + + + + + + + + + DevFunclnstallPDD + + + + + + + + + This + vector + will + be + called + by + the + operating + system + when + the + device + driver + is + loaded + to + initialise + any + of + + + its + internal + variables. + The + install + vector + is + called + in + the + context + of + the + operating + system + and + not + the + + + process + that + is + loading + the + device + driver. + The + DevInstall + operating + system + service + will + cause + this + + + + + + + + + Revision + 1.00 + Page + 49 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + vector + to + be + called. + Applications + should + not + call + this + directly, + they + should + use + the + DevLoadPDD + + + service. + + + + + + + + + An + installable + device + driver + may + have + the + same + name + as + a + currently + installed + device + driver. + When + + + installed, + the + driver + is + added + to + the + end + of + the + device + driver + table. + When + a + channel + to + a + device + driver + + + is + being + established + by + the + operating + system, + it + searches + the + device + table + from + the + end + first, + thus + the + + + latest + installed + device + driver + with + the + required + name + will + be + asked + first + for + a + channel. + So + as + with + + + LDDs + by + this + mechanism + installable + device + drivers + can + replace + any + of + the + resident + drivers. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state. + The + device + driver + should + + + take + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + + + this + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + operating + system + will + not + move + + + memory + whilst + in + this + function, + thus + the + normal + rules + governing + DS + and + ES + may + be + ignored. + All + + + operating + system + services + may + be + called + except + those + concerning + file + or + device + access. + + + + + PASSED + + + + + No + values + are + passed + to + the + install + vector. + + + + + RETURN + + + + + If + the + installation + was + successful, + return + with + the + carry + flag + clear. + + + + + If + the + installation + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + PANIC + + + + + The + install + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + install + vector. + + + + + + + + + DevFuncRemovePDD + + + + + + + + + This + vector + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + be + unloaded. + + + The + remove + vector + is + called + in + the + context + of + the + operating + system + and + not + the + process + that + requests + + + the + unload. + The + DevRemove + operating + system + service + will + cause + this + vector + to + be + called. + Applications + + + should + not + call + this + service + directly; + instead, + they + should + call + the + DevDelete + service. + Before + the + + + remove + function + is + requested, + the + operating + system + will + send + a + DevFuncHold + request + to + all + LDDs. + + + The + LDD + is + responsible + for + ensuring + that + no + activity + will + occur + during + the + remove. + Note + that + any + + + device + driver + that + handles + hardware + interrupts + must + contain + an + LDD + since + only + LDDs + receive + a + hold + + + request. + If + the + device + driver + is + currently + busy + serving + a + client, + the + remove + request + should + return + an + + + error. + All + resident + device + drivers + will + return + an + error + since + there + is + no + mechanism + by + which + they + can + + + be + re-installed. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + operating + system + will + not + move + + + memory + whilst + in + this + function, + thus + the + normal + rules + governing + DS + and + ES + may + be + ignored. + All + + + operating + system + services + may + be + called + except + those + concerning + file + or + device + access. + + + + + PASSED + + + + + No + values + are + passed + to + the + remove + vector. + + + + + RETURN + + + + + If + the + remove + was + successful, + return + with + the + carry + flag + clear. + + + + + If + the + remove + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + PANIC + + + + + The + remove + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + remove + vector. + + + + + + + + + DevFuncOpenPDD + + + + + + + + + This + function + is + defined + as + a + convenience + function + for + the + LDD-PDD + interface. + When + an + application + + + opens + a + channel + to + an + LDD, + it + normally + uses + the + Ioopen + system + service. + If + the + name + specifies, + or + the + + + LDD + requires, + a + PDD + then + it + needs + to + open + a + channel + toa + PDD. + The + Devopenppp + system + service + will + + + call + this + PDD + vector + to + establish + a + channel. + The + LDD + now + has + a + choice + of + calling + a + PDD + vector + using + + + the + DevVector + system + service + or + calling + the + fourth + vector + in + the + vector + table + directly. + The + fourth + + + + + + + + + Revision + 1.00 + Page + 50 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + vector + is + assumed + to + be + a + strategy + vector + to + which + any + parameters + as + required + by + the + LDD-PDD + + + interface + can + be + passed. + The + FAR + address + of + the + strategy + vector + is + returned + by + the + + + DevGetPDDAddress. + When + an + LDD + receives + a + DevFuncResume + it + should + call + DevGet + PDDAddress + + + again + to + ensure + that + if + the + PDD + has + moved + the + LDD + still + has + its + correct + address. + As + a + design, + a + PDD + + + could + provide + many + vectors, + one + for + each + required + function. + The + LDD + would + then + use + the + Devvector + + + system + service + to + access + each + of + these + functions. + The + DevGetPDDAddress + will + only + return + the + FAR + + + address + of + the + fourth + vector. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + making + the + open + function + request. + The + application + should + ensure + that + this + is + indeed + the + case. + The + + + device + driver + must + obey + the + normal + rules + concerning + segment + register + manipulation. + All + operating + + + system + services + may + be + called. + + + + + PASSED + + + + + The + BX + register + contains + a + pointer + to + the + PDD + unit + name. + The + pointer + passed + to + the + DevOpenPDD + + + service + is + used + to + find + the + PDD + device + to + open. + The + BX + register + is + loaded + with + a + pointer + to + the + + + trailing + colon + (if + any) + in + the + PDD + unit + name. + For + example + if + the + name + "TTy.AS5:A" + was + passed + to + + + the + DevOpenPDD + service, + BX + would + contain + a + pointer + to + :A + upon + calling + the + open + vector. + + + RETURN + + + + + If + the + open + was + successful, + return + with + the + carry + flag + clear. + + + + + If + the + open + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + + + PANIC + + + + + The + open + vector + can + panic; + it + will + cause + the + process + requesting + the + device + open + to + terminate. + It + is + + + however + more + usual + to + return + an + error + to + the + calling + process. + + + + + PRESERVE + + + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + open + vector. + + + + + + + + + DevFuncStrategyPDD + + + + + + + + + This + function + is + defined + as + a + convenience + function + for + the + LDD-PDD + interface. + Typically, + all + + + application + function + requests + are + routed + through + the + strategy + vector. + To + speed + the + calling + interface, + + + the + DevGet + PDDAddress + operating + system + function + will + return + a + FAR + address + of + this + vector. + The + + + device + driver + writer + defines + all + the + functions + and + return + values + as + required. + + + + + + + + + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + making + the + function + request. + The + application + should + ensure + that + the + DS + and + ES + segment + registers + do + + + in + fact + point + to + its + data + segment. + The + device + driver + must + obey + the + normal + rules + concerning + segment + + + register + manipulation. + All + operating + system + services + may + be + called. + + + + + PASSED + + + + + The + parameters + passed + are + defined + by + the + device + driver + write. + + + + + RETURN + + + + + All + returns + are + defined + by + the + device + driver + writer. + + + + + PANIC + + + + + The + strategy + vector + can + panic; + it + will + cause + the + process + requesting + the + function + to + terminate. + It + is + + + however + more + usual + to + return + an + error + to + the + calling + process. + + + + + PRESERVE + + + + + Which + registers + are + preserved + is + defined + by + the + device + driver + writer. + + + + + + + + + Revision + 1.00 + Page + 51 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 10. + ASIC4/ASIC5 + BASED + DEVICE + DRIVERS + + + + + + + + + Introduction + + + + + + + + + This + chapter + describes + the + rules + and + problems + involved + in + writing + a + device + driver + that + controls + some + + + form + of + ASIC4 + or + ASICS + based + hardware. + Details + concerning + the + internal + organisation + of + these + + + ASICs + were + presented + earlier + in + chapters + 6 + and + 7. + The + emphasis + is + on + their + use + for + Series + 3a + + + applications, + though + most + issues + that + will + be + discussed + also + apply + to + the + Series + 3, + MC + and + HC + range + of + + + Psion + products. + + + + + + + + + In + addition + to + the + eight + mandatory + functions + already + detailed + in + the + Device + Driver + Overview + chapter, + + + an + LDD + will + usually + provide + additional + functionality + in + the + form + of + further + vector + table + entries + + + dependent + upon + the + requirements + of + its + application. + Wherever + possible, + these + functions + should + make + + + use + of + the + various + pre-defined + system + defines + for + services + such + as + reading + (p_read) + and + writing + + + (p_write) + etc. + It + should + be + noted + that + there + is + no + particular + requirement + to + implement + a + device + + + driver + as + a + separate + PDD + and + LDD + and + in + the + case + of + the + example + logical + device + driver + + + A4EXIF.LDD, + the + approach + taken + is + to + incorporate + both + aspects + into + the + one + LDD. + + + + + + + + + SIBO + Hardware + Expansion + Channels + + + + + + + + + The + number + of + SIBO + expansion + channels + supported + by + the + host + machine + will + vary + according + to + the + + + particular + Psion + hardware + present. + So + that + a + single + device + driver + may + be + compiled + for + the + different + + + host + machine + possibilities, + a + number + of + build + flags + can + be + used + to + set + various + constants + within + the + + + include + files. + The + hardware + options + are + outlined + in + the + table + below: + + + + + + + + + SIBO + Machine + Flags + | + Number + of + SIBO + serial + channels + supported + Machine + Build + Flag + + + + + + + + + Consumer + (S3a) + Refers + to + $3a + with + ASIC9 + only. + Supports + 1 + SIBO + channel + + + (A) + + + + + + + + + ES + ae + Mat + AST + lysed + SPS + PTT + + + + + + + + + It + should + be + noted + that + Psion + device + drivers + should + be + designed + to + be + easily + adapted + from + machine + to + + + machine. + For + a + well-written + driver, + the + only + change + that + needs + to + be + made + in + adapting + it + for + use + on + + + another + Psion + machine + is + the + alteration + of + the + build + flag + at + the + start + of + the + code. + This + flag + indicates + to + + + the + compiler + which + SIBO + machine + flags + as + well + as + other + variables + should + be + set + for + the + host + machine. + + + The + four + most + important + SIBO + machine + variables + are + the + channel + interrupt + mask, + the + channel + + + interrupt + number, + the + channel + interrupt + vector + and + the + hardware + SIBO + channel. + The + channel + + + interrupt + mask + is + an + eight + bit + value + or'd + with + the + contents + of + either + AlInterruptMask + or + + + A9BInterruptMask + (the + mask + registers) + to + initiate + interrupts + on + the + relevant + channel + depending + on + + + whether + the + interrupt + controller + resides + in + ASIC1 + or + ASIC9. + If + this + mask + is + then + used + in + a + + + HwGetChannel + call, + any + hardware + interrupts + on + the + selected + expansion + channel + will + be + directed + to + the + + + appropriately + coded + interrupt + service + routine. + The + channel + interrupt + mask + is + also + required + in + the + + + subsequent + HwFreeChannel + OS + service + call + and + when + stopping + hardware + interrupts. + The + channel + + + interrupt + number + is + a + sixteen-bit + quantity + required + by + the + GenSetRevector + and + GenResetRevector + + + OS + system + services + to + indicate + to + the + OS + which + default + interrupt + service + routine + is + to + be + replaced + by + + + the + suitably + coded + device + driver + interrupt + vector. + The + channel + interrupt + vector + is + a + sixteen-bit + + + pointer + to + the + location + of + that + interrupt + vector + in + the + device + driver + code. + Finally, + the + hardware + SIBO + + + channel + is + used + by + the + HwSelectChannel + OS + service + to + direct + any + SIBO + serial + control + or + data + frames + + + + + + + + + Revision + 1.00 + Page + 52 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + along + the + appropriate + channel. + The + situation + regarding + the + value + of + these + variables + for + the + expansion + + + ports + on + all + current + SIBO + platforms + is + illustrated + in + the + table + overleaf: + + + + + + + + + IW + orkabout + (Series3) + + + a + en + en + an + + + Channels + + + + + + + + + Controller + ASIC + |ASIC? + ASICO + + + Mask + Register + A9BInterruptMaskRW + a + a + a + ae + + + + + + + + + IHwIrq2Revector + + + + + + + + + mask + A9MExpIntA + + + (Expansion + Port + A) + + + mask + A9MExpIntB + + + (Expansion + Port + B) + + + Imask + AOMSlave + + + + + (Expansion + Port + C) + + + + + + + + + IHwIrq4Revector + + + IHwIrgq5Revector + + + IHwIrq2Revector + + + + + + + + + ASIC2 + + + + + + + + + mask + ExpIntLeftA + + + (Expansion + Port + A) + + + mask + ExpIntRightB + + + (Expansion + Port + B) + + + mask + Asic2Int + + + (Expansion + Port + C) + + + + + + + + + IHwIrgq3Revector + + + IHwIrq2Revector + + + IHwIrq4Revector + + + + + + + + + ASIC2 + ASIC2 + + + + + + + + + mask + Asic2Int + + + (Expansion + Port + C) + + + + + + + + + mask + ExpIntLeftA + + + + + (Expansion + Port + A) + + + mask + ExpIntRightB + + + (Expansion + Port + B) + + + + + + + + + IHwIrgq3Revector + + + IHwIrq2Revector + + + + + + + + + IHwIrq4Revector + + + + + + + + + Ptr + + + Channel + SelectChannel5. + SelectChannel3 + IExpChannelLeftA + IExpChannelLeftA + SelectChannel7 + + + Hard + Select + SelectChannel4 + ExpChannelRightB + = + |ExpChannelRightB + + + + + arOWAre + Dre’ + SelectChannel5 + SelectChannel7 + + + + + + + + + Talking + to + ASIC4 + + + + + + + + + All + communication + to + an + ASIC4 + is + via + a + Psion + Serial + Link. + As + explained + in + the + chapter + on + the + SIBO + + + serial + protocol, + two + forms + of + data + can + be + sent + and + received + along + this + channel. + These + are + control + and + + + data + bytes. + Control + bytes + give + specific + instructions + to + ASIC4 + and + data + bytes + can + either + be + data + sent + to + + + or + from + ASIC4 + or + data + given + to + or + taken + from + peripheral + chips + in + ASIC4's + address + space. + Sending + + + and + receiving + control + and + data + frames + down + a + Psion + Serial + Channel + from + a + Series + 3/HC + host + is + simply + + + a + matter + of + IN + and + OUT + instructions + to + various + fixed + I/O + addresses. + Various + assembler + macros + have + + + been + set + up + to + ease + this + task + and + provide + machine + independence + and + they + are + detailed + in + the + appendix. + + + These + include: + + + + + + + + + SCONTOUT + Output + the + control + byte + held + in + the + AL + register + + + SDATAIN + Input + a + byte + of + data + and + place + it + in + AL + + + + + SDATAOUT + Output + the + data + byte + in + the + AL + register + + + + + XNOP + Wait + a + short + while + + + + + SBUSY + Wait + while + the + Psion + Serial + Link + is + busy + + + + + + + + + Once + a + piece + of + peripheral + hardware + has + been + designed + the + appropriate + software + must + be + written + to + + + control + it. + All + hardware + devices + on + Series + 3/3a, + Workabout + and + HC + machines + are + controlled + by + device + + + drivers. + These + act + as + an + interface + between + a + piece + of + hardware + and + an + application + that + uses + it. + The + + + following + section + goes + into + further + detail + regarding + the + methods + by + which + a + device + driver + is + able + to + + + communicate + with + and + thereby + control + an + ASIC4 + and + ASICS + based + peripheral. + + + + + + + + + ASIC4 + Registers + + + + + + + + + ASIC4 + has + eight + registers + and + their + functions + in + mixed + (i.e. + peripheral) + mode + are + outlined + below: + + + + + + + + + Register + 0: + This + register + is + the + read/write + Data + Register + that + controls + the + data + lines + DO-D7 + which + are + + + normally + in + tri-state + mode. + Data + written + to + the + Data + Register + is + output + on + DO-D7 + during + a + write + cycle + + + and + data + input + to + the + DO-D7 + may + be + read + from + the + register + during + a + read + cycle. + On + reset, + this + register + + + holds + the + Info + Byte + and + its + bits + have + the + following + meanings: + + + + + + + + + Revision + 1.00 + Page + 53 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Bit + No. + D7 + D6 + DS + D4 + D3 + D2 + DI + DO + + + DD + DN + N + S + S + _ + S + + + + + + + + + D + D_ + OD + i + _ + Device + type + + + + + 0 + 0 + O + RAM + SSD + + + + + 0 + oO + 1 + Intel + Flash + type + 1 + + + + + 0 + 1 + O + Intel + Flash + type + 2 + + + + + Oo + 1 + 1 + TBS + + + + + 1 + 0 + O + TBS + + + + + 1 + 0 + 1 + TBS + + + + + 1 + 1 + 0 + Read + only + SSD + (ROM + OTP + etc.) + + + 1 + 1 + 1 + Hardware + Write + protected + SSD + + + N + N + Number + of + devices + + + + + 0 + O + 1 + + + + + 0 + 1 + 2 + + + + + 1 + 0O + 3 + + + + + | + ae + | + 4 + + + + + S + S_ + S__ + Device + Size + + + + + 0 + O + O + Illegal + (Indicates + no + SSD + present) + + + 0 + 0 + 1 + 32Kbyte + + + + + 0 + 1 + O + 64Kbyte + + + + + Oo + 1 + 1 + 128Kbyte + + + + + 1 + 0 + O + 256Kbyte + + + + + 1 + 0 + 1 + 512Kbyte + + + + + 1 + 1 + O + 1Mbyte + + + + + 1 + 1 + 1 + 2Mbyte + + + + + + + + + Register + 1: + This + register + is + both + a + read + and + write + register. + In + read + mode, + it + is + termed + the + Input + + + Register. + The + eight + bits + of + this + register + are + then + defined + as + follows: + + + + + + + + + The + Se, + De + and + Ne + bits + hold, + on + reset, + the + Extended + Info + Byte + which + is + used + in + ASIC4 + Extended + mode + + + to + define + the + type + of + peripheral + device + as + explained + later + in + the + section + on + ASIC4 + reset + and + + + configuration + and + outlined + below: + + + + + + + + + M + De + Ne + Se + + + 1 + 0 + 0 + 90 + No + peripheral + devices + + + 1 + 0 + O + 1 + Turbo + RS232 + serial + (16550) + + + 1 + oO + 1 + O + 3Fax + + + 1 + oO + 1 + 1 + T.B.S. + + + 1 + 1 + 0O + 0 + T.B.S. + + + 1 + 1 + OO + 1 + T.B.S. + + + 1 + 1 + 1 + O + T.B.S. + + + 1 + 1 + 1 + 1 + Extended + info + contained + in + ROM. + + + + + + + + + The + X2 + bit + sets + the + state + of + the + X2D2 + input + which + is + used + to + indicate + whether + the + device + size + is + + + correct. + In + M=0 + mixed + mode, + the + X2 + bit + must + be + low. + Inputs + In0-In2 + hold + the + current + status + of + the + + + three + correspondingly + named + general + input + lines + to + ASIC4. + + + + + + + + + In + write + mode, + Register + 1 + is + termed + the + Device + Size + Register + where + bits + 3-0 + (S3-SO) + map + to + the + + + settings + of + the + decoder + inputs + (and + hence + the + peripheral + device + size) + as + follows + overleaf: + + + + + + + + + Revision + 1.00 + Page + 54 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Size + Register + Decoder + Inputs + Device + Size + (bytes) + + + S3 + S2 + S1 + SO + DCO + DC1 + DC2 + + + + + 0 + 0 + 0 + 0 + A15 + Al6 + Al7 + 32k + + + + + 0 + 0 + 0 + 1 + Al15 + Al6 + Al7 + 32k + + + + + 0 + 0 + 1 + =O + Al6 + Al7 + A18 + 64k + + + + + 0 + oO + 1 + 1 + Al7 + Al18 + A19 + 128k + + + 0 + 1 + 0 + 0 + Al8 + Al19 + A20 + 256k + + + 0 + 1 + 0 + 1 + A19 + A20 + A21 + 512k + + + 0 + 1 + 1 + =O + A20 + A21 + A22 + 1M + + + + + 0 + 1 + 1 + 1 + A21 + A22 + A23 + 2M + + + + + 1 + 0 + 0 + 0 + A22 + A23 + A24 + 4M + + + + + 1 + 0 + O + 1 + A23 + A24 + A25 + 8M + + + + + 1 + 0 + 1 + O + A24 + A25 + A26 + 16M + + + + + 1 + oO + 1 + 1 + A25 + A26 + A27 + 32M + + + + + 1 + 1 + 0 + 0 + A26 + A27 + 0 + 64M + + + + + 1 + 1 + 0 + 1 + A27 + 0 + O + 128M + + + 1 + 1 + 1 + = + O + 0 + 0 + O + 256M + + + 1 + 1 + 1 + 1 + 0 + oO + O + Not + Used + + + + + + + + + This + register + defaults + to + OxOf + on + reset + (i.e. + not + used). + + + + + + + + + Register + 2: + A + write + to + this + register + , + the + Address + Increment + Register, + will + increment + the + addresses + + + AO-A3. + + + + + + + + + Register3: + This + register + is + the + write-only + Address + Register + which + controls + all + 28 + address + lines + (AO- + + + A27) + directly + and + the + eight + chip + selects + (CSO-CS7) + indirectly. + The + address + register + is + written + to + in + + + multi-transfer + mode + LSByte + (ATO) + first. + There + can + be + up + to + four + bytes + written: + + + + + + + + + Byte + Address + lines + + + ATO + AQ + - + A7 + + + ATI + A8& + - + Al5 + + + AT2 + Al6 + - + A23 + + + AT3 + A24 + - + A27 + + + + + + + + + When + the + first + byte + is + written, + all + the + higher + address + lines + (A8-A27) + are + reset + to + 0. + Bits + 4-6 + of + AT3 + + + may + be + used + by + the + internal + address + decoder + to + control + the + CS + outputs + CSO-CS3 + if + appropriate. + On + + + reset, + all + bits + of + this + register + are + cleared. + + + + + + + + + Register + 4, + 5 + and + 6: + Not + implemented. + + + Register + 7: + This + register + is + the + write + only + ASIC4 + Control + Register + and + holds + the + following + bits: + + + + + + + + + Bit: + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + Label: + LBO + TSTA + LTM + VPS + EDA + CSS + WRS + OES + + + + + + + + + Setting + the + LBO + and + VPS + bits + causes + the + corresponding + lines + on + ASIC4 + to + be + set + high + enabling + them + + + to + be + used + as + general + purpose + outputs + for + peripheral + development. + OES + and + WRS + control + R/W + + + accesses. + + + + + + + + + Additional + ASIC4 + Signals + + + + + + + + + InO, + In1, + In2 + are + general + purpose + digital + inputs. + LBO, + VPS + are + general + purpose + digital + outputs. + OE, + + + WR + control + Read/Write + bus + accesses. + MCSD, + X2D2 + should + be + tied + to + ground + via + a + 100k + resister. + + + POR + is + the + reset + line. + + + + + + + + + Revision + 1.00 + Page + 55 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Talking + to + ASIC5 + + + + + + + + + The + Psion + serial + protocol + was + designed + to + allow + many + different + peripheral + ASICs + to + lie + on + the + same + + + serial + channel. + Before + software + can + communicate + with + an + ASICS + it + must + first + be + selected. + ASICS + + + must + be + selected + in + different + ways + depending + on + whether + it + has + been + configured + (in + hardware) + to + + + operate + in + either + Pack + or + Peripheral + mode. + In + addition + to + selecting + ASICS + when + it + is + first + used, + + + ASICS + must + be + re-selected + whenever + a + hold + and + resume + is + generated + due + to + power + down, + pack + doors + + + opening + or + when + the + peripheral + is + inserted + or + removed. + ASIC5 + will + always + respond + to + a + select + with + a + + + byte + indicating + what + type + of + peripheral + or + pack + it + is. + If + there + is + no + ASICS + connected + to + the + Psion + + + serial + link + there + will + obviously + be + no + response + (zero + is + returned) + and + software + must + then + take + the + + + appropriate + action. + To + select + a + peripheral + mode + ASICS + the + following + code + can + be + used: + + + + + + + + + HwNullFrame + + + + + mov + al, + (SerialSelect + or + Asic5NormallId) + + + SBUSY + + + + + SCONTOUT + + + + + XNOP + + + + + SBUSY + + + + + SDATAIN + + + + + test + al,al + + + + + je + NoASIC5PeripheralOutThere + + + + + + + + + To + select + a + pack + mode + ASICS + the + following + code + can + be + used. + + + + + + + + + HwNullFrame + + + + + mov + al, + (SerialSelect + or + Asic5PackId) + + + SBUSY + + + + + SCONTOUT + + + + + XNOP + + + + + SBUSY + + + + + SDATAIN + + + + + test + al,al + + + + + je + NoASIC5PackOut + There + + + + + + + + + Note + that + an + ASIC4 + can + pretend + to + be + an + ASICS + in + pack + mode + and + will + respond + appropriately. + + + + + + + + + ASIC5 + Registers + + + + + + + + + ASICS + has + sixteen + internal + registers. + To + read + or + write + from + an + ASICS + register + takes + two + steps. + First + + + a + control + byte + must + be + sent + along + the + Psion + serial + link + to + select + which + register. + This + should + be + + + followed + by + a + read + or + write + of + the + appropriate + data + value. + The + sixteen + registers + are + listed + in + the + table + + + below. + Some + can + be + read + and + written + to + and + some + are + read + or + write + only. + + + + + + + + + | + oO + | + URW + PortAreadandwritedata + + + | + 6 + | + RW + Interrupt + Maskread + and + write + + + | + 8 + | + RW + __| + UART + Status/UART + Control + register + + + | + 9 + | + R/W_| + UART + Receive/UART + transmit + holding + register_| + + + UART + Baud + rate + LSB + + + + + | + 13) + | + OR + Barcodereaddata + + + | + 4 + {| + ER + Synchronous + Port2read + + + + + + + + + Revision + 1.00 + Page + 56 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Reading + from + the + Port + A + register + causes + ASICS + to + generate + a + memory + access + cycle. + The + value + read + + + from + port + A + will + be + the + value + retrieved + from + any + attached + memory + or + memory + mapped + peripheral. + + + Writing + to + Port + A + will + cause + ASICS + to + generate + a + write + cycle + and + write + the + supplied + value + to + attached + + + memory. + In + both + cases + the + address + used + for + the + access + will + depend + on + ASICS's + mode + and + the + + + configuration + of + ports + B, + C, + and + D. + If + the + UART + is + enabled + (Bit + 0 + of + the + port + B + mode + register) + + + memory + cannot + be + accessed + because + port + A + lines + are + reused. + + + + + + + + + Writing + to + port + B + will + cause + the + value + written + to + be + latched + onto + the + output + lines + PBO-PB7 + (which + + + form + address + lines + AO-A7 + for + memory + access + cycles). + Reading + from + this + register + will + return + the + last + + + value + written. + + + + + + + + + Writing + to + the + port + B + mode + controls + various + aspects + of + ASIC5 + behaviour. + The + table + below + indicates + + + the + meanings + of + each + bit + in + the + register. + When + set + to + operate + in + counter + mode + the + value + output + on + + + lines + PBO-PB7 + can + be + incremented + by + reading + from + the + port + B + mode + register, + post-incremented + by + + + reading + or + writing + to + the + port + A + register + or + cleared + to + zero + by + writing + to + the + Port + D + and + C + register. + + + + + + + + + | + 0 + _| + 0, + Memory + mode. + 1, + Peripheral + mode + -enables + UART____| + + + | + 6 + NotUsed + + + + a + + + + + + + + + 7 + Not + Used + + + + + + + + + POT + | + Countermode + + + POT + Latch + mode + + + Pot + | + Baud + rate + outon + portB + + + + + + + + + When + ASICS + is + in + pack + mode + the + first + write + to + the + port + D + and + C + register + will + be + latched + onto + lines + + + PDO-PD7. + In + multiwrite + mode + the + second + and + subsequent + data + writes + will + be + latched + onto + port + C + with + + + the + following + bits + in + the + register + forming + the + following + functions. + + + + + + + + + | + Databit_ + | + Pin, + | + Function + _| + + + a + | + + + + + + + + + The + bit + SELO + and + SEL1 + determine + which + chip + select + is + used + when + a + memory + access + cycle + is + generated + + + by + accessing + port + A. + CSO-CS3 + are + selected + as + follows. + + + + + + + + + CSO + + + + + + + + + CS2 + + + + + + + + + = + + + + + + + + + Revision + 1.00 + Page + 57 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + In + peripheral + mode + a + write + to + the + port + D + and + C + register + will + latch + the + value + written + onto + lines + PD1- + + + PD7. + In + peripheral + mode + the + line + PDO + forms + the + UART + TX + line. + Setting + bit + zero + in + the + port + C + and + D + + + register + therefore + has + no + effect. + + + + + + + + + ASICS + is + capable + of + generating + an + interrupt + due + to + various + external + events. + The + interrupt + mask + + + register + is + used + to + select + which + events + will + generate + an + interrupt. + Writing + to + the + interrupt + mask + + + register + will + set + the + mask + to + the + value + written. + Reading + the + interrupt + mask + register + will + return + the + + + current + mask. + The + meanings + of + each + bit + in + this + register + is + given + in + the + table + below. + Setting + an + + + appropriate + bit + to + 1 + will + enable + that + events + interrupt, + clearing + to + 0 + will + stop + that + event + from + causing + an + + + interrupt. + On + reset + all + events + are + disabled. + + + + + + + + + Bit + + + | + OP + UART + CT + UART + character + received + + + + + + + + + Synchronous + port] + character + received + + + Synchronous + port2 + character + received + + + | + 6 + [PCA + Barcode + data/general + interrupt + + + + + + + + + When + an + interrupt + occurs + reading + the + Interrupt + Status + register + will + indicate + the + source + of + the + interrupt. + + + The + meaning + of + each + bit + corresponds + directly + to + each + bit + in + the + interrupt + mask + (see + table + above). + A + + + high + bit + indicates + an + active + interrupt + event. + + + + + + + + + Reading + the + Barcode + data + register + returns + a + byte + representing + the + states + of + the + following + lines. + + + + + + + + + Communicating + with + ASIC4 + + + + + + + + + ASIC4 + is + capable + of + operating + in + several + modes. + Attached + peripherals + can + contain + an + ASICS + chip + + + instead + of + an + ASIC4. + Before + talking + to + an + ASIC4 + you + must + first + ensure + that + there + is + an + ASIC4 + at + the + + + end + of + your + serial + link + and + you + must + set + ASIC4 + into + the + correct + operating + mode. + You + must + do + this + + + when + the + channel + is + first + obtained + to + ensure + you + have + the + right + peripheral + to + start + with, + and + also + + + whenever + you + get + a + Hold + and + Resume + due + to + a + power + down, + Pack + doors + opening, + or + the + peripheral + + + being + removed. + You + should + also + check + the + peripherals + ID + to + check + what + peripheral + it + is. + The + user + is + + + more + than + likely + to + pull + out + your + I/O + port + and + replace + it + with + a + 3Fax + in + mid + operation. + You + select + + + ASIC4 + in + the + correct + mode + by + sending + a + special + control + code. + If + there + is + an + ASIC4 + out + there + it + will + + + respond + by + sending + back + a + non + zero + value. + The + peripherals + ID + can + be + read + back + from + ASIC4's + info + + + register. + This + register + also + returns + the + state + of + the + input + lines + INO, + IN1, + IN2. + The + coding + example + + + below + shows + how + ASIC4 + can + be + checked + for, + selected + and + the + peripheral + ID + checked: + + + + + + + + + HwNullFrame + + + + + mov + al, + (SerialSelect + or + Asic4Id) + ; + First + look + for + an + + + SBUSY + ; + ASIC4 + at + the + other + + + SCONTOUT + ; + end + of + the + link + + + XNOP + + + + + + + + + Revision + 1.00 + Page + 58 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + SBUSY + + + SDATAIN + + + test + al,al + + + je + NoAnASIC4IsItAnASIC5 + + + mov + al, + (SerialReadSingle + or + A4InfoR) + ; + Now + see + if + we + + + SBUSY + ; + have + the + right + + + SCONTOUT + ; + peripheral + + + XNOP + + + SBUSY + + + SDATAIN + ; + Mask + out + the + unwanted + + + and + al,0Of0h + ; + bits + + + cmp + al,PERIPHERAL_ID + ; + check + for + correct + ID + + + jne + IsASIC4ButNotRightPeripheral + ; + Got + our + peripheral + + + ele + ; + Connection + Okay! + + + ret + + + IsASIC4ButNotRightPeripheral: + + + Is + an + ASIC4 + but + not + + + popt + ; + the + right + peripheral + + + stc + ; + Connection + Failed! + + + ret + + + NoAnASIC4IsItAnASIC5: + ; + No + ASIC4 + + + mov + al, + (SerialSelect + or + Asic5NormallId) + + + SBUSY + ; + Could + have + been + an + + + SCONTOUT + ; + ASIC5 + so + try + to + put + + + XNOP + stc + ; + back + in + the + + + right + mode + + + ret + ; + Connection + Failed + + + + + + + + + Bits + in + ASIC4’s + info + register + have + the + following + definitions: + + + + + + + + + Pot + | + Dmsb + | + DT + Wiss + | + TN? + TN + NO + + + Sending + and + Receiving + data + using + ASIC4 + + + + + + + + + All + ASIC4 + peripherals + are + memory + mapped + into + that + ASIC's + address + space. + To + access + a + peripheral + or + + + a + particular + peripheral's + register + the + ASIC + must + first + be + told + to + set + its + address + bus + to + the + appropriate + + + location. + Once + it + has + been + informed + of + the + address + which + it + is + to + access + that + location + can + be + read + from + + + or + written + to + as + many + times + as + required. + The + value + to + be + written + is + held + in + the + data + register. + To + read + + + or + write + to + another + location + the + address + that + the + ASIC + is + accessing + must + be + changed. + To + read + from + a + + + random + address + within + the + ASIC's + address + space + the + sequence + would + be: + + + + + 1) + Send + a + control + code + to + inform + the + ASIC + that + it + is + to + set + its + address + bus + to + the + following + address. + + + + + 2) + Send + the + address + to + position + to. + + + + + 3) + Send + a + control + frame + to + inform + the + ASIC + that + we + wish + to + read + from + this + address. + + + + + 4) + Read + back + the + byte. + + + + + + + + + To + write + a + random + value + to + and + address + within + the + ASIC's + address + space + the + sequence + would + be: + + + + + + + + + 1) + Send + a + control + code + to + inform + the + ASIC + that + it + is + to + set + its + address + bus + to + the + following + address. + + + 2) + Send + the + address + to + position + to. + + + + + 3) + Send + a + control + frame + to + inform + the + ASIC + that + we + wish + to + write + to + this + address. + + + + + 4) + Send + the + byte. + + + + + + + + + Overleaf + are + two + 8086 + assembler + functions + Input + and + Output + which + read + from + or + write + to + an + address + + + within + the + ASIC's + address + space. + These + functions + only + give + access + to + the + bottom + 256 + addresses. + For + + + peripheral + devices + this + is + usually + more + than + adequate. + Interrupts + should + always + be + off + during + calls + to + + + these + functions + to + prevent + the + S3/S3a/HC + from + multitasking. + Note + that + in + the + following + routines, + + + A4Address + and + A4Data + refer + to + the + value + of + the + respective + ASIC4 + registers. + SerialWriteSingle + has + + + the + value + corresponding + to + a + single + frame + write + in + the + SIBO + serial + protocol + format. + These + system + + + defines + can + be + found + in + the + important + include + files + ospack.inc + and + ossibo.inc. + + + + + + + + + ProcBegin@ + Output + + + + + + + + + ; + + + ; + + + + + ; + Output + byte + to + ASIC4-based + peripheral + + + + + ; + IN: + DL + holds + the + hardware + address + ASIC4 + is + to + write + to + + + + + + + + + Revision + 1.00 + Page + 59 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + ; + AL + holds + the + byte + to + be + output + to + that + address + + + + + push + ax + + + + + mov + al, + (SerialWriteSingle + or + A4Address) + ;CTRL=Write + to + A4 + address + + + reg + + + + + SBUSY + + + + + SCONTOUT + ;Send + this + control + + + frame + + + + + mov + al,dl + ;DATA=Hardware + address + + + + + SBUSY + + + + + SDATAOUT + ;Send + this + data + + + frame + + + + + mov + al, + (SerialWriteSingle + or + A4Data) + ;CTRL=Writing + data + + + now + + + + + SBUSY + + + + + SCONTOUT + ;Send + this + control + + + frame + + + + + pop + ax + ;DATA=Data + to + write + + + + + SBUSY + + + + + SDATAOUT + ;Send + this + data + + + frame + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + Input + + + + + + + + + ; + Input + byte + from + ASIC4-based + peripheral + + + 7 + IN: + DL + holds + the + hardware + address + ASIC4 + is + to + read + from + + + ; + OUT:AL + holds + the + value + read + from + that + address + + + + + mov + al, + (SerialWriteSingle + or + A4Address) + ;CTRL=Write + to + A4 + address + + + reg + + + + + SBUSY + + + + + SCONTOUT + ;Send + this + control + + + frame + + + + + mov + al,dl + ;DATA=Hardware + address + + + + + SBUSY + + + + + SDATAOUT + ;Send + this + data + + + frame + + + + + mov + al, + (SerialReadSingle + or + A4Data) + ;CTRL=Reading + data + + + now + + + + + SBUSY + + + + + SCONTOUT + ;Send + above + + + control + frame + + + + + SBUSY + + + + + XNOP + + + + + SDATAIN + ;Receive + data + frame + + + + + ret + ;AL + holds + the + data + + + + + + + + + ProcEnd + noret + + + + + + + + + Obtaining + and + using + a + channel + + + + + + + + + The + s3/S3a/HC + have + three + Psion + serial + links. + Only + one + of + these + channels + can + be + selected + for + + + communication + at + any + one + time. + Two + of + these + channels + form + the + SSD + slots. + The + third + forms + the + + + expansion + port. + Before + a + device + driver + is + able + to + talk + to + a + peripheral + it + must + both + own + and + have + this + + + third + channel + selected. + Many + device + drivers + can + exist + in + memory + and + more + than + one + may + access + the + + + peripheral. + To + prevent + multiple + access + to + a + single + peripheral + a + device + driver + must + first + own + a + serial + + + channel + before + it + is + free + to + communicate + to + the + ASIC4/S + peripheral + at + the + end + of + it. + To + check + if + a + + + channel + is + free + and + then + reserve + it + call + the + operating + system + function + HwGetChannel. + This + will + return + + + with + carry + clear + if + the + attempt + to + capture + the + channel + was + successful, + carry + set + otherwise. + + + + + + + + + mov + al, + InterruptMaskForDesiredChannel + + + HwGetChannel + + + jc + CouldntGetTheChannel + + + + + + + + + Obtaining + the + desired + channel + will + usually + be + performed + by + a + device + drivers + open + vector. + Open + + + should + fail + if + the + channel + is + unavailable. + If + a + device + drivers + takes + possession + of + a + channel + it + is + its + duty + + + + + + + + + Revision + 1.00 + Page + 60 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + to + free + it + again + once + it + is + finished. + This + would + normally + be + done + when + the + device + drivers + is + closed + and + + + is + performed + by + the + operating + system + function + HwFreeChannel. + + + + + + + + + mov + al, + InterruptMaskForDesiredChannel + + + HwF + reeChannel + + + + + + + + + As + illustrated + in + the + above + table, + on + a + series + 3a + the + interrupt + mask + for + the + expansion + port + (Port + C) + is + + + defined + by + A9MSlave, + on + a + series + 3 + Asic2Int. + Interrupts + are + IRQ2 + and + IRQ4 + respectively. + Only + one + + + serial + link + can + ever + be + selected + at + one + moment + in + time. + Selecting + a + particular + channel + means + that + you + + + are + unable + to + speak + to + another + without + selecting + it + instead. + To + select + a + channel + the + operating + system + + + call + HwSelectChannel + is + used. + + + + + + + + + mov + al, + SelectForDesiredChannel + + + HwSelectChannel + + + push + ax + + + + + + + + + HwSelectChannel + will + return + in + al + the + channel + that + was + previously + selected. + Device + drivers + should + + + select + the + correct + channel + on + entry + to + any + vector + or + interrupt + service + routine + that + needs + to + + + communicate + down + that + channel. + On + exit + the + previously + selected + channel + should + be + restored. + + + Between + the + time + when + the + channel + is + first + selected + and + when + the + old + channel + is + restored + multitasking + + + should + be + disabled. + this + will + usually + mean + switching + off + interrupts. + Because + of + the + watchdog + timer, + + + interrupts + cannot + be + left + off + for + an + indeterminate + length + of + time. + Communications + down + channels + + + therefore + will + usually + be + restricted + to + short + bursts. + For + the + expansion + port + the + channel + to + select + on + an + + + S3a + is + defined + by + Select + Channel5 + on + an + $3 + SelectChannel7. + + + + + + + + + pushf + + + + + eli + + + + + mov + al, + SelectChannel5 + + + hwSelectChannel + + + + + push + ax + + + + + mov + dl, + AddressOfInputBuffer + + + call + Input + + + + + mov + dl, + AddressOfOutputBuffer + + + + + + + + + call + Output + + + + + + + + + pop + ax + + + hwSelectChannel + + + popf + + + + + + + + + Controlling + ASIC5's + UART + + + + + + + + + Before + data + can + be + sent + or + received + from + ASIC5's + UART + continuous + clocking + from + the + host + must + be + + + enabled + and + a + baud + rate + selected. + The + UART + must + be + enabled + by + setting + bit + 0 + in + the + port + B + mode + + + register. + The + selected + baud + rate + value + is + related + to + the + result + of + dividing + the + required + baud + rate + into + + + the + input + clock + frequency + from + the + host + of + 1.536 + MHz. + The + value + generated + from + the + equation + given + + + below + forms + a + sixteen + bit + word. + ASICS + has + two + registers + for + selecting + the + baud + rate. + Register + 10 + + + should + contain + the + least + significant + byte + and + register + 11 + the + most + significant + byte + of + the + calculated + + + word + value. + The + table + below + lists + the + divisor + values + for + some + of + the + more + commonly + required + baud + + + rates: + + + + + + + + + Divisor + = + 1-(96000/Desired + Baud + Rate) + + + + + + + + + 9600 + a + ee + ae + ee + + + 7200 + fff + + + 4800 + + + + + + + + + Revision + 1.00 + Page + 61 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + format + of + data + communicated, + stop + bits, + data + bits, + parity + checking, + is + controlled + by + writing + to + the + + + UART + status/control + Register. + Bits + in + the + UART + status/control + register + have + the + following + meanings: + + + + + + + + + | + 0 + | + Stateof + the + CTS + line + (PAI) + ___| + Generate + break + character + + + iar + + + + + + + + + A + character + to + be + transmitted + should + be + written + to + the + Transmitter + Holding + Register + where + ASICS + will + + + convert + it + to + serial + form + for + transmission. + The + register + will + be + emptied + once + the + character + has + been + + + transmitted. + ASIC5 + contains + no + internal + buffering. + The + Transmitter + Holding + Register + must + be + empty + + + before + writing + a + character + to + it. + The + state + of + the + Transmitter + Holding + Register + is + reflected + in + the + + + Transmitter + Empty + bit + in + the + UART + status + register. + Enabling + the + Transmitting + Holding + Register + + + interrupt + will + cause + ASICS + to + generate + an + interrupt + every + time + that + the + Transmitting + Holding + Register + + + becomes + empty. + Reading + the + UART + Status + Register + will + clear + the + interrupt. + Received + characters + are + + + copied + into + the + Receive + Character + Register. + If + the + Receive + Character + Interrupt + is + enabled + ASICS + + + generates + an + interrupt + on + each + character + received. + If + the + character + is + received + in + error + due + either + + + parity, + framing + or + overrun + errors, + appropriate + bits + in + the + UART + Status + Register + are + set + to + reflect + this. + + + + + + + + + Hold + and + Resumes + + + + + + + + + There + are + three + types + of + hold + and + resume. + The + first + occurs + when + memory + is + being + moved. + An + LDDs + + + hold + and + resume + vectors + will + always + be + called + when + this + occurs. + The + second + is + a + On/Off + Hold + and + + + resume. + An + LDD + will + always + be + held + and + resumed + when + this + occurs + although + it + is + not + guaranteed + that + + + power + will + have + been + restored + to + the + expansion + ports + when + the + resume + is + issued. + The + third + type + + + occurs + when + one + of + the + pack + doors + is + opened + or + a + peripheral + inserted. + Only + certain + internal + LDDs + + + receive + a + Hold + and + Resume + under + these + circumstances. + Any + loaded + LDD + will + definitely + not + receive + a + + + Hold + or + Resume. + To + get + around + these + problem, + the + TcK: + device + driver + is + used + to + provide + a + regular + + + call + to + a + routine + within + your + driver. + This + call + monitors + the + power + to + the + expansion + port + and + issues + its + + + own + holds + and + resumes + as + appropriate. + Holds + and + resumes + can + become + nested + and + the + whole + situation + + + can + become + rather + complicated. + The + correct + procedure + for + dealing + with + holds + and + resumes + for + an + + + ASIC4 + peripheral + device + driver + (LDD) + is + given + below. + + + + + + + + + When + a + hold + is + received + through + the + normal + route + the + channel + is + marked + as + being + under + a + normal + + + hold. + If + the + polling + routine + sees + that + the + power + has + vanished + and + the + channel + is + not + already + under + a + + + + + + + + + Revision + 1.00 + Page + 62 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + normal + hold + then + it + holds + the + channel + and + marks + it + as + being + under + a + special + hold. + If + a + normal + resume + + + is + issued + channel + can + be + resumed + but + only + if + power + is + present. + If + power + is + not + present + then + the + + + channel + is + marked + as + being + under + a + special + hold + and + the + resume + is + put + off. + If + the + polling + routine + sees + + + that + the + power + is + present + and + that + the + channel + is + under + a + special + hold + then + it + should + resume + the + + + channel. + + + + + + + + + Alternatively + of + course + each + time + you + read + and + write + to + your + peripheral + you + could + do + a + quick + pre- + + + check + to + see + if + the + hardware + is + available + and + set-up + correctly. + This + would + dispense + with + the + need + to + + + handle + power + up/down + or + pack + door + holds + and + resumes. + You + would + still + have + to + start + and + stop + + + interrupts + though + when + appropriate. + + + + + + + + + Example + Device + Drivers + + + + + + + + + An + example + device + driver + which + will + control + the + ASIC4 + Example + Interface + Board + described + earlier + + + can + be + found + in + the + file + A4EXIF.ASM. + The + device + driver + is + a + fully + comprehensive + multi-channel + + + implementation. + It + supports + all + the + mandatory + logical + device + driver + functions. + Open + will + fail + if + the + + + Interface + Board + hardware + is + not + present. + It + has + an + interrupt + service + routine + and + handles + Holds + and + + + Resumes + correctly + in + all + the + distinct + cases + outlined + earlier. + In + addition, + asynchronous + reads + of + the + + + LED + status + are + possible + so + a + special + routine + to + handle + this + case, + the + Wait + Handler, + is + included. + The + + + driver + has + been + made + as + fully + comprehensive + as + possible + both + in + terms + of + functionality + and + the + choice + + + of + host + machine. + To + this + end, + the + code + given + can + be + compiled + for + the + entire + range + of + Psion + machines + + + simply + by + changing + the + appropriate + machine + Build + Flag + at + the + head + of + the + file + which + then + causes + the + + + correct + interrupt + masks + to + be + selected + for + the + machine. + Chapter + 11 + of + this + document + details + the + + + structure + of + A4EXIF.LDD + a + logical + device + driver + constructed + for + the + ASIC4 + Example + Interface + Board. + + + + + + + + + Chapter + 12 + details + the + functionality + of + a + physical + device + driver + for + the + ASIC5-based + Psion + 3-link + + + peripheral + that + enables + the + host + hardware + to + communicate + with + a + PC + by + converting + SIBO + serial + + + protocol + signals + into + RS232 + signals. + Once + again, + this + driver + contains + various + build + flags + to + facilitate + + + conditional + compilation. + Common + interrupt + routine + code + is + included + and + the + LDD-PDD + interface + is + + + specified. + + + + + + + + + The + source + code + for + both + A4ZEXIF.LDD + and + SYS$AS5.PDD + is + presented + in + the + appendix + to + this + + + document. + + + + + + + + + Revision + 1.00 + Page + 63 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 11. + AN + EXAMPLE + DEVICE + DRIVER + FOR + ASIC4: + + + A4EXIF.LDD + + + + + + + + + Introduction + + + + + + + + + In + this + chapter, + the + functionality + and + code + structure + an + example + installable + logical + device + driver, + + + A4EXIF.LDD, + is + presented + in + some + depth. + Circuit + details + of + the + corresponding + Psion + peripheral + for + + + this + driver, + the + ASIC4 + Example + Interface + board, + were + outlined + in + chapter + 8. + A4EXIF.LDD + enables + + + software + written + using + the + Psion + SDK + to + communicate + with + the + prototype + ASIC4 + Example + Interface + + + board + through + means + of + standard + PLIB + calls + such + as + ‘p_open' + and + 'p_write’. + The + description + of + + + A4EXIF.LDD + is + intended + to + provide + a + clear + insight + into + the + generalised + structure + of + logical + device + + + drivers + for + peripherals + based + around + the + SIBO + architecture. + To + this + end + the + actual + usefulness + of + the + + + combined + hardware-driver + interface + is + of + secondary + importance. + As + shown + earlier, + the + ASIC4 + + + Interface + Board + translates + SIBO + serial + protocol + signals + into + a + parallel + 8-way + data + bus + format + which + + + can + be + used + to + set + various + 74HC + series + latches + and + gates. + An + eight-bit + buffer + and + latch + are + commoned + + + to + eight + LEDs. + The + latch + is + write-only + and + is + used + for + setting + the + state + of + the + LEDs. + The + buffer + is + + + read-only + and + is + used + to + sense + the + state + of + the + LEDs. + In + addition, + a + facility + for + generating + hardware + + + interrupts + is + provided + by + means + of + a + suitably + connected + switch + and + third + 8-way + buffer + (the + status + + + buffer). + Address + decoding + is + provided + by + two + 2-to-4 + decoders + attached + to + address + lines + AO + and + Al. + + + + + + + + + Code + Structure + + + + + + + + + Loading + A4EXIF.LDD + and + Device + Names + + + + + + + + + A4EXIF.LDD + is + loaded + into + the + RAM + of + the + host + machine + by + means + of + the + following + PLIB + call + in + the + + + application + code: + + + + + + + + + p_loadldd + ("A4EXIF.LDD") + ; + + + + + + + + + The + name + of + a + device + driver + is + the + mechanism + by + which + an + application + can + obtain + a + channel + to + that + + + device + driver. + LDDs + all + have + three + character + names + which + are + stored + in + the + second + field + of + the + + + driver's + LibEnt + structure + followed + by + a + colon. + This + name + is + required + to + uniquely + identify + the + LDD + to + + + the + OS + when + attempting + to + open + a + channel + on + it. + The + A4EXIF + LDD + has + the + three + character + name + + + "LED" + so + a + channel + with + its + handle + in + pcb + may + be + obtained + on + it + by + means + of + the + following + call: + + + + + + + + + p_open + (&pcb, + "LED:",-1); + + + + + + + + + EPOC + used + the + driver + name + in + the + p_open + call + to + invoke + the + ToOpen + system + service + which + in + turn + + + invokes + the + Open + vector + on + the + associated + device + driver. + + + + + + + + + The + Single + Code + Segment + and + Data + Storage + + + + + + + + + As + indicated + earlier, + loadable + Psion + device + drivers + have + a + single + code + segment + and + no + data + segment. + + + Data + associated + with + the + driver + is + stored + in + one + of + two + distinct + ways + dependent + on + its + nature. + Global + + + data + associated + with + the + driver + is + stored + in + its + code + segment. + Examples + of + such + data + are + the + channel + + + interrupt + masks + and + numbers + have + to + be + visible + to + all + processes + that + may + be + using + A4EXIF.LDD. + + + Data + local + to + the + application + invoking + the + driver, + however, + is + stored + in + the + heap + space + of + that + + + application. + An + example + in + A4EXIF.LDD + would + be + the + pointers + to + the + open + channel + strategy + vector + + + parameters. + + + + + The + overall + structure + of + the + code + segment + is + typical + of + Psion + logical + device + drivers. + The + code + segment + + + begins + with + a + CodeSeg + directive + followed + by + the + LibEnt + structure + which + defines + the + mandatory + device + + + driver + functions + as + well + as + two + non-mandatory + ones. + These + are + the + Wait + Handler + and + the + replacement + + + + + + + + + Revision + 1.00 + Page + 64 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Tick + Interrupt + Vector. + Before + entering + the + code + for + these + functions, + all + global + variables + are + declared + + + in + what + is + termed + the + device + driver's + internal + data + space. + Following + the + code + for + the + Lib + Ent + functions + + + comes + the + code + for + all + the + local + driver + functions. + After + these + are + the + EndCodeSeg + and + end + A4ExifLDD + + + directives. + + + + + + + + + Channel + Status + Ent + and + Open + Channel + Control + Block + + + + + + + + + At + the + head + of + the + driver's + assembler + source + file + A4EXIF.ASM, + various + constants, + compiler + defines + + + and + type + definitions + are + listed. + It + is + here + that + templates + are + declared + for + the + global + structures + that + hold + + + the + key + driver + variables. + In + view + of + the + above + discussion, + most + device + drivers + employ + at + least + one + + + globally + defined + structure + to + hold + the + various + important + flags + and + masks + that + relate + to + the + status + of + + + each + separate + channel + on + that + driver. + In + the + case + of + A4EXIF.LDD, + two + different + structure + types + are + + + employed, + namely + A4ExifStatusEnt + and + A4ExifEnt. + The + former + is + referred + to + in + this + chapter + as + the + + + StatusEnt + struc + and + is + instantiated + later + on + in + the + device + driver + code + segment + with + each + separate + + + permissible + channel + of + the + main + Psion + host + machines + being + assigned + its + own + StatusEnt + struc. + A + + + channel's + StatusEnt + struc + is + generally + accessed + through + CS:DI + and + holds + important + channel-related + + + information + such + as + the + A4ExifChannelOpen + and + A4ExifChannelRunning + flags + and + the + channel + + + interrupt + masks + and + interrupt + numbers. + The + StatusEnt + structure + resides + in + the + driver + code + segment + + + whereas + the + A4ExifEnt + struc + is + held + in + the + heap + space + of + the + application + invoking + the + driver + and + so + is + + + accessed + through + DS:BX. + The + A4ExifEnt + structure + contains + a + number + of + variables + that + are + logically + + + associated + with + a + successfully + opened + channel + and + as + such + should + be + distinguished + from + the + StatusEnt + + + variables. + An + A4ExifEnt + struc + instantiated + by + invoking + the + device + driver's + open + vector + is + referred + to + + + as + the + open + channel + control + block + and + it + is + generally + accessed + through + DS:BX. + + + + + + + + + The + layout + of + both + the + StatusEnt + struc + and + the + A4ExifEnt + open + channel + control + block + struc + are + + + presented + later + in + this + chapter + along + with + various + other + important + pre-defined + structs + that + were + used + in + + + the + construction + of + A4EXIF.LDD. + Both + of + these + structures + were + extensively + used + in + the + coding + of + the + + + LDD + functions + described + in + the + following + pages. + + + + + + + + + SIBO + hardware + and + conditional + compilation + + + + + + + + + The + number + of + expansion + channels + supported + by + a + host + SIBO + machine + is + dependent + on + the + hardware. + + + In + the + case + of + the + S3a, + only + one + SIBO + channel + can + legitimately + be + opened + corresponding + to + expansion + + + port + A. + With + the + HC + and + Workabout, + it + is + possible + to + open + up + to + three + separate + SIBO + channels + on + + + ports + A + through + to + C. + In + A4EXIF.LDD, + a + global + constant + numberofchannels + 1s + set + at + the + start + of + the + + + device + driver + code + segment + to + indicate + the + number + of + serial + SIBO + channels + supported + by + the + different + + + machines. + This + will + vary + according + to + the + Psion + hardware + present + and + in + order + to + aid + conditional + + + compilation + of + the + A4EXIF + driver + for + the + different + host + machine + possibilities, + a + number + of + build + flags + + + can + be + used + to + set + various + constants + within + the + include + files. + The + hardware + options + with + regard + to + + + these + flags + were + outlined + in + the + previous + chapter. + + + + + + + + + It + should + be + noted + that + Psion + device + drivers + should + be + designed + to + be + easily + adapted + from + machine + to + + + machine. + With + the + A4EXIF + driver, + for + instance, + the + only + change + that + needs + to + be + made + in + adapting + it + + + for + use + on + another + Psion + machine + is + the + alteration + of + the + build + flag + at + the + start + of + the + code + segment. + + + This + flag + indicates + to + the + compiler + which + SIBO + machine + flags + as + well + as + other + variables + should + be + set. + + + The + SIBO + machine + flags + are + in + turn + used + later + in + the + code + segment + header + to + set + the + global + + + numberofchannels + variable + mentioned + above. + For + example, + in + A4EXIF.LDD, + we + have + the + + + following: + + + + + + + + + if + Corporate + or + Workabout + + + numberofchannels + equ + 3 + + + else + + + + + + + + + endif + + + + + + + + + This + type + of + code + is + used + extensively + in + the + conditional + instantiation + of + A4ExifStatusEnts + in + the + + + device + driver's + internal + data + space. + Here + different + interrupt + masks + and + SIBO + channels + are + invoked + for + + + the + different + machines + according + to + the + host + controller + ASIC. + For + instance, + in + the + case + of + a + consumer + + + (S3a), + the + hardware + interrupt + mask + corresponding + to + expansion + port + C + on + an + ASIC9 + is + mask + + + A9MsSlave + and + the + interrupt + number + is + HwIrq2Revector. + On + an + Workabout, + the + masks + for + expansion + + + + + + + + + Revision + 1.00 + Page + 65 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + ports + A, + B + and + C + are + A9MExpIntA, + A9MExpIntB + and + A9MSlave + respectively. + The + corresponding + + + interrupt + numbers + are + HwIrq4Revector, + HwIrq5Revector + and + HwIrq2Revector. + This + conditional + + + compilation + code + in + A4EXIF.LDD + outlined + here + is + worthy + of + some + study + because + it + encapsulates + all + + + the + information + regarding + masks + and + SIBO + hardware + channels + required + by + the + prospective + developer + + + interested + in + constructing + a + multi-platform + Psion + peripheral + and + driver. + + + + + + + + + Mandatory + LDD + Functions + + + + + + + + + The + eight + mandatory + LDD + functions + are + the + Install, + Remove, + Hold, + Resume, + Reset, + Units, + Open + and + + + Strategy + and + they + are + all + discussed + in + the + context + of + the + example + device + driver + A4EXIF.LDD + below. + + + + + + + + + A4Exifinstall + + + IN: + No + values + are + passed + to + the + install + vector. + + + OUT: + If + successful + return + with + carry + clear. + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register. + + + + + + + + + PRESERVE: + SS, + SP + and + BP + + + + + + + + + The + install + vector + is + called + by + the + operating + system + when + the + device + driver + is + loaded + in + order + to + + + initialise + any + internal + variables. + It + should + not + be + called + directly + by + an + application + process + but + invoked + + + indirectly + by + a + 'p_loadldd("A4EXIF.LDD")' + call. + Typically + at + this + stage + the + various + open + channel + + + flags + would + be + initialised + to + zero + but + in + the + case + of + the + A4EXIF.LDD, + this + has + already + been + done + in + + + the + appropriate + A4ExifStatusEnt + struc + headers. + As + a + result, + the + install + vector + merely + clears + the + carry + + + flag + and + returns. + + + + + + + + + A4ExifRemove + + + IN: + No + values + are + passed + to + the + remove + vector + + + OUT: + If + successful + return + with + carry + clear. + + + + + + + + + If + installation + unsuccessful, + return + with + carry + set + and + error + number + in + the + AL + + + register. + + + PRESERVE: + SS, + SP + and + BP + + + + + + + + + The + remove + vector + is + called + by + the + operating + system + whenever + the + device + driver + is + requested + to + be + + + unloaded + which + is + usually + indirectly + as + the + result + of + a + call + to + 'p_devdel + ("LED", + E_LDD)'. + ROM- + + + resident + drivers + cannot + be + deleted + so + any + attempt + to + invoke + this + vector + on + them + will + result + in + an + error + + + being + returned. + The + code + for + the + remove + vector + checks + to + see + that + all + the + device + driver + channels + are + + + closed + and + returns + carry + clear + if + this + is + the + case. + In + the + case + of + A4EXIF.LDD, + a + closed + channel + will + + + hold + a + zero + in + its + corresponding + StatusEnt + open + channel + flag. + If + any + of + the + open + channel + flags + is + non- + + + zero + then + the + carry + flag + is + set + before + returning + indicating + that + an + attempt + has + been + made + to + unload + a + + + device + driver + that + still + holds + at + least + one + open + channel. + In + the + case + of + A4EXIF.LDD, + the + + + numberofchannels + flag + is + used + as + a + loop + counter + for + the + different + hardware + channel + possibilities + in + a + + + similar + manner + to + the + corresponding + code + in + the + open + vector. + + + + + + + + + A4ExifHold + + + + + IN: + AH + register + holds + one + of + the + following + values: + + + DevHoldNormal, + DevHoldPowerDown + Or + DevHoldPowerFail + + + + + OUT: + None + + + + + + + + + PRESERVE: + SS, + SP + and + BP + + + + + The + hold + vector + is + called + by + the + operating + system + whenever + the + device + driver + is + requested + to + be + held. + + + This + can + occur + as + a + result + of + three + conditions + which + result + in + the + three + different + possibilities + for + the + + + value + held + in + AH: + + + + + 1. + Device + memory + segments + about + to + be + moved. + AH + holds + DevHoldNormal. + + + + + + + + + Revision + 1.00 + Page + 66 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 2. + Machine + about + to + switch + off + due + to + power-save + time-out + or + the + off + switch + being + pressed. + AH + holds + + + DevHoldPowerDown. + + + + + 3. + Machine + about + to + switch + off + due + to + power + source + being + removed + or + the + batteries + failing. + AH + holds + + + DevHoldPowerFail. + + + + + The + hold + vector + code + must + be + able + to + conduct + a + rapid + shut + down + of + the + device + driver + because + in + the + + + case + of + DevHoldPowerFail, + the + driver + may + only + have + a + couple + of + ms + before + internal + voltages + fall + to + an + + + unworkable + level. + The + EPOC + OS + automatically + handles + the + three + cases + highlighted + above + but + in + + + Series + 3a + machines + and + the + Workabout, + in + addition + to + these + there + is + another + situation + that + requires + the + + + invocation + of + the + hold + vector, + namely + the + opening/closing + of + the + SSD + pack + doors + on + an + S3a + or + + + Workabout. + This + is + an + action + which + can + only + be + detected + by + means + of + software + polling + which + requires + + + the + setting + up + of + the + ROM-resident + "TcK:" + device + driver + so + that + the + door + status + can + be + checked + each + + + system + tick + (i.e. + 32 + times + a + second). + The + section + on + A4ExifTickInt + provides + a + more + detailed + outline + of + + + the + TCK + interrupt + code + required + to + handle + pack + door + opening + and + closing. + It + is + this + latter + routine + that + + + polls + for + the + open + or + closed + status + of + the + host + machine + doors, + setting + the + global + HoldFlag + accordingly. + + + The + Hold + vector + code + thus + includes + a + check + on + the + status + of + the + HoldFlag + and + is + generally + optimised + + + to + be + as + efficient + as + possible. + An + outline + of + the + structure + of + A4ExifHold + presented + below. + It + follows + + + the + pattern + for + a + typical + device + driver: + + + + + + + + + e + Check + the + state + of + the + global + HoldFlag. + + + + + e + If + the + flag + is + non-zero, + then + the + driver + is + already + held + and + the + function + returns + without + taking + + + any + further + action. + + + + + e + = + If + the + HoldFlag + is + zero, + then + the + function + checks + the + status + of + all + the + channels + that + the + driver + + + is + permitted + to + open. + If + any + of + these + channels + have + their + open + channel + flags + cleared, + it + is + not + + + necessary + to + do + anything + as + part + of + the + process + of + holding + the + channel. + Only + in + the + case + when + + + the + flags + are + set + is + the + 'stopChannelRunning’ + function + invoked. + As + with + the + similar + loop + in + + + the + Reset + vector, + the + global + numberofchannels + is + used + as + the + loop + counter + as + each + of + the + + + possible + channels + has + to + be + checked. + + + + + + + + + A4ExifResume + + + IN: + None + + + OUT: + None + + + + + + + + + PRESERVE: + SS, + SP + and + BP + + + + + + + + + The + resume + vector + is + called + by + the + operating + system + to + restart + a + held + device + driver. + Resume + will + be + + + called + after + a + hold + caused + by + any + of + the + four + possibilities + indicated + above + in + the + section + on + A4ExifHold + + + but + it + should + be + noted + that + in + some + cases, + ASIC4 + will + only + be + switched + on + after + the + call + to + resume. + + + The + device + driver + is + expected + to + recover + from + the + previous + hold + and + resume + any + suspended + I/O + except + + + in + the + case + of + power + failure + where + the + resume + vector + ought + to + power + up + the + peripheral + and + put + it + into + a + + + known + state + indicating + to + the + user + that + data + may + have + been + lost. + The + resume + vector + will + also + have + to + + + handle + the + reinstallation + of + any + interrupt + service + routines + by + checking + the + status + of + the + open + channel + + + flag. + + + + + + + + + e + Check + the + state + of + the + global + HoldFlag. + + + + + e + If + the + flag + is + zero, + then + the + driver + has + already + resumed + so + return + without + further + action. + + + + + e + If + the + flag + is + non-zero, + then + check + the + door + status + of + the + host + machine + with + a + call + to + the + OS + + + HwGetSsdData + service. + If + the + doors + are + open, + then + set + HoldFlag + to + 2 + to + signal + this + position + + + to + the + driver. + If + the + doors + are + closed, + then + numberofchannels + is + used + as + a + loop + counter + while + + + the + open + channel + flags + of + each + of + the + permissible + channels + for + the + host + hardware + are + checked. + + + Only + if + these + flags + are + set + is + the + 'start + TheChannelRunning’ + function + invoked. + + + + + + + + + A4ExifReset + + + IN: + BX + holds + the + device + driver + device + handle + + + CX + holds + user + specified + channel + identification + data. + In + this + case, + holds + the + address + + + of + the + status + struc + identifying + the + open + channel + to + be + reset. + + + OUT: + None + + + + + + + + + Revision + 1.00 + Page + 67 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + PRESERVE: + SS, + SP + and + BP + + + + + + + + + The + reset + vector + enables + a + device + driver + to + reset + itself + when + the + application + which + owns + the + device + + + driver + terminates + abnormally + before + closing + one + or + more + open + channels + on + that + driver. + The + vector + is + + + only + invoked + by + the + operating + system + if + it + has + been + primed + by + means + of + a + call + to + the + ToRequestReset + + + operating + system + service + in + the + open + vector. + Such + a + call + must + be + balanced + by + a + corresponding + call + to + + + IoRequestResetCancel + in + the + close + function + code + of + the + strategy + vector. + Registers + BX + and + CX + are + + + required + to + be + set + up + by + the + user + prior + to + invocation + of + either + of + these + services. + BX + should + contain + the + + + device + driver + handle + which + is + passed + through + DX + in + the + open + vector. + CX + should + hold + any + suitable + + + open + channel + identification + data + that + can + be + accessed + in + the + driver's + internal + data + space + (i.e. + through + + + CS:DI). + In + the + case + of + A4EXIF.LDD, + this + information + is + the + address + of + the + channel + StatusEnt + + + structure. + If + a + device + driver + is + only + capable + of + opening + one + channel, + then + it + is + irrelevant + what + CX + + + holds. + A + reset + should + only + be + outstanding + while + some + process + has + a + channel + open + on + the + device + + + driver. + The + format + of + A4ExifReset + is + similar + to + that + of + a + typical + reset + vector + and + can + be + summarised + + + as + follows: + + + + + + + + + e + Move + the + address + of + the + channel + status + Ent + from + CX + into + DI. + + + + + e + Check + the + value + of + the + corresponding + cs:[di].A4ExifChannelOpen + flag. + + + + + e + If + channel + is + not + open + to + reset, + then + return + from + the + vector + otherwise + call + + + "StopTheChannelRunning’ + and + use + HwFreeChannel + to + release + the + SIBO + serial + channel. + Set + + + the + ChannelOpen + flag + to + zero. + + + + + + + + + A4ExifUnits + + + IN: + None + + + OUT: + AX + holds + the + number + of + channels + supported. + + + + + + + + + PRESERVE: + SS, + SP + and + BP + + + + + + + + + The + A4ExifUnits + function + is + called + by + the + operating + system + when + the + device + driver + is + requested + to + + + report + the + number + of + units + (or + channels) + that + it + can + support. + This + is + primarily + useful + for + purposes + of + + + information. + + + + + + + + + A4ExifOpen + + + + + + + + + IN: + DX + contains + the + device + handle + of + the + device + driver + + + SL + is + a + pointer + to + an + OpenEnt + struc + + + BP + is + a + pointer + to + an + IntEnt + struc + + + DS, + ES + point + to + the + application + process's + data + segment + + + OUT: + If + successful + return + with + carry + clear + and + the + address + of + the + open + channel + in + BX. + + + i.e. + BX + holds + the + address + of + an + A4ExifEnt + struc + which + contains + various + fields + of + + + information + concerning + the + open + channel. + + + If + installation + unsuccessful, + return + with + carry + set + and + error + number + in + the + AL + + + register. + + + PRESERVE: + DS, + ES, + SS, + SP, + BP + and + DX + + + + + + + + + The + open + vector + is + called + by + the + operating + system + when + a + channel + to + the + device + driver + is + required + to + be + + + opened. + The + device + handle, + which + is + passed + through + DX, + is + used + by + the + operating + system + to + route + any + + + I/O + requests + on + the + opened + channel + to + the + correct + device + driver. + An + LDD + must + place + this + handle + in + + + the + ChanLibHandle + field + of + the + ChanEnt + struc + of + the + open + channel + structure + allocated + within + the + + + application's + data + segment. + In + the + case + of + A4EXIF.LDD, + this + structure + is + the + A4ExifEnt + struc + + + described + in + the + Appendix + to + this + document. + The + open + vector + of + a + device + driver + runs + in + the + context + of + + + the + process + that + has + called + p_open + to + open + a + serial + port + on + that + device + driver. + + + + + + + + + The + OpenEnt + struc + consists + of + three + fields + , + OpenNamePtr, + OpenMode + and + OpenChan. + The + + + OpenNamefPtr + points + to + the + character + immediately + following + the + device + name + as + passed + in + the + + + p_open + call. + For + instance, + in + the + case + of + A4EXIF.LDD, + the + OpenNamePtr + would + point + to + the + colon + + + after + LED + in + the + name + "LED:". + The + OpenMode + field + contains + the + mode + for + opening + the + device + driver + + + + + + + + + Revision + 1.00 + Page + 68 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + which + is + not + used + in + this + example. + The + OpenChan + field + holds + the + I/O + channel + handle + of + the + device + + + that + the + driver + is + required + to + 'attach' + to. + Attached + drivers + add + functionality + to, + or + replace, + a + service + + + provided + by + an + underlying + device + driver. + The + IntEnt + struc + pointed + to + by + BP + can + be + used + to + reload + the + + + various + segment + registers + if + their + contents + have + been + altered. + The + A4ExifEnt + struc + requires + further + + + elaboration. + It + consists + of + four + fields: + A4Exiflo, + A4ExifHandlerPtr, + A4ExifStatusPtr + and + + + A4ExifA1Ptr. + A4ExifHandlerPtr + contains + a + handle + to + the + driver's + WaitHandler, + A4ExifHandler. + + + This + is + the + routine + required + to + handle + the + completion + of + asynchronous + I/O + requests + and + is + described + in + + + more + detail + later + on + in + this + chapter. + Of + the + remaining + fields, + A4ExifStatusPtr + holds + the + location + of + the + + + completion + status + word + for + I/O + requests + and + A4ExifA1Ptr + is + a + user-defined + parameter. + These + two + + + values + are + passed + to + the + strategy + vector + through + the + RqEnt + structure. + A4Exiflo + is + itself + a + ChanEnt + + + struc + with + sub + fields + ChanSignature, + ChanNext + and + ChanLibHandle. + After + initialisation + of + this + + + structure, + [bx]. + A4Exiflo.ChanSignature + must + hold + 'TochanSignature’ + and + + + [bx].A4Exiflo.ChanLibHandle + holds + the + handle + to + the + device + driver + (stored + in + DX). + Both + of + these + + + values + are + again + required + by + the + strategy + vector. + The + [bx].A4Exiflo.ChanNext + field + is + used + by + + + attached + drivers + and + is + set + to + 0 + for + root + drivers + like + A4EXIF.LDD. + + + + + + + + + The + code + in + an + open + vector + follows + a + similar + pattern + in + many + LDDs + and + is + presented + in + outline + form + + + below: + + + + + + + + + e + Determine + the + channel + to + be + opened + using + the + pointer + to + the + device + name + held + in + + + [si]. + OpenNamePtr. + + + + + e + If + OK, + disable + interrupts + and + invoke + the + OS + HwGet + Channel + call. + + + + + e + If + OK, + then + set + A4ExifChannelOpen + flag + to + non-zero. + + + + + e + In + order + to + poll + for + door-opening + and + closing, + it + is + necessary + to + open + a + "TcK:" + channel + at + this + + + stage + and + initialise + it + by + means + of + using + the + OS + IowithWait + service + to + call + the + TickInt + vector + + + on + each + system + tick. + + + + + e + Re-enable + interrupts + and + set + up + the + calling + process + id + using + the + ProcId + service. + + + + + e + Check + for + the + presence + of + the + required + hardware. + If + present + return + with + carry + clear. + + + + + e + Allocate + space + in + calling + process' + heap + (i.e. + the + application + data + space) + to + contain + the + I/O + + + channel + control + block + (an + A4ExifEnt + struc + in + the + case + of + A4AEXIF.LDD) + and + set + its + base + + + address + to + BX + (thus + BX + holds + the + address + of + the + open + channel + control + block). + + + + + e + If + OK, + install + the + device + driver + Wait + Handler + using + the + IoAddHandler + system + service. + A + + + Wait + Handler + is + required + only + if + there + are + any + asynchronous + I/O + requests + to + be + handled. + + + + + e + If + OK, + initialise + the + fields + inside + the + I/O + channel + control + block + that + were + outlined + above. + + + + + e + Invoke + IoRequestReset + system + service + to + handle + unexpected + termination + of + main + program + + + by + invoking + the + driver's + Reset + vector. + + + + + e + Before + leaving + the + Open + vector, + if + the + call + succeeded, + BX + must + hold + the + open + channel + control + + + + + + + + + block + handle. + + + A4ExifStrategy + + + IN: + BX + holds + the + allocated + channel + control + block + initialised + in + the + open + vector + + + + + + + + + DX + contains + device + handle + of + the + device + driver + in + the + case + of + an + LDD + + + + + SL + is + pointer + to + RqEnt + struc + + + + + BP + is + pointer + to + IntEnt + struc + + + + + DS, + ES + point + to + data + segment + of + application + making + the + I/O + function + request + + + + + + + + + OUT: + If + successful + return + with + carry + clear. + Furthermore, + in + this + case, + if + the + strategy + + + vector + is + meant + to + complete + the + I/O + request + (as + is + the + case + with + IoClose + for + + + instance) + then + the + completion + status + should + be + written + back + to + RqStatusPtr + location + + + and + the + I/O + semaphore + signalled + by + calling + IoSignal. + If + the + I/O + request + is + not + completed + + + by + the + strategy + vector + (as + is + the + case + with + the + asynchronous + functions + IoFuncRead + + + and + IoFuncWrite) + then + PendingErr + should + be + written + back + to + the + location + pointed + to + by + + + + + + + + + RqStatusPtr + and + the + I/O + semaphore + should + not + be + signalled. + + + + + If + installation + unsuccessful, + return + with + carry + set + and + error + number + in + the + AL + + + register. + + + PRESERVE: + DS, + ES, + SS, + SP + and + BP + + + + + + + + + Revision + 1.00 + Page + 69 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + When + an + application + makes + a + I/O + request + on + the + opened + device + driver + channel, + the + request + is + routed + + + to + this + vector + by + the + operating + system. + A + device + driver + defines + the + set + of + strategy + functions + that + it + + + supports + such + as + IoFuncSet, + IoFuncSense, + IoFuncWrite + and + IoFuncClose. + The + functions + of + a + + + device + driver + are + usually + dependent + on + its + purpose + and + there + is + no + requirement + to + support + any + + + particular + function. + The + ordering + of + these + functions + in + the + strategy + vector + table + is + defined + in + p_file.h + + + and + presented + in + A4EXIF.ASM. + + + + + + + + + The + SI + register + contains + a + pointer + to + an + RqEnt + struc + which + consists + of + four + fields: + RqFunction, + + + RqStatusPtr, + RgA1Ptr + and + RqA2Ptr. + RqFunction + contains + the + function + number + passed + to + the + I/O + + + request + by + the + application. + In + the + device + driver + strategy + vector + code, + the + value + held + in + RqFunction + is + + + compared + against + the + supported + function + numbers + held + in + ToFuncClose, + IoFuncRead + etc. + If + the + + + function + number + is + not + one + of + those + supported + then + a + call + to + IoRoot + is + necessary + in + the + case + of + a + root + + + device + driver + such + as + A4EXIF.LDD. + toRoot + chains + the + I/O + request + through + to + the + operating + system + + + which + runs + some + default + code + to + handle + it. + RqStatusPtr + is + a + pointer + to + a + memory + location + in + the + + + application + data + space + which + holds + the + value + of + the + I/O + request's + completion + status + word. + While + a + + + request + is + outstanding, + this + value + is + set + to + PendingErr + and + only + when + it + completes + does + a + completion + + + code + get + written + to + this + location. + I/O + requests + can + complete + within + the + strategy + vector + or + later + after + an + + + interrupt. + Often + as + is + the + case + with + A4EXIF.LDD, + only + a + single + request + of + any + one + kind + can + be + + + outstanding + at + any + time + otherwise + the + application + is + panicked. + RqA1Ptr + and + RqA2Ptr + hold + the + values + + + of + two + parameters + that + are + passed + to + the + IoAsynchronous + EPOC + service. + Each + synchronous + strategy + + + function + has + a + similar + pattern + with + explicit + I/O + being + conducted + whilst + interrupts + are + disabled + and + a + + + completed + request + being + signalled + with + an + OS + ToSignal + call + prior + to + exit + from + the + function. + This + call + + + signals + to + the + OS + the + completion + of + the + particular + I/O + request + entailed + by + the + function + call. + The + + + situation + with + regard + to + the + one + asynchronous + strategy + function + is + somewhat + more + complicated + and + is + + + dealt + with + in + greater + detail + in + a + later + section. + + + + + + + + + The + structure + of + the + strategy + vector + of + A4EXIF.ASM + is + outlined + below: + + + + + + + + + e + Determine + the + strategy + function + number + using + [si].RqFunction + and + compare + with + the + below: + + + + + e + JIOFUNCREAD: + Asynchronous + read + of + latches + U4 + and + U3. + Panic + if + [bx].A4ExifStatusPtr + != + + + 0. + Update + [bx].A4ExifA1Ptr + and + [bx].A4ExifStatusPtr + with + [si].RqA1Ptr + and + + + [si].RqStatusPtr + respectively + as + the + locations + to + be + accessed + on + receipt + of + interrupt. + Move + + + PendingErr + into + the + location + pointed + to + by + [bx].A4ExifStatusPtr + to + signal + that + the + request + is + + + awaiting + completion. + Allow + handler + to + be + enabled + through + the + IoEnableHandler + OS + call + + + and + exit + without + signalling + completion + of + the + request. + + + + + e + IOFUNCWRITE: + Identical + behaviour + to + that + of + IoFUNCSET + which + it + calls. + + + + + e + TIOFUNCCANCEL: + Used + to + cancel + any + pending + asynchronous + reads. + This + involves + + + disabling + the + wait + handler, + consuming + any + stray + signal + from + the + interrupt + routine + by + means + of + + + an + OS + IoWaitForSignal + call + and + then + storing + cancelErr + in + the + channel + I/O + request + status + + + word. + + + + + e + IOFUNCCLOSE: + Close + down + the + TCK + channel + and + remove + handler. + Disable + interrupts + + + and + HwFreeChannel + setting + A4ExifPid + to + 0 + before + re-enabling + interrupts. + Invoke + + + IoRequestResetCancel + system + service + and + HeapFreeCell. + Signal + completion + of + I/O + + + request + by + calling + IoSignal + system + service. + + + + + e + IOFUNCSENSE: + Reads + the + status + and + LED + bytes + from + latches + U4 + and + U3 + respectively + + + storing + the + results + at + the + addresses + pointed + to + by + RgA1Ptr + and + RqA2Ptr. + + + + + e + IOFUNCSET: + Sets + latch + U5 + to + contain + the + value + pointed + to + by + the + sole + argument + in + the + + + call + to + P_FSENSE. + + + + + e + If + not + supported + then + call + IoRoot + system + service. + + + + + + + + + The + Non-Mandatory + LDD + Functions + + + + + + + + + The + eight + functions + described + above + must + be + supported + by + all + device + driver. + Typical + Psion + LDDs + + + employ + at + least + two + other + LDD + functions. + The + first + of + these + is + a + pseudo-interrupt + routine + which + is + + + invoked + by + the + OS + on + each + system + tick. + In + A4EXIF.LDD, + this + function + is + represented + by + + + A4ExifTickInt + and + an + outline + of + its + purpose + was + presented + earlier + in + the + discussion + on + holding + and + + + + + + + + + Revision + 1.00 + Page + 70 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + resuming + device + drivers. + As + was + indicated + then, + the + minimum + functionality + required + by + this + routine + + + is + to + poll + the + status + of + the + host + machine + doors + and + if + appropriate + call + the + driver's + Hold + and + Resume + + + vectors. + If + in + addition + the + LDD + is + intended + to + service + any + asynchronous + I/O + requests, + a + wait + handler + + + and + common + interrupt + service + routine + are + required. + With + A4EXIF.LDD, + these + two + additional + + + functions + are + represented + by + A4ExifHandler + and + ComInt + respectively. + The + former + function + + + constitutes + the + second + of + the + additional + LDD + functions + as + can + be + seen + by + examining + the + LibEnt + + + structure + for + A4EXIF.LDD. + The + latter + function + is + set + up + so + that + it + replaces + the + default + interrupt + + + service + routine + code + invoked + by + the + OS + on + the + receipt + of + hardware + interrupts + on + the + peripheral's + SIBO + + + channels. + A4ExifHandler + is + invoked + by + the + OS + every + time + the + I/O + semaphore + of + the + process + that + + + opened + the + channel + is + signalled + with + through + an + IoSignalByPidNoResched + call + indicating + that + an + + + interrupt + has + been + received + and + an + outstanding + I/O + request + has + completed. + The + function + of + the + wait + + + handler + is + to + deal + with + I/O + semaphore + signalling + and + to + update + the + appropriate + open + channel + control + + + block + field + variables. + The + common + interrupt + service + routine + code + in + ComInt + cannot + do + this + because + it + + + is + not + permitted + to + access + the + application + data + space. + This + in + turn + is + because + the + routine + runs + in + the + + + context + of + the + process + which + was + running + when + the + interrupt + occurred. + A4ExifTickInt, + the + wait + + + handler + and + the + common + interrupt + service + routine + for + A4EXIF.LDD + as + well + further + details + as + to + how + + + the + latter + two + interact + to + handle + asynchronous + I/O + requests + are + described + below. + + + + + + + + + A4ExifTicklint + + + + + + + + + As + was + explained + earlier + in + discussing + the + A4ExifHold + vector, + it + is + necessary + to + utilise + the + "TcK:" + + + system + tick + device + driver + in + order + to + handle + the + particular + case + of + invoking + a + hold + on + A4EXIF.LDD + + + when + the + host + machine + SSD + pack + doors + are + opened. + Such + an + action + automatically + causes + power + to + be + + + removed + from + any + peripherals. + The + TCK + driver + is + opened + via + an + OS + Toopen + call + in + the + A4ExifOpen + + + vector + which + returns + with + carry + clear + and + a + non-zero + handle + in + AX + if + successful. + In + this + case, + the + + + IoWithWait + function + is + called + to + request + an + synchronous + I/O + service + from + the + TCK + driver. + Prior + to + + + this + call, + the + service + number + requested + is + held + in + AL + and + the + I/O + handle + procured + from + the + previous + + + call + to + ToOpen + is + loaded + into + BX. + The + interrupt + number + of + the + tick + poll + routine, + A4ExifTickInt, + is + + + loaded + into + CX + so + that + as + its + parent + driver + is + invoked + on + each + system + tick, + the + OS + enters + this + vector. + + + The + reason + the + TickInt + routine + is + required + in + A4EXIF.LDD + is + solely + to + handle + the + problem + of + + + recognising + a + sudden + removal + of + power + from + the + host + machine. + The + OS + has + no + way + of + testing + for + this + + + condition + other + than + polling + its + global + 'Doorstatus' + variable + every + system + tick + and + taking + the + + + requisite + course + of + action. + As + such, + the + outline + of + the + code + for + the + tick + poll + routine + which + is + required + + + in + all + Psion + LDDs + can + be + presented + below. + This + outline + should + be + carefully + compared + with + the + + + structure + of + the + Hold + and + Resume + vectors + shown + earlier + in + order + to + see + how + they + interact: + + + + + + + + + e + Check + the + current + status + of + doors + which + is + held + in + SI. + + + + If + DoorlsOpen + then + if + global + HoldFlag + is + zero, + force + a + call + to + A4ExifHold, + set + HoldFlag + to + 2 + + + and + return + far + + + else + do + a + far + ret + + + e + = + Else + if + DoorIsClosed + then + + + if + global + HoldFlag + is + 2, + force + a + call + to + A4ExifResume + and + return + far + + + else + do + a + far + ret + + + + + + + + + It + should + be + emphasised + that + A4ExifTickInt + is + only + a + pseudo + interrupt + service + routine + in + that + it + does + + + not + preserve + the + status + of + the + registers + which + is + something + that + the + device + driver + writer + must + + + undertake + to + ensure + is + done + explicitly. + + + + + + + + + The + handling + of + synchronous + and + asynchronous + I/O + + + + + + + + + The + provision + of + synchronous + and + asynchronous + I/O + services + are + an + important + aspect + of + writing + any + + + device + driver. + In + the + case + of + Psion + drivers, + all + such + services + are + the + provided + through + the + Strategy + + + vector + which + is + typically + preceded + by + a + Strategy + Vector + Table + listing + the + complete + set + of + I/O + services + + + that + can + be + invoked + on + the + driver. + The + strategy + vector + table + for + A4EXIF.LDD + is + presented + below + to + + + provide + an + indication + as + to + the + kind + of + service + routines + that + can + be + written: + + + + + + + + + StrategyVectorTable + label + word + + + + + + + + + Revision + 1.00 + Page + 71 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + dw + offset + A4ExifDefault + 7StrategyPanic + + + + + dw + offset + A4ExifRead + ;StrategyRead + (function + define + is + P_FREAD) + + + + + dw + offset + A4ExifWrite + ;StrategyWrite + (function + define + is + P_FWRITE) + + + dw + offset + A4ExifClose + ;StrategyClose + (function + define + is + P_FCLOSE) + + + dw + offset + A4ExifCancel + ;StrategyCancel + (function + define + is + P_FCANCEL) + + + + + dw + offset + A4ExifDefault + 7StrategyAttach + + + + + dw + offset + A4ExifDefault + 7 + StrategyDetach + + + + + dw + offset + A4ExifSet + ;StrategySet + (function + define + is + P_FSET) + + + + + dw + offset + A4ExifSense + ;StrategySense + (function + define + is + P_FSENSE) + + + + + + + + + Both + synchronous + and + asynchronous + I/O + requests + can + be + made + on + the + driver + through + means + of + the + + + PLIB + 'p_iow + (pcb, + <func>, + &A1, + &A2)' + call + where + pcb + is + the + open + channel + handle, + <func> + is + one + of + + + the + above + function + defines + and + Al + and + A2 + are + two + optional + parameters + required + for + the + servicing + of + + + the + request. + The + routing + of + an + I/O + request + to + the + correct + service + code + is + done + by + the + common + code + at + + + the + head + of + the + strategy + vector. + Each + time + this + vector + is + entered, + BX + holds + the + address + of + the + open + + + channel + control + block, + DX + the + device + handle + of + the + device + driver + and + SI + a + pointer + to + the + strategy + + + RqEnt + struc + used + by + the + OS + to + follow + the + course + of + the + I/O + request. + Using + this + information, + it + is + + + possible + to + access + all + the + relevant + flags + in + the + channel + StatusEnt + by + moving + [bx].A4ExifStatusEntPtr + + + into + DI. + This + leaves + us + with + the + open + channel + control + block + in + DS:BX + and + the + channel + StatusEnt + in + + + CS:DI. + + + + + + + + + Armed + with + the + above + information, + it + is + possible + to + outline + the + general + pattern + of + both + synchronous + + + and + asynchronous + I/O + requests + at + an + OS + level. + The + case + of + synchronous + requests + is + particularly + + + straightforward + since + the + servicing + of + the + request + can + be + completed + entirely + within + the + relevant + + + strategy + vector + table + function. + It + should + be + emphasised + that + in + the + outline + presented + below, + disabling + + + and + re-enabling + of + interrupts + only + actually + has + to + be + done + around + any + I/O. + + + + + + + + + SYNCHRONOUS + I/O + REQUEST + STRATEGY + VECTOR + TABLE + FUNCTION + + + + + + + + + pushf + + + cli + ;Disable + interrupts + + + < + request + service + code + > + ;Relevant + synchr. + I/O + processing + + + + + + + + + ExitWithCompletionStatusZero: + + + < + set + I/O + request + status + word + to + zero + > + + + + + + + + + IoSignal + ;Signals + completion + of + I/O + to + OS + + + XOr + ax, + ax + + + + + onl + ol + ;Tells + OS + that + strategy + exited + OK + + + popf + ;Re-enable + interrupts + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + Note + that + in + the + above + outline, + the + single + ToSignal + call + is + made + after + completion + of + the + I/O + request + in + + + order + to + signal + this + fact + to + the + OS. + The + situation + is + somewhat + more + complicated + in + the + case + of + an + + + asynchronous + request + because + the + I/O + request + strategy + vector + table + function + has + to + interact + with + both + a + + + wait + handler + function + and + an + interrupt + service + routine. + Of + the + I/O + request + services + outlined + above + for + + + A4EXIF.LDD, + only + one, + namely + A4ExifRead, + is + asynchronous + and + it + serves + as + a + good + illustration + of + + + the + nature + of + programming + for + asynchroneity. + The + steps + taken + in + the + A4ExifRead + vector + are + outlined + + + below: + + + + + + + + + e + = + Set + the + ChannelReadCompleted + flag + to + 0 + (stored + in + cs:[di]. + A4ExifChanReadCompleted) + + + e + If + the + address + of + the + I/O + request + status + word + is + non-zero + then + panic + (i.e. + there + is + an + + + outstanding + read + request) + + + + + e + Update + the + open + channel + control + block + variables + using + the + RqEnt + struc + + + + + e + Load + I/O + request + status + word + with + PendingErr + + + + + e + Enable + the + wait + handler + by + using + the + To—EnableHandler + OS + service + + + The + read + request + is + now + in + a + pending + state + waiting + for + completion + via + receipt + of + a + hardware + interrupt. + + + When + such + an + interrupt + is + received, + the + OS + switches + into + the + appropriately + configured + common + + + interrupt + routine + ComInt. + Here, + the + channelReadCompleted + flag + is + set + to + indicate + to + the + handler + that + + + the + read + request + has + completed. + An + IoSignalByPidNoReSched + OS + service + call + is + also + made + to + + + indicate + to + the + OS + that + an + as + yet + unspecified + I/O + request + has + terminated. + This + signal + is + consumed + by + + + the + OS + which + means + that + at + this + stage, + an + IoSignal + for + completion + of + the + original + asynchronous + + + request + has + yet + to + be + made. + The + interrupt + service + routine + exits + after + sensing + the + status + and + LED + byte + + + values + from + the + ASIC4 + Example + Interface + Board + and + loading + the + appropriate + response + bytes + into + the + + + relevant + locations + in + the + device + driver + code + segment. + More + details + as + to + the + functionality + of + the + + + interrupt + service + routine + are + provided + in + the + section + on + interrupts. + The + OS + now + invokes + all + the + + + currently + active + wait + handlers + in + order + to + determine + which + application + is + responsible + for + consuming + + + + + + + + + Revision + 1.00 + Page + 72 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + the + completed + read. + The + wait + handler + code + includes + the + all-important + IoSignal + call + that + indicates + to + + + the + OS + that + the + original + asynchronous + read + request + has + finally + been + accounted + for. + Receipt + of + this + + + signal + by + the + OS + constitutes + completion + of + the + request. + The + outline + code + for + the + A4EXIF.LDD + wait + + + handler + A4ExifHandler + is + outlined + in + the + next + section. + + + + + + + + + A4ExifHandler + + + + + + + + + A + WaitHandler + is + a + special + function + of + the + LDD + which + is + nominated + to + be + called + by + the + operating + + + system + every + time + the + I/O + semaphore + of + the + process + that + opened + the + channel + is + signalled. + It + will + only + + + actually + be + called + if + the + application + is + already + waiting + for + an + outstanding + I/O + request + to + complete + (1.e. + + + while + the + application + is + hung + in + p_iowait). + The + handler + function + is + the + means + by + which + hardware + + + interrupts + can + be + filtered + through + to + the + process + which + opened + the + I/O + channel + since + it + permits + the + + + rescheduling + of + processes. + + + + + + + + + The + WaitHandler + is + invoked + in + the + open + vector + by + using + the + IoAddHandler + system + service. + When + an + + + application + makes + an + I/O + request, + the + I/O + semaphore + is + signalled + and + the + operating + system + calls + the + + + Wait + Handler + function + while + the + application + is + waiting + for + the + request + to + complete. + The + wait + handler + + + returns + with + CLC + if + no + outstanding + request + has + completed. + Otherwise + the + wait + handler + returns + with + + + STC + and + zero + in + AL. + The + wait + handler + can + include + within + it + synchronous + I/O + requests + to + cancel + or + + + use + up + signals + but + it + is + not + entered + recursively + (i.e. + re-enterently) + by + the + operating + system. + A + wait + + + handler + is + best + viewed + as + a + necessary + requirement + in + dealing + with + the + I/O + semaphore + signalling + which + + + cannot + entirely + be + addressed + in + the + appropriate + interrupt + service + routine + because + the + latter + is + not + able + + + to + access + the + open + channel's + control + block. + + + + + + + + + Interrupts + and + Interrupt + Service + Routines + + + + + + + + + The + SIBO + architecture + allows + for + eight + separate + hardware + interrupt + sources. + The + EPOC + operating + + + system + provides + a + GenSetRevector + service + to + enable + a + device + driver + to + install + an + interrupt + service + + + routine + for + any + of + these + eight + interrupt + sources. + When + an + interrupt + occurs, + the + operating + system + + + preserves + the + state + of + all + the + registers + before + calling + the + appropriately-installed + interrupt + service + + + routine. + As + a + result + of + this, + the + interrupt + service + routine + is + free + to + employ + any + register + it + sees + fit + to + use. + + + A + few + important + points + ought + to + be + made + concerning + the + code + within + an + interrupt + service + routine: + + + + + + + + + e + On + an + 8086 + processor, + interrupts + cannot + be + nested + so + their + is + no + requirement + to + disable + + + interrupts + whilst + inside + the + interrupt + service + routine. + + + + + e + Interrupt + service + routines + should + operate + as + fast + as + possible. + In + general, + operating + system + + + service + routines + are + tuned + to + be + of + less + than + Ims + duration. + + + + + e + Interrupt + service + routines + run + in + the + context + of + the + process + that + was + running + at + the + time + of + the + + + interrupt + and + should + access + only + the + device + driver + data + space + which, + as + with + A4EXIF.LDD, + + + typically + resides + in + its + own + CS + space. + + + + + e + Interrupt + service + routines + should + not + cause + a + process + rescheduling. + To + indicate + that + an + event + + + has + occurred + to + the + interrupted + process, + the + ToSignalByPidNoResched + system + service + + + should + be + called. + If + a + call + is + made + to + this + service, + the + interrupt + service + routine + should + exit + + + with + CLC + otherwise + it + returns + with + STC. + + + + + + + + + The + interrupt + routines + called + require + knowledge + as + to + the + particular + hardware + SIBO + channel + being + + + used + by + the + driver + at + the + time + an + interrupt + occurs. + This + information + is + passed + through + to + the + + + GenSetRevector + function + in + StartInterrupts + by + loading + the + address + of + the + appropriate + Int + Vec + routine + + + from + the + A4ExifChannelIntVec + field + of + the + channel + StatusEnt + struc. + As + a + result, + when + an + interrupt + + + occurs, + the + currently + loaded + IntVec + routine + is + invoked. + All + the + Intvec + routines + reload + DI + with + the + + + appropriate + address + of + the + channel + StatusEnt + in + the + device + driver + code + segment + before + falling + through + + + to + the + common + interrupt + routine + service + code + held + in + ComInt. + + + + + + + + + Comint + + + + + + + + + Revision + 1.00 + Page + 73 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + common + interrupt + service + routine + code + resides + in + the + ComInt + vector. + The + structure + of + this + code + is + + + presented + below. + It + should + be + emphasised + that + no + data + in + the + application + data + space + and + hence + in + the + + + open + channel + control + block + can + be + accessed + from + ComInt. + This + explains + why + it + is + necessary + for + the + + + OS + to + invoke + a + wait + handler + to + clean + up + after + the + interrupt + service + routine + code + for + a + particular + + + asynchronous + I/O + request + has + been + run. + + + + + + + + + e + Check + the + value + held + in + the + chanReadCompleted + flag + + + + + e + If + this + value + is + 2 + then + we + do + not + have + an + asynchronous + read + completed + but + rather + the + + + interrupt + line + has + been + pulled + low + outside + of + an + asynchronous + I/O + request. + + + + + e + If + this + value + is + 1 + then + we + have + an + asynchronous + I/O + request + completed + and + so + + + IoSignalByPidNoResched + must + be + invoked + to + signal + to + the + OS + that + a + read + has + completed. + + + + + e + In + both + cases, + sense + the + status + and + LED + bytes + from + the + Example + Interface + hardware + and + load + + + these + values + in + the + device + driver's + code + segment + A4ExifStatusEnt + struc. + + + + + e + There + are + four + possibilities + of + status + byte + corresponding + to + the + four + combinations + offered + by + + + the + two + input + switches, + S1 + and + S2. + These + are + used + to + output + one + of + four + separate + LED + bytes + + + to + the + LEDs. + + + + + e + Awrite + to + AlNonSpecificEoi + register + (or + A9BNonSpecificEoiW + in + the + case + of + an + ASIC9 + + + machine) + must + be + done + prior + to + exiting + to + let + the + OS + know + that + the + installed + interrupt + service + + + routine + has + terminated. + + + + + + + + + Other + important + local + device + driver + functions + + + + + + + + + The + functions + presented + in + this + section + are + local + to + A4EXIF.LDD + and + perform + various + important + tasks + + + relating + to + the + peripheral + hardware + such + as + groping + the + hardware + and + setting + interrupts + running. + + + Since + these + tasks + have + to + be + undertaken + by + most + device + drivers, + the + relevant + functions + are + outlined + in + + + greater + detail. + + + + + + + + + A4ExifCheckHardwarePresent + + + + + + + + + Every + Psion + device + driver + has + a + characteristic + 'CheckHardwarePresent’ + or + 'GropeHardware" + function + + + that + usually + involves + checking + for + the + presence + of + the + required + peripheral + device + by + means + of + + + comparing + a + couple + of + ASIC4 + identification + bytes + returned + by + the + peripheral + in + response + to + a + SIBO + + + serial + protocol + identification + message + with + the + expected + answers. + The + specific + value + of + the + InfoByte + is + + + unimportant + as + long + asa + "test + al, + al" + call + is + made + which + will + always + return + a + non-zero + answer + if + + + ASIC4 + is + present. + In + that + case, + the + extended + info + byte + should + be + tested + for + against + what + is + expected + + + from + address + lines + A23-A27. + + + + + + + + + Psion + Workabout/HC + machines + have + three + physical + serial + links + and + two + of + these + are + accessed + via + the + + + SSD + slots. + The + third + link + corresponds + to + the + serial + expansion + port. + In + order + for + a + driver + to + talk + to + a + + + peripheral + connected + to + this + port, + it + must + specifically + select + this + serial + link. + In + order + to + prevent + + + multiple + access + to + a + single + peripheral, + it + is + necessary + in + the + first + instance + to + check + whether + the + serial + + + channel + is + free + or + not. + A + call + to + the + operating + system + function + HwGet + Channel + with + the + appropriate + + + interrupt + mask + in + AL + returns + with + CLC + if + the + channel + was + captured + successfully. + Logically + this + call + + + should + be + made + in + the + Open + vector + but + since + it + can + only + sensibly + be + made + after + the + hardware + has + been + + + successfully + located + it + can + be + placed + at + the + end + of + the + GropeHardware + function. + A + corresponding + call + + + to + HwFreeChannel + must + be + made + when + closing + the + channel. + To + actually + select + a + channel + prior + to + + + communication + along + it, + a + call + to + HwSelectChannel + Is + necessary. + + + + + + + + + A4ExifStartChannelRunning + + + + + + + + + This + function + is + called + at + the + end + of + the + Open + vector + to + set + the + ASIC4 + Example + Interface + hardware + + + running. + It + can + also + be + invoked + by + the + Hold + vector. + The + function + first + checks + the + status + of + the + global + + + StatusEnt + ChannelRunning + flag. + If + this + flag + is + clear, + CheckHardware + is + called + to + determine + whether + + + the + hardware + is + still + connected + and + then + StartInterrupts + is + called + before + the + channelRunning + flag + is + + + + + + + + + Revision + 1.00 + Page + 74 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + set + to + indicate + that + the + channel + hardware + has + been + started. + The + function + returns + with + CLC + on + + + successful + completion + or + with + STC + if + no + hardware + was + located. + + + + + + + + + A4ExifStopChannelRunning + + + + + + + + + This + function + simply + clears + the + channelRunning + flag + if + set + and + calls + StopInterrupts + unless + the + + + channel + already + has + its + ChannelRunning + flag + clear. + The + StopChannelRunning + function + will + be + called + + + by + Strategy + vector + when + trying + to + close + a + channel + and + can + also + be + called + by + the + Resume + vector. + + + + + + + + + A4ExifStartinterrupts + + + + + + + + + StartInterrupts + is + called + whenever + a + call + is + made + to + StartChannelRunning. + At + the + heart + of + the + + + function + is + a + call + to + the + OS + GenSetRevector + function + which + is + used + to + install + a + specified + interrupt + + + service + routine + in + the + place + of + the + default + routine + held + in + the + interrupt + vector + table. + GenSetRevector + + + is + called + with + the + interrupt + vector + number + of + the + service + to + be + replaced + in + AX + and + the + offset + and + code + + + segment + of + the + replacement + interrupt + vector + service + in + BX + and + CX + respectively. + BX + is + loaded + from + + + the + ChannelIntVec + field + of + the + channel + StatusEnt + which + holds + the + name + of + the + specific + interrupt + + + service + routine + code + (i.e. + IntVecO, + IntVec1 + etc.). + The + latter + functions + set + up + the + appropriate + channel- + + + specific + variables + before + falling + through + to + the + common + ComInt + routine. + The + channel + interrupt + mask + + + which + is + machine + and + channel + dependent + is + written + to + the + appropriate + register + on + the + host + ASIC. + In + + + the + case + of + ASIC9, + this + register + will + be + A9BInterruptMaskRW. + For + ASIC1 + it + will + be + + + AlInterruptMask. + + + + + + + + + A4ExifStopInterrupts + + + + + + + + + StopInterrupts + reinstalls + the + original + interrupt + service + routine + by + invoking + the + GenResetRevector + OS + + + system + service + and + signalling + the + interrupt + mask + to + the + corresponding + host + ASIC + register. + + + + + + + + + Structures + and + Include + files + + + + + + + + + Epocdef.inc + and + device + driver + strucs + + + + + + + + + Epocdef.inc + is + an + important + header + file + that + contains + the + definitions + of + various + strucs + extensively + used + + + in + the + construction + of + device + drivers. + It + also + contains + the + definitions + of + all + the + OS + error + values + such + as + + + DeviceErr + and + NameErr + that + are + used + in + A4EXIF.LDD + to + communicate + an + error + to + the + application + + + via + AX. + Listed + below + and + overleaf + are + the + key + strucs + defined + in + Epocdef.inc + that + were + used + in + the + + + coding + of + A4EXIF.LDD. + + + + + + + + + LibEnt + struc + Start + of + device + driver + + + LibSignature + dw + ? + + + + + LibInfo + dw + 2 + + + + + LibCount + dw + ? + + + + + LibBase + dw + ? + + + + + LibEnt + ends + + + + + + + + + OpenEnt + struc + Pointed + to + by + SI + in + Open + vector + + + OpenNamePtr + dw + ? + + + + + OpenMode + dw + ? + + + + + OpenChan + dw + ? + + + + + OpenEnt + ends + + + + + ChanEnt + struc + Used + in + open + channel + control + block + + + ChanSignature + dw + 2 + + + + + ChanNext + dw + ? + + + + + ChanLibHandle + dw + ? + + + + + ChanEnt + ends + + + + + + + + + IntEnt + struc + Pointed + to + by + BP + in + Open + and + Strategy + vectors + + + IntFrame + dw + ? + + + + + IntBP + dw + ? + + + + + IntES + dw + 2 + + + + + IntDS + dw + ? + + + + + + + + + Revision + 1.00 + Page + 75 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + IntPC + dw + ? + + + IntCs + dw + 2 + + + IntFLAGS + dw + ? + + + + + + + + + IntEnt + struc + ends + + + + + + + + + RqEnt + struc + Pointed + to + by + SI + in + strategy + vector + + + RqFunction + dw + 2 + + + RqA1Ptr + dw + ? + + + RqA2Ptr + dw + ? + + + RqStatusPtr + dw + ? + + + + + + + + + RqEnt + struc + ends + + + + + + + + + A4EXIF + channel + strucs + + + + + + + + + These + are + defined + at + the + start + of + the + A4EXIF.LDD + code + segment. + The + open + channel + control + block + is + + + held + in + a + structure + of + type + A4ExifEnt + and + is + allocated + space + from + the + heap + of + the + process + invoking + the + + + device + driver's + open + vector. + As + such, + it + cannot + be + accessed + from + the + Hold, + Resume + and + Reset + vectors + + + or + from + the + interrupt + service + routine, + ComInt. + The + channel + StatusEnt + holds + various + key + channel + + + related + flags. + Each + hardware + channel + has + its + own + StatusEnt + which + is + instantiated + in + a + header + in + the + + + device + driver + code + segment + following + the + LibEnt + structure. + This + header + block + is + usually + held + in + + + CS:DI + which + is + how + the + StatusEnt + variables + are + accessed. + The + structure + of + both + A4EXIF + channel + + + strucs + is + shown + below: + + + + + + + + + A4ExifEnt + struc + OPEN + CHANNEL + CONTROL + BLOCK + + + A4xifIo + ChanEnt<> + + + + + A4ExifHandlerPtr + dw + ? + Pointer + to + the + Wait + Handler + + + A4ExifStatus + dw + ? + Address + of + I/O + request + status + word + + + A4ExifAlPtr + dw + ? + Pointer + to + first + argument + + + + + A4ExifA2Ptr + dw + 2. + Pointer + to + second + argument + + + A4ExifStatusEntPtr + dw + ? + Pointer + to + channel's + StatusEnt + + + A4ExifTickHandle + dw + ? + Handle + to + the + TCK + device + channel + + + + + + + + + A4ExifEnt + ends + + + + + + + + + A4ExifStatusEnt + struc + CHANNEL + STATUS_ENT + + + + + A4ExifChannelPid + db + ? + Process + id + of + process + holding + + + channel + open + + + + + A4ExifChannelOpen + db + 2 + Is + the + channel + open + or + not? + + + A4ExifChannelRunning + db + ? + Is + the + channel + running? + + + A4ExifChanReadCompleted + db + ? + Flag + used + to + indicate + to + handler + + + when + + + + + A4ExifChanneliIntMask + db + ? + Contains + the + HW + channel + interrupt + mask + + + A4ExifChannelIntNum + db + ? + Holds + no. + of + interrupt + vector + to + be + + + replaced + + + + + A4ExifChannelSelect + db + 2 + SIBO + channel + select + flag + + + A4ExifChannelDummy + db + 2 + Spare + + + + + A4ExifChanneliIntVec + dw + ? + Holds + replacement + int. + vector + routine + + + name + + + + + + + + + A4ExifStatusEnt + ends + + + + + + + + + Ossibo.inc + and + Ospack.inc + + + + + + + + + Ossibo.inc + is + an + important + header + file + that + contains + the + defines + for + all + the + ASIC2 + and + ASIC9 + register + + + addresses. + Ospack.inc + contains + similar + information + but + for + ASIC4. + + + + + + + + + Revision + 1.00 + Page + 76 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 12. + AN + EXAMPLE + DEVICE + DRIVER + FOR + ASIC5: + + + SYS$AS5.PDD + + + + + + + + + Introduction + + + + + + + + + In + this + chapter, + the + functionality + and + code + structure + an + example + installable + physical + device + driver, + + + SYS$AS5.PDD, + is + presented + in + some + depth. + Circuit + details + of + the + corresponding + Psion + peripheral + for + + + this + driver, + the + Psion + 3-link, + were + outlined + in + chapter + 8. + SYS$AS5.PDD + enables + software + written + + + using + the + Psion + SDK + to + communicate + with + the + 3-link + peripheral + through + means + of + standard + PLIB + + + calls + such + as + ‘p_open' + and + 'p_write'. + This + peripheral + incorporates + an + ASICS + as + the + SIBO + serial + + + protocol + slave + device. + As + explained + earlier + in + chapter + 7, + ASICS + has + an + on-board + 16550 + UART + which + + + means + that + it + can + be + used + in + conjunction + with + the + standard + serial + LDD + provided + an + appropriate + PDD + + + is + loaded. + SYS$AS5 + is + a + PDD + intended + for + this + purpose + and + its + description + in + this + chapter + provides + a + + + clear + insight + into + the + generalised + structure + and + construction + of + physical + device + drivers + for + peripherals + + + based + around + the + SIBO + architecture. + + + + + + + + + The + LDD-PDD + interface + + + + + + + + + All + Psion + device + drivers + have + a + LibEnt + structure + at + the + head + of + their + code + segment + which + includes + a + + + vector + table + defining + the + functionality + of + the + driver. + In + the + case + of + SYS$AS5, + four + vectors + are + defined. + + + These + are: + Install, + Remove, + Open + and + Strategy. + The + structure + of + the + first + three + of + these + are + fixed + for + + + most + device + drivers + but + the + fourth + can + be + specified + in + any + way. + This + fourth + vector + defines + the + LDD- + + + PDD + interface + and + is + constructed + to + allow + the + two + drivers + to + best + communicate + with + each + other. + In + the + + + case + of + serial + PDDs, + the + approach + taken + is + modelled + on + the + LDD + strategy + vector + with + the + + + corresponding + strategy + vector + table + and + function + numbers. + This + is + a + logical + choice + but + it + is + important + + + to + emphasise + that + the + LDD-PDD + interface + is + completely + user-definable + and + that + the + approach + + + described + in + this + chapter + is + optional. + + + + + + + + + The + key + feature + of + any + LDD-PDD + interface + is + that + the + LDD + must + have + no + explicit + concept + of + + + hardware. + In + the + case + of + the + serial + LDD, + for + instance, + it + knows + that + it + has + a + serial + port + that + it + can + read + + + data + bytes + from + or + write + data + bytes + to + but + it + is + ignorant + of + the + explicit + implementation + of + the + hardware + + + at + this + port. + That + aspect + is + handled + by + the + corresponding + PDD + which + handles + all + the + specifics + of + data + + + byte + I/O. + In + the + case + of + an + application + writing + a + buffer + to + the + serial + port + by + means + of + a + + + p_iow(P_FWRITE....) + call, + for + instance, + the + LDD + will + first + copy + the + data + in + the + application's + DS + into + + + a + local + CS + buffer. + It + will + then + call + the + PDD + to + indicate + that + it + intends + to + start + sending + data + bytes + when + + + the + PDD + is + ready + to + start + receiving. + When + the + PDD + is + ready + to + commence + sending + a + byte + out + of + the + + + serial + port, + it + calls + a + function + (TransmitByte) + in + the + LDD. + This + function + reads + the + next + byte + to + be + + + transmitted + from + its + local + buffer + and + hands + it + to + the + PDD. + The + PDD + duly + transmits + the + byte + and + again + + + calls + TransmitByte + until + all + the + bytes + are + completed. + The + LDD + then + sends + a + special + 'NothingToSend' + + + signal + to + the + PDD + which + indicates + that + transmission + is + finished. + The + LDD + also + sends + an + + + IoSignalByPidNoResched + which + causes + its + wait + handler + to + be + invoked + by + the + OS. + In + this + way, + the + + + IoSignal + that + signifies + completion + of + the + original + write + request + is + invoked + by + the + LDD. + Note + that + the + + + LDD + has + no + concept + of + interrupts, + merely + of + sending + a + byte + at + a + time + and + registering + completion + or + + + otherwise + of + I/O + requests. + Futhermore, + the + PDD + never + takes + the + initiative + from + the + LDD + and + merely + + + undertakes + one + function + at + a + time + before + returning + control + back + to + the + LDD. + The + LDD-PDD + interface + + + is + examined + in + greater + depth + later + in + this + chapter + when + the + structure + of + the + PDD + strategy + vector + is + + + presented. + + + + + + + + + Revision + 1.00 + Page + 77 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Code + Structure + + + + + + + + + Device + Names + and + Loading + SYS$AS5.PDD + + + + + + + + + SYS$AS5.PDD + is + loaded + into + the + RAM + of + the + host + machine + by + means + of + the + following + PLIB + call + in + + + the + application + code: + + + + + + + + + p_loadldd("SYSS$AS5.PDD") + ; + + + + + + + + + The + name + of + a + device + driver + is + the + mechanism + by + which + an + application + can + obtain + a + channel + to + that + + + device + driver. + LDDs + all + have + three + character + names + followed + by + a + period, + a + further + three + characters + + + and + acolon. + The + first + three + characters + of + a + PDD + name + are + the + name + of + the + LDD + to + which + the + PDD + + + belongs. + The + second + set + of + three + characters + uniquely + identify + the + PDD. + The + device + name + is + required + + + to + uniquely + identify + the + LDD + to + the + OS + when + attempting + to + open + a + channel + on + it. + The + SYS$AS5 + PDD + + + belongs + to + the + "TTY:" + LDD. + Its + name + as + defined + in + its + LibEnt + structure + is + 'TTY.SR5'. + Thus + a + + + channel + with + its + handle + in + pcb + may + be + obtained + on + it + at + the + application + level + by + means + of + the + + + following + call: + + + + + + + + + p_open + (&pcb, + "TTY.SR5:A",-1); + + + + + + + + + The + qualifier + after + the + colon + indicates + that + the + driver + can + support + more + than + one + channel. + Channels + + + are + allocated + a + single + character + sequentially + from + the + character + 'A' + up + to + the + character + 'C'. + The + + + number + of + channels + that + can + be + supported + in + this + way + is + dependent + upon + the + host + hardware. + Only + one + + + expansion + port + can + be + opened + on + the + S3a + for + instance + whereas + three + are + possible + on + the + Workabout + + + and + HC. + EPOC + uses + the + driver + name + in + the + p_open + call + to + invoke + the + ToOpen + system + service + which + in + + + turn + invokes + the + Open + vector + on + the + associated + device + driver. + + + + + + + + + The + Single + Code + Segment + and + Data + Storage + + + + + + + + + All + data + associated + with + a + physical + device + driver + must + be + stored + in + its + code + segment. + Examples + of + + + such + data + are + the + channel + interrupt + masks + and + numbers + that + have + to + be + visible + to + all + processes + that + + + may + be + using + SYS$AS5.PDD. + + + + + + + + + The + overall + structure + of + the + code + segment + is + typical + of + Psion + physical + device + drivers. + The + segment + + + begins + with + a + CodeSeg + directive + followed + by + the + LibEnt + structure + which + defines + all + the + device + driver + + + functions. + Before + entering + the + code + for + these + functions, + all + global + variables + are + declared + in + the + + + internal + (CS) + data + space. + Following + the + code + for + the + LibEnt + functions + comes + the + code + for + all + the + local + + + driver + functions, + After + these + are + the + EndCodeSeg + and + end + OsAs5PDD + directives. + + + + + + + + + The + Channel + struct + and + A5Ent + struct + + + + + + + + + At + the + head + of + the + driver's + assembler + source + file, + SYS$AS5.ASM, + various + constants, + compiler + defines + + + and + types + are + listed. + It + is + here + that + templates + are + declared + for + the + global + structures + that + hold + the + key + + + driver + variables. + in + the + case + of + SYS$AS5, + one + main + structure, + the + Sr5ChannelStruct, + is + employed + to + + + hold + the + various + important + flags + and + masks + that + relate + to + the + status + of + each + separate + channel + on + the + + + driver. + This + structure + is + termed + the + Channel + struct + and + its + fields + are + filled + in + during + the + course + of + + + running + the + PDD + install + and + open + vectors. + Whenever + the + serial + LDD + invokes + one + of + the + PDD + + + functions, + the + application + must + ensure + that + CS + holds + the + address + of + the + PDD's + code + segment + which + is + + + where + the + Channel + struc + resides. + The + channel's + Channel + struct + is + usually + accessed + through + DI + or + BX + + + depending + on + preference. + Its + layout + is + presented + later + in + this + chapter + along + with + other + important + + + defines + that + were + used + in + the + construction + of + SYS$AS5.PDD. + + + + + + + + + SIBO + hardware + and + conditional + compilation + + + + + + + + + As + indicated + previously, + the + number + of + expansion + channels + supported + by + a + host + Psion + machine + is + + + dependent + on + the + hardware. + In + the + case + of + the + S3a, + only + one + SIBO + channel + can + legitimately + be + + + opened + corresponding + to + expansion + port + A. + With + the + HC + and + the + Workabout, + it + is + possible + to + open + up + + + to + three + separate + SIBO + channels + on + ports + A + through + to + C. + SYS$AS5.PDD + is + constructed + to + enable + it + + + to + run + on + any + host + Psion + platform. + In + its + internal + data + space, + the + various + hardware + options + for + the + + + SIBO + channels, + interrupt + masks + and + interrupt + numbers + are + coded + in + a + large + if + statement + thereby + + + + + + + + + Revision + 1.00 + Page + 78 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + permitting + conditional + compilation + of + the + driver + for + the + required + host + hardware. + The + only + change + that + + + need + be + made + in + adapting + it + for + use + on + another + Psion + machine + is + the + alteration + of + the + build + flag + at + the + + + start + of + the + code + segment. + This + flag + indicates + to + the + compiler + which + SIBO + machine + flags + as + well + as + + + other + variables + should + be + set. + The + conditional + compilation + table + outlined + here + is + worthy + of + some + study + + + because + it + encapsulates + all + the + information + regarding + masks + and + SIBO + hardware + channels + required + by + + + the + prospective + developer + interested + in + constructing + a + multi-platform + peripheral + and + accompanying + + + PDD. + + + + + + + + + The + PDD + Functions + + + + + + + + + OsAS5install + + + IN: + Nothing + + + OUT: + If + successful, + return + with + carry + clear + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + + + + + + + + + PRESERVE: + SS, + SP, + BP + + + + + + + + + The + install + vector + is + called + by + the + parent + LDD + whenever + the + PDD + is + required + to + be + loaded. + It + cannot + + + be + called + directly + be + an + application + only + indirectly + through + the + LDD + in + its + Install + vector. + The + install + + + vector + is + called + in + the + context + of + the + OS + with + DS + and + ES + in + an + unknown + state. + Memory + will + not + be + + + moved + while + in + this + function + so + the + normal + rules + governing + the + use + of + ES + and + DS + may + be + ignored. + + + + + + + + + OsAS5Remove + + + + + + + + + IN: + Nothing + + + OUT: + If + successful, + return + with + carry + clear + + + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + + + + + + + + + PRESERVE: + SS, + SP, + BP + + + + + + + + + The + remove + vector + is + called + by + the + parent + LDD + whenever + the + PDD + is + required + to + be + unloaded. + It + + + cannot + be + called + directly + by + an + application + and + only + indirectly + through + the + LDD + in + its + Remove + vector. + + + The + remove + vector + is + called + in + the + context + of + the + OS + with + DS + and + ES + in + an + unknown + state. + Memory + + + will + not + be + moved + while + in + this + function + so + the + normal + rules + governing + the + use + of + ES + and + DS + may + be + + + ignored. + + + + + + + + + OsAS5Open + + + IN: + SS:SI + points + to + the + OpenEnt + structure + + + ES, + DS + point + to + the + DS + of + the + application + process. + + + OUT: + If + successful, + return + with + carry + clear + and + control + block + in + BX + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + + + + + + + + + PRESERVE: + SS, + SP, + BP + + + + + + + + + The + open + vector + is + called + by + the + parent + LDD + whenever + a + channel + to + the + PDD + is + required + to + be + opened. + + + It + cannot + be + called + directly + by + an + application + and + is + typically + invoked + in + the + higher + level + LDD + Open + + + vector + code + by + means + of + the + DevOpenPpp + OS + system + call. + On + invoking + the + open + vector, + SI + points + to + + + the + OpenEnt + structure + which + contains + three + fields, + namely + OpenNamePtr, + OpenMode + and + OpenChan. + + + The + OpenNamePtr + points + to + the + qualifier + immediately + following + the + device + name + in + the + call + to + + + p_open. + In + the + case + of + SYS$ASS5, + for + instance, + the + OpenNamePtr + would + point + to + the + 'a' + in + the + name + + + "TTY.SR5:A". + This + corresponds + to + an + attempt + to + open + the + first + hardware + SIBO + channel + on + the + host + + + machine + which + if + successful + will + leave + the + address + of + the + ChanO + Sr5ChannelStruct + in + BX. + The + PDD + + + open + vector + finally + includes + a + call + to + the + OS + service + HwGet + Channel + to + obtain + the + requested + SIBO + + + channel. + + + + + + + + + Revision + 1.00 + Page + 79 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + The + order + of + action + undertaken + by + the + parent + serial + LDD's + open + vector + is + generally + fairly + complicated + + + and + includes + various + calls + to + the + PDD + strategy + vector + routines. + The + situation + is + outlined + overleaf: + + + + + + + + + e + Ensure + that + the + LDD + itself + can + be + opened. + + + + + e + Call + the + PDD + open + vector + using + the + OS + DevOpenPDD + OS + call. + + + + + e + = + If + successful, + call + the + OS + service + DevGet + PDDAddress + which + returns + the + full + segment:offset + + + address + of + the + PDD's + fourth + strategy + vector + in + BX:AX. + These + values + are + loaded + into + the + + + dword + Channel + struct + field + SerialPDDEntry. + + + + + e + Invoke + the + PDD + strategy + Open + and + SetHandlerCS + functions + to + set + up + offsets + and + segments + + + respectively + to + locations + in + the + LDD + above. + + + + + e + Invoke + strategy + Set + to + initialise + the + transmission + baud + rate. + + + + + e + Invoke + strategy + Start + to + set-up + and + then + enable + interrupts + + + + + + + + + Once + the + DevGetPDDAddress + service + has + been + used + to + load + the + LDD's + SerialPDDEntry + field, + it + may + + + be + used + to + load + in + the + address + of + any + of + the + PDD's + strategy + functions. + The + DevGetPDDAddress + OS + + + call + invoked + in + the + LDD + open + vector + must + also + be + invoked + in + the + LDD + resume + vector + code + since + + + memory + may + have + been + moved + while + the + LDD + was + held. + The + PDD + is + ignorant + of + such + activity + since + + + the + serial + LDD + is + responsible + for + handling + all + holds + and + resumes. + + + + + + + + + OsAS5Strategy + + + IN: + AX + holds + the + vector + number + + + ES, + DS + point + to + the + DS + of + the + application + process. + + + OUT: + If + successful, + return + with + carry + clear + and + control + block + in + BX + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + + + + + + + + + PRESERVE: + SS, + SP, + BP + + + + + + + + + The + strategy + functions + are + invoked + directly + from + the + various + serial + LDD + vectors + to + provide + hardware- + + + specific + services. + For + instance, + in + order + to + set + up + the + baud + rate, + it + is + necessary + to + invoke + strategy + Set. + + + The + strategy + vector + table + for + OsAS5Strategy + is + presented + below + and + then + the + functionality + of + the + + + important + component + vectors + is + outlined: + + + + + + + + + AS5StrategyJumpTable + label + word + + + + + + + + + dw + offset + AS5Open + ;Load + Handler + offsets + + + + + dw + offset + AS5Close + ;Close + the + channel + + + + + dw + offset + AS5Start + ;Start + the + channel + + + + + dw + offset + AS5Stop + ;Stop + the + channel + + + + + dw + offset + AS5Set + ;Set + the + channel + status + + + + + dw + offset + AS5Sense + ,;Return + channel + status + + + dw + offset + AS5Control + ;Drive + the + handshaking + lines + + + dw + offset + ASS5Enquire + ;Returns + baud + rate + + + + + dw + offset + AS5Enable + ;Begin + sending + output + + + dw + offset + ASS5SetHandlercCs + ;Load + Handler + segments + + + + + + + + + Open + and + SetHandlerCS + go + together + and + are + invoked + from + the + LDD + open + and + resume + vector + code. + + + Both + are + required + to + let + the + PDD + know + the + address + at + which + its + LDD + resides. + The + four + full + addresses + + + passed + through + to + Open + and + SetHandlerCS + are + of + the + LDD's + control + block + and + the + LDD + StatusInt, + + + RecvInt + and + XmitInt + vectors. + Close + is + called + in + order + to + close + an + opened + channel. + Start + and + Stop + are + + + used + to + enable/disable + interrupts + and + are + invoked + from + the + LDD + open, + hold/resume + and + set + vectors. + + + The + order + of + action + in + the + PDD + Start + vector + is + as + follows: + + + e + Initialise + PDD + variables + + + e + Check + H/W + present + + + e + Start + the + hardware + running. + In + the + case + of + SYS$ASS5, + part + of + this + process + involves + starting + a + + + continuous + clock + from + the + host + controller + ASIC + in + order + to + trigger + the + UART + clock + on + the + 3- + + + link's + ASICS. + In + addition + to + this + clock, + the + RTS + and + DTR + lines + must + be + driven + low. + + + e + = + Start + interrupts. + + + The + common + interrupt + service + routine + code + resides + in + the + PDD + ComInt + function. + This + code + is + patched + + + into + the + interrupt + vector + via + the + GenSetRevector + system + service. + The + interrupt + mask + contains + bits + to + + + + + + + + + Revision + 1.00 + Page + 80 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + generate + the + following + interrupts: + Receive + character, + Ready + to + send + next + character + and + Modem + line + + + change + character. + In + SYS$ASS, + all + three + interrupts + are + enabled + in + Start. + It + is + important + to + realise + + + that + after + masking + in + these + bits, + a + Ready + to + send + next + character + interrupt + is + almost + immediately + + + generated + so + the + corresponding + ComInt + code + must + be + able + to + handle + this. + + + + + + + + + CheckHardwarePresent + + + + + + + + + This + non-mandatory + function + is + called + from + the + Open + vector + and + follows + the + lines + of + previously + + + discussed + CheckHardwarePresent + code. + After + checking + for + an + ASICS + at + the + end + of + the + serial + link, + the + + + function + returns + with + the + carry + flag + clear + if + one + is + found. + If + a + non-zero + info + byte + is + returned + with + an + + + Asic5Normalld, + then + various + other + IDs + are + tried + (Asic4Id, + Asic8Id, + Asic5PackId) + before + returning + + + with + the + carry + flag + set. + + + + + + + + + CheckHardwarePresentFromStart + + + + + + + + + This + is + a + non-mandatory + function + called + only + from + the + PDD + Start + vector. + After + checking + that + we + have + + + an + ASICS + at + the + end + of + the + SIBO + channel, + the + function + sets + the + S_PERIPHERALMODE + bit + of + the + + + A5PortBMode + register. + This + then + puts + ASICS + into + UART + mode. + + + + + + + + + Comint + + + + + + + + + The + common + interrupt + routine + code + is + entered + with + DI + holding + the + address + of + the + appropriate + channel + + + struct. + ASICS's + control + register + (A5CtrlReg) + is + read + first + to + determine + which + interrupt + has + occurred. + + + The + byte + read + from + the + register + is + compared + against + S_ + MDINT + (Modem + lines + interrupt), + S_RXINT + + + (Receive + character + interrupt) + and + S_TXINT + (Transmit + interrupt). + The + code + to + handle + each + of + these + + + cases + is + then + entered + prior + to + returning + control + back + to + the + LDD + via + the + Channel + struct + fields + that + were + + + filled + by + a + previous + LDD + calls + to + the + PDD + strategy + Open + and + SetHandlersCS + vectors. + The + LDD + has + + + no + knowledge + of + interrupts + and + the + purpose + of + ComInt + is + therefore + to + hide + the + hardware + details + of + + + handling + interrupts + from + the + LDD. + Once + the + interrupt + has + been + serviced, + a + write + is + made + to + + + A9BNonSpecificEoiW + in + the + case + of + ASIC9 + or + AlNonSpecificEoi + for + an + ASIC1/ASIC2 + based + system + + + to + indicate + to + the + OS + that + the + interrupt + has + been + serviced. + + + + + + + + + Revision + 1.00 + Page + 81 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + 13. + DEBUGGING + AND + TESTING + DEVICE + DRIVERS + + + + + + + + + Introduction + + + + + + + + + This + chapter + will + detail + the + techniques + that + can + be + used + by + the + developer + to + first + debug + and + then + test + + + device + drivers. + The + emphasis + will + be + on + the + software + methods + such + as: + + + + Good + use + of + variables. + e.g. + Starting + all + the + fields + in + the + CS + Channel + Status + structure + with + + + CS. + + + e + Debugging + by + eye. + Even + more + important + with + regard + to + device + drivers. + + + e + Using + SDBG. + The + pitfalls + and + benefits. + Working + your + way + around + the + strategy + vector + calls + + + with + SDBG. + + + e + Construction + of + C + test + harness + programs. + Catching + all + the + error + flags + that + can + be + returned + by + + + device + driver + functions. + + + e + The + comprehensive + memory + check + program + mem.c. + + + + + + + + + Debugging + Techniques + + + + + + + + + A + Psion + device + driver + is + written + in + 8086 + assembler + as + an + asm + file + and + built + using + the + Borland + Turbo + + + Assembler + compiler. + The + subsequent + debugging + process + centres + around + the + construction + of + an + + + appropriate + PLIB + test + harness. + The + purpose + of + a + test + harness + is + to + check + a + number + of + the + device + driver + + + vectors + to + ensure + that + they + do + not + return + errors + or + cause + panics. + The + majority + of + PLIB + calls + that + would + + + be + used + in + this + context + return + a + negative + integer + that + is + used + to + ascertain + the + cause + of + the + problem + in + + + the + corresponding + device + driver + vector. + The + code + below, + for + instance, + would + be + used + to + test + the + install, + + + open, + strategy + close + and + remove + vectors + of + the + A4EXIF + LDD: + + + + + + + + + GLDEF_C + VOID + main(VOID) + + + { + + + + + VOID + *serH; + + + + + INT + ret; + + + + + + + + + if + ((ret=p_loadldd("A4EXIF.LDD") + ) + <0) + + + { + + + p_printf + ("Error + %d + on + p_loadldd", + ret); + + + p_getch + () + + + p_exit + (0) + + + } + + + + + + + + + else + + + p_printf + ("Successfully + loaded + A4EXIF.LDD"); + + + + + if + ((ret=p_open(&serH, + "LED:",-1) + ) + <0) + + + { + + + p_printf + ("Error + %d + on + p_open", + ret); + + + p_getch(); + + + + + + + + + x + + + + + + + + + else + + + + + + + + + p_printf + ("Successfully + opened + LED: + channel"); + + + p_close(serH) + ; + + + p_printf + ("Successfully + closed + LED: + channel"); + + + } + + + + + p_devdel + ("LED",E_LDD) + ; + + + + + p_getch(); + + + + + p_exit + (0); + + + + + } + + + + + + + + + Revision + 1.00 + Page + 82 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + If + as + often + happens + at + this + stage, + a + bug + in + the + device + driver + causes + the + test + harness + program + to + crash, + it + + + is + necessary + to + debug + the + driver + code + either + by + eye + or + using + SDBG. + Debugging + by + eye + should + always + + + be + the + first + resort, + however, + whenever + the + bug + can + be + readily + pinned + down + to + a + particular + vector. + + + Things + to + look + out + for + include: + + + + + + + + + e + ~=An + unbalanced + stack: + Check + that + the + number + of + 'pushes' + equals + the + number + of + 'pops' + in + the + + + appropriate + vector + code. + + + + + e + Addressing + the + wrong + location: + Ensure + that + all + the + Channel + status + fields + (stored + in + CS) + are + + + offset + using + the + correct + register + and + that + that + register + holds + the + right + value. + The + following + + + code + for + instance + requires + DI + to + hold + the + address + of + the + channel + status + struct + prior + to + + + + + + + + + invocation: + + + mov + al, + cs: + [di].ChannelOpenFlag + + + + + + + + + e + Consistency: + With + regard + to + the + last + point, + it + is + important + to + be + consistent + if + possible + and + try + + + and + use + the + same + register + (i.e. + DI) + to + hold + the + channel + status + structure. + A + different + one + + + (usually + BX) + should + also + be + used + to + hold + the + address + of + the + open + channel + control + block. + + + + + e + Trashing + BX + and + DI: + If + these + registers + are + used + in + the + vector + code + for + anything + other + than + + + addressing, + check + that + their + value + is + not + being + trashed + by + the + operation. + + + + + + + + + Debugging + using + SDBG + is + an + extension + of + debugging + by + eye. + The + SIBO + debugger + allows + the + + + programmer + to + trace + through + the + driver's + source + code + instruction + by + instruction + and + observe + the + + + contents + of + the + CPU + registers + in + the + process. + In + this + way + it + is + possible + to + discover + any + discrepancies + in + + + terms + of + the + values + stored + in + the + various + registers. + Furthermore, + tracing + with + SDBG + will + enable + the + + + user + to + pinpoint + the + source + of + panics. + The + first + objective + of + the + device + driver + debugging + process + + + should + be + to + get + the + code + outlined + on + the + previous + page + to + work + OK. + + + + + + + + + Further + Testing + Strategies + + + + + + + + + Once + installing, + opening, + closing + and + unloading + are + dealt + with, + a + test + harness + can + be + expanded + to + + + include + p_iow + or + p_ioc + calls + which + map + onto + the + LDD's + strategy + vector. + At + this + stage, + SDBG + is + + + particularly + useful + for + testing + purposes + as + breakpoints + can + be + set + and + jumped + to. + In + this + way + for + any + + + p_ioc(serH, + <func>, + &serStat, + &Al,&A2) + call, + the + contents + of + the + status + word, + serStat, + and + the + A1 + + + and + a2 + parameters + can + be + tracked + through + the + LDD's + strategy + vector. + The + value + held + by + the + status + + + word + at + the + end + of + a + particular + strategy + call + is + the + value + returned + by + the + corresponding + PLIB + + + p_iow/p_ioc + call. + Thus + negative + errors + within + the + strategy + code + can + be + picked + up + by + the + test + harness. + + + A + good + test + harness + should + be + able + to + catch + all + the + possible + errors + and + at + the + least + invoke + p_printf + to + + + let + the + user + know + when + one + of + them + is + returned. + The + file + p_file.h + contains + a + list + of + all + the + current + + + return + error + values + and + the + corresponding + PLIB + level + error + name. + The + entry + for + PendingErr, + for + + + instance + is + as + follows: + + + + + + + + + #define + PendingErr + (-46) + + + #define + E_FILE_PENDING + PendingErr + + + + + + + + + In + order + to + induce + the + return + of + these + error + values + it + is + necessary + to + extend + the + basic + test + harness + + + outline + to + allow + the + user + to + undertake + various + pathological + actions. + For + instance, + the + harness + may + + + include + code + that + tries + to + open + a + channel + twice + which + should + result + in + InUseErr + being + invoked. + By + + + such + means + it + is + possible + to + ensure + that + a + driver + is + not + only + operating + as + it + should + in + normal + + + circumstances + but + returning + the + correct + error + value + when + relevant. + + + + + + + + + Memory + Testing + + + + + + + + + The + final + process + that + should + be + undertaken + to + fully + test + a + device + driver + consists + of + the + construction + of + + + an + appropriate + memory + test + harness. + Three + functions + are + presented + on + the + next + two + pages + which + + + provide + the + core + of + such + a + comprehensive + memory + test + program. + The + first + function, + CheckMemory, + + + uses + the + PLIB + routines + p_allspce + and + p_sgfree + to + print + out + the + current + free + bytes + on + the + heap + and + the + + + number + of + free + segments + in + the + host + RAM. + This + function + can + be + invoked + after + installing, + opening, + + + closing + or + removing + a + device + driver + to + ensure + that + memory + is + not + going + to + ‘alloc + heaven’. + The + + + GobbleMemory + function + is + first + used + to + determine + the + amount + of + free + memory + available + in + segments + + + + + + + + + Revision + 1.00 + Page + 83 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + through + calling + p_sgfree. + The + PLIB + p_sgcreate + function + is + then + invoked + to + create + a + new + segment, + + + "Test", + that + consists + of + all + of + this + free + memory. + Finally, + the + p_sgcopyto + PLIB + function + is + called + to + fill + + + "Test" + with + Ox55's. + By + using + up + all + free + memory + in + this + way, + it + is + possible + to + use + segment + "Test" + to + + + determine + whether + a + particular + driver + vector + is + writing + to + the + wrong + location. + TestGobble, + presented + + + overleaf, + is + the + third + function + outlined. + It + uses + the + PLIB + function + p_sgcopyfr + to + check + the + values + of + + + the + bytes + in + the + segment + "Test". + If + any + of + the + 0x55's + have + been + overwritten + then + we + know + that + we + + + have + a + problem. + These + three + functions + should + be + incorporated + within + the + standard + test + harness + + + functions + already + presented + in + this + chapter. + In + this + way, + it + is + possible + to + generate + a + powerful + generic + + + test + program + that + can + be + used + as + the + basis + for + all + device + driver + testing. + + + + + + + + + LOCAL_C + VOID + CheckMemory + (VOID) + + + { + + + + + VOID + *Heap; + + + + + INT + fbytes; + + + + + + + + + fbytes=p_allspc + (&Heap) + ; + + + + + p_printf + ("Free + Heap + Memory + =>%x + bytes", + fbytes) + ; + + + p_printf + ("Free + Segments + =>%d",p_sgfree()); + + + p_getch(); + + + + + } + + + + + + + + + [KR + KR + KK + KR + KK + KI + KK + IK + I + I + I + I + / + + + + + + + + + LOCAL_C + VOID + GobbleMemory + (VOID) + + + { + + + UINT + nParas, + segSize; + + + INT + 3; + + + + + LONG + pos,i; + + + + + UBYTE + buf + [256]; + + + + + + + + + p_printf(" + System + RAM + size + = + %d",p_getram()); + + + p_printf + ("Internal + RAM + usage + = + %d",p_sgramdisk())j; + + + nParas=p_sgfree()j; + + + p_printf + ("Amount + of + free + RAM + = + %d",nParas); + + + segH=p_sgcreate("Test",nParas, + E_SEGMENT_HIGH) + ; + + + if + (segH) + + + + + p_printf + ("Created + segment + \"test\""); + + + + + + + + + else + + + { + + + p_printf + ("Error + in + creating + segment"); + + + p_getch(); + + + p_exit + (0); + + + } + + + segSize=p_sgsize(segH) + ; + + + p_printf("Size + of + segment + is + %d",segSize); + + + p_printf("In + 16-byte + paragraphs"); + + + p_sleep(5L); + + + for + (j=0; + j<16; + j++) + + + buf + [j]=0x55; + + + + + + + + + i=0; + + + while + (i<segSize) + + + { + + + pos=i*16; + + + if + (p_sgcopyto(segH, + pos, + &buf + [0],16) + <0) + + + { + + + p_printf + ("Failed + on + p_sgcopy"); + + + p_printf + ("%d",i); + + + p_getch(); + + + } + + + i++; + + + } + + + p_printf("Test + segment + full + of + 0x55s"); + + + p_getch(); + + + } + + + + + + + + + [RRR + KK + KK + KK + KKK + IK + I + I + I + I + / + + + + + + + + + Revision + 1.00 + Page + 84 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + LOCAL_C + VOID + TestGobble + (VOID) + + + + + + + + + UINT + segCount; + + + buf + [16]; + + + + + + + + + segCount=0; + + + p_printf + ("Checking + segment + integrity + ..."); + + + for + (segCount=0; + segCount<p_sgsize(segH); + segCount+t+) + + + { + + + if + (p_sgcopyfr(segH, + segCount*16, + &buf + [0] + ,16) + <0) + + + p_printf + ("Error + in + segment"); + + + + + + + + + else + + + { + + + for + (i=0;i<16;i++) + + + if + (buf[i] + !=0x55) + + + { + + + p_printf + ("OVERWRITE + ERROR!"); + + + p_printf + ("Segment + count=%d",segCount) + ; + + + p_printf + ("Byte + count=%d",i); + + + } + + + } + + + } + + + p_printf + ("Test + segment + OK"); + + + p_printf + ("Heap + integrity + checks + OK"); + + + p_allchk + (44); + + + p_printf("If + get + here, + heap + OK"); + + + p_getch(); + + + + + + + + + } + + + + + + + + + [KR + KR + KK + KR + KK + KKK + I + I + I + I + I + / + + + + + + + + + Revision + 1.00 + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Page + 85 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + APPENDIX: + SOURCE + CODE + FILES + + + + + + + + + A4EXIF.ASM + + + + + + + + + title + A4EXIF + -- + Example + ASIC4 + Interface + device + driver + + + subttl + Copyright + (c) + Psion + PLC + (1994) + + + name + A4EXIF + + + ; + + + ; + VER + DATE + BY + DESCRIPTION + + + jo + -o-------------------------------------- + + + 7 + 1.00F + 26/1/95 + Mal + Working + Version + + + BUILDSB=1 + 7S3a + build + environment + (channels=1) + + + S3c=0 + ;Need + to + specify + no + s3c + + + ; + BUILDSC=1 + 7S3c + build + environment + (channels=3) + + + ; + BUILDCH=1 + ;HC + build + environment + (channels=3) + + + ; + BUILDHH=1 + 753 + build + environment + (channels=1) + + + include + ..\inc\epoc.inc + + + include + ..\inc\epoclib.inc + + + include + ..\inc\epocsibo.inc + + + + + + + + + include + ossibo.inc + + + include + ospack.inc + + + + + + + + + Example + Logical + Device + Driver + for + prototype + LED-ASIC4 + Interface + + + circuit + for + Corporate/S3C/Consumer + serial + port. + + + Written + by + Mal + Dec + 1994/Jan + 1995. + + + + + + + + + Me + oNe + Ne + + + + + + + + + A4EXIF + CONSTANTS + AND + TYPES + + + + + + + + + The + following + constants + and + type + definitions + + + are + compiler + directives + used + by + the + TCEP + assembler + + + when + it + is + creating + the + LDD. + + + + + + + + + Ne + Ne + Ne + Ne + Ne + + + + + + + + + if + Consumer + + + + + + + + + numberofchannels + equ + 1 + + + else + + + if + Corporate + or + S3c + + + numberofchannels + equ + 3 + + + else + + + numberofchannels + equ + 2 + + + endif + + + endif + + + + + + + + + 7;Channel + StatusEnt + block + accessed + through + CS:DI + + + A4ExifStatusEnt + struc + + + + + + + + + A4ExifCSProcessId + dw + <i + ;Channel + parent + process + id + + + A4ExifCSChannelOpen + db + 2 + ;Channel + open + flag + + + A4ExifCSChannelRunning + db + ? + ;Channel + hardware + running + + + flag + + + A4ExifCSChanReadCompleted + db + 2 + ;Channel + request + completed + + + flag + + + A4ExifCSChannelIntMask + db + 2 + ;Channel + interrupt + mask + + + A4ExifCSChanneliIntNum + db + ? + ;Channel + interrupt + number + + + A4ExifCSChannelSelect + db + 2 + ;SIBO + Channel + select + + + A4ExifCSChanneliIntVec + dw + ? + ;Channel + int + vector + number + + + A4ExifCSTickHandle + dw + ee + ;TCK + channel + handle + + + A4ExifCSA1Value + db + i + ;Channel + strategy + Al + parameter + + + A4ExifCSA2Value + db + ? + ;Channel + strategy + A2 + parameter + + + + + + + + + A4ExifStatusEnt + ends + + + + + + + + + ;Open + Channel + Control + block + accessed + through + DS:BX + + + A4ExifEnt + struc + + + + + + + + + A4ExifDSIo + ChanEnt + <> + 7;Open + channel + control + block + Ent + + + A4ExifDSHandlerPtr + dw + 2 + ;Cant + touch + when + under + + + A4ExifDSStatusPtr + dw + ? + ;Hold, + Resume, + Reset + or + + + A4ExifDSA1Ptr + dw + ? + ;interrupt + routine + + + A4ExifDSA2Ptr + dw + es + + + A4ExifDSStatusEntPtr + dw + ? + + + + + A4ExifEnt + ends + + + A4PERIPH + MASK + equ + Of0h + 711110000b + + + + + + + + + Revision + 1.00 + Page + 86 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + EXTENDED_INFO_BYTE + equ + 090h + + + U5_ENABLE_ON + equ + 080h + + + U5_ENABLE_OFF + equ + 000h + + + ;Latch + addresses + for + reading/writing + + + USOUTPUT_LATCH + equ + 00000000b + + + U3INPUT_BUFFER + equ + 00000000b + + + U4STATUS_BUFFER + equ + 00000001b + + + cs: + [di] + .A4ExifCsAlValuefor + + + INTERRUPT_LATCH + equ + 00000001b + + + ;Status + byte + masks + + + S2S3_ON + equ + 00000011b + + + S2S3_OFF + equ + 00000000b + + + S2_ONLY + equ + 00000001b + + + S3_ONLY + equ + 00000010b + + + INTERRUPT_STATUS_MASK + equ + 00000011b + + + 7; + LED + bytes + + + SOME_LEDS_ON + equ + 01010101b + + + SOME_LEDS_OFF + equ + 10101010b + + + TOP_LEDS_ON + equ + 11110000b + + + BOTTOM_LEDS_ON + equ + 00001111b + + + ZERO_BYTE + equ + 00h + + + dgroup + group + stack + + + assume + ds:dgroup,es:dgroup,ss:dgroup + + + CodeSeg + + + 7 + A4EXIF + ENTRY + TABLE + + + ; + Seseseo + eee + ee + sececs + + + ProcBegin@ + A4ExifLDD + + + ; + ssieceees + + + dw + LDDSignature + + + db + 'LED',0,0,0,0,0 + + + dw + (VectorEnd-Vector) + /2 + + + Vector: + + + dw + A4ExifInstall + + + dw + A4ExifRemove + + + dw + A4ExifHold + + + dw + A4ExifResume + + + dw + A4ExifReset + + + dw + A4ExifUnits + + + dw + A4ExifOpen + + + dw + A4ExifStrategy + + + VectorHandler: + + + dw + A4ExifHandler + + + if + Asic9 + + + InterruptVectors: + + + dw + A4ExifTickInt + + + endif + + + VectorEnd: + + + H + A4EXIF + INTERNAL + DATA + SPACE + + + , + + + ; + Device + Driver + global + variables + follow. + + + ; + These + variables + reside + in + the + code + segment + + + ; + and + as + such + can + always + be + accessed + with + + + 7 + the + 'cs:' + prefix. + + + + + + + + + if + Asic9 + + + if + Consumer + + + + + + + + + Channel0O + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + 710010000b + + + 7;Sets + LBO + for + latch + U5 + + + ;Deselects + LBO + for + U5 + + + + + + + + + ;Selects + + + ;Selects + + + ;Selects + + + + + + + + + ;Selects + + + + + + + + + A9MSlave, + HwIrq2Revector, + SelectChannel5, + IntVec0O,0,0> + + + + + + + + + else + + + if + Corporate + or + S3c + + + + + + + + + Channel0 + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + AOMExpIntA, + HwIrq4Revector, + SelectChannel3, + IntVec0O,0,0> + + + + + + + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + AQMExpIntB, + HwIrq5Revector, + SelectChannel4, + IntVec1,0,0> + + + + + + + + + Channel2 + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + A9MSlave, + HwIrq2Revector, + SelectChannel5, + IntVec2,0,0> + + + + + + + + + Revision + 1.00 + + + + + + + + + AO + for + writing + + + AO + for + reading + + + + + + + + + ; + reading + + + Al + for + writing + + + + + + + + + Page + 87 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + else + + + Channel0 + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + AOMExpIntA, + HwIrq4Revector, + SelectChannel3, + IntVec0O,0,0> + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + AQ9MExpIntB, + HwIrq5Revector, + SelectChannel4, + IntVec1,0,0> + + + endif + + + endif + + + else + + + if + Consumer + + + Channel0O + A4ExifStatusEnt<0,0,0,0,mask + + + + + + + + + Asic2Int, + HwIrq4Revector, + SelectChannel7, + IntVec0,0,0> + + + + + + + + + else + + + if + Corporate + + + ChannelO + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntLeftA, + HwIrq3Revector, + ExpChannelLeftA, + IntVec0O,0,0> + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntRightB, + HwIrq2Revector, + ExpChannelRightB, + IntVecl1,0,0> + + + Channel2 + A4ExifStatusEnt<0,0,0,0,mask + + + Asic2Int, + HwIrq4Revector, + SelectChannel7, + IntVec2,0,0> + + + else + + + ChannelO + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntLeftA, + HwIrq3Revector, + ExpChannelLeftA, + IntVec0O,0,0> + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntRightB, + HwIrq2Revector, + ExpChannelRightB, + IntVecl1,0,0> + + + endif + + + endif + + + endif + + + HoldFlag + db + 0 + ;Hold/Resume + flag + + + SwitchStatus + db + ? + ;Holds + the + masked + status + byte + from + U4 + after + + + interrupt + + + ProcEnd + noret + + + ProcBegin@ + A4ExifInstall, + far + + + ; + eee + + + ; + Installs + the + device + driver. + + + 7 + Invoked + after + a + PLIB + 'p_loadldd("A4EXIF.LDD")' + call + to + load + the + LDD + + + ; + All + of + the + fields + inside + the + CS + control + blocks + are + preloaded + + + ; + with + the + correct + values + at + install + time. + Install + therefore + does + + + ; + not + do + any + work. + + + 7 + IN: + + + ; + Nothing + + + 7 + OUT: + + + ; + Carry + Clear + - + driver + successfully + installed + + + 7 + + + cle + ;The + ChannelOpen + fields + are + set + to + zero + + + ret + ;in + the + relevant + ChannelStatusEnt + headers + + + ProcEnd + noret + + + ProcBegin@ + A4ExifRemove, + far + + + ; + eSeseces + eee + + + ; + Removes + the + device + driver. + + + ; + Invoked + after + a + PLIB + 'p_devdel("LED",E_LDD) + 'call + to + unload + the + + + H + device + driver. + + + ; + A + device + driver + cannot + be + removed + if + any + of + its + channels + + + i + are + still + open. + + + H + IN: + + + ; + Nothing + + + H + OUT: + + + ; + Carry + clear + - + successfully + removed + + + 7 + Carry + set + - + remove + failed, + error + number + in + AL + + + 7 + + + mov + cx, + numberofchannels + ;Check + that + each + + + mov + di, + offset + Channel0O + ;channel + is + closed + + + xor + ax, + ax + + + CheckAl1lChannelsClosedLoop: + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + al + ;Closed + channels + will + + + jne + WeHaveAChannelOpenSoFail + ;have + the + value + 0 + in + + + add + di, + (size + A4ExifStatusEnt) + ;their + ChannelOpen + + + + + + + + + Revision + 1.00 + Page + 88 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + loop + CheckAl1ChannelsClosedLoop + ;flags + + + jmp + FinishedOkay + + + WeHaveAChannelOpenSoFail: + + + mov + al, + InUseErr + ;Fail + if + not + all + + + stc + ;closed + + + ret + + + FinishedOkay: + + + cle + + + ret + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifHold, + far + + + + + + + + + v + + + + + ; + Called + by + the + operating + system + whenever + the + device + driver + is + + + + + ; + being + moved + or + the + machine + is + powering + down. + + + + + ; + This + will + also + be + called + by + our + pack + door + polling + function + when + + + + + ; + it + sees + that + the + doors + have + been + opened + and + our + peripheral + has + + + + + ; + lost + power. + + + + + ; + IN: + + + + + 7 + Reason + for + the + hold + in + AH + + + + + 7 + OUT: + + + + + 7 + Nothing + + + + + 13 + + + mov + cx, + 1 + ;Hold + can + be + called + + + xchg + cl, + HoldFlag + ;when + the + driver + is + + + cmp + cl, + 0 + ;under + a + hold + so + + + jne + AlreadyHeld + ;re-entrancy + blocking + + + + + A4HoldFromTick: + ;is + required + + + mov + cx, + numberofchannels + + + mov + di, + offset + Channel0 + ; + Loop + because + Hold + + + + + + + + + HoldAllTheChannelsLoop: + + + + + + + + + ;must + stop + all + the + + + + + + + + + cmp + cs: + [di] + .-A4ExifCSChannelOpen, + ; + channels + + + je + DontHoldBecauseNotOpen + ;Is + the + channel + open? + + + push + cx + ;If + it + is + then + stop + + + call + StopTheChannelRunning + yall + interrupts + + + pop + cx + + + DontHoldBecauseNotOpen: + + + add + di, + (size + A4ExifStatusEnt) + + + loop + HoldAl1lTheChannelsLoop + + + AlreadyHeld: + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifResume, + far + + + + + + + + + 3 + Called + by + the + operating + system + when + it + has + finished + moving + the + + + - + device + driver + in + memory + or + when + the + machine + is + switching + back + on. + + + ; + Also + called + by + our + door + polling + routine + when + it + sees + that + the + doors + + + ; + have + been + closed + and + we + can + resume + communication + with + our + peripheral. + + + ; + IN: + + + iH + Nothing + + + ; + OUT: + + + 7 + Nothing + + + is + + + xor + CX, + cx + ;Block + in + case + of + re-entrancy + + + xchg + cl, + HoldFlag + + + cmp + cl, + 0 + + + je + AlreadyResumed + + + if + Asic9 + + + GenDataSegment + ;Check + to + see + if + the + pack + + + HwGetSsdData + ;doors + are + still + closed + + + mov + bx, + ax + + + cmp + es: + [bx] + .SsdDoorStatus, + DoorOpen + + + je + DoorsAreOpen + + + endif + + + A4ResumeFromTick: + + + mov + cx, + numberofchannels + ; + Loop + because + resume + must + + + mov + di, + offset + Channel0 + ;restart + each + open + channel + + + ResumeAllTheChannelsLoop: + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + 0 + ;Is + the + channel + open? + + + je + DontResumeBecauseNotOpen + + + push + Cx + + + call + StartTheChannelRunning + + + pop + cx + + + DontResumeBecauseNotOpen: + + + add + di, + (size + A4ExifStatusEnt) + + + loop + ResumeAl1lTheChannelsLoop + + + AlreadyResumed: + + + + + + + + + Revision + 1.00 + Page + 89 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + ret + + + + + + + + + DoorsAreOpen: + + + + + + + + + mov + HoldFlag, + 2 + + + ret + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifReset, + far + + + + + + + + + Called + when + an + application + which + opened + a + channel + terminates + without + + + closing + the + device + driver. + + + A + device + driver, + for + each + open + channel, + has + to + request + that + the + + + operating + system + calls + this + function + when + the + application + + + terminates + abnormally + (ie + without + closing + an + open + channel). + + + Reset + can + supply + one + piece + of + identifying + data + which + will + be + + + passed + in + CX. + This + would + usually + be + the + channel's + number + or + CS + + + control + block + pointer. + + + Reset + just + needs + to + clear + interrupts, + hardware + reservations, + and + free + + + the + channel. + Any + allocated + space + will + be + cleaned + up + for + you + by + the + OS. + + + IN: + + + + + The + device + driver's + handle + in + BX + + + + + The + address + of + the + status + struc + identifying + the + channel + in + CX + + + + + + + + + 7 + OUT: + + + ; + Nothing + + + , + + + mov + di, + cx + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + je + NotOpenToReset + + + call + StopTheChannelRunning + 7Stop + interrupts + + + mov + al, + cs: + [di] + .A4ExifCSChannelIntMask + ;Free + the + reserved + + + HwF + reeChannel + ;hardware + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 0 + ;The + channel + is + now + + + NotOpenToReset: + ;free + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifUnits, + far + + + + + + + + + Called + to + find + how + many + open + channels + the + driver + will + support + + + + + + + + + - + In: + + + ; + Nothing + + + - + Out: + + + H + The + total + number + of + channels + supported + in + AX + + + , + + + mov + ax, + numberofchannels + + + ret + + + + + + + + + ~ + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifOpen, + far + + + + + + + + + Opens + a + device + driver + channel. + + + Invoked + after + the + PLIB + call + 'p_open(é&appHandle, + "LED:*",-1)'to + open + a + + + channel + to + the + device + driver. + + + + + + + + + , + + + + + , + + + + + 7 + + + + + H + Tn: + + + + + ; + OS + device + handle + of + the + device + driver + in + DX + + + + + ; + Pointer + to + the + OpenEnt + struc + in + SI + + + + + ; + Pointer + to + the + IntEnt + struc + in + BP + + + + + ; + DS,ES,SS + point + to + the + applications + data + space + + + + + i + Out: + + + + + ; + Carry + clear + - + BX + holds + the + address + of + the + open + channel + + + + + 7 + Carry + set + - + AL + holds + the + error + number + + + + + is + + + cld + ;Interrupts + off + to + + + pushf + ;prevent + multiple + apps + + + oli + ;calling + open + + + mov + si, + [si] + .OpenNamePtr + ; + Simultaneously + + + mov + al, + [sitl] + + + CharToFoldedChar + ;Read + the + unit + no. + + + cmp + al, + 'A' + ;part + of + device + name + + + jb + OpenNameErr + ;to + find + which + channel + + + sub + al, + 'A' + ;to + open. + eg + "LED:A" + + + cmp + al, + numberofchannels + + + jae + OpenNameErr + + + xor + ah, + ah + + + push + ax + ;Map + the + channel + no. + + + mov + dx, + (size + A4ExifStatusEnt) + ;to + a + channel + control + + + mul + dx + ;block + in + our + CS + + + pop + ax + 7; + space + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 90 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + mov + di, + ax + + + add + di, + offset + Channel0O + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + je + GetATickChannel + + + popft + + + mov + ax, + AlreadyOpenErr + + + jmp + ChannelAlreadyOpen + + + GetATickChannel: + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 1 + + + mov + cs: + [di] + .-A4ExifCSChannelRunning, + 0 + + + popft + + + ife + Asic9 + + + jmp + GetHardwareChannel + + + else + + + push + ax + + + mov + ax, + ((':' + shl + 8)+'K') + + + push + ax + + + mov + ax, + (('C' + shl + 8)+'T') + + + push + ax + + + mov + bx, + sp + + + ToOpen + + + jne + GotATickChannel + + + add + sp, + 6 + + + mov + ax, + LockedErr + + + jmp + OpenFailed + + + GotATickChannel: + + + add + sp, + 6 + + + mov + cs: + [di] + .A4ExifCSTickHandle, + ax + + + push + ax + + + mov + bx, + ax + + + mov + ax, + IoFuncStart + + + mov + ex, + 1 + + + push + cx + + + push + cx + + + push + ax + + + mov + cx, + (InterruptVectors-Vector) + /2 + + + push + cx + + + mov + cx, + sp + + + ToWithWait + + + add + sp, + 8 + + + pop + dx + + + jmp + GetHardwareChannel + + + endif + + + OpenNameErr: + + + popft + + + mov + ax, + NameErr + + + jmp + ChannelAlreadyOpen + + + GetHardwareChannel: + + + mov + al, + cs: + [di] + .A4ExifCSChannelIntMask + + + HwGetChannel + + + jne + CheckHardwareNowThatSIBOChannellIsOpen + + + mov + ax, + InUseErr + + + jmp + FreeTckAndExit + + + FreeTckAndChannelHardware: + + + mov + al, + cs: + [di] + .A4ExifCSChannelIntMask + + + HwF + reeChannel + + + mov + ax, + DeviceErr + + + FreeTckAndExit: + + + if + Asic9 + + + push + ax + + + mov + bx, + cs: + [di] + .A4ExifCSTickHandle + + + IoClose + + + pop + ax + + + endif + + + OpenFailed: + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + ChannelAlreadyOpen: + + + stc + + + OpenExit: + + + ret + + + CheckHardwareNowThatSIBOChannellIsOpen: + + + Proclid + + + mov + cs: + [di].A4ExifCSProcessId, + ax + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + + + call + CheckHardwarePresent + + + jc + FreeTckAndChannelHardware + + + mov + cx, + (size + A4ExifEnt) + + + HeapAllocateCell + + + jc + FreeTckAndChannelHardware + + + mov + bx, + ax + + + + + + + + + Revision + 1.00 + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + ;Offset + in + DI + + + + + + + + + ;Check + to + see + if + + + ;channel + is + already + + + ;open + + + + + + + + + ,Obtain + a + TCK + channel + so + + + ;we + can + poll + the + door + state + + + + + + + + + 7;If + HC, + we + don't + need + + + ;to + set + up + the + TCK + + + ; + routine + + + + + + + + + ;Try + to + open + "TCK:" + + + ;channel + with + "TCK:" + + + ; + string + on + stack + + + + + + + + + ;TCK + will + call + our + + + ,door-polling + function + + + 732 + times + a + second + + + + + + + + + 7Start + our + + + ,door-polling + function + + + ;running + by + starting + + + ;the + "TCK:" + channel + + + + + + + + + 7Frequency + 1 + tick + + + ;Data + irrelevant + + + ;Handle + to + driver + + + ;TCK + function + to + call + + + + + + + + + 7;Check + the + hardware + + + ;is + available + then + + + ;reserve + it + + + ;Returns + with + carry + + + ;clear + if + OK + + + + + + + + + 7Set + up + the + calling + + + ;process + ID + + + + + + + + + ;Returns + with + carry + + + ;clear + if + successful + + + ;Allocate + a + control + + + ;block + in + our + app's + + + ;data + space + + + + + + + + + Page + 91 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + push + bx + ;IloAddHandler + trashes + BX + + + mov + al, + (VectorHandler-Vector) + /2 + ;Set + up + our + wait + handler + + + ToAddHandler + ;Leaves + the + address + of + + + pop + bx + ;handler + in + AX + + + jne + GotHandler + + + push + ax + ;If + no + handler, + open + fails + + + HeapFreeCell + + + pop + ax + + + jmp + FreeTckAndChannelHardware + + + GotHandler: + + + mov + [bx] + .A4ExifDSStatusEntPtr, + di + + + mov + [bx] + .A4ExifDSHandlerPtr, + ax + + + mov + [bx] + .A4ExifDSStatusPtr, + 0 + + + mov + [bx] + .A4ExifDSIo.ChanNext, + bx + + + mov + [bx] + .A4ExifDSIo.ChanSignature, + IoChanSignature + + + mov + [bx] + .A4ExifDSIo.ChanLibHandle, + dx + + + mov + cx, + al + ; + loRequestReset + takes + + + xchg + bx, + dx + ;the + device + handle + in + + + IoRequestReset + 7BX + and + the + channel + + + xchg + bx, + dx + ;handle + in + CX + + + xor + ax, + ax + + + call + StartTheChannelRunning + + + ReturnCLc: + + + cle + + + ret + + + ProcEnd + + + if + Asic9 + + + + + + + + + ProcBegin@ + A4ExifTickInt, + far + + + + + + + + + This + function + is + called + by + the + tick + handler + on + every + tick + of + + + + + ; + the + system + clock. + This + happens + 32 + times + a + second. + + + + + ; + The + operating + system + will + call + a + device + driver + to + hold + when + memory + is + + + ; + being + moved + and + when + the + machine + is + being + powered + down. + It + will + not + + + + + ; + call + the + device + driver + when + the + pack + doors + are + opened. + + + + + Opening + the + pack + doors + will + cause + power + to + the + peripheral + to + be + cut, + + + + + + + + + ; + + + ; + and + therefore + the + driver + needs + to + be + held + in + the + way + it + would + be + if + + + ; + the + machine + powered + down. + Only + for + Asic9 + based + machines. + + + ; + This + function + checks + the + state + of + the + doors + on + every + tick + and + calls + + + iH + Hold + and + resume + when + it + sees + the + status + of + the + doors + change. + + + H + IN: + + + ; + The + state + of + the + door + in + SI + + + ; + OUT: + + + ; + Nothing + + + ; + + + cmp + si, + DoorOpen + 7Is + the + door + open + + + je + TheDoorIsOpen + 7or + closed? + + + cmp + HoldFlag, + 2 + 7Closed + Door, + HoldFlag=2 + + + je + NeedToDoTheResume + ;means + we + do + a + resume + + + ret + 7Closed + Door, + HoldFlag!=2 + + + NeedToDoTheHold: + + + mov + HoldFlag, + 2 + + + jmp + A4HoldFromTick + + + NeedToDoTheResume: + + + mov + HoldFlag, + 0 + + + jmp + A4ResumeFromTick + + + TheDoorIsOpen: + + + xor + ax, + ax + + + cmp + HoldFlag, + al + + + je + NeedToDoTheHold + + + ret + + + ProcEnd + noret + + + endif + + + ProcBegin@ + A4ExifHandler, + far + + + ; + + + ; + When + an + application + is + waiting + within + an + iowait + and + a + signal + is + + + ; + generated + then + before + passing + that + signal + to + the + application + the + + + : + OS + first + runs + any + wait + handlers + belonging + to + the + device + driver + + + ; + channels + that + the + application + has + open. + + + ; + The + interrupt + routine + can + generate + a + signal + but + cannot + fill + in + any + + + ; + status + words + or + pass + values + back + to + the + application + because + the + + + ; + applications + DS + space + is + not + available. + The + handler + can + consume + a + + + ; + signal + generated + by + an + interrupt + and + then + fill + any + status + words + + + 7 + before + re-signalling + the + application. + A + handler + always + has + access + + + ; + to + the + application's + DS + space. + The + wait + handler + can + consume + the + + + 7 + signal + which + is + then + no + longer + passed + back + to + the + application. + + + Hi + IN: + + + + + + + + + Revision + 1.00 + Page + 92 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Pointer + to + our + control + block + in + applications + DS + space + in + BX + + + DS,ES,SS + point + at + application's + data + space + + + + + + + + + OUT: + + + Carry + clear + - + do + not + consume + the + signal, + signal + not + for + us + + + 7 + Carry + set + - + consume + the + signal, + re-enable + handler + if + AL + + + ; + non-zero + else + don't + re-enable + handler + if + AL=0. + + + 7 + + + cld + + + pushf + + + cli + + + mov + di, + [bx].A4ExifDSStatusEntPtr + ;Is + the + signal + for + us? + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 1 + + + jne + ExitHandlerSignalNotForuUs + ;If + it + is, + copy + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + ;the + values + read + in + + + mov + al, + cs: + [di] + .A4ExifCSA1Value + ;the + interrupt + + + mov + ah, + cs: + [di] + .A4ExifCSA2Value + ;routine + back + to + + + mov + di, + [bx].A4ExifDSA1Ptr + ;the + application + + + mov + [di], + al + ;Asynchronous + read + + + mov + di, + [bx].A4ExifDSA2Ptr + ;has + been + completed + + + mov + [di], + ah + + + xor + di, + di + + + xchg + [bx] + .A4ExifDSStatusPtr, + di + ;Clear + the + status + + + mov + word + ptr + [di], + 0 + ;word + + + popft + + + ToSignal + + + xor + ax, + ax + + + stc + ;STC + and + AL!=0 + => + + + ret + ;consume + signal + and + + + ExitHandlerSignalNotForus: + ;don't + re-enable + + + popft + ;handler + + + elec + + + ret + + + ProcEnd + + + StrategyVectorTable + label + word + + + dw + offset + A4ExifDefault + ;StrategyPanic + + + dw + offset + A4ExifRead + 7 + StrategyRead + ie + P_FREAD + + + dw + offset + A4ExifWrite + ;StrategyWrite + ie + P_FWRITE + + + dw + offset + A4ExifClose + ;StrategyClose + ie + P_FCLOSE + + + dw + offset + A4ExifCancel + 7 + StrategyCancel + ie + P_FCANCEL + + + dw + offset + A4ExifDefault + ;StrategyAttach + + + dw + offset + A4ExifDefault + ;StrategyDetach + + + dw + offset + A4ExifSet + ;StrategySet + ie + P_FSET + + + dw + offset + A4ExifSense + ;StrategySense + ie + P_FSENSE + + + ProcBegin@ + A4ExifStrategy, + far + + + Called + by + the + operating + system + when + an + I/O + request + is + made + on + + + + + + + + + the + device + driver. + + + + + Calls + to + this + funcion + from + an + owning + application + will + usually + take + + + the + form + p_ioc(pcb, + func, + &Stat, + &Al, + &A2) + ; + + + + + The + strategy + function + is + called + with + a + function + number + specifying + + + the + action + which + the + driver + is + to + take, + a + status + word + to + fill + when + + + the + action + is + complete, + and + two + arguments + Al + and + A2. + + + + + + + + + Nee + Ne + Ne + + + + + + + + + Se + ee + + + + + + + + + All + strategy + functions + must + complete + with + a + signal + to + the + application. + + + Functions + can + be + asynchronous + and + need + not + complete + immediately. + + + IN: + + + Pointer + to + our + control + block + in + the + applications + DS + in + BX + + + 7 + Device + driver + handle + in + DX + + + ; + Pointer + to + the + RqEnt + struct + in + SI + + + ; + Pointer + to + a + IntEnt + struct + in + BP + + + ; + DS,ES,SS + point + at + the + applications + data + space + + + i + OUT: + + + ; + Returned + value + in + AX + + + ; + Must + call + IoSignal + somewhere + to + signal + completion + + + ; + of + the + I/O + request. + + + v + + + mov + ax, + [si].RqFunction + ;Get + the + function + number + + + mov + dx, + [si].RqAlPtr + ;DX + holds + the + first + argument + + + mov + di, + [si].RqStatusPtr + ;for + convenience + + + mov + word + ptr + [di], + PendingErr + 7Status + word + holds + + + shl + ax, + 1 + ; + E_FILE_PENDING + + + mov + di, + ax + + + push + StrategyVectorTable[di] + ;Jump + to + required + function + + + mov + di, + [bx] + .A4ExifDSStatusEntPtr + ;with + our + CS + control + block + + + retn + ;pointer + in + DI + + + A4ExifDefault: + + + ToRoot + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 93 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + ret + + + ExitWithCompletionStatusZero: + + + + + xor + ax, + ax + ;Common + exit + points + + + ExitWithOtherCompletionStatus: + + + + + mov + di, + [si].RqStatusPtr + + + + + mov + word + ptr + [di], + ax + + + + + ToSignal + + + ExitStillPending: + + + + + xOr + ax, + ax + + + + + cle + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + STRATEGY + VECTOR + TABLE + FUNCTIONS + + + + + + + + + IN: + + + DX + holds + the + pointer + to + the + first + argument + in + 'p_iow(...)' + call + + + BX + holds + the + address + of + the + open + channel + control + block + + + CS:DI + holds + the + address + of + status + struc + identifying + the + open + channel + + + + + + + + + See + eee + Ty + + + + + + + + + ProcBegin@ + A4ExifRead, + far + + + + + + + + + H + Strategy + vector + table + function + that + handles + asynchronous + byte + reads + + + 7 + from + the + LEDs + and + switches. + + + + + i; + The + corresponding + PLIB + call + is + p_ioc(pcb,P_FREAD, + &Stat, + &Argl, + &Arg2) + ; + + + ; + The + request + is + completed + when + the + interrupt + routine + signals + the + + + + + ; + handler + which + in + turn + signals + the + application + passing + back + the + values + + + ; + read + at + the + time + of + the + interrupt + through + the + AlPtr + and + A2Ptr. + + + + + H + IN: + + + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + + + i + Pointer + to + control + block + in + our + CS + space + in + DI + + + + + ; + Al + (pointer + to + Argl) + in + DX + + + + + , + + + + + v + + + + + + + + + OUT: + + + Jumps + to + common + exit + point + + + . + Panics + if + multiple + requests + + + , + + + cmp + [bx] + .A4ExifDSStatusPtr, + 0 + ;Panic + if + we + already + + + jne + PanicPending + ;have + an + I/O + read + request + + + pushf + ;pending + on + the + channel + + + cli + ;Disable + interrupts + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 2 + + + mov + ax, + [si].RqA1Ptr + + + mov + [bx] + .A4ExifDSA1Ptr, + ax + ; + Store + the + locations + to + + + mov + ax, + [si].RqA2Ptr + ;put + the + data + when + we + get + it + + + mov + [bx] + .A4ExifDSA2Ptr, + ax + + + mov + di, + [si].RqStatusPtr + + + mov + [bx] + .A4ExifDSStatusPtr, + di + ;DI + holds + the + address + + + mov + word + ptr + [di], + PendingErr + 7of + status + word + and + we + + + popf + ;Signal + that + we + are + waiting + + + mov + bx, + [bx] + .A4ExifDSHandlerPtr + ;for + completion + of + read + + + mov + cl, + + + ToEnableHandler + ;Enable + Wait + Handler + + + jmp + short + ExitStillPending + 7No + IoSignal + because + + + PanicPending: + ;we + are + still + waiting + + + mov + al, + PaniclIoPending + + + ProcPanic + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifWrite, + far + + + + + + + + + This + function + sets + the + state + of + the + LEDs. + + + + + It + completes + immediately + after + setting + the + state + as + it + has + nothing + + + to + wait + for. + + + + + Write + is + the + same + as + set. + + + + + + + + + Ne + Ne + Ne + Ne + Ne + te + + + + + + + + + IN: + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + ; + Pointer + to + control + block + in + our + CS + space + in + DI + + + . + Al + in + DX + + + - + OUT: + + + - + Jumps + to + Set + + + , + + + jmp + WriteAndSetAreTheSame + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifClose, + far + + + + + + + + + Revision + 1.00 + Page + 94 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Handles + the + request + to + close + a + channel. + + + called + by + the + PLIB + call + p_iow(pcb,P_FCLOSE) + or + p_close + (pcb) + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + IN: + + + Pointer + to + control + block + in + applications + data + space + in + BX + + + ; + Pointer + to + control + block + in + our + CS + space + in + DI + + + ; + OUT: + + + ; + Jumps + to + common + exit + point + + + , + + + call + StopTheChannelRunning + 7Stop + interrupts + + + if + Asic9 + + + push + bx + ;Close + down + the + + + mov + bx, + cs: + [di] + .A4ExifCSTickHandle + 7;"TCK:" + channel + + + IoClose + + + pop + bx + + + endif + + + push + bx + + + mov + ax, + [bx] + .A4ExifDSIo.ChanLibHandle + ;Remove + the + wait + + + push + ax + ;handler + + + mov + bx, + [bx] + .A4ExifDSHandlerPtr + + + IoRemoveHandler + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + ;If + the + interrupt + + + je + NoSignalToConsumeFromInterrupt + ;has + signalled + the + + + ToWaitForSignal + ;handler + we + need + to + + + NoSignalToConsumeFromInterrupt: + ;consume + its + signal + + + pop + bx + ;now + the + handler + + + mov + cx, + di + ;has + been + removed + + + ToRequestResetCancel + + + pop + bx + 7No + longer + need + reset + + + HeapFreeCell + ;Free + our + control + + + mov + al, + cs: + [di] + .-A4ExifCSChannelIntMask + ;block + in + app's + DS + + + HwFreeChannel + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + jmp + ExitWithCompletionStatusZero + 7To + signal + completion + + + ProcEnd + noret + 7,of + close + request + + + ProcBegin@ + A4ExifCancel, + far + + + v + + + ; + Cancel + any + pending + asynchronous + read. + + + ; + Called + by + the + PLIB + function + p_iow(pcb,P_FCANCEL) + ; + + + i + In: + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + ; + Pointer + to + control + block + in + our + CS + space + in + DI + + + ; + Out: + + + ; + Jumps + to + common + exit + point + + + 7 + + + pushf + + + cli + + + cmp + [bx] + .A4ExifDSStatusPtr, + 0 + ;Check + that + there + is + + + je + NothingToCancel + ya + request + pending + + + push + bx + + + mov + bx, + [bx] + .A4ExifDSHandlerPtr + + + sub + cl + ol + + + ToEnableHandler + ;Disable + Wait + Handler + + + pop + bx + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 1 + + + jne + NoSignalFromInterrupt + ;TO + consume + any + stray + + + ToWaitForSignal + ;Signal + from + the + + + NoSignalFromInterrupt: + ;interrupt + routine + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + + + xor + fomcramre + be + ;To + signal + completion + + + xchg + di, + [bx].A4ExifDSStatusPtr + ;of + the + outstanding + + + mov + word + ptr + [di], + CancelErr + pasync + read + request + + + ToSignal + ;Signal + to + p_waitstat + + + NothingToCancel: + + + popft + + + jmp + ExitWithCompletionStatusZero + 7To + signal + completion + + + ProcEnd + noret + 7of + the + cancel + request + + + ProcBegin@ + A4ExifSet, + far + + + , + + + 7 + Write + a + value + to + the + LED + latch. + + + ; + Can + be + called + by + the + PLIB + call + p_iow(pcb,P_FSET, + &Argl); + where + Al + + + ; + is + an + unsigned + byte. + + + ; + Write + is + the + same + as + set. + + + 7 + IN: + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + 7 + Pointer + to + control + block + in + our + CS + space + in + DI + + + 7 + Al + (pointer + to + Argl) + in + DX + + + + + + + + + Revision + 1.00 + Page + 95 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + + + + + + + + + + + + + + + + + + + OUT: + + + Jumps + to + common + exit + point + + + + + + + + + , + + + WriteAndSetAreTheSame: + + + + + + + + + Steere + Ty + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + seo + + + + + + + + + pushf + + + + + cli + + + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + + + push + ax + + + + + mov + bx, + dx + + + + + mov + dl, + U50UTPUT_LATCH + + + + + mov + al, + [bx] + + + + + call + OutputByte + + + + + pop + ax + + + + + HwSelectChannel + + + + + popft + + + + + jmp + ExitWithCompletionStatusZero + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + A4ExifSense, + far + + + + + + + + + Reads + the + state + of + the + LEDS + and + Switches. + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + 7Select + our + SIBO + + + ; + serial + channel + + + 7Store + old + channel + + + + + + + + + ;DX + (now + BX) + points + + + ;to + the + value + to + + + output + to + our + + + ;peripheral + + + + + ;Return + old + channel + + + + + + + + + ;To + signal + completion + + + + + + + + + 7of + set + request + + + + + + + + + Can + be + called + from + PLIB + using + p_iow(pcb, + P_FSENSE, + éArgl, + &Arg2) + + + + + + + + + Where + Argl + and + Arg2 + are + unsigned + bytes. + + + In: + + + + + + + + + Pointer + to + control + block + in + applications + data + space + in + BX + + + Pointer + to + control + block + in + our + CS + space + in + DI + + + + + + + + + Al + (pointer + to + Argl) + in + DX + + + + + + + + + Out: + + + Jumps + to + common + exit + point + + + pushf + + + cli + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + push + ax + + + mov + bx, + dx + + + mov + dl, + U4STATUS_BUFFER + + + call + InputByte + + + mov + [bx], + al + + + mov + bx, + [si] + .RqA2Ptr + + + mov + dl, + U3INPUT_BUFFER + + + call + InputByte + + + mov + [bx], + al + + + pop + ax + + + HwSelectChannel + + + popft + + + jmp + ExitWithCompletionStatusZero + + + + + + + + + ProcEnd + noret + + + + + + + + + LOCAL + DEVICE + DRIVER + FUNCTIONS + + + + + + + + + 7Select + our + SIBO + + + ;serial + channel + + + 7 + Store + old + channel + + + + + + + + + ;DX + (now + BX) + points + + + ;to + the + variable + in + + + ;which + to + place + the + + + ;value + read + from + U4. + + + 7BX + now + points + to + + + + + ;the + variable + in + + + + + ;which + to + place + the + + + ;value + read + from + U3. + + + + + + + + + ;Return + old + channel + + + + + + + + + ;To + signal + completion + + + + + + + + + ;of + a + sense + request + + + + + + + + + Interrupts + must + be + off + prior + to + the + call + to + this + function. + + + + + + + + + IN: + + + + + + + + + DL + has + address + to + which + Asic4 + is + to + write + + + + + + + + + AL + holds + the + value + to + output + + + + + + + + + mov + al, + (SerialWriteSingle + or + A4Address) + + + + + + + + + SBUSY + + + SCONTOUT + + + mov + al, + dl + + + SBUSY + + + SDATAOUT + + + mov + al, + (SerialReadSingle + or + A4Data) + + + SBUSY + + + + + SCONTOUT + + + + + SBUSY + + + + + SDATAIN + + + + + ret + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + OutputByte + + + + + + + + + Interrupts + must + be + off + prior + to + the + call + to + this + function. + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 96 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + H + IN: + + + ; + DL + has + address + to + which + Asic4 + is + to + write + + + ; + AL + has + the + value + to + output + + + + + + + + + mov + al, + (SerialWriteSingle + or + A4Address) + + + + + + + + + mov + al, + dl + + + + + + + + + mov + al, + (SerialWriteSingle + or + A4Data) + + + SBUSY + + + SCONTOUT + + + SBUSY + + + XNOP + + + pop + ax + + + SDATAOUT + + + ret + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + IntVecO, + far + + + + + + + + + - + Interrupt + on + serial + channel0 + + + 3 + Calls + Comint + with + channel + control + block + pointer + in + DI + + + , + + + + + mov + di, + offset + Channel0O + + + + + jmp + ComIint + + + + + + + + + ProcEnd + noret + + + + + + + + + if + Corporate + or + S3c + + + ProcBegin@ + IntVecl1, + far + + + + + + + + + Sat + + + + + + + + + Interrupt + on + serial + channell + + + + + + + + + ; + Calls + Comint + with + channel + control + block + pointer + in + DI + + + , + + + + + mov + di, + offset + Channell + + + + + jmp + ComInt + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + IntVec2,far + + + + + + + + + Interrupt + on + serial + channel2 + + + Calls + Comint + with + channel + control + block + pointer + in + DI + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + mov + di, + offset + Channel2 + + + 7 + FALL + THROUGH + + + ProcEnd + noret + + + endif + + + ProcBegin@ + ComInt, + far + + + , + + + ; + The + common + interrupt + service + routine + code. + + + ; + When + an + interrupt + occurs, + the + first + task + is + to + read + the + status + + + 7 + buffer + of + latch + U4. + The + subsequent + action + is + dependent + on + the + + + ; + postion + of + switches + Sl + and + S2. + For + the + purposes + of + this + example, + + + ; + the + four + posibilities + for + the + switch + values + correspond + somewhat + + + ; + arbitrarily + to + four + different + byte + values + that + are + written + to + U5. + + + ; + in + the + 8086, + interrupts + cannot + occur + while + in + an + interrupt + routine. + + + ; + If + an + asynchronous + read + is + pending + then + the + handler + is + signalled. + + + 7 + IN: + + + ; + Channel's + CS + based + control + block + pointer + in + DI + + + , + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 2 + ;Only + if + 2 + do + we + have + + + jne + NotAsynchronousRead + ;asynch + read + completed + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 1 + + + mov + bx, + cs: + [di] + .A4ExifCSProcessId + ;Signals + completion + + + ToSignalByPidNoReSched + 7Of + read + to + OS + so + as + + + NotAsynchronousRead: + ;to + invoke + handler + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + push + ax + + + mov + dl, + U3INPUT_BUFFER + + + call + InputByte + + + mov + cs: + [di] + .A4ExifCSA2Value, + al + ;LED + byte + + + mov + dl, + U4STATUS_BUFFER + + + + + + + + + Revision + 1.00 + Page + 97 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + call + InputByte + + + mov + cs: + [di] + .A4ExifCSAlValue, + al + ; + Status + byte + + + and + al, + INTERRUPT_STATUS_MASK + + + xchg + al, + SwitchStatus + + + cmp + SwitchStatus, + S2S3_ON + 7;S2 + and + S3 + on + => + turn + + + je + A11LEDsOn + 7on + alternate + LEDs + + + cmp + SwitchStatus, + S2S3_OFF + 7S2 + and + S3 + off + => + not + + + je + A11LEDsOff + ;the + alternate + LEDs + + + cmp + SwitchStatus, + S2_ONLY + 782 + on, + S3 + off + => + turn + + + je + TopLEDsOn + 7on + top + four + LEDs + + + cmp + SwitchStatus, + S3_ONLY + 753 + on, + S2 + off + => + turn + + + je + BottomLEDsOn + 7on + bottom + four + LEDs + + + ErroriInSwitchStatusByte: + + + jmp + ClearInterruptAndReschedule + + + A11LEDsOn: + + + mov + al, + SOME_LEDS_ON + + + jmp + Output + LEDByte + + + A11LEDsOff: + + + mov + al, + SOME_LEDS_OFF + + + jmp + Output + LEDByte + + + TopLEDsOn: + + + mov + al, + TOP_LEDS_ON + + + jmp + Output + LEDByte + + + BottomLEDsOn: + + + mov + al, + BOTTOM_LEDS_ON + + + OutputLEDByte: + + + mov + dl, + US50UTPUT_LATCH + + + call + OutputByte + + + ClearInterruptAndReschedule: + + + mov + dl, + INTERRUPT_LATCH + + + call + OutputByte + + + if + Asic9 + ;A + write + to + this + location + + + out + A9BNonSpecificEoiw, + al + ;informs + the + interrupt + + + else + ;controller + that + the + + + out + AlNonSpecificEoi, + al + ;installed + interrupt + + + endif + ;service + routine + has + + + pop + ax + ; + finished + + + HwSelectChannel + + + onlkres + ;Reschedule + if + necessary + + + ret + + + ProcEnd + noret + + + ProcBegin@ + StartInterrupts + + + po + SSS + SES + + + ; + Start + interrupts + assuming + interrupts + are + + + ; + off + prior + to + call. + + + ; + The + EPOC + GenSetRevector + service + loads + in + + + ; + a + user-specified + interrupt + service + routine + + + ; + located + at + the + address + given + in + cx:bx + + + ; + (segment + cx, + offset + bx) + for + the + interrupt + + + ; + vector + number + given + in + AL. + Note + that + the + + + 7 + variable + A4ExifCSChannelIntVec + holds + the + + + ; + name + of + the + appropriate + required + interrupt + + + ; + vector + routine + for + the + channel. + + + H + IN: + + + ; + Our + CS + control + block + pointer + in + DI + + + H + OUT: + + + i; + Nothing + + + is + + + mov + al, + cs: + [di] + .-A4ExifCSChannelIntNum + 7Get + the + OS + to + call + + + mov + cx, + CS + ;the + function + in + + + push + bx + 7CS:BX + every + time + + + mov + bx, + cs: + [di] + .A4ExifCSChannelIntVec + ;that + the + interrupt + + + GenSetRevector + ;whose + number + is + in + + + pop + bx + 7;AL + occurs + + + ife + Asic9 + + + in + al, + AlInterruptMask + + + or + al, + cs: + [di] + .A4ExifCSChannelIntMask + ;Set + the + mask + + + out + AlInterruptMask, + al + ;location + so + as + + + ; + interrupt + + + else + ;to + enable + that + + + in + al, + A9BInterruptMaskRW + ; + interrupt + + + or + al, + cs: + [di] + .A4ExifCSChannelIntMask + + + out + A9BInterruptMaskRW, + al + + + endif + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + Revision + 1.00 + Page + 98 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + ProcBegin@ + StopInterrupts + + + + + + + + + ; + Stop + interrupts + assuming + that + interrupts + are + off + + + + + + + + + The + EPOC + GenResetRevector + OS + service + + + + + + + + + interrupt + service + routine + with + the + original + + + routine + and + interrupt + mask + for + the + vector + + + given + in + AL. + + + IN: + + + + + Our + CS + control + block + pointer + in + DI + + + + + + + + + Se + ee + Te + + + + + + + + + OUT: + + + ; + Nothing + + + + + + + + + ife + Asic9 + + + + + + + + + replaces + the + previously + loaded + user-specified + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + in + al, + AlInterruptMask + ;Disable + the + + + mov + ah, + cs: + [di] + .A4ExifCSChannelIntMask + ; + interrupt + + + not + ah + + + and + al, + ah + + + out + AlInterruptMask, + al + + + else + + + in + al, + A9BInterruptMaskRW + + + mov + ah, + cs: + [di] + .A4ExifCSChannelIntMask + + + not + ah + + + and + al, + ah + + + out + A9BInterruptMaskRW, + al + + + endif + + + mov + al, + cs: + [di] + .-A4ExifCSChannelIntNum + ;Return + the + interrupt + + + GenResetRevector + ;vector + to + the + OS + + + ret + ; + default + + + ProcEnd + noret + + + ProcBegin@ + StartTheChannelRunning + + + Fo + eee + eeeeeeea= + + + ; + Starts + the + hardware + and + interrupts + going + + + ; + If + the + hardware + is + aready + running + then + there + is + nothing + to + do + + + ; + Must + check + that + the + hardware + has + not + vanished + before + restarting + it + + + H + IN: + + + ; + Our + CS + control + block + pointer + in + DI + + + 7 + OUT: + + + i + Nothing + + + 7 + + + pushf + + + cli + + + cmp + byte + ptr + cs: + [di].A4ExifCSChannelRunning, + 0 + + + jne + ChannelAlreadyRunning + + + call + CheckHardwarePresent + + + jc + HardwareNotPresent + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + push + ax + + + mov + al, + (SerialWriteSingle + or + A4Control) + ; + Switch + on + the + + + SBUSY + output + latch + U5 + + + SCONTOUT + ;by + asserting + + + mov + al, + U5_ENABLE_ON + ;the + ASIC4 + LBO + line + + + SBUSY + ; + (LBO + is + inverted) + + + SDATAOUT + + + xor + ax,ax + + + mov + dl, + INTERRUPT_LATCH + 7Clear + any + pending + + + call + OutputByte + ;interrupt + on + the + + + mov + dl, + US5OUTPUT_LATCH + ;peripheral + + + call + OutputByte + 7Preset + the + LEDs + + + pop + ax + ;to + all + off + + + HwSelectChannel + + + call + StartInterrupts + + + mov + cs: + [di] + .A4ExifCSChannelRunning, + 1 + + + ChannelAlreadyRunning: + + + popft + + + cle + + + ret + + + HardwareNotPresent: + + + popft + + + stc + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + StopTheChannelRunning + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 99 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + Stops + the + hardware + and + interrupts + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Checks + to + see + if + the + hardware + is + really + running + to + start + with + + + + + + + + + IN: + + + Our + CS + control + block + pointer + in + DI + + + + + i + OUT: + + + ; + Nothing + + + 7 + + + + + pushf + + + + + cli + + + + + cmp + byte + ptr + cs:[di].A4ExifCSChannelRunning, + 0 + + + + + je + ChannelNotRunning + + + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + + + HwSelectChannel + + + + + push + ax + + + + + mov + al, + (SerialWriteSingle + or + A4Control) + + + + + SBUSY + + + + + SCONTOUT + + + + + mov + al, + U5_ENABLE_OFF + + + + + SBUSY + + + + + SDATAOUT + + + + + xor + ax, + ax + + + + + mov + dl, + US50OUTPUT_LATCH + + + + + call + OutputByte + + + + + pop + ax + + + + + HwSelectChannel + + + + + call + StopInterrupts + + + + + mov + cs: + [di] + .A4ExifCSChannelRunning, + 0 + + + ChannelNotRunning: + + + + + popft + + + + + ret + + + + + + + + + Se + eT + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + CheckHardwarePresent + + + + + + + + + Used + to + determine + whether + the + correct + hardware + is + present + + + + + + + + + on + the + successfully + procured + serial + channel. + + + + + + + + + IN: + + + + + CS + control + block + pointer + in + DI + + + OUT: + + + + + Carry + clear + - + correct + hardware + is + there + + + + + Carry + set + - + wrong + or + no + hardware + + + pushf + + + cli + ;Select + the + correct + + + mov + al, + cs: + [di] + .A4ExifCSChannelSelect + ;SIBO + channel + that + + + HwSelectChannel + ;the + peripheral + is + + + push + ax + ;attached + to + + + HwNullFrame + + + mov + al, + (SerialSelect + or + Asic4Id) + + + SBUSY + ;First + look + for + an + + + SCONTOUT + 7;ASIC4 + at + the + other + + + XNOP + ;end + of + the + link + + + SBUSY + + + SDATAIN + ;Ilf + the + returned + + + test + al,al + ;value + is + non-zero + + + je + ConnectionFailedA4NotPresent + ;we + have + an + ASIC4 + + + mov + al, + (SerialReadSingle + or + A4InfoR) + + + SBUSY + ;Now + see + if + we + have + + + SCONTOUT + ;the + right + peripheral + + + XNOP + 7;XNOP + allows + the + busy + + + SBUSY + 7Signal + to + come + + + SDATAIN + ;through + for + the + wait + + + and + al, + A4PERIPH_MASK + + + cmp + al, + EXTENDED_INFO_BYTE + ;Mask + out + the + bottom + + + jne + ConnectionFailed + ;four + bits + as + the + + + pop + ax + yupper + four + contain + + + HwSelectChannel + ;the + peripheral + ID + + + popft + + + cle + ;If + it + is + our + hardware + + + ret + 7exit + with + carry + clear + + + + + ConnectionFailedA4NotPresent: + + + + + mov + al, + (SerialSelect + or + Asic5Normalld) + ;Its + not + an + ASIC4 + + + SBUSY + ;peripheral + + + SCONTOUT + 7By + selecting + a + non + + + XNOP + 7;ASIC4 + as + an + ASIC4, + + + SDATAIN + ;we + effectively + + + + + + + + + test + al,al + + + + + + + + + Revision + 1.00 + + + + + + + + + ;disable + whatever + is + + + + + + + + + Page + 100 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + jne + ConnectionFailed + yout + there + so + we + do + + + mov + al, + (SerialSelect + or + Asic5PackId) + ja + select + for + all + + + SBUSY + ;possibilities + so + + + SCONTOUT + ;that + we + don't + end + + + XNOP + ;up + disabling + + + SDATAIN + yanything + that + we + + + + + + + + + test + al,al + ;can't + control. + + + jne + ConnectionFailed + + + + + + + + + mov + al, + (SerialSelect + or + Asic8Id) + 7Modem + chip + id + + + + + SBUSY + + + + + SCONTOUT + + + + + XNOP + + + + + SDATAIN + + + ConnectionFailed: + + + + + pop + ax + + + + + HwSelectChannel + + + + + popft + + + + + stc + + + + + ret + + + + + ProcEnd + noret + + + + + + + + + EndCodeSeg + + + + + stack + segment + stack + para + 'data' + + + stack + ends + + + + + end + A4ExifLDD + + + + + + + + + Revision + 1.00 + Page + 101 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + SYSS$AS5.ASM + + + + + + + + + title + ASSPDD + Epoc + Serial + physical + device + driver + for + the + 16550 + + + subttl + Copyright + Psion + PLC + 1993 + + + name + SYSSAS5 + + + + + i + VERSION + DATE + DESCRIPTION + + + + + me + MEE + ee + ee + ee + eee + + + + + ; + Lat + 08/12/94 + Initial + version + + + + + 7 + Written + by + Jason + December + 1994 + + + + + : + Serial + Driver + for + Epoc + based + around + ASIC5 + + + + + Sr5s3 + = + 0 + + + + + Sr5S3a + = + 1 + + + + + ifdef + BUILDS3 + + + + + Sr5S3 + = + 1. + + + + + Sr5S3a + = + 0 + + + + + BUILDHH + equ + 1 + + + + + endif + + + + + a + Sr5S3a + + + + + BUILDSB + equ + 1 + + + + + endif + + + include + ..\inc\epoc.inc + + + include + ..\inc\epocser.inc + + + include + ..\inc\epoclib.inc + + + include + ..\inc\epocsibo.inc + + + include + ..\srcs\ossibo.inc + + + include + ..\srces\ospack.inc + + + + + + + + + Sr5ChannelStruct + struc + + + + + + + + + Sr50pen + db + ? + ; + Is + the + channel + open + + + SrKSCtY1L + db + ? + ; + State + of + control + lines + + + Sr5IntVector + db + 2 + ; + The + Vector + number + + + Sr5Channel + db + ? + ; + Which + channel + are + we + + + Sr5Mask + db + ? + ; + InterruptMask + + + Sr5Running + db + ; + Are + we + running + + + Sr5IntRoutineVec + dw + cs + ; + Vector + to + Interrupt + + + Sr5Baud + dw + ? + ; + The + baud + rate + + + Sr5LddData + dw + ? + ; + Info + from + Ldd + above + + + Sr5StatusInt + dd + ? + ; + Vectors + in + serial + + + Sr5Recvint + dd + 2 + ; + Above + to + be + called + + + Sr5XmitInt + dd + ? + ; + On + input/output + + + Sr5ClockEnable + db + ? + ; + Reason + to + stop + + + + + Sr5TheLines + db + ? + ; + State + of + the + modem + lines + + + + + + + + + Sr5ChannelStruct + ends + + + + + + + + + A5Ent + struc + + + A5PortA + + + A5PortB + + + A5PortBMode + + + A5PortD + + + A5Swipel + + + A5Swipe2 + + + A5IntMask + + + A5CtrlReg + + + A5USR + + + A5RHR + + + A5BDLSB + + + A5SBDMSB + + + A5MCRIEoi + + + A5MCRPresentEoi + + + A5MCR2Eoi + + + ASDUMMYF + + + + + A5Ent + ends + + + + + + + + + Lt + Consumer + + + NumberOfChannels + + + else + + + NumberOfChannels + + + endif + + + OsActivityMeter + + + StopTimeOut + + + + + + + + + S_RS2320N + + + + + + + + + Revision + 1.00 + + + + + + + + + db + + + db + + + db + + + db + + + db + + + db + + + db + + + db + + + + + + + + + db + + + db + + + + + + + + + db + + + db + + + db + + + db + + + db + + + db + + + + + + + + + equ + + + + + + + + + equ + + + + + + + + + equ + + + + + + + + + equ + + + + + + + + + equ + + + + + + + + + VVV + Vv + vw + + + + + + + + + YN + vn + vv + + + + + + + + + 158ch + + + 1000 + + + + + + + + + 00000001b + + + + + + + + + at + + + + + + + + + ASIC5 + Read/Write + + + Port + A + R/W + + + + + Port + B + R/W + + + Inc/Mode + + + + + Port + CD + Write + only + + + + + + + + + Ne + Ne + Ne + Ne + Ne + + + + + + + + + Interrupt + mask + R/W + + + IntType/Ctrl + register + + + UART + Status/Ctrl + + + Receive/Transmit + + + + + Baud + Rate + write + only + + + Baud + Rate + write + only + + + MCR + shift + register + + + Barcode + data&ints + + + + + + + + + + + + + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + ; + S3 + Single + Channel + + + , + HC,S3C + Three + Channel + + + + + + + + + ; + Activity + Channel + + + ; + w~ls + (1000ms) + wait + + + + + + + + + 7 + RS232 + on + + + + + + + + + Page + 102 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + S_RSTTLON + equ + 00000100b + ; + Line + drivers + on + + + S_CENTON + equ + 00010000b + ; + Line + drivers + enable + + + S_RXENB + equ + 00000001b + ; + Receive + interrupt + on + + + S_TXENB + equ + 00000010b + ; + Transmit + interrupt + on + + + S_TXEMPTY + equ + 00010000b + ; + transmit + buffer + empty + + + S_RXINT + equ + 00000001b + ; + Receive + interrupt? + + + S_TXINT + equ + 00000010b + ; + transmit + interrupt? + + + S_MDINT + equ + 00000100b + ; + Modem + status + interrupt + + + S_CTS + equ + 00000001b + # + CLS + + + S_RTS + equ + 00000010b + ; + RTS + + + S_DCD + equ + 00000100b + DCD + + + S_DSR + equ + 00000010b + ; + DCR + + + S_DTR + equ + 00000100b + ; + DIR + + + OVERRUN_ERROR + equ + 01000000b + ; + Character + overrun + + + PARITY_ERROR + equ + 10000000b + ; + Parity + error + + + S_PERIPHERALMODE + equ + 00000011b + ; + ASIC5 + RS232 + mode + + + S_UART_OFF + equ + 00000010b + ; + ASIC5 + peripheral + mode + + + dgroup + group + stack + + + assume + ds:dgroup,es:dgroup,ss:dgroup + + + CodeSeg + + + ProcBegin@ + OsAS5PDD + + + ; + SiS + SeSe + Sees + Ses + eceses + + + dw + PDDSignature + + + db + 'TTY.SR5',0 + + + dw + (VectorEnd-Vector) + /2 + + + Vector: + + + dw + OsAS5SInstall + + + dw + OsAS5Remove + + + dw + OsAS50Open + + + dw + OsAS5Strategy + + + VectorEnd: + + + + + + + + + BaudRateTable + dw + + + + + + + + + -077f£h, + -04£fh, + -0368h, + -02cch, + -027£h, + -013fh + + + + + + + + + dw + -009fh, + -004fh, + -0035h, + -0030h, + -0027h, + -0019h + + + dw + -—0013h, + -000ch, + -0009h, + -0004h + + + + + + + + + DataBitsTable + db + 0,2,4,6 + + + + + + + + + + + + + + + + + + 5,6,7,8 + bits + per + char + frame + + + + + + + + + ParityTable + db + 08h,18h, + 0h, + 0h + ; + Even,Odd,Mark, + Space + parity + + + Chan0O + Sr5ChannelStruct + <> + + + Chanl + Sr5ChannelStruct + <> + + + Chan2 + Sr5ChannelStruct + <> + + + + + + + + + if + Consumer + + + + + + + + + if + Asic9 + + + SetupTable + dw + offset + AS5Int1l + + + db + HwIrq2Revector,mask + A9MSlave + + + db + SelectChannel5, + (mask + A9MClockEnable5 + shr + 8) + + + else + + + SetupTable + dw + offset + AS5Intl + + + db + HwIrq4Revector,mask + Asic2Int + + + db + SelectChannel7, + (mask + ClockEnable7 + shr + 8) + + + endif + + + else + + + if + Asic9 + + + SetupTable + dw + offset + AS5Int1l + + + db + HwIrq4Revector,mask + A9MExpIntA + + + db + SelectChannel3, + (mask + A9MClockEnable3 + shr + 8) + + + dw + offset + AS5Int2 + + + db + HwIrq5Revector,mask + A9MExpIntB + + + db + SelectChannel4, + (mask + A9MClockEnable4 + shr + 8) + + + dw + offset + ASSInt3 + + + db + HwIrq2Revector,mask + A9MSlave + + + db + SelectChannel5, + (mask + A9MClockEnable5 + shr + 8) + + + else + + + SetupTable + dw + offset + AS5Int1l + + + db + HwIrq3Revector,mask + ExpIntLeftA + + + db + ExpChannelLeftA, + (mask + ClockEnableé + shr + 8) + + + dw + offset + AS5Int2 + + + db + HwIlrq2Revector,mask + ExpIntRightB + + + db + ExpChannelRightB, + (mask + ClockEnable5 + shr + 8) + + + dw + offset + AS5Int3 + + + db + HwIrq4Revector,mask + Asic2Int + + + db + SelectChannel7, + (mask + ClockEnable7 + shr + 8) + + + endif + + + endif + + + + + + + + + ProcEnd + noret + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 103 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + ProcBegin@ + OsAS5Install, + far + + + + + + + + + Install + the + device + driver + + + Out: + Carry + clear + -happy + to + install + + + + + + + + + cld + + + mov + cx, + NumberOfChannels + + + mov + di, + offset + Chan0od + + + mov + si, + offset + SetupTable + + + pushf + + + cli + + + push + ds + + + mov + ax, + Cs + + + mov + ds, + ax + + + ResetAllChannelsLoop: + + + mov + di].Sr50pen, + 0 + + + lodsw + + + mov + di].Sr5IntRoutineVec, + ax + + + lodsb + + + mov + di].Sr5IntVector, + al + + + lodsb + + + mov + di].Sr5Mask, + al + + + lodsb + + + mov + di].Sr5Channel, + al + + + lodsb + + + mov + di].Sr5ClockEnable, + al + + + add + di, + size + Sr5ChannelStruct + + + loop + ResetAllChannelsLoop + + + pop + ds + + + popft + + + AllChannelsOkay: + + + cle + + + ret + + + + + + + + + Mee + Ne + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + GotChan: + + + + + + + + + Revision + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + OsAS5Remove, + far + + + + + + + + + Remove + the + device + driver + + + Out: + Carry + clear + -happy + to + remove + + + + + + + + + + + + + + + + + + + + + ~ + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Clear + the + channels + + + and + set + up + fixed + + + parameters + such + + + + + as + the + interrupt + + + vectors + and + masks + + + for + each + channel + + + + + + + + + Channel + not + open + + + + + + + + + Set + the + interrupt + + + handler + to + call + + + hich + Interrupt + + + + + + + + + = + + + + + + + + + Mask + for + that + + + interrupt + + + + + Which + Psion + serial + + + channel + + + + + Baud + rate + clocking + + + enable + + + + + + + + + Returns + with + + + Carry + clear + + + + + + + + + Carry + set + -we + have + an + open + channel + and + cant + be + removed. + + + + + + + + + xor + ax, + ax + + + or + al, + Chan0O.Sr50pen + + + or + al, + Chanl.Sr50pen + + + or + al, + Chan2.Sr50pen + + + jz + AllChannelsOkay + + + mov + ax, + InUseErr + + + + + stc + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + OsAS5Open, + far + + + + + + + + + Open + a + serial + channel + + + + + + + + + see + + + + + + + + + In: + SS:SI + is + a + pointer + to + the + open + Ent + Structure + + + + + + + + + Out: + Carry + clear, + control + block + in + BX + + + + + + + + + Carry + set, + error + in + AX + + + + + + + + + cld + + + + + mov + si, + [si] + .OpenNamePtr + + + mov + al, + [sitl] + + + CharToFoldedChar + + + + + cmp + al, + 'A' + + + + + jb + ErrorInOpen + + + + + sub + al, + ‘'A' + + + + + cmp + al, + NumberOfChannels + + + jae + ErrorInOpen + + + + + xoOr + ah, + ah + + + + + mov + bx, + offset + Chan0O + + + + + cmp + al, + 1 + + + + + jb + GotChan + + + + + mov + bx, + offset + Chan2 + + + + + ja + GotChan + + + + + mov + bx, + offset + Chanl + + + + + mov + al, + 1 + + + + + 1.00 + + + + + + + + + If + we + have + a + + + channel + Still + open + + + then + return + a + can't + + + do + error + else + + + complete + okay + + + + + + + + + Open + the + channel + + + Get + the + channel + + + Make + Upper + Case + + + Indicator + which + is + + + Part + of + the + name + + + Should + be + A,B,C + + + + + + + + + What + Channel + are + + + We + Openning + + + Pointer + to + Control + + + Block + in + bx + + + + + + + + + Page + 104 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + xchg + al, + cs: + [bx].Sr50Open + + + cmp + al, + 0 + + + je + OkayToOpen + + + CantOpen: + + + mov + ax, + InUseErr + + + CantOpenDiffErr: + + + stc + + + ret + + + ErroriInOpen: + + + mov + ax, + NameErr + + + stc + + + ret + + + OkayToOpen: + + + xor + al, + al + + + mov + cs: + [bx].Sr5Running, + al + + + mov + cs: + [bx].Sr5TheLines, + al + + + mov + cs: + [bx].Sr5Ctrl, + al + + + mov + al, + cs: + [bx].Sr5Mask + + + HwGetChannel + + + jc + CantOpenSoClose + + + call + CheckHardwarePresent + + + jne + OpenedOkay + + + mov + al, + cs: + [bx].Sr5Mask + + + HwF + reeChannel + + + CantOpenSoClose: + + + mov + cs: + [bx].Sr50pen, + 0 + + + mov + ax, + DeviceErr + + + jmp + short + CantOpenDiffErr + + + OpenedOkay: + + + xor + ax, + ax + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + AS5StrategyJumpTable + label + word + + + + + + + + + dw + offset + AS50Open + + + + + dw + offset + AS5Close + + + + + dw + offset + AS5Start + + + channel + + + + + dw + offset + AS5Stop + + + + + dw + offset + AS5Set + + + + + dw + offset + AS5Sense + + + + + dw + offset + AS5Control + + + + + dw + offset + ASS5Enquire + + + + + dw + offset + AS5Enable + + + + + dw + offset + AS5SetHandlerCs + + + + + + + + + ProcBegin@ + OsAS5Strategy, + far + + + + + + + + + Strategy + functions + entry + point + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + 7 + Now + try + to + Open + + + ; + That + channel + + + + + + + + + ; + Check + that + we + have + + + ; + The + right + Hardware + + + + + + + + + Return + with + the + + + Offset + of + our + + + Control + Block + + + In + bx + + + + + + + + + Ne + Ne + Ne + Ne + + + + + + + + + ; + Load + Handler + offsets + + + ; + Close + the + channel + + + ; + Start + the + + + + + + + + + 7 + Stop + the + channel + + + ; + Does + nothing + + + ; + Returns + chan + status + + + ; + Drive + the + lines + + + ; + Returns + baud + rate + + + ; + Begin + Output + + + ; + Get + Handler + segments + + + + + + + + + In: + vector + number + in + AX + + + various + data + in + other + registers + + + + + + + + + ; + Select + the + correct + + + + + ; + Output + channel + + + Then + Call + the + right + + + Function + to + deal + + + + + ; + With + the + strategy + + + + + 7; + request + + + + + + + + + + + + + + + + + + + + + ; + Interrupts + off + + + ;, + and + flags + are + on + + + ; + the + stack + + + + + + + + + 7 + + + 7 + Warning! + This + can + be + called + from + within + Interrupt + + + 7 + + + iH + DS + is + OsDataGroup + (and + MUST + be + preserved) + + + ; + Out: + DI + is + pointer + to + control + block + + + H + Old + channel + and + flags + on + stack + + + + + cld + + + + + mov + bx, + sp + + + + + mov + bx, + ss: + [bx+4] + + + + + mov + bl, + cs: + [bx].Sr5Channel + + + + + xchg + bx, + ax + + + + + pushf + + + + + cli + + + + + HwSelectChannel + + + + + mov + ah, + bh + + + + + xOr + bh, + bh + + + + + push + ax + + + + + mov + ax, + di + + + + + mov + di, + sp + + + + + mov + di, + ss: + [dit+8] + + + + + jmp + AS5StrategyJumpTable + [bx] + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Open, + far + + + + + + + + + ; + Old + channel + and + flags + on + the + stack, + + + mov + cs: + [di].Sr5LddData, + cx + + + mov + word + ptr + cs: + [di].Sr5StatusInt, + + + + + + + + + Revision + 1.00 + + + + + + + + + interrupts + off + + + + + + + + + ; + Load + the + offsets + of + + + + + + + + + ax + ; + the + data + send + and + + + + + + + + + Page + 105 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + if + + + + + + + + + else + + + + + + + + + endif + + + + + + + + + mov + word + ptr + cs:[di].Sr5RecvInt, + si + + + mov + word + ptr + cs:[di].Sr5XmitInt, + dx + + + xor + ax, + ax + + + + + pop + ax + + + + + HwSelectChannel + + + + + popft + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Close, + far + + + + + + + + + Old + channel + and + flags + on + the + stack, + + + + + + + + + and + cs:[di].Sr50Open, + 0 + + + mov + al, + cs: + [di].Sr5Mask + + + HwF + reeChannel + + + + + pop + ax + + + + + HwSelectChannel + + + + + popft + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Start, + far + + + + + + + + + Old + channel + and + flags + on + the + stack, + + + + + + + + + call + CheckHardwareFromStart + + + + + mov + dx, + 0 + + + + + je + CantStartSomethingWhichIsntThere + + + Asic9 + + + + + in + ax, + AQWControlExtraRW + + + + + or + ah, + cs: + [di].Sr5ClockEnable + + + + + out + A9QWControlExtraRW, + ax + + + + + mov + al, + cs: + [di].Sr5ClockEnable + + + HwSetA2Control2Bits + + + + + mov + al, + SerialWriteSingle + or + A5USR + + + SBUSY + + + + + SCONTOUT + + + + + mov + al, + cs: + [di].Sr5Ctrl + + + + + SBUSY + + + + + SDATAOUT + + + + + mov + al, + SerialWriteSingle + or + A5BDLSB + + + SBUSY + + + + + SCONTOUT + + + + + mov + al, + byte + ptr + cs: + [di].Sr5Baud + + + SBUSY + + + + + SDATAOUT + + + + + mov + al, + SerialWriteSingle + or + A5BDMSB + + + SBUSY + + + + + SCONTOUT + + + + + mov + al, + byte + ptr + cs: + [dit+1].Sr5Baud + + + SBUSY + + + + + SDATAOUT + + + + + call + Get + TheInterrupt + + + + + xor + CX), + Cx + + + + + call + DriveRts + + + + + mov + al, + SerialWriteSingle + or + A5CtrlReg + + + SBUSY + + + + + SCONTOUT + + + + + mov + al, + (S_CENTON + or + S_RS2320N + or + + + SBUSY + + + + + SDATAOUT + + + + + mov + cx, + 8 + ; + 8 + ms + + + + + pop + dx + + + + + call + WaitTimer + + + + + push + dx + + + + + mov + ah, + (S_RXENB + or + S_TXENB + or + S_MDINT) + + + call + EnableTheInterrupt + + + + + mov + cs:[di].Sr5Running, + 1 + + + + + mov + bx, + Asic5SerialCurrent + + + HwSetPCurrent + + + + + call + Status + + + + + + + + + Revision + 1.00 + + + + + + + + + interrupts + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + ; + veceive + routines + in + + + ; + the + Ldd + above + us + + + ; + DX=0 + —-We + don't + support + + + 7; + power + management + + + ; + Return + the + old + + + ; + Channel + + + + + + + + + interrupts + off + + + + + + + + + ; + Close + the + Channel + + + + + ; + Free + up + our + channel + + + ; + And + the + Hardware + + + + + ; + Channel + + + + + ; + Return + the + old + + + + + ; + channel + + + + + + + + + off + + + + + + + + + ; + Start + the + S3s + clock + + + ; + Generator + + + + + + + + + ; + Set + the + baud + rate + + + ; + and + other + + + ; + Characteristics + + + + + + + + + Get + the + interrupt + + + and + clear + down + + + + + the + RTS + line + (DTR + + + stays + at + the + state + + + ; + it + was + set) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + S_RSTTLON) + + + + + + + + + ; + Switch + on + the + line + + + ; + QGrivers + and + wait + + + ; + for + them + to + power + up + + + + + + + + + ; + Start + all + interrupts + + + + + + + + + Page + 106 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + CantStartSomethingWhichIsntThere: + + + + + + + + + pop + ax + + + HwSelectChannel + + + popft + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Stop, + far + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + ; + Return + the + old + + + ; + Channel + + + + + + + + + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + + + xor + CX, + CX + ; + Clear + the + state + of + + + call + DriveRts + ; + the + modem + lines + + + mov + al, + SerialReadSingle + or + A5IntMask + ; + Stop + all + of + the + + + SBUSY + ; + interrupts + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + not + (S_TXENB + or + S_RXENB + or + S_MDINT) + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + pop + ax + + + cmp + dh, + DevHoldPowerFail + + + je + Dont + StopHardware + + + cmp + cs:[di].Sr5Running, + 1 + + + jne + DontWait + + + mov + cx, + StopTimeOut + + + jmp + short + CompareNow + + + WaitForEmpty: + + + call + TickTimer + + + CompareNow: + + + mov + al, + SerialReadSingle + or + A5USR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + al, + S_TXEMPTY + + + loopne + WaitForEmpty + + + DontWait: + + + cmp + bh, + DevHoldNormal + + + je + Dont + StopHardware + + + if + Asic9 + + + mov + cl, + cs: + [di].Sr5ClockEnable + ; + Turn + off + baud + rate + + + not + cl + ; + Clocking + from + the + + + in + ax, + A9WControlExtraRW + } + S3y3a + + + and + ah, + cl + + + out + A9WControlExtraRW, + ax + + + else + + + mov + al, + cs: + [di].Sr5ClockEnable + + + HwClearA2Control2Bits + + + endif + + + mov + al, + SerialWriteSingle + or + A5CtrlReg + ; + Stop + the + drivers + + + SBUSY + , + and + stuff + + + SCONTOUT + + + sub + al, + al + ; + Clear + S_CENTON, + + + SBUSY + 7 + S_RS2320N, + S_RSTTLON + + + SDATAOUT + + + Dont + StopHardware: + + + mov + al, + dl + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + popft + + + xor + bx, + bx + + + HwSetPCurrent + + + ret + + + ProcEnd + noret + + + ProcBegin@ + AS5Set, + far + + + ; + Se + SeSeees + ees + Sees + + + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 107 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + ; + In: + Information + required + is + on + the + stack + + + pop + ax + + + HwSelectChannel + + + popft + + + mov + ah, + ss:[si].SerialCharTbaud + + + cmp + ah, + ss: + [si] + .SerialCharRbaud + + + jnz + ErrorInSet + + + cmp + ah, + P_BAUD_50 + + + jb + ErroriInSet + + + cmp + ah, + P_BAUD_19200 + + + ja + ErroriInSet + + + Got + TheSpecialBaud: + + + dec + ah + + + mov + cl, + ss:[si].SerialCharFrame + + + mov + al, + ss:[si].SerialCharParity + + + dec + al + + + xor + ch, + ch + + + push + bx + + + test + cl, + P_TWOSTOP + + + jz + OnlyOneStopBit + + + or + ch, + 020h + + + OnlyOneStopBit: + + + test + cl, + P_PARITY + + + jz + NoParity + + + mov + bx, + offset + ParityTable + + + xlat + cs: + [ParityTable] + + + or + ch, + al + + + NoParity: + + + mov + bx, + offset + DataBitsTable + + + and + cl, + P_DATA_FRM + + + mov + al, + cl + + + xlat + cs: + [DataBitsTable] + + + Or + ch, + al + + + mov + bx, + offset + BaudRateTable + + + mov + al, + ah + + + xOr + ah, + ah + + + shl + ax, + 1 + + + add + bx, + ax + + + mov + ax, + cs: + [bx] + + + pop + bx + + + mov + es? + [dt] + .Sractrl; + ch + + + mov + cs:[di].Sr5Baud, + ax + + + xOr + al, + al + + + ret + + + ErroriInSet: + + + mov + al, + NotSupportedErr + + + stc + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Sense, + far + + + + + + + + + seo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ~ + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Return + the + old + + + channel + + + + + + + + + Set + the + Recieve, + + + Transmit + characteristics + + + First + set + the + Baud + + + + + Rate + + + + + + + + + Then + the + number + of + + + Stop + bits + + + + + + + + + The + Parity + + + + + + + + + And + finally + the + + + Number + of + data + bits + + + Per + frame + + + + + + + + + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + + + ; + Out: + The + state + of + the + DCD,CTS,DSR + lines + returned + in + DX + + + call + Status + + + pop + ax + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + popft + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + Status + + + + + + + + + i + Out: + State + of + modem + lines + in + DX + + + mov + al, + SerialReadSingle + or + A5USR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + (S_CTS + or + S_DSR + or + S_DCD) + + + xor + al, + (S_CTS + or + S_DSR + or + S_DCD) + + + xOr + ah, + ah + + + + + + + + + Revision + 1.00 + + + + + + + + + see + + + + + + + + + Get + the + current + + + Modem + status + + + Lines + and + return + + + With + the + result + + + In + dx + + + + + + + + + Get + the + lines + we + want + + + Invert + signals + + + + + + + + + Page + 108 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + mov + ax, + ax + + + ret + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Control, + far + + + + + + + + + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + + + + + 7 + In: + Lines + to + drive + and + state + to + drive + them + in + DX + + + mov + onl + emo + ie + ; + Set + the + state + of + one + + + test + dh, + P_SRCTRL_DTR + ; + of + the + modem + Lines + + + jz + DriveRtsNow + ; + DH + is + the + line + to + + + call + DriveDtr + ; + Drive + and + DL + is + the + + + pop + ax + ; + Stateto + drive + it + to + + + HwSelectChannel + ; + Return + the + old + + + popft + ; + channel + + + ret + + + + + DriveRtsNow: + + + call + DriveRts + + + pop + ax + ; + Return + the + old + + + HwSelectChannel + ; + channel + + + popft + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + DriveDtr + + + + + + + + + mov + ah, + S_DTR + ; + Set/Reset + the + DTR + + + jmp + short + DriveTheLine + ; + Line + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + DriveRts + + + + + + + + + mov + ah, + S_RTS + ; + Set/Reset + RTS + + + DriveTheLine: + + + mov + al, + SerialWriteSingle + or + A5PortD + ; + Common + code + to + set + + + SBUSY + ; + and + reset + either + + + SCONTOUT + ; + line + while + + + mov + al, + cs:[di].Sr5TheLines + ; + preserving + the + + + test + cl, + cl + ; + states + of + the + other + + + IZ + ClearLine + ; + lines + + + or + al, + ah + + + jmp + DoTheOutput + + + ClearLine: + + + not + ah + + + and + al, + ah + + + DoTheOutput: + + + mov + cs:[di].Sr5TheLines, + al + + + SBUSY + + + SDATAOUT + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Enquire, + far + + + + + + + + + 7 + Old + channel + and + flags + on + the + stack, + interrupts + off + + + - + Out: + DX,AX + are + the + supported + baud + rates + AX + for + 50 + to + 19200 + DX + for + above + + + ; + CX + says + what + data + bits, + parity, + etc + we + support + + + pop + ax + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + popf + + + if + Asic9 + + + mov + ax, + —-1 + + + else + + + mov + ax, + O7fffh + + + endif + + + xor + dx, + ax + + + mov + cx, + (Offffh + AND + (NOT + (P_SRINQ_SPLIT + OR + P_SRINQ_PARSPACE + OR + + + P_SRINQ_PARMARK) + ) + ) + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Enable, + far + + + + + + + + + Revision + 1.00 + Page + 109 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + - + Old + channel + and + flags + on + the + stack, + interrupts + off + + + mov + ah, + S_TXENB + ; + Begin + Output + by + + + call + EnableTheInterrupt + ; + enabling + transmit + + + pop + ax + ; + interrupts + + + HwSelectChannel + ; + Return + the + old + + + popft + ; + channel + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5SetHandlerCs, + far + + + + + + + + + CX + is + CS + of + above + LDD + + + + + + + + + sew + + + + + + + + + mov + word + ptr + cs: + [di]. + (Sr5StatusInt+2), + cx + + + mov + word + ptr + cs:[di].(Sr5RecvInt+2), + cx + + + mov + word + ptr + cs: + [di]. + (Sr5XmitInt+2), + cx + + + pop + ax + + + + + HwSelectChannel + + + + + popft + + + + + ret + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Int3, + far + + + + + + + + + mov + di, + offset + Chan2 + + + mov + ax, + PortCActive + + + jmp + ComInt + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Int2,far + + + + + + + + + mov + di, + offset + Chanl + + + mov + ax, + PortBActive + + + jmp + ComIint + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + AS5Int1,far + + + + + + + + + mov + di,offset + Chan0 + + + mov + ax, + PortAActive + + + 4 + FALL + THROUGH + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + ComInt, + far + + + + + + + + + The + common + interrupt + handler + + + DS + points + to + OS + data + space + + + DI + is + our + control + block + + + + + + + + + Mee + Ne + + + + + + + + + ; + AX + is + the + Active + channel + + + ab + S3b + or + S3c + + + + + or + ds: + [OsActivityMeter], + ax + + + endif + + + + + mov + al, + cs: + [di].Sr5Channel + + + + + HwSelectChannel + + + + + push + ax + + + + + mov + bx, + cs: + [di].Sr5LddData + + + TheInterruptLoop: + + + + + mov + al, + SerialReadSingle + or + A5CtrlReg + + + + + SBUSY + + + + + SCONTOUT + + + + + XNOP + + + + + SBUSY + + + + + SDATAIN + + + + + test + al, + al + + + + + je + NothingToDo + + + HaveWeGotAModemStatusLineInterrupt: + + + + + test + al, + S_MDINT + + + + + 4z + HaveWeGotARecievelInterrupt + + + + + mov + al, + SerialReadSingle + or + A5USR + + + + + SBUSY + + + + + SCONTOUT + + + + + + + + + Revision + 1.00 + + + + + + + + + ~ + + + + + + + + + Mee + Ne + + + + + + + + + Old + channel + and + flags + on + the + stack, + interrupts + off + + + + + + + + + ; + Load + the + Segment + + + + + ; + Within + which + the + + + The + Ldd + above + us + + + Return + the + old + + + channel + + + + + ; + Resides + + + + + + + + + Channel + 3 + interrupt + + + vector + + + Jumps + to + Comint + + + + + + + + + see + + + + + + + + + ~ + + + + + + + + + Channel + 2 + interrupt + + + vector + + + Jumps + to + Comint + + + + + + + + + seo + + + + + + + + + ~ + + + + + + + + + Channel + 1 + interrupt + + + 7; + vector + + + + + ; + Falls + through + + + + + 7 + to + Comint + + + + + + + + + ; + Set + active + state + + + + + + + + + ; + Select + our + + + ; + Channel + + + + + + + + + ; + Data + for + LDD + above + + + ; + in + bx + + + + + ; + Find + out + what + + + + + ; + caused + the + + + + + ; + interrupt + + + + + + + + + Page + 110 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + ; + Something + has + been + + + ; + recieved + in + error + + + + + + + + + ; + Establish + the + error + + + + + + + + + ; + Get + the + character + + + ; + in + question + + + + + + + + + ; + invert + signals + + + + + + + + + XNOP + + + SBUSY + + + SDATAIN + + + test + al, + (OVERRUN_ERROR + or + PARITY_ERROR) + + + jz + ModemStatusInterruptOnly + + + push + ax + + + mov + ah, + SERPARITY_ERR + + + test + al, + PARITY_ERROR + + + jnz + IsAParityError + + + mov + ah, + SEROVERRUN_ERR + + + IsAParityError: + + + mov + al, + SerialReadSingle + or + A5RHR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + push + di + + + call + dword + ptr + cs: + [di] + .Sr5RecvInt + + + pop + di + + + pop + ax + + + ModemStatusInterruptOnly: + + + and + ax, + (S_CTS + or + S_DSR + or + S_DCD) + + + xor + al, + (S_CTS + or + S_DSR + or + S_DCD) + + + mov + ax, + ax + + + push + di + + + call + dword + ptr + cs: + [di].Sr5StatusInt + + + pop + di + + + jmp + short + TheInterruptLoop + + + + + + + + + HaveWeGotARecievelInterrupt: + + + + + + + + + ; + AX + has + character + received + + + + + + + + + Resced + if + neccessary + + + + + + + + + ; + Gisable + TX + interrupts + + + + + + + + + test + al, + S_RXINT + + + jz + HaveWeGotATransmitInterrupt + + + mov + al, + SerialReadSingle + or + A5RHR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + xOr + ah, + ah + + + push + di + + + call + dword + ptr + cs: + [di] + .Sr5RecvInt + + + pop + di + + + jmp + short + TheInterruptLoop + + + HaveWeGotATransmitInterrupt: + + + test + al, + S_TXINT + + + jz + NothingToDo + + + push + di + + + call + dword + ptr + cs: + [di] + .Sr5XmitInt + + + pop + di + + + test + ax, + ax + ; + —-l1 + if + disable + + + js + DisableTransmitInts + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5RHR + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + jmp + TheInterrupt + Loop + + + NothingToDo: + + + if + Asic9 + + + out + A9BNonSpecificEoiwW, + al + + + else + + + out + AlNonSpecificEoi, + al + + + endif + + + pop + ax + + + HwSelectChannel + + + cle + ; + + + ret + + + DisableTransmitInts: + + + mov + al, + SerialReadSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + not + S_TXENB + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + + + + + + + Revision + 1.00 + + + + + + + + + Page + 111 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + SCONTOUT + + + mov + + + SBUSY + + + SDATAOUT + + + jmp + TheInterrupt + Loop + + + ProcEnd + noret + + + + + + + + + al, + ah + + + + + + + + + ProcBegin@ + GetTheInterrupt + + + + + + + + + mov + al, + cs:[di].Sr5IntVector + H + + + mov + Cx, + CS + F + + + mov + bx, + cs:[di].Sr5IntRoutineVec + ; + + + GenSetRevector + A + + + ret + , + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + EnableTheInterrupt + + + + + + + + + mov + al, + SerialReadSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + or + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + if + Asic9 + + + in + al, + A9BInterruptMaskRW + ; + + + or + al, + cs: + [di].Sr5Mask + ; + + + out + A9BInterruptMaskRwW, + al + + + else + + + in + al, + AlInterruptMask + + + or + al, + cs: + [di] + .Sr5Mask + + + out + AlInterruptMask, + al + + + endif + + + ret + + + ProcEnd + noret + + + ProcBegin@ + StopInterrupts + + + ; + StessSeSesee—e-Seeeseeese + + + mov + al, + SerialReadSingle + or + A5IntMask + H + + + SBUSY + ; + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + not + (S_RXENB + or + S_TXENB + or + S_MDINT) + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + mov + ah, + cs: + [di].Sr5Mask + + + not + ah + + + if + Asic9 + + + in + al, + A9BInterruptMaskRW + ; + + + and + al,ah + ; + + + out + A9BInterruptMaskRW, + al + ; + + + else + ; + + + in + al, + AlInterruptMask + + + and + al,ah + + + out + AlInterruptMask, + al + + + endif + + + mov + al, + cs:[di].Sr5IntVector + + + GenResetRevector + + + ret + + + + + + + + + Revision + 1.00 + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Load + the + address + of + + + the + appropriate + + + interrupt + routine + + + into + the + correct + + + vector + + + + + + + + + Set + the + mask + + + to + enable + Interrupts + + + + + + + + + Stop + interrupts + + + from + Asic5 + + + + + + + + + Stop + Interrupts + + + By + clearing + the + + + + + + + + + Mask + and + resetting + + + The + Vector + + + + + + + + + Page + 112 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + + + + + + + + + ProcEnd + noret + + + + + + + + + ProcBegin@ + CheckHardwarePresent + + + + + + + + + mov + al, + cs: + [bx] + .Sr5Channel + + + HwSelectChannel + + + HwNullFrame + + + mov + al, + (SerialSelect + or + Asic5Normalld) + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + al,al + + + je + ConnectionFailed + + + GotConnection: + + + popft + + + ous) + + + ret + + + ConnectionFailed: + + + mov + al, + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + + + jne + + + mov + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + + + jne + + + mov + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + ConnectionFailedExit: + + + popft + + + stc + + + ret + + + ProcEnd + noret + + + + + + + + + SerialSelect + or + Asic4Id + + + + + + + + + al, + al + + + ConnectionFailedExit + + + al, + SerialSelect + or + Asic8Id + + + + + + + + + al, + al + + + ConnectionFailedExit + + + al, + SerialSelect + or + Asic5PackId + + + + + + + + + ProcBegin@ + CheckHardwareFromStart + + + + + + + + + pushf + + + + + HwNullFrame + + + + + mov + al, + (SerialSelect + or + Asic5Normalld) + + + SBUSY + + + + + SCONTOUT + + + + + XNOP + + + + + SBUSY + + + + + SDATAIN + + + + + test + al,al + + + + + je + ConnectionFailed + + + + + test + al, + mask + A5MultiDrop + + + + + jne + ConnectionFailedExit + + + + + popft + + + mov + + + SBUSY + + + SCONTOUT + + + mov + + + SBUSY + + + SDATAOUT + + + cle + + + + + ret + + + ProcEnd + noret + + + + + + + + + al, + + + + + + + + + al, + S_PERIPHERALMODE + + + + + + + + + ProcBegin@ + WaitTimer + + + + + + + + + Revision + 1.00 + + + + + + + + + SerialWriteSingle + or + A5PortBMode + + + + + + + + + Ne + Ne + Ne + Ne + te + + + + + + + + + Ne + Ne + Ne + Ne + Ne + + + + + + + + + + + + + + + + + + Psion + PLC + (c) + May + 1995 + + + + + + + + + Check + that + the + + + ; + Harware + is + there + + + + + + + + + And + that + it + is + what + + + It + should + be + + + + + First + look + for + An + + + ASIC4 + at + the + other + + + End + of + the + link + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Asic4 + Id + + + + + + + + + Modem + chip + Id + + + + + + + + + Asic5Spack + Id + + + + + + + + + Check + that + the + + + Harware + is + there + + + First + look + for + An + + + ASIC5 + at + the + other + + + End + of + the + link + + + + + + + + + + + + + + + + + + + + + + + + If + not + a + 3link + or + + + if + in + multidrop + + + mode + then + we + are + + + in + trouble + + + + + + + + + Put + the + 3Link + in + + + peripheral + mode + + + + + + + + + Page + 113 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + In: + CX + number + of + ms + to + wait + for + + + Channel + store + in + DL + + + Out: + Channel + store + in + DL + + + + + + + + + Wait + for + a + given + + + + + + + + + inc + cx + i + + + + + WaitTickLoop: + ; + Number + of + ms + + + call + TickTimer + ; + Plus + one + to + guarantee + + + loop + WaitTickLoop + ; + That + at + least + cx + ms + + + ret + 7 + Go + by + + + ProcEnd + + + + + + + + + WaiterLoop: + + + + + + + + + stack + + + stack + + + + + + + + + ProcBegin@ + TickTimer + + + + + + + + + Uses + writes + down + our + channel + to + simulate + tick + timer + waits + + + + + Must + allow + interrupts + so + other + things + can + run + -we + will + be + here + + + for + 1/1000 + of + a + second + and + may + be + called + many + times + + + ChannelStore + in/out + in + DL + + + + + + + + + mov + al, + dl + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + + + mov + ah, + al + + + pushf + + + + + sez + + + + + push + Cx + + + + + mov + cx, + 12 + ims + + + + + 128 + frames + =1lms + + + + + pushf + about + 12 + times + + + + + cli + 7 + round + the + loop + + + + + out + ResetWatchDog, + al + + + + + mov + al, + ah + + + + + HwSelectChannel + + + + + mov + dl, + al + ; + Get + Correct + channel + + + mov + al, + (SerialWriteSingle + or + 0) + Do + a + write + to + + + + + SBUSY + nowhere + and + + + + + SCONTOUT + waste + some + time + + + + + + + + + See + Ne + + + + + + + + + See + Ne + + + + + + + + + SCONTOUT + ; + Do + it + eight + times + + + + + + + + + SBUSY + + + SCONTOUT + + + SBUSY + + + mov + al, + dl + + + HwSelectChannel + + + mov + ah, + al + + + popft + + + + + loop + WaiterLoop + + + pop + CX + + + + + popft + + + + + mov + al, + ah + + + HwSelectChannel + + + mov + dl, + al + + + ret + + + + + ProcEnd + + + + + + + + + Return + the + old + + + channel + + + + + + + + + + + + + + + + + + + + + EndCodeSeg + + + + + + + + + segment + stack + para + 'data' + + + ends + + + + + + + + + end + OsAS5PDD + + + + + + + + + Revision + 1.00 + Page + 114 + of + 115 + pages + + + + + + + + + + + + + + + + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + + + + + + + + + Assembler + Macros + + + + + + + + + Excerpts + from + the + include + file + ossibo.inc. + + + + + + + + + if + ASIC1 + + + SCONTOUT + macro + + + out + A2SerialControl, + al + + + endm + + + SDATAOUT + macro + + + out + A2SerialData, + al + + + endm + + + SBUSY + macro + + + wait + + + endm + + + SREAD + macro + _REG + + + mov + al, + SerialReadSingle + or + _REG + + + out + A2SerialControl, + al + + + nop + + + SBUSY + + + in + al, + A2SerialData + + + endm + + + SREADM + macro + _REG + + + mov + al, + SerialReadMulti + or + _REG + + + out + A2SerialControl, + al + + + nop + + + SBUSY + + + in + al, + A2SerialData + + + endm + + + SWRITE + macro + _REG,_VAL + + + mov + al, + SerialWriteSingle + or + _REG + + + out + A2SerialControl, + al + + + SBUSY + + + mov + al, + _VAL + + + out + A2SerialData, + al + + + endm + + + SWRITEM + macro + _REG,_VAL + + + mov + al, + SerialWriteMulti, + _REG + + + out + A2SerialControl, + al + + + SBUSY + + + mov + al, + _VAL + + + out + A2SerialData, + al + + + endm + + + endif + + + ach + ASIC9 + + + SCONTOUT + macro + + + out + A9BSerialControlW, + al + + + endm + + + SDATAOUT + macro + + + out + A9BSerialDataRW, + al + + + endm + + + SDATAIN + macro + + + in + al, + A9BSerialDataRW + + + endm + + + SBUSY + macro + + + endm + + + SREAD + macro + _REG + + + mov + al, + SerialReadSingle + or + _REG + + + out + A9BSerialControlwW, + al + + + in + al, + A9BSerialDataRW + + + endm + + + SREADM + macro + _REG + + + mov + al, + SerialReadMulti + or + _REG + + + out + A9BSerialControlwW, + al + + + in + al, + A9BSerialDataRW + + + endm + + + SWRITE + macro + _REG,_VAL + + + mov + al, + SerialWriteSingle + or + _REG + + + out + A9BSerialControlwW, + al + + + mov + al, + _VAL + + + out + A9BSerialDataRW, + al + + + endm + + + SWRITEM + macro + _REG,_VAL + + + mov + al, + SerialWriteMulti + or + _REG + + + out + A9BSerialControlwW, + al + + + mov + al, + _VAL + + + out + A9BSerialDataRW, + al + + + endm + + + endif + + + + + + + + + Revision + 1.00 + Page + 115 + of + 115 + pages + + + + + + + + + diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr.html b/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr.html new file mode 100755 index 0000000..35cf6ab --- /dev/null +++ b/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr.html @@ -0,0 +1,72601 @@ + + + + + + + + + + +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + THE + PSION + SIBO + HARDWARE + DEVELOPMENT + KIT + +

+
+
+

+ + Version + 1.00 + +

+
+
+

+ + May + 26 + 1995 + +

+
+
+

+ + Revision + 1.00 + Page + i + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + (c) + Copyright + Psion + PLC + 1990-93 + +

+
+
+

+ + All + rights + reserved. + This + manual + and + the + programs + referred + to + herein + are + copyrighted + works + of + Psion + + + PLC, + London, + England. + Reproduction + in + whole + or + part, + including + utilisation + in + machines + capable + of + + + reproduction + or + retrieval, + without + express + written + permission + of + Psion + PLC, + is + prohibited. + Reverse + + + engineering + is + also + prohibited. + +

+
+
+

+ + The + information + in + this + document + is + subject + to + change + without + notice. + +

+
+
+

+ + Psion + and + the + Psion + logo + are + registered + trademarks, + and + Psion, + Psion + MC, + Psion + HC, + Psion + Series + 3, + + + Psion + Series + 3a + and + Psion + Workabout + are + trademarks + of + Psion + PLC. + +

+
+
+

+ + TopSpeed + is + a + registered + trademark + of + Clarion + Software + Corporation. + Intel + 8086 + and + 80286 + are + + + registered + trademarks + of + Intel + Corporation. + IBM, + IBM + XT + and + IBM + AT + are + registered + trademarks + of + + + International + Business + Machines + Corp. + Microsoft + and + MS-DOS + are + registered + trademarks + of + + + Microsoft + Corporation. + Apple + and + Macintosh + are + registered + trademarks + of + Digital + Equipment + + + Corporation. + Brief + is + a + registered + trademark + of + Underware + Inc. + Psion + PLC + acknowledges + that + some + + + other + names + referred + to + are + registered + trademarks. + +

+
+
+

+ + Revision + 1.00 + Page + ii + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Contents + +

+
+
+

+ + + + + De + IMGrOMUCUON + sec + ioiciescccetisshicattxstcathaslicatixssdcstenslacatenstecatenslicatinssdesvenslacevinswdvatensldcsvisatibiteislacibedse + +

+
+
+

+ + 2. + System + Overview..........scccccscssccssssscscsscsseccsscssecssccsesssscssesssscsssesscssesssssesssscssssssscssssssscsessssesesseeees + +

+
+
+

+ + 3. + Hardware + Overview + .........sssccssssssssssscssscssscsssssssesssesssesssesssesssssssssessscssscsssessesssesssnssseesscseoeeees + + + The + Psion + SIBO + serial + protocol + .... + + + Psion + ASICs + and + what + they + do.. + + + Interrupts + . + + + The + current + range + of + Psion + periphera + +

+
+
+

+ + 4. + The + Psion + SIBO + Serial + Protocol + . + + + Hardware + Interface + ... + + + The + Physical + layer + . + + + The + Transport + layer + .. + +

+
+
+

+ + 5. + Mechanical + Overview + ...........sscssscsssssrscsssssessscessecssessessssesseessessscesssessesscssssssscsssessccssesssessosees + LD + + + The + Psion + Series + 3/3a + range + ... + + + The + Psion + Workabout + + + The + Psion + HC + range + +

+
+
+

+ + 6. + ASIC + 4......... + + + ASIC4 + Addressing + and + Modes + + + Reset + and + configuration + + + ASIC4 + Pin-out + +

+
+
+

+ + 7. + ASIC + 5.......scesee + + + ASICS + Mode + + + Reset + and + configuration + + + ASICS + Pin-out + +

+
+
+

+ + 8. + Example + Peripheralls................cccssccssssssssssssseccsscscccssssscsssscccesssscscesssssesssscsssssssssesscsssssscsseeesess + OO + + + The + ASIC4 + Example + Interface + Board.. + + + The + Psion + 3-Link + +

+
+
+

+ + 9. + Device + Driver + Overview...........cccsrsercesssserscersserecssecssesscesssesesssessssessesssesscsscssscsssssssesssessosees + OT + + + Introduction + + + Device + Names + and + Channel: + + + Loadable + Logical + Device + Driver + Structure + + + Mandatory + LDD + Functions + ............... + + + Interrupts + and + Interrupt + Service + Routines + at + + + Loadable + Physical + Device + Driver + Structure... + ccscecesesesseesssesssesesssesesesescseseseenenesesesesesesenenesseesesesusueasaeaeseeessecacaeaeaeenenssesecasaseeeeeneeeeeaeaes + +

+
+
+

+ + 10. + ASIC4/ASIC5 + Based + Device + Drivers + +

+
+
+

+ + Introduction + + + SIBO + Hardware + Expansion + Channels + + + Talking + to + ASIC4.. + + + ASIC4 + Registers + + + Talking + to + ASICS + .. + + + ASICS + Registers... + + + Communicating + with + ASIC4 + + + Sending + and + Receiving + data + using + ASIC4. + + + Obtaining + and + using + a + channel... + + + Controlling + ASICS's + UART + + + Hold + and + Resumes. + + + Example + Device + Driver: + +

+
+
+

+ + 11. + An + Example + Device + Driver + for + ASIC4: + A4EXIF.LDD.. + +

+
+
+

+ + Introduction + +

+
+
+
+
+
+

+ + oo + TO + eR + UU + RS + gs + pad + +

+
+
+
+
+
+
+
+

+ + Mandatory + LDD + Function: + + + The + Non-Mandatory + LDD + Functions..........cceee + + + The + handling + of + synchronous + and + asynchronous + I/O + + + Interrupts + and + Interrupt + Service + Routines + + + Other + important + local + device + driver + functions + + + Structures + and + Include + files + «0... + cee + +

+
+
+

+ + 12. + An + Example + Device + Driver + for + ASIC5: + SYS$AS5.PDD.............ssssssssssssssessessessssesscsessessesseee + 77 + +

+
+
+

+ + Introduction + + + The + LDD-PDD + interface. + +

+
+
+

+ + 13. + Debugging + and + Testing + Device + Drivers + + + Introduction + .... + + + Debugging + Techniqu + + + Further + Testing + Strategies + ae + + + Memory + Lestitng + seiscs + lech + easch + oiece + siscn + Sates + losecdestecwcsautsse + sean + tosevaleslosedtracepudtesiiensdertoanioenteoisebeensse + bait + es + ieettaus + adanus + teats + a + a + tanta + eae + +

+
+
+

+ + APPENDIX: + Source + Code + Files.. + + + A4EXIF.ASM + oo + + + SYS$AS5.ASM + .... + 102 + + + Assembler + Macros. + 1S + +

+
+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + iii + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 1. + INTRODUCTION + +

+
+
+

+ + This + document + is + intended + to + provide + guidance + to + anyone + wishing + to + construct + peripherals + for + the + + + Psion + SIBO + (sixteen + bit + organiser) + range + of + computers. + It + describes + in + detail + all + aspects + of + Psion + + + peripheral + hardware + development + and + the + structure + of + the + software + required + to + drive + such + peripherals. + + + It + is + the + aim + of + this + document + to + aid + third + party + development + engineers + in + producing + production + ready + + + peripherals + for + any + of + the + following + Psion + products: + Series + 3/3a, + Workabout, + HC + and + HCDOS. + + + Mechanical + and + plastic + moulding + information + and + information + on + how + to + develop + production + test + + + equipment + is + therefore + also + included. + The + emphasis + throughout + is + on + the + two + key + Psion + peripheral + + + chips + ASIC4 + and + ASIC5. + Detailed + information + regarding + their + functionality + is + provided. + The + + + structure + of + Psion + hardware + device + drivers + is + examined + both + in + general + outline + and + then + with + regard + to + + + two + specific + examples + whose + source + code + is + provided + in + the + appendix + to + this + document. + It + has + been + + + assumed + that + the + reader + has + some + knowledge + of + a + Psion + computer + such + as + the + Series + 3/3a + and + an + + + understanding + of + how + such + a + machine + is + programmed. + A + good + understanding + of + electronics, + the + C + + + programming + language + and + 8086 + assembler + is + also + assumed. + +

+
+
+

+ + Due + to + the + continuous + nature + of + development, + information + in + this + manual + may + change + without + notice. + +

+
+
+

+ + Developers + are + advised + to + contact + Psion + Support + to + confirm + critical + details + prior + to + committing + + + products + to + manufacture. + +

+
+
+

+ + Revision + 1.00 + Page + | + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 2. + SYSTEM + OVERVIEW + +

+
+
+

+ + All + present + Psion + computers + are + based + around + the + proprietary + SIBO + architecture. + A + SIBO + machine + is + + + a + battery-powered, + 8086-based, + computer + system. + SIBO + stands + for + SIxteen + Bit + Organiser. + The + + + architecture + has + been + designed + with + the + size, + weight + and + power + consumption + of + computers + designed + + + for + the + portable + environment + in + mind. + The + key + components + of + the + SIBO + architecture + are: + +

+
+
+

+ + e + —_ + An + 8086 + class + processor + . + +

+ +

+ + e + A + sophisticated + power + management + system + that + selectively + powers + subsystems + under + software + + + control. + +

+ +

+ + e + + Asynchronous, + high + speed, + serial + protocol + (the + Psion + SIBO + serial + interface) + for + communication + + + between + a + machine + and + its + peripherals. + +

+ +

+ + e + —_ + Solid + State + Disks + (SSDs) + that + provide + fast, + low-power, + silicon-based + mass + storage + with + no + + + moving + parts. + +

+ +

+ + e + Hardware + protection + of + the + system + from + aberrant + software + processes + (trapping + of + out + of + range + +

+ +

+ + addressing + and + a + watch-dog + timer + on + interrupts + being + disabled). + +

+ +

+ + Real-time + clock. + +

+ +

+ + ROM-resident + system + software. + +

+ +

+ + Graphics + LCD + display. + +

+ +

+ + A + touch + sensitive + digitising + pad + that + provides + a + pointing + device + (only + available + on + some + models). + +

+ +

+ + ISDN-8bit + standard + combo + sound + system + (only + available + on + some + models). + +

+
+
+

+ + The + SIBO + architecture + has + primarily + been + implemented + in + custom + ICs + called + ASICs. + At + the + time + of + + + writing + there + are + ten + different + SIBO + ASICs. + Some + of + these + ASICs + have + been + designed + for + use + inside + + + peripherals + and + these + will + discussed + in + detail + throughout + this + document. + All + SIBO + ASICs + have + been + + + implemented + in + surface + mount + packages + and + are + based + on + a + static + CMOS + technology. + Current + SIBO + + + products + in + the + MC, + HC + and + Series + 3 + range + are + based + on + the + same + three + principal + chips. + These + are + + + the + V30H + (an + 8086-compatible + processor) + and + two + Psion + custom + chips + known + as + ASIC1 + and + ASIC2. + + + Later + SIBO + products + including + the + Series + 3a + and + Workabout + have + these + three + devices + integrated + into + a + + + single + Psion + custom + chip + known + as + ASIC9. + The + V30H + is + an + enhanced + 16-bit + CMOS + version + of + the + + + 8088 + found + in + the + original + IBM + PC. + It + is + software + compatible + with + the + 8088. + The + V30H + is + a + fully + + + static + design + which + means + that + all + the + internal + storage + elements + (i.e. + its + registers) + are + made + from + static + + + rather + than + dynamic + storage + components. + This + in + turn + means + that + there + is + no + minimum + clock + speed + + + required + to + refresh + the + storage + elements + and + the + system + clock + can + be + stopped + at + any + time + with + no + loss + + + of + internal + state. + This + technique + is + used + extensively + in + the + SIBO + architecture + to + save + power + while + the + + + processor + is + idle + (i.e. + waiting + for + an + event). + +

+
+
+

+ + The + Psion + SIBO + serial + protocol + is + a + proprietary + synchronous + two + wire + serial + standard + by + which + host + + + Psion + handhelds + communicate + with + external + devices. + These + devices + will + typically + be + Memory + Packs + + + (usually + referred + to + as + Solid + State + Disks + or + SSDs), + RS232 + and + Centronics + printer + interfaces, + fax + + + modems, + bar-code + scanners, + and + so + on. + The + SIBO + architecture + provides + for + two + basic + forms + of + + + expansion + device, + namely + the + extended + internal + expansion + connection + (as + with + SSDs) + and + the + reduced + + + external + expansion + connection + (the + 6-pin + S3a + serial + port + or + the + 11-pin + LIF + connector). + The + MC + and + + + HC + range + of + computers + have + two + SSD + ports + and + two + separate + independent + single + row + 25-way + + + extended + internal + expansion + ports. + These + ports + have + in + addition + to + a + Psion + SIBO + Channel, + direct, + + + parallel + I/O + from + the + processor. + Direct + connection + to + these + machines + 7.2 + volt + battery + is + included + to + + + support + high + power + peripherals + such + as + Printers + and + Barcode + readers. + The + Series + 3 + range + of + + + computers + have + two + ports + for + SSDs + and + a + single, + reduced, + 6-pin + expansion + port, + which + provides + only + a + + + Psion + SIBO + serial + channel + and + limited + power + (<25mA). + The + Psion + Workabout + has + two + SSD + ports, + + + two + internal + expansion + points, + and + one + external + expansion + port. + The + single + external + expansion + port + + + uses + an + | + 1-pin + Low + Insertion + Force + (LIF) + socket + which + provides + a + Psion + SIBO + channel, + 25mA + of + + + current + and + additional + lines + required + for + detecting + the + presence + of + the + Workabout + cradle. + Each + + + internal + expansion + port + consists + of + a + single + row + 26-way + connector + carrying + two + high + speed + serial + + + ports. + +

+
+
+

+ + Revision + 1.00 + Page + 2 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + A + range + of + Psion + peripherals + have + been + produced + for + connection + to + the + Psion + handhelds + outlined + + + above. + These + peripherals + currently + incorporate + one + of + two + custom + integrated + circuits + (ASIC4 + and + + + ASICS) + that + convert + SIBO + serial + protocol + signals + to + data + bus + TTL + level + voltages + which + enable + + + memory + and + memory-mapped + peripherals + to + be + addressed. + ASIC4 + is + used + in + SSDs + and + for + memory- + + + mapped + peripherals. + A + typical + ASIC4 + peripheral + for + a + Psion + S3a + would + consist + of + an + ASIC4 + + + connected + to + port + C + of + the + host + machine + and + a + peripheral + chip/device + mapped + into + ASIC4's + addressing + + + space. + ASICS + is + a + general + purpose + I/O + chip + with + a + UART + on + board + that + can + be + run + in + several + + + different + modes. + For + example + ASICS + can + be + used + for + MCRs + (magnetic + card + readers) + or + Centronics + + + interfaces + thereby + simplifying + peripheral + design. + Psion + extended + internal + expansion + ports + carries + an + + + active + low + interrupt + input + line + to + the + host + controller + circuitry. + The + reduced + external + expansion + ports + + + has + an + active + high + interrupt + input + line. + The + function + of + the + interrupt + can + thus + be + programmed + into + the + + + host + machine's + ASIC1 + or + ASIC9. + +

+
+
+

+ + The + low-level + programming + interface + to + a + Psion + handheld + peripheral + is + encapsulated + within + an + + + appropriate + device + driver. + Psion + device + drivers + are + written + in + 8086 + assembler + and + follow + a + prescribed + + + pattern + outlined + later + in + this + document. + The + construction + of + a + peripheral + and + the + coding + of + its + + + complimentary + device + driver + enable + the + developer + to + access + its + functionality + through + the + means + of + + + library + calls + in + a + C + program. + Examples + of + such + calls + are + p_loadldd(), + p_open() + and + p_close(). + + + I/O + requests + are + routed + through + the + device + driver's + strategy + vector + which + maps + to + the + PLIB + p_iow + () + + + call. + The + device + driver + is + built + using + the + Borland + Turbo + Assembler + and + resides + in + a + single + code + + + segment. + The + device + driver + can + be + stored + in + either + RAM + or + a + ROM + on + board + the + peripheral + or + can + be + + + supplied + on + an + SSD + (solid + state + disk). + +

+
+
+

+ + Revision + 1.00 + Page + 3 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 3. + HARDWARE + OVERVIEW + +

+
+
+

+ + The + Psion + SIBO + serial + protocol + +

+
+
+

+ + The + Psion + SIBO + serial + protocol + is + a + general + purpose + method + of + bi-directional + serial + data + transfer. + It + + + has + been + designed + for + synchronous + communication + between + a + host + controlling + device + and + a + number + of + + + slave + devices. + On + a + hardware + level, + the + SIBO + serial + protocol + is + implemented + through + Psion + ASICs. + + + The + controlling + device + must + contain + an + ASIC2 + (or + ASIC9) + and + the + slave + devices + an + ASIC4 + or + ASICS. + + + The + various + Psion + ASICs + are + described + in + more + detail + below. + +

+ +

+ + The + synchronous + SIBO + serial + protocol + interface + consists + of + 2 + wires: + +

+ +

+ + CLK + ~ + - + Aclock + output + from + the + controller + to + the + slaves. + Nominally + 3.84 + MHz. + +

+ +

+ + DATA + - + A + bi-directional + synchronous + data + line. + +

+ +

+ + The + data + is + transferred + using + a + series + of + 12 + bit + frames + including + 8 + data + bits + each. + This + equates + to + a + + + theoretical + maximum + data + transfer + rate + of + approximately + 312 + Kbytes/second. + Other + bits + of + the + frame + + + contain + control + information. + The + "system" + is + generically + defined + by + 2 + protocol + layers, + namely + the + + + Physical + layer + and + the + Transport + layer. + These + layers + are + described + in + detail + in + the + next + chapter. + +

+
+
+

+ + Psion + ASICs + and + what + they + do + +

+
+
+

+ + ASIC + stands + for + Application + Specific + Integrated + Circuit + and + as + previously + indicated, + these + devices + are + + + widely + used + within + Psion + hardware. + Summaries + of + the + functionality + of + each + ASIC + that + is + relevant + to + + + peripheral + development + are + presented + below: + +

+
+
+

+ + ASIC1: + ASIC1 + is + the + main + system + controller + chip + for + the + SIBO + architecture. + It + connects + directly + to + + + the + 8086-based + processor + (i.e. + the + V30H) + controlling + all + bus + cycles + to + and + from + the + processor. + This + + + configuration + effectively + forms + a + micro-controller + like + device + that + executes + 8086 + instruction + codes. + + + ASIC + 1 + is + made + up + of + a + number + of + functional + blocks + including + a + bus + controller, + a + programmable + + + timer, + an + eight + input + interrupt + controller, + an + LCD + controller + and + the + memory + decoding + circuitry. + +

+
+
+

+ + ASIC2: + ASIC2 + is + the + peripheral + controller + chip + for + the + SIBO + architecture. + It + contains + the + system + + + clock + oscillator + and + controls + switching + between + the + standby + and + operating + states. + ASIC2 + provides + an + + + interface + to + the + power + supply, + keyboard, + buzzer + and + SSDs. + ASIC + 2 + includes + the + eight-channel + SIBO + + + serial + protocol + controller + and + provides + interface + circuitry + to + both + the + reduced + external + and + extended + + + internal + peripheral + expansion + ports. + +

+
+
+

+ + ASIC4: + ASIC4 + is + a + serial + protocol + slave + IC + for + addressing + memory + and + general + memory-mapped + + + peripherals. + It + is + used + in + SSDs + to + convert + SIBO + serial + protocol + signals + into + addresses + within + the + + + memory + range + of + the + memory + pack. + ASIC4 + was + designed + to + be + a + cut-down + version + of + ASICS + which + + + was + the + original + SIBO + serial + protocol + slave + chip. + +

+
+
+

+ + ASICS: + ASICS + is + a + general + purpose + I/O + chip + with + a + built-in + UART + that + can + be + set + to + run + in + a + number + + + of + different + modes + thereby + simplifying + the + task + of + peripheral + design. + For + example, + it + is + possible + to + set + + + up + ASICS + to + run + as + a + Centronics + parallel + port + interface, + an + 8-bit + parallel + I/O + port, + a + serial + bar + code + + + controller + or + a + serial + RS232 + converter. + +

+
+
+

+ + ASIC9: + ASIC9 + is + a + composite + chip + comprising + of + a + V30H + processor, + ASIC1, + ASIC2 + and + general + I/O + + + and + PSU + control + logic + all + on + one + IC. + ASIC9 + thus + integrates + all + the + digital + logic + required + to + produce + a + + + SIBO + architecture + computer + less + the + memory + onto + one + chip. + ASIC9 + has + a + few + additional + features + + + such + as + an + extra + free-running + clock + (FRC) + and + a + codec + interface + for + sound. + +

+
+
+

+ + Revision + 1.00 + Page + 4 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Interrupts + +

+
+
+

+ + Psion + peripherals + usually + incorporate + some + circuitry + to + generate + hardware + interrupts. + Both + reduced + + + external + expansion + ports + (such + as + the + LIF + connector + on + the + Workabout + or + the + 6-pin + serial + port + + + connector + on + the + S3a) + and + extended + internal + expansion + ports + (such + as + the + two + single + row + 25-way + HC + + + connectors) + carry + an + interrupt + line. + This + is + an + active + high + input + to + the + host + machine's + interrupt + + + controller + circuitry + which + resides + on + the + logical + equivalent + of + ASIC1. + The + OS + intercepts + all + interrupts + + + and + can + be + requested + to + call + a + particular + function + within + a + controlling + device + driver. + Eight + hardware + + + interrupts + are + supported + by + SIBO + hardware. + IRQO + is + the + highest + priority + and + IRQ7 + the + lowest. + All + + + interrupts + are + level + triggered + and + must + be + serviced + in + the + following + order: + +

+ +

+ + e + Device + asserts + the + appropriate + interrupt + request + line. + +

+ +

+ + e + The + interrupt + controller + unit + within + either + ASIC2 + or + ASIC9 + places + onto + the + data + bus + the + vector + of + + + the + highest + priority + device + with + an + interrupt + pending. + This + enables + the + CPU + to + jump + to + the + + + correct + interrupt + service + routine + code. + +

+ +

+ + e + During + the + interrupt + service + routine, + the + software + clears + the + interrupt + line + by + some + action + specific + + + to + the + device. + +

+ +

+ + e + The + interrupt + service + routine + then + informs + the + interrupt + controller + that + the + interrupt + has + been + + + cleared + by + writing + to + the + non-specific + end + of + interrupt + (NSEOD) + location. + +

+ +

+ + e + If + another + interrupt + is + pending + then + go + back + to + the + second + step. + +

+ +

+ + With + 8086-based + processors, + it + is + not + possible + to + have + nested + interrupts. + +

+
+
+

+ + The + current + range + of + Psion + peripherals + +

+
+
+

+ + There + are + currently + a + number + of + Psion + peripherals + in + use + and + some + of + the + key + ones + are + outlined + below + + + in + order + to + provide + the + developer + with + a + feel + for + peripheral + design + issues: + +

+ +

+ + SSDs: + Solid + State + Disks + (or + Memory + Packs) + use + a + built-in + ASIC4 + to + decode + SIBO + serial + protocol + + + signals + into + memory + addresses + within + the + memory + range + of + the + SSD. + +

+ +

+ + Psion + 3-link: + The + 3-link + translates + the + high + speed + SIBO + serial + protocol + channel + on + the + S3a + 6-pin + + + reduced + external + expansion + socket + into + a + serial + RS232 + format. + This + enables + the + host + machine + to + + + communicate + with + a + PC + for + example + by + means + of + connecting + the + 3-link + unit + from + the + handheld's + 6-pin + + + port + to + the + PC's + COM1 + or + COM2 + port. + The + 3-link + contains + an + ASICS + which + uses + its + on-board + UART + + + to + convert + SIBO + serial + protocol + signals + to + RS232 + format + TTL + level + voltages. + +

+ +

+ + The + HC + Printer: + The + HC + Printer + translates + SIBO + serial + protocol + signals + transmitted + across + the + single + + + row + 25-way + extended + internal + expansion + socket + of + the + host + HC + into + a + parallel + 8-bit + format + that + is + + + compatible + with + the + universal + Centronics + printer + interface + standard. + The + HC + Printer + unit + contains + an + + + ASICS + running + in + Centronics + interface + mode + which + acts + as + the + serial + protocol + slave + and + requires + a + + + small + number + of + support + chips. + +

+ +

+ + Psion + 3-Fax: + The + 3-Fax + contains + an + ASIC4 + and + a + memory-mapped + modem + chip + set + which + permits + the + + + host + machine + to + transmit + (but + not + receive) + fax + messages. + +

+ +

+ + Barcode: + The + Psion + Barcode + reader + employs + an + ASICS + running + in + serial + mode + to + read + the + data + + + received + from + the + barcode + decoder + chip + into + a + SIBO + serial + protocol + format + that + can + be + transmitted + to + + + the + host + ASIC2/ASIC9. + +

+ +

+ + Workabout + RS232 + Interface: + This + peripheral + connects + to + the + single + row + 26-way + extended + internal + + + expansion + port + of + the + Workabout. + It + incorporates + an + ASICS + running + in + its + default + mode + to + translate + + + SIBO + serial + protocol + signals + into + a + TTL + level + (+/-5v) + serial + RS232 + format + using + ASIC5's + on-board + + + UART. + The + TTL + level + RS232 + signals + are + converted + into + the + standard + EIA + format + (+/-12v) + before + + + coming + out + on + the + conventional + RS232 + 9-pin + D-type + connector. + +

+
+
+

+ + Revision + 1.00 + Page + 5 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 4. + THE + PSION + SIBO + SERIAL + PROTOCOL + +

+
+
+

+ + Introduction + +

+
+
+

+ + The + Psion + SIBO + serial + protocol + is + a + proprietary + standard + for + bi-directional + serial + data + transfer + between + +

+ +

+ + a + controlling + device + and + a + number + of + slave + devices. + The + synchronous + interface + consists + of + 2 + wires + +

+ +

+ + CLK + and + DATA + as + mentioned + earlier: + +

+ +

+ + CLK + _~ + - + Aclock + output + from + the + controller + to + the + slaves. + Nominally + 3.84 + Mhz + for + memory + +

+ +

+ + interfaces + or + 1.536.Mhz + continuous + for + peripherals. + +

+ +

+ + DATA + - + A + bi-directional + synchronous + data + line. + +

+ +

+ + The + data + is + transferred + using + a + series + of + 12 + bit + frames + including + 8 + data + bits + each. + This + equates + to + a + +

+ +

+ + theoretical + maximum + data + transfer + rate + of + approximately + 312 + Kbytes/second. + Other + bits + of + the + frame + +

+ +

+ + contain + control + information. + The + "system" + is + generically + defined + by + 2 + protocol + layers:- + +

+ +

+ + e + The + Physical + layer + defining + the + hardware + interface + and + frame + structure. + +

+ +

+ + e + The + Transport + layer + defines + system + control + and + register + transfers + between + the + controller + and + the + + + slaves. + +

+ +

+ + Using + this + system, + a + large + number + of + higher + level + implementations + can + be + defined. + In + normal + use + the + +

+ +

+ + controller + will + communicate + to + slaves + in + a + point + to + point + configuration. + Multidrop + configurations + with + +

+ +

+ + a + number + of + slaves + attached + to + one + channel + of + the + controller + are + also + supported. + +

+
+
+

+ + As + indicated + in + the + previous + chapter, + the + SIBO + serial + protocol + controller + circuitry + resides + in + either + an + + + ASIC2 + or + an + ASIC9 + depending + on + the + particular + Psion + hardware + platform. + The + S3a + and + Workabout + + + employ + ASIC9 + whereas + the + HC, + MC + and + S3 + use + ASIC2. + +

+
+
+

+ + Hardware + Interface + +

+
+
+

+ + As + indicated + above, + the + SIBO + serial + protocol + consists + of + two + lines + that + switch + at + 5V + CMOS + voltage + + + levels: + +

+
+
+

+ + Clock + Line + +

+
+
+

+ + This + line + is + used + to + synchronously + clock + data + between + the + controller + and + slaves. + It + is + always + output + + + from + the + controller + circuitry + that + resides + in + ASIC2/ASIC9. + The + clock + should + only + be + active + during + the + + + transfer + of + data + or + when + the + serial + channel + is + continuous + clocking + mode + (used + by + ASICS). + At + all + other + + + times + it + is + tri-state + pulled + low. + +

+
+
+

+ + Clock + Timing + Parameters + +

+
+
+

+ + Parameter + + + Width + of + Clock + High + +

+
+
+

+ + Width + of + Clock + Low + + + Cycle + time + of + clock + + + Clock + Frequency + +

+
+
+
+

+ + Data + Line + +

+
+
+

+ + This + is + a + bi-directional + line + used + to + transfer + data + synchronously + between + the + controller + and + slaves. + + + The + direction + of + the + data + line + is + not + determined + by + the + physical + layer + but + by + the + control + information + in + + + the + transport + layer. + This + is + described + in + the + next + section. + When + no + data + transfers + are + in + progress + the + + + data + line + is + always + set + to + input + on + both + the + controller + and + slaves. + This + line + is + pulled + low. + Data + is + + + changed + on + the + falling + edge + of + clock + by + the + transmit + device + and + latched + into + the + receiving + device + on + + + the + rising + edge + of + the + clock. + +

+
+
+

+ + Revision + 1.00 + Page + 6 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + Physical + layer + +

+
+
+

+ + This + section + specifies + the + low + level + protocol + of + the + SIBO + serial + protocol. + The + physical + layer + protocol + + + consists + of + a + series + of + 12 + bit + frames. + There + are + four + types + of + frames:- + +

+ +

+ + Null + frames + - + Transmitted + by + controller + to + synchronise + slaves. + +

+ +

+ + Control + frames + - + Control + information + transmitted + by + controller + to + slaves. + +

+ +

+ + Data + output + frames + - + Data + frame + transmitted + by + controller + to + slaves. + +

+ +

+ + Data + input + frames + - + Data + frame + received + by + controller + from + a + slave. + +

+
+
+

+ + Frame + structure + +

+
+
+

+ + All + 12 + bit + frames + have + the + following + structure:- + +

+
+
+
+

+ + Bit + +

+ +

+ + Name + ST + +

+ +

+ + ST + Start + bit. + This + bit + goes + high + to + indicate + the + start + of + a + valid + frame. + +

+ +

+ + CTL + ~~ + Control + bit. + When + low + indicates + this + is + a + control + frame. + High + indicates + a + data + frame. + + + Il + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Normally + Low. + +

+ +

+ + DO-D7 + Data + bits. + +

+ +

+ + 12 + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Normally + low. + +

+ +

+ + Null + Frame + +

+
+
+

+ + This + is + a + special + frame + transmitted + by + the + controller + to + ensure + all + slaves + are + synchronised. + It + is + + + generated + by + transmitting + 12 + clock + pulses + with + the + data + line + set + to + input. + Since + the + data + line + is + pulled + + + low + this + results + in + 12 + zeroes + being + transmitted. + +

+
+
+

+ + Control + frame + +

+
+
+

+ + This + frame + is + transmitted + from + the + controller + to + one + or + more + slaves. + The + data + line + is + an + output + from + + + the + controller + throughout + the + whole + frame. + The + bits + in + the + frame + have + the + following + value + in + a + control + + + frame: + +

+
+
+

+ + ST + Start + bit. + This + bit + goes + high + to + indicate + the + start + of + a + valid + frame. + + + CTL + Control + bit. + Low + to + indicate + this + is + a + control + frame. + +

+ +

+ + I1 + Idle + bit + Set + low. + +

+ +

+ + DO-D7 + Data + bits. + 8 + bits + of + control + information. + +

+ +

+ + I2 + Idle + bit + Set + low. + +

+
+
+

+ + Data + Output + Frame + +

+
+
+

+ + This + frame + is + transmitted + from + the + controller + to + one + or + more + slaves. + The + data + line + is + an + output + from + + + the + controller + throughout + the + whole + frame. + The + bits + in + the + frame + have + the + following + value + in + a + data + + + output + frame: + +

+
+
+

+ + ST + Start + bit. + This + bit + goes + high + to + indicate + the + start + of + a + valid + frame. + + + CTL + Control + bit. + High + to + indicate + this + is + a + data + frame. + +

+ +

+ + Il + Idle + bit + Set + low. + +

+ +

+ + DO-D7 + Data + bits. + 8 + bits + of + transmitted + data. + +

+ +

+ + 12 + Idle + bit + Set + low. + +

+
+
+

+ + Data + Input + Frame + +

+
+
+

+ + This + frame + is + received + by + the + controller + from + a + slave. + The + data + line + is + an + output + from + the + controller + + + for + cycles + 1 + and + 2 + and + input + to + the + controller + for + cycles + 4 + to + 11. + The + bits + in + the + frame + have + the + + + following + value + in + a + data + input + frame: + +

+
+
+

+ + ST + Start + bit. + Output + from + controller. + This + bit + goes + high + to + indicate + the + start + of + a + valid + + + frame. + +

+ +

+ + CTL + Control + bit. + Output + from + controller. + High + to + indicate + this + is + a + data + frame. + +

+ +

+ + Il + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Both + controller + and + slave + +

+ +

+ + should + tri-state + the + data + line + during + this + bit. + This + bit + should + be + low + due + to + pull + +

+ +

+ + down + resistor + on + data + line. + The + controller + changes + the + data + line + from + output + to + +

+
+
+

+ + Revision + 1.00 + Page + 7 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + input + at + the + end + of + cycle + 2. + The + slave + changes + the + data + line + from + input + to + + + output + at + the + start + of + cycle + 4. + +

+
+
+

+ + DO-D7 + Data + bits. + Output + from + slave + 8 + bits + of + data + transmitted + by + slave. + Controller + sets + data + + + line + to + input + during + these + bits. + +

+ +

+ + 12 + Idle + bit. + Used + to + turn + around + direction + of + data + line. + Both + controller + and + slave + +

+ +

+ + should + tri-state + the + data + line + during + this + bit. + Should + be + low + due + to + pull + down + +

+ +

+ + resistor + on + data + line. + The + slave + changes + data + line + from + output + to + input + at + the + end + of + + + cycle + 11. + +

+
+
+

+ + Data + line + direction + +

+
+
+

+ + The + following + table + summarises + the + direction + of + the + data + line. + +

+
+
+

+ + CONTROLLER + SLAVE + + + Condition + CK + DATA + CK + +

+
+
+

+ + Outside + Frame + +

+ +

+ + Null + frame + +

+ +

+ + Control + Frame + +

+ +

+ + Data + output + from + controller + +

+ +

+ + Data + input + to + controller:- + + + Cycles + 1-2 + + + Cycle + 3 + + + Cycles + 4-11 + + + Cycle + 12 + +

+
+
+

+ + OO000 + 0004 + +

+
+
+
+

+ + Key + T + Tri-state + + + I + Input + + + O + Output + +

+
+
+

+ + The + Transport + layer + +

+
+
+

+ + This + section + specifies + the + transport + level + protocol + that + operates + above + the + SIBO + serial + communication + + + physical + layer. + The + transport + layer + protocol + controls + the + serial + communication + between + the + SIBO + + + Protocol + Controller + (SPC) + and + a + number + of + SIBO + Protocol + Slave + (SPS) + devices. + The + following + rules + + + apply:- + +

+ +

+ + 1) + The + interface + is + controlled + by + the + writing + of + control + bytes + from + the + controller + to + the + slaves. + Control + + + bytes + cannot + be + written + by + the + slaves. + +

+ +

+ + Unsolicited + data + cannot + be + sent + from + the + slave + to + the + controller. + +

+ +

+ + 2) + The + controlling + device + contains + two + registers + to + communicate + to + the + slaves. + These + are + the + control + + + register + (byte, + write + only) + and + the + Data + register + (byte + or + word, + read/write). + +

+ +

+ + Control + bytes + are + transmitted + to + the + slaves + by + writing + to + the + control + register. + +

+ +

+ + The + format + of + the + control + byte + is + as + follows:- + +

+
+
+
+

+ + The + control + word + can + have + 2 + distinct + formats + depending + on + the + setting + of + bit + 7 + the + Select + (S) + bit:- + + + Select + = + 0 + This + is + the + slave + select + mode. + This + mode + is + for + selecting, + deselecting + and + resetting + slaves. + + + Select + = + 1 + This + is + the + slave + control + mode. + This + mode + is + for + communicating + with + a + slave + which + has + + + been + previously + selected + using + the + select + slave + command. + +

+
+
+

+ + Revision + 1.00 + Page + 8 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Slave + select + mode + +

+
+
+

+ + The + format + of + the + slave + select + byte + is + as + follows:- + +

+
+
+
+

+ + Key:- + + + R + single + reset + bit. + + + TU + 6 + bit + ID + field. + +

+
+
+

+ + The + 6 + bit + ID + field + is + a + property + only + of + the + slave. + No + slave + may + have + an + ID + of + zero, + hence + there + can + be + + + 63 + different + slaves + connected + to + one + controller. + The + reset + bit + (R) + controls + whether + the + slave(s) + are + + + selected + or + reset. + If + R + = + 0 + slave(s) + are + reset, + R + = + | + slave(s) + are + selected. + Slave + select + control + bytes + can + + + be + summarised + by + the + following + table:- + +

+
+
+

+ + Description + + + Reset + all + slaves + +

+
+
+

+ + Reset + specific + slave + with + ID + = + xx + + + Deselect + slave + (does + not + reset + slave) + + + Select + slave + with + ID=xx + and + read + slave + info + (see + below). + +

+
+
+
+

+ + The + Reset + function + is + dependant + on + the + slave. + It + would + normally + put + the + slave + into + a + known + passive + + + reset + state. + +

+ +

+ + Select + Slave + with + ID=xx + (S=0,R=1) + +

+ +

+ + This + is + a + special + command + that + causes + a + slave + with + ID=xx + to + transmit + to + the + controller + an + 8 + bit + + + information + field. + This + field + depends + entirely + on + the + slave + but + must + be + non + zero. + A + reply + of + 0 + + + indicates + that + there + is + no + slave + of + the + requested + ID + present. + +

+
+
+

+ + Slave + control + mode + +

+
+
+

+ + This + mode + is + for + communicating + with + a + slave + which + has + been + previously + selected + using + the + select + + + slave + command + described + above. + + + The + format + of + the + control + word + in + slave + select + mode + is + as + follows:- + +

+
+
+
+

+ + R/W + Read/write + select. + 0 + = + write, + 1 + = + read + +

+ +

+ + B/W + Data + transfer + size. + 0 + = + 1 + byte + transfer, + 1 + = + word + (2 + byte + transfer). + + + S/M + Single/Multi + transfer + mode. + 0 + = + single, + 1 + = + multibyte. + +

+ +

+ + XXXX + = + 4 + bits + of + data + to + slave. + +

+
+
+

+ + Note + the + meaning + of + the + 4 + bits + of + data + (XX + XX) + is + entirely + dependent + on + the + slave. + +

+
+
+

+ + The + settings + of + R/W,B/W,S/M + bits + in + the + control + word + determine + the + size, + type + and + direction + of + + + subsequent + data + transfers + in + the + following + manner:- + +

+
+
+

+ + Revision + 1.00 + Page + 9 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + R/W + B/W + _ + S/M + +

+ +

+ + 0 + 0 + 0 + write + a + single + byte + to + slave + +

+ +

+ + 0 + 0 + 1 + write + a + number + of + single + bytes + to + slave + +

+ +

+ + 0 + 1 + 0 + write + a + byte + pair + to + slave + (not + implemented) + +

+ +

+ + 0 + 1 + 1 + write + a + number + of + byte + pairs + to + slave + (not + implemented) + +

+ +

+ + 1 + 0 + 0 + read + a + single + byte + from + slave + +

+ +

+ + 1 + 0 + 1 + read + a + number + of + single + bytes + from + slave + +

+ +

+ + 1 + 1 + 0 + read + a + byte + pair + from + slave + (not + implemented) + +

+ +

+ + 1 + 1 + 1 + read + a + number + of + byte + pairs + from + slave + (not + implemented) + + + Write + a + single + byte + +

+
+
+

+ + This + command + readies + the + currently + selected + slave + to + receive + a + byte + of + data + and + sets + up + the + controller + + + so + that + the + next + byte + (or + the + LSB + of + a + word) + written + to + its + data + register + will + be + transmitted + to + that + + + slave. + Anything + further + written + to + the + controller's + data + register + will + have + no + effect. + +

+
+
+

+ + Write + a + number + of + single + bytes + +

+
+
+

+ + This + command + readies + the + currently + selected + slave + to + receive + a + number + of + sequential + bytes + of + data. + + + The + slave + will + expect + to + receive + data + bytes + until + another + control + byte + is + received. + The + controller + is + set + + + up + so + that + the + next + byte + (or + the + LSB + of + a + word) + written + to + its + data + register + will + be + transmitted + to + that + + + slave. + All + subsequent + bytes + written + to + the + controller's + data + register + will + be + transmitted + to + the + slave. + + + This + will + continue + until + another + byte + is + written + to + the + controller's + control + register. + +

+
+
+

+ + Write + a + byte + pair + +

+
+
+

+ + This + command + readies + the + currently + selected + slave + to + receive + two + bytes + of + data + and + sets + up + the + + + controller + so + that + the + next + word + written + to + its + data + register + will + be + transmitted + to + that + slave + (LSB + first). + + + Anything + further + written + to + the + controller's + data + register + will + have + no + effect. + +

+
+
+

+ + Write + a + number + of + byte + pairs + +

+
+
+

+ + This + command + readies + the + currently + selected + slave + to + receive + a + number + of + sequential + byte + pairs + of + + + data. + The + slave + will + expect + to + receive + byte + pairs + until + another + control + byte + is + received. + The + controller + + + is + set + up + so + that + the + next + word + written + to + its + data + register + will + be + transmitted + to + that + slave + (LSB + first). + + + All + subsequent + words + written + to + the + controller's + data + register + will + be + transmitted + to + the + slave. + This + + + will + continue + until + another + byte + is + written + to + the + controller's + control + register. + +

+
+
+

+ + Read + a + single + byte + +

+
+
+

+ + This + command + triggers + a + byte + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + byte + + + can + then + be + read + from + the + LSB + of + the + controller's + data + register. + Further + reads + of + the + controller's + data + + + register + will + return + the + same + data + but + have + no + effect + on + the + protocol. + +

+
+
+

+ + Read + a + number + of + single + bytes + +

+
+
+

+ + This + command + triggers + a + byte + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + byte + + + can + then + be + read + from + the + LSB + of + the + data + register. + This + read + will + trigger + the + next + byte + to + be + + + transmitted + to + the + data + register + of + the + controller. + All + subsequent + reads + of + the + controller's + data + register + + + will + trigger + further + bytes + to + be + transmitted + to + the + controller. + This + will + continue + until + another + byte + is + + + written + to + the + controller's + control + register. + +

+
+
+

+ + Read + a + byte + pair + +

+ +

+ + This + command + triggers + a + byte + pair + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + + + word + can + then + be + read + from + the + controller's + data + register. + Further + reads + of + the + controller's + data + + + register + will + return + the + same + data + but + have + no + effect + on + the + protocol. + +

+ +

+ + Read + a + number + of + byte + pairs + +

+
+
+

+ + This + command + triggers + a + byte + pair + to + be + transmitted + from + the + selected + slave + to + the + controller. + This + + + word + can + then + be + read + from + the + controller's + data + register. + This + read + will + trigger + the + next + byte + pair + to + +

+
+
+

+ + Revision + 1.00 + Page + 10 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + be + transmitted + to + the + data + register + of + the + controller. + All + subsequent + reads + of + the + controller's + data + + + register + will + trigger + further + byte + pairs + to + be + transmitted + to + the + controller. + This + will + continue + until + + + another + byte + is + written + to + the + controller's + control + register. + +

+
+
+

+ + Timing + + + The + time + taken + for + commands + to + be + processed + and + data + sent + is + shown + below. + The + time + is + given + in + +

+
+
+

+ + SIBO + pack + protocol + clock + cycles. + The + length + of + a + clock + cycle + is + nominally + 260 + nanoseconds + for + a + + + clock + frequency + of + 3.84 + MHz. + +

+
+
+

+ + Receive + and + process + the + control + byte + 12 + cycles + + + Byte + transfer + to + or + from + slave + 12 + cycles + + + Byte + pair + transfer + to + or + from + slave + 24 + cycles + +

+
+
+

+ + When + writing + to + the + controller's + data + and + control + registers + the + following + rules + apply:- + +

+ +

+ + e + After + writing + to + the + control + register + there + must + be + a + delay + of + at + least + 12 + cycles + before + the + data + + + register + is + accessed + or + another + control + word + is + written. + +

+ +

+ + e + Toread + a + word + from + the + data + register + after + the + command + to + read + byte + pair + is + issued + there + must + a + + + delay + of + at + least + 12 + (for + control + byte)+24 + (for + the + byte + pair + transfer)= + 36 + cycles. + +

+ +

+ + e + To + perform + a + multiple + byte + pair + write + there + must + be + a + delay + of + at + least + 12 + cycles + after + the + + + command + is + written + to + the + control + register + before + the + first + word + can + be + written + to + the + data + register + + + and + a + delay + of + at + least + 24 + cycles + between + subsequent + writes + to + the + data + register. + +

+
+
+

+ + States + +

+ +

+ + A + slave + can + be + in + one + of + 5 + states. + Note + a + control + byte + can + be + received + and + interpreted + at + any + time. + + + 1) + Waiting + to + receive + a + data + byte + or + control + byte + +

+ +

+ + 2) + Waiting + to + receive + a + data + byte + pair + or + control + byte + +

+ +

+ + 3) + Waiting + to + transmit + a + data + byte + or + control + byte + +

+ +

+ + 4) + Waiting + to + transmit + a + data + byte + pair + or + control + byte + +

+ +

+ + 5) + Waiting + to + receive + control + byte + only + +

+
+
+

+ + Revision + 1.00 + Page + 11 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 5. + MECHANICAL + OVERVIEW + +

+
+
+

+ + This + section + will + contain + information + regarding + mechanical + and + plastic + moulding + for + Series + 3/3a, + + + Workabout + and + HC + machines + that + is + deemed + to + be + of + especial + importance + to + developers + who + are + + + considering + producing + peripherals + for + these + particular + Psion + platforms. + +

+
+
+

+ + The + Psion + Series + 3/3a + range + +

+
+
+

+ + S3a/Series + 3 + Reduced + External + Expansion + Port + +

+
+
+

+ + The + Psion + Series + 3/S3a + personal + digital + assistants + have + two + SSD + slots + and + provide + access + to + external + + + peripheral + units + through + a + single + reduced + internal + expansion + port, + port + C, + on + the + left + edge + of + the + + + machine. + The + reduced + external + serial + interface + expansion + port + from + the + Series + 3/3a + forms + six + wires. + + + The + purpose + of + each + is + described + in + the + table + below. + In + addition + to + data, + clock + and + power + an + active + + + high + interrupt + line + is + provided. + This + allows + the + peripheral + device + to + generate + an + interrupt + within + the + + + host + series + 3/3a. + The + level + of + interrupt + that + is + generated + depends + on + both + the + machine + and + the + + + expansion + port + that + is + used. + Either + ASIC4 + or + ASICS + can + act + as + the + other + end + of + the + Psion + Serial + + + Interface. + With + exception + of + the + interrupt + line + all + used + signals + should + be + connected + directly + to + the + + + appropriate + pins + on + ASIC4/5. + +

+
+
+

+ + ASIC4/5 + SDAT + + + MCLK + Serial + clock + ASIC4/5 + SCLK + +

+
+
+

+ + | + 6 + | + SCK/EXON + | + Not + used + in + this + scenario + | + Donot + Connect____| + +

+
+
+
+

+ + Signal + Definition + +

+
+
+

+ + MSD + and + MCLK + form + a + single + master + SIBO + serial + protocol + channel. + This + is + normally + channel + 7 + on + a + + + Series + 3 + and + channel + 5 + on + an + S3a. + The + serial + channel + clock + can + be + continuously + enabled + to + provide + a + + + free + running + clock + for + expansion + devices. + The + frequency + is + fixed + at + 1.536MHz + regardless + of + the + + + system + clock + frequency. + SDKs/INT + and + SCK/EXON + are + both + dual + function + pins. + SDKS + and + SCK + + + form + a + single + slave + SIBO + serial + protocol + channel. + This + can + be + combined + with + MSD + and + MCLK + to + + + form + a + bi-directional + high + speed + data + link. + SDS/INT + can + also + be + used + to + as + an + active + high + interrupt + + + input. + The + function + of + SDS/INT + can + be + programmed + in + ASIC2 + or + ASIC9. + A + rising + edge + on + the + + + SCK/EXON + input + will + bring + the + system + out + of + the + standby + state + into + the + operating + state. + VCC + is + a + +5 + + + volt + supply + that + is + switched + off + when + the + system + is + in + the + standby + state + and + is + switched + on + when + the + + + system + is + in + the + operating + or + idle + state. + The + maximum + current + that + can + be + drawn + is + 25mA. + Opening + + + the + pack + doors + on + either + an + S3a + or + a + Workabout + will + cut + power + to + external + peripherals. + +

+
+
+

+ + Physical + Connector + +

+
+
+

+ + The + reduced + expansion + port + is + made + up + of + a + 6-way + two + row + connector + spaced + on + a + 2x3 + way + 0.1 + inch + + + pitch. + The + diagram + below + shows + the + physical + connector + numbering: + +

+
+
+

+ + Revision + 1.00 + Page + 12 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Looking + into + Series + 3 + / + 3a + +

+
+
+
+
+

+ + The + male + plug + is + connected + to + a + 0.5m + long + plastic + moulded + 3-link + cable + assembly + (part + no. + 25020013) + + + which + is + terminated + in + a + six-pin + in-line + connector + which + connects + to + a + 6-way + 1.5mm + pitch + transition + + + header + (part + no. + 47000106). + +

+
+
+

+ + The + Psion + Workabout + +

+
+
+

+ + The + Workabout + Expansion + Interfaces + +

+
+
+

+ + The + Psion + Workabout + provides + a + rugged + and + easy-to-use + computer + system + for + a + wide + range + of + mobile + + + corporate + needs. + The + machine + can + be + readily + adapted + to + support + various + peripheral + units + such + as + + + barcode + scanners + and + modems + attached + to + the + expansion + ports. + The + Workabout + has + a + 26-way + + + extended + internal + expansion + interface + and + a + special + 11-pin + reduced + external + expansion + interface. + +

+
+
+

+ + Workabout + Extended + Internal + Expansion + Interface + +

+
+
+

+ + The + pin-out + of + the + Workabout + 26-way + internal + Torson + connector + is + outlined + below: + +

+
+
+

+ + Torson + 26 + way + connector + pin + Workabout + Signal + name + + + NICD + (not + used) + +

+
+
+

+ + THM + (not + used) + + + VIN + (not + used) + +

+
+
+
+

+ + Revision + 1.00 + Page + 13 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + e + = + Vccl + is + 3.0V + nominal + power + supply. + Current + available + from + Workabout + is + limited + to + 100mA. + +

+ +

+ + e + =Vcc2 + is + 5V + nominal + power + supply. + Current + available + from + Workabout + is + limited + to + 200mA. + +

+ +

+ + e + RUN + is + low + when + powered + down + and + high + when + powered + up. + It + is + used + to + power + down + or + reset + + + the + peripheral + module. + +

+ +

+ + e + SCK2 + and + SCK3 + are + serial + data + clocks. + The + clocks + are + left + running + continuously + at + 1.536MHz + + + when + the + serial + port + is + in + use. + They + are + used + to + clock + the + UART + in + ASICS + in + the + RS232 + AT/TTL + + + and + AT/Barcode + modules + respectively. + +

+ +

+ + e + SD2 + and + SD3 + are + bi-directional + serial + data + lines + used + in + the + RS232 + AT/TTL + and + AT/Barcode + +

+ +

+ + modules + respectively. + +

+ +

+ + EINT1 + and + EINT2 + are + active + low + signals + for + interrupt + input. + +

+ +

+ + EXON + is + an + active + high + signal + used + to + turn + on + the + Workabout. + +

+ +

+ + All + of + the + above + logic + signals + are + at + 3.0V + or + 3.3V + levels, + depending + upon + the + logic + supply + Vcc1. + +

+ +

+ + Lines + currently + described + as + unused + relate + to + a + yet + unspecified + codec + interface. + +

+
+
+

+ + Workabout + Reduced + External + Expansion + Interface + +

+
+
+

+ + For + the + Workabout + reduced + external + expansion + interface, + a + new + | + 1-pin + Low + Insertion + Force + (LIF) + + + connector + has + been + designed + for + connecting + the + computer + to + the + Cradle + System. + The + computer + + + mounted + male + LIF + may + be + weather + proofed, + the + cable + mounted + female + LIF + cannot. + Currently + the + LIF + + + connector + cover + can + be + moulded + with + a + polarising + pin + in + one + of + two + positions. + The + facility + exists + to + + + manufacture + the + cover + with + the + polarising + pin + in + two + more + positions, + giving + four + possible + variants. + If + + + more + than + four + versions + are + required + it + is + possible + to + have + the + cover + and + the + socket + bezel + moulded + in + a + + + range + of + colours + to + differentiate + between + variants. + The + polarising + options + are + presented + below: + +

+
+
+

+ + Pin + numbers + + + 1st + (1 + GROUND + 9 + + + 2nd + (________] + SIGNALS + 2,3,4,5,8,10 + + + 1,6,7,11 + +

+
+
+
+

+ + The + step + arrangement + of + the + LIF + Connector + pins + +

+
+
+
+

+ + Cable + mounted + LIF + (Female + plug) + Computer + mounted + LIF + (Male + socket) + +

+
+
+

+ + Revision + 1.00 + Page + 14 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 3S + 310 + +

+
+
+

+ + @e0000 + 08 + + + ODOOOO + +

+
+
+
+

+ + Cable + mounted + LIF + (Female + plug) + Computer + mounted + LIF + (Male + socket) + +

+
+
+

+ + Type + A + and + Type + B + polarisation + of + the + LIF + Connector + +

+
+
+

+ + Revision + 1.00 + Page + 15 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Pin + Definition + for + LIF + - + PFS + Connector + + + LIF + Connector + Polarisation + Type + B + +

+
+
+

+ + Pin + Pin + Name + Wire + Colour + Contact + Direction + Standard + Function + Cradle + usage + + + No + Gauge + (Cradle's + + + perspective) + +

+ +

+ + 1 + LCA + 710.1 + Brown + third + Input + Local’ + Computer + Active. + High + when + the + Used + as + an + enable + for + the + cradle + + + computer + is + on. + (The + Workabout + can + source + resident + Xmod + 5V + supply. + + + 100mA + from + this + pin + and + the + HC/HCDOS + + + 5mA + to + power + remote + circuitry) + +

+
+
+

+ + EXON + 710.1 + Blue + second + Output + EXternal + switch + ON, + active + high + (+5V). + May + be + asserted + by + a + cradle + resident + + + Asserted + by + a + remote” + device + to + switch + on + Xmod. + + + the + computer. + + + Xmod. + +

+
+
+

+ + se + He + 1 + a + eee + eet + Battery + thermistor + terminal. + Allows + remote“ + function + + + eae + of + the + battery + temperature. + +

+
+
+

+ + meal + 1 + Bead + ie + Output + Disconnect + Local” + ASIC, + active + high + (+5V). + Asserted + by + the + Cradle + ASIC, + + + (does + not + apply + to + Workabout). + When + this + connects + the + cradle + resident + Xmod + to + + + signal + is + asserted + the + serial + channel + is + the + serial + channel. + + + disconnected + from + the + local? + ASIC4/5 + in + the + + + HC + resident + Xmod + (if + present) + and + instead + + + connected + to + a + remote + ASIC4/5 + (if + present). + +

+
+
+

+ + FN + Te + + + | + 7 + | + vin + | + 28SwG + Power + supply + to + computer + (+10V) + + + | + 8 + | + SCLK + 710.1 + | + SerialchannelCLocK. + +

+
+
+

+ + GND + 28 + SWG + White + “fiat + Power, + [Seval + channel + Chev + —_____ + ground + and + -ve + battery + Standard + function + + + terminal + (1 + amp) + +

+
+
+

+ + SDATA + 710.1 + Serial + channel + DATA. + +

+
+
+

+ + 11 + STATUS + 710.1 + Pink + third + Cai + STATUS. + Connected + to + a + pull-up + resistor + to + Driven + low + by + an + open + collector + driver + + + allow + connection + to + an + open-collector/drain + when + LCA + is + high + and + the + cradle + is + + + driver. + Normal + usage + is: + low + indicates + the + powered-up + to + allow + the + computer + to + + + presence + of + a + remote” + device. + sense + whether + or + not + the + cradle + is + +

+ +

+ + connected. + +

+
+
+

+ + LIF + Connector + Polarisation + Type + A + +

+
+
+

+ + Pin + Wire + Colour + Contact + Direction + Function + + + No + eine + Gauge + (Computer's + + + perspective) + + + ee + oe + RS2I2 + signal + + + a + a + RS232 + signal + +

+
+
+

+ + 77 + Output + | + RS232 + signal + + + THERM + [7101 + [Yellow + [ + second_[ + =] + Battery + thermistor + terminal + +

+
+
+
+
+

+ + [svar + [2sswo + [Red + [tind + [- + | + tvebattery + terminal + ——SSSSSCSCSCSCSCSCSCSCC~C~* + + + [3 + [pe + 701 + [Grey + [second + [Input + [ + RS232signal + OSS + + + [9 + [exp + eswo + [white + [fist + [= + | + Power, + signal + ground + and + ve + battery + terminal + —____——SS—~S + +

+
+
+
+
+

+ + Definitions + +

+ +

+ + Computer + HC, + HCDOS + or + Workabout + +

+ +

+ + Cradle + resident + Xmod + Expansion + module + fitted + to + the + cradle, + may + or + may + not + be + present. + +

+ +

+ + HC + resident + Xmod + Expansion + module + fitted + to + the + HC, + which + contains + the + cradle + interface + and + possibly + another + peripheral. + + + HC + peripheral + A + peripheral, + located + in + the + HC + resident + Xmod + which + is + connected + to + the + same + serial + channel + as + the + cradle. + + + Cradle + ASIC + An + ASICS + located + on + the + main + cradle + PCB + which + remains + connected + to + the + serial + channel + +

+
+
+

+ + irrespective + of + the + state + of + DLA. + +

+
+
+

+ + 1. + | + The + term + "local + computer" + implies + the + computer + local + to + the + LIF + connector, + i.e. + the + HC, + HCDOS + or + Workabout, + as + opposed + to + + + a + "remote" + computer + which + might + be + connected + via + a + cradle + resident + Xmod + for + example. + +

+ +

+ + 2. + The + term + "remote" + implies + something + on + the + other + side + of + the + LIF + connector + to + the + computer. + +

+ +

+ + 3. + | + The + term + "local" + implies + something + on + the + computer + side + of + the + LIF + connector + including + devices + on + an + HC + resident + Xmod. + +

+
+
+

+ + Revision + 1.00 + Page + 16 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Exploded + view + of + the + Psion + Workabout + +

+
+
+

+ + Below + is + an + exploded + view + of + a + complete + Psion + Workabout + showing + part + numbers + for + various + + + components + and + illustrating + the + positioning + of + the + expansion + interfaces. + +

+
+
+
+
+

+ + 4 + + + g + y + + + o + # + + + + 4 + a + § + 8 + + + Ss + 8 + + + 4 + gy + Fa + i + + + f + a + Of + i + + + a + 8 + a + a + + + a + « + + + a + 2 + + + 8G + + + Roo + + + ae + + + 38 + + + a3 + + + 3 + + + a + @ + ¢ + + + me + oON + Sgt + + + 3 + + + ROS + + + a + 3 + g + + + ® + S + +8 + + + Be + $3 + + + $s + $8 + + + a + 8 + 28 + + + = + + + o + + + j + z + + + a + 3 + + + a3 + F + | + + + 8 + + + a + 4 + 9 + Boa + ey + + + 3 + a + a + 9 + 3 + + + a + g + 4g + 1 + o + + + & + & + a9 + 3 + 4 + 2 + + + # + 8 + . + p + 3 + 3 + + + zh + ae + 6 + ¢ + a + + + 3 + i + 3 + f + é + i + 3 + " + + + 3 + a8 + a + 8 + 2 + 3 + § + + + goa + + + 3 + BS + + + g + a + 8 + Poa + + + 3 + + + 5 + : + + + a + 8 + a + 9 + + + a + oF + a + + + + + & + § + + + ff + 42 + + + Oo + oN + bos + + + ng + + + a + 3 + + + al + + + a + + + «38 + + + i + + + hoon + + + 2 + 8 + > + + + f + + a + 38 + + + ag + eg + + + 2 + as + + + & + + + a + + + $3 + + + Gc + @ + + + aa + + + 4 + + + a + og + + + 3 + + + 4 + + + o + § + + + 8 + + + g + 8 + + + & + + + g + 3 + + + a + + + a + S$ + + + 0 + y + + + 8 + 3 + + + 4 + + + 8 + + + d + + + 1 + a + + + 3 + ages + + + a + Be, + gy + ee! + + + 8 + g + 3 + + + ae + + + a + + + 3 + + + 8 + & + + + 4 + + + 9 + 2 + 3 + + + p + t + ° + ib + + + a + oO + © + + + 3 + Re + eS + + + 3 + y + § + 3 + + + 4 + 3 + + + 3 + + + ae + oe: + + + n + oc + = + «© + + + x + + + » + + + zg + a3 + + + xg + + + é + + + a3 + 28 + + + 4 + a + 3 + 6 + + + 4 + 4 + + + s + 3 + ¢ + 2 + 3 + os + 3 + + + a + a + 8 + § + + + a + 4 + hoa + gs + 4 + $ + + + 3 + ROS + * + + + § + a + & + aoa + + + g + + + g + 8 + i + 3 + + + a + 3 + 5 + 3 + + + 3 + i + rf + + + g + + + Son + + + 8 + 38 + + + 4 + og + + + F + 2 + 9 + + + * + 3 + + + 8 + + + a + a + 4 + + + j + 4:8 + + + 8 + + + + a5 + + + 3 + + + a + +

+
+
+

+ + Revision + 1.00 + Page + 17 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + Psion + HC + range + +

+
+
+

+ + HC + Extended + Internal + Expansion + Port + +

+
+
+

+ + The + Psion + HC + range + of + computers + are + intended + to + provide + a + rugged + and + powerful + mobile + computer + + + system + for + a + wide + variety + of + demanding + application + requirements. + As + part + of + its + adaptability, + every + + + element + of + the + hardware + is + configurable + from + the + plug-in + SSDs + to + the + expansion + ports + for + peripheral + + + devices + such + as + bar + code + scanners, + modems + and + magnetic + card + readers. + There + are + two + independent + + + extended + internal + expansion + ports + at + either + end + of + an + HC + unit. + The + top + port + is + termed + the + "A" + port + + + and + the + bottom + one + the + "B" + port. + Each + expansion + port + provides + direct + I/O + with + the + processor, + a + SIBO + + + serial + channel, + and + connection + to + the + power + supply. + It + allows + for + higher + powered + expansion + devices + to + + + be + added + by + including + a + direct + connection + to + the + main + 7.2 + volt + battery. + +

+
+
+

+ + Physical + Connector + +

+
+
+

+ + The + expansion + port + is + made + up + of + a + 25 + way + single + row + connector + spaced + on + a + 0.1 + inch + pitch. + The + 26th + + + position + is + a + polarising + key + and + should + be + left + blank. + The + correct + mating + connector + on + the + expansion + + + device + is + made + up + from + a + number + of + Molex + C-Grid + series + 90148 + connectors. + Pins + | + and + 2 + are + ground + + + and + should + have + there + own + connector + placed + nearer + the + board + edge + to + ensure + the + ground + connection + is + + + made + first + when + the + expansion + device + is + inserted. + The + required + connectors + are + Molex + 90148-1102 + for + + + the + GND + contacts + and + Molex + 90148-1123 + for + the + signal + contacts. + The + diagram + below + shows + the + + + physical + position + of + the + connectors. + +

+
+
+
+
+
+
+
+
+
+
+
+

+ + =$f + ene + 98148-1182 + 3 + +

+ +

+ + Se + : + EXPANSION + D + + + =e + +

+ +

+ + sad + Abe + COMPONENT + SID + +

+
+
+
+
+

+ + fet + +

+ +

+ + feu) + + + HHDE + + + eorn + + + AEM + + + on + +

+
+
+
+

+ + 38148-1125 + +

+
+
+

+ + raftats + afte + + + + + [o}:o + loo) + en] + + + Heonwnm + + + Zuaorom + + + Scteorn + + + aa + ne + +

+
+
+
+

+ + raftofea + + + Lsfosfra + + + wn + + + Ox + + + ol + + + Fr! + +

+
+
+

+ + wi + + + Zo + + + OR + +

+
+
+

+ + ge + +

+
+
+

+ + voce + + + (SPACE? + +

+
+
+
+
+
+
+
+

+ + SIBO + COMPUTER + +

+
+
+
+
+
+
+
+
+

+ + Revision + 1.00 + Page + 18 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Signal + definition + +

+
+
+

+ + The + following + table + defines + the + 25 + way + expansion + connector:- + +

+
+
+

+ + Pin + No. + Name + _ + Sig. + type + Comments + +

+ +

+ + GND + Power + Should + mate + first + when + device + inserted + +

+ +

+ + GND + Power + Should + mate + first + when + device + inserted + +

+ +

+ + ADO + BCMOS + 8 + bit + multiplexed + address + and + data + bus + pulled + low + with + 100 + K + resistors + + + ADI + BCMOS + +

+ +

+ + AD2 + BCMOS + +

+ +

+ + AD3 + BCMOS + +

+ +

+ + AD4 + BCMOS + +

+ +

+ + ADS + BCMOS + +

+ +

+ + AD6 + BCMOS + +

+ +

+ + AD7 + BCMOS + +

+ +

+ + ALE + OCMOS + Address + latch + enable + - + high + when + valid + address + on + ADO-AD7 + +

+ +

+ + IOWR + OCMOS + I/O + write + strobe + - + active + high, + data + valid + on + falling + edge + of + IOWR + + + IORD + OCMOS + I/O + read + strobe + - + high + when + device + can + place + valid + data + on + ADO-AD7 + + + EES + OCMOS + External + Expansion + Select + - + high + during + I/O + cycles + to + expansion + device + + + SCLX + TCMOS + 512 + KHz + SCL + signal + for + SLD + bus + - + usually + Hi-Z + and + pulled + low + +

+ +

+ + DNC + N/A + For + future + expansion + - + do + not + use. + +

+ +

+ + THERM + Resistor + Connected + to + thermistor + (bottom + slot + only + - + top + slot + DNC) + +

+ +

+ + VBI + Battery + Connected + to + the + internal + NiCd + battery + (bottom + slot + only + - + top + slot + DNC) + + + Vsup + Power + Unregulated + battery + voltage + - + present + all + the + time + +

+ +

+ + INTR + ICMOS + Active + high + interrupt + input + +

+ +

+ + _EXON + ICMOS + Active + low + input + pulled + up + to + Vccl + - + pull + low + to + switch + machine + on + +

+ +

+ + SD + B + CMOS + SIBO + serial + protocol + data + line + - + pulled + low + +

+ +

+ + SCLK + TCMOS + SIBO + serial + protocol + clock + line + - + Hi-Z + in + standby + needs + a + pull + down + + + GND + Power + +

+ +

+ + Vcc2 + Power + +5 + volt + supply, + switched + off + in + standby. + Max + current + available + = + 50 + mA + +

+
+
+

+ + AADNKRWN + KH + +

+
+
+
+
+

+ + DNC + (Do + Not + Connect) + indicates + that + the + pin + should + not + be + connected. + The + signal + types + are:- + +

+
+
+

+ + O + CMOS + CMOS + output + to + the + expansion + device. + +

+ +

+ + B + CMOS + CMOS + bi-directional + line + to + the + expansion + device. + + + T + CMOS + CMOS + tri-state + output + to + the + expansion + device. + +

+ +

+ + I + CMOS + CMOS + input + from + the + expansion + device. + +

+
+
+

+ + All + the + CMOS + signals + including + the + ADO-AD7 + bus + are + buffered + from + the + main + system + busses + and + so + + + present + a + load + of + one + HC + series + logic + gate. + +

+
+
+

+ + Direct + I/O + +

+
+
+

+ + Expansion + devices + can + be + connected + to + direct + processor + I/O + space + using + the + following + signals; + ADO- + + + AD7, + ALE, + IOWR, + IORD, + EES + and + INTR. + +

+
+
+

+ + ADO-AD7 + is + the + least + significant + half + of + the + multiplexed + address + and + data + bus, + this + means + that + up + to + + + 128 + I/O + addresses + are + available + for + each + expansion + device. + As + only + the + least + significant + half + of + the + + + bus + is + available + and + no + bus + conversion + is + done + only + even + addresses + can + be + used. + +

+
+
+

+ + ALE + must + be + used + to + latch + the + address + from + ADO-AD7 + for + devices + that + require + a + stable + address. + The + + + address + is + valid + on + the + falling + edge + of + ALE. + Note + that + AO + will + always + be + low + for + valid + writes + to + the + + + expansion + device + and + as + such + should + not + be + used + as + an + address + line, + Al + should + be + used + as + the + lowest + + + order + address + line. + AO + can + be + used + as + an + additional + enable + signal + to + stop + odd + I/O + accesses + disturbing + + + the + expansion + device. + +

+
+
+

+ + EES + is + the + External + Expansion + Select + and + is + high + during + all + I/O + accesses + to + the + expansion + device, + i.e. + +

+
+
+

+ + for + I/O + reads + and + writes + to + address + range + 100 + to + 1FF + hex. + for + expansion + port + 1, + and + 200 + to + 2FF + for + + + expansion + port + 2. + +

+
+
+

+ + Revision + 1.00 + Page + 19 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + IOWR + is + an + active + high + signal + which + is + high + during + all + I/O + write + bus + cycles. + The + data + on + ADO-AD7 + + + is + guaranteed + to + be + stable + before + the + rising + edge + of + IOWR + and + after + the + falling + edge + of + IOWR. + IORD + + + is + an + active + high + signal + which + is + high + during + all + I/O + read + bus + cycles. + The + ADO-AD7 + bus + is + + + guaranteed + to + be + tri-state + before + the + rising + edge + of + IORD + and + after + the + falling + edge + of + IORD. + The + + + expansion + device + must + present + valid + data + on + the + bus + when + IORD + is + high, + see + the + timing + details + below. + +

+
+
+

+ + INTR + is + an + active + high + interrupt + input + to + ASIC1. + T + his + can + be + used + as + a + directly + readable + bit + or + as + a + + + dedicated + interrupt + input. + It + must + not + be + driven + high + when + the + system + is + in + the + standby + state + as + this + + + input + is + pulled + down + and + will + cause + excessive + standby + current + consumption. + The + diagram + below + + + shows + the + timing + of + the + I/O + write + and + read + cycles. + +

+
+
+
+
+

+ + T/0 + WRITE + CYCLE + +

+
+
+

+ + ADS-ADT + VALID + ADDR + +

+
+
+
+
+
+
+
+
+
+

+ + VALID + WwW + +

+
+
+
+
+
+
+

+ + QOD + +

+
+
+
+
+
+
+

+ + FES + q_Tadstp + _ + plyTadhidy, + +

+
+
+
+
+
+
+
+
+
+

+ + | + Tudstp + | + Tudhld + | + +

+
+
+
+
+

+ + IYO + READ + CYCLE + +

+
+
+

+ + ADS-ADT + VALID + ADDR> + +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ + } + Tadetp + fel + adhd + ,, + +

+
+
+
+
+
+
+
+
+
+

+ + | + Thztd + Trdste + Trdhid + +

+
+
+
+
+
+

+ + Parameter + +

+ +

+ + Address + set + up + time + + + Address + hold + time + + + Write + data + set + up + time + + + Write + cycle + pulse + width + +

+
+
+

+ + Write + data + hold + time + +

+ +

+ + Time + from + Hi-Z + to + data + active + + + Read + cycle + pulse + width + +

+ +

+ + Read + data + set + up + time + +

+ +

+ + Read + data + hold + time + +

+
+
+
+

+ + Note + the + typical + values + given + are + for + an + HC + with + a + system + oscillator + of + 7.68 + MHz. + +

+
+
+

+ + The + SIBO + serial + channel + +

+
+
+

+ + A + single + SIBO + serial + protocol + channel + is + provided + on + each + expansion + port. + Expansion + port + | + is + + + connected + to + serial + channel + 5, + expansion + port + 2 + is + connected + to + serial + channel + 6. + The + serial + channel + + + clock + can + be + continuously + enabled + to + provide + a + free + running + clock + for + expansion + devices. + The + + + frequency + is + fixed + at + 1.536 + MHz + regardless + of + the + system + clock + frequency. + This + frequency + is + a + + + multiple + of + the + SLD + clock + rate + and + of + all + normal + RS232 + baud + rates. + +

+
+
+

+ + High + Speed + Side + Port + +

+
+
+

+ + Port + C + on + an + HC + houses + an + 8-pin + in-line + connector + that + allows + access + to + a + high + speed + SIBO + serial + + + interface. + This + interface + is + currently + used + only + by + the + HC + cradle + peripheral. + Its + pin-out + is + outlined + in + + + the + table + overleaf: + +

+
+
+

+ + Revision + 1.00 + Page + 20 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + [Pin + | + Signal + | + Type + | + Description, + +

+
+
+

+ + fo + | + Sb7_ + | + InOut__| + Bi-directional + Serial + Data + line- + Side + portC + + + [8 + TSEN + Input + Battery + temperature + sensor + +

+
+
+
+

+ + Power + supplies + +

+
+
+

+ + Two + power + supplies + are + available + for + expansion + devices + these + are + Vcc2 + and + Vsup. + Vcc2 + is + a + +5 + volt + + + supply + that + is + derived + from + Vsup. + Vcc2 + is + switched + off + when + the + system + is + in + the + standby + state + and + is + + + switched + on + when + the + operating + or + idle + state + is + entered. + Each + expansion + device + can + draw + up + to + 50 + mA + + + from + Vcc2. + If + an + expansion + device + requires + more + than + 50 + mA + or + cannot + be + powered + down + when + the + + + system + is + in + the + standby + state + the + Vsup + power + supply + must + be + used. + Vsup + is + the + unregulated + supply + + + directly + from + the + main + system + batteries + or + from + the + DC + jack + input. + It + will + be + in + the + range + 5.5 + to + 12 + + + volts + under + normal + conditions. + To + use + Vsup + the + expansion + device + must + regulate + Vsup + to + 5 + volts + with + + + a + low + drop-out + linear + regulator. + Care + must + be + taken + to + not + be + active + and + driving + any + signals + high + + + when + the + system + is + in + the + standby + state + as + Vsup + is + always + present. + This + can + be + achieved + either + in + + + software + or + by + using + Vcc2 + as + a + signal + indicating + the + active + state. + +

+
+
+

+ + Mechanical + Information + +

+
+
+

+ + Mechanical + details + regarding + the + numerous + build + variants + and + accessories + that + currently + exist + for + the + + + HC + are + presented + overleaf. + The + peripheral + expansion + boards + for + these + build + variants + are + housed + in + a + + + special + plastic + casing + that + can + be + machined + to + hold + the + requisite + connectors. + In + the + matrix, + ae + + + indicates + that + the + relevant + combination + of + HC + and + accessory + are + compatible + and + an + X + indicates + that + + + the + combination + is + not + compatible. + Following + the + build + variant + table + are + two + diagrams + that + display + + + exploded + views + of + the + HC + expansion + connector + and + the + HC + Expansion + Board + complete + with + part + + + numbers + and + dimensions. + +

+
+
+

+ + Revision + 1.00 + Page + 21 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + Build + Variants + +

+
+
+

+ + With + EL + Backlighting + + + Without + EL + Backlighting + +

+
+
+
+

+ + Industrial + +

+
+
+

+ + Non-Industrial + +

+
+
+

+ + Keypad + Variants + +

+
+
+

+ + 53 + Key + A/N + UK + 2401-0026 + + + A/N + European + 2401-0051 + + + A/N + Scandinavian + 2401-0050 + + + Numeric + only + UK + 2401-0046 + + + DOS + Keypad + 2401-0147 + + + 53 + Key + A/N + USA + 2400-0026 + + + HC + Expansion + Modules + +

+
+
+

+ + RS232 + / + Parallel + (Printer) + 1502-0001 + + + 25 + way + D + type + (F) + + + 9 + way + Mini + DIN + + + Certified + FCC + Class + B + / + Passed + VDE + Class + B + +

+
+
+

+ + RS232 + / + TTL + +

+ +

+ + 1502-0039 + (IP64), + 1502-0040 + (NON + IP64) + +

+ +

+ + 9 + way + D + type + (F) + + + 9 + way + D + type + (M) + +

+ +

+ + Passed + FCC + Class + B + / + Passed + EN55022 + Class + B + +

+
+
+

+ + UK + Modem + (Asic + 8) + 1502-0010 + + + RJ + 11 + connector + + + BABT + Approved + in + UK, + BS6301 + (Safety) + +

+
+
+
+
+

+ + Barcode + Only + +

+ +

+ + HP + Wand + HBCS-A207 + + + Plug + + + EXMOD + 1502-0020 + + + Wand + Welch + Allen + + + Plug + + + EXMOD + 1502-0021 + + + FCC + Class + A/ + Passed + VDE + Class + B + +

+
+
+

+ + RS232 + / + Barcode + 1502-0044 + + + 9 + way + D + type + Quick + Loc(F) + + + 9 + way + D + type + (M) + + + Complies + with + FCC + Class + A + +

+
+
+

+ + MCR + / + Scanner + / + RS232 + 1502-0003 + + + Scanner + NipDenso + + + Plug + 1502-0022 + + + Scanner + DigVision + + + Plug + 1502-0023 + + + Magnetic + Card + Reader + + + Plug + 1502-0024 + + + Certified + FCC + Class + B + / + Passed + VDE + Class + B + +

+
+
+

+ + LIF + / + RS232 + (Under + development) + + + 9 + way + D + type + (M) + + + 9 + way + LIF- + PFS + (M) + +

+
+
+
+
+

+ + LIF + / + TTL + (Under + development) + + + 9 + way + D + type + (F) + + + 9 + way + LIF- + PFS + (M) + +

+
+
+

+ + LIF + / + BARCODE + 1502-0043 + + + 9 + way + D + type + Quick + Loc(F) + + + 9 + way + LIF- + PFS + (M) + +

+
+
+

+ + Vehicle + / + TTL + + + 9 + way + D + type + (F) + + + 9 + way + LIF- + RS232 + (M) + +

+
+
+
+

+ + 16550 + RS232 + / + TTL + (Under + development) + + + 9 + way + D + type + (F) + + + 9 + way + D + type + (M) + + + Complies + with + FCC + Class + A + +

+
+
+
+
+

+ + Printer + (High + Res.) + 1502-0037 + + + Laser + Scanner + 1503-0012 + +

+
+
+

+ + Fast + Charger + Variants + +

+
+
+

+ + Fast + Charger + with + Holster + (Due + Jan + 95) + + + Fast + Charger + without + Holster + (Due + Jan + 95) + +

+
+
+
+

+ + Additional + Accessories + + + Nicad + Battery + Pack + 500 + mA + 1503-0005 + +

+
+
+

+ + Revision + 1.00 + +

+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+
+

+ + CHARGER + +

+
+
+

+ + a + a + a + Ee + + + i + ie + IE + a + a + + + ee + ee + + + Re + ca + Da + ca + +

+
+
+

+ + ans + he + ae + Ss + eee + + + FS + a + a + a + a + +

+
+
+

+ + Page + 22 + of + 115 + pages + +

+
+
+ +
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + Corporate + Hand + Held + (CHH) + +

+
+
+

+ + Expansion + Module + Exploded + Assembly + Drawing + +

+
+
+

+ + (yovig) + Sso0-zoz9 + +

+
+
+

+ + (USENNN + LYVd + YSLINO + OSTY) + (A3N9) + £000-20z9 + +

+
+
+

+ + YANVIG + NOISNVdX4d + 138V1 + +

+
+
+

+ + (440 + 2) + 2000-z0¢g + + + WSO + IZOd + WWOXZZ% + MINIS + +

+
+
+

+ + (OV1E) + 9107-2018 + +

+
+
+

+ + (AJN9) + 9101-2018 + + + ONITINOW + Y3LNO + NOISNVdxX3 + OLS + HHO + +

+
+
+

+ + (wov1d) + $10Z-Z018 + + + (AIUD) + SLOL-ZOL8 + + + ONIGINOW + YSNNI + NOISNYdX3 + HHO + | + +

+
+
+

+ + 6000-0072 + + + ANVIG + dd + +

+
+
+

+ + SNOISNSNIG + YSLLNS + + + ANVIG + NOISNVdX3 + 138V1 + +

+
+
+
+
+
+
+
+
+
+

+ + Page + 23 + of + 115 + pages + +

+
+
+

+ + Revision + 1.00 + +

+
+
+ +
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + t + +

+
+
+

+ + The + Psion + SIBO + Hardware + Development + +

+
+
+

+ + QrOr + o22 + ILD + :xW4 + + + 008! + 802 + 120 + “7131 + + + 1G) + HIM + +

+
+
+

+ + NOONOT + N/OIl + +

+
+
+

+ + AS + 18NOQYVH + 61-21 + + + Jd + NOd + +

+
+
+

+ + MSV + LENOd + Ni + dl + + + JNWOS + ION + OG + +

+
+
+
+

+ + (SOs + 2) + ONDOEL + =O + + + w300 + 34 + OL + G3U0Y + vey + +

+
+
+

+ + 26, + +

+
+
+
+

+ + 94 + 01 + GMQy + SFI + NOILWOOT + +

+
+
+

+ + 26/1/91 + +

+
+
+
+

+ + Sa + @ + SINSNOGNOD + 40 + + + wa) + 38 + OL + G200V + vw + +

+
+
+

+ + 26/0178 + +

+
+
+
+

+ + ‘Gadd + NOWOWISIS + + + AHOIBH + LN3NOEWOD + W207 + +

+
+
+

+ + 06 + /c0/zal + +

+
+
+
+

+ + 108 + X3T0K + + + a300¥ + $89 + 8ou93~N09 + +

+
+
+

+ + oss + 9792 + +

+
+
+
+

+ + SSI + Sas + +

+
+
+
+

+ + SONVHO, + +

+
+
+
+
+

+ + SmAOVd + NOISNVdx4 + +

+
+
+
+
+
+

+ + SH + T1¥ + A044 + GssyINGS + +

+
+
+
+
+
+
+

+ + NOILYWAOSANI + 4H + +

+
+
+
+
+
+

+ + L + SMOHS + SONIMVAC + Sit + +

+
+
+
+

+ + LH513H + LN3SNOdWOD + + + X¥W + ONIMOHS + 311 + 408d + +

+
+
+
+

+ + 216 + +

+
+
+

+ + cay) + Y_NOISN3WIC + +

+
+
+
+

+ + C30N31LX3 + +

+
+
+
+
+

+ + CAVONVLS + +

+
+
+
+

+ + JdWwOS + aNv + +

+
+
+

+ + qa.0N3d + vaav + +

+
+
+

+ + A11V901 + NO3IaLS34 + +

+
+
+
+
+
+
+

+ + COMPONENT + HEIGHT + RESTRICTION + +

+
+
+

+ + (SEE + PLAN + VIEW) + +

+
+
+
+
+
+
+
+
+
+
+

+ + (SOd + 2) + ONIMDVYL + ANY + + + WOS4 + 3384 + 38 + O1 + voav + +

+
+
+

+ + CAVA + 92 + WiOL) + SYOLO3NNO9 + +

+
+
+
+
+
+
+
+

+ + LTO + +

+
+
+
+
+

+ + SOd + 2) + SIN3NOdWOD + ANY + + + WOSs + 3384 + 34 + OL + vaav + +

+
+
+
+

+ + : + @szaze + @ + S3143S + 8y106 + X370N + +

+
+
+
+
+
+
+
+

+ + a2 + +

+
+
+
+
+
+
+

+ + 4.5 + BOTH + SIDES + +

+
+
+
+
+

+ + 1 + + + | + + + 31.75 + CRS + l + 31.75 + CRS + +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ + Page + 24 + of + 115 + pages + +

+
+
+

+ + Revision + 1.00 + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 6. + ASIC + 4 + +

+
+
+

+ + What + is + ASIC + 4? + +

+
+
+

+ + ASIC4 + is + custom + integrated + circuit + designed + for + use + in + Memory + Packs + (called + SSDs) + and + peripheral + + + devices. + Its + primary + purpose + is + to + convert + the + PSION + Serial + protocol + into + the + signals + required + to + + + address + memory + and + memory-mapped + peripherals. + A + typical + Series + 3/3a + ASIC4 + peripheral + will + + + consist + of + an + ASIC4 + connected + to + port + C + of + the + host + machine + and + a + peripheral + chip/device + mapped + + + into + ASIC4's + addressing + space. + An + example + could + be + an + ASIC4 + connected + to + a + simple + 1k + memory + + + device: + +

+
+
+

+ + Chip + select + +

+
+
+

+ + To + write + a + value, + <v>, + to + address + <addr>, + the + appropriate + control + codes + must + be + sent + along + the + port + + + C + Psion + Serial + link + to + assert + <addr> + on + ASIC4's + address + outputs + and + <v> + on + ASIC4's + data + outputs. + +

+
+
+

+ + ASIC4 + Addressing + and + Modes + +

+
+
+

+ + ASIC4 + has + an + 8 + bit + data + bus + and + a + 28 + bit + address + bus. + Also + provided + are + eight + chip + select + lines + that + + + form + selectable + addressing + blocks + each + of + a + size + defined + by + software. + The + default + is + 32Kbyte/block. + + + The + filing + system + will + set + this + to + the + appropriate + size + while + accessing + memory + in + the + upper + portion + of + + + the + address + space. + +

+
+
+
+
+

+ + ASIC4 + has + two + basic + modes + of + operation, + namely + ASIC5 + Compatibility + (or + SSD) + mode + and + ASIC4 + + + Extended + mode. + To + select + the + mode, + ASIC4 + must + be + selected + with + an + appropriate + ID. + This + is + + + achieved + by + writing + a + SIBO + serial + protocol + slave + control + frame, + as + detailed + in + chapter + four, + to + the + + + ASIC + prior + to + sending + any + read + or + write + requests. + After + sending + this + frame, + the + so-called + Info + Byte + is + + + read + off + the + data + bus. + Details + concerning + the + meaning + of + the + various + Info + Byte + bits + are + provided + in + the + + + following + section. + In + the + case + of + SSD + mode, + the + ID + is + 2 + and + for + ASIC4 + Extended + mode, + the + ID + is + 6. + +

+
+
+

+ + Putting + ASIC4 + into + SSD + mode + makes + the + chip + compatible + with + all + current + versions + of + existing + SSD + + + software + in + production + by + Psion + including + all + HC, + series + 3/3a + and + MC + software. + In + this + mode, + ASIC4 + + + mimics + an + ASICS + in + pack + mode + (see + next + chapter). + This + is + because + ASIC4 + was + originally + designed + to + + + be + a + cut-down + version + of + ASICS + and + so + from + the + outset + it + was + necessary + to + make + previously + existing + + + ASICS + software + run + on + the + new + chip. + The + maximum + address + space + in + SSD + mode + is + 21 + address + bits + + + and + 4 + chip + selects + (which + comes + to + 4 + x + 2Mb). + In + ASIC4 + Extended + mode, + ASIC4 + is + capable + of + + + addressing + up + to + 28 + address + bits + (256Mb). + In + this + mode, + in + addition + to + the + Info + Byte, + a + further + 4 + bits + + + of + information + can + be + elicited + from + the + state + of + the + address + lines + A27-A24 + during + reset. + Of + these + bits, + + + the + state + of + A27 + (bit + M) + determines + whether + ASIC4 + is + going + to + be + used + as + a + standard + SSD + (M=0) + or + in + + + a + mixed + mode + (M=1) + comprising + of + memory + devices + and + peripherals. + It + is + only + the + latter + case + which + + + is + of + interest + to + the + potential + developer + since + this + is + the + mode + intended + specifically + for + peripheral + type + + + expansion. + In + mixed + mode + ASIC4's + address + space + is + split + into + two + equal + halves. + The + lower + half + of + + + the + addressing + range + is + set + aside + for + memory-mapped + peripherals + and + can + be + used + for + any + purpose. + + + The + upper + portion + of + the + address + space + is + reserved + for + pure + memory. + The + Series + 3/3a, + Workabout + and + +

+
+
+

+ + Revision + 1.00 + Page + 25 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + HC + filing + system + is + able + to + use + this + memory + (which + does + not + have + to + be + present) + as + an + additional + + + storage + medium. + Typically + it + will + be + a + ROM + containing + the + software + that + controls + the + peripheral. + On + + + reset, + configuration + data + is + supplied + to + ASIC4 + on + its + data + bus + lines + which + the + filing + system + can + read + + + in + order + to + determine + what + form + of + and + how + much + memory + it + has + available + in + this + upper + region. + +

+
+
+

+ + In + mixed + mode + chip + selects + are + split + into + four + selectable + peripheral + blocks + and + four + selectable + memory + + + blocks. + CSO-CS3 + are + for + peripheral + access. + CS4-CS7 + select + memory + devices + one + to + four. + This + set-up + + + is + illustrated + below: + +

+
+
+

+ + Peripherals + + + S1 + + + $2 + + + $3 + + + Total + + + Addressing + S4 + + + Range + Memory + + + (256Mb) + SS + + + S6 + + + S7 + +

+
+
+

+ + Reset + and + configuration + +

+
+
+

+ + As + indicated + earlier, + in + mixed + mode, + following + a + reset + or + power + up + ASIC4 + will + read + the + form + in + which + + + to + configure + itself + from + the + data + on + data + lines + DO-D7 + (the + Info + Byte) + and + address + lines + A24, + A25, + A26, + + + A27 + (most + significant + nibble + of + the + Extended + Info + Byte). + The + table + below + shows + the + meaning + of + each + + + of + these + lines + during + reset. + +

+
+
+
+

+ + | + A27 + | + A26 + | + A25 + | + A24 + | + D7 + | + Do + | + Ds + | + D4 + | + D3 + | + D2 + | + Di + | + DO + | + +

+
+
+

+ + Don't + care, + some + 000 + RAM + 00 + 1 + device + No + memory + + + codes + are + reserved. + | + 001 + Typel + Flash + | + 01 + 2 + 32Kbyte + + + 000 + No + peripheral + | + 010 + Type2 + Flash + | + 10 + 3 + 64Kbyte + +

+
+
+

+ + 001 + T3Link + 110 + ROM + 114 + 128Kbyte + + + 010 + 3Fax + 256Kbyte + + + Contact + Psion + for + 512Kbyte + + + an + official + code. + 1Mbyte + +

+
+
+
+

+ + Pull + up, + pull + down + resisters + would + usually + be + used + to + place + these + lines + in + the + desired + state + on + reset. + + + High + value + resisters + of + typically + 100k + would + be + used + to + allow + ASIC4 + and + bus + devices + to + drive + these + + + lines + to + other + levels + during + normal + operation. + +

+
+
+

+ + ASIC4 + should + be + powered + from + its + host + Series + 3/3a/HC. + High + current + peripheral + chips + or + volatile + + + memories + should + have + their + own + supply. + Whenever + the + Series + 3/3a/HC + is + powered + down, + has + its + + + batteries + removed, + or + has + it's + pack + doors + open, + any + attached + ASIC4 + will + be + powered + down + and + reset + + + upon + resumption + of + power. + Taking + the + 3Fax + as + an + example + with + one + Read + Only + Memory + device + of + + + 512k + the + required + configuration + is: + +

+
+
+
+

+ + Revision + 1.00 + Page + 26 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + ASIC4 + Pin-out + +

+
+
+

+ + Pin + No + Pin + Name + + + 50 + DO + + + 49 + D1 + + + 48 + D2 + + + 47 + D3 + + + 46 + D4 + + + 45 + D5 + + + 44 + D6 + + + 43 + D7 + +

+ +

+ + 13 + AO + + + 12 + Al + +

+ +

+ + 11 + A2 + +

+ +

+ + 8 + A3 + +

+ +

+ + 7 + A4 + +

+ +

+ + 6 + AS + +

+ +

+ + 5 + A6 + +

+ +

+ + 4 + AT + +

+ +

+ + 3 + A8 + +

+ +

+ + 2 + AQ + +

+ +

+ + 1 + Al0 + + + 64 + All + + + 63 + Al2 + + + 62 + Al3 + + + 61 + Al4 + + + 60 + Al5 + + + 29 + Al6 + + + 28 + Al7 + + + 27 + Al8 + + + 25 + Al9 + + + 24 + A20 + + + 23 + A21 + + + 22 + A22 + + + 21 + A23 + + + 20 + A24 + + + 19 + A25 + + + 18 + A26 + + + 17 + A27 + + + 37 + CSO + + + 36 + CS1 + + + 35 + CS2 + + + 34 + CS3 + + + 33 + CS4 + + + 32 + CS5 + + + 31 + CS6 + + + 30 + CS7 + + + 16 + OE + + + 14 + WR + + + 15 + VPS + + + 39 + POR + + + 40 + SCLK + + + 38 + SDAT + + + 59 + SDIR + + + 51 + LBO + + + 56 + MCSD + + + 52 + INO + + + 53 + INI + + + 54 + IN2 + + + 55 + X2D2 + + + 57 + ATST + + + 10 + VDD + + + 42 + VDD + + + 9 + GND + + + 26 + GND + + + 41 + GND + + + 58 + GND + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Direction + + + VO + + + vO + +

+
+
+

+ + fe) + +

+
+
+

+ + ~*=“O0O000000000 + +

+
+
+

+ + fo) + +

+
+
+

+ + PWR + + + PWR + + + PWR + + + PWR + + + PWR + + + PWR + +

+
+
+

+ + Pin + Description + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Databus + +

+ +

+ + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + ATO + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT + 1 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + + + Address + bus + - + register + AT2 + +

+
+
+

+ + Address + bus + - + register + AT2/Oscillator + Output + in + PSPRAM + Mode + +

+
+
+

+ + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Address + bus + - + register + AT3 + Inputs + to + set + device + size + on + reset + + + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Device + chip + selects + +

+ +

+ + Output + Enable/Refresh + in + PSRAM + Mode + +

+ +

+ + Write + pulse + +

+ +

+ + VPP + control + +

+ +

+ + Reset + input + +

+ +

+ + Serial + clock + input + +

+ +

+ + Serial + Data + input + +

+ +

+ + Protocol + Direction + indication + Bit + +

+ +

+ + Low + Battery + detect + driver + output + (Open + drain) + +

+ +

+ + PSRAM + Mode + Select + +

+ +

+ + General + Purpose + inputs + +

+ +

+ + General + Purpose + inputs + +

+ +

+ + General + Purpose + inputs/Refresh + Disable + in + PSRAM + Mode + + + Oscillator + Input + for + PSRAM + Mode + +

+ +

+ + Test + input + (pull + high + to + put + device + into + address + test + mode) + + + Power + inputs + +

+ +

+ + Power + inputs + +

+ +

+ + Ground + +

+ +

+ + Ground + +

+ +

+ + Ground + +

+ +

+ + Ground + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Page + 27 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + A11 + A12 + A13 + A14 + A15 + SDIR + GND + ATST + PS + OSCIN + IN2. + IN1 + INO + LBO + DO + D1 + +

+
+
+

+ + - + LU + Li + Lt + Ly + ae + L + Ls + LI + Li + +

+
+
+

+ + 62 + 61 + 60 + 57 + 56 + 54 + 53 + 52 + 51 + +

+
+
+
+
+
+

+ + 64 + +

+
+
+
+
+

+ + A10 + 48 + D2 + + + AQ + 47 + D3 + + + A8 + 46 + D4 + + + A7 + 45 + D5 + + + A6 + 44 + D6 + + + AS + 43 + D7 + + + A4 + 42 + VDD + + + AS + ASIC4 + 41} + —J + GNo + +

+ +

+ + GND + 40 + SCLK + + + VDD + 39 + POR + + + A2 + 38 + SDAT + + + Al + 37 + cso + + + AO + 36 + cs1 + + + WR + 35 + cs2 + + + VPS + 34 + CS3 + + + OE + 33 + cs4 + +

+
+
+

+ + 17° + 18 + «#19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31° + 32 + +

+
+
+

+ + Rigizipininigiolgipinipimdeig + +

+
+
+

+ + A27 + A26 + A25 + A24 + A23 + A22 + A21 + A20 + A19 + GND + A18 + A17 + A16 + CS7 + CS6 + CS5 + + + OSCOUT + +

+
+
+
+
+
+

+ + Diagram + of + ASIC4 + Pin-out + (NEC) + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Page + 28 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 7. + ASIC + 5 + +

+
+
+

+ + What + is + ASIC + 5? + +

+
+
+

+ + ASICS + is + custom + integrated + circuit + designed + for + use + in + Memory + Packs + (called + SSDs) + and + peripheral + + + devices. + ASICS + provides + three + primary + functions. + A + built + in + UART + provides + for + serial + + + communication + at + baud + rates + of + up + to + 48000 + baud. + General + purpose + I/O + pins + provide + for + a + wide + range + + + of + control + and + communication + applications. + Finally + ASIC5 + provides + address + and + data + lines + for + access + + + to + memory + devices + and + memory + mapped + peripherals. + A + typical + ASICS + peripheral + such + as + the + 3Link + + + consists + of + an + ASICS + connected + to + port + C + of + a + series + 3/3a, + a + ROM + memory + device + mapped + into + + + ASICS's + addressing + space + and + line + drivers + to + convert + the + UART + signals + from + ASICS + into + standard + + + RS232 + levels. + +

+
+
+

+ + Chip + select + +

+
+
+

+ + ASIC5 + rea + Memory + +

+
+
+

+ + RS232 + Line + Drivers + +

+
+
+
+
+

+ + Psion + Serial + link + +

+
+
+

+ + ASIC5 + Modes + +

+
+
+

+ + ASICS + can + operate + in + two + modes. + In + pack + mode + ASICS + generates + all + the + address, + data, + and + control + + + signals + necessary + to + access + memory + devices. + No + peripheral + functions + are + available + in + this + mode. + In + + + peripheral + mode + ASICS + has + only + limited + memory + address + capabilities + as + some + or + all + address + and + + + control + lines + are + reused + for + I/O + purposes. + ASICS + is + placed + into + peripheral + mode + by + setting + the + + + peripheral + bit + in + ASIC5's + PBMODE + register. + +

+
+
+

+ + ASIC5 + as + a + UART + +

+
+
+

+ + ASICS + contains + a + full + function + UART + which + supports + baud + rates + of + up + to + 48000 + bits + per + second. + In + + + order + to + use + ASIC5 + as + a + UART, + ASICS5 + must + be + placed + into + peripheral + mode. + In + this + mode + the + input + + + signals + PAO, + PAI, + PA2, + PA3 + become + the + UART + inputs + RX, + CTS, + DSR, + and + DCD + respectively. + The + + + output + signals + PDO, + PD1, + PD2 + become + the + UART + signals + TX, + RTS, + and + DTR. + Serial + data + is + + + transmitted + from + the + TX + line. + Incoming + serial + data + is + received + by + the + RX + line. + RTS + and + DTR + can + be + + + used + for + handshaking + or + as + general + purpose + outputs + and + need + to + be + set + high + or + low + explicitly + by + + + software. + CTS, + DSR, + and + DCD + can + be + used + for + handshaking + or + as + general + purpose + inputs. + +

+
+
+

+ + The + Psion + SIBO + serial + link + which + connects + ASIC5 + to + a + host + computer + is + a + two + wire + interface + + + consisting + of + a + data + and + a + clock + line. + ASICS + generates + it's + baud + rate + clocks + from + this + clock + line. + + + Under + normal + operation, + clock + pulses + along + a + Psion + SIBO + serial + link + only + accompany + data + frames. + To + + + be + able + to + generate + baud + rate + clocks + ASICS + requires + a + steady + clock + from + the + Hosts + Psion + port. + To + + + facilitate + this, + Psion + serial + links + can + be + put + into + a + mode + called + continuous + clocking + where + clock + pulses + + + are + generated + regardless + of + whether + there + is + any + actual + data + to + be + transferred. + Continuous + clocking + +

+
+
+

+ + Revision + 1.00 + Page + 29 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + increases + power + consumption + and + Psion + serial + links + should + not + be + left + in + this + mode + unnecessarily. + + + The + UART + portion + of + ASICS + is + capable + of + generating + interrupts + when + characters + are + received, + when + + + the + transmitter + is + awaiting + a + character + to + send + and + when + there + is + a + change + of + state + on + the + handshaking + + + lines. + ASICS + has + only + one, + active + high, + interrupt + line. + This + line + is + shared + between + these + interrupt + + + sources. + When + an + interrupt + is + generated + it + is + the + responsibility + of + software + to + determine + the + cause + of + + + the + interrupt. + +

+
+
+

+ + A + character + to + be + transmitted + should + be + written + to + the + Transmitter + Holding + Register + where + ASICS + will + + + convert + it + to + serial + form + for + transmission. + The + register + will + be + emptied + once + the + character + has + been + + + transmitted. + ASIC5 + contains + no + internal + buffering. + The + Transmitter + Holding + Register + must + be + empty + + + before + writing + a + character + to + it. + The + state + of + the + Transmitter + Holding + Register + is + reflected + in + the + + + Transmitter + Empty + bit + in + the + UART + status + register. + Enabling + the + Transmitting + Holding + Register + + + interrupt + will + cause + ASICS + to + generate + an + interrupt + every + time + that + the + Transmitting + Holding + Register + + + becomes + empty. + Reading + the + UART + Status + Register + will + clear + the + interrupt. + Received + characters + are + + + copied + into + the + Receive + Character + Register. + If + the + Receive + Character + Interrupt + is + enabled, + ASICS + + + generates + an + interrupt + on + each + character + received. + If + the + character + is + received + in + error + due + either + + + parity, + framing + or + overrun + errors, + appropriate + bits + in + the + UART + Status + Register + are + set + to + reflect + this. + +

+
+
+

+ + ASIC5 + for + parallel + I/O + +

+
+
+

+ + Lines + PAO-PA7 + form + a + general + purpose, + non + latched, + 8 + bit + input/output + port. + All + access + to + this + port + + + take + a + total + of + twelve + clock + cycles. + The + clock + is + generated + from + the + Psion + Serial + Link. + Actual + + + memory + access + cycles + only + last + for + one + clock + cycle. + Twelve + cycles + are + required + because + data + being + + + sent + or + received + needs + to + be + converted + to + or + from + the + Psion + serial + format. + Because + of + the + conversion + + + read + accesses + occur + on + the + third + cycle, + write + cycles + on + the + twelfth. + This + is + usually + of + no + real + + + consequence + to + the + peripheral + designer + +

+
+
+

+ + In + peripheral + mode + CSO + will + be + taken + low + for + one + clock + period + each + time + Port + A + is + accessed. + Data + + + outputted + from + this + port + will + remain + valid + for + only + the + period + that + CSO + is + low. + In + pack + mode + Port + A + + + forms + the + data + bus + in + memory + mapped + systems. + A + read + from + or + write + to + Port + A + in + this + mode + will + + + result + in + one + of + the + lines + CSO-CS3, + being + taken + low + for + one + clock + period. + The + line + which + will + be + + + taken + low + will + depend + on + the + address + being + generated + for + the + access. + During + read + cycles + OE + line + will + + + be + taken + low + and + remain + so + for + 10 + cycles. + Data + present + on + PAO-PA7 + must + remain + stable + for + the + last + + + nine + cycles. + During + write + cycles + the + WR_B + line + will + be + taken + low + for + the + second + half + of + the + cycle + over + + + which + one + of + CSO-CS3 + is + low. + If + port + B + is + set + to + counter + mode, + accessing + port + A + will + result + in + the + + + counter + being + incremented + upon + completion + of + the + access. + +

+
+
+

+ + ASICS + can + be + programmed + to + generate + an + interrupt + whenever + the + state + of + line + PA4 + changes. + Reading + + + port + A + will + clear + this + interrupt. + One + use + of + PA4 + is + as + the + BUSY + line + in + a + Centronics + port + + + implementation. + +

+
+
+

+ + The + Lines + PBO-PB7 + can + be + programmed + to + operate + in + four + different + modes. + Two + of + these + modes + are + + + for + testing + purposes + and + will + not + be + discussed + further. + In + latched + mode, + data + written + to + the + Port + B + + + resister + is + latched + onto + the + Lines + PBO-PB7 + and + will + remain + there + until + a + following + write + to + Port + B + or + a + + + reset + condition + occurs. + In + counter + mode, + the + binary + value + on + lines + PBO-PB7 + is + incremented + following + + + any + access + to + port + A. + With + ASICS + in + pack + mode + lines + PBO-PB7 + form + the + address + lines + AO-A7. + + + Placing + port + B + into + counter + mode + allows + 256 + consecutive + memory + locations + to + be + read + without + need + to + + + set-up + the + address + of + each + access. + +

+
+
+

+ + Lines + PDO-PD7 + are + general + purpose + outputs. + In + pack + mode + these + form + the + address + lines + A8-A15. + In + + + peripheral + mode + lines + PDO, + PD1, + PD2 + become + UART + outputs. + +

+
+
+

+ + Lines + PCO-PC4 + in + pack + mode + form + the + address + lines + A16-A20. + In + peripheral + mode + lines + PC4 + and + + + PC7 + become + inverted + inputs + and + can + be + used + as + edge + triggered + interrupt + lines. + PC5 + becomes + the + + + interrupt + output + line. + PC6 + becomes + a + general + purpose + latched + output. + PCO-PC3 + become + a + dual + + + synchronous + serial + port + for + use + in + magnetic + card + systems. + +

+
+
+

+ + Revision + 1.00 + Page + 30 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ASIC5 + for + Barcodes + +

+
+
+

+ + Psion + barcode + peripherals + use + the + UART + functionality + of + ASICS + to + receive + data + from + a + dedicated + + + barcode + scanner + IC. + +

+
+
+

+ + ASIC5 + for + Card + readers + +

+
+
+

+ + Magnetic + card + readers + generate + clocked + serial + data. + ASIC5 + contains + two + synchronous + serial + ports + for + + + connection + to + card + readers + or + other + peripherals + which + generate + clocked + serial + data. + +

+
+
+

+ + Reset + and + configuration + +

+
+
+

+ + Following + a + reset + or + power + up + ASIC5 + will + read + the + form + in + which + to + configure + itself + from + the + data + on + + + data + lines + PAO-PA7. + Line + PC6 + is + used + to + select + whether + ASICS + is + to + operate + in + pack + or + peripheral + + + mode. + The + table + below + shows + the + meaning + of + each + of + these + lines + during + reset. + In + peripheral + mode + + + lines + PAO-PA7 + should + be + set + to + give + an + indication + of + the + type + peripheral + the + ASICS + is + forming. + + + combinations + of + types + can + be + used. + +

+
+
+

+ + 000 + RAM + 00 + 1 + device + No + memory + +

+ +

+ + 001 + Typel + Flash + | + 01 + 2 + 32Kbyte + +

+ +

+ + 010 + Type2 + Flash + | + 10 + 3 + 64Kbyte + +

+ +

+ + 110 + ROM + 114 + 128Kbyte + +

+ +

+ + 1 + 1 + 1 + Write + protect + 256Kbyte + + + 512Kbyte + + + 1Mbyte + +

+
+
+
+
+

+ + Peripheral + Mode + Type + +

+
+
+

+ + RS232 + port + + + Centronics + (Parallel) + port + +

+
+
+

+ + Hx + KK + KK + XX + + + xo + KKM + KK + XX + +

+
+
+

+ + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + +

+
+
+
+

+ + Pull + up, + pull + down + resisters + would + usually + be + used + to + place + these + lines + in + the + desired + state + on + reset. + + + High + value + resisters + of + typically + 100k + would + be + used + to + allow + ASICS + and + bus + devices + to + drive + these + + + lines + to + other + levels + during + normal + operation. + +

+
+
+

+ + ASICS + should + be + powered + from + its + host + Series + 3/3a, + Workabout + or + HC. + High + current + peripheral + chips + + + or + volatile + memories + should + have + their + own + supply. + Whenever + the + Series + 3/3a/HC + is + powered + down, + + + has + its + batteries + removed + or + has + its + pack + doors + open, + any + attached + ASICS + will + be + powered + down + and + + + will + be + reset + upon + resumption + of + power. + +

+
+
+

+ + Revision + 1.00 + Page + 31 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ASIC5 + Pin-out + +

+
+
+

+ + A10 + Ali + A1l2 + Ai3 + NC + A14 + A15 + DO + D1 + D2 + +

+
+
+

+ + DONO + o + net + +

+
+
+
+
+
+

+ + ASIC5 + +

+
+
+
+
+

+ + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + +

+
+
+

+ + MAMAMAAMMo + +

+
+
+

+ + WR + VPS + OE + A20 + A19 + NC + A18 + A17 + A116 + CS3 + CS2 + +

+
+
+

+ + ASIC + 5 + current + pin-out + (TI + version + CF30179) + +

+
+
+
+
+
+

+ + Revision + 1.00 + Page + 32 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 8. + EXAMPLE + PERIPHERALS + +

+
+
+

+ + The + ASIC4 + Example + Interface + Board + +

+
+
+

+ + The + ASIC4 + Example + Interface + Board + detailed + in + this + chapter + is + intended + to + provide + the + developer + with + + + a + simple + example + of + a + Psion + ASIC4 + peripheral. + To + this + end, + the + actual + practical + usefulness + of + the + + + hardware + is + of + secondary + importance. + In + fact, + the + board + essentially + consists + of + eight + LEDs + connected + + + via + some + latches + to + an + ASIC4. + Using + a + device + driver, + the + host + machine + is + able + to + control + the + status + of + + + the + LEDs. + Specifically, + the + board + translates + SIBO + serial + protocol + signals + into + a + parallel + 8-way + data + + + bus + format + that + can + be + used + to + set + the + various + 74HC + series + latches + and + gates. + It + is + intended + that + the + + + board + can + be + readily + adapted + to + run + on + all + currently + available + Psion + machines. + The + only + physical + + + change + that + need + be + made + concerns + connection + to + the + host + machine's + external + expansion + interface. + +

+
+
+

+ + In + the + following + circuit, + an + eight-bit + tri-state + data + buffer, + U3, + and + an + eight-bit + output + data + latch, + US, + + + are + commoned + together + to + the + eight + LEDs + thereby + enabling + their + status + to + be + sensed + and + set. + In + + + addition, + a + facility + for + generating + hardware + interrupts + is + provided + by + means + of + a + suitably + connected + + + switch, + S1, + and + a + third + eight-way + buffer, + U4. + U4 + is + the + interrupt + switch + status + buffer. + It + holds + the + + + values + of + the + two + input + switches + S2 + and + S3 + which + are + read + as + part + of + the + interrupt + service + routine. + + + Depending + on + the + value + of + the + switch + positions, + a + different + response + can + be + output + to + the + LEDs + from + + + the + set + buffer, + US. + One + of + the + D-type + flip-flops + in + U6 + is + used + to + latch + hardware + interrupt + signals + into + + + the + INT + line + (pin + 5) + of + the + reduced + external + expansion + interface + connector. + On + completion + of + the + + + interrupt + routine + code, + it + is + necessary + to + reset + this + flip-flop + and + hence + the + interrupt + hardware + by + means + + + of + a + write + to + address + Al. + Address + decoding + is + provided + by + two + 2-to-4 + decoders + on + chip + U1 + paralleled + + + to + address + lines + AO + and + Al. + A + circuit + diagram + of + the + ASIC4 + Example + Interface + Board + is + presented + + + overleaf + for + the + case + of + a + host + S3a. + +

+
+
+

+ + Note + that + it + is + possible + to + construct + this + circuit + with + or + without + the + compiled + driver + code + in + an + on- + + + board + ROM. + The + developer + merely + has + to + set + the + resistors + on + the + three + data + bus + lines + DO-D2 + such + that + + + the + corresponding + info + byte + conveys + the + appropriate + information. + The + meaning + of + the + various + bits + in + + + an + ASIC4 + info + byte + was + discussed + earlier + in + chapter + 6. + If + a + ROM + is + to + be + used, + then + the + info + byte + read + + + off + DO-D7 + on + reset + should + include + bits + 001 + on + lines + D2-D0. + This + requires + the + R1/R2 + optional + resistor + + + to + be + connected + to + Vcc. + If + a + ROM + is + not + used, + as + was + the + case + with + the + constructed + test + circuit, + the + + + data + bus + lines + D2-D0 + should + be + set + to + 000. + This + is + done + by + choosing + the + resistors + connected + to + ground + + + from + the + three + R1/R2, + R3/R4 + and + R5/R6 + pairs. + +

+
+
+

+ + Revision + 1.00 + Page + 33 + of + 115 + pages + +

+
+
+ +
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ + VOD + + + voc + voc + voc + voc + + + 3 + + + cs + ca + cio + _|+ + caa + For + 128K + Bute + ROM + fit + option + resistors + Ri, + R4, + RG, + RE + and + Rio + eibe + + + idon + toon + ioon + Our + evs + For + no + ROM + fit + option + resistors + RZ, + R4, + RE + bo + 2 + + + ue + ve + ve + as + VOD + + + SNC + GND + GND + GND + + + 1 + + + 3 + + + Xf + RE-/R4 + + + vor + GND + + + res + Di + 2g + 100K + + + ag + voo + | + 338 + + + bo + = + ae + base + es + Do + + + Di + 14 + Bd + 1 + + + AS + Bi + + + DE + Be + be + (45 + De + + + veo + DS + ce + be + Cie + mE + v + Biel + + + Da + 18 + ba + SNC + + + oS + + ba + Te + DS + + + az + BS + + + R22 + [ery + AS + be + 20 + [T= + 3 + + + 100K + Br + aS + BS + [ei + isk + RE + RE + + + aio + fa + 100K + + + ort + ze + | + 22 + bz + z + + + Al2 + + + ails + oe + [24 + + + 7 + ate + 1 + + + aaa + oe + awe + hae + + + Aiz + L + + + ae + GND + + + eto + nigga + | + ao + + + vor + voc + + + ZEK—ine + ROM + DS + R16 + 100K + + + Ss + Is + + + RT-RE + RS/RL0 + + + vos + z + z + + + 7 + FaHcT4a + + + ja + oR + oR + + + R26 + + + Rea + 100K + 1 + 1 + DF + R20. + 100K + + + LooR + + + GND + + + GND + + + Ree + SND + + + aoe + t + R27 + ba + + + voc + LED + GND + + + CONNL + + + sp7 + bo + * + 0 + + + sck7 + b-# + = + Bo + 18/ivi + = + 1ai + +329 + + + = + Di + is + a_i + LED + ND + + + sDSs/INT + iv2 + 0 + 1Az + + + SCKS/“EXON + a + Wie + D2 + 14 + is. + 1AS + & + P2 + + + z + z + Ds + iz + = + Ps + + + Wor + * + a + vo + ava + iaa + + + 4 + z + bas + ii_F4 + + + She + , + a. + be + revi + 281 + Ge + re + LED + GND + + + YE + 2Yz + ZAz + + + CON + COMMS + CONN + be + oer + te + be + S| + S02 + 282 + (re + Pe + + + bre) + S)5: + Soy + bere + + + FPS4HC1sg + + + GND + te + het + LED + GND + + + vor + 28 + brs + + + DL + uza + + + 1 + OE + 4 + ae + FaHceas + FaHCETS + + + z + 3 + ORD + LED + ND + + + 2 + cso + 2 + FaHca4d + + + A + t + ua + + + WF + Baves + clr + Se + T4Hese + DO + 18 + Tyg + LAL + + + GND + 1006F + El + tel + ge: + {ee + LED + GND + + + 1B + a + De + 14 + + + ive + 9 + 1az + + + Mee + Nf + 14) + 4 + vo + BS + tetiva + iad + + + D2 + GND + U2B + is + ba + 3 + + + B + vi + Zvi + ZAL + + + 4 + WR + 4 + oS + + + LED + GND + + + Y2 + 2vz + BAZ + + + = + 6 + Lor + 15 + bss + + + Gc + YS + 2yYe + 2As + + + =P + = + Dre + 3/oy4q + Baa + + + FaHCLss + + + yo + OBAYSS + FaHese + ee + 470 + LED + GND + + + GND + Vos + a + Si + voc + ¥ + v + + + vos + J" + GND + SND + DATA + OUTPUT + + + vor + FaHCe44 + + + DOS + la + Us6Al + Lk + Interrupt + Sw + + + a: + + + = + Ne + Saal + = + a + B + Db + 2 + CC? + 1993 + (PSIOS + PLS. + + + aa + ADDRESS + R-M + FUNC + 3 + Interrupt + In + + + + + Bava + fal + RYH + Read + & + write + to + latch + SLK + Eiki + Sp + ee) + omnes + + + GND + rs + Md + Clear + Interrupt + els; + = + R25 + + + 1 + R + Read + status + 100K + Poe + REY + : + oO + + + status + Bit + Func + F4HCr4 + Title + + + a + Ineut + a + + + L + Tneut + 1 + > + ASICS + Example + IF + + + 2-5 + Not + Used + GND + GND + Size + Pocument + Number + REV + + + 6 + Interrupt + Line + B + 7 + lo.s + + + ? + Interrupt + Latch + : + + + Date: + Aerial + 19, + 1995|[Sheet + i_of + Z + +

+
+
+
+
+
+
+

+ + Page + 34 + of + 115 + pages + +

+
+
+

+ + 1.00 + +

+
+
+

+ + 1S10n + +

+
+
+

+ + Rev + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + Psion + 3-Link + +

+
+
+

+ + The + Psion + 3-Link + is + an + ASIC5-based + peripheral + that + enables + the + user + to + transform + SIBO + serial + + + protocol + signals + into + RS232 + format + data + so + that + a + host + Psion + machine + can + communicate + with + a + PC + or + + + printer. + The + diagram + below + shows + the + schematic + of + a + TTL + level + RS232 + based + expansion + device. + The + + + interface + is + based + around + ASICS + and + allows + the + standard + RS232 + device + driver + contained + in + EPOC + to + + + be + used. + +

+
+
+

+ + Transistor + Q1 + provides + a + switched + power + rail + for + any + other + expansion + device. + This + rail + will + + + automatically + be + switched + off + when + the + RS232 + port + is + closed. + D1 + is + required + to + isolate + the + supply + so + + + that + the + external + device + does + not + back + power + the + SIBO + computer + when + it + enters + the + standby + state. + If + + + the + additional + device + does + not + require + a + supply + or + only + uses + a + few + microamps + then + Q1 + and + D1 + can + be + + + omitted. + Vcc + and + the + supply + for + the + expansion + device + can + be + directly + connected + to + Vcc2. + +

+
+
+

+ + If + CMOS + level + RS232 + signals + are + required + then + IC1 + can + be + replaced + with + a + 74HC244 + device. + If + + + inverted + sense + RS232 + signals + are + required, + IC1 + can + be + replaced + with + a + 74HC241 + device. + +

+
+
+

+ + The + diagram + overleaf + shows + the + circuitry + for + an + ASICS-based + 3-link + with + ROM. + +

+
+
+

+ + Revision + 1.00 + Page + 35 + of + 115 + pages + +

+
+
+ +
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ + vec + + + Rig + + + Icz + vec + 100K + + + 64/128K + PROM + SITE + E + + + B + + + ag + 12Tag + wy + po + Laz + ba + + + ta + ¥ + 14 + Di + + + AL + D1 + + + To + é + TS + Be + + + Az + Dz + + + g + id + Da + + + as + DS + + + 3 + tg + ba + + + Aa + ba + + + id + 15 + DS + + + aS + DS + + + 20 + DE + + + AS + De + }s¢ + = + + + ay + DF + + + ae + voc + voc + + + ag + + + Alo + vec + + + AlL + - + + + A1lz + ne + |S? + + + ars + ver + 4 + i + + + Ais + Pst + [22 + +08 + ce + cz + + + $3 + rea + Our + /25v + idon + io0n + + + Ale. + + + + + N + + + B + + + * + + + T + + + le + t + GND + + + GND + + + ND + Fs + + + ey + eee + 2g + + + Re + 100K + TRL + + + + + BCH + 1 + cs + cz + + + + + 1ur/50¥ + LuF/so¥ + + + GND + vee + + + mS + 1 + | + s + + + aL + + + rs + + + 82 + (ita + 1 + ies + + + veo + 22 + [aa + i + wees + + + 23 + i + 19° + + + iOurv2sy + + + D1 + Fi + 14 + + + ¢ + 13 + + + " + 24s + ex + i + ca + + + | + 1 + 4 + aa + c + + + = + vor + 15 + | + coy + yo + LAZ + ayes + + + 2 + t + 16 + 7 + SKT1 + CASE + + + za + 2- + Fi + + + Teu + uF + 7254 + + + BAYS? + I + FaHorS + 7d + TitN + taout + 2 + GND + SKTL + + + 36 + e + _DTR + + + PBO + + PAD + TBIN + TZOUT + RLSD/bco| + + + ba + PBL + © + pai + }32 + 294 + 7 + SIN + TzouT + 2 + rs + RX + + + 4 + tad + Sa + ei + ze + _Tx + + + x + * + PBZ + paz + [3 + T4IN + T40UT + Tx + + + 2 + PES + paz + = + 3 + Pare + DIR + + + PB4 + paa + [22 + £4 + R1OuIT + R1IN + p32 + _RX__§_+ + t + GND + + + a + ee + PBS + pas + fed + eno + se] + RZOUT + R2IN + Pst—Bek + . + DSR + + + PES + Pas + pse + 25) + REOUT + RSIN + bee—GeR + 4 + RTS + + + PE? + PA? + R4ouT + RaIN + * + cts + + + DS, + ig + Te + RI + + + * + a + WEE + + RS0UT + . + RSIN + * + RI + + + PDO + poco + i + at + S| + + + = + a + PDL + pci + H2 + 24 + eR + ql + sp + }25 + SIBO + RS2S2 + CONNECTOR + + + PDE + pez + He + ibe + Ria + L + c + + + BAYSS + co: + pea + fas + REG + Too + 100K + a + mMaxzan + GND + + + 12 + ciolesilcizicizicis4 + + + PDS + pes + + + SMB + PDS + roe + 3S + + + PD? + pe? + L414 + L + GND + in + Jin + Jin + Jain + Jain + + + | + 1008 + R4 + 25 + /ep + zen + b24 + GND + vovVoov¥ + vo + + + 1O5R + at + 27 + €39 + Pox + GND + GND + GND + GND + GND + + + ' + CLK + eSi + + + 26 + 2 + + + FOR + cs2 + + + i7q + Fo + s + T + + + 3g + N53 + PIL + + + cs + NG + BD + ¢np + PL2 + fh + + + 100pF + iz + + + veo + asics + [8 + 4 + + + GND + + + GND + ND + R? + + + RL + 100R + + + 100K + Sue + + + o——___| + + + cL + SH + SPDT + + + vee + 100n + + + CONNI + + + cer + GND + + + SRT + ee + RG + RS + + + SDS/INT + BS + Copuriaht + CC) + Psion + PLO + 1991 + + + ScKS/ExON + PS + + + Vee + bs + File + name! + CONHH + DRAFT + RS232.5CH + + + yee + Bg + ioorR + is + a + 10k + Braun: + MG + + + CON + COMMS + CONN + R20 + B2xe4—Cay7 + PCB + Rey + 1.4 + + + 100K + Title + + + ¥ + 2|a + + + GND + Rev + 1.2 + Move + SD + (pin + 25 + IC2> + from + pin + 23 + to + 21 + of + Ici + : + EONSUMER + Bases + ExCeL + on + + + Rev + 1.3 + Alter + Ri? + from + 100K + to + 10K + Size + Pocument + Number + REV + + + Rev + 114 + Added + C1io—c14 + = + + + Rev + 1.5 + Moved + C3 + to + CLK + input + GND + GND + is + 6500.0008 + cata + + + Date: + June + i0, + i953 + Sheet + i + oF + L + +

+
+
+
+
+
+
+

+ + Page + 36 + of + 115 + pages + +

+
+
+

+ + 1.00 + +

+
+
+

+ + 1S10n + +

+
+
+

+ + Rev + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 9. + DEVICE + DRIVER + OVERVIEW + +

+
+
+

+ + Introduction + +

+
+
+

+ + Once + a + piece + of + peripheral + hardware + has + been + designed + the + appropriate + software + must + be + written + to + + + control + it. + All + hardware + on + Series + 3/3a, + Workabout + and + HC + machines + is + controlled + by + logical + and + + + physical + device + drivers. + These + act + as + the + logical + low-level + software + interface + between + a + piece + of + + + hardware + and + an + application + that + uses + it. + The + remainder + of + this + document + is + concerned + with + the + + + methods + by + which + a + device + driver + is + able + to + communicate + with + and + thereby + control + an + ASIC4 + or + + + ASICS-based + peripheral. + +

+
+
+

+ + APPLICA + TION + SOFTW + ARE + +

+
+
+

+ + Psion + C + PLIB + call + interface + + + LOGICAL + DEVICE + DRIVER + +

+
+
+

+ + PHYSICAL + DEVICE + DRIVER + +

+
+
+
+
+

+ + PHYSICAL + HARDW + ARE + +

+
+
+

+ + This + chapter + is + intended + to + guide + the + programmer + through + the + central + issues + involved + in + writing + + + device + drivers + for + peripherals + that + attach + to + the + family + of + Psion + host + machines + based + around + the + + + proprietary + SIxteen-Bit + Organiser + (SIBO) + architecture. + The + purpose + of + a + device + driver + is + to + abstract + + + away + the + hardware + details + required + to + conduct + communication + between + a + peripheral + and + a + software + + + application + that + uses + that + peripheral. + The + device + driver + therefore + performs + the + logical + processing + + + required + to + translate + low + level + hardware + instructions + into + high + level + application + services. + Psion + device + + + drivers + are + written + in + 8086 + assembler + and + following + convention + are + divided + into + a + logical + layer + + + residing + over + a + physical + layer. + A + physical + device + driver + (PDD) + contains + the + code + required + for + talking + + + directly + with + the + hardware + device + and + provides + a + set + of + low + level + hardware + specific + services. + A + logical + + + device + driver + (LDD) + performs + the + logical + processing + that + transforms + these + low + level + services + into + the + + + high + level + services + used + by + an + application. + This + two-layer + nature + of + device + drivers + at + Psion + can + be + + + illustrated + by + the + following + example. + An + application + using + the + serial + driver + decides + that + it + requires + + + RTS/CTS + handshaking. + It + calls + an + LDD + which + decides + whether + or + not + a + line + should + be + driven. + If + the + + + answer + is + yes, + the + LDD + calls + the + appropriate + PDD + and + asks + for + a + particular + line + to + be + driven + to + a + + + specific + state. + The + PDD + duly + carries + out + the + requested + service. + Psion + SIBO + machines + often + use + the + + + same + LDD + with + a + PDD + written + specifically + for + each + version + of + the + hardware + device. + In + such + a + + + situation, + splitting + the + device + driver + is + highly + desirable. + In + the + example + given + above, + however, + the + + + LDD + could + have + talked + directly + with + the + hardware + negating + the + requirement + for + a + separate + PDD. + + + Similarly, + most + external + peripherals + would + normally + use + an + LDD. + +

+
+
+

+ + An + LDD + must + provide + a + minimum + of + eight + functions + for + use + by + the + operating + system. + The + functions + + + are + passed + to + the + OS + via + a + table + of + function + offsets + (referred + to + as + the + vector + function + table). + These + + + functions + are + mandatory. + Similarly, + a + PDD + must + provide + two + functions + for + use + by + the + operating + + + system + and + may + provide + more + if + required. + An + LDD + will + usually + provide + further + services/functions + for + + + use + by + an + application. + The + form + these + take + is + dependent + on + the + LDD + requirements + and + the + functions + + + supplied + by + the + associated + PDD(s). + +

+
+
+

+ + Revision + 1.00 + Page + 37 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Psion + SIBO + machines + are + supplied + with + a + set + of + resident + device + drivers + built + into + the + ROM + each + of + + + which + can + be + replaced + with + an + installable + device + driver + having + the + same + name. + Installable + device + + + drivers + can + also + be + added + to + increase + the + number + of + available + device + drivers. + Installing + a + device + driver + + + is + carried + out + dynamically + without + resetting + the + machine + (this + is + not + the + case + with + many + operating + + + systems). + +

+
+
+

+ + Device + Names + and + Channels + +

+
+
+

+ + The + name + of + a + device + driver + is + the + mechanism + by + which + an + application + can + obtain + a + channel + to + that + + + device + driver. + A + logical + device + driver + name + always + has + three + characters + followed + by + a + colon. + For + + + example, + "TTy:" + is + the + serial + LDD. + This + name + is + required + to + uniquely + identify + the + LDD + to + the + EPOC + + + OS + when + attempting + to + open + a + channel + on + it. + A + physical + device + driver + name + always + has + the + three + + + characters + of + its + owning + LDD + followed + by + a + period, + a + further + three + characters + and + a + colon. + For + + + example + "TTy.UAR" + is + the + ASICS + UART + driver + and + "TTy.srRx" + is + the + 16450/16550 + driver. + The + first + + + three + characters + of + a + PDD + name + are + the + name + of + the + LDD + to + which + the + PDD + belongs. + The + second + set + + + of + three + characters + uniquely + identify + the + PDD. + Thus + in + the + above + examples, + both + PDDs + belong + to + the + + + "tty:" + LDD. + +

+
+
+

+ + A + channel + can + be + opened + on + an + LDD + by + calling + the + PLIB + library + function + p_open. + EPOC + uses + the + + + driver + name + passed + through + an + application + p_open + call + to + invoke + the + IoOpen + operating + system + + + service. + This + service + in + turn + calls + the + associated + driver + ‘open + vector’ + which + can + decide + whether + or + not + + + to + open + a + channel + on + the + driver. + The + assembled + ASIC4 + Example + Interface + Board + logical + device + + + driver, + A4EXIF.LDD, + for + example, + has + the + three-character + device + name + "LED" + so + a + channel + with + its + + + handle + in + pcb + may + be + obtained + on + it + by + means + of + the + following + call: + +

+
+
+
+
+

+ + p_open(&pcb, + "LED:", + -1) + +

+
+
+

+ + In + this + call, + the + third + argument + refers + to + the + open + mode + and + a + value + of + -1 + indicates + that + the + mode + + + parameter + is + to + be + ignored. + To + obtain + a + channel + on + a + PDD, + an + application + should + call + the + DevopenPpp + + + OS + service. + Typically, + only + LDDs + open + PDDs + though + the + p_open + library + function + can + be + used + to + open + + + a + PDD + indirectly + as + illustrated + in + the + following + example: + +

+
+
+

+ + p_open(&pcb, + “"TTY.UAR:", + -1) + +

+
+
+

+ + For + a + device + driver + configuration + consisting + of + an + LDD + and + a + PDD, + the + application + will + usually + open + + + a + channel + to + the + LDD + only: + the + LDD + as + part + of + its + initialisation + would + open + a + channel + to + the + required + + + PDD. + If + an + LDD + requires + a + PDD + and + none + is + specified, + it + is + up + to + the + LDD + to + either + fail + the + open + + + request + or + hunt + for + a + loaded + PDD + that + it + can + use. + An + LDD + uses + the + DevFind + OS + service + to + search + for + + + a + PDD + as + for + instance + in + the + case + of + the + "TTy:" + device. + +

+
+
+

+ + A + device + driver + may + be + capable + of + supporting + more + than + one + open + expansion + channel + at + a + time. + In + + + order + to + distinguish + the + channels, + a + qualifier + can + be + added + to + the + open + request + as + part + of + the + device + + + name. + It + is + then + up + to + the + device + driver + to + specify + the + format + of + the + qualifier. + By + convention, + + + channels + are + allocated + a + single + character + sequentially + from + the + character + 'A'. + For + example, + the + + + parallel + port + driver + can + support + two + open + channel, + 'A' + and + 'B'. + The + LDD + requires + one + of + these + + + qualifiers + in + order + to + open + a + parallel + driver + channel: + +

+
+
+

+ + p_open(&pcb, + "PAR:A", + -1) + + + p_open(&pcb, + "PAR:B", + -1) + +

+
+
+

+ + The + number + of + channels + that + can + be + thus + supported + will + in + general + be + dependent + on + the + host + SIBO + + + hardware. + In + the + case + of + the + serial + port + on + the + S3a, + for + instance, + only + one + SIBO + channel + can + + + legitimately + be + opened + corresponding + to + expansion + port + C. + With + the + Workabout + and + HC, + however, + it + + + is + possible + to + open + up + to + three + separate + SIBO + channels + on + ports + A + through + to + C + where + A + refers + to + the + + + top + port + of + the + host + machine, + B + to + the + bottom + port + and + C + to + the + side + (or + cradle) + port. + +

+
+
+

+ + LDDs + have + been + designed + to + be + accessed + via + the + I/O + system. + I/O + requests + on + the + opened + channel + will + + + reach + the + 'strategy + vector' + of + the + device + driver. + PDDs + have + been + designed + to + be + accessed + by + an + LDD + +

+
+
+

+ + Revision + 1.00 + Page + 38 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + either + via + far + calls + or + the + Devvector + OS + system + service. + Once + a + channel + has + been + obtained + on + a + + + device + driver, + the + operating + system + can + send + it + events + not + sent + to + other + applications. + Examples + are + + + events + generated + by + the + machine + being + switched + on + or + off, + memory + segments + being + moved + about + and + + + the + owning + application + being + panicked. + The + EPOC + OS + can + handle + a + maximum + of + 32 + device + drivers + + + on + a + Series3 + machine + and + 48 + on + other + machines. + +

+
+
+

+ + Loadable + Logical + Device + Driver + Structure + +

+
+
+

+ + Common + features + of + the + structure + of + loadable + LDDs + +

+
+
+

+ + All + loadable + LDDs + must + conform + to + the + following + rules: + +

+ +

+ + e + There + must + be + a + single + code + segment + and + no + data + segments. + The + code + segment + is + encapsulated + in + + + the + assembler + .asm + file + by + calls + to + the + codeSeg + and + EndCodeSeg + defines + respectively. + +

+ +

+ + e + The + code + segment + must + begin + with + a + LibEnt + structure + which + indicates + the + LDD + name + or + + + signature + which + is + used + to + identify + the + driver + when + trying + to + open + and + close + channels. + +

+ +

+ + e + There + must + be + at + least + eight + supported + functions + which + are + listed + in + the + LibEnt + struc. + +

+
+
+

+ + LibEnt + Structure + +

+
+
+

+ + The + first + field + of + the + LibEnt + structure + consists + of + a + two-byte + signature + containing + the + define + + + ‘LDDSignature’ + or + 'PDDSignature’ + in + the + case + of + a + PDD. + The + remaining + fields + consist + of + an + eight + + + byte + name + which + holds + the + device + driver + name + stored + as + a + zero + terminated + string + (note + that + the + + + trailing + colon + is + omitted), + a + two + byte + vector + count + which + must + be + at + least + eight + and + a + vector + table + + + listing + the + supported + device + driver + functions. + The + relevant + code + in + the + case + of + a + hypothetical + DevFunc + + + LDD + (DEVFUNC.LDD) + with + the + device + name + of + "TES:" + is + listed + below: + +

+
+
+

+ + CodeSeg + +

+
+
+

+ + ProcBegin@ + DevFuncLDD + +

+
+
+
+
+

+ + dw + LDDSignature + + + db + 'TES',0,0,0,0,0 + + + dw + (VectorEnd-Vector) + /2 + + + Vector: + + + dw + DevFuncInstall + + + dw + DevFuncRemove + + + dw + DevFuncHold + + + dw + DevFuncResume + ; + Mandatory + LDD + vectors + + + dw + DevFuncReset + ; + must + be + in + this + order + + + dw + DevFuncUnits + + + dw + DevFuncOpen + + + dw + DevFuncStrategy + + + VectorHandler: + + + dw + DevFuncHandler + ; + Optional + LDD + vectors + + + InterruptVectors: + + + dw + DevFuncTickInt + + + VectorEnd: + +

+
+
+

+ + ProcEnd + noret + + + The + vector + table + contains + the + offsets + within + the + device + drivers + code + segment + for + the + functions + required + +

+
+
+

+ + by + the + EPOC + operating + system + which + must + be + entered + in + the + order + shown. + Note + that + in + this + + + document, + the + terms + vector + and + function + are + used + interchangeably. + +

+
+
+

+ + Mandatory + LDD + Functions + +

+
+
+

+ + All + LDDs + must + support + the + following + eight + functions: + +

+
+
+

+ + @ + DevFuncInstall + called + on + device + installation + +

+ +

+ + @ + DevFuncRemove + called + on + device + removal + +

+ +

+ + @ + DevFuncHold + called + to + temporarily + disable + the + driver + +

+ +

+ + @ + DevFuncResume + called + to + enable + the + driver + after + it + has + been + temporarily + disabled + +

+
+
+

+ + Revision + 1.00 + Page + 39 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + @ + DevFuncReset + called + when + an + application + terminates + without + closing + the + channel + + + @ + DevFuncUnits + called + to + query + the + number + of + supported + units + (i.e. + channels) + +

+ +

+ + @ + DevFuncOpen + called + to + open + a + channel + to + an + LDD + +

+ +

+ + @ + DevFuncStrategy + called + to + access + the + driver's + functionality + from + the + I/O + system + +

+
+
+

+ + All + of + the + eight + mandatory + routines + pointed + at + by + the + function + vector + table + will + be + called + FAR + by + the + + + operating + system + and + should + therefore + use + a + FAR + return + machine + code + instruction + to + return + control + + + back + to + the + OS. + Since + the + FAR + return + address + is + to + the + OS + it + does + not + matter + if + the + OS + moves + memory + + + whilst + code + in + the + LDD + is + being + executed: + the + OS + cannot + move + its + own + code. + +

+
+
+

+ + DevFunclinstall + +

+
+
+

+ + This + function + is + called + by + the + operating + system + when + the + device + driver + is + loaded + in + order + to + initialise + + + any + internal + variables. + It + should + not + be + called + directly + by + an + application + process. + The + DevInstall + + + operating + system + service + will + cause + this + function + to + be + called. + Applications + should + not + call + this + service + + + directly + and + should + call + instead + the + DevLoadLDD + service. + +

+
+
+

+ + An + installable + device + driver + may + have + the + same + name + as + a + resident + device + driver. + When + the + operating + + + system + loads + a + device + driver, + it + places + it + at + the + end + of + the + device + driver + table. + The + operating + system + + + will + search + this + table + for + the + appropriate + device + driver + when + it + wishes + to + establish + a + channel. + The + + + search + starts + at + the + end + and + thus + will + locate + the + most + recently + installed + device + driver + (if + any) + or + if + not, + + + the + resident + driver. + By + this + mechanism + an + installable + driver + can + replace + any + resident + driver. + +

+ +

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state. + The + device + driver + should + + + take + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + + + this + involves + setting + the + DS + and + ES + registers + to + the + CS + register + or + more + commonly + just + using + the + CS + + + override. + The + operating + system + will + not + move + memory + whilst + in + this + function, + thus + the + normal + rules + + + governing + DS + and + ES + may + be + ignored. + All + operating + system + services + may + be + called, + except + those + + + concerning + file + or + device + access. + +

+ +

+ + PASSED + +

+ +

+ + No + values + are + passed + to + the + install + vector. + +

+ +

+ + RETURN + +

+ +

+ + If + the + installation + was + successful, + return + with + the + carry + flag + clear. + +

+ +

+ + If + the + installation + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + PANIC + +

+ +

+ + The + install + vector + must + not + panic: + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + install + function. + +

+
+
+

+ + DevFuncRemove + +

+
+
+

+ + This + function + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + be + + + unloaded. + It + should + not + be + called + directly + by + an + application + process. + The + DevRemove + operating + system + + + service + will + cause + this + function + to + be + called. + Applications + should + not + call + this + directly, + they + should + use + + + the + DevDelete + service. + Before + the + remove + function + is + requested, + the + device + driver + will + have + received + + + a + hold + request. + Thus + devices + will + only + ever + be + removed + when + in + a + held + state. + If + the + device + driver + is + + + currently + busy + serving + a + client, + the + remove + request + should + return + an + error. + Note + that + all + resident + + + device + drivers + will + return + an + error + since + there + is + no + mechanism + by + which + they + can + be + re-installed. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + operating + system + will + not + move + + + memory + whilst + in + this + function, + thus + the + normal + rules + governing + DS + and + ES + may + be + ignored. + All + + + operating + system + services + may + be + called + inside + the + remove + vector, + except + those + concerning + file + or + + + device + access. + +

+ +

+ + PASSED + +

+ +

+ + No + values + are + passed + to + the + remove + vector. + +

+ +

+ + RETURN + +

+ +

+ + If + the + remove + was + successful, + return + with + the + carry + flag + clear. + +

+ +

+ + If + the + remove + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + +

+
+
+

+ + Revision + 1.00 + Page + 40 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + PANIC + +

+ +

+ + The + remove + vector + must + not + panic: + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + remove + vector. + +

+
+
+

+ + DevFuncHold + +

+
+
+

+ + This + vector + will + be + called + by + the + operating + system + when + a + logical + device + driver + is + requested + to + be + held. + + + The + hold + vector + is + called + in + the + context + of + the + operating + system + so + DS + and + ES + are + not + available. + The + + + DevHold + operating + system + service + will + cause + this + vector + to + be + called. + Applications + should + not + call + this + + + service. + Physical + device + drivers + cannot + invoke + holds + and + resumes. + The + operating + system + will + call + the + + + hold + vector + under + three + conditions: + +

+ +

+ + e + Device + memory + segments + are + about + to + be + moved. + +

+
+
+

+ + e + The + machine + is + about + to + switch + off + due + to + the + auto + switch + off + time-out + or + user + request, + it + + + enters + the + standby + state. + +

+
+
+

+ + e + The + machine + is + about + to + switch + off + due + to + the + power + source + being + removed. + +

+
+
+

+ + It + should + be + noted + that + holds + and + resumes + are + called + on + a + per + driver + basis + and + so + the + corresponding + + + driver + code + must + deal + with + all + the + currently + open + channels. + In + all + cases + the + device + driver + must + + + respond + to + the + request + as + quickly + as + possible. + It + must + also + ensure + that + ALL + interrupts + from + the + + + hardware + device + that + it + is + driving + are + disabled. + Device + memory + segments + can + only + be + moved + if + an + + + installable + device + driver + is + being + installed + or + removed. + If + the + LDD + uses + an + attached + PDD + and + uses + the + + + faster + FAR + call + mechanism + to + call + the + PDD + strategy + vector, + the + PDD + strategy + vector + address + will + + + potentially + move, + thus + the + FAR + address + will + be + wrong. + This + address + can + be + resolved + in + the + resume + + + vector. + The + LDD + must + not + call + the + PDD + between + a + hold + and + resume. + Typically, + the + device + driver + + + only + needs + to + disable + its + interrupts. + When + a + resume + occurs, + the + device + driver + should + continue + as + + + though + nothing + had + happened. + +

+
+
+

+ + If + the + machine + is + about + to + switch + off + due + to + the + auto + switch + off + or + user + request + mechanisms + (enter + the + + + standby + state), + the + device + driver + should + make + an + orderly + shut + down + of + the + device + such + that + the + state + + + before + the + shut + down + can + be + recovered + when + the + system + powers + up + again. + The + device + driver + should + + + also + attempt + to + ensure + that + no + data + is + lost. + For + example, + in + the + serial + driver + the + current + state + of + the + + + hardware + handshaking + lines + should + be + noted + so + that + each + state + can + be + restored + on + power + up. + For + this + + + type + of + power + down + the + hold + vector + is + allowed + to + take + a + significant + length + of + time + to + shut + down + a + + + device. + For + example + in + a + serial + driver + the + hold + vector + should + wait + until + the + remote + end + stops + + + transmitting + data + after + any + hardware + handshaking + has + been + applied. + Of + course, + the + time + taken + should + + + be + kept + to + a + minimum: + in + the + case + of + the + serial + driver + above + the + time + is + roughly + equivalent + to + 3 + + + character + transmission + times. + When + a + resume + occurs + the + device + driver + should + continue + as + though + + + nothing + had + happened. + +

+
+
+

+ + If + the + machine + is + about + to + switch + off + due + to + the + power + source + being + removed, + the + device + driver + should + + + reset + the + device + in + the + minimum + possible + time: + no + attempt + should + be + made + to + perform + an + orderly + shut- + + + down. + The + device + driver + is + not + expected + to + be + able + to + recover + the + hardware + state. + When + a + resume + + + occurs, + the + device + driver + would + typically + fail + any + outstanding + application + requests. + If + the + hold + vector + + + takes + too + long + the + voltage + will + fall + below + the + threshold + to + hold + the + state + of + the + internal + RAM. + If + this + + + occurs + the + machine + will + perform + a + warm + re-boot + when + powering + up, + all + data + in + the + internal + memory + + + of + the + machine + will + be + lost + including + the + device + driver + code! + On + power + fail + there + is + about + 2ms + + + available + to + power + down + all + devices. + +

+
+
+

+ + On + a + power + failure + hold, + the + operating + system + will + already + have + sent + a + 'reset' + to + all + the + SIBO + serial + + + channels. + Any + device + drivers + using + these + channels + need + only + record + the + hold + reason + for + the + resume + + + vector. + Any + other + peripherals + should + be + designed + to + allow + a + power + fail + mechanism + with + the + minimum + + + amount + of + code. + It + must + be + noted + that + the + power + fail + type + hold + can + occur + whilst + the + device + driver + is + in + + + the + memory + move + hold + state. + In + this + case, + the + device + driver + will + receive + two + hold + requests + before + + + seeing + a + resume + request. + A + device + driver + must + be + capable + of + handling + this. + In + this + case, + the + device + + + driver + will + also + receive + two + resume + requests. + A + device + driver + will + not + get + a + power + fail + hold + whilst + in + +

+
+
+

+ + Revision + 1.00 + Page + 41 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + power + down + hold. + A + call + to + the + hold + vector + will + always + be + followed + by + a + call + to + the + resume + vector + + + (except + when + a + device + is + requested + to + be + removed). + +

+
+
+

+ + Note + that + with + the + Series + 3a + and + Workabout, + there + is + an + additional + case + when + hold + and + resume + must + + + be + invoked + and + that + is + on + opening/closing + of + the + pack + doors. + In + this + case, + the + LDD + must + generate + its + + + own + Hold + and + Resume. + This + situation + is + examined + in + more + depth + in + the + context + of + the + specific + + + example + drivers + presented + later + in + this + document. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + device + driver + should + not + call + any + + + operating + system + services + in + the + hold + vector + code + due + to + the + time + taken, + especially + on + power + failure. + + + PASSED + +

+ +

+ + The + AH + register + takes + one + of + the + following + +

+
+
+

+ + @ + DevHoldNormal + Device + memory + is + about + to + be + moved. + + + @ + DevHoldPowerDown + The + system + is + about + to + enter + the + standby + state. + + + @ + DevHoldPowerFail + The + system + has + lost + its + power + supply. + + + RETURN + + + None. + + + PANIC + +

+
+
+

+ + The + hold + vector + must + not + panic: + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + + + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + hold + vector. + +

+
+
+

+ + DevFuncResume + +

+
+
+

+ + This + vector + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + be + resumed. + + + The + resume + vector + is + called + in + the + context + of + the + operating + system. + The + DevResume + operating + system + + + service + will + cause + this + vector + to + be + called. + Applications + should + not + call + this + service. + The + resume + + + vector + will + be + called + either + when + memory + has + finished + being + moved + or + when + the + machine + powers + back + + + up. + In + both + cases + the + hold + vector + will + have + been + called + before + this + vector + is + called. + The + device + driver + + + is + expected + to + recover + from + the + previous + hold + request + (except + power + fail) + and + resume + any + I/O + that + was + + + suspended. + If + the + device + driver + has + an + interrupt + service + routine, + it + should + reset + the + interrupt + service + + + routine's + address + since + the + device + driver + may + have + moved + in + memory; + its + absolute + segment + address + + + will + be + different. + +

+
+
+

+ + If + the + hold + was + a + device + memory + segment + move + type + hold, + interrupts + should + be + re-enabled. + If + the + + + LDD + uses + an + attached + PDD + and + uses + the + FAR + call + mechanism + to + access + the + PDD + strategy + vector, + the + + + address + of + the + PDD + should + be + reset + by + using + the + DevGet + PDDAddress + operating + system + service + before + + + enabling + interrupts. + Typically, + the + PDD + will + have + a + call + back + to + the + LDD + and + it + needs + to + be + informed + + + of + the + change + of + address + of + the + LDD + call + back + function, + the + LDD-PDD + interface + definition + should + + + allow + such + a + function + request. + +

+
+
+

+ + If + the + hold + was + a + power + down + type + hold, + the + resume + vector + needs + to + power + up + the + peripheral + and + set + it + + + to + the + state + that + it + was + in + before + the + power + down + occurred. + If + this + is + not + possible + or + data + has + been + lost, + + + the + device + driver + should + inform + any + outstanding + requests + of + this + fact. + It + is + also + possible + that + the + + + hardware + device + that + the + driver + is + associated + with + has + been + removed. + The + driver + should + be + able + to + + + handle + this + properly. + If + the + device + driver + is + expected + to + generate + events + due + to + an + external + state + + + change, + the + driver + should + check + the + external + state + and + generate + appropriate + events. + For + example, + the + + + serial + driver + may + be + requested + to + inform + an + application + when + the + DTR + line + changes + state. + The + remote + + + end + may + have + changed + the + state + of + DTR + whilst + the + driver + is + held. + +

+
+
+

+ + If + the + hold + was + a + power + failure + type + hold, + the + resume + vector + should + power + up + the + peripheral + and + put + it + +

+
+
+

+ + into + a + known + state, + preferably + the + state + that + the + application + software + thinks + that + the + device + is + in + and + + + fail + any + outstanding + requests + as + data + is + quite + likely + to + have + been + lost. + +

+
+
+

+ + Revision + 1.00 + Page + 42 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state. + The + device + driver + should + + + take + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + + + this + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + All + operating + system + services + may + be + + + called, + except + those + concerning + file + or + device + access. + +

+ +

+ + PASSED + +

+ +

+ + None + +

+ +

+ + RETURN + +

+ +

+ + None. + +

+ +

+ + PANIC + +

+ +

+ + The + resume + vector + must + not + panic, + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + resume + vector. + +

+
+
+

+ + DevFuncReset + +

+
+
+

+ + This + function + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + reset + a + + + channel. + The + reset + function + is + called + in + the + context + of + the + operating + system + so + DS + and + ES + are + not + + + available. + The + device + driver + must + request + that + the + operating + system + call + the + reset + function. + This + is + + + achieved + by + calling + the + IoRequestReset + system + service, + usually + in + the + open + vector. + To + cancel + this + + + request, + the + device + driver + should + call + the + IoRequestResetCancel + system + service. + The + cancel + service + + + is + usually + called + as + part + of + the + close + functionality + in + the + strategy + vector. + The + reset + vector + will + be + called + + + when + the + operating + system + is + tidying + up + resources + owned + by + a + process + that + has + terminated. + Ifa + + + process + terminated + before + it + closed + the + device + driver + channel + and + no + reset + service + is + requested, + that + + + channel + would + remain + allocated; + no + process + will + ever + close + the + channel. + The + reset + vector + allows + a + + + device + driver + to + reset + itself + and + allow + the + channel + to + be + opened + again. + Any + data + required + to + perform + + + the + reset + must + be + stored + in + the + device + driver. + The + data + space + belonging + to + the + process + that + originally + + + opened + the + channel + has + been + returned + to + the + operating + system + memory + pool + and + is + no + longer + valid. + If + + + a + device + driver + can + handle + multiple + channels + then + the + data + passed + to + the + IoRequestReset + system + + + service + should + identify + the + channel. + This + data + will + be + passed + in + the + CX + register + to + the + reset + vector. + + + The + device + driver + should + only + have + a + reset + request + outstanding + with + the + operating + system + while + a + + + process + has + a + channel + open. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register + or + using + CS + override. + All + operating + system + + + services + may + be + called, + except + those + concerning + file + or + device + access. + +

+ +

+ + PASSED + +

+ +

+ + This + function + is + passed + data + in + the + CX + register + that + the + device + driver + requested + it + be + sent + to + determine + + + which + channel + should + be + reset. + +

+ +

+ + RETURN + +

+ +

+ + None. + +

+ +

+ + PANIC + +

+ +

+ + The + reset + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + +

+ +

+ + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + reset + vector. + +

+
+
+

+ + DevFuncUnits + +

+
+
+

+ + This + function + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + report + the + + + number + of + units + (i.e. + channels) + the + device + driver + can + support. + This + function + is + called + in + the + context + of + + + the + operating + system. + The + operating + system + places + no + significance + on + the + number + of + channels + a + + + device + driver + can + support. + It + is + primarily + used + for + informational + purposes. + An + application + may + use + + + the + number + of + units + to + attempt + to + open + any + available + channel + on + that + device + driver. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + All + operating + system + services + may + be + + + called, + except + those + concerning + file + or + device + access. + +

+ +

+ + PASSED + +

+
+
+

+ + Revision + 1.00 + Page + 43 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + None. + +

+
+
+

+ + RETURN + +

+ +

+ + The + AX + register + should + contain + the + number + of + channels + supported. + If + a + device + driver + can + support + + + multiple + channels + (limited + only + by + memory + constraints) + then + the + driver + may + return + -1. + A + serial + device + + + driver, + for + example, + might + only + support + two + channels + (TTY:a + and + TTy:8) + whereas + the + file + device + + + driver + can + open + an + unlimited + number + of + files. + +

+ +

+ + PANIC + +

+ +

+ + The + channels + units + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + units + vector. + +

+
+
+

+ + DevFuncOpen + +

+
+
+

+ + This + function + will + be + called + by + the + operating + system + when + a + channel + to + the + device + driver + is + required + to + + + be + opened. + This + function + is + called + in + the + context + of + the + process + that + called + the + Ioopen + system + service. + + + This + means + that + DS + and + ES + point + to + the + application + data + space. + The + device + driver + is + passed + two + + + parameters, + its + device + handle + and + a + pointer + to + an + OpenEnt + structure. + The + device + handle + is + the + entry + in + + + the + system + device + table + of + this + device + driver. + The + device + driver + is + required + to + place + this + handle + in + the + + + ChanLibHandle + field + of + the + ChanEnt + structure + which + must + be + allocated + in + the + user's + data + space. + The + + + operating + system + uses + the + device + handle + to + route + any + I/O + requests + on + the + opened + channel + to + the + correct + + + device + driver. + +

+
+
+

+ + The + OpenEnt + structure + contains + three + fields, + openNamePtr, + OpenMode + and + OpenChan. + +

+ +

+ + The + openNamePt + r + field + contains + a + pointer + to + the + character + that + exists + after + the + device + name + as + passed + + + to + the + ToOpen + system + service. + For + example, + if + the + ToOpen + service + was + passed + a + name + of + PAR:A, + the + + + OpenNamePtr + field + would + point + to + the + colon. + If + the + ToOpen + service + was + passed + a + name + of + TTY.AS5:B + + + the + OpenNamePtr + field + would + point + to + the + full + stop. + The + device + driver + should + process + the + name + + + appropriately, + opening + the + correct + PDD + as + required. + +

+ +

+ + The + OpenMode + field + contains + the + mode + for + opening + the + device + driver. + The + available + modes + are + + + specified + by + the + device + driver + writers. + For + example, + a + combined + Xmodem + and + Ymodem + device + driver + + + could + use + the + mode + to + specify + whether + the + Xmodem + or + the + Ymodem + protocol + is + to + be + used. + +

+ +

+ + The + Openchan + field + contains + the + I/O + channel + handle + of + the + device + that + this + driver + is + required + to + + + ‘attach’ + to. + Attached + device + drivers + are + dealt + with + later + in + the + chapter. + +

+ +

+ + The + code + in + a + device + driver + open + vector + tends + to + follow + a + very + similar + pattern. + This + is + demonstrated + + + by + the + following + code + fragments + and + associated + comments. + The + first + stage + is + to + allocate + some + data + + + space + in + the + calling + process' + heap + space. + This + will + contain + the + I/O + channel + control + block: + +

+
+
+

+ + mov + cx, + (size + DeviceEnt) + +

+ +

+ + HeapAllocateCell + +

+ +

+ + jc + noMemory + +

+ +

+ + mov + bx, + ax + ; + cell + handle + +

+
+
+

+ + If + the + device + driver + requires + a + WaitHandler + (described + later): + +

+
+
+

+ + mov + al, + (VectorHandler-Vector) + /2 + + + ToAddHandler + +

+ +

+ + jc + endFreeMemory + +

+ +

+ + mov + [bx].DriverHandler, + ax + +

+
+
+

+ + If + the + device + driver's + DevFuncReset + vector + is + required + to + be + called: + +

+
+
+

+ + push + bx + +

+ +

+ + mov + cx, + ChannelIndicator + 7 + unique + per + channel + + + mov + bx, + ax + ; + the + device + handle + + + ToRequestReset + +

+ +

+ + pop + bx + ; + restore + alloc + cell + +

+
+
+

+ + The + chanEnt + field + of + the + DriverEnt + structure + must + be + initialised: + +

+
+
+
+

+ + mov + [bx] + .DriverIo.ChanNext, + bx + + + mov + [bx] + .DriverIo.ChanSignature, + IoChanSignature + + + mov + [bx] + .DriverIo.ChanLibHandle, + dx + +

+
+
+

+ + The + ChanNext + field + is + used + by + attached + drivers + and + will + usually + be + set + to + be + the + allocated + cell + handle + + + of + the + device + driver + being + opened. + The + IoFuncattach + and + IoFuncDetach + functions + manipulate + these + + + fields. + The + I/O + system + uses + this + field + to + direct + the + I/O + request + to + the + correct + driver. + +

+
+
+

+ + Revision + 1.00 + Page + 44 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + ChanSignature + field + is + checked + by + the + operating + system + during + any + I/O + requests + for + the + value + + + IoChanSignature. + If + it + does + not + contain + that + value, + the + process + calling + the + I/O + service + will + be + + + panicked + for + having + passed + an + invalid + I/O + channel + handle. + +

+ +

+ + The + ChanLibHandle + field + is + used + by + the + operating + system + to + route + an + application's + I/O + request + to + this + + + device. + The + I/O + request + will + call + the + DevFuncstrategy + vector + of + the + device + driver. + +

+ +

+ + If + the + driver + is + an + attached + driver + the + following + is + required: + +

+
+
+

+ + mov + cx, + bx + ; + allocated + channel + +

+ +

+ + mov + bx, + [si] + .OpenChan + ; + channel + attaching + to + + + mov + al, + IoFuncAttach + ; + return + in + BX + the + + + ToWithWait + ; + channel + attached + to + +

+
+
+

+ + Finally, + if + the + channel + has + been + successfully + opened: + + + ele + Opened + Ok + + + ret + return + BX + and + DX + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + The + error + recovery + code + typically + follows + the + following + pattern: + +

+
+
+

+ + endFreeReset: + + + push + ax + + + push + bx + + + mov + cx, + ChannelIndicator + + + mov + bx, + ax + + + ToRequestResetCancel + + + pop + bx + + + pop + ax + + + endFreeHandler: + + + push + ax + + + push + bx + + + mov + bx, + [bx] + .DriverHandler + + + ToRemoveHandler + + + pop + bx + + + pop + ax + + + endFreeMemory: + + + push + ax + + + HeapFreeCell + + + pop + ax + + + stc + + + noMemory: + + + ret + +

+
+
+

+ + If + a + device + driver + supports + a + fixed + number + of + channels, + it + typically + contains + static + control + blocks. + In + + + order + to + determine + if + a + requested + channel + is + currently + open, + a + field + should + be + interrogated. + The + device + + + driver + should + ensure + that + interrupts + are + disabled + during + this + sort + of + check + since + a + context + switch + could + + + occur + and + another + process + request + the + opening + of + the + same + channel. + This + is + the + classic + 'test + and + set' + + + problem + encountered + in + multi-tasking + environments. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + attempting + to + open + a + device + channel. + The + application + should + ensure + that + the + DS + and + ES + segment + + + registers + do + in + fact + point + to + its + data + segment. + The + device + driver + must + obey + the + normal + rules + + + concerning + segment + register + manipulation. + The + DS + and + ES + segment + registers + can + be + reloaded + if + + + required + from + the + IntEnt + structure + pointed + at + by + the + BP + register. + All + operating + system + services + may + + + be + called. + +

+ +

+ + PASSED + +

+ +

+ + DX + contains + the + device + handle + of + the + device + driver. + +

+ +

+ + SI + is + a + pointer + to + the + OpenEnt + structure + +

+ +

+ + BP + is + a + pointer + to + the + IntEnt + structure. + +

+ +

+ + RETURN + +

+ +

+ + If + the + channel + open + was + successful, + return + with + the + carry + flag + clear + and + the + BX + register + containing + the + + + open + channel. + +

+ +

+ + If + the + open + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + +

+ +

+ + PANIC + +

+ +

+ + The + open + vector + can + panic; + it + will + cause + the + process + requesting + the + device + open + to + terminate. + It + is + + + however + more + usual + to + return + an + error + to + the + calling + process. + +

+ +

+ + PRESERVE + +

+ +

+ + The + DS, + ES, + SS, + SP, + BP + and + DX + registers + must + be + preserved + by + the + open + vector. + +

+
+
+
+
+

+ + Revision + 1.00 + Page + 45 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + DevFuncStrategy + +

+
+
+

+ + When + an + application + makes + an + I/O + request + on + the + opened + device + driver + channel + the + request + is + routed + + + to + this + vector + by + the + operating + system. + A + device + driver + defines + the + set + of + functions + that + it + supports. + + + These + typically + include + IoFuncSet, + IoFuncSense, + IoFuncRead, + IoFuncWrite + and + IoFuncClose. + A + + + device + driver + does + not + have + to + support + any + particular + function, + as + it + is + a + matter + of + design + between + a + + + device + driver + writer + and + application + writer + as + to + what + functions + and + associated + parameters + are + + + provided. + To + obtain + the + power + of + attached + device + drivers, + however, + it + is + recommended + that + the + device + + + driver + use + the + system + defines + with + their + appropriate + functionality, + for + example, + the + loFuncWrite + + + function + number + should + always + be + associated + with + writing + data. + +

+
+
+

+ + The + strategy + function + is + passed + the + channel + handle + as + allocated + in + the + open + vector + in + the + BX + register. + + + This + typically + contains + control + information + concerning + the + current + state + of + the + I/O + channel. + +

+ +

+ + The + SI + register + contains + a + pointer + to + a + RgEnt + structure. + This + structure + contains + four + fields, + + + RqFunction, + RqStatusPtr, + RqA1Ptr + and + RqA2Ptr. + +

+ +

+ + The + RgFunction + field + contains + the + function + number + as + passed + to + the + IowithWait + (or + + + IoAsynchronous) + I/O + request + by + the + application. + If + a + device + driver + does + not + support + the + specified + + + function, + it + should + pass + the + request + on + to + its + 'parent' + device + driver. + +

+ +

+ + The + RqStatus + pointer + contains + a + pointer + to + a + memory + location + in + the + application + process's + data + space + + + that + receives + the + I/O + requests + completion + status. + The + device + driver + must + set + this + memory + location + to + + + the + value + PendingErr + whilst + the + I/O + request + is + outstanding + and + a + completion + code + when + the + I/O + + + request + completes. + An + I/O + request + may + complete + within + the + strategy + vector + or + it + may + complete + some + + + time + in + the + future, + presumably + from + some + interrupt. + +

+ +

+ + The + RgA1Ptr + and + RqA2Ptr + fields + contain + the + argument + | + and + 2 + parameters + as + passed + to + the + + + IoWithWait + (or + IoAsynchronous) + system + services. + The + device + driver + is + free + to + specify + what + these + + + parameters + are + (if + any). + +

+
+
+
+
+

+ + The + operating + system + defines + a + set + of + common + function + numbers + used + by + device + drivers + referred + to + as + + + the + IoFuncxxx + set + of + defines. + By + convention, + a + device + driver + should + select + from + this + list, + particularly + + + if + some + of + the + more + advanced + features + of + the + I/O + system + are + to + be + used, + such + as + attached + device + + + drivers. + The + more + common + defines + are + listed + below: + +

+
+
+

+ + @ + ToFuncRead + ; + read + from + the + device. + +

+ +

+ + ® + TfoFuncWrite + ; + write + to + the + device. + +

+ +

+ + @ + TloFuncClose + ; + close + device + channel. + +

+ +

+ + @ + = + =ToFuncCancel + ; + cancel + an + I/O + request. + +

+ +

+ + ® + ToFuncSet + ; + set + driver + characteristics. + +

+ +

+ + ® + tloFuncSense + ; + sense + driver + characteristics. + + + e + lIoFuncFlush + ; + flush + any + buffers. + +

+
+
+

+ + The + PLIB + library + functions + p_read, + p_write + and + p_close + will + call + the + device + driver + with + the + + + IoFuncRead, + IoFuncWrite + and + IoFuncClose + function + numbers. + Thus, + if + the + device + driver + chooses + + + an + alternative + function + number + set, + an + application + will + not + be + able + to + use + the + supplied + library + + + functions. + All + resident + device + drivers + obey + the + following + conventions: + + + e + Acancel + request + will + cancel + any + outstanding + requests. + A + cancel + request + will + not + return + any + + + error. + +

+
+
+

+ + e + Aclose + request + will + ensure + that + any + outstanding + requests + are + completed + before + closing + the + + + channel. + A + close + request + will + not + return + any + error. + +

+
+
+

+ + e + Only + one + request + of + a + particular + type + can + be + outstanding + at + any + one + time. + If + a + second + request + + + is + made + the + device + driver + will + panic + the + calling + application. + +

+
+
+

+ + Any + functions + that + the + strategy + function + does + not + support + should + be + passed + on + to + the + next + driver + down + + + the + driver + hierarchy. + If + the + driver + is + a + root + driver + (attached + driver), + this + is + achieved + using + the + IoRoot + +

+
+
+

+ + Revision + 1.00 + Page + 46 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + (IoSuper)system + service. + If + the + requested + function + is + not + supported + by + any + driver, + the + operating + + + system + will + return + a + Not + Supported + error. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + making + the + I/O + function + request. + The + application + should + ensure + that + the + DS + and + ES + segment + registers + + + do + in + fact + point + to + its + data + segment. + The + device + driver + must + obey + the + normal + rules + concerning + + + segment + register + manipulation. + The + DS + and + ES + segment + registers + can + be + reloaded + if + required + from + + + the + IntEnt + structure + pointed + at + by + the + BP + register. + All + operating + system + services + may + be + called. + + + PASSED + +

+ +

+ + BX + contains + the + allocated + channel + control + block. + +

+ +

+ + DX + contains + the + device + handle + of + the + device + driver. + +

+ +

+ + SI + is + a + pointer + to + the + RqEnt + structure. + +

+ +

+ + BP + is + a + pointer + to + the + IntEnt + structure. + +

+ +

+ + RETURN + +

+ +

+ + If + the + function + request + is + successful, + the + strategy + vector + should + return + with + carry + clear. + A + request + + + typically + causes + some + I/O. + If + the + I/O + is + completed + by + the + strategy + vector + (i.e. + the + request + is + for + a + + + synchronous + function + such + as + close), + the + completion + status + should + be + written + back + to + the + RqStatusPtr + + + location + and + the + I/O + semaphore + signalled + (using + the + IoSignal + system + service). + If + the + request + has + not + + + yet + completed + (i.e. + the + request + is + for + an + asynchronous + function), + the + RqStatusPtr + location + should + + + contain + the + value + PendingErr + and + the + I/O + semaphore + should + not + be + signalled. + +

+ +

+ + If + the + function + request + failed + the + strategy + vector + should + return + with + carry + set + and + the + error + code + in + AL. + + + In + this + case, + typically + no + I/O + requests + will + be + completed. + +

+ +

+ + PANIC + +

+ +

+ + The + strategy + vector + can + panic; + it + will + cause + the + process + making + the + I/O + request + to + terminate. + In + most + + + cases + it + is + usual + to + return + an + error + to + the + calling + process. + A + major + exception + to + this + is + if + the + calling + + + process + makes + an + I/O + request + of + the + same + type + as + one + that + is + currently + outstanding + and + the + device + + + driver + only + supports + one + I/O + request + of + a + particular + type + at + a + time; + by + convention + the + device + driver + + + should + panic + the + calling + process + with + the + PanicIoPending + panic + code. + +

+ +

+ + PRESERVE + +

+ +

+ + The + DS, + ES, + SS, + SP + and + BP + registers + must + be + preserved + by + the + strategy + vector. + +

+
+
+

+ + Interrupts + and + Interrupt + Service + Routines + +

+
+
+

+ + Device + drivers + that + talk + to + hardware + tend + to + have + interrupt + service + routines + associated + with + them, + + + especially + if + they + are + receiving + data + from + an + external + source. + The + EPOC + operating + system + provides + a + + + framework + within + which + an + interrupt + service + routine + can + be + written + relatively + easily. + An + interrupt + + + service + routine + is + a + code + section + that + is + called + by + the + OS + in + response + to + a + particular + hardware + event. + + + As + indicated + in + the + Hardware + Overview, + the + SIBO + architecture + allows + for + eight + independent + hardware + + + interrupt + sources, + some + of + which + are + pre-allocated + to + system + components. + The + operating + system + + + provides + the + GenSetRevector + service + to + allow + a + device + driver + to + install + an + interrupt + service + routine + + + for + any + of + the + eight + hardware + interrupt + sources. + This + call + passes + the + interrupt + vector + (the + address + of + + + the + interrupt + service + routine) + and + the + interrupt + number + (which + is + dependent + on + the + host + hardware) + to + + + the + OS + so + that + it + knows + where + to + jump + to + when + the + interrupt + occurs. + A + device + driver + should + use + this + + + system + service + and + not + poke + directly + into + the + 8086 + interrupt + vector + table. + The + address + passed + to + the + + + GenSetRevector + Service + is + not + written + into + the + interrupt + vector + table + but + to + an + internal + table. + After + + + invoking + this + service, + the + desired + interrupts + must + be + masked + in + by + writing + the + appropriate + mask + to + the + + + mask + register. + Initially, + of + the + eight + interrupt + sources, + only + the + tick + interrupt + is + masked + in. + +

+
+
+

+ + When + an + interrupt + occurs, + the + microprocessor + could + be + running + any + currently + active + process. + The + OS + + + handles + the + servicing + of + interrupts + by + building + a + mandatory + operating + system + call + frame. + All + CPU + + + registers + are + preserved + on + route. + The + interrupt + service + routine + is + then + called + as + a + FAR + routine. + Since + + + the + operating + system + preserves + all + registers + the + interrupt + service + routine + is + free + to + use + any + register. + As + + + with + all + interrupt + service + routines + various + rules + apply: + +

+
+
+

+ + e + Interrupt + service + routines + should + execute + as + fast + as + possible. + Operating + system + interrupt + + + service + routines + are + tuned + to + last + no + longer + than + one + millisecond. + +

+
+
+

+ + Revision + 1.00 + Page + 47 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + e + Typically, + interrupt + service + routines + do + not + enable + interrupts + unless + the + routine + can + handle + re- + + + entrancy. + +

+
+
+

+ + e + Interrupt + service + routines + run + in + the + context + of + whatever + process + is + running + at + the + time + of + the + + + interrupt. + An + interrupt + service + routine + should + not + attempt + to + obtain + admissibility + to + the + + + process + that + opened + the + channel + but + access + the + internal + driver + space + only + which + in + general + is + + + its + own + code + space. + +

+
+
+

+ + e + An + interrupt + service + routine + must + not + directly + cause + the + OS + to + reschedule + the + running + process + + + as + this + would + significantly + delay + its + completion. + It + must + use + the + IoSignalByPidNoReSched + system + + + service + in + order + to + indicate + to + the + handler + that + an + event + has + occurred + to + the + owning + process. + + + The + handler + function + of + the + device + driver + must + pick + up + the + event + and + inform + the + owning + + + process. + +

+
+
+

+ + e + An + interrupt + service + routine + should + return + with + the + carry + flag + clear + if + it + requires + a + reschedule + + + to + occur + (it + has + called + IoSignalByPidNoReSched) + otherwise + return + with + the + carry + flag + set. + This + + + will + cause + the + operating + system + to + reschedule + if + the + internal + state + allows + such + an + action + + + otherwise + the + reschedule + request + is + effectively + queued + until + such + time + that + the + operating + + + system + can + reschedule. + +

+
+
+

+ + At + some + stage + during + the + course + of + an + interrupt + service + routine, + it + is + necessary + to + clear + the + interrupt + + + line + with + some + hardware-specific + action. + Then + the + interrupt + controller + inside + the + host + ASIC1 + or + + + ASIC9 + has + to + be + cleared + with + a + write + to + the + NonSpecificEoi + location. + To + remove + the + interrupt + service + + + routine + address, + the + operating + system + service + GenResetRevector + should + be + used. + This + will + reset + the + + + internal + table + entry + to + the + default + held + in + the + ROM. + Additionally, + the + interrupt + mask + should + be + reset + + + to + the + original + value. + +

+
+
+

+ + Device + Driver + I/O + Semaphore + Wait + Handlers + +

+
+
+

+ + An + LDD + may + nominate + one + of + its + functions + to + be + called + by + the + operating + system + every + time + the + I/O + + + semaphore + of + the + process + that + opened + the + channel + is + signalled. + The + nominated + function, + known + as + the + + + wait + handler, + will + only + be + called + if + the + application + is + waiting + for + an + outstanding + I/O + request + to + + + complete. + For + well + written + applications + this + is + practically + all + the + time. + By + convention + the + vector + table + + + entry + after + the + mandatory + vectors + contains + the + handler + vector. + A + handler + routine + is + similar + to + an + + + interrupt + service + routine + in + that + it + appears + to + run + ‘from + nowhere’. + Comparing + handlers + and + interrupt + + + services + routines + shows + that: + +

+
+
+

+ + e + A + handler + will + always + run + in + the + context + of + the + process + that + has + opened + a + channel. + An + + + interrupt + service + routine + will + run + in + the + context + of + whatever + process + happens + to + be + running + at + + + the + time + of + the + interrupt. + +

+
+
+

+ + e + A + handler + can + access + the + data + space + of + the + process + that + opened + the + channel. + The + interrupt + + + service + routine + must + not. + An + interrupt + service + routine + should + only + access + the + data + space + in + + + the + driver + which + is + usually + its + own + CS + space. + +

+
+
+

+ + e + A + handler + can + cause + a + reschedule. + An + interrupt + service + routine + must + not + cause + a + reschedule. + + + If + it + did, + the + interrupt + would + not + be + fully + serviced + (the + rest + of + the + interrupt + service + routine + + + would + not + be + executed + until + a + reschedule + back + to + the + process + running + at + the + time + of + the + + + interrupt, + which + may + not + happen + for + a + significant + length + of + time). + The + interrupt + service + + + routine + must + only + use + the + IoSignalByPidNoReSched + to + signal + the + channel + owner. + +

+
+
+

+ + The + handler + is + the + mechanism + by + which + hardware + interrupt + events + can + be + filtered + through + to + the + + + process + using + the + I/O + channel. + Typically, + it + is + in + the + handler + code + that + the + 1oSignal + signifying + + + completion + of + an + asynchronous + I/O + request + is + invoked. + +

+
+
+

+ + Loadable + Physical + Device + Driver + Structure + +

+
+
+

+ + A + loadable + PDD + must + obey + the + following + rules: + + + e + There + must + be + a + single + code + segment + and + no + data + segments. + +

+
+
+

+ + Revision + 1.00 + Page + 48 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + e + The + code + segment + must + start + with + a + LibEnt + structure. + + + e + There + must + be + at + least + two + supported + functions, + with + typically + a + further + two + defined. + +

+
+
+

+ + Single + Code + Segment + +

+
+
+

+ + A + PDD + must + be + written + to + contain + any + internal + variables + within + its + own + code + segment. + Typically, + + + these + variables + are + only + concerned + with + unit + (i.e. + channel) + allocation + and + hardware + state. + Data + space + + + for + a + particular + open + channel + can + be + allocated + in + the + heap + space + of + the + process + that + opens + the + device. + + + This + data + space + will + however + disappear + if + the + process + terminates, + thus + any + variables + required + for + + + ‘freeing’ + the + hardware + after + a + process + terminates + must + exist + in + the + code + space + of + the + device + driver. + +

+
+
+

+ + The + LibEnt + Structure + +

+
+
+
+

+ + A + LibEnt + structure + has + the + following + format: + + + e + =A + two + byte + signature + +

+
+
+

+ + e + §=6©An + eight + byte + name + + + e + A + two + byte + vector + count + + + e + A + vector + table + +

+
+
+

+ + The + two + byte + signature + should + contain + the + 'PDDSignature' + define. + The + eight + byte + name + contains + a + + + zero + terminated + name, + being + that + of + the + device + driver. + Note + that + there + is + no + trailing + colon. + The + two + + + byte + vector + count + contains + the + number + of + vectors + that + follow + immediately + after + the + count. + There + + + should + be + at + least + two. + For + example: + +

+
+
+
+

+ + dw + PDDSignature + ; + Its + an + PDD + driver + +

+ +

+ + db + "DVR.HW1',0 + ; + Name + of + the + driver + +

+ +

+ + dw + (VectorEnd-Vector)/2 + ; + Number + of + vectors + + + Vector: + +

+ +

+ + dw + DvriInstall + ; + Install + vector + +

+ +

+ + dw + DvrRemove + ; + Remove + vector + + + VectorEnd: + +

+
+
+

+ + Most + PDDs + also + define + a + further + two + vectors: + + + dw + DvrOpen + , + Open + Vector + + + dw + DvrStrategy + ; + Strategy + vector + +

+
+
+

+ + The + table + of + vectors + is + a + table + of + offsets + within + the + device + drivers + code + segment + of + the + routines + that + + + implement + the + required + functionality. + The + vector + table + must + have + the + entries + in + the + order + shown + in + + + the + example. + +

+
+
+

+ + Mandatory + PDD + functions + +

+
+
+

+ + All + PDDs + must + support + the + following + two + functions: + + + @ + DevFuncInstallppp + called + on + device + installation. + +

+
+
+

+ + @ + DevFuncRemovePDD + called + on + device + removal. + +

+
+
+

+ + Most + PDDs + will + support + the + following + two + additional + functions: + + + @ + DevFuncOpenPDD + called + to + open + a + PDD. + +

+
+
+
+

+ + @ + DevFuncStrategyPDD + called + to + provide + PDD + functionality. + +

+
+
+

+ + All + of + the + routines + pointed + at + by + the + function + vector + table + will + be + called + FAR + by + the + operating + system + + + and + should + consequently + use + a + FAR + return + machine + code + instruction + to + return + back + to + the + operating + + + system. + Since + the + FAR + return + address + is + to + the + operating + system, + it + does + not + matter + if + the + operating + + + system + moves + memory + whilst + code + in + the + LDD + is + being + executed; + the + operating + system + cannot + move. + +

+
+
+

+ + DevFunclnstallPDD + +

+
+
+

+ + This + vector + will + be + called + by + the + operating + system + when + the + device + driver + is + loaded + to + initialise + any + of + + + its + internal + variables. + The + install + vector + is + called + in + the + context + of + the + operating + system + and + not + the + + + process + that + is + loading + the + device + driver. + The + DevInstall + operating + system + service + will + cause + this + +

+
+
+

+ + Revision + 1.00 + Page + 49 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + vector + to + be + called. + Applications + should + not + call + this + directly, + they + should + use + the + DevLoadPDD + + + service. + +

+
+
+

+ + An + installable + device + driver + may + have + the + same + name + as + a + currently + installed + device + driver. + When + + + installed, + the + driver + is + added + to + the + end + of + the + device + driver + table. + When + a + channel + to + a + device + driver + + + is + being + established + by + the + operating + system, + it + searches + the + device + table + from + the + end + first, + thus + the + + + latest + installed + device + driver + with + the + required + name + will + be + asked + first + for + a + channel. + So + as + with + + + LDDs + by + this + mechanism + installable + device + drivers + can + replace + any + of + the + resident + drivers. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state. + The + device + driver + should + + + take + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + + + this + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + operating + system + will + not + move + + + memory + whilst + in + this + function, + thus + the + normal + rules + governing + DS + and + ES + may + be + ignored. + All + + + operating + system + services + may + be + called + except + those + concerning + file + or + device + access. + +

+ +

+ + PASSED + +

+ +

+ + No + values + are + passed + to + the + install + vector. + +

+ +

+ + RETURN + +

+ +

+ + If + the + installation + was + successful, + return + with + the + carry + flag + clear. + +

+ +

+ + If + the + installation + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + PANIC + +

+ +

+ + The + install + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + install + vector. + +

+
+
+

+ + DevFuncRemovePDD + +

+
+
+

+ + This + vector + will + be + called + by + the + operating + system + when + the + device + driver + is + requested + to + be + unloaded. + + + The + remove + vector + is + called + in + the + context + of + the + operating + system + and + not + the + process + that + requests + + + the + unload. + The + DevRemove + operating + system + service + will + cause + this + vector + to + be + called. + Applications + + + should + not + call + this + service + directly; + instead, + they + should + call + the + DevDelete + service. + Before + the + + + remove + function + is + requested, + the + operating + system + will + send + a + DevFuncHold + request + to + all + LDDs. + + + The + LDD + is + responsible + for + ensuring + that + no + activity + will + occur + during + the + remove. + Note + that + any + + + device + driver + that + handles + hardware + interrupts + must + contain + an + LDD + since + only + LDDs + receive + a + hold + + + request. + If + the + device + driver + is + currently + busy + serving + a + client, + the + remove + request + should + return + an + + + error. + All + resident + device + drivers + will + return + an + error + since + there + is + no + mechanism + by + which + they + can + + + be + re-installed. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + are + in + an + unknown + state; + the + device + driver + should + take + + + whatever + steps + necessary + to + obtain + direct + addressability + to + its + data. + For + loadable + device + drivers + this + + + involves + setting + the + DS + and + ES + registers + to + the + CS + register. + The + operating + system + will + not + move + + + memory + whilst + in + this + function, + thus + the + normal + rules + governing + DS + and + ES + may + be + ignored. + All + + + operating + system + services + may + be + called + except + those + concerning + file + or + device + access. + +

+ +

+ + PASSED + +

+ +

+ + No + values + are + passed + to + the + remove + vector. + +

+ +

+ + RETURN + +

+ +

+ + If + the + remove + was + successful, + return + with + the + carry + flag + clear. + +

+ +

+ + If + the + remove + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + + + PANIC + +

+ +

+ + The + remove + vector + must + not + panic; + it + will + cause + an + operating + system + kernel + fault + if + it + does. + + + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + remove + vector. + +

+
+
+

+ + DevFuncOpenPDD + +

+
+
+

+ + This + function + is + defined + as + a + convenience + function + for + the + LDD-PDD + interface. + When + an + application + + + opens + a + channel + to + an + LDD, + it + normally + uses + the + Ioopen + system + service. + If + the + name + specifies, + or + the + + + LDD + requires, + a + PDD + then + it + needs + to + open + a + channel + toa + PDD. + The + Devopenppp + system + service + will + + + call + this + PDD + vector + to + establish + a + channel. + The + LDD + now + has + a + choice + of + calling + a + PDD + vector + using + + + the + DevVector + system + service + or + calling + the + fourth + vector + in + the + vector + table + directly. + The + fourth + +

+
+
+

+ + Revision + 1.00 + Page + 50 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + vector + is + assumed + to + be + a + strategy + vector + to + which + any + parameters + as + required + by + the + LDD-PDD + + + interface + can + be + passed. + The + FAR + address + of + the + strategy + vector + is + returned + by + the + + + DevGetPDDAddress. + When + an + LDD + receives + a + DevFuncResume + it + should + call + DevGet + PDDAddress + + + again + to + ensure + that + if + the + PDD + has + moved + the + LDD + still + has + its + correct + address. + As + a + design, + a + PDD + + + could + provide + many + vectors, + one + for + each + required + function. + The + LDD + would + then + use + the + Devvector + + + system + service + to + access + each + of + these + functions. + The + DevGetPDDAddress + will + only + return + the + FAR + + + address + of + the + fourth + vector. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + making + the + open + function + request. + The + application + should + ensure + that + this + is + indeed + the + case. + The + + + device + driver + must + obey + the + normal + rules + concerning + segment + register + manipulation. + All + operating + + + system + services + may + be + called. + +

+ +

+ + PASSED + +

+ +

+ + The + BX + register + contains + a + pointer + to + the + PDD + unit + name. + The + pointer + passed + to + the + DevOpenPDD + + + service + is + used + to + find + the + PDD + device + to + open. + The + BX + register + is + loaded + with + a + pointer + to + the + + + trailing + colon + (if + any) + in + the + PDD + unit + name. + For + example + if + the + name + "TTy.AS5:A" + was + passed + to + + + the + DevOpenPDD + service, + BX + would + contain + a + pointer + to + :A + upon + calling + the + open + vector. + + + RETURN + +

+ +

+ + If + the + open + was + successful, + return + with + the + carry + flag + clear. + +

+ +

+ + If + the + open + failed, + return + with + the + carry + flag + set + and + the + error + number + in + the + AL + register. + +

+ +

+ + PANIC + +

+ +

+ + The + open + vector + can + panic; + it + will + cause + the + process + requesting + the + device + open + to + terminate. + It + is + + + however + more + usual + to + return + an + error + to + the + calling + process. + +

+ +

+ + PRESERVE + +

+ +

+ + The + SS, + SP + and + BP + registers + must + be + preserved + by + the + open + vector. + +

+
+
+

+ + DevFuncStrategyPDD + +

+
+
+

+ + This + function + is + defined + as + a + convenience + function + for + the + LDD-PDD + interface. + Typically, + all + + + application + function + requests + are + routed + through + the + strategy + vector. + To + speed + the + calling + interface, + + + the + DevGet + PDDAddress + operating + system + function + will + return + a + FAR + address + of + this + vector. + The + + + device + driver + writer + defines + all + the + functions + and + return + values + as + required. + +

+
+
+

+ + When + called, + the + DS + and + ES + segment + registers + point + to + the + data + segment + of + the + application + process + + + making + the + function + request. + The + application + should + ensure + that + the + DS + and + ES + segment + registers + do + + + in + fact + point + to + its + data + segment. + The + device + driver + must + obey + the + normal + rules + concerning + segment + + + register + manipulation. + All + operating + system + services + may + be + called. + +

+ +

+ + PASSED + +

+ +

+ + The + parameters + passed + are + defined + by + the + device + driver + write. + +

+ +

+ + RETURN + +

+ +

+ + All + returns + are + defined + by + the + device + driver + writer. + +

+ +

+ + PANIC + +

+ +

+ + The + strategy + vector + can + panic; + it + will + cause + the + process + requesting + the + function + to + terminate. + It + is + + + however + more + usual + to + return + an + error + to + the + calling + process. + +

+ +

+ + PRESERVE + +

+ +

+ + Which + registers + are + preserved + is + defined + by + the + device + driver + writer. + +

+
+
+

+ + Revision + 1.00 + Page + 51 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 10. + ASIC4/ASIC5 + BASED + DEVICE + DRIVERS + +

+
+
+

+ + Introduction + +

+
+
+

+ + This + chapter + describes + the + rules + and + problems + involved + in + writing + a + device + driver + that + controls + some + + + form + of + ASIC4 + or + ASICS + based + hardware. + Details + concerning + the + internal + organisation + of + these + + + ASICs + were + presented + earlier + in + chapters + 6 + and + 7. + The + emphasis + is + on + their + use + for + Series + 3a + + + applications, + though + most + issues + that + will + be + discussed + also + apply + to + the + Series + 3, + MC + and + HC + range + of + + + Psion + products. + +

+
+
+

+ + In + addition + to + the + eight + mandatory + functions + already + detailed + in + the + Device + Driver + Overview + chapter, + + + an + LDD + will + usually + provide + additional + functionality + in + the + form + of + further + vector + table + entries + + + dependent + upon + the + requirements + of + its + application. + Wherever + possible, + these + functions + should + make + + + use + of + the + various + pre-defined + system + defines + for + services + such + as + reading + (p_read) + and + writing + + + (p_write) + etc. + It + should + be + noted + that + there + is + no + particular + requirement + to + implement + a + device + + + driver + as + a + separate + PDD + and + LDD + and + in + the + case + of + the + example + logical + device + driver + + + A4EXIF.LDD, + the + approach + taken + is + to + incorporate + both + aspects + into + the + one + LDD. + +

+
+
+

+ + SIBO + Hardware + Expansion + Channels + +

+
+
+

+ + The + number + of + SIBO + expansion + channels + supported + by + the + host + machine + will + vary + according + to + the + + + particular + Psion + hardware + present. + So + that + a + single + device + driver + may + be + compiled + for + the + different + + + host + machine + possibilities, + a + number + of + build + flags + can + be + used + to + set + various + constants + within + the + + + include + files. + The + hardware + options + are + outlined + in + the + table + below: + +

+
+
+

+ + SIBO + Machine + Flags + | + Number + of + SIBO + serial + channels + supported + Machine + Build + Flag + +

+
+
+

+ + Consumer + (S3a) + Refers + to + $3a + with + ASIC9 + only. + Supports + 1 + SIBO + channel + + + (A) + +

+
+
+

+ + ES + ae + Mat + AST + lysed + SPS + PTT + +

+
+
+

+ + It + should + be + noted + that + Psion + device + drivers + should + be + designed + to + be + easily + adapted + from + machine + to + + + machine. + For + a + well-written + driver, + the + only + change + that + needs + to + be + made + in + adapting + it + for + use + on + + + another + Psion + machine + is + the + alteration + of + the + build + flag + at + the + start + of + the + code. + This + flag + indicates + to + + + the + compiler + which + SIBO + machine + flags + as + well + as + other + variables + should + be + set + for + the + host + machine. + + + The + four + most + important + SIBO + machine + variables + are + the + channel + interrupt + mask, + the + channel + + + interrupt + number, + the + channel + interrupt + vector + and + the + hardware + SIBO + channel. + The + channel + + + interrupt + mask + is + an + eight + bit + value + or'd + with + the + contents + of + either + AlInterruptMask + or + + + A9BInterruptMask + (the + mask + registers) + to + initiate + interrupts + on + the + relevant + channel + depending + on + + + whether + the + interrupt + controller + resides + in + ASIC1 + or + ASIC9. + If + this + mask + is + then + used + in + a + + + HwGetChannel + call, + any + hardware + interrupts + on + the + selected + expansion + channel + will + be + directed + to + the + + + appropriately + coded + interrupt + service + routine. + The + channel + interrupt + mask + is + also + required + in + the + + + subsequent + HwFreeChannel + OS + service + call + and + when + stopping + hardware + interrupts. + The + channel + + + interrupt + number + is + a + sixteen-bit + quantity + required + by + the + GenSetRevector + and + GenResetRevector + + + OS + system + services + to + indicate + to + the + OS + which + default + interrupt + service + routine + is + to + be + replaced + by + + + the + suitably + coded + device + driver + interrupt + vector. + The + channel + interrupt + vector + is + a + sixteen-bit + + + pointer + to + the + location + of + that + interrupt + vector + in + the + device + driver + code. + Finally, + the + hardware + SIBO + + + channel + is + used + by + the + HwSelectChannel + OS + service + to + direct + any + SIBO + serial + control + or + data + frames + +

+
+
+
+

+ + Revision + 1.00 + Page + 52 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + along + the + appropriate + channel. + The + situation + regarding + the + value + of + these + variables + for + the + expansion + + + ports + on + all + current + SIBO + platforms + is + illustrated + in + the + table + overleaf: + +

+
+
+

+ + IW + orkabout + (Series3) + + + a + en + en + an + + + Channels + +

+
+
+

+ + Controller + ASIC + |ASIC? + ASICO + + + Mask + Register + A9BInterruptMaskRW + a + a + a + ae + +

+
+
+

+ + IHwIrq2Revector + +

+
+
+

+ + mask + A9MExpIntA + + + (Expansion + Port + A) + + + mask + A9MExpIntB + + + (Expansion + Port + B) + + + Imask + AOMSlave + +

+ +

+ + (Expansion + Port + C) + +

+
+
+

+ + IHwIrq4Revector + + + IHwIrgq5Revector + + + IHwIrq2Revector + +

+
+
+

+ + ASIC2 + +

+
+
+

+ + mask + ExpIntLeftA + + + (Expansion + Port + A) + + + mask + ExpIntRightB + + + (Expansion + Port + B) + + + mask + Asic2Int + + + (Expansion + Port + C) + +

+
+
+

+ + IHwIrgq3Revector + + + IHwIrq2Revector + + + IHwIrq4Revector + +

+
+
+

+ + ASIC2 + ASIC2 + +

+
+
+

+ + mask + Asic2Int + + + (Expansion + Port + C) + +

+
+
+

+ + mask + ExpIntLeftA + +

+ +

+ + (Expansion + Port + A) + + + mask + ExpIntRightB + + + (Expansion + Port + B) + +

+
+
+

+ + IHwIrgq3Revector + + + IHwIrq2Revector + +

+
+
+

+ + IHwIrq4Revector + +

+
+
+
+

+ + Ptr + + + Channel + SelectChannel5. + SelectChannel3 + IExpChannelLeftA + IExpChannelLeftA + SelectChannel7 + + + Hard + Select + SelectChannel4 + ExpChannelRightB + = + |ExpChannelRightB + +

+ +

+ + arOWAre + Dre’ + SelectChannel5 + SelectChannel7 + +

+
+
+

+ + Talking + to + ASIC4 + +

+
+
+

+ + All + communication + to + an + ASIC4 + is + via + a + Psion + Serial + Link. + As + explained + in + the + chapter + on + the + SIBO + + + serial + protocol, + two + forms + of + data + can + be + sent + and + received + along + this + channel. + These + are + control + and + + + data + bytes. + Control + bytes + give + specific + instructions + to + ASIC4 + and + data + bytes + can + either + be + data + sent + to + + + or + from + ASIC4 + or + data + given + to + or + taken + from + peripheral + chips + in + ASIC4's + address + space. + Sending + + + and + receiving + control + and + data + frames + down + a + Psion + Serial + Channel + from + a + Series + 3/HC + host + is + simply + + + a + matter + of + IN + and + OUT + instructions + to + various + fixed + I/O + addresses. + Various + assembler + macros + have + + + been + set + up + to + ease + this + task + and + provide + machine + independence + and + they + are + detailed + in + the + appendix. + + + These + include: + +

+
+
+

+ + SCONTOUT + Output + the + control + byte + held + in + the + AL + register + + + SDATAIN + Input + a + byte + of + data + and + place + it + in + AL + +

+ +

+ + SDATAOUT + Output + the + data + byte + in + the + AL + register + +

+ +

+ + XNOP + Wait + a + short + while + +

+ +

+ + SBUSY + Wait + while + the + Psion + Serial + Link + is + busy + +

+
+
+

+ + Once + a + piece + of + peripheral + hardware + has + been + designed + the + appropriate + software + must + be + written + to + + + control + it. + All + hardware + devices + on + Series + 3/3a, + Workabout + and + HC + machines + are + controlled + by + device + + + drivers. + These + act + as + an + interface + between + a + piece + of + hardware + and + an + application + that + uses + it. + The + + + following + section + goes + into + further + detail + regarding + the + methods + by + which + a + device + driver + is + able + to + + + communicate + with + and + thereby + control + an + ASIC4 + and + ASICS + based + peripheral. + +

+
+
+

+ + ASIC4 + Registers + +

+
+
+

+ + ASIC4 + has + eight + registers + and + their + functions + in + mixed + (i.e. + peripheral) + mode + are + outlined + below: + +

+
+
+

+ + Register + 0: + This + register + is + the + read/write + Data + Register + that + controls + the + data + lines + DO-D7 + which + are + + + normally + in + tri-state + mode. + Data + written + to + the + Data + Register + is + output + on + DO-D7 + during + a + write + cycle + + + and + data + input + to + the + DO-D7 + may + be + read + from + the + register + during + a + read + cycle. + On + reset, + this + register + + + holds + the + Info + Byte + and + its + bits + have + the + following + meanings: + +

+
+
+

+ + Revision + 1.00 + Page + 53 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Bit + No. + D7 + D6 + DS + D4 + D3 + D2 + DI + DO + + + DD + DN + N + S + S + _ + S + +

+
+
+

+ + D + D_ + OD + i + _ + Device + type + +

+ +

+ + 0 + 0 + O + RAM + SSD + +

+ +

+ + 0 + oO + 1 + Intel + Flash + type + 1 + +

+ +

+ + 0 + 1 + O + Intel + Flash + type + 2 + +

+ +

+ + Oo + 1 + 1 + TBS + +

+ +

+ + 1 + 0 + O + TBS + +

+ +

+ + 1 + 0 + 1 + TBS + +

+ +

+ + 1 + 1 + 0 + Read + only + SSD + (ROM + OTP + etc.) + + + 1 + 1 + 1 + Hardware + Write + protected + SSD + + + N + N + Number + of + devices + +

+ +

+ + 0 + O + 1 + +

+ +

+ + 0 + 1 + 2 + +

+ +

+ + 1 + 0O + 3 + +

+ +

+ + | + ae + | + 4 + +

+ +

+ + S + S_ + S__ + Device + Size + +

+ +

+ + 0 + O + O + Illegal + (Indicates + no + SSD + present) + + + 0 + 0 + 1 + 32Kbyte + +

+ +

+ + 0 + 1 + O + 64Kbyte + +

+ +

+ + Oo + 1 + 1 + 128Kbyte + +

+ +

+ + 1 + 0 + O + 256Kbyte + +

+ +

+ + 1 + 0 + 1 + 512Kbyte + +

+ +

+ + 1 + 1 + O + 1Mbyte + +

+ +

+ + 1 + 1 + 1 + 2Mbyte + +

+
+
+

+ + Register + 1: + This + register + is + both + a + read + and + write + register. + In + read + mode, + it + is + termed + the + Input + + + Register. + The + eight + bits + of + this + register + are + then + defined + as + follows: + +

+
+
+

+ + The + Se, + De + and + Ne + bits + hold, + on + reset, + the + Extended + Info + Byte + which + is + used + in + ASIC4 + Extended + mode + + + to + define + the + type + of + peripheral + device + as + explained + later + in + the + section + on + ASIC4 + reset + and + + + configuration + and + outlined + below: + +

+
+
+

+ + M + De + Ne + Se + + + 1 + 0 + 0 + 90 + No + peripheral + devices + + + 1 + 0 + O + 1 + Turbo + RS232 + serial + (16550) + + + 1 + oO + 1 + O + 3Fax + + + 1 + oO + 1 + 1 + T.B.S. + + + 1 + 1 + 0O + 0 + T.B.S. + + + 1 + 1 + OO + 1 + T.B.S. + + + 1 + 1 + 1 + O + T.B.S. + + + 1 + 1 + 1 + 1 + Extended + info + contained + in + ROM. + +

+
+
+

+ + The + X2 + bit + sets + the + state + of + the + X2D2 + input + which + is + used + to + indicate + whether + the + device + size + is + + + correct. + In + M=0 + mixed + mode, + the + X2 + bit + must + be + low. + Inputs + In0-In2 + hold + the + current + status + of + the + + + three + correspondingly + named + general + input + lines + to + ASIC4. + +

+
+
+

+ + In + write + mode, + Register + 1 + is + termed + the + Device + Size + Register + where + bits + 3-0 + (S3-SO) + map + to + the + + + settings + of + the + decoder + inputs + (and + hence + the + peripheral + device + size) + as + follows + overleaf: + +

+
+
+

+ + Revision + 1.00 + Page + 54 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Size + Register + Decoder + Inputs + Device + Size + (bytes) + + + S3 + S2 + S1 + SO + DCO + DC1 + DC2 + +

+ +

+ + 0 + 0 + 0 + 0 + A15 + Al6 + Al7 + 32k + +

+ +

+ + 0 + 0 + 0 + 1 + Al15 + Al6 + Al7 + 32k + +

+ +

+ + 0 + 0 + 1 + =O + Al6 + Al7 + A18 + 64k + +

+ +

+ + 0 + oO + 1 + 1 + Al7 + Al18 + A19 + 128k + + + 0 + 1 + 0 + 0 + Al8 + Al19 + A20 + 256k + + + 0 + 1 + 0 + 1 + A19 + A20 + A21 + 512k + + + 0 + 1 + 1 + =O + A20 + A21 + A22 + 1M + +

+ +

+ + 0 + 1 + 1 + 1 + A21 + A22 + A23 + 2M + +

+ +

+ + 1 + 0 + 0 + 0 + A22 + A23 + A24 + 4M + +

+ +

+ + 1 + 0 + O + 1 + A23 + A24 + A25 + 8M + +

+ +

+ + 1 + 0 + 1 + O + A24 + A25 + A26 + 16M + +

+ +

+ + 1 + oO + 1 + 1 + A25 + A26 + A27 + 32M + +

+ +

+ + 1 + 1 + 0 + 0 + A26 + A27 + 0 + 64M + +

+ +

+ + 1 + 1 + 0 + 1 + A27 + 0 + O + 128M + + + 1 + 1 + 1 + = + O + 0 + 0 + O + 256M + + + 1 + 1 + 1 + 1 + 0 + oO + O + Not + Used + +

+
+
+

+ + This + register + defaults + to + OxOf + on + reset + (i.e. + not + used). + +

+
+
+

+ + Register + 2: + A + write + to + this + register + , + the + Address + Increment + Register, + will + increment + the + addresses + + + AO-A3. + +

+
+
+

+ + Register3: + This + register + is + the + write-only + Address + Register + which + controls + all + 28 + address + lines + (AO- + + + A27) + directly + and + the + eight + chip + selects + (CSO-CS7) + indirectly. + The + address + register + is + written + to + in + + + multi-transfer + mode + LSByte + (ATO) + first. + There + can + be + up + to + four + bytes + written: + +

+
+
+

+ + Byte + Address + lines + + + ATO + AQ + - + A7 + + + ATI + A8& + - + Al5 + + + AT2 + Al6 + - + A23 + + + AT3 + A24 + - + A27 + +

+
+
+

+ + When + the + first + byte + is + written, + all + the + higher + address + lines + (A8-A27) + are + reset + to + 0. + Bits + 4-6 + of + AT3 + + + may + be + used + by + the + internal + address + decoder + to + control + the + CS + outputs + CSO-CS3 + if + appropriate. + On + + + reset, + all + bits + of + this + register + are + cleared. + +

+
+
+

+ + Register + 4, + 5 + and + 6: + Not + implemented. + + + Register + 7: + This + register + is + the + write + only + ASIC4 + Control + Register + and + holds + the + following + bits: + +

+
+
+

+ + Bit: + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + Label: + LBO + TSTA + LTM + VPS + EDA + CSS + WRS + OES + +

+
+
+

+ + Setting + the + LBO + and + VPS + bits + causes + the + corresponding + lines + on + ASIC4 + to + be + set + high + enabling + them + + + to + be + used + as + general + purpose + outputs + for + peripheral + development. + OES + and + WRS + control + R/W + + + accesses. + +

+
+
+

+ + Additional + ASIC4 + Signals + +

+
+
+

+ + InO, + In1, + In2 + are + general + purpose + digital + inputs. + LBO, + VPS + are + general + purpose + digital + outputs. + OE, + + + WR + control + Read/Write + bus + accesses. + MCSD, + X2D2 + should + be + tied + to + ground + via + a + 100k + resister. + + + POR + is + the + reset + line. + +

+
+
+

+ + Revision + 1.00 + Page + 55 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Talking + to + ASIC5 + +

+
+
+

+ + The + Psion + serial + protocol + was + designed + to + allow + many + different + peripheral + ASICs + to + lie + on + the + same + + + serial + channel. + Before + software + can + communicate + with + an + ASICS + it + must + first + be + selected. + ASICS + + + must + be + selected + in + different + ways + depending + on + whether + it + has + been + configured + (in + hardware) + to + + + operate + in + either + Pack + or + Peripheral + mode. + In + addition + to + selecting + ASICS + when + it + is + first + used, + + + ASICS + must + be + re-selected + whenever + a + hold + and + resume + is + generated + due + to + power + down, + pack + doors + + + opening + or + when + the + peripheral + is + inserted + or + removed. + ASIC5 + will + always + respond + to + a + select + with + a + + + byte + indicating + what + type + of + peripheral + or + pack + it + is. + If + there + is + no + ASICS + connected + to + the + Psion + + + serial + link + there + will + obviously + be + no + response + (zero + is + returned) + and + software + must + then + take + the + + + appropriate + action. + To + select + a + peripheral + mode + ASICS + the + following + code + can + be + used: + +

+
+
+

+ + HwNullFrame + +

+ +

+ + mov + al, + (SerialSelect + or + Asic5NormallId) + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + XNOP + +

+ +

+ + SBUSY + +

+ +

+ + SDATAIN + +

+ +

+ + test + al,al + +

+ +

+ + je + NoASIC5PeripheralOutThere + +

+
+
+

+ + To + select + a + pack + mode + ASICS + the + following + code + can + be + used. + +

+
+
+

+ + HwNullFrame + +

+ +

+ + mov + al, + (SerialSelect + or + Asic5PackId) + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + XNOP + +

+ +

+ + SBUSY + +

+ +

+ + SDATAIN + +

+ +

+ + test + al,al + +

+ +

+ + je + NoASIC5PackOut + There + +

+
+
+

+ + Note + that + an + ASIC4 + can + pretend + to + be + an + ASICS + in + pack + mode + and + will + respond + appropriately. + +

+
+
+

+ + ASIC5 + Registers + +

+
+
+

+ + ASICS + has + sixteen + internal + registers. + To + read + or + write + from + an + ASICS + register + takes + two + steps. + First + + + a + control + byte + must + be + sent + along + the + Psion + serial + link + to + select + which + register. + This + should + be + + + followed + by + a + read + or + write + of + the + appropriate + data + value. + The + sixteen + registers + are + listed + in + the + table + + + below. + Some + can + be + read + and + written + to + and + some + are + read + or + write + only. + +

+
+
+

+ + | + oO + | + URW + PortAreadandwritedata + + + | + 6 + | + RW + Interrupt + Maskread + and + write + + + | + 8 + | + RW + __| + UART + Status/UART + Control + register + + + | + 9 + | + R/W_| + UART + Receive/UART + transmit + holding + register_| + + + UART + Baud + rate + LSB + +

+ +

+ + | + 13) + | + OR + Barcodereaddata + + + | + 4 + {| + ER + Synchronous + Port2read + +

+
+
+
+

+ + Revision + 1.00 + Page + 56 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Reading + from + the + Port + A + register + causes + ASICS + to + generate + a + memory + access + cycle. + The + value + read + + + from + port + A + will + be + the + value + retrieved + from + any + attached + memory + or + memory + mapped + peripheral. + + + Writing + to + Port + A + will + cause + ASICS + to + generate + a + write + cycle + and + write + the + supplied + value + to + attached + + + memory. + In + both + cases + the + address + used + for + the + access + will + depend + on + ASICS's + mode + and + the + + + configuration + of + ports + B, + C, + and + D. + If + the + UART + is + enabled + (Bit + 0 + of + the + port + B + mode + register) + + + memory + cannot + be + accessed + because + port + A + lines + are + reused. + +

+
+
+

+ + Writing + to + port + B + will + cause + the + value + written + to + be + latched + onto + the + output + lines + PBO-PB7 + (which + + + form + address + lines + AO-A7 + for + memory + access + cycles). + Reading + from + this + register + will + return + the + last + + + value + written. + +

+
+
+

+ + Writing + to + the + port + B + mode + controls + various + aspects + of + ASIC5 + behaviour. + The + table + below + indicates + + + the + meanings + of + each + bit + in + the + register. + When + set + to + operate + in + counter + mode + the + value + output + on + + + lines + PBO-PB7 + can + be + incremented + by + reading + from + the + port + B + mode + register, + post-incremented + by + + + reading + or + writing + to + the + port + A + register + or + cleared + to + zero + by + writing + to + the + Port + D + and + C + register. + +

+
+
+

+ + | + 0 + _| + 0, + Memory + mode. + 1, + Peripheral + mode + -enables + UART____| + + + | + 6 + NotUsed + + + + a + +

+
+
+

+ + 7 + Not + Used + +

+
+
+

+ + POT + | + Countermode + + + POT + Latch + mode + + + Pot + | + Baud + rate + outon + portB + +

+
+
+

+ + When + ASICS + is + in + pack + mode + the + first + write + to + the + port + D + and + C + register + will + be + latched + onto + lines + + + PDO-PD7. + In + multiwrite + mode + the + second + and + subsequent + data + writes + will + be + latched + onto + port + C + with + + + the + following + bits + in + the + register + forming + the + following + functions. + +

+
+
+

+ + | + Databit_ + | + Pin, + | + Function + _| + + + a + | + +

+
+
+
+
+

+ + The + bit + SELO + and + SEL1 + determine + which + chip + select + is + used + when + a + memory + access + cycle + is + generated + + + by + accessing + port + A. + CSO-CS3 + are + selected + as + follows. + +

+
+
+

+ + CSO + +

+
+
+

+ + CS2 + +

+
+
+

+ + = + +

+
+
+
+

+ + Revision + 1.00 + Page + 57 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + In + peripheral + mode + a + write + to + the + port + D + and + C + register + will + latch + the + value + written + onto + lines + PD1- + + + PD7. + In + peripheral + mode + the + line + PDO + forms + the + UART + TX + line. + Setting + bit + zero + in + the + port + C + and + D + + + register + therefore + has + no + effect. + +

+
+
+

+ + ASICS + is + capable + of + generating + an + interrupt + due + to + various + external + events. + The + interrupt + mask + + + register + is + used + to + select + which + events + will + generate + an + interrupt. + Writing + to + the + interrupt + mask + + + register + will + set + the + mask + to + the + value + written. + Reading + the + interrupt + mask + register + will + return + the + + + current + mask. + The + meanings + of + each + bit + in + this + register + is + given + in + the + table + below. + Setting + an + + + appropriate + bit + to + 1 + will + enable + that + events + interrupt, + clearing + to + 0 + will + stop + that + event + from + causing + an + + + interrupt. + On + reset + all + events + are + disabled. + +

+
+
+

+ + Bit + + + | + OP + UART + CT + UART + character + received + +

+
+
+

+ + Synchronous + port] + character + received + + + Synchronous + port2 + character + received + + + | + 6 + [PCA + Barcode + data/general + interrupt + +

+
+
+
+

+ + When + an + interrupt + occurs + reading + the + Interrupt + Status + register + will + indicate + the + source + of + the + interrupt. + + + The + meaning + of + each + bit + corresponds + directly + to + each + bit + in + the + interrupt + mask + (see + table + above). + A + + + high + bit + indicates + an + active + interrupt + event. + +

+
+
+

+ + Reading + the + Barcode + data + register + returns + a + byte + representing + the + states + of + the + following + lines. + +

+
+
+
+

+ + Communicating + with + ASIC4 + +

+
+
+

+ + ASIC4 + is + capable + of + operating + in + several + modes. + Attached + peripherals + can + contain + an + ASICS + chip + + + instead + of + an + ASIC4. + Before + talking + to + an + ASIC4 + you + must + first + ensure + that + there + is + an + ASIC4 + at + the + + + end + of + your + serial + link + and + you + must + set + ASIC4 + into + the + correct + operating + mode. + You + must + do + this + + + when + the + channel + is + first + obtained + to + ensure + you + have + the + right + peripheral + to + start + with, + and + also + + + whenever + you + get + a + Hold + and + Resume + due + to + a + power + down, + Pack + doors + opening, + or + the + peripheral + + + being + removed. + You + should + also + check + the + peripherals + ID + to + check + what + peripheral + it + is. + The + user + is + + + more + than + likely + to + pull + out + your + I/O + port + and + replace + it + with + a + 3Fax + in + mid + operation. + You + select + + + ASIC4 + in + the + correct + mode + by + sending + a + special + control + code. + If + there + is + an + ASIC4 + out + there + it + will + + + respond + by + sending + back + a + non + zero + value. + The + peripherals + ID + can + be + read + back + from + ASIC4's + info + + + register. + This + register + also + returns + the + state + of + the + input + lines + INO, + IN1, + IN2. + The + coding + example + + + below + shows + how + ASIC4 + can + be + checked + for, + selected + and + the + peripheral + ID + checked: + +

+
+
+

+ + HwNullFrame + +

+ +

+ + mov + al, + (SerialSelect + or + Asic4Id) + ; + First + look + for + an + + + SBUSY + ; + ASIC4 + at + the + other + + + SCONTOUT + ; + end + of + the + link + + + XNOP + +

+
+
+

+ + Revision + 1.00 + Page + 58 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+
+
+

+ + SBUSY + + + SDATAIN + + + test + al,al + + + je + NoAnASIC4IsItAnASIC5 + + + mov + al, + (SerialReadSingle + or + A4InfoR) + ; + Now + see + if + we + + + SBUSY + ; + have + the + right + + + SCONTOUT + ; + peripheral + + + XNOP + + + SBUSY + + + SDATAIN + ; + Mask + out + the + unwanted + + + and + al,0Of0h + ; + bits + + + cmp + al,PERIPHERAL_ID + ; + check + for + correct + ID + + + jne + IsASIC4ButNotRightPeripheral + ; + Got + our + peripheral + + + ele + ; + Connection + Okay! + + + ret + + + IsASIC4ButNotRightPeripheral: + + + Is + an + ASIC4 + but + not + + + popt + ; + the + right + peripheral + + + stc + ; + Connection + Failed! + + + ret + + + NoAnASIC4IsItAnASIC5: + ; + No + ASIC4 + + + mov + al, + (SerialSelect + or + Asic5NormallId) + + + SBUSY + ; + Could + have + been + an + + + SCONTOUT + ; + ASIC5 + so + try + to + put + + + XNOP + stc + ; + back + in + the + + + right + mode + + + ret + ; + Connection + Failed + +

+
+
+
+
+

+ + Bits + in + ASIC4’s + info + register + have + the + following + definitions: + +

+
+
+

+ + Pot + | + Dmsb + | + DT + Wiss + | + TN? + TN + NO + + + Sending + and + Receiving + data + using + ASIC4 + +

+
+
+

+ + All + ASIC4 + peripherals + are + memory + mapped + into + that + ASIC's + address + space. + To + access + a + peripheral + or + + + a + particular + peripheral's + register + the + ASIC + must + first + be + told + to + set + its + address + bus + to + the + appropriate + + + location. + Once + it + has + been + informed + of + the + address + which + it + is + to + access + that + location + can + be + read + from + + + or + written + to + as + many + times + as + required. + The + value + to + be + written + is + held + in + the + data + register. + To + read + + + or + write + to + another + location + the + address + that + the + ASIC + is + accessing + must + be + changed. + To + read + from + a + + + random + address + within + the + ASIC's + address + space + the + sequence + would + be: + +

+ +

+ + 1) + Send + a + control + code + to + inform + the + ASIC + that + it + is + to + set + its + address + bus + to + the + following + address. + +

+ +

+ + 2) + Send + the + address + to + position + to. + +

+ +

+ + 3) + Send + a + control + frame + to + inform + the + ASIC + that + we + wish + to + read + from + this + address. + +

+ +

+ + 4) + Read + back + the + byte. + +

+
+
+

+ + To + write + a + random + value + to + and + address + within + the + ASIC's + address + space + the + sequence + would + be: + +

+
+
+

+ + 1) + Send + a + control + code + to + inform + the + ASIC + that + it + is + to + set + its + address + bus + to + the + following + address. + + + 2) + Send + the + address + to + position + to. + +

+ +

+ + 3) + Send + a + control + frame + to + inform + the + ASIC + that + we + wish + to + write + to + this + address. + +

+ +

+ + 4) + Send + the + byte. + +

+
+
+

+ + Overleaf + are + two + 8086 + assembler + functions + Input + and + Output + which + read + from + or + write + to + an + address + + + within + the + ASIC's + address + space. + These + functions + only + give + access + to + the + bottom + 256 + addresses. + For + + + peripheral + devices + this + is + usually + more + than + adequate. + Interrupts + should + always + be + off + during + calls + to + + + these + functions + to + prevent + the + S3/S3a/HC + from + multitasking. + Note + that + in + the + following + routines, + + + A4Address + and + A4Data + refer + to + the + value + of + the + respective + ASIC4 + registers. + SerialWriteSingle + has + + + the + value + corresponding + to + a + single + frame + write + in + the + SIBO + serial + protocol + format. + These + system + + + defines + can + be + found + in + the + important + include + files + ospack.inc + and + ossibo.inc. + +

+
+
+

+ + ProcBegin@ + Output + +

+
+
+
+
+

+ + ; + + + ; + +

+ +

+ + ; + Output + byte + to + ASIC4-based + peripheral + +

+ +

+ + ; + IN: + DL + holds + the + hardware + address + ASIC4 + is + to + write + to + +

+
+
+

+ + Revision + 1.00 + Page + 59 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ; + AL + holds + the + byte + to + be + output + to + that + address + +

+ +

+ + push + ax + +

+ +

+ + mov + al, + (SerialWriteSingle + or + A4Address) + ;CTRL=Write + to + A4 + address + + + reg + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + ;Send + this + control + + + frame + +

+ +

+ + mov + al,dl + ;DATA=Hardware + address + +

+ +

+ + SBUSY + +

+ +

+ + SDATAOUT + ;Send + this + data + + + frame + +

+ +

+ + mov + al, + (SerialWriteSingle + or + A4Data) + ;CTRL=Writing + data + + + now + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + ;Send + this + control + + + frame + +

+ +

+ + pop + ax + ;DATA=Data + to + write + +

+ +

+ + SBUSY + +

+ +

+ + SDATAOUT + ;Send + this + data + + + frame + +

+ +

+ + ret + +

+
+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + Input + +

+
+
+
+
+
+

+ + ; + Input + byte + from + ASIC4-based + peripheral + + + 7 + IN: + DL + holds + the + hardware + address + ASIC4 + is + to + read + from + + + ; + OUT:AL + holds + the + value + read + from + that + address + +

+ +

+ + mov + al, + (SerialWriteSingle + or + A4Address) + ;CTRL=Write + to + A4 + address + + + reg + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + ;Send + this + control + + + frame + +

+ +

+ + mov + al,dl + ;DATA=Hardware + address + +

+ +

+ + SBUSY + +

+ +

+ + SDATAOUT + ;Send + this + data + + + frame + +

+ +

+ + mov + al, + (SerialReadSingle + or + A4Data) + ;CTRL=Reading + data + + + now + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + ;Send + above + + + control + frame + +

+ +

+ + SBUSY + +

+ +

+ + XNOP + +

+ +

+ + SDATAIN + ;Receive + data + frame + +

+ +

+ + ret + ;AL + holds + the + data + +

+
+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + Obtaining + and + using + a + channel + +

+
+
+

+ + The + s3/S3a/HC + have + three + Psion + serial + links. + Only + one + of + these + channels + can + be + selected + for + + + communication + at + any + one + time. + Two + of + these + channels + form + the + SSD + slots. + The + third + forms + the + + + expansion + port. + Before + a + device + driver + is + able + to + talk + to + a + peripheral + it + must + both + own + and + have + this + + + third + channel + selected. + Many + device + drivers + can + exist + in + memory + and + more + than + one + may + access + the + + + peripheral. + To + prevent + multiple + access + to + a + single + peripheral + a + device + driver + must + first + own + a + serial + + + channel + before + it + is + free + to + communicate + to + the + ASIC4/S + peripheral + at + the + end + of + it. + To + check + if + a + + + channel + is + free + and + then + reserve + it + call + the + operating + system + function + HwGetChannel. + This + will + return + + + with + carry + clear + if + the + attempt + to + capture + the + channel + was + successful, + carry + set + otherwise. + +

+
+
+

+ + mov + al, + InterruptMaskForDesiredChannel + + + HwGetChannel + + + jc + CouldntGetTheChannel + +

+
+
+

+ + Obtaining + the + desired + channel + will + usually + be + performed + by + a + device + drivers + open + vector. + Open + + + should + fail + if + the + channel + is + unavailable. + If + a + device + drivers + takes + possession + of + a + channel + it + is + its + duty + +

+
+
+

+ + Revision + 1.00 + Page + 60 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + to + free + it + again + once + it + is + finished. + This + would + normally + be + done + when + the + device + drivers + is + closed + and + + + is + performed + by + the + operating + system + function + HwFreeChannel. + +

+
+
+

+ + mov + al, + InterruptMaskForDesiredChannel + + + HwF + reeChannel + +

+
+
+

+ + As + illustrated + in + the + above + table, + on + a + series + 3a + the + interrupt + mask + for + the + expansion + port + (Port + C) + is + + + defined + by + A9MSlave, + on + a + series + 3 + Asic2Int. + Interrupts + are + IRQ2 + and + IRQ4 + respectively. + Only + one + + + serial + link + can + ever + be + selected + at + one + moment + in + time. + Selecting + a + particular + channel + means + that + you + + + are + unable + to + speak + to + another + without + selecting + it + instead. + To + select + a + channel + the + operating + system + + + call + HwSelectChannel + is + used. + +

+
+
+

+ + mov + al, + SelectForDesiredChannel + + + HwSelectChannel + + + push + ax + +

+
+
+

+ + HwSelectChannel + will + return + in + al + the + channel + that + was + previously + selected. + Device + drivers + should + + + select + the + correct + channel + on + entry + to + any + vector + or + interrupt + service + routine + that + needs + to + + + communicate + down + that + channel. + On + exit + the + previously + selected + channel + should + be + restored. + + + Between + the + time + when + the + channel + is + first + selected + and + when + the + old + channel + is + restored + multitasking + + + should + be + disabled. + this + will + usually + mean + switching + off + interrupts. + Because + of + the + watchdog + timer, + + + interrupts + cannot + be + left + off + for + an + indeterminate + length + of + time. + Communications + down + channels + + + therefore + will + usually + be + restricted + to + short + bursts. + For + the + expansion + port + the + channel + to + select + on + an + + + S3a + is + defined + by + Select + Channel5 + on + an + $3 + SelectChannel7. + +

+
+
+

+ + pushf + +

+ +

+ + eli + +

+ +

+ + mov + al, + SelectChannel5 + + + hwSelectChannel + +

+ +

+ + push + ax + +

+ +

+ + mov + dl, + AddressOfInputBuffer + + + call + Input + +

+ +

+ + mov + dl, + AddressOfOutputBuffer + +

+
+
+

+ + call + Output + +

+
+
+

+ + pop + ax + + + hwSelectChannel + + + popf + +

+
+
+

+ + Controlling + ASIC5's + UART + +

+
+
+

+ + Before + data + can + be + sent + or + received + from + ASIC5's + UART + continuous + clocking + from + the + host + must + be + + + enabled + and + a + baud + rate + selected. + The + UART + must + be + enabled + by + setting + bit + 0 + in + the + port + B + mode + + + register. + The + selected + baud + rate + value + is + related + to + the + result + of + dividing + the + required + baud + rate + into + + + the + input + clock + frequency + from + the + host + of + 1.536 + MHz. + The + value + generated + from + the + equation + given + + + below + forms + a + sixteen + bit + word. + ASICS + has + two + registers + for + selecting + the + baud + rate. + Register + 10 + + + should + contain + the + least + significant + byte + and + register + 11 + the + most + significant + byte + of + the + calculated + + + word + value. + The + table + below + lists + the + divisor + values + for + some + of + the + more + commonly + required + baud + + + rates: + +

+
+
+

+ + Divisor + = + 1-(96000/Desired + Baud + Rate) + +

+
+
+

+ + 9600 + a + ee + ae + ee + + + 7200 + fff + + + 4800 + +

+
+
+
+

+ + Revision + 1.00 + Page + 61 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+
+

+ + The + format + of + data + communicated, + stop + bits, + data + bits, + parity + checking, + is + controlled + by + writing + to + the + + + UART + status/control + Register. + Bits + in + the + UART + status/control + register + have + the + following + meanings: + +

+
+
+

+ + | + 0 + | + Stateof + the + CTS + line + (PAI) + ___| + Generate + break + character + + + iar + +

+
+
+
+

+ + A + character + to + be + transmitted + should + be + written + to + the + Transmitter + Holding + Register + where + ASICS + will + + + convert + it + to + serial + form + for + transmission. + The + register + will + be + emptied + once + the + character + has + been + + + transmitted. + ASIC5 + contains + no + internal + buffering. + The + Transmitter + Holding + Register + must + be + empty + + + before + writing + a + character + to + it. + The + state + of + the + Transmitter + Holding + Register + is + reflected + in + the + + + Transmitter + Empty + bit + in + the + UART + status + register. + Enabling + the + Transmitting + Holding + Register + + + interrupt + will + cause + ASICS + to + generate + an + interrupt + every + time + that + the + Transmitting + Holding + Register + + + becomes + empty. + Reading + the + UART + Status + Register + will + clear + the + interrupt. + Received + characters + are + + + copied + into + the + Receive + Character + Register. + If + the + Receive + Character + Interrupt + is + enabled + ASICS + + + generates + an + interrupt + on + each + character + received. + If + the + character + is + received + in + error + due + either + + + parity, + framing + or + overrun + errors, + appropriate + bits + in + the + UART + Status + Register + are + set + to + reflect + this. + +

+
+
+

+ + Hold + and + Resumes + +

+
+
+

+ + There + are + three + types + of + hold + and + resume. + The + first + occurs + when + memory + is + being + moved. + An + LDDs + + + hold + and + resume + vectors + will + always + be + called + when + this + occurs. + The + second + is + a + On/Off + Hold + and + + + resume. + An + LDD + will + always + be + held + and + resumed + when + this + occurs + although + it + is + not + guaranteed + that + + + power + will + have + been + restored + to + the + expansion + ports + when + the + resume + is + issued. + The + third + type + + + occurs + when + one + of + the + pack + doors + is + opened + or + a + peripheral + inserted. + Only + certain + internal + LDDs + + + receive + a + Hold + and + Resume + under + these + circumstances. + Any + loaded + LDD + will + definitely + not + receive + a + + + Hold + or + Resume. + To + get + around + these + problem, + the + TcK: + device + driver + is + used + to + provide + a + regular + + + call + to + a + routine + within + your + driver. + This + call + monitors + the + power + to + the + expansion + port + and + issues + its + + + own + holds + and + resumes + as + appropriate. + Holds + and + resumes + can + become + nested + and + the + whole + situation + + + can + become + rather + complicated. + The + correct + procedure + for + dealing + with + holds + and + resumes + for + an + + + ASIC4 + peripheral + device + driver + (LDD) + is + given + below. + +

+
+
+

+ + When + a + hold + is + received + through + the + normal + route + the + channel + is + marked + as + being + under + a + normal + + + hold. + If + the + polling + routine + sees + that + the + power + has + vanished + and + the + channel + is + not + already + under + a + +

+
+
+

+ + Revision + 1.00 + Page + 62 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + normal + hold + then + it + holds + the + channel + and + marks + it + as + being + under + a + special + hold. + If + a + normal + resume + + + is + issued + channel + can + be + resumed + but + only + if + power + is + present. + If + power + is + not + present + then + the + + + channel + is + marked + as + being + under + a + special + hold + and + the + resume + is + put + off. + If + the + polling + routine + sees + + + that + the + power + is + present + and + that + the + channel + is + under + a + special + hold + then + it + should + resume + the + + + channel. + +

+
+
+

+ + Alternatively + of + course + each + time + you + read + and + write + to + your + peripheral + you + could + do + a + quick + pre- + + + check + to + see + if + the + hardware + is + available + and + set-up + correctly. + This + would + dispense + with + the + need + to + + + handle + power + up/down + or + pack + door + holds + and + resumes. + You + would + still + have + to + start + and + stop + + + interrupts + though + when + appropriate. + +

+
+
+

+ + Example + Device + Drivers + +

+
+
+

+ + An + example + device + driver + which + will + control + the + ASIC4 + Example + Interface + Board + described + earlier + + + can + be + found + in + the + file + A4EXIF.ASM. + The + device + driver + is + a + fully + comprehensive + multi-channel + + + implementation. + It + supports + all + the + mandatory + logical + device + driver + functions. + Open + will + fail + if + the + + + Interface + Board + hardware + is + not + present. + It + has + an + interrupt + service + routine + and + handles + Holds + and + + + Resumes + correctly + in + all + the + distinct + cases + outlined + earlier. + In + addition, + asynchronous + reads + of + the + + + LED + status + are + possible + so + a + special + routine + to + handle + this + case, + the + Wait + Handler, + is + included. + The + + + driver + has + been + made + as + fully + comprehensive + as + possible + both + in + terms + of + functionality + and + the + choice + + + of + host + machine. + To + this + end, + the + code + given + can + be + compiled + for + the + entire + range + of + Psion + machines + + + simply + by + changing + the + appropriate + machine + Build + Flag + at + the + head + of + the + file + which + then + causes + the + + + correct + interrupt + masks + to + be + selected + for + the + machine. + Chapter + 11 + of + this + document + details + the + + + structure + of + A4EXIF.LDD + a + logical + device + driver + constructed + for + the + ASIC4 + Example + Interface + Board. + +

+
+
+

+ + Chapter + 12 + details + the + functionality + of + a + physical + device + driver + for + the + ASIC5-based + Psion + 3-link + + + peripheral + that + enables + the + host + hardware + to + communicate + with + a + PC + by + converting + SIBO + serial + + + protocol + signals + into + RS232 + signals. + Once + again, + this + driver + contains + various + build + flags + to + facilitate + + + conditional + compilation. + Common + interrupt + routine + code + is + included + and + the + LDD-PDD + interface + is + + + specified. + +

+
+
+

+ + The + source + code + for + both + A4ZEXIF.LDD + and + SYS$AS5.PDD + is + presented + in + the + appendix + to + this + + + document. + +

+
+
+

+ + Revision + 1.00 + Page + 63 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 11. + AN + EXAMPLE + DEVICE + DRIVER + FOR + ASIC4: + + + A4EXIF.LDD + +

+
+
+

+ + Introduction + +

+
+
+

+ + In + this + chapter, + the + functionality + and + code + structure + an + example + installable + logical + device + driver, + + + A4EXIF.LDD, + is + presented + in + some + depth. + Circuit + details + of + the + corresponding + Psion + peripheral + for + + + this + driver, + the + ASIC4 + Example + Interface + board, + were + outlined + in + chapter + 8. + A4EXIF.LDD + enables + + + software + written + using + the + Psion + SDK + to + communicate + with + the + prototype + ASIC4 + Example + Interface + + + board + through + means + of + standard + PLIB + calls + such + as + ‘p_open' + and + 'p_write’. + The + description + of + + + A4EXIF.LDD + is + intended + to + provide + a + clear + insight + into + the + generalised + structure + of + logical + device + + + drivers + for + peripherals + based + around + the + SIBO + architecture. + To + this + end + the + actual + usefulness + of + the + + + combined + hardware-driver + interface + is + of + secondary + importance. + As + shown + earlier, + the + ASIC4 + + + Interface + Board + translates + SIBO + serial + protocol + signals + into + a + parallel + 8-way + data + bus + format + which + + + can + be + used + to + set + various + 74HC + series + latches + and + gates. + An + eight-bit + buffer + and + latch + are + commoned + + + to + eight + LEDs. + The + latch + is + write-only + and + is + used + for + setting + the + state + of + the + LEDs. + The + buffer + is + + + read-only + and + is + used + to + sense + the + state + of + the + LEDs. + In + addition, + a + facility + for + generating + hardware + + + interrupts + is + provided + by + means + of + a + suitably + connected + switch + and + third + 8-way + buffer + (the + status + + + buffer). + Address + decoding + is + provided + by + two + 2-to-4 + decoders + attached + to + address + lines + AO + and + Al. + +

+
+
+

+ + Code + Structure + +

+
+
+

+ + Loading + A4EXIF.LDD + and + Device + Names + +

+
+
+

+ + A4EXIF.LDD + is + loaded + into + the + RAM + of + the + host + machine + by + means + of + the + following + PLIB + call + in + the + + + application + code: + +

+
+
+

+ + p_loadldd + ("A4EXIF.LDD") + ; + +

+
+
+

+ + The + name + of + a + device + driver + is + the + mechanism + by + which + an + application + can + obtain + a + channel + to + that + + + device + driver. + LDDs + all + have + three + character + names + which + are + stored + in + the + second + field + of + the + + + driver's + LibEnt + structure + followed + by + a + colon. + This + name + is + required + to + uniquely + identify + the + LDD + to + + + the + OS + when + attempting + to + open + a + channel + on + it. + The + A4EXIF + LDD + has + the + three + character + name + + + "LED" + so + a + channel + with + its + handle + in + pcb + may + be + obtained + on + it + by + means + of + the + following + call: + +

+
+
+

+ + p_open + (&pcb, + "LED:",-1); + +

+
+
+

+ + EPOC + used + the + driver + name + in + the + p_open + call + to + invoke + the + ToOpen + system + service + which + in + turn + + + invokes + the + Open + vector + on + the + associated + device + driver. + +

+
+
+

+ + The + Single + Code + Segment + and + Data + Storage + +

+
+
+

+ + As + indicated + earlier, + loadable + Psion + device + drivers + have + a + single + code + segment + and + no + data + segment. + + + Data + associated + with + the + driver + is + stored + in + one + of + two + distinct + ways + dependent + on + its + nature. + Global + + + data + associated + with + the + driver + is + stored + in + its + code + segment. + Examples + of + such + data + are + the + channel + + + interrupt + masks + and + numbers + have + to + be + visible + to + all + processes + that + may + be + using + A4EXIF.LDD. + + + Data + local + to + the + application + invoking + the + driver, + however, + is + stored + in + the + heap + space + of + that + + + application. + An + example + in + A4EXIF.LDD + would + be + the + pointers + to + the + open + channel + strategy + vector + + + parameters. + +

+ +

+ + The + overall + structure + of + the + code + segment + is + typical + of + Psion + logical + device + drivers. + The + code + segment + + + begins + with + a + CodeSeg + directive + followed + by + the + LibEnt + structure + which + defines + the + mandatory + device + + + driver + functions + as + well + as + two + non-mandatory + ones. + These + are + the + Wait + Handler + and + the + replacement + +

+
+
+

+ + Revision + 1.00 + Page + 64 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Tick + Interrupt + Vector. + Before + entering + the + code + for + these + functions, + all + global + variables + are + declared + + + in + what + is + termed + the + device + driver's + internal + data + space. + Following + the + code + for + the + Lib + Ent + functions + + + comes + the + code + for + all + the + local + driver + functions. + After + these + are + the + EndCodeSeg + and + end + A4ExifLDD + + + directives. + +

+
+
+

+ + Channel + Status + Ent + and + Open + Channel + Control + Block + +

+
+
+

+ + At + the + head + of + the + driver's + assembler + source + file + A4EXIF.ASM, + various + constants, + compiler + defines + + + and + type + definitions + are + listed. + It + is + here + that + templates + are + declared + for + the + global + structures + that + hold + + + the + key + driver + variables. + In + view + of + the + above + discussion, + most + device + drivers + employ + at + least + one + + + globally + defined + structure + to + hold + the + various + important + flags + and + masks + that + relate + to + the + status + of + + + each + separate + channel + on + that + driver. + In + the + case + of + A4EXIF.LDD, + two + different + structure + types + are + + + employed, + namely + A4ExifStatusEnt + and + A4ExifEnt. + The + former + is + referred + to + in + this + chapter + as + the + + + StatusEnt + struc + and + is + instantiated + later + on + in + the + device + driver + code + segment + with + each + separate + + + permissible + channel + of + the + main + Psion + host + machines + being + assigned + its + own + StatusEnt + struc. + A + + + channel's + StatusEnt + struc + is + generally + accessed + through + CS:DI + and + holds + important + channel-related + + + information + such + as + the + A4ExifChannelOpen + and + A4ExifChannelRunning + flags + and + the + channel + + + interrupt + masks + and + interrupt + numbers. + The + StatusEnt + structure + resides + in + the + driver + code + segment + + + whereas + the + A4ExifEnt + struc + is + held + in + the + heap + space + of + the + application + invoking + the + driver + and + so + is + + + accessed + through + DS:BX. + The + A4ExifEnt + structure + contains + a + number + of + variables + that + are + logically + + + associated + with + a + successfully + opened + channel + and + as + such + should + be + distinguished + from + the + StatusEnt + + + variables. + An + A4ExifEnt + struc + instantiated + by + invoking + the + device + driver's + open + vector + is + referred + to + + + as + the + open + channel + control + block + and + it + is + generally + accessed + through + DS:BX. + +

+
+
+

+ + The + layout + of + both + the + StatusEnt + struc + and + the + A4ExifEnt + open + channel + control + block + struc + are + + + presented + later + in + this + chapter + along + with + various + other + important + pre-defined + structs + that + were + used + in + + + the + construction + of + A4EXIF.LDD. + Both + of + these + structures + were + extensively + used + in + the + coding + of + the + + + LDD + functions + described + in + the + following + pages. + +

+
+
+

+ + SIBO + hardware + and + conditional + compilation + +

+
+
+

+ + The + number + of + expansion + channels + supported + by + a + host + SIBO + machine + is + dependent + on + the + hardware. + + + In + the + case + of + the + S3a, + only + one + SIBO + channel + can + legitimately + be + opened + corresponding + to + expansion + + + port + A. + With + the + HC + and + Workabout, + it + is + possible + to + open + up + to + three + separate + SIBO + channels + on + + + ports + A + through + to + C. + In + A4EXIF.LDD, + a + global + constant + numberofchannels + 1s + set + at + the + start + of + the + + + device + driver + code + segment + to + indicate + the + number + of + serial + SIBO + channels + supported + by + the + different + + + machines. + This + will + vary + according + to + the + Psion + hardware + present + and + in + order + to + aid + conditional + + + compilation + of + the + A4EXIF + driver + for + the + different + host + machine + possibilities, + a + number + of + build + flags + + + can + be + used + to + set + various + constants + within + the + include + files. + The + hardware + options + with + regard + to + + + these + flags + were + outlined + in + the + previous + chapter. + +

+
+
+

+ + It + should + be + noted + that + Psion + device + drivers + should + be + designed + to + be + easily + adapted + from + machine + to + + + machine. + With + the + A4EXIF + driver, + for + instance, + the + only + change + that + needs + to + be + made + in + adapting + it + + + for + use + on + another + Psion + machine + is + the + alteration + of + the + build + flag + at + the + start + of + the + code + segment. + + + This + flag + indicates + to + the + compiler + which + SIBO + machine + flags + as + well + as + other + variables + should + be + set. + + + The + SIBO + machine + flags + are + in + turn + used + later + in + the + code + segment + header + to + set + the + global + + + numberofchannels + variable + mentioned + above. + For + example, + in + A4EXIF.LDD, + we + have + the + + + following: + +

+
+
+

+ + if + Corporate + or + Workabout + + + numberofchannels + equ + 3 + + + else + +

+
+
+

+ + endif + +

+
+
+

+ + This + type + of + code + is + used + extensively + in + the + conditional + instantiation + of + A4ExifStatusEnts + in + the + + + device + driver's + internal + data + space. + Here + different + interrupt + masks + and + SIBO + channels + are + invoked + for + + + the + different + machines + according + to + the + host + controller + ASIC. + For + instance, + in + the + case + of + a + consumer + + + (S3a), + the + hardware + interrupt + mask + corresponding + to + expansion + port + C + on + an + ASIC9 + is + mask + + + A9MsSlave + and + the + interrupt + number + is + HwIrq2Revector. + On + an + Workabout, + the + masks + for + expansion + +

+
+
+

+ + Revision + 1.00 + Page + 65 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ports + A, + B + and + C + are + A9MExpIntA, + A9MExpIntB + and + A9MSlave + respectively. + The + corresponding + + + interrupt + numbers + are + HwIrq4Revector, + HwIrq5Revector + and + HwIrq2Revector. + This + conditional + + + compilation + code + in + A4EXIF.LDD + outlined + here + is + worthy + of + some + study + because + it + encapsulates + all + + + the + information + regarding + masks + and + SIBO + hardware + channels + required + by + the + prospective + developer + + + interested + in + constructing + a + multi-platform + Psion + peripheral + and + driver. + +

+
+
+

+ + Mandatory + LDD + Functions + +

+
+
+

+ + The + eight + mandatory + LDD + functions + are + the + Install, + Remove, + Hold, + Resume, + Reset, + Units, + Open + and + + + Strategy + and + they + are + all + discussed + in + the + context + of + the + example + device + driver + A4EXIF.LDD + below. + +

+
+
+

+ + A4Exifinstall + + + IN: + No + values + are + passed + to + the + install + vector. + + + OUT: + If + successful + return + with + carry + clear. + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register. + +

+
+
+

+ + PRESERVE: + SS, + SP + and + BP + +

+
+
+

+ + The + install + vector + is + called + by + the + operating + system + when + the + device + driver + is + loaded + in + order + to + + + initialise + any + internal + variables. + It + should + not + be + called + directly + by + an + application + process + but + invoked + + + indirectly + by + a + 'p_loadldd("A4EXIF.LDD")' + call. + Typically + at + this + stage + the + various + open + channel + + + flags + would + be + initialised + to + zero + but + in + the + case + of + the + A4EXIF.LDD, + this + has + already + been + done + in + + + the + appropriate + A4ExifStatusEnt + struc + headers. + As + a + result, + the + install + vector + merely + clears + the + carry + + + flag + and + returns. + +

+
+
+
+

+ + A4ExifRemove + + + IN: + No + values + are + passed + to + the + remove + vector + + + OUT: + If + successful + return + with + carry + clear. + +

+
+
+

+ + If + installation + unsuccessful, + return + with + carry + set + and + error + number + in + the + AL + + + register. + + + PRESERVE: + SS, + SP + and + BP + +

+
+
+

+ + The + remove + vector + is + called + by + the + operating + system + whenever + the + device + driver + is + requested + to + be + + + unloaded + which + is + usually + indirectly + as + the + result + of + a + call + to + 'p_devdel + ("LED", + E_LDD)'. + ROM- + + + resident + drivers + cannot + be + deleted + so + any + attempt + to + invoke + this + vector + on + them + will + result + in + an + error + + + being + returned. + The + code + for + the + remove + vector + checks + to + see + that + all + the + device + driver + channels + are + + + closed + and + returns + carry + clear + if + this + is + the + case. + In + the + case + of + A4EXIF.LDD, + a + closed + channel + will + + + hold + a + zero + in + its + corresponding + StatusEnt + open + channel + flag. + If + any + of + the + open + channel + flags + is + non- + + + zero + then + the + carry + flag + is + set + before + returning + indicating + that + an + attempt + has + been + made + to + unload + a + + + device + driver + that + still + holds + at + least + one + open + channel. + In + the + case + of + A4EXIF.LDD, + the + + + numberofchannels + flag + is + used + as + a + loop + counter + for + the + different + hardware + channel + possibilities + in + a + + + similar + manner + to + the + corresponding + code + in + the + open + vector. + +

+
+
+

+ + A4ExifHold + +

+ +

+ + IN: + AH + register + holds + one + of + the + following + values: + + + DevHoldNormal, + DevHoldPowerDown + Or + DevHoldPowerFail + +

+ +

+ + OUT: + None + +

+
+
+

+ + PRESERVE: + SS, + SP + and + BP + +

+ +

+ + The + hold + vector + is + called + by + the + operating + system + whenever + the + device + driver + is + requested + to + be + held. + + + This + can + occur + as + a + result + of + three + conditions + which + result + in + the + three + different + possibilities + for + the + + + value + held + in + AH: + +

+ +

+ + 1. + Device + memory + segments + about + to + be + moved. + AH + holds + DevHoldNormal. + +

+
+
+

+ + Revision + 1.00 + Page + 66 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 2. + Machine + about + to + switch + off + due + to + power-save + time-out + or + the + off + switch + being + pressed. + AH + holds + + + DevHoldPowerDown. + +

+ +

+ + 3. + Machine + about + to + switch + off + due + to + power + source + being + removed + or + the + batteries + failing. + AH + holds + + + DevHoldPowerFail. + +

+ +

+ + The + hold + vector + code + must + be + able + to + conduct + a + rapid + shut + down + of + the + device + driver + because + in + the + + + case + of + DevHoldPowerFail, + the + driver + may + only + have + a + couple + of + ms + before + internal + voltages + fall + to + an + + + unworkable + level. + The + EPOC + OS + automatically + handles + the + three + cases + highlighted + above + but + in + + + Series + 3a + machines + and + the + Workabout, + in + addition + to + these + there + is + another + situation + that + requires + the + + + invocation + of + the + hold + vector, + namely + the + opening/closing + of + the + SSD + pack + doors + on + an + S3a + or + + + Workabout. + This + is + an + action + which + can + only + be + detected + by + means + of + software + polling + which + requires + + + the + setting + up + of + the + ROM-resident + "TcK:" + device + driver + so + that + the + door + status + can + be + checked + each + + + system + tick + (i.e. + 32 + times + a + second). + The + section + on + A4ExifTickInt + provides + a + more + detailed + outline + of + + + the + TCK + interrupt + code + required + to + handle + pack + door + opening + and + closing. + It + is + this + latter + routine + that + + + polls + for + the + open + or + closed + status + of + the + host + machine + doors, + setting + the + global + HoldFlag + accordingly. + + + The + Hold + vector + code + thus + includes + a + check + on + the + status + of + the + HoldFlag + and + is + generally + optimised + + + to + be + as + efficient + as + possible. + An + outline + of + the + structure + of + A4ExifHold + presented + below. + It + follows + + + the + pattern + for + a + typical + device + driver: + +

+
+
+

+ + e + Check + the + state + of + the + global + HoldFlag. + +

+ +

+ + e + If + the + flag + is + non-zero, + then + the + driver + is + already + held + and + the + function + returns + without + taking + + + any + further + action. + +

+ +

+ + e + = + If + the + HoldFlag + is + zero, + then + the + function + checks + the + status + of + all + the + channels + that + the + driver + + + is + permitted + to + open. + If + any + of + these + channels + have + their + open + channel + flags + cleared, + it + is + not + + + necessary + to + do + anything + as + part + of + the + process + of + holding + the + channel. + Only + in + the + case + when + + + the + flags + are + set + is + the + 'stopChannelRunning’ + function + invoked. + As + with + the + similar + loop + in + + + the + Reset + vector, + the + global + numberofchannels + is + used + as + the + loop + counter + as + each + of + the + + + possible + channels + has + to + be + checked. + +

+
+
+

+ + A4ExifResume + + + IN: + None + + + OUT: + None + +

+
+
+

+ + PRESERVE: + SS, + SP + and + BP + +

+
+
+

+ + The + resume + vector + is + called + by + the + operating + system + to + restart + a + held + device + driver. + Resume + will + be + + + called + after + a + hold + caused + by + any + of + the + four + possibilities + indicated + above + in + the + section + on + A4ExifHold + + + but + it + should + be + noted + that + in + some + cases, + ASIC4 + will + only + be + switched + on + after + the + call + to + resume. + + + The + device + driver + is + expected + to + recover + from + the + previous + hold + and + resume + any + suspended + I/O + except + + + in + the + case + of + power + failure + where + the + resume + vector + ought + to + power + up + the + peripheral + and + put + it + into + a + + + known + state + indicating + to + the + user + that + data + may + have + been + lost. + The + resume + vector + will + also + have + to + + + handle + the + reinstallation + of + any + interrupt + service + routines + by + checking + the + status + of + the + open + channel + + + flag. + +

+
+
+

+ + e + Check + the + state + of + the + global + HoldFlag. + +

+ +

+ + e + If + the + flag + is + zero, + then + the + driver + has + already + resumed + so + return + without + further + action. + +

+ +

+ + e + If + the + flag + is + non-zero, + then + check + the + door + status + of + the + host + machine + with + a + call + to + the + OS + + + HwGetSsdData + service. + If + the + doors + are + open, + then + set + HoldFlag + to + 2 + to + signal + this + position + + + to + the + driver. + If + the + doors + are + closed, + then + numberofchannels + is + used + as + a + loop + counter + while + + + the + open + channel + flags + of + each + of + the + permissible + channels + for + the + host + hardware + are + checked. + + + Only + if + these + flags + are + set + is + the + 'start + TheChannelRunning’ + function + invoked. + +

+
+
+

+ + A4ExifReset + + + IN: + BX + holds + the + device + driver + device + handle + + + CX + holds + user + specified + channel + identification + data. + In + this + case, + holds + the + address + + + of + the + status + struc + identifying + the + open + channel + to + be + reset. + + + OUT: + None + +

+
+
+

+ + Revision + 1.00 + Page + 67 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + PRESERVE: + SS, + SP + and + BP + +

+
+
+

+ + The + reset + vector + enables + a + device + driver + to + reset + itself + when + the + application + which + owns + the + device + + + driver + terminates + abnormally + before + closing + one + or + more + open + channels + on + that + driver. + The + vector + is + + + only + invoked + by + the + operating + system + if + it + has + been + primed + by + means + of + a + call + to + the + ToRequestReset + + + operating + system + service + in + the + open + vector. + Such + a + call + must + be + balanced + by + a + corresponding + call + to + + + IoRequestResetCancel + in + the + close + function + code + of + the + strategy + vector. + Registers + BX + and + CX + are + + + required + to + be + set + up + by + the + user + prior + to + invocation + of + either + of + these + services. + BX + should + contain + the + + + device + driver + handle + which + is + passed + through + DX + in + the + open + vector. + CX + should + hold + any + suitable + + + open + channel + identification + data + that + can + be + accessed + in + the + driver's + internal + data + space + (i.e. + through + + + CS:DI). + In + the + case + of + A4EXIF.LDD, + this + information + is + the + address + of + the + channel + StatusEnt + + + structure. + If + a + device + driver + is + only + capable + of + opening + one + channel, + then + it + is + irrelevant + what + CX + + + holds. + A + reset + should + only + be + outstanding + while + some + process + has + a + channel + open + on + the + device + + + driver. + The + format + of + A4ExifReset + is + similar + to + that + of + a + typical + reset + vector + and + can + be + summarised + + + as + follows: + +

+
+
+

+ + e + Move + the + address + of + the + channel + status + Ent + from + CX + into + DI. + +

+ +

+ + e + Check + the + value + of + the + corresponding + cs:[di].A4ExifChannelOpen + flag. + +

+ +

+ + e + If + channel + is + not + open + to + reset, + then + return + from + the + vector + otherwise + call + + + "StopTheChannelRunning’ + and + use + HwFreeChannel + to + release + the + SIBO + serial + channel. + Set + + + the + ChannelOpen + flag + to + zero. + +

+
+
+

+ + A4ExifUnits + + + IN: + None + + + OUT: + AX + holds + the + number + of + channels + supported. + +

+
+
+

+ + PRESERVE: + SS, + SP + and + BP + +

+
+
+

+ + The + A4ExifUnits + function + is + called + by + the + operating + system + when + the + device + driver + is + requested + to + + + report + the + number + of + units + (or + channels) + that + it + can + support. + This + is + primarily + useful + for + purposes + of + + + information. + +

+
+
+

+ + A4ExifOpen + +

+
+
+

+ + IN: + DX + contains + the + device + handle + of + the + device + driver + + + SL + is + a + pointer + to + an + OpenEnt + struc + + + BP + is + a + pointer + to + an + IntEnt + struc + + + DS, + ES + point + to + the + application + process's + data + segment + + + OUT: + If + successful + return + with + carry + clear + and + the + address + of + the + open + channel + in + BX. + + + i.e. + BX + holds + the + address + of + an + A4ExifEnt + struc + which + contains + various + fields + of + + + information + concerning + the + open + channel. + + + If + installation + unsuccessful, + return + with + carry + set + and + error + number + in + the + AL + + + register. + + + PRESERVE: + DS, + ES, + SS, + SP, + BP + and + DX + +

+
+
+

+ + The + open + vector + is + called + by + the + operating + system + when + a + channel + to + the + device + driver + is + required + to + be + + + opened. + The + device + handle, + which + is + passed + through + DX, + is + used + by + the + operating + system + to + route + any + + + I/O + requests + on + the + opened + channel + to + the + correct + device + driver. + An + LDD + must + place + this + handle + in + + + the + ChanLibHandle + field + of + the + ChanEnt + struc + of + the + open + channel + structure + allocated + within + the + + + application's + data + segment. + In + the + case + of + A4EXIF.LDD, + this + structure + is + the + A4ExifEnt + struc + + + described + in + the + Appendix + to + this + document. + The + open + vector + of + a + device + driver + runs + in + the + context + of + + + the + process + that + has + called + p_open + to + open + a + serial + port + on + that + device + driver. + +

+
+
+

+ + The + OpenEnt + struc + consists + of + three + fields + , + OpenNamePtr, + OpenMode + and + OpenChan. + The + + + OpenNamefPtr + points + to + the + character + immediately + following + the + device + name + as + passed + in + the + + + p_open + call. + For + instance, + in + the + case + of + A4EXIF.LDD, + the + OpenNamePtr + would + point + to + the + colon + + + after + LED + in + the + name + "LED:". + The + OpenMode + field + contains + the + mode + for + opening + the + device + driver + +

+
+
+
+

+ + Revision + 1.00 + Page + 68 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + which + is + not + used + in + this + example. + The + OpenChan + field + holds + the + I/O + channel + handle + of + the + device + + + that + the + driver + is + required + to + 'attach' + to. + Attached + drivers + add + functionality + to, + or + replace, + a + service + + + provided + by + an + underlying + device + driver. + The + IntEnt + struc + pointed + to + by + BP + can + be + used + to + reload + the + + + various + segment + registers + if + their + contents + have + been + altered. + The + A4ExifEnt + struc + requires + further + + + elaboration. + It + consists + of + four + fields: + A4Exiflo, + A4ExifHandlerPtr, + A4ExifStatusPtr + and + + + A4ExifA1Ptr. + A4ExifHandlerPtr + contains + a + handle + to + the + driver's + WaitHandler, + A4ExifHandler. + + + This + is + the + routine + required + to + handle + the + completion + of + asynchronous + I/O + requests + and + is + described + in + + + more + detail + later + on + in + this + chapter. + Of + the + remaining + fields, + A4ExifStatusPtr + holds + the + location + of + the + + + completion + status + word + for + I/O + requests + and + A4ExifA1Ptr + is + a + user-defined + parameter. + These + two + + + values + are + passed + to + the + strategy + vector + through + the + RqEnt + structure. + A4Exiflo + is + itself + a + ChanEnt + + + struc + with + sub + fields + ChanSignature, + ChanNext + and + ChanLibHandle. + After + initialisation + of + this + + + structure, + [bx]. + A4Exiflo.ChanSignature + must + hold + 'TochanSignature’ + and + + + [bx].A4Exiflo.ChanLibHandle + holds + the + handle + to + the + device + driver + (stored + in + DX). + Both + of + these + + + values + are + again + required + by + the + strategy + vector. + The + [bx].A4Exiflo.ChanNext + field + is + used + by + + + attached + drivers + and + is + set + to + 0 + for + root + drivers + like + A4EXIF.LDD. + +

+
+
+

+ + The + code + in + an + open + vector + follows + a + similar + pattern + in + many + LDDs + and + is + presented + in + outline + form + + + below: + +

+
+
+

+ + e + Determine + the + channel + to + be + opened + using + the + pointer + to + the + device + name + held + in + + + [si]. + OpenNamePtr. + +

+ +

+ + e + If + OK, + disable + interrupts + and + invoke + the + OS + HwGet + Channel + call. + +

+ +

+ + e + If + OK, + then + set + A4ExifChannelOpen + flag + to + non-zero. + +

+ +

+ + e + In + order + to + poll + for + door-opening + and + closing, + it + is + necessary + to + open + a + "TcK:" + channel + at + this + + + stage + and + initialise + it + by + means + of + using + the + OS + IowithWait + service + to + call + the + TickInt + vector + + + on + each + system + tick. + +

+ +

+ + e + Re-enable + interrupts + and + set + up + the + calling + process + id + using + the + ProcId + service. + +

+ +

+ + e + Check + for + the + presence + of + the + required + hardware. + If + present + return + with + carry + clear. + +

+ +

+ + e + Allocate + space + in + calling + process' + heap + (i.e. + the + application + data + space) + to + contain + the + I/O + + + channel + control + block + (an + A4ExifEnt + struc + in + the + case + of + A4AEXIF.LDD) + and + set + its + base + + + address + to + BX + (thus + BX + holds + the + address + of + the + open + channel + control + block). + +

+ +

+ + e + If + OK, + install + the + device + driver + Wait + Handler + using + the + IoAddHandler + system + service. + A + + + Wait + Handler + is + required + only + if + there + are + any + asynchronous + I/O + requests + to + be + handled. + +

+ +

+ + e + If + OK, + initialise + the + fields + inside + the + I/O + channel + control + block + that + were + outlined + above. + +

+ +

+ + e + Invoke + IoRequestReset + system + service + to + handle + unexpected + termination + of + main + program + + + by + invoking + the + driver's + Reset + vector. + +

+ +

+ + e + Before + leaving + the + Open + vector, + if + the + call + succeeded, + BX + must + hold + the + open + channel + control + +

+
+
+

+ + block + handle. + + + A4ExifStrategy + + + IN: + BX + holds + the + allocated + channel + control + block + initialised + in + the + open + vector + +

+
+
+

+ + DX + contains + device + handle + of + the + device + driver + in + the + case + of + an + LDD + +

+ +

+ + SL + is + pointer + to + RqEnt + struc + +

+ +

+ + BP + is + pointer + to + IntEnt + struc + +

+ +

+ + DS, + ES + point + to + data + segment + of + application + making + the + I/O + function + request + +

+
+
+

+ + OUT: + If + successful + return + with + carry + clear. + Furthermore, + in + this + case, + if + the + strategy + + + vector + is + meant + to + complete + the + I/O + request + (as + is + the + case + with + IoClose + for + + + instance) + then + the + completion + status + should + be + written + back + to + RqStatusPtr + location + + + and + the + I/O + semaphore + signalled + by + calling + IoSignal. + If + the + I/O + request + is + not + completed + + + by + the + strategy + vector + (as + is + the + case + with + the + asynchronous + functions + IoFuncRead + + + and + IoFuncWrite) + then + PendingErr + should + be + written + back + to + the + location + pointed + to + by + +

+
+
+

+ + RqStatusPtr + and + the + I/O + semaphore + should + not + be + signalled. + +

+ +

+ + If + installation + unsuccessful, + return + with + carry + set + and + error + number + in + the + AL + + + register. + + + PRESERVE: + DS, + ES, + SS, + SP + and + BP + +

+
+
+

+ + Revision + 1.00 + Page + 69 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + When + an + application + makes + a + I/O + request + on + the + opened + device + driver + channel, + the + request + is + routed + + + to + this + vector + by + the + operating + system. + A + device + driver + defines + the + set + of + strategy + functions + that + it + + + supports + such + as + IoFuncSet, + IoFuncSense, + IoFuncWrite + and + IoFuncClose. + The + functions + of + a + + + device + driver + are + usually + dependent + on + its + purpose + and + there + is + no + requirement + to + support + any + + + particular + function. + The + ordering + of + these + functions + in + the + strategy + vector + table + is + defined + in + p_file.h + + + and + presented + in + A4EXIF.ASM. + +

+
+
+

+ + The + SI + register + contains + a + pointer + to + an + RqEnt + struc + which + consists + of + four + fields: + RqFunction, + + + RqStatusPtr, + RgA1Ptr + and + RqA2Ptr. + RqFunction + contains + the + function + number + passed + to + the + I/O + + + request + by + the + application. + In + the + device + driver + strategy + vector + code, + the + value + held + in + RqFunction + is + + + compared + against + the + supported + function + numbers + held + in + ToFuncClose, + IoFuncRead + etc. + If + the + + + function + number + is + not + one + of + those + supported + then + a + call + to + IoRoot + is + necessary + in + the + case + of + a + root + + + device + driver + such + as + A4EXIF.LDD. + toRoot + chains + the + I/O + request + through + to + the + operating + system + + + which + runs + some + default + code + to + handle + it. + RqStatusPtr + is + a + pointer + to + a + memory + location + in + the + + + application + data + space + which + holds + the + value + of + the + I/O + request's + completion + status + word. + While + a + + + request + is + outstanding, + this + value + is + set + to + PendingErr + and + only + when + it + completes + does + a + completion + + + code + get + written + to + this + location. + I/O + requests + can + complete + within + the + strategy + vector + or + later + after + an + + + interrupt. + Often + as + is + the + case + with + A4EXIF.LDD, + only + a + single + request + of + any + one + kind + can + be + + + outstanding + at + any + time + otherwise + the + application + is + panicked. + RqA1Ptr + and + RqA2Ptr + hold + the + values + + + of + two + parameters + that + are + passed + to + the + IoAsynchronous + EPOC + service. + Each + synchronous + strategy + + + function + has + a + similar + pattern + with + explicit + I/O + being + conducted + whilst + interrupts + are + disabled + and + a + + + completed + request + being + signalled + with + an + OS + ToSignal + call + prior + to + exit + from + the + function. + This + call + + + signals + to + the + OS + the + completion + of + the + particular + I/O + request + entailed + by + the + function + call. + The + + + situation + with + regard + to + the + one + asynchronous + strategy + function + is + somewhat + more + complicated + and + is + + + dealt + with + in + greater + detail + in + a + later + section. + +

+
+
+

+ + The + structure + of + the + strategy + vector + of + A4EXIF.ASM + is + outlined + below: + +

+
+
+

+ + e + Determine + the + strategy + function + number + using + [si].RqFunction + and + compare + with + the + below: + +

+ +

+ + e + JIOFUNCREAD: + Asynchronous + read + of + latches + U4 + and + U3. + Panic + if + [bx].A4ExifStatusPtr + != + + + 0. + Update + [bx].A4ExifA1Ptr + and + [bx].A4ExifStatusPtr + with + [si].RqA1Ptr + and + + + [si].RqStatusPtr + respectively + as + the + locations + to + be + accessed + on + receipt + of + interrupt. + Move + + + PendingErr + into + the + location + pointed + to + by + [bx].A4ExifStatusPtr + to + signal + that + the + request + is + + + awaiting + completion. + Allow + handler + to + be + enabled + through + the + IoEnableHandler + OS + call + + + and + exit + without + signalling + completion + of + the + request. + +

+ +

+ + e + IOFUNCWRITE: + Identical + behaviour + to + that + of + IoFUNCSET + which + it + calls. + +

+ +

+ + e + TIOFUNCCANCEL: + Used + to + cancel + any + pending + asynchronous + reads. + This + involves + + + disabling + the + wait + handler, + consuming + any + stray + signal + from + the + interrupt + routine + by + means + of + + + an + OS + IoWaitForSignal + call + and + then + storing + cancelErr + in + the + channel + I/O + request + status + + + word. + +

+ +

+ + e + IOFUNCCLOSE: + Close + down + the + TCK + channel + and + remove + handler. + Disable + interrupts + + + and + HwFreeChannel + setting + A4ExifPid + to + 0 + before + re-enabling + interrupts. + Invoke + + + IoRequestResetCancel + system + service + and + HeapFreeCell. + Signal + completion + of + I/O + + + request + by + calling + IoSignal + system + service. + +

+ +

+ + e + IOFUNCSENSE: + Reads + the + status + and + LED + bytes + from + latches + U4 + and + U3 + respectively + + + storing + the + results + at + the + addresses + pointed + to + by + RgA1Ptr + and + RqA2Ptr. + +

+ +

+ + e + IOFUNCSET: + Sets + latch + U5 + to + contain + the + value + pointed + to + by + the + sole + argument + in + the + + + call + to + P_FSENSE. + +

+ +

+ + e + If + not + supported + then + call + IoRoot + system + service. + +

+
+
+
+
+

+ + The + Non-Mandatory + LDD + Functions + +

+
+
+

+ + The + eight + functions + described + above + must + be + supported + by + all + device + driver. + Typical + Psion + LDDs + + + employ + at + least + two + other + LDD + functions. + The + first + of + these + is + a + pseudo-interrupt + routine + which + is + + + invoked + by + the + OS + on + each + system + tick. + In + A4EXIF.LDD, + this + function + is + represented + by + + + A4ExifTickInt + and + an + outline + of + its + purpose + was + presented + earlier + in + the + discussion + on + holding + and + +

+
+
+

+ + Revision + 1.00 + Page + 70 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + resuming + device + drivers. + As + was + indicated + then, + the + minimum + functionality + required + by + this + routine + + + is + to + poll + the + status + of + the + host + machine + doors + and + if + appropriate + call + the + driver's + Hold + and + Resume + + + vectors. + If + in + addition + the + LDD + is + intended + to + service + any + asynchronous + I/O + requests, + a + wait + handler + + + and + common + interrupt + service + routine + are + required. + With + A4EXIF.LDD, + these + two + additional + + + functions + are + represented + by + A4ExifHandler + and + ComInt + respectively. + The + former + function + + + constitutes + the + second + of + the + additional + LDD + functions + as + can + be + seen + by + examining + the + LibEnt + + + structure + for + A4EXIF.LDD. + The + latter + function + is + set + up + so + that + it + replaces + the + default + interrupt + + + service + routine + code + invoked + by + the + OS + on + the + receipt + of + hardware + interrupts + on + the + peripheral's + SIBO + + + channels. + A4ExifHandler + is + invoked + by + the + OS + every + time + the + I/O + semaphore + of + the + process + that + + + opened + the + channel + is + signalled + with + through + an + IoSignalByPidNoResched + call + indicating + that + an + + + interrupt + has + been + received + and + an + outstanding + I/O + request + has + completed. + The + function + of + the + wait + + + handler + is + to + deal + with + I/O + semaphore + signalling + and + to + update + the + appropriate + open + channel + control + + + block + field + variables. + The + common + interrupt + service + routine + code + in + ComInt + cannot + do + this + because + it + + + is + not + permitted + to + access + the + application + data + space. + This + in + turn + is + because + the + routine + runs + in + the + + + context + of + the + process + which + was + running + when + the + interrupt + occurred. + A4ExifTickInt, + the + wait + + + handler + and + the + common + interrupt + service + routine + for + A4EXIF.LDD + as + well + further + details + as + to + how + + + the + latter + two + interact + to + handle + asynchronous + I/O + requests + are + described + below. + +

+
+
+

+ + A4ExifTicklint + +

+
+
+

+ + As + was + explained + earlier + in + discussing + the + A4ExifHold + vector, + it + is + necessary + to + utilise + the + "TcK:" + + + system + tick + device + driver + in + order + to + handle + the + particular + case + of + invoking + a + hold + on + A4EXIF.LDD + + + when + the + host + machine + SSD + pack + doors + are + opened. + Such + an + action + automatically + causes + power + to + be + + + removed + from + any + peripherals. + The + TCK + driver + is + opened + via + an + OS + Toopen + call + in + the + A4ExifOpen + + + vector + which + returns + with + carry + clear + and + a + non-zero + handle + in + AX + if + successful. + In + this + case, + the + + + IoWithWait + function + is + called + to + request + an + synchronous + I/O + service + from + the + TCK + driver. + Prior + to + + + this + call, + the + service + number + requested + is + held + in + AL + and + the + I/O + handle + procured + from + the + previous + + + call + to + ToOpen + is + loaded + into + BX. + The + interrupt + number + of + the + tick + poll + routine, + A4ExifTickInt, + is + + + loaded + into + CX + so + that + as + its + parent + driver + is + invoked + on + each + system + tick, + the + OS + enters + this + vector. + + + The + reason + the + TickInt + routine + is + required + in + A4EXIF.LDD + is + solely + to + handle + the + problem + of + + + recognising + a + sudden + removal + of + power + from + the + host + machine. + The + OS + has + no + way + of + testing + for + this + + + condition + other + than + polling + its + global + 'Doorstatus' + variable + every + system + tick + and + taking + the + + + requisite + course + of + action. + As + such, + the + outline + of + the + code + for + the + tick + poll + routine + which + is + required + + + in + all + Psion + LDDs + can + be + presented + below. + This + outline + should + be + carefully + compared + with + the + + + structure + of + the + Hold + and + Resume + vectors + shown + earlier + in + order + to + see + how + they + interact: + +

+
+
+

+ + e + Check + the + current + status + of + doors + which + is + held + in + SI. + + + + If + DoorlsOpen + then + if + global + HoldFlag + is + zero, + force + a + call + to + A4ExifHold, + set + HoldFlag + to + 2 + + + and + return + far + + + else + do + a + far + ret + + + e + = + Else + if + DoorIsClosed + then + + + if + global + HoldFlag + is + 2, + force + a + call + to + A4ExifResume + and + return + far + + + else + do + a + far + ret + +

+
+
+

+ + It + should + be + emphasised + that + A4ExifTickInt + is + only + a + pseudo + interrupt + service + routine + in + that + it + does + + + not + preserve + the + status + of + the + registers + which + is + something + that + the + device + driver + writer + must + + + undertake + to + ensure + is + done + explicitly. + +

+
+
+

+ + The + handling + of + synchronous + and + asynchronous + I/O + +

+
+
+

+ + The + provision + of + synchronous + and + asynchronous + I/O + services + are + an + important + aspect + of + writing + any + + + device + driver. + In + the + case + of + Psion + drivers, + all + such + services + are + the + provided + through + the + Strategy + + + vector + which + is + typically + preceded + by + a + Strategy + Vector + Table + listing + the + complete + set + of + I/O + services + + + that + can + be + invoked + on + the + driver. + The + strategy + vector + table + for + A4EXIF.LDD + is + presented + below + to + + + provide + an + indication + as + to + the + kind + of + service + routines + that + can + be + written: + +

+
+
+

+ + StrategyVectorTable + label + word + +

+
+
+

+ + Revision + 1.00 + Page + 71 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + dw + offset + A4ExifDefault + 7StrategyPanic + +

+ +

+ + dw + offset + A4ExifRead + ;StrategyRead + (function + define + is + P_FREAD) + +

+ +

+ + dw + offset + A4ExifWrite + ;StrategyWrite + (function + define + is + P_FWRITE) + + + dw + offset + A4ExifClose + ;StrategyClose + (function + define + is + P_FCLOSE) + + + dw + offset + A4ExifCancel + ;StrategyCancel + (function + define + is + P_FCANCEL) + +

+ +

+ + dw + offset + A4ExifDefault + 7StrategyAttach + +

+ +

+ + dw + offset + A4ExifDefault + 7 + StrategyDetach + +

+ +

+ + dw + offset + A4ExifSet + ;StrategySet + (function + define + is + P_FSET) + +

+ +

+ + dw + offset + A4ExifSense + ;StrategySense + (function + define + is + P_FSENSE) + +

+
+
+

+ + Both + synchronous + and + asynchronous + I/O + requests + can + be + made + on + the + driver + through + means + of + the + + + PLIB + 'p_iow + (pcb, + <func>, + &A1, + &A2)' + call + where + pcb + is + the + open + channel + handle, + <func> + is + one + of + + + the + above + function + defines + and + Al + and + A2 + are + two + optional + parameters + required + for + the + servicing + of + + + the + request. + The + routing + of + an + I/O + request + to + the + correct + service + code + is + done + by + the + common + code + at + + + the + head + of + the + strategy + vector. + Each + time + this + vector + is + entered, + BX + holds + the + address + of + the + open + + + channel + control + block, + DX + the + device + handle + of + the + device + driver + and + SI + a + pointer + to + the + strategy + + + RqEnt + struc + used + by + the + OS + to + follow + the + course + of + the + I/O + request. + Using + this + information, + it + is + + + possible + to + access + all + the + relevant + flags + in + the + channel + StatusEnt + by + moving + [bx].A4ExifStatusEntPtr + + + into + DI. + This + leaves + us + with + the + open + channel + control + block + in + DS:BX + and + the + channel + StatusEnt + in + + + CS:DI. + +

+
+
+

+ + Armed + with + the + above + information, + it + is + possible + to + outline + the + general + pattern + of + both + synchronous + + + and + asynchronous + I/O + requests + at + an + OS + level. + The + case + of + synchronous + requests + is + particularly + + + straightforward + since + the + servicing + of + the + request + can + be + completed + entirely + within + the + relevant + + + strategy + vector + table + function. + It + should + be + emphasised + that + in + the + outline + presented + below, + disabling + + + and + re-enabling + of + interrupts + only + actually + has + to + be + done + around + any + I/O. + +

+
+
+

+ + SYNCHRONOUS + I/O + REQUEST + STRATEGY + VECTOR + TABLE + FUNCTION + +

+
+
+

+ + pushf + + + cli + ;Disable + interrupts + + + < + request + service + code + > + ;Relevant + synchr. + I/O + processing + +

+
+
+

+ + ExitWithCompletionStatusZero: + + + < + set + I/O + request + status + word + to + zero + > + +

+
+
+

+ + IoSignal + ;Signals + completion + of + I/O + to + OS + + + XOr + ax, + ax + +

+ +

+ + onl + ol + ;Tells + OS + that + strategy + exited + OK + + + popf + ;Re-enable + interrupts + +

+ +

+ + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + Note + that + in + the + above + outline, + the + single + ToSignal + call + is + made + after + completion + of + the + I/O + request + in + + + order + to + signal + this + fact + to + the + OS. + The + situation + is + somewhat + more + complicated + in + the + case + of + an + + + asynchronous + request + because + the + I/O + request + strategy + vector + table + function + has + to + interact + with + both + a + + + wait + handler + function + and + an + interrupt + service + routine. + Of + the + I/O + request + services + outlined + above + for + + + A4EXIF.LDD, + only + one, + namely + A4ExifRead, + is + asynchronous + and + it + serves + as + a + good + illustration + of + + + the + nature + of + programming + for + asynchroneity. + The + steps + taken + in + the + A4ExifRead + vector + are + outlined + + + below: + +

+
+
+

+ + e + = + Set + the + ChannelReadCompleted + flag + to + 0 + (stored + in + cs:[di]. + A4ExifChanReadCompleted) + + + e + If + the + address + of + the + I/O + request + status + word + is + non-zero + then + panic + (i.e. + there + is + an + + + outstanding + read + request) + +

+ +

+ + e + Update + the + open + channel + control + block + variables + using + the + RqEnt + struc + +

+ +

+ + e + Load + I/O + request + status + word + with + PendingErr + +

+ +

+ + e + Enable + the + wait + handler + by + using + the + To—EnableHandler + OS + service + + + The + read + request + is + now + in + a + pending + state + waiting + for + completion + via + receipt + of + a + hardware + interrupt. + + + When + such + an + interrupt + is + received, + the + OS + switches + into + the + appropriately + configured + common + + + interrupt + routine + ComInt. + Here, + the + channelReadCompleted + flag + is + set + to + indicate + to + the + handler + that + + + the + read + request + has + completed. + An + IoSignalByPidNoReSched + OS + service + call + is + also + made + to + + + indicate + to + the + OS + that + an + as + yet + unspecified + I/O + request + has + terminated. + This + signal + is + consumed + by + + + the + OS + which + means + that + at + this + stage, + an + IoSignal + for + completion + of + the + original + asynchronous + + + request + has + yet + to + be + made. + The + interrupt + service + routine + exits + after + sensing + the + status + and + LED + byte + + + values + from + the + ASIC4 + Example + Interface + Board + and + loading + the + appropriate + response + bytes + into + the + + + relevant + locations + in + the + device + driver + code + segment. + More + details + as + to + the + functionality + of + the + + + interrupt + service + routine + are + provided + in + the + section + on + interrupts. + The + OS + now + invokes + all + the + + + currently + active + wait + handlers + in + order + to + determine + which + application + is + responsible + for + consuming + +

+
+
+
+
+

+ + Revision + 1.00 + Page + 72 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + the + completed + read. + The + wait + handler + code + includes + the + all-important + IoSignal + call + that + indicates + to + + + the + OS + that + the + original + asynchronous + read + request + has + finally + been + accounted + for. + Receipt + of + this + + + signal + by + the + OS + constitutes + completion + of + the + request. + The + outline + code + for + the + A4EXIF.LDD + wait + + + handler + A4ExifHandler + is + outlined + in + the + next + section. + +

+
+
+

+ + A4ExifHandler + +

+
+
+

+ + A + WaitHandler + is + a + special + function + of + the + LDD + which + is + nominated + to + be + called + by + the + operating + + + system + every + time + the + I/O + semaphore + of + the + process + that + opened + the + channel + is + signalled. + It + will + only + + + actually + be + called + if + the + application + is + already + waiting + for + an + outstanding + I/O + request + to + complete + (1.e. + + + while + the + application + is + hung + in + p_iowait). + The + handler + function + is + the + means + by + which + hardware + + + interrupts + can + be + filtered + through + to + the + process + which + opened + the + I/O + channel + since + it + permits + the + + + rescheduling + of + processes. + +

+
+
+

+ + The + WaitHandler + is + invoked + in + the + open + vector + by + using + the + IoAddHandler + system + service. + When + an + + + application + makes + an + I/O + request, + the + I/O + semaphore + is + signalled + and + the + operating + system + calls + the + + + Wait + Handler + function + while + the + application + is + waiting + for + the + request + to + complete. + The + wait + handler + + + returns + with + CLC + if + no + outstanding + request + has + completed. + Otherwise + the + wait + handler + returns + with + + + STC + and + zero + in + AL. + The + wait + handler + can + include + within + it + synchronous + I/O + requests + to + cancel + or + + + use + up + signals + but + it + is + not + entered + recursively + (i.e. + re-enterently) + by + the + operating + system. + A + wait + + + handler + is + best + viewed + as + a + necessary + requirement + in + dealing + with + the + I/O + semaphore + signalling + which + + + cannot + entirely + be + addressed + in + the + appropriate + interrupt + service + routine + because + the + latter + is + not + able + + + to + access + the + open + channel's + control + block. + +

+
+
+

+ + Interrupts + and + Interrupt + Service + Routines + +

+
+
+

+ + The + SIBO + architecture + allows + for + eight + separate + hardware + interrupt + sources. + The + EPOC + operating + + + system + provides + a + GenSetRevector + service + to + enable + a + device + driver + to + install + an + interrupt + service + + + routine + for + any + of + these + eight + interrupt + sources. + When + an + interrupt + occurs, + the + operating + system + + + preserves + the + state + of + all + the + registers + before + calling + the + appropriately-installed + interrupt + service + + + routine. + As + a + result + of + this, + the + interrupt + service + routine + is + free + to + employ + any + register + it + sees + fit + to + use. + + + A + few + important + points + ought + to + be + made + concerning + the + code + within + an + interrupt + service + routine: + +

+
+
+

+ + e + On + an + 8086 + processor, + interrupts + cannot + be + nested + so + their + is + no + requirement + to + disable + + + interrupts + whilst + inside + the + interrupt + service + routine. + +

+ +

+ + e + Interrupt + service + routines + should + operate + as + fast + as + possible. + In + general, + operating + system + + + service + routines + are + tuned + to + be + of + less + than + Ims + duration. + +

+ +

+ + e + Interrupt + service + routines + run + in + the + context + of + the + process + that + was + running + at + the + time + of + the + + + interrupt + and + should + access + only + the + device + driver + data + space + which, + as + with + A4EXIF.LDD, + + + typically + resides + in + its + own + CS + space. + +

+ +

+ + e + Interrupt + service + routines + should + not + cause + a + process + rescheduling. + To + indicate + that + an + event + + + has + occurred + to + the + interrupted + process, + the + ToSignalByPidNoResched + system + service + + + should + be + called. + If + a + call + is + made + to + this + service, + the + interrupt + service + routine + should + exit + + + with + CLC + otherwise + it + returns + with + STC. + +

+
+
+

+ + The + interrupt + routines + called + require + knowledge + as + to + the + particular + hardware + SIBO + channel + being + + + used + by + the + driver + at + the + time + an + interrupt + occurs. + This + information + is + passed + through + to + the + + + GenSetRevector + function + in + StartInterrupts + by + loading + the + address + of + the + appropriate + Int + Vec + routine + + + from + the + A4ExifChannelIntVec + field + of + the + channel + StatusEnt + struc. + As + a + result, + when + an + interrupt + + + occurs, + the + currently + loaded + IntVec + routine + is + invoked. + All + the + Intvec + routines + reload + DI + with + the + + + appropriate + address + of + the + channel + StatusEnt + in + the + device + driver + code + segment + before + falling + through + + + to + the + common + interrupt + routine + service + code + held + in + ComInt. + +

+
+
+

+ + Comint + +

+
+
+

+ + Revision + 1.00 + Page + 73 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + common + interrupt + service + routine + code + resides + in + the + ComInt + vector. + The + structure + of + this + code + is + + + presented + below. + It + should + be + emphasised + that + no + data + in + the + application + data + space + and + hence + in + the + + + open + channel + control + block + can + be + accessed + from + ComInt. + This + explains + why + it + is + necessary + for + the + + + OS + to + invoke + a + wait + handler + to + clean + up + after + the + interrupt + service + routine + code + for + a + particular + + + asynchronous + I/O + request + has + been + run. + +

+
+
+

+ + e + Check + the + value + held + in + the + chanReadCompleted + flag + +

+ +

+ + e + If + this + value + is + 2 + then + we + do + not + have + an + asynchronous + read + completed + but + rather + the + + + interrupt + line + has + been + pulled + low + outside + of + an + asynchronous + I/O + request. + +

+ +

+ + e + If + this + value + is + 1 + then + we + have + an + asynchronous + I/O + request + completed + and + so + + + IoSignalByPidNoResched + must + be + invoked + to + signal + to + the + OS + that + a + read + has + completed. + +

+ +

+ + e + In + both + cases, + sense + the + status + and + LED + bytes + from + the + Example + Interface + hardware + and + load + + + these + values + in + the + device + driver's + code + segment + A4ExifStatusEnt + struc. + +

+ +

+ + e + There + are + four + possibilities + of + status + byte + corresponding + to + the + four + combinations + offered + by + + + the + two + input + switches, + S1 + and + S2. + These + are + used + to + output + one + of + four + separate + LED + bytes + + + to + the + LEDs. + +

+ +

+ + e + Awrite + to + AlNonSpecificEoi + register + (or + A9BNonSpecificEoiW + in + the + case + of + an + ASIC9 + + + machine) + must + be + done + prior + to + exiting + to + let + the + OS + know + that + the + installed + interrupt + service + + + routine + has + terminated. + +

+
+
+

+ + Other + important + local + device + driver + functions + +

+
+
+

+ + The + functions + presented + in + this + section + are + local + to + A4EXIF.LDD + and + perform + various + important + tasks + + + relating + to + the + peripheral + hardware + such + as + groping + the + hardware + and + setting + interrupts + running. + + + Since + these + tasks + have + to + be + undertaken + by + most + device + drivers, + the + relevant + functions + are + outlined + in + + + greater + detail. + +

+
+
+

+ + A4ExifCheckHardwarePresent + +

+
+
+

+ + Every + Psion + device + driver + has + a + characteristic + 'CheckHardwarePresent’ + or + 'GropeHardware" + function + + + that + usually + involves + checking + for + the + presence + of + the + required + peripheral + device + by + means + of + + + comparing + a + couple + of + ASIC4 + identification + bytes + returned + by + the + peripheral + in + response + to + a + SIBO + + + serial + protocol + identification + message + with + the + expected + answers. + The + specific + value + of + the + InfoByte + is + + + unimportant + as + long + asa + "test + al, + al" + call + is + made + which + will + always + return + a + non-zero + answer + if + + + ASIC4 + is + present. + In + that + case, + the + extended + info + byte + should + be + tested + for + against + what + is + expected + + + from + address + lines + A23-A27. + +

+
+
+

+ + Psion + Workabout/HC + machines + have + three + physical + serial + links + and + two + of + these + are + accessed + via + the + + + SSD + slots. + The + third + link + corresponds + to + the + serial + expansion + port. + In + order + for + a + driver + to + talk + to + a + + + peripheral + connected + to + this + port, + it + must + specifically + select + this + serial + link. + In + order + to + prevent + + + multiple + access + to + a + single + peripheral, + it + is + necessary + in + the + first + instance + to + check + whether + the + serial + + + channel + is + free + or + not. + A + call + to + the + operating + system + function + HwGet + Channel + with + the + appropriate + + + interrupt + mask + in + AL + returns + with + CLC + if + the + channel + was + captured + successfully. + Logically + this + call + + + should + be + made + in + the + Open + vector + but + since + it + can + only + sensibly + be + made + after + the + hardware + has + been + + + successfully + located + it + can + be + placed + at + the + end + of + the + GropeHardware + function. + A + corresponding + call + + + to + HwFreeChannel + must + be + made + when + closing + the + channel. + To + actually + select + a + channel + prior + to + + + communication + along + it, + a + call + to + HwSelectChannel + Is + necessary. + +

+
+
+

+ + A4ExifStartChannelRunning + +

+
+
+

+ + This + function + is + called + at + the + end + of + the + Open + vector + to + set + the + ASIC4 + Example + Interface + hardware + + + running. + It + can + also + be + invoked + by + the + Hold + vector. + The + function + first + checks + the + status + of + the + global + + + StatusEnt + ChannelRunning + flag. + If + this + flag + is + clear, + CheckHardware + is + called + to + determine + whether + + + the + hardware + is + still + connected + and + then + StartInterrupts + is + called + before + the + channelRunning + flag + is + +

+
+
+

+ + Revision + 1.00 + Page + 74 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + set + to + indicate + that + the + channel + hardware + has + been + started. + The + function + returns + with + CLC + on + + + successful + completion + or + with + STC + if + no + hardware + was + located. + +

+
+
+

+ + A4ExifStopChannelRunning + +

+
+
+

+ + This + function + simply + clears + the + channelRunning + flag + if + set + and + calls + StopInterrupts + unless + the + + + channel + already + has + its + ChannelRunning + flag + clear. + The + StopChannelRunning + function + will + be + called + + + by + Strategy + vector + when + trying + to + close + a + channel + and + can + also + be + called + by + the + Resume + vector. + +

+
+
+

+ + A4ExifStartinterrupts + +

+
+
+

+ + StartInterrupts + is + called + whenever + a + call + is + made + to + StartChannelRunning. + At + the + heart + of + the + + + function + is + a + call + to + the + OS + GenSetRevector + function + which + is + used + to + install + a + specified + interrupt + + + service + routine + in + the + place + of + the + default + routine + held + in + the + interrupt + vector + table. + GenSetRevector + + + is + called + with + the + interrupt + vector + number + of + the + service + to + be + replaced + in + AX + and + the + offset + and + code + + + segment + of + the + replacement + interrupt + vector + service + in + BX + and + CX + respectively. + BX + is + loaded + from + + + the + ChannelIntVec + field + of + the + channel + StatusEnt + which + holds + the + name + of + the + specific + interrupt + + + service + routine + code + (i.e. + IntVecO, + IntVec1 + etc.). + The + latter + functions + set + up + the + appropriate + channel- + + + specific + variables + before + falling + through + to + the + common + ComInt + routine. + The + channel + interrupt + mask + + + which + is + machine + and + channel + dependent + is + written + to + the + appropriate + register + on + the + host + ASIC. + In + + + the + case + of + ASIC9, + this + register + will + be + A9BInterruptMaskRW. + For + ASIC1 + it + will + be + + + AlInterruptMask. + +

+
+
+

+ + A4ExifStopInterrupts + +

+
+
+

+ + StopInterrupts + reinstalls + the + original + interrupt + service + routine + by + invoking + the + GenResetRevector + OS + + + system + service + and + signalling + the + interrupt + mask + to + the + corresponding + host + ASIC + register. + +

+
+
+

+ + Structures + and + Include + files + +

+
+
+

+ + Epocdef.inc + and + device + driver + strucs + +

+
+
+

+ + Epocdef.inc + is + an + important + header + file + that + contains + the + definitions + of + various + strucs + extensively + used + + + in + the + construction + of + device + drivers. + It + also + contains + the + definitions + of + all + the + OS + error + values + such + as + + + DeviceErr + and + NameErr + that + are + used + in + A4EXIF.LDD + to + communicate + an + error + to + the + application + + + via + AX. + Listed + below + and + overleaf + are + the + key + strucs + defined + in + Epocdef.inc + that + were + used + in + the + + + coding + of + A4EXIF.LDD. + +

+
+
+

+ + LibEnt + struc + Start + of + device + driver + + + LibSignature + dw + ? + +

+ +

+ + LibInfo + dw + 2 + +

+ +

+ + LibCount + dw + ? + +

+ +

+ + LibBase + dw + ? + +

+ +

+ + LibEnt + ends + +

+
+
+
+
+

+ + OpenEnt + struc + Pointed + to + by + SI + in + Open + vector + + + OpenNamePtr + dw + ? + +

+ +

+ + OpenMode + dw + ? + +

+ +

+ + OpenChan + dw + ? + +

+ +

+ + OpenEnt + ends + +

+ +

+ + ChanEnt + struc + Used + in + open + channel + control + block + + + ChanSignature + dw + 2 + +

+ +

+ + ChanNext + dw + ? + +

+ +

+ + ChanLibHandle + dw + ? + +

+ +

+ + ChanEnt + ends + +

+
+
+
+

+ + IntEnt + struc + Pointed + to + by + BP + in + Open + and + Strategy + vectors + + + IntFrame + dw + ? + +

+ +

+ + IntBP + dw + ? + +

+ +

+ + IntES + dw + 2 + +

+ +

+ + IntDS + dw + ? + +

+
+
+
+

+ + Revision + 1.00 + Page + 75 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + IntPC + dw + ? + + + IntCs + dw + 2 + + + IntFLAGS + dw + ? + +

+
+
+

+ + IntEnt + struc + ends + +

+
+
+
+

+ + RqEnt + struc + Pointed + to + by + SI + in + strategy + vector + + + RqFunction + dw + 2 + + + RqA1Ptr + dw + ? + + + RqA2Ptr + dw + ? + + + RqStatusPtr + dw + ? + +

+
+
+

+ + RqEnt + struc + ends + +

+
+
+

+ + A4EXIF + channel + strucs + +

+
+
+

+ + These + are + defined + at + the + start + of + the + A4EXIF.LDD + code + segment. + The + open + channel + control + block + is + + + held + in + a + structure + of + type + A4ExifEnt + and + is + allocated + space + from + the + heap + of + the + process + invoking + the + + + device + driver's + open + vector. + As + such, + it + cannot + be + accessed + from + the + Hold, + Resume + and + Reset + vectors + + + or + from + the + interrupt + service + routine, + ComInt. + The + channel + StatusEnt + holds + various + key + channel + + + related + flags. + Each + hardware + channel + has + its + own + StatusEnt + which + is + instantiated + in + a + header + in + the + + + device + driver + code + segment + following + the + LibEnt + structure. + This + header + block + is + usually + held + in + + + CS:DI + which + is + how + the + StatusEnt + variables + are + accessed. + The + structure + of + both + A4EXIF + channel + + + strucs + is + shown + below: + +

+
+
+
+

+ + A4ExifEnt + struc + OPEN + CHANNEL + CONTROL + BLOCK + + + A4xifIo + ChanEnt<> + +

+ +

+ + A4ExifHandlerPtr + dw + ? + Pointer + to + the + Wait + Handler + + + A4ExifStatus + dw + ? + Address + of + I/O + request + status + word + + + A4ExifAlPtr + dw + ? + Pointer + to + first + argument + +

+ +

+ + A4ExifA2Ptr + dw + 2. + Pointer + to + second + argument + + + A4ExifStatusEntPtr + dw + ? + Pointer + to + channel's + StatusEnt + + + A4ExifTickHandle + dw + ? + Handle + to + the + TCK + device + channel + +

+
+
+

+ + A4ExifEnt + ends + +

+
+
+
+
+
+

+ + A4ExifStatusEnt + struc + CHANNEL + STATUS_ENT + +

+ +

+ + A4ExifChannelPid + db + ? + Process + id + of + process + holding + + + channel + open + +

+ +

+ + A4ExifChannelOpen + db + 2 + Is + the + channel + open + or + not? + + + A4ExifChannelRunning + db + ? + Is + the + channel + running? + + + A4ExifChanReadCompleted + db + ? + Flag + used + to + indicate + to + handler + + + when + +

+ +

+ + A4ExifChanneliIntMask + db + ? + Contains + the + HW + channel + interrupt + mask + + + A4ExifChannelIntNum + db + ? + Holds + no. + of + interrupt + vector + to + be + + + replaced + +

+ +

+ + A4ExifChannelSelect + db + 2 + SIBO + channel + select + flag + + + A4ExifChannelDummy + db + 2 + Spare + +

+ +

+ + A4ExifChanneliIntVec + dw + ? + Holds + replacement + int. + vector + routine + + + name + +

+
+
+

+ + A4ExifStatusEnt + ends + +

+
+
+

+ + Ossibo.inc + and + Ospack.inc + +

+
+
+

+ + Ossibo.inc + is + an + important + header + file + that + contains + the + defines + for + all + the + ASIC2 + and + ASIC9 + register + + + addresses. + Ospack.inc + contains + similar + information + but + for + ASIC4. + +

+
+
+

+ + Revision + 1.00 + Page + 76 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 12. + AN + EXAMPLE + DEVICE + DRIVER + FOR + ASIC5: + + + SYS$AS5.PDD + +

+
+
+

+ + Introduction + +

+
+
+

+ + In + this + chapter, + the + functionality + and + code + structure + an + example + installable + physical + device + driver, + + + SYS$AS5.PDD, + is + presented + in + some + depth. + Circuit + details + of + the + corresponding + Psion + peripheral + for + + + this + driver, + the + Psion + 3-link, + were + outlined + in + chapter + 8. + SYS$AS5.PDD + enables + software + written + + + using + the + Psion + SDK + to + communicate + with + the + 3-link + peripheral + through + means + of + standard + PLIB + + + calls + such + as + ‘p_open' + and + 'p_write'. + This + peripheral + incorporates + an + ASICS + as + the + SIBO + serial + + + protocol + slave + device. + As + explained + earlier + in + chapter + 7, + ASICS + has + an + on-board + 16550 + UART + which + + + means + that + it + can + be + used + in + conjunction + with + the + standard + serial + LDD + provided + an + appropriate + PDD + + + is + loaded. + SYS$AS5 + is + a + PDD + intended + for + this + purpose + and + its + description + in + this + chapter + provides + a + + + clear + insight + into + the + generalised + structure + and + construction + of + physical + device + drivers + for + peripherals + + + based + around + the + SIBO + architecture. + +

+
+
+

+ + The + LDD-PDD + interface + +

+
+
+

+ + All + Psion + device + drivers + have + a + LibEnt + structure + at + the + head + of + their + code + segment + which + includes + a + + + vector + table + defining + the + functionality + of + the + driver. + In + the + case + of + SYS$AS5, + four + vectors + are + defined. + + + These + are: + Install, + Remove, + Open + and + Strategy. + The + structure + of + the + first + three + of + these + are + fixed + for + + + most + device + drivers + but + the + fourth + can + be + specified + in + any + way. + This + fourth + vector + defines + the + LDD- + + + PDD + interface + and + is + constructed + to + allow + the + two + drivers + to + best + communicate + with + each + other. + In + the + + + case + of + serial + PDDs, + the + approach + taken + is + modelled + on + the + LDD + strategy + vector + with + the + + + corresponding + strategy + vector + table + and + function + numbers. + This + is + a + logical + choice + but + it + is + important + + + to + emphasise + that + the + LDD-PDD + interface + is + completely + user-definable + and + that + the + approach + + + described + in + this + chapter + is + optional. + +

+
+
+

+ + The + key + feature + of + any + LDD-PDD + interface + is + that + the + LDD + must + have + no + explicit + concept + of + + + hardware. + In + the + case + of + the + serial + LDD, + for + instance, + it + knows + that + it + has + a + serial + port + that + it + can + read + + + data + bytes + from + or + write + data + bytes + to + but + it + is + ignorant + of + the + explicit + implementation + of + the + hardware + + + at + this + port. + That + aspect + is + handled + by + the + corresponding + PDD + which + handles + all + the + specifics + of + data + + + byte + I/O. + In + the + case + of + an + application + writing + a + buffer + to + the + serial + port + by + means + of + a + + + p_iow(P_FWRITE....) + call, + for + instance, + the + LDD + will + first + copy + the + data + in + the + application's + DS + into + + + a + local + CS + buffer. + It + will + then + call + the + PDD + to + indicate + that + it + intends + to + start + sending + data + bytes + when + + + the + PDD + is + ready + to + start + receiving. + When + the + PDD + is + ready + to + commence + sending + a + byte + out + of + the + + + serial + port, + it + calls + a + function + (TransmitByte) + in + the + LDD. + This + function + reads + the + next + byte + to + be + + + transmitted + from + its + local + buffer + and + hands + it + to + the + PDD. + The + PDD + duly + transmits + the + byte + and + again + + + calls + TransmitByte + until + all + the + bytes + are + completed. + The + LDD + then + sends + a + special + 'NothingToSend' + + + signal + to + the + PDD + which + indicates + that + transmission + is + finished. + The + LDD + also + sends + an + + + IoSignalByPidNoResched + which + causes + its + wait + handler + to + be + invoked + by + the + OS. + In + this + way, + the + + + IoSignal + that + signifies + completion + of + the + original + write + request + is + invoked + by + the + LDD. + Note + that + the + + + LDD + has + no + concept + of + interrupts, + merely + of + sending + a + byte + at + a + time + and + registering + completion + or + + + otherwise + of + I/O + requests. + Futhermore, + the + PDD + never + takes + the + initiative + from + the + LDD + and + merely + + + undertakes + one + function + at + a + time + before + returning + control + back + to + the + LDD. + The + LDD-PDD + interface + + + is + examined + in + greater + depth + later + in + this + chapter + when + the + structure + of + the + PDD + strategy + vector + is + + + presented. + +

+
+
+

+ + Revision + 1.00 + Page + 77 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Code + Structure + +

+
+
+

+ + Device + Names + and + Loading + SYS$AS5.PDD + +

+
+
+

+ + SYS$AS5.PDD + is + loaded + into + the + RAM + of + the + host + machine + by + means + of + the + following + PLIB + call + in + + + the + application + code: + +

+
+
+

+ + p_loadldd("SYSS$AS5.PDD") + ; + +

+
+
+

+ + The + name + of + a + device + driver + is + the + mechanism + by + which + an + application + can + obtain + a + channel + to + that + + + device + driver. + LDDs + all + have + three + character + names + followed + by + a + period, + a + further + three + characters + + + and + acolon. + The + first + three + characters + of + a + PDD + name + are + the + name + of + the + LDD + to + which + the + PDD + + + belongs. + The + second + set + of + three + characters + uniquely + identify + the + PDD. + The + device + name + is + required + + + to + uniquely + identify + the + LDD + to + the + OS + when + attempting + to + open + a + channel + on + it. + The + SYS$AS5 + PDD + + + belongs + to + the + "TTY:" + LDD. + Its + name + as + defined + in + its + LibEnt + structure + is + 'TTY.SR5'. + Thus + a + + + channel + with + its + handle + in + pcb + may + be + obtained + on + it + at + the + application + level + by + means + of + the + + + following + call: + +

+
+
+

+ + p_open + (&pcb, + "TTY.SR5:A",-1); + +

+
+
+

+ + The + qualifier + after + the + colon + indicates + that + the + driver + can + support + more + than + one + channel. + Channels + + + are + allocated + a + single + character + sequentially + from + the + character + 'A' + up + to + the + character + 'C'. + The + + + number + of + channels + that + can + be + supported + in + this + way + is + dependent + upon + the + host + hardware. + Only + one + + + expansion + port + can + be + opened + on + the + S3a + for + instance + whereas + three + are + possible + on + the + Workabout + + + and + HC. + EPOC + uses + the + driver + name + in + the + p_open + call + to + invoke + the + ToOpen + system + service + which + in + + + turn + invokes + the + Open + vector + on + the + associated + device + driver. + +

+
+
+

+ + The + Single + Code + Segment + and + Data + Storage + +

+
+
+

+ + All + data + associated + with + a + physical + device + driver + must + be + stored + in + its + code + segment. + Examples + of + + + such + data + are + the + channel + interrupt + masks + and + numbers + that + have + to + be + visible + to + all + processes + that + + + may + be + using + SYS$AS5.PDD. + +

+
+
+

+ + The + overall + structure + of + the + code + segment + is + typical + of + Psion + physical + device + drivers. + The + segment + + + begins + with + a + CodeSeg + directive + followed + by + the + LibEnt + structure + which + defines + all + the + device + driver + + + functions. + Before + entering + the + code + for + these + functions, + all + global + variables + are + declared + in + the + + + internal + (CS) + data + space. + Following + the + code + for + the + LibEnt + functions + comes + the + code + for + all + the + local + + + driver + functions, + After + these + are + the + EndCodeSeg + and + end + OsAs5PDD + directives. + +

+
+
+

+ + The + Channel + struct + and + A5Ent + struct + +

+
+
+

+ + At + the + head + of + the + driver's + assembler + source + file, + SYS$AS5.ASM, + various + constants, + compiler + defines + + + and + types + are + listed. + It + is + here + that + templates + are + declared + for + the + global + structures + that + hold + the + key + + + driver + variables. + in + the + case + of + SYS$AS5, + one + main + structure, + the + Sr5ChannelStruct, + is + employed + to + + + hold + the + various + important + flags + and + masks + that + relate + to + the + status + of + each + separate + channel + on + the + + + driver. + This + structure + is + termed + the + Channel + struct + and + its + fields + are + filled + in + during + the + course + of + + + running + the + PDD + install + and + open + vectors. + Whenever + the + serial + LDD + invokes + one + of + the + PDD + + + functions, + the + application + must + ensure + that + CS + holds + the + address + of + the + PDD's + code + segment + which + is + + + where + the + Channel + struc + resides. + The + channel's + Channel + struct + is + usually + accessed + through + DI + or + BX + + + depending + on + preference. + Its + layout + is + presented + later + in + this + chapter + along + with + other + important + + + defines + that + were + used + in + the + construction + of + SYS$AS5.PDD. + +

+
+
+

+ + SIBO + hardware + and + conditional + compilation + +

+
+
+

+ + As + indicated + previously, + the + number + of + expansion + channels + supported + by + a + host + Psion + machine + is + + + dependent + on + the + hardware. + In + the + case + of + the + S3a, + only + one + SIBO + channel + can + legitimately + be + + + opened + corresponding + to + expansion + port + A. + With + the + HC + and + the + Workabout, + it + is + possible + to + open + up + + + to + three + separate + SIBO + channels + on + ports + A + through + to + C. + SYS$AS5.PDD + is + constructed + to + enable + it + + + to + run + on + any + host + Psion + platform. + In + its + internal + data + space, + the + various + hardware + options + for + the + + + SIBO + channels, + interrupt + masks + and + interrupt + numbers + are + coded + in + a + large + if + statement + thereby + +

+
+
+

+ + Revision + 1.00 + Page + 78 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + permitting + conditional + compilation + of + the + driver + for + the + required + host + hardware. + The + only + change + that + + + need + be + made + in + adapting + it + for + use + on + another + Psion + machine + is + the + alteration + of + the + build + flag + at + the + + + start + of + the + code + segment. + This + flag + indicates + to + the + compiler + which + SIBO + machine + flags + as + well + as + + + other + variables + should + be + set. + The + conditional + compilation + table + outlined + here + is + worthy + of + some + study + + + because + it + encapsulates + all + the + information + regarding + masks + and + SIBO + hardware + channels + required + by + + + the + prospective + developer + interested + in + constructing + a + multi-platform + peripheral + and + accompanying + + + PDD. + +

+
+
+

+ + The + PDD + Functions + +

+
+
+

+ + OsAS5install + + + IN: + Nothing + + + OUT: + If + successful, + return + with + carry + clear + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + +

+
+
+

+ + PRESERVE: + SS, + SP, + BP + +

+
+
+

+ + The + install + vector + is + called + by + the + parent + LDD + whenever + the + PDD + is + required + to + be + loaded. + It + cannot + + + be + called + directly + be + an + application + only + indirectly + through + the + LDD + in + its + Install + vector. + The + install + + + vector + is + called + in + the + context + of + the + OS + with + DS + and + ES + in + an + unknown + state. + Memory + will + not + be + + + moved + while + in + this + function + so + the + normal + rules + governing + the + use + of + ES + and + DS + may + be + ignored. + +

+
+
+

+ + OsAS5Remove + +

+
+
+

+ + IN: + Nothing + + + OUT: + If + successful, + return + with + carry + clear + +

+ +

+ + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + +

+
+
+

+ + PRESERVE: + SS, + SP, + BP + +

+
+
+

+ + The + remove + vector + is + called + by + the + parent + LDD + whenever + the + PDD + is + required + to + be + unloaded. + It + + + cannot + be + called + directly + by + an + application + and + only + indirectly + through + the + LDD + in + its + Remove + vector. + + + The + remove + vector + is + called + in + the + context + of + the + OS + with + DS + and + ES + in + an + unknown + state. + Memory + + + will + not + be + moved + while + in + this + function + so + the + normal + rules + governing + the + use + of + ES + and + DS + may + be + + + ignored. + +

+
+
+

+ + OsAS5Open + + + IN: + SS:SI + points + to + the + OpenEnt + structure + + + ES, + DS + point + to + the + DS + of + the + application + process. + + + OUT: + If + successful, + return + with + carry + clear + and + control + block + in + BX + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + +

+
+
+

+ + PRESERVE: + SS, + SP, + BP + +

+
+
+

+ + The + open + vector + is + called + by + the + parent + LDD + whenever + a + channel + to + the + PDD + is + required + to + be + opened. + + + It + cannot + be + called + directly + by + an + application + and + is + typically + invoked + in + the + higher + level + LDD + Open + + + vector + code + by + means + of + the + DevOpenPpp + OS + system + call. + On + invoking + the + open + vector, + SI + points + to + + + the + OpenEnt + structure + which + contains + three + fields, + namely + OpenNamePtr, + OpenMode + and + OpenChan. + + + The + OpenNamePtr + points + to + the + qualifier + immediately + following + the + device + name + in + the + call + to + + + p_open. + In + the + case + of + SYS$ASS5, + for + instance, + the + OpenNamePtr + would + point + to + the + 'a' + in + the + name + + + "TTY.SR5:A". + This + corresponds + to + an + attempt + to + open + the + first + hardware + SIBO + channel + on + the + host + + + machine + which + if + successful + will + leave + the + address + of + the + ChanO + Sr5ChannelStruct + in + BX. + The + PDD + + + open + vector + finally + includes + a + call + to + the + OS + service + HwGet + Channel + to + obtain + the + requested + SIBO + + + channel. + +

+
+
+

+ + Revision + 1.00 + Page + 79 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + The + order + of + action + undertaken + by + the + parent + serial + LDD's + open + vector + is + generally + fairly + complicated + + + and + includes + various + calls + to + the + PDD + strategy + vector + routines. + The + situation + is + outlined + overleaf: + +

+
+
+

+ + e + Ensure + that + the + LDD + itself + can + be + opened. + +

+ +

+ + e + Call + the + PDD + open + vector + using + the + OS + DevOpenPDD + OS + call. + +

+ +

+ + e + = + If + successful, + call + the + OS + service + DevGet + PDDAddress + which + returns + the + full + segment:offset + + + address + of + the + PDD's + fourth + strategy + vector + in + BX:AX. + These + values + are + loaded + into + the + + + dword + Channel + struct + field + SerialPDDEntry. + +

+ +

+ + e + Invoke + the + PDD + strategy + Open + and + SetHandlerCS + functions + to + set + up + offsets + and + segments + + + respectively + to + locations + in + the + LDD + above. + +

+ +

+ + e + Invoke + strategy + Set + to + initialise + the + transmission + baud + rate. + +

+ +

+ + e + Invoke + strategy + Start + to + set-up + and + then + enable + interrupts + +

+
+
+

+ + Once + the + DevGetPDDAddress + service + has + been + used + to + load + the + LDD's + SerialPDDEntry + field, + it + may + + + be + used + to + load + in + the + address + of + any + of + the + PDD's + strategy + functions. + The + DevGetPDDAddress + OS + + + call + invoked + in + the + LDD + open + vector + must + also + be + invoked + in + the + LDD + resume + vector + code + since + + + memory + may + have + been + moved + while + the + LDD + was + held. + The + PDD + is + ignorant + of + such + activity + since + + + the + serial + LDD + is + responsible + for + handling + all + holds + and + resumes. + +

+
+
+

+ + OsAS5Strategy + + + IN: + AX + holds + the + vector + number + + + ES, + DS + point + to + the + DS + of + the + application + process. + + + OUT: + If + successful, + return + with + carry + clear + and + control + block + in + BX + + + If + installation + unsuccessful, + return + with + the + carry + flag + set + and + error + number + in + the + + + AL + register + +

+
+
+

+ + PRESERVE: + SS, + SP, + BP + +

+
+
+

+ + The + strategy + functions + are + invoked + directly + from + the + various + serial + LDD + vectors + to + provide + hardware- + + + specific + services. + For + instance, + in + order + to + set + up + the + baud + rate, + it + is + necessary + to + invoke + strategy + Set. + + + The + strategy + vector + table + for + OsAS5Strategy + is + presented + below + and + then + the + functionality + of + the + + + important + component + vectors + is + outlined: + +

+
+
+

+ + AS5StrategyJumpTable + label + word + +

+
+
+
+
+

+ + dw + offset + AS5Open + ;Load + Handler + offsets + +

+ +

+ + dw + offset + AS5Close + ;Close + the + channel + +

+ +

+ + dw + offset + AS5Start + ;Start + the + channel + +

+ +

+ + dw + offset + AS5Stop + ;Stop + the + channel + +

+ +

+ + dw + offset + AS5Set + ;Set + the + channel + status + +

+ +

+ + dw + offset + AS5Sense + ,;Return + channel + status + + + dw + offset + AS5Control + ;Drive + the + handshaking + lines + + + dw + offset + ASS5Enquire + ;Returns + baud + rate + +

+ +

+ + dw + offset + AS5Enable + ;Begin + sending + output + + + dw + offset + ASS5SetHandlercCs + ;Load + Handler + segments + +

+
+
+

+ + Open + and + SetHandlerCS + go + together + and + are + invoked + from + the + LDD + open + and + resume + vector + code. + + + Both + are + required + to + let + the + PDD + know + the + address + at + which + its + LDD + resides. + The + four + full + addresses + + + passed + through + to + Open + and + SetHandlerCS + are + of + the + LDD's + control + block + and + the + LDD + StatusInt, + + + RecvInt + and + XmitInt + vectors. + Close + is + called + in + order + to + close + an + opened + channel. + Start + and + Stop + are + + + used + to + enable/disable + interrupts + and + are + invoked + from + the + LDD + open, + hold/resume + and + set + vectors. + + + The + order + of + action + in + the + PDD + Start + vector + is + as + follows: + + + e + Initialise + PDD + variables + + + e + Check + H/W + present + + + e + Start + the + hardware + running. + In + the + case + of + SYS$ASS5, + part + of + this + process + involves + starting + a + + + continuous + clock + from + the + host + controller + ASIC + in + order + to + trigger + the + UART + clock + on + the + 3- + + + link's + ASICS. + In + addition + to + this + clock, + the + RTS + and + DTR + lines + must + be + driven + low. + + + e + = + Start + interrupts. + + + The + common + interrupt + service + routine + code + resides + in + the + PDD + ComInt + function. + This + code + is + patched + + + into + the + interrupt + vector + via + the + GenSetRevector + system + service. + The + interrupt + mask + contains + bits + to + +

+
+
+

+ + Revision + 1.00 + Page + 80 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + generate + the + following + interrupts: + Receive + character, + Ready + to + send + next + character + and + Modem + line + + + change + character. + In + SYS$ASS, + all + three + interrupts + are + enabled + in + Start. + It + is + important + to + realise + + + that + after + masking + in + these + bits, + a + Ready + to + send + next + character + interrupt + is + almost + immediately + + + generated + so + the + corresponding + ComInt + code + must + be + able + to + handle + this. + +

+
+
+

+ + CheckHardwarePresent + +

+
+
+

+ + This + non-mandatory + function + is + called + from + the + Open + vector + and + follows + the + lines + of + previously + + + discussed + CheckHardwarePresent + code. + After + checking + for + an + ASICS + at + the + end + of + the + serial + link, + the + + + function + returns + with + the + carry + flag + clear + if + one + is + found. + If + a + non-zero + info + byte + is + returned + with + an + + + Asic5Normalld, + then + various + other + IDs + are + tried + (Asic4Id, + Asic8Id, + Asic5PackId) + before + returning + + + with + the + carry + flag + set. + +

+
+
+

+ + CheckHardwarePresentFromStart + +

+
+
+

+ + This + is + a + non-mandatory + function + called + only + from + the + PDD + Start + vector. + After + checking + that + we + have + + + an + ASICS + at + the + end + of + the + SIBO + channel, + the + function + sets + the + S_PERIPHERALMODE + bit + of + the + + + A5PortBMode + register. + This + then + puts + ASICS + into + UART + mode. + +

+
+
+

+ + Comint + +

+
+
+

+ + The + common + interrupt + routine + code + is + entered + with + DI + holding + the + address + of + the + appropriate + channel + + + struct. + ASICS's + control + register + (A5CtrlReg) + is + read + first + to + determine + which + interrupt + has + occurred. + + + The + byte + read + from + the + register + is + compared + against + S_ + MDINT + (Modem + lines + interrupt), + S_RXINT + + + (Receive + character + interrupt) + and + S_TXINT + (Transmit + interrupt). + The + code + to + handle + each + of + these + + + cases + is + then + entered + prior + to + returning + control + back + to + the + LDD + via + the + Channel + struct + fields + that + were + + + filled + by + a + previous + LDD + calls + to + the + PDD + strategy + Open + and + SetHandlersCS + vectors. + The + LDD + has + + + no + knowledge + of + interrupts + and + the + purpose + of + ComInt + is + therefore + to + hide + the + hardware + details + of + + + handling + interrupts + from + the + LDD. + Once + the + interrupt + has + been + serviced, + a + write + is + made + to + + + A9BNonSpecificEoiW + in + the + case + of + ASIC9 + or + AlNonSpecificEoi + for + an + ASIC1/ASIC2 + based + system + + + to + indicate + to + the + OS + that + the + interrupt + has + been + serviced. + +

+
+
+

+ + Revision + 1.00 + Page + 81 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 13. + DEBUGGING + AND + TESTING + DEVICE + DRIVERS + +

+
+
+

+ + Introduction + +

+
+
+

+ + This + chapter + will + detail + the + techniques + that + can + be + used + by + the + developer + to + first + debug + and + then + test + + + device + drivers. + The + emphasis + will + be + on + the + software + methods + such + as: + + + + Good + use + of + variables. + e.g. + Starting + all + the + fields + in + the + CS + Channel + Status + structure + with + + + CS. + + + e + Debugging + by + eye. + Even + more + important + with + regard + to + device + drivers. + + + e + Using + SDBG. + The + pitfalls + and + benefits. + Working + your + way + around + the + strategy + vector + calls + + + with + SDBG. + + + e + Construction + of + C + test + harness + programs. + Catching + all + the + error + flags + that + can + be + returned + by + + + device + driver + functions. + + + e + The + comprehensive + memory + check + program + mem.c. + +

+
+
+

+ + Debugging + Techniques + +

+
+
+

+ + A + Psion + device + driver + is + written + in + 8086 + assembler + as + an + asm + file + and + built + using + the + Borland + Turbo + + + Assembler + compiler. + The + subsequent + debugging + process + centres + around + the + construction + of + an + + + appropriate + PLIB + test + harness. + The + purpose + of + a + test + harness + is + to + check + a + number + of + the + device + driver + + + vectors + to + ensure + that + they + do + not + return + errors + or + cause + panics. + The + majority + of + PLIB + calls + that + would + + + be + used + in + this + context + return + a + negative + integer + that + is + used + to + ascertain + the + cause + of + the + problem + in + + + the + corresponding + device + driver + vector. + The + code + below, + for + instance, + would + be + used + to + test + the + install, + + + open, + strategy + close + and + remove + vectors + of + the + A4EXIF + LDD: + +

+
+
+

+ + GLDEF_C + VOID + main(VOID) + + + { + +

+ +

+ + VOID + *serH; + +

+ +

+ + INT + ret; + +

+
+
+

+ + if + ((ret=p_loadldd("A4EXIF.LDD") + ) + <0) + + + { + + + p_printf + ("Error + %d + on + p_loadldd", + ret); + + + p_getch + () + + + p_exit + (0) + + + } + +

+
+
+
+

+ + else + + + p_printf + ("Successfully + loaded + A4EXIF.LDD"); + +

+ +

+ + if + ((ret=p_open(&serH, + "LED:",-1) + ) + <0) + + + { + + + p_printf + ("Error + %d + on + p_open", + ret); + + + p_getch(); + +

+
+
+
+

+ + x + +

+
+
+

+ + else + +

+
+
+
+

+ + p_printf + ("Successfully + opened + LED: + channel"); + + + p_close(serH) + ; + + + p_printf + ("Successfully + closed + LED: + channel"); + + + } + +

+ +

+ + p_devdel + ("LED",E_LDD) + ; + +

+ +

+ + p_getch(); + +

+ +

+ + p_exit + (0); + +

+ +

+ + } + +

+
+
+
+
+
+
+

+ + Revision + 1.00 + Page + 82 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + If + as + often + happens + at + this + stage, + a + bug + in + the + device + driver + causes + the + test + harness + program + to + crash, + it + + + is + necessary + to + debug + the + driver + code + either + by + eye + or + using + SDBG. + Debugging + by + eye + should + always + + + be + the + first + resort, + however, + whenever + the + bug + can + be + readily + pinned + down + to + a + particular + vector. + + + Things + to + look + out + for + include: + +

+
+
+

+ + e + ~=An + unbalanced + stack: + Check + that + the + number + of + 'pushes' + equals + the + number + of + 'pops' + in + the + + + appropriate + vector + code. + +

+ +

+ + e + Addressing + the + wrong + location: + Ensure + that + all + the + Channel + status + fields + (stored + in + CS) + are + + + offset + using + the + correct + register + and + that + that + register + holds + the + right + value. + The + following + + + code + for + instance + requires + DI + to + hold + the + address + of + the + channel + status + struct + prior + to + +

+
+
+

+ + invocation: + + + mov + al, + cs: + [di].ChannelOpenFlag + +

+
+
+

+ + e + Consistency: + With + regard + to + the + last + point, + it + is + important + to + be + consistent + if + possible + and + try + + + and + use + the + same + register + (i.e. + DI) + to + hold + the + channel + status + structure. + A + different + one + + + (usually + BX) + should + also + be + used + to + hold + the + address + of + the + open + channel + control + block. + +

+ +

+ + e + Trashing + BX + and + DI: + If + these + registers + are + used + in + the + vector + code + for + anything + other + than + + + addressing, + check + that + their + value + is + not + being + trashed + by + the + operation. + +

+
+
+

+ + Debugging + using + SDBG + is + an + extension + of + debugging + by + eye. + The + SIBO + debugger + allows + the + + + programmer + to + trace + through + the + driver's + source + code + instruction + by + instruction + and + observe + the + + + contents + of + the + CPU + registers + in + the + process. + In + this + way + it + is + possible + to + discover + any + discrepancies + in + + + terms + of + the + values + stored + in + the + various + registers. + Furthermore, + tracing + with + SDBG + will + enable + the + + + user + to + pinpoint + the + source + of + panics. + The + first + objective + of + the + device + driver + debugging + process + + + should + be + to + get + the + code + outlined + on + the + previous + page + to + work + OK. + +

+
+
+

+ + Further + Testing + Strategies + +

+
+
+

+ + Once + installing, + opening, + closing + and + unloading + are + dealt + with, + a + test + harness + can + be + expanded + to + + + include + p_iow + or + p_ioc + calls + which + map + onto + the + LDD's + strategy + vector. + At + this + stage, + SDBG + is + + + particularly + useful + for + testing + purposes + as + breakpoints + can + be + set + and + jumped + to. + In + this + way + for + any + + + p_ioc(serH, + <func>, + &serStat, + &Al,&A2) + call, + the + contents + of + the + status + word, + serStat, + and + the + A1 + + + and + a2 + parameters + can + be + tracked + through + the + LDD's + strategy + vector. + The + value + held + by + the + status + + + word + at + the + end + of + a + particular + strategy + call + is + the + value + returned + by + the + corresponding + PLIB + + + p_iow/p_ioc + call. + Thus + negative + errors + within + the + strategy + code + can + be + picked + up + by + the + test + harness. + + + A + good + test + harness + should + be + able + to + catch + all + the + possible + errors + and + at + the + least + invoke + p_printf + to + + + let + the + user + know + when + one + of + them + is + returned. + The + file + p_file.h + contains + a + list + of + all + the + current + + + return + error + values + and + the + corresponding + PLIB + level + error + name. + The + entry + for + PendingErr, + for + + + instance + is + as + follows: + +

+
+
+
+

+ + #define + PendingErr + (-46) + + + #define + E_FILE_PENDING + PendingErr + +

+
+
+
+
+

+ + In + order + to + induce + the + return + of + these + error + values + it + is + necessary + to + extend + the + basic + test + harness + + + outline + to + allow + the + user + to + undertake + various + pathological + actions. + For + instance, + the + harness + may + + + include + code + that + tries + to + open + a + channel + twice + which + should + result + in + InUseErr + being + invoked. + By + + + such + means + it + is + possible + to + ensure + that + a + driver + is + not + only + operating + as + it + should + in + normal + + + circumstances + but + returning + the + correct + error + value + when + relevant. + +

+
+
+

+ + Memory + Testing + +

+
+
+

+ + The + final + process + that + should + be + undertaken + to + fully + test + a + device + driver + consists + of + the + construction + of + + + an + appropriate + memory + test + harness. + Three + functions + are + presented + on + the + next + two + pages + which + + + provide + the + core + of + such + a + comprehensive + memory + test + program. + The + first + function, + CheckMemory, + + + uses + the + PLIB + routines + p_allspce + and + p_sgfree + to + print + out + the + current + free + bytes + on + the + heap + and + the + + + number + of + free + segments + in + the + host + RAM. + This + function + can + be + invoked + after + installing, + opening, + + + closing + or + removing + a + device + driver + to + ensure + that + memory + is + not + going + to + ‘alloc + heaven’. + The + + + GobbleMemory + function + is + first + used + to + determine + the + amount + of + free + memory + available + in + segments + +

+
+
+

+ + Revision + 1.00 + Page + 83 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + through + calling + p_sgfree. + The + PLIB + p_sgcreate + function + is + then + invoked + to + create + a + new + segment, + + + "Test", + that + consists + of + all + of + this + free + memory. + Finally, + the + p_sgcopyto + PLIB + function + is + called + to + fill + + + "Test" + with + Ox55's. + By + using + up + all + free + memory + in + this + way, + it + is + possible + to + use + segment + "Test" + to + + + determine + whether + a + particular + driver + vector + is + writing + to + the + wrong + location. + TestGobble, + presented + + + overleaf, + is + the + third + function + outlined. + It + uses + the + PLIB + function + p_sgcopyfr + to + check + the + values + of + + + the + bytes + in + the + segment + "Test". + If + any + of + the + 0x55's + have + been + overwritten + then + we + know + that + we + + + have + a + problem. + These + three + functions + should + be + incorporated + within + the + standard + test + harness + + + functions + already + presented + in + this + chapter. + In + this + way, + it + is + possible + to + generate + a + powerful + generic + + + test + program + that + can + be + used + as + the + basis + for + all + device + driver + testing. + +

+
+
+

+ + LOCAL_C + VOID + CheckMemory + (VOID) + + + { + +

+ +

+ + VOID + *Heap; + +

+ +

+ + INT + fbytes; + +

+
+
+

+ + fbytes=p_allspc + (&Heap) + ; + +

+ +

+ + p_printf + ("Free + Heap + Memory + =>%x + bytes", + fbytes) + ; + + + p_printf + ("Free + Segments + =>%d",p_sgfree()); + + + p_getch(); + +

+ +

+ + } + +

+
+
+

+ + [KR + KR + KK + KR + KK + KI + KK + IK + I + I + I + I + / + +

+
+
+

+ + LOCAL_C + VOID + GobbleMemory + (VOID) + + + { + + + UINT + nParas, + segSize; + + + INT + 3; + +

+ +

+ + LONG + pos,i; + +

+ +

+ + UBYTE + buf + [256]; + +

+
+
+
+
+

+ + p_printf(" + System + RAM + size + = + %d",p_getram()); + + + p_printf + ("Internal + RAM + usage + = + %d",p_sgramdisk())j; + + + nParas=p_sgfree()j; + + + p_printf + ("Amount + of + free + RAM + = + %d",nParas); + + + segH=p_sgcreate("Test",nParas, + E_SEGMENT_HIGH) + ; + + + if + (segH) + +

+ +

+ + p_printf + ("Created + segment + \"test\""); + +

+
+
+
+
+
+

+ + else + + + { + + + p_printf + ("Error + in + creating + segment"); + + + p_getch(); + + + p_exit + (0); + + + } + + + segSize=p_sgsize(segH) + ; + + + p_printf("Size + of + segment + is + %d",segSize); + + + p_printf("In + 16-byte + paragraphs"); + + + p_sleep(5L); + + + for + (j=0; + j<16; + j++) + + + buf + [j]=0x55; + +

+
+
+
+

+ + i=0; + + + while + (i<segSize) + + + { + + + pos=i*16; + + + if + (p_sgcopyto(segH, + pos, + &buf + [0],16) + <0) + + + { + + + p_printf + ("Failed + on + p_sgcopy"); + + + p_printf + ("%d",i); + + + p_getch(); + + + } + + + i++; + + + } + + + p_printf("Test + segment + full + of + 0x55s"); + + + p_getch(); + + + } + +

+
+
+

+ + [RRR + KK + KK + KK + KKK + IK + I + I + I + I + / + +

+
+
+

+ + Revision + 1.00 + Page + 84 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + LOCAL_C + VOID + TestGobble + (VOID) + +

+
+
+

+ + UINT + segCount; + + + buf + [16]; + +

+
+
+
+

+ + segCount=0; + + + p_printf + ("Checking + segment + integrity + ..."); + + + for + (segCount=0; + segCount<p_sgsize(segH); + segCount+t+) + + + { + + + if + (p_sgcopyfr(segH, + segCount*16, + &buf + [0] + ,16) + <0) + + + p_printf + ("Error + in + segment"); + +

+
+
+
+
+
+

+ + else + + + { + + + for + (i=0;i<16;i++) + + + if + (buf[i] + !=0x55) + + + { + + + p_printf + ("OVERWRITE + ERROR!"); + + + p_printf + ("Segment + count=%d",segCount) + ; + + + p_printf + ("Byte + count=%d",i); + + + } + + + } + + + } + + + p_printf + ("Test + segment + OK"); + + + p_printf + ("Heap + integrity + checks + OK"); + + + p_allchk + (44); + + + p_printf("If + get + here, + heap + OK"); + + + p_getch(); + +

+
+
+

+ + } + +

+
+
+

+ + [KR + KR + KK + KR + KK + KKK + I + I + I + I + I + / + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Page + 85 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + APPENDIX: + SOURCE + CODE + FILES + +

+
+
+

+ + A4EXIF.ASM + +

+
+
+

+ + title + A4EXIF + -- + Example + ASIC4 + Interface + device + driver + + + subttl + Copyright + (c) + Psion + PLC + (1994) + + + name + A4EXIF + + + ; + + + ; + VER + DATE + BY + DESCRIPTION + + + jo + -o-------------------------------------- + + + 7 + 1.00F + 26/1/95 + Mal + Working + Version + + + BUILDSB=1 + 7S3a + build + environment + (channels=1) + + + S3c=0 + ;Need + to + specify + no + s3c + + + ; + BUILDSC=1 + 7S3c + build + environment + (channels=3) + + + ; + BUILDCH=1 + ;HC + build + environment + (channels=3) + + + ; + BUILDHH=1 + 753 + build + environment + (channels=1) + + + include + ..\inc\epoc.inc + + + include + ..\inc\epoclib.inc + + + include + ..\inc\epocsibo.inc + +

+
+
+

+ + include + ossibo.inc + + + include + ospack.inc + +

+
+
+

+ + Example + Logical + Device + Driver + for + prototype + LED-ASIC4 + Interface + + + circuit + for + Corporate/S3C/Consumer + serial + port. + + + Written + by + Mal + Dec + 1994/Jan + 1995. + +

+
+
+

+ + Me + oNe + Ne + +

+
+
+

+ + A4EXIF + CONSTANTS + AND + TYPES + +

+
+
+

+ + The + following + constants + and + type + definitions + + + are + compiler + directives + used + by + the + TCEP + assembler + + + when + it + is + creating + the + LDD. + +

+
+
+

+ + Ne + Ne + Ne + Ne + Ne + +

+
+
+

+ + if + Consumer + +

+
+
+

+ + numberofchannels + equ + 1 + + + else + + + if + Corporate + or + S3c + + + numberofchannels + equ + 3 + + + else + + + numberofchannels + equ + 2 + + + endif + + + endif + +

+
+
+

+ + 7;Channel + StatusEnt + block + accessed + through + CS:DI + + + A4ExifStatusEnt + struc + +

+
+
+
+
+
+
+
+

+ + A4ExifCSProcessId + dw + <i + ;Channel + parent + process + id + + + A4ExifCSChannelOpen + db + 2 + ;Channel + open + flag + + + A4ExifCSChannelRunning + db + ? + ;Channel + hardware + running + + + flag + + + A4ExifCSChanReadCompleted + db + 2 + ;Channel + request + completed + + + flag + + + A4ExifCSChannelIntMask + db + 2 + ;Channel + interrupt + mask + + + A4ExifCSChanneliIntNum + db + ? + ;Channel + interrupt + number + + + A4ExifCSChannelSelect + db + 2 + ;SIBO + Channel + select + + + A4ExifCSChanneliIntVec + dw + ? + ;Channel + int + vector + number + + + A4ExifCSTickHandle + dw + ee + ;TCK + channel + handle + + + A4ExifCSA1Value + db + i + ;Channel + strategy + Al + parameter + + + A4ExifCSA2Value + db + ? + ;Channel + strategy + A2 + parameter + +

+
+
+

+ + A4ExifStatusEnt + ends + +

+
+
+

+ + ;Open + Channel + Control + block + accessed + through + DS:BX + + + A4ExifEnt + struc + +

+
+
+

+ + A4ExifDSIo + ChanEnt + <> + 7;Open + channel + control + block + Ent + + + A4ExifDSHandlerPtr + dw + 2 + ;Cant + touch + when + under + + + A4ExifDSStatusPtr + dw + ? + ;Hold, + Resume, + Reset + or + + + A4ExifDSA1Ptr + dw + ? + ;interrupt + routine + + + A4ExifDSA2Ptr + dw + es + + + A4ExifDSStatusEntPtr + dw + ? + +

+ +

+ + A4ExifEnt + ends + + + A4PERIPH + MASK + equ + Of0h + 711110000b + +

+
+
+

+ + Revision + 1.00 + Page + 86 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+
+
+
+

+ + EXTENDED_INFO_BYTE + equ + 090h + + + U5_ENABLE_ON + equ + 080h + + + U5_ENABLE_OFF + equ + 000h + + + ;Latch + addresses + for + reading/writing + + + USOUTPUT_LATCH + equ + 00000000b + + + U3INPUT_BUFFER + equ + 00000000b + + + U4STATUS_BUFFER + equ + 00000001b + + + cs: + [di] + .A4ExifCsAlValuefor + + + INTERRUPT_LATCH + equ + 00000001b + + + ;Status + byte + masks + + + S2S3_ON + equ + 00000011b + + + S2S3_OFF + equ + 00000000b + + + S2_ONLY + equ + 00000001b + + + S3_ONLY + equ + 00000010b + + + INTERRUPT_STATUS_MASK + equ + 00000011b + + + 7; + LED + bytes + + + SOME_LEDS_ON + equ + 01010101b + + + SOME_LEDS_OFF + equ + 10101010b + + + TOP_LEDS_ON + equ + 11110000b + + + BOTTOM_LEDS_ON + equ + 00001111b + + + ZERO_BYTE + equ + 00h + + + dgroup + group + stack + + + assume + ds:dgroup,es:dgroup,ss:dgroup + + + CodeSeg + + + 7 + A4EXIF + ENTRY + TABLE + + + ; + Seseseo + eee + ee + sececs + + + ProcBegin@ + A4ExifLDD + + + ; + ssieceees + + + dw + LDDSignature + + + db + 'LED',0,0,0,0,0 + + + dw + (VectorEnd-Vector) + /2 + + + Vector: + + + dw + A4ExifInstall + + + dw + A4ExifRemove + + + dw + A4ExifHold + + + dw + A4ExifResume + + + dw + A4ExifReset + + + dw + A4ExifUnits + + + dw + A4ExifOpen + + + dw + A4ExifStrategy + + + VectorHandler: + + + dw + A4ExifHandler + + + if + Asic9 + + + InterruptVectors: + + + dw + A4ExifTickInt + + + endif + + + VectorEnd: + + + H + A4EXIF + INTERNAL + DATA + SPACE + + + , + + + ; + Device + Driver + global + variables + follow. + + + ; + These + variables + reside + in + the + code + segment + + + ; + and + as + such + can + always + be + accessed + with + + + 7 + the + 'cs:' + prefix. + +

+
+
+

+ + if + Asic9 + + + if + Consumer + +

+
+
+

+ + Channel0O + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 710010000b + + + 7;Sets + LBO + for + latch + U5 + + + ;Deselects + LBO + for + U5 + +

+
+
+

+ + ;Selects + + + ;Selects + + + ;Selects + +

+
+
+

+ + ;Selects + +

+
+
+

+ + A9MSlave, + HwIrq2Revector, + SelectChannel5, + IntVec0O,0,0> + +

+
+
+

+ + else + + + if + Corporate + or + S3c + +

+
+
+

+ + Channel0 + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+

+ + AOMExpIntA, + HwIrq4Revector, + SelectChannel3, + IntVec0O,0,0> + +

+
+
+

+ + Channell + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+

+ + AQMExpIntB, + HwIrq5Revector, + SelectChannel4, + IntVec1,0,0> + +

+
+
+

+ + Channel2 + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+

+ + A9MSlave, + HwIrq2Revector, + SelectChannel5, + IntVec2,0,0> + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + AO + for + writing + + + AO + for + reading + +

+
+
+

+ + ; + reading + + + Al + for + writing + +

+
+
+

+ + Page + 87 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + else + + + Channel0 + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+

+ + AOMExpIntA, + HwIrq4Revector, + SelectChannel3, + IntVec0O,0,0> + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+

+ + AQ9MExpIntB, + HwIrq5Revector, + SelectChannel4, + IntVec1,0,0> + + + endif + + + endif + + + else + + + if + Consumer + + + Channel0O + A4ExifStatusEnt<0,0,0,0,mask + +

+
+
+

+ + Asic2Int, + HwIrq4Revector, + SelectChannel7, + IntVec0,0,0> + +

+
+
+
+
+
+
+

+ + else + + + if + Corporate + + + ChannelO + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntLeftA, + HwIrq3Revector, + ExpChannelLeftA, + IntVec0O,0,0> + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntRightB, + HwIrq2Revector, + ExpChannelRightB, + IntVecl1,0,0> + + + Channel2 + A4ExifStatusEnt<0,0,0,0,mask + + + Asic2Int, + HwIrq4Revector, + SelectChannel7, + IntVec2,0,0> + + + else + + + ChannelO + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntLeftA, + HwIrq3Revector, + ExpChannelLeftA, + IntVec0O,0,0> + + + Channell + A4ExifStatusEnt<0,0,0,0,mask + + + ExpIntRightB, + HwIrq2Revector, + ExpChannelRightB, + IntVecl1,0,0> + + + endif + + + endif + + + endif + + + HoldFlag + db + 0 + ;Hold/Resume + flag + + + SwitchStatus + db + ? + ;Holds + the + masked + status + byte + from + U4 + after + + + interrupt + + + ProcEnd + noret + + + ProcBegin@ + A4ExifInstall, + far + + + ; + eee + + + ; + Installs + the + device + driver. + + + 7 + Invoked + after + a + PLIB + 'p_loadldd("A4EXIF.LDD")' + call + to + load + the + LDD + + + ; + All + of + the + fields + inside + the + CS + control + blocks + are + preloaded + + + ; + with + the + correct + values + at + install + time. + Install + therefore + does + + + ; + not + do + any + work. + + + 7 + IN: + + + ; + Nothing + + + 7 + OUT: + + + ; + Carry + Clear + - + driver + successfully + installed + + + 7 + + + cle + ;The + ChannelOpen + fields + are + set + to + zero + + + ret + ;in + the + relevant + ChannelStatusEnt + headers + + + ProcEnd + noret + + + ProcBegin@ + A4ExifRemove, + far + + + ; + eSeseces + eee + + + ; + Removes + the + device + driver. + + + ; + Invoked + after + a + PLIB + 'p_devdel("LED",E_LDD) + 'call + to + unload + the + + + H + device + driver. + + + ; + A + device + driver + cannot + be + removed + if + any + of + its + channels + + + i + are + still + open. + + + H + IN: + + + ; + Nothing + + + H + OUT: + + + ; + Carry + clear + - + successfully + removed + + + 7 + Carry + set + - + remove + failed, + error + number + in + AL + + + 7 + + + mov + cx, + numberofchannels + ;Check + that + each + + + mov + di, + offset + Channel0O + ;channel + is + closed + + + xor + ax, + ax + + + CheckAl1lChannelsClosedLoop: + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + al + ;Closed + channels + will + + + jne + WeHaveAChannelOpenSoFail + ;have + the + value + 0 + in + + + add + di, + (size + A4ExifStatusEnt) + ;their + ChannelOpen + +

+
+
+

+ + Revision + 1.00 + Page + 88 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + loop + CheckAl1ChannelsClosedLoop + ;flags + + + jmp + FinishedOkay + + + WeHaveAChannelOpenSoFail: + + + mov + al, + InUseErr + ;Fail + if + not + all + + + stc + ;closed + + + ret + + + FinishedOkay: + + + cle + + + ret + + + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifHold, + far + +

+
+
+

+ + v + +

+ +

+ + ; + Called + by + the + operating + system + whenever + the + device + driver + is + +

+ +

+ + ; + being + moved + or + the + machine + is + powering + down. + +

+ +

+ + ; + This + will + also + be + called + by + our + pack + door + polling + function + when + +

+ +

+ + ; + it + sees + that + the + doors + have + been + opened + and + our + peripheral + has + +

+ +

+ + ; + lost + power. + +

+ +

+ + ; + IN: + +

+ +

+ + 7 + Reason + for + the + hold + in + AH + +

+ +

+ + 7 + OUT: + +

+ +

+ + 7 + Nothing + +

+ +

+ + 13 + + + mov + cx, + 1 + ;Hold + can + be + called + + + xchg + cl, + HoldFlag + ;when + the + driver + is + + + cmp + cl, + 0 + ;under + a + hold + so + + + jne + AlreadyHeld + ;re-entrancy + blocking + +

+ +

+ + A4HoldFromTick: + ;is + required + + + mov + cx, + numberofchannels + + + mov + di, + offset + Channel0 + ; + Loop + because + Hold + +

+
+
+

+ + HoldAllTheChannelsLoop: + +

+
+
+

+ + ;must + stop + all + the + +

+
+
+

+ + cmp + cs: + [di] + .-A4ExifCSChannelOpen, + ; + channels + + + je + DontHoldBecauseNotOpen + ;Is + the + channel + open? + + + push + cx + ;If + it + is + then + stop + + + call + StopTheChannelRunning + yall + interrupts + + + pop + cx + + + DontHoldBecauseNotOpen: + + + add + di, + (size + A4ExifStatusEnt) + + + loop + HoldAl1lTheChannelsLoop + + + AlreadyHeld: + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifResume, + far + +

+
+
+

+ + 3 + Called + by + the + operating + system + when + it + has + finished + moving + the + + + - + device + driver + in + memory + or + when + the + machine + is + switching + back + on. + + + ; + Also + called + by + our + door + polling + routine + when + it + sees + that + the + doors + + + ; + have + been + closed + and + we + can + resume + communication + with + our + peripheral. + + + ; + IN: + + + iH + Nothing + + + ; + OUT: + + + 7 + Nothing + + + is + + + xor + CX, + cx + ;Block + in + case + of + re-entrancy + + + xchg + cl, + HoldFlag + + + cmp + cl, + 0 + + + je + AlreadyResumed + + + if + Asic9 + + + GenDataSegment + ;Check + to + see + if + the + pack + + + HwGetSsdData + ;doors + are + still + closed + + + mov + bx, + ax + + + cmp + es: + [bx] + .SsdDoorStatus, + DoorOpen + + + je + DoorsAreOpen + + + endif + + + A4ResumeFromTick: + + + mov + cx, + numberofchannels + ; + Loop + because + resume + must + + + mov + di, + offset + Channel0 + ;restart + each + open + channel + + + ResumeAllTheChannelsLoop: + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + 0 + ;Is + the + channel + open? + + + je + DontResumeBecauseNotOpen + + + push + Cx + + + call + StartTheChannelRunning + + + pop + cx + + + DontResumeBecauseNotOpen: + + + add + di, + (size + A4ExifStatusEnt) + + + loop + ResumeAl1lTheChannelsLoop + + + AlreadyResumed: + +

+
+
+

+ + Revision + 1.00 + Page + 89 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ret + +

+
+
+

+ + DoorsAreOpen: + +

+
+
+

+ + mov + HoldFlag, + 2 + + + ret + + + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifReset, + far + +

+
+
+

+ + Called + when + an + application + which + opened + a + channel + terminates + without + + + closing + the + device + driver. + + + A + device + driver, + for + each + open + channel, + has + to + request + that + the + + + operating + system + calls + this + function + when + the + application + + + terminates + abnormally + (ie + without + closing + an + open + channel). + + + Reset + can + supply + one + piece + of + identifying + data + which + will + be + + + passed + in + CX. + This + would + usually + be + the + channel's + number + or + CS + + + control + block + pointer. + + + Reset + just + needs + to + clear + interrupts, + hardware + reservations, + and + free + + + the + channel. + Any + allocated + space + will + be + cleaned + up + for + you + by + the + OS. + + + IN: + +

+ +

+ + The + device + driver's + handle + in + BX + +

+ +

+ + The + address + of + the + status + struc + identifying + the + channel + in + CX + +

+
+
+

+ + 7 + OUT: + + + ; + Nothing + + + , + + + mov + di, + cx + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + je + NotOpenToReset + + + call + StopTheChannelRunning + 7Stop + interrupts + + + mov + al, + cs: + [di] + .A4ExifCSChannelIntMask + ;Free + the + reserved + + + HwF + reeChannel + ;hardware + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 0 + ;The + channel + is + now + + + NotOpenToReset: + ;free + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifUnits, + far + +

+
+
+

+ + Called + to + find + how + many + open + channels + the + driver + will + support + +

+
+
+

+ + - + In: + + + ; + Nothing + + + - + Out: + + + H + The + total + number + of + channels + supported + in + AX + + + , + + + mov + ax, + numberofchannels + + + ret + +

+
+
+

+ + ~ + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifOpen, + far + +

+
+
+

+ + Opens + a + device + driver + channel. + + + Invoked + after + the + PLIB + call + 'p_open(é&appHandle, + "LED:*",-1)'to + open + a + + + channel + to + the + device + driver. + +

+
+
+

+ + , + +

+ +

+ + , + +

+ +

+ + 7 + +

+ +

+ + H + Tn: + +

+ +

+ + ; + OS + device + handle + of + the + device + driver + in + DX + +

+ +

+ + ; + Pointer + to + the + OpenEnt + struc + in + SI + +

+ +

+ + ; + Pointer + to + the + IntEnt + struc + in + BP + +

+ +

+ + ; + DS,ES,SS + point + to + the + applications + data + space + +

+ +

+ + i + Out: + +

+ +

+ + ; + Carry + clear + - + BX + holds + the + address + of + the + open + channel + +

+ +

+ + 7 + Carry + set + - + AL + holds + the + error + number + +

+ +

+ + is + + + cld + ;Interrupts + off + to + + + pushf + ;prevent + multiple + apps + + + oli + ;calling + open + + + mov + si, + [si] + .OpenNamePtr + ; + Simultaneously + + + mov + al, + [sitl] + + + CharToFoldedChar + ;Read + the + unit + no. + + + cmp + al, + 'A' + ;part + of + device + name + + + jb + OpenNameErr + ;to + find + which + channel + + + sub + al, + 'A' + ;to + open. + eg + "LED:A" + + + cmp + al, + numberofchannels + + + jae + OpenNameErr + + + xor + ah, + ah + + + push + ax + ;Map + the + channel + no. + + + mov + dx, + (size + A4ExifStatusEnt) + ;to + a + channel + control + + + mul + dx + ;block + in + our + CS + + + pop + ax + 7; + space + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 90 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+

+ + mov + di, + ax + + + add + di, + offset + Channel0O + + + cmp + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + je + GetATickChannel + + + popft + + + mov + ax, + AlreadyOpenErr + + + jmp + ChannelAlreadyOpen + + + GetATickChannel: + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 1 + + + mov + cs: + [di] + .-A4ExifCSChannelRunning, + 0 + + + popft + + + ife + Asic9 + + + jmp + GetHardwareChannel + + + else + + + push + ax + + + mov + ax, + ((':' + shl + 8)+'K') + + + push + ax + + + mov + ax, + (('C' + shl + 8)+'T') + + + push + ax + + + mov + bx, + sp + + + ToOpen + + + jne + GotATickChannel + + + add + sp, + 6 + + + mov + ax, + LockedErr + + + jmp + OpenFailed + + + GotATickChannel: + + + add + sp, + 6 + + + mov + cs: + [di] + .A4ExifCSTickHandle, + ax + + + push + ax + + + mov + bx, + ax + + + mov + ax, + IoFuncStart + + + mov + ex, + 1 + + + push + cx + + + push + cx + + + push + ax + + + mov + cx, + (InterruptVectors-Vector) + /2 + + + push + cx + + + mov + cx, + sp + + + ToWithWait + + + add + sp, + 8 + + + pop + dx + + + jmp + GetHardwareChannel + + + endif + + + OpenNameErr: + + + popft + + + mov + ax, + NameErr + + + jmp + ChannelAlreadyOpen + + + GetHardwareChannel: + + + mov + al, + cs: + [di] + .A4ExifCSChannelIntMask + + + HwGetChannel + + + jne + CheckHardwareNowThatSIBOChannellIsOpen + + + mov + ax, + InUseErr + + + jmp + FreeTckAndExit + + + FreeTckAndChannelHardware: + + + mov + al, + cs: + [di] + .A4ExifCSChannelIntMask + + + HwF + reeChannel + + + mov + ax, + DeviceErr + + + FreeTckAndExit: + + + if + Asic9 + + + push + ax + + + mov + bx, + cs: + [di] + .A4ExifCSTickHandle + + + IoClose + + + pop + ax + + + endif + + + OpenFailed: + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + ChannelAlreadyOpen: + + + stc + + + OpenExit: + + + ret + + + CheckHardwareNowThatSIBOChannellIsOpen: + + + Proclid + + + mov + cs: + [di].A4ExifCSProcessId, + ax + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + + + call + CheckHardwarePresent + + + jc + FreeTckAndChannelHardware + + + mov + cx, + (size + A4ExifEnt) + + + HeapAllocateCell + + + jc + FreeTckAndChannelHardware + + + mov + bx, + ax + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ;Offset + in + DI + +

+
+
+

+ + ;Check + to + see + if + + + ;channel + is + already + + + ;open + +

+
+
+

+ + ,Obtain + a + TCK + channel + so + + + ;we + can + poll + the + door + state + +

+
+
+

+ + 7;If + HC, + we + don't + need + + + ;to + set + up + the + TCK + + + ; + routine + +

+
+
+

+ + ;Try + to + open + "TCK:" + + + ;channel + with + "TCK:" + + + ; + string + on + stack + +

+
+
+

+ + ;TCK + will + call + our + + + ,door-polling + function + + + 732 + times + a + second + +

+
+
+

+ + 7Start + our + + + ,door-polling + function + + + ;running + by + starting + + + ;the + "TCK:" + channel + +

+
+
+

+ + 7Frequency + 1 + tick + + + ;Data + irrelevant + + + ;Handle + to + driver + + + ;TCK + function + to + call + +

+
+
+

+ + 7;Check + the + hardware + + + ;is + available + then + + + ;reserve + it + + + ;Returns + with + carry + + + ;clear + if + OK + +

+
+
+

+ + 7Set + up + the + calling + + + ;process + ID + +

+
+
+

+ + ;Returns + with + carry + + + ;clear + if + successful + + + ;Allocate + a + control + + + ;block + in + our + app's + + + ;data + space + +

+
+
+

+ + Page + 91 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+
+

+ + push + bx + ;IloAddHandler + trashes + BX + + + mov + al, + (VectorHandler-Vector) + /2 + ;Set + up + our + wait + handler + + + ToAddHandler + ;Leaves + the + address + of + + + pop + bx + ;handler + in + AX + + + jne + GotHandler + + + push + ax + ;If + no + handler, + open + fails + + + HeapFreeCell + + + pop + ax + + + jmp + FreeTckAndChannelHardware + + + GotHandler: + + + mov + [bx] + .A4ExifDSStatusEntPtr, + di + + + mov + [bx] + .A4ExifDSHandlerPtr, + ax + + + mov + [bx] + .A4ExifDSStatusPtr, + 0 + + + mov + [bx] + .A4ExifDSIo.ChanNext, + bx + + + mov + [bx] + .A4ExifDSIo.ChanSignature, + IoChanSignature + + + mov + [bx] + .A4ExifDSIo.ChanLibHandle, + dx + + + mov + cx, + al + ; + loRequestReset + takes + + + xchg + bx, + dx + ;the + device + handle + in + + + IoRequestReset + 7BX + and + the + channel + + + xchg + bx, + dx + ;handle + in + CX + + + xor + ax, + ax + + + call + StartTheChannelRunning + + + ReturnCLc: + + + cle + + + ret + + + ProcEnd + + + if + Asic9 + +

+
+
+

+ + ProcBegin@ + A4ExifTickInt, + far + +

+
+
+

+ + This + function + is + called + by + the + tick + handler + on + every + tick + of + +

+ +

+ + ; + the + system + clock. + This + happens + 32 + times + a + second. + +

+ +

+ + ; + The + operating + system + will + call + a + device + driver + to + hold + when + memory + is + + + ; + being + moved + and + when + the + machine + is + being + powered + down. + It + will + not + +

+ +

+ + ; + call + the + device + driver + when + the + pack + doors + are + opened. + +

+ +

+ + Opening + the + pack + doors + will + cause + power + to + the + peripheral + to + be + cut, + +

+
+
+
+
+
+
+
+

+ + ; + + + ; + and + therefore + the + driver + needs + to + be + held + in + the + way + it + would + be + if + + + ; + the + machine + powered + down. + Only + for + Asic9 + based + machines. + + + ; + This + function + checks + the + state + of + the + doors + on + every + tick + and + calls + + + iH + Hold + and + resume + when + it + sees + the + status + of + the + doors + change. + + + H + IN: + + + ; + The + state + of + the + door + in + SI + + + ; + OUT: + + + ; + Nothing + + + ; + + + cmp + si, + DoorOpen + 7Is + the + door + open + + + je + TheDoorIsOpen + 7or + closed? + + + cmp + HoldFlag, + 2 + 7Closed + Door, + HoldFlag=2 + + + je + NeedToDoTheResume + ;means + we + do + a + resume + + + ret + 7Closed + Door, + HoldFlag!=2 + + + NeedToDoTheHold: + + + mov + HoldFlag, + 2 + + + jmp + A4HoldFromTick + + + NeedToDoTheResume: + + + mov + HoldFlag, + 0 + + + jmp + A4ResumeFromTick + + + TheDoorIsOpen: + + + xor + ax, + ax + + + cmp + HoldFlag, + al + + + je + NeedToDoTheHold + + + ret + + + ProcEnd + noret + + + endif + + + ProcBegin@ + A4ExifHandler, + far + + + ; + + + ; + When + an + application + is + waiting + within + an + iowait + and + a + signal + is + + + ; + generated + then + before + passing + that + signal + to + the + application + the + + + : + OS + first + runs + any + wait + handlers + belonging + to + the + device + driver + + + ; + channels + that + the + application + has + open. + + + ; + The + interrupt + routine + can + generate + a + signal + but + cannot + fill + in + any + + + ; + status + words + or + pass + values + back + to + the + application + because + the + + + ; + applications + DS + space + is + not + available. + The + handler + can + consume + a + + + ; + signal + generated + by + an + interrupt + and + then + fill + any + status + words + + + 7 + before + re-signalling + the + application. + A + handler + always + has + access + + + ; + to + the + application's + DS + space. + The + wait + handler + can + consume + the + + + 7 + signal + which + is + then + no + longer + passed + back + to + the + application. + + + Hi + IN: + +

+
+
+

+ + Revision + 1.00 + Page + 92 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+
+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Pointer + to + our + control + block + in + applications + DS + space + in + BX + + + DS,ES,SS + point + at + application's + data + space + +

+
+
+

+ + OUT: + + + Carry + clear + - + do + not + consume + the + signal, + signal + not + for + us + + + 7 + Carry + set + - + consume + the + signal, + re-enable + handler + if + AL + + + ; + non-zero + else + don't + re-enable + handler + if + AL=0. + + + 7 + + + cld + + + pushf + + + cli + + + mov + di, + [bx].A4ExifDSStatusEntPtr + ;Is + the + signal + for + us? + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 1 + + + jne + ExitHandlerSignalNotForuUs + ;If + it + is, + copy + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + ;the + values + read + in + + + mov + al, + cs: + [di] + .A4ExifCSA1Value + ;the + interrupt + + + mov + ah, + cs: + [di] + .A4ExifCSA2Value + ;routine + back + to + + + mov + di, + [bx].A4ExifDSA1Ptr + ;the + application + + + mov + [di], + al + ;Asynchronous + read + + + mov + di, + [bx].A4ExifDSA2Ptr + ;has + been + completed + + + mov + [di], + ah + + + xor + di, + di + + + xchg + [bx] + .A4ExifDSStatusPtr, + di + ;Clear + the + status + + + mov + word + ptr + [di], + 0 + ;word + + + popft + + + ToSignal + + + xor + ax, + ax + + + stc + ;STC + and + AL!=0 + => + + + ret + ;consume + signal + and + + + ExitHandlerSignalNotForus: + ;don't + re-enable + + + popft + ;handler + + + elec + + + ret + + + ProcEnd + + + StrategyVectorTable + label + word + + + dw + offset + A4ExifDefault + ;StrategyPanic + + + dw + offset + A4ExifRead + 7 + StrategyRead + ie + P_FREAD + + + dw + offset + A4ExifWrite + ;StrategyWrite + ie + P_FWRITE + + + dw + offset + A4ExifClose + ;StrategyClose + ie + P_FCLOSE + + + dw + offset + A4ExifCancel + 7 + StrategyCancel + ie + P_FCANCEL + + + dw + offset + A4ExifDefault + ;StrategyAttach + + + dw + offset + A4ExifDefault + ;StrategyDetach + + + dw + offset + A4ExifSet + ;StrategySet + ie + P_FSET + + + dw + offset + A4ExifSense + ;StrategySense + ie + P_FSENSE + + + ProcBegin@ + A4ExifStrategy, + far + + + Called + by + the + operating + system + when + an + I/O + request + is + made + on + +

+
+
+

+ + the + device + driver. + +

+ +

+ + Calls + to + this + funcion + from + an + owning + application + will + usually + take + + + the + form + p_ioc(pcb, + func, + &Stat, + &Al, + &A2) + ; + +

+ +

+ + The + strategy + function + is + called + with + a + function + number + specifying + + + the + action + which + the + driver + is + to + take, + a + status + word + to + fill + when + + + the + action + is + complete, + and + two + arguments + Al + and + A2. + +

+
+
+

+ + Nee + Ne + Ne + +

+
+
+

+ + Se + ee + +

+
+
+

+ + All + strategy + functions + must + complete + with + a + signal + to + the + application. + + + Functions + can + be + asynchronous + and + need + not + complete + immediately. + + + IN: + + + Pointer + to + our + control + block + in + the + applications + DS + in + BX + + + 7 + Device + driver + handle + in + DX + + + ; + Pointer + to + the + RqEnt + struct + in + SI + + + ; + Pointer + to + a + IntEnt + struct + in + BP + + + ; + DS,ES,SS + point + at + the + applications + data + space + + + i + OUT: + + + ; + Returned + value + in + AX + + + ; + Must + call + IoSignal + somewhere + to + signal + completion + + + ; + of + the + I/O + request. + + + v + + + mov + ax, + [si].RqFunction + ;Get + the + function + number + + + mov + dx, + [si].RqAlPtr + ;DX + holds + the + first + argument + + + mov + di, + [si].RqStatusPtr + ;for + convenience + + + mov + word + ptr + [di], + PendingErr + 7Status + word + holds + + + shl + ax, + 1 + ; + E_FILE_PENDING + + + mov + di, + ax + + + push + StrategyVectorTable[di] + ;Jump + to + required + function + + + mov + di, + [bx] + .A4ExifDSStatusEntPtr + ;with + our + CS + control + block + + + retn + ;pointer + in + DI + + + A4ExifDefault: + + + ToRoot + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 93 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ret + + + ExitWithCompletionStatusZero: + +

+ +

+ + xor + ax, + ax + ;Common + exit + points + + + ExitWithOtherCompletionStatus: + +

+ +

+ + mov + di, + [si].RqStatusPtr + +

+ +

+ + mov + word + ptr + [di], + ax + +

+ +

+ + ToSignal + + + ExitStillPending: + +

+ +

+ + xOr + ax, + ax + +

+ +

+ + cle + +

+ +

+ + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + STRATEGY + VECTOR + TABLE + FUNCTIONS + +

+
+
+

+ + IN: + + + DX + holds + the + pointer + to + the + first + argument + in + 'p_iow(...)' + call + + + BX + holds + the + address + of + the + open + channel + control + block + + + CS:DI + holds + the + address + of + status + struc + identifying + the + open + channel + +

+
+
+

+ + See + eee + Ty + +

+
+
+

+ + ProcBegin@ + A4ExifRead, + far + +

+
+
+

+ + H + Strategy + vector + table + function + that + handles + asynchronous + byte + reads + + + 7 + from + the + LEDs + and + switches. + +

+ +

+ + i; + The + corresponding + PLIB + call + is + p_ioc(pcb,P_FREAD, + &Stat, + &Argl, + &Arg2) + ; + + + ; + The + request + is + completed + when + the + interrupt + routine + signals + the + +

+ +

+ + ; + handler + which + in + turn + signals + the + application + passing + back + the + values + + + ; + read + at + the + time + of + the + interrupt + through + the + AlPtr + and + A2Ptr. + +

+ +

+ + H + IN: + +

+ +

+ + ; + Pointer + to + control + block + in + applications + data + space + in + BX + +

+ +

+ + i + Pointer + to + control + block + in + our + CS + space + in + DI + +

+ +

+ + ; + Al + (pointer + to + Argl) + in + DX + +

+ +

+ + , + +

+ +

+ + v + +

+
+
+
+
+
+
+
+
+

+ + OUT: + + + Jumps + to + common + exit + point + + + . + Panics + if + multiple + requests + + + , + + + cmp + [bx] + .A4ExifDSStatusPtr, + 0 + ;Panic + if + we + already + + + jne + PanicPending + ;have + an + I/O + read + request + + + pushf + ;pending + on + the + channel + + + cli + ;Disable + interrupts + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 2 + + + mov + ax, + [si].RqA1Ptr + + + mov + [bx] + .A4ExifDSA1Ptr, + ax + ; + Store + the + locations + to + + + mov + ax, + [si].RqA2Ptr + ;put + the + data + when + we + get + it + + + mov + [bx] + .A4ExifDSA2Ptr, + ax + + + mov + di, + [si].RqStatusPtr + + + mov + [bx] + .A4ExifDSStatusPtr, + di + ;DI + holds + the + address + + + mov + word + ptr + [di], + PendingErr + 7of + status + word + and + we + + + popf + ;Signal + that + we + are + waiting + + + mov + bx, + [bx] + .A4ExifDSHandlerPtr + ;for + completion + of + read + + + mov + cl, + + + ToEnableHandler + ;Enable + Wait + Handler + + + jmp + short + ExitStillPending + 7No + IoSignal + because + + + PanicPending: + ;we + are + still + waiting + + + mov + al, + PaniclIoPending + + + ProcPanic + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifWrite, + far + +

+
+
+

+ + This + function + sets + the + state + of + the + LEDs. + +

+ +

+ + It + completes + immediately + after + setting + the + state + as + it + has + nothing + + + to + wait + for. + +

+ +

+ + Write + is + the + same + as + set. + +

+
+
+

+ + Ne + Ne + Ne + Ne + Ne + te + +

+
+
+

+ + IN: + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + ; + Pointer + to + control + block + in + our + CS + space + in + DI + + + . + Al + in + DX + + + - + OUT: + + + - + Jumps + to + Set + + + , + + + jmp + WriteAndSetAreTheSame + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifClose, + far + +

+
+
+

+ + Revision + 1.00 + Page + 94 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Handles + the + request + to + close + a + channel. + + + called + by + the + PLIB + call + p_iow(pcb,P_FCLOSE) + or + p_close + (pcb) + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+
+
+
+

+ + IN: + + + Pointer + to + control + block + in + applications + data + space + in + BX + + + ; + Pointer + to + control + block + in + our + CS + space + in + DI + + + ; + OUT: + + + ; + Jumps + to + common + exit + point + + + , + + + call + StopTheChannelRunning + 7Stop + interrupts + + + if + Asic9 + + + push + bx + ;Close + down + the + + + mov + bx, + cs: + [di] + .A4ExifCSTickHandle + 7;"TCK:" + channel + + + IoClose + + + pop + bx + + + endif + + + push + bx + + + mov + ax, + [bx] + .A4ExifDSIo.ChanLibHandle + ;Remove + the + wait + + + push + ax + ;handler + + + mov + bx, + [bx] + .A4ExifDSHandlerPtr + + + IoRemoveHandler + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + ;If + the + interrupt + + + je + NoSignalToConsumeFromInterrupt + ;has + signalled + the + + + ToWaitForSignal + ;handler + we + need + to + + + NoSignalToConsumeFromInterrupt: + ;consume + its + signal + + + pop + bx + ;now + the + handler + + + mov + cx, + di + ;has + been + removed + + + ToRequestResetCancel + + + pop + bx + 7No + longer + need + reset + + + HeapFreeCell + ;Free + our + control + + + mov + al, + cs: + [di] + .-A4ExifCSChannelIntMask + ;block + in + app's + DS + + + HwFreeChannel + + + mov + cs: + [di] + .A4ExifCSChannelOpen, + 0 + + + jmp + ExitWithCompletionStatusZero + 7To + signal + completion + + + ProcEnd + noret + 7,of + close + request + + + ProcBegin@ + A4ExifCancel, + far + + + v + + + ; + Cancel + any + pending + asynchronous + read. + + + ; + Called + by + the + PLIB + function + p_iow(pcb,P_FCANCEL) + ; + + + i + In: + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + ; + Pointer + to + control + block + in + our + CS + space + in + DI + + + ; + Out: + + + ; + Jumps + to + common + exit + point + + + 7 + + + pushf + + + cli + + + cmp + [bx] + .A4ExifDSStatusPtr, + 0 + ;Check + that + there + is + + + je + NothingToCancel + ya + request + pending + + + push + bx + + + mov + bx, + [bx] + .A4ExifDSHandlerPtr + + + sub + cl + ol + + + ToEnableHandler + ;Disable + Wait + Handler + + + pop + bx + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 1 + + + jne + NoSignalFromInterrupt + ;TO + consume + any + stray + + + ToWaitForSignal + ;Signal + from + the + + + NoSignalFromInterrupt: + ;interrupt + routine + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 0 + + + xor + fomcramre + be + ;To + signal + completion + + + xchg + di, + [bx].A4ExifDSStatusPtr + ;of + the + outstanding + + + mov + word + ptr + [di], + CancelErr + pasync + read + request + + + ToSignal + ;Signal + to + p_waitstat + + + NothingToCancel: + + + popft + + + jmp + ExitWithCompletionStatusZero + 7To + signal + completion + + + ProcEnd + noret + 7of + the + cancel + request + + + ProcBegin@ + A4ExifSet, + far + + + , + + + 7 + Write + a + value + to + the + LED + latch. + + + ; + Can + be + called + by + the + PLIB + call + p_iow(pcb,P_FSET, + &Argl); + where + Al + + + ; + is + an + unsigned + byte. + + + ; + Write + is + the + same + as + set. + + + 7 + IN: + + + ; + Pointer + to + control + block + in + applications + data + space + in + BX + + + 7 + Pointer + to + control + block + in + our + CS + space + in + DI + + + 7 + Al + (pointer + to + Argl) + in + DX + +

+
+
+

+ + Revision + 1.00 + Page + 95 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + OUT: + + + Jumps + to + common + exit + point + +

+
+
+

+ + , + + + WriteAndSetAreTheSame: + +

+
+
+

+ + Steere + Ty + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + seo + +

+
+
+

+ + pushf + +

+ +

+ + cli + +

+ +

+ + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + +

+ +

+ + push + ax + +

+ +

+ + mov + bx, + dx + +

+ +

+ + mov + dl, + U50UTPUT_LATCH + +

+ +

+ + mov + al, + [bx] + +

+ +

+ + call + OutputByte + +

+ +

+ + pop + ax + +

+ +

+ + HwSelectChannel + +

+ +

+ + popft + +

+ +

+ + jmp + ExitWithCompletionStatusZero + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + A4ExifSense, + far + +

+
+
+

+ + Reads + the + state + of + the + LEDS + and + Switches. + +

+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 7Select + our + SIBO + + + ; + serial + channel + + + 7Store + old + channel + +

+
+
+

+ + ;DX + (now + BX) + points + + + ;to + the + value + to + + + output + to + our + + + ;peripheral + +

+ +

+ + ;Return + old + channel + +

+
+
+

+ + ;To + signal + completion + +

+
+
+

+ + 7of + set + request + +

+
+
+

+ + Can + be + called + from + PLIB + using + p_iow(pcb, + P_FSENSE, + éArgl, + &Arg2) + +

+
+
+

+ + Where + Argl + and + Arg2 + are + unsigned + bytes. + + + In: + +

+
+
+

+ + Pointer + to + control + block + in + applications + data + space + in + BX + + + Pointer + to + control + block + in + our + CS + space + in + DI + +

+
+
+

+ + Al + (pointer + to + Argl) + in + DX + +

+
+
+
+
+

+ + Out: + + + Jumps + to + common + exit + point + + + pushf + + + cli + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + push + ax + + + mov + bx, + dx + + + mov + dl, + U4STATUS_BUFFER + + + call + InputByte + + + mov + [bx], + al + + + mov + bx, + [si] + .RqA2Ptr + + + mov + dl, + U3INPUT_BUFFER + + + call + InputByte + + + mov + [bx], + al + + + pop + ax + + + HwSelectChannel + + + popft + + + jmp + ExitWithCompletionStatusZero + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + LOCAL + DEVICE + DRIVER + FUNCTIONS + +

+
+
+
+

+ + 7Select + our + SIBO + + + ;serial + channel + + + 7 + Store + old + channel + +

+
+
+

+ + ;DX + (now + BX) + points + + + ;to + the + variable + in + + + ;which + to + place + the + + + ;value + read + from + U4. + + + 7BX + now + points + to + +

+ +

+ + ;the + variable + in + +

+ +

+ + ;which + to + place + the + + + ;value + read + from + U3. + +

+
+
+

+ + ;Return + old + channel + +

+
+
+

+ + ;To + signal + completion + +

+
+
+

+ + ;of + a + sense + request + +

+
+
+

+ + Interrupts + must + be + off + prior + to + the + call + to + this + function. + +

+
+
+

+ + IN: + +

+
+
+

+ + DL + has + address + to + which + Asic4 + is + to + write + +

+
+
+

+ + AL + holds + the + value + to + output + +

+
+
+

+ + mov + al, + (SerialWriteSingle + or + A4Address) + +

+
+
+

+ + SBUSY + + + SCONTOUT + + + mov + al, + dl + + + SBUSY + + + SDATAOUT + + + mov + al, + (SerialReadSingle + or + A4Data) + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + SBUSY + +

+ +

+ + SDATAIN + +

+ +

+ + ret + +

+ +

+ + ProcEnd + noret + +

+
+
+
+
+
+

+ + ProcBegin@ + OutputByte + +

+
+
+

+ + Interrupts + must + be + off + prior + to + the + call + to + this + function. + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 96 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + H + IN: + + + ; + DL + has + address + to + which + Asic4 + is + to + write + + + ; + AL + has + the + value + to + output + +

+
+
+

+ + mov + al, + (SerialWriteSingle + or + A4Address) + +

+
+
+

+ + mov + al, + dl + +

+
+
+
+

+ + mov + al, + (SerialWriteSingle + or + A4Data) + + + SBUSY + + + SCONTOUT + + + SBUSY + + + XNOP + + + pop + ax + + + SDATAOUT + + + ret + + + ProcEnd + noret + +

+
+
+
+
+
+
+
+

+ + ProcBegin@ + IntVecO, + far + +

+
+
+

+ + - + Interrupt + on + serial + channel0 + + + 3 + Calls + Comint + with + channel + control + block + pointer + in + DI + + + , + +

+ +

+ + mov + di, + offset + Channel0O + +

+ +

+ + jmp + ComIint + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + if + Corporate + or + S3c + + + ProcBegin@ + IntVecl1, + far + +

+
+
+

+ + Sat + +

+
+
+

+ + Interrupt + on + serial + channell + +

+
+
+

+ + ; + Calls + Comint + with + channel + control + block + pointer + in + DI + + + , + +

+ +

+ + mov + di, + offset + Channell + +

+ +

+ + jmp + ComInt + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + IntVec2,far + +

+
+
+

+ + Interrupt + on + serial + channel2 + + + Calls + Comint + with + channel + control + block + pointer + in + DI + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + mov + di, + offset + Channel2 + + + 7 + FALL + THROUGH + + + ProcEnd + noret + + + endif + + + ProcBegin@ + ComInt, + far + + + , + + + ; + The + common + interrupt + service + routine + code. + + + ; + When + an + interrupt + occurs, + the + first + task + is + to + read + the + status + + + 7 + buffer + of + latch + U4. + The + subsequent + action + is + dependent + on + the + + + ; + postion + of + switches + Sl + and + S2. + For + the + purposes + of + this + example, + + + ; + the + four + posibilities + for + the + switch + values + correspond + somewhat + + + ; + arbitrarily + to + four + different + byte + values + that + are + written + to + U5. + + + ; + in + the + 8086, + interrupts + cannot + occur + while + in + an + interrupt + routine. + + + ; + If + an + asynchronous + read + is + pending + then + the + handler + is + signalled. + + + 7 + IN: + + + ; + Channel's + CS + based + control + block + pointer + in + DI + + + , + + + cmp + cs: + [di] + .A4ExifCSChanReadCompleted, + 2 + ;Only + if + 2 + do + we + have + + + jne + NotAsynchronousRead + ;asynch + read + completed + + + mov + cs: + [di] + .A4ExifCSChanReadCompleted, + 1 + + + mov + bx, + cs: + [di] + .A4ExifCSProcessId + ;Signals + completion + + + ToSignalByPidNoReSched + 7Of + read + to + OS + so + as + + + NotAsynchronousRead: + ;to + invoke + handler + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + push + ax + + + mov + dl, + U3INPUT_BUFFER + + + call + InputByte + + + mov + cs: + [di] + .A4ExifCSA2Value, + al + ;LED + byte + + + mov + dl, + U4STATUS_BUFFER + +

+
+
+

+ + Revision + 1.00 + Page + 97 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+
+
+
+

+ + call + InputByte + + + mov + cs: + [di] + .A4ExifCSAlValue, + al + ; + Status + byte + + + and + al, + INTERRUPT_STATUS_MASK + + + xchg + al, + SwitchStatus + + + cmp + SwitchStatus, + S2S3_ON + 7;S2 + and + S3 + on + => + turn + + + je + A11LEDsOn + 7on + alternate + LEDs + + + cmp + SwitchStatus, + S2S3_OFF + 7S2 + and + S3 + off + => + not + + + je + A11LEDsOff + ;the + alternate + LEDs + + + cmp + SwitchStatus, + S2_ONLY + 782 + on, + S3 + off + => + turn + + + je + TopLEDsOn + 7on + top + four + LEDs + + + cmp + SwitchStatus, + S3_ONLY + 753 + on, + S2 + off + => + turn + + + je + BottomLEDsOn + 7on + bottom + four + LEDs + + + ErroriInSwitchStatusByte: + + + jmp + ClearInterruptAndReschedule + + + A11LEDsOn: + + + mov + al, + SOME_LEDS_ON + + + jmp + Output + LEDByte + + + A11LEDsOff: + + + mov + al, + SOME_LEDS_OFF + + + jmp + Output + LEDByte + + + TopLEDsOn: + + + mov + al, + TOP_LEDS_ON + + + jmp + Output + LEDByte + + + BottomLEDsOn: + + + mov + al, + BOTTOM_LEDS_ON + + + OutputLEDByte: + + + mov + dl, + US50UTPUT_LATCH + + + call + OutputByte + + + ClearInterruptAndReschedule: + + + mov + dl, + INTERRUPT_LATCH + + + call + OutputByte + + + if + Asic9 + ;A + write + to + this + location + + + out + A9BNonSpecificEoiw, + al + ;informs + the + interrupt + + + else + ;controller + that + the + + + out + AlNonSpecificEoi, + al + ;installed + interrupt + + + endif + ;service + routine + has + + + pop + ax + ; + finished + + + HwSelectChannel + + + onlkres + ;Reschedule + if + necessary + + + ret + + + ProcEnd + noret + + + ProcBegin@ + StartInterrupts + + + po + SSS + SES + + + ; + Start + interrupts + assuming + interrupts + are + + + ; + off + prior + to + call. + + + ; + The + EPOC + GenSetRevector + service + loads + in + + + ; + a + user-specified + interrupt + service + routine + + + ; + located + at + the + address + given + in + cx:bx + + + ; + (segment + cx, + offset + bx) + for + the + interrupt + + + ; + vector + number + given + in + AL. + Note + that + the + + + 7 + variable + A4ExifCSChannelIntVec + holds + the + + + ; + name + of + the + appropriate + required + interrupt + + + ; + vector + routine + for + the + channel. + + + H + IN: + + + ; + Our + CS + control + block + pointer + in + DI + + + H + OUT: + + + i; + Nothing + + + is + + + mov + al, + cs: + [di] + .-A4ExifCSChannelIntNum + 7Get + the + OS + to + call + + + mov + cx, + CS + ;the + function + in + + + push + bx + 7CS:BX + every + time + + + mov + bx, + cs: + [di] + .A4ExifCSChannelIntVec + ;that + the + interrupt + + + GenSetRevector + ;whose + number + is + in + + + pop + bx + 7;AL + occurs + + + ife + Asic9 + + + in + al, + AlInterruptMask + + + or + al, + cs: + [di] + .A4ExifCSChannelIntMask + ;Set + the + mask + + + out + AlInterruptMask, + al + ;location + so + as + + + ; + interrupt + + + else + ;to + enable + that + + + in + al, + A9BInterruptMaskRW + ; + interrupt + + + or + al, + cs: + [di] + .A4ExifCSChannelIntMask + + + out + A9BInterruptMaskRW, + al + + + endif + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + Revision + 1.00 + Page + 98 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + ProcBegin@ + StopInterrupts + +

+
+
+

+ + ; + Stop + interrupts + assuming + that + interrupts + are + off + +

+
+
+

+ + The + EPOC + GenResetRevector + OS + service + +

+
+
+

+ + interrupt + service + routine + with + the + original + + + routine + and + interrupt + mask + for + the + vector + + + given + in + AL. + + + IN: + +

+ +

+ + Our + CS + control + block + pointer + in + DI + +

+
+
+

+ + Se + ee + Te + +

+
+
+

+ + OUT: + + + ; + Nothing + +

+
+
+

+ + ife + Asic9 + +

+
+
+
+
+
+

+ + replaces + the + previously + loaded + user-specified + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + in + al, + AlInterruptMask + ;Disable + the + + + mov + ah, + cs: + [di] + .A4ExifCSChannelIntMask + ; + interrupt + + + not + ah + + + and + al, + ah + + + out + AlInterruptMask, + al + + + else + + + in + al, + A9BInterruptMaskRW + + + mov + ah, + cs: + [di] + .A4ExifCSChannelIntMask + + + not + ah + + + and + al, + ah + + + out + A9BInterruptMaskRW, + al + + + endif + + + mov + al, + cs: + [di] + .-A4ExifCSChannelIntNum + ;Return + the + interrupt + + + GenResetRevector + ;vector + to + the + OS + + + ret + ; + default + + + ProcEnd + noret + + + ProcBegin@ + StartTheChannelRunning + + + Fo + eee + eeeeeeea= + + + ; + Starts + the + hardware + and + interrupts + going + + + ; + If + the + hardware + is + aready + running + then + there + is + nothing + to + do + + + ; + Must + check + that + the + hardware + has + not + vanished + before + restarting + it + + + H + IN: + + + ; + Our + CS + control + block + pointer + in + DI + + + 7 + OUT: + + + i + Nothing + + + 7 + + + pushf + + + cli + + + cmp + byte + ptr + cs: + [di].A4ExifCSChannelRunning, + 0 + + + jne + ChannelAlreadyRunning + + + call + CheckHardwarePresent + + + jc + HardwareNotPresent + + + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + + + HwSelectChannel + + + push + ax + + + mov + al, + (SerialWriteSingle + or + A4Control) + ; + Switch + on + the + + + SBUSY + output + latch + U5 + + + SCONTOUT + ;by + asserting + + + mov + al, + U5_ENABLE_ON + ;the + ASIC4 + LBO + line + + + SBUSY + ; + (LBO + is + inverted) + + + SDATAOUT + + + xor + ax,ax + + + mov + dl, + INTERRUPT_LATCH + 7Clear + any + pending + + + call + OutputByte + ;interrupt + on + the + + + mov + dl, + US5OUTPUT_LATCH + ;peripheral + + + call + OutputByte + 7Preset + the + LEDs + + + pop + ax + ;to + all + off + + + HwSelectChannel + + + call + StartInterrupts + + + mov + cs: + [di] + .A4ExifCSChannelRunning, + 1 + + + ChannelAlreadyRunning: + + + popft + + + cle + + + ret + + + HardwareNotPresent: + + + popft + + + stc + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + StopTheChannelRunning + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 99 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + Stops + the + hardware + and + interrupts + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Checks + to + see + if + the + hardware + is + really + running + to + start + with + +

+
+
+
+

+ + IN: + + + Our + CS + control + block + pointer + in + DI + +

+ +

+ + i + OUT: + + + ; + Nothing + + + 7 + +

+ +

+ + pushf + +

+ +

+ + cli + +

+ +

+ + cmp + byte + ptr + cs:[di].A4ExifCSChannelRunning, + 0 + +

+ +

+ + je + ChannelNotRunning + +

+ +

+ + mov + al, + cs: + [di] + .-A4ExifCSChannelSelect + +

+ +

+ + HwSelectChannel + +

+ +

+ + push + ax + +

+ +

+ + mov + al, + (SerialWriteSingle + or + A4Control) + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + mov + al, + U5_ENABLE_OFF + +

+ +

+ + SBUSY + +

+ +

+ + SDATAOUT + +

+ +

+ + xor + ax, + ax + +

+ +

+ + mov + dl, + US50OUTPUT_LATCH + +

+ +

+ + call + OutputByte + +

+ +

+ + pop + ax + +

+ +

+ + HwSelectChannel + +

+ +

+ + call + StopInterrupts + +

+ +

+ + mov + cs: + [di] + .A4ExifCSChannelRunning, + 0 + + + ChannelNotRunning: + +

+ +

+ + popft + +

+ +

+ + ret + +

+
+
+

+ + Se + eT + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + CheckHardwarePresent + +

+
+
+
+

+ + Used + to + determine + whether + the + correct + hardware + is + present + +

+
+
+

+ + on + the + successfully + procured + serial + channel. + +

+
+
+

+ + IN: + +

+ +

+ + CS + control + block + pointer + in + DI + + + OUT: + +

+ +

+ + Carry + clear + - + correct + hardware + is + there + +

+ +

+ + Carry + set + - + wrong + or + no + hardware + + + pushf + + + cli + ;Select + the + correct + + + mov + al, + cs: + [di] + .A4ExifCSChannelSelect + ;SIBO + channel + that + + + HwSelectChannel + ;the + peripheral + is + + + push + ax + ;attached + to + + + HwNullFrame + + + mov + al, + (SerialSelect + or + Asic4Id) + + + SBUSY + ;First + look + for + an + + + SCONTOUT + 7;ASIC4 + at + the + other + + + XNOP + ;end + of + the + link + + + SBUSY + + + SDATAIN + ;Ilf + the + returned + + + test + al,al + ;value + is + non-zero + + + je + ConnectionFailedA4NotPresent + ;we + have + an + ASIC4 + + + mov + al, + (SerialReadSingle + or + A4InfoR) + + + SBUSY + ;Now + see + if + we + have + + + SCONTOUT + ;the + right + peripheral + + + XNOP + 7;XNOP + allows + the + busy + + + SBUSY + 7Signal + to + come + + + SDATAIN + ;through + for + the + wait + + + and + al, + A4PERIPH_MASK + + + cmp + al, + EXTENDED_INFO_BYTE + ;Mask + out + the + bottom + + + jne + ConnectionFailed + ;four + bits + as + the + + + pop + ax + yupper + four + contain + + + HwSelectChannel + ;the + peripheral + ID + + + popft + + + cle + ;If + it + is + our + hardware + + + ret + 7exit + with + carry + clear + +

+ +

+ + ConnectionFailedA4NotPresent: + +

+ +

+ + mov + al, + (SerialSelect + or + Asic5Normalld) + ;Its + not + an + ASIC4 + + + SBUSY + ;peripheral + + + SCONTOUT + 7By + selecting + a + non + + + XNOP + 7;ASIC4 + as + an + ASIC4, + + + SDATAIN + ;we + effectively + +

+
+
+

+ + test + al,al + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + ;disable + whatever + is + +

+
+
+

+ + Page + 100 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + jne + ConnectionFailed + yout + there + so + we + do + + + mov + al, + (SerialSelect + or + Asic5PackId) + ja + select + for + all + + + SBUSY + ;possibilities + so + + + SCONTOUT + ;that + we + don't + end + + + XNOP + ;up + disabling + + + SDATAIN + yanything + that + we + +

+
+
+

+ + test + al,al + ;can't + control. + + + jne + ConnectionFailed + +

+
+
+

+ + mov + al, + (SerialSelect + or + Asic8Id) + 7Modem + chip + id + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + XNOP + +

+ +

+ + SDATAIN + + + ConnectionFailed: + +

+ +

+ + pop + ax + +

+ +

+ + HwSelectChannel + +

+ +

+ + popft + +

+ +

+ + stc + +

+ +

+ + ret + +

+ +

+ + ProcEnd + noret + +

+
+
+

+ + EndCodeSeg + +

+ +

+ + stack + segment + stack + para + 'data' + + + stack + ends + +

+ +

+ + end + A4ExifLDD + +

+
+
+

+ + Revision + 1.00 + Page + 101 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + SYSS$AS5.ASM + +

+
+
+

+ + title + ASSPDD + Epoc + Serial + physical + device + driver + for + the + 16550 + + + subttl + Copyright + Psion + PLC + 1993 + + + name + SYSSAS5 + +

+ +

+ + i + VERSION + DATE + DESCRIPTION + +

+ +

+ + me + MEE + ee + ee + ee + eee + +

+ +

+ + ; + Lat + 08/12/94 + Initial + version + +

+ +

+ + 7 + Written + by + Jason + December + 1994 + +

+ +

+ + : + Serial + Driver + for + Epoc + based + around + ASIC5 + +

+ +

+ + Sr5s3 + = + 0 + +

+ +

+ + Sr5S3a + = + 1 + +

+ +

+ + ifdef + BUILDS3 + +

+ +

+ + Sr5S3 + = + 1. + +

+ +

+ + Sr5S3a + = + 0 + +

+ +

+ + BUILDHH + equ + 1 + +

+ +

+ + endif + +

+ +

+ + a + Sr5S3a + +

+ +

+ + BUILDSB + equ + 1 + +

+ +

+ + endif + + + include + ..\inc\epoc.inc + + + include + ..\inc\epocser.inc + + + include + ..\inc\epoclib.inc + + + include + ..\inc\epocsibo.inc + + + include + ..\srcs\ossibo.inc + + + include + ..\srces\ospack.inc + +

+
+
+

+ + Sr5ChannelStruct + struc + +

+
+
+
+

+ + Sr50pen + db + ? + ; + Is + the + channel + open + + + SrKSCtY1L + db + ? + ; + State + of + control + lines + + + Sr5IntVector + db + 2 + ; + The + Vector + number + + + Sr5Channel + db + ? + ; + Which + channel + are + we + + + Sr5Mask + db + ? + ; + InterruptMask + + + Sr5Running + db + ; + Are + we + running + + + Sr5IntRoutineVec + dw + cs + ; + Vector + to + Interrupt + + + Sr5Baud + dw + ? + ; + The + baud + rate + + + Sr5LddData + dw + ? + ; + Info + from + Ldd + above + + + Sr5StatusInt + dd + ? + ; + Vectors + in + serial + + + Sr5Recvint + dd + 2 + ; + Above + to + be + called + + + Sr5XmitInt + dd + ? + ; + On + input/output + + + Sr5ClockEnable + db + ? + ; + Reason + to + stop + +

+ +

+ + Sr5TheLines + db + ? + ; + State + of + the + modem + lines + +

+
+
+

+ + Sr5ChannelStruct + ends + +

+
+
+

+ + A5Ent + struc + + + A5PortA + + + A5PortB + + + A5PortBMode + + + A5PortD + + + A5Swipel + + + A5Swipe2 + + + A5IntMask + + + A5CtrlReg + + + A5USR + + + A5RHR + + + A5BDLSB + + + A5SBDMSB + + + A5MCRIEoi + + + A5MCRPresentEoi + + + A5MCR2Eoi + + + ASDUMMYF + +

+ +

+ + A5Ent + ends + +

+
+
+

+ + Lt + Consumer + + + NumberOfChannels + + + else + + + NumberOfChannels + + + endif + + + OsActivityMeter + + + StopTimeOut + +

+
+
+

+ + S_RS2320N + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + db + + + db + + + db + + + db + + + db + + + db + + + db + + + db + +

+
+
+

+ + db + + + db + +

+
+
+

+ + db + + + db + + + db + + + db + + + db + + + db + +

+
+
+

+ + equ + +

+
+
+

+ + equ + +

+
+
+

+ + equ + +

+
+
+

+ + equ + +

+
+
+

+ + equ + +

+
+
+

+ + VVV + Vv + vw + +

+
+
+

+ + YN + vn + vv + +

+
+
+

+ + 158ch + + + 1000 + +

+
+
+

+ + 00000001b + +

+
+
+

+ + at + +

+
+
+

+ + ASIC5 + Read/Write + + + Port + A + R/W + +

+ +

+ + Port + B + R/W + + + Inc/Mode + +

+ +

+ + Port + CD + Write + only + +

+
+
+

+ + Ne + Ne + Ne + Ne + Ne + +

+
+
+

+ + Interrupt + mask + R/W + + + IntType/Ctrl + register + + + UART + Status/Ctrl + + + Receive/Transmit + +

+ +

+ + Baud + Rate + write + only + + + Baud + Rate + write + only + + + MCR + shift + register + + + Barcode + data&ints + +

+
+
+

+ + + + + + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + ; + S3 + Single + Channel + + + , + HC,S3C + Three + Channel + +

+
+
+

+ + ; + Activity + Channel + + + ; + w~ls + (1000ms) + wait + +

+
+
+

+ + 7 + RS232 + on + +

+
+
+

+ + Page + 102 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + S_RSTTLON + equ + 00000100b + ; + Line + drivers + on + + + S_CENTON + equ + 00010000b + ; + Line + drivers + enable + + + S_RXENB + equ + 00000001b + ; + Receive + interrupt + on + + + S_TXENB + equ + 00000010b + ; + Transmit + interrupt + on + + + S_TXEMPTY + equ + 00010000b + ; + transmit + buffer + empty + + + S_RXINT + equ + 00000001b + ; + Receive + interrupt? + + + S_TXINT + equ + 00000010b + ; + transmit + interrupt? + + + S_MDINT + equ + 00000100b + ; + Modem + status + interrupt + + + S_CTS + equ + 00000001b + # + CLS + + + S_RTS + equ + 00000010b + ; + RTS + + + S_DCD + equ + 00000100b + DCD + + + S_DSR + equ + 00000010b + ; + DCR + + + S_DTR + equ + 00000100b + ; + DIR + + + OVERRUN_ERROR + equ + 01000000b + ; + Character + overrun + + + PARITY_ERROR + equ + 10000000b + ; + Parity + error + + + S_PERIPHERALMODE + equ + 00000011b + ; + ASIC5 + RS232 + mode + + + S_UART_OFF + equ + 00000010b + ; + ASIC5 + peripheral + mode + + + dgroup + group + stack + + + assume + ds:dgroup,es:dgroup,ss:dgroup + + + CodeSeg + + + ProcBegin@ + OsAS5PDD + + + ; + SiS + SeSe + Sees + Ses + eceses + + + dw + PDDSignature + + + db + 'TTY.SR5',0 + + + dw + (VectorEnd-Vector) + /2 + + + Vector: + + + dw + OsAS5SInstall + + + dw + OsAS5Remove + + + dw + OsAS50Open + + + dw + OsAS5Strategy + + + VectorEnd: + +

+
+
+

+ + BaudRateTable + dw + +

+
+
+

+ + -077f£h, + -04£fh, + -0368h, + -02cch, + -027£h, + -013fh + +

+
+
+

+ + dw + -009fh, + -004fh, + -0035h, + -0030h, + -0027h, + -0019h + + + dw + -—0013h, + -000ch, + -0009h, + -0004h + +

+
+
+

+ + DataBitsTable + db + 0,2,4,6 + +

+
+
+

+ + + +

+
+
+

+ + 5,6,7,8 + bits + per + char + frame + +

+
+
+

+ + ParityTable + db + 08h,18h, + 0h, + 0h + ; + Even,Odd,Mark, + Space + parity + + + Chan0O + Sr5ChannelStruct + <> + + + Chanl + Sr5ChannelStruct + <> + + + Chan2 + Sr5ChannelStruct + <> + +

+
+
+

+ + if + Consumer + +

+
+
+
+
+
+
+
+
+
+

+ + if + Asic9 + + + SetupTable + dw + offset + AS5Int1l + + + db + HwIrq2Revector,mask + A9MSlave + + + db + SelectChannel5, + (mask + A9MClockEnable5 + shr + 8) + + + else + + + SetupTable + dw + offset + AS5Intl + + + db + HwIrq4Revector,mask + Asic2Int + + + db + SelectChannel7, + (mask + ClockEnable7 + shr + 8) + + + endif + + + else + + + if + Asic9 + + + SetupTable + dw + offset + AS5Int1l + + + db + HwIrq4Revector,mask + A9MExpIntA + + + db + SelectChannel3, + (mask + A9MClockEnable3 + shr + 8) + + + dw + offset + AS5Int2 + + + db + HwIrq5Revector,mask + A9MExpIntB + + + db + SelectChannel4, + (mask + A9MClockEnable4 + shr + 8) + + + dw + offset + ASSInt3 + + + db + HwIrq2Revector,mask + A9MSlave + + + db + SelectChannel5, + (mask + A9MClockEnable5 + shr + 8) + + + else + + + SetupTable + dw + offset + AS5Int1l + + + db + HwIrq3Revector,mask + ExpIntLeftA + + + db + ExpChannelLeftA, + (mask + ClockEnableé + shr + 8) + + + dw + offset + AS5Int2 + + + db + HwIlrq2Revector,mask + ExpIntRightB + + + db + ExpChannelRightB, + (mask + ClockEnable5 + shr + 8) + + + dw + offset + AS5Int3 + + + db + HwIrq4Revector,mask + Asic2Int + + + db + SelectChannel7, + (mask + ClockEnable7 + shr + 8) + + + endif + + + endif + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 103 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + ProcBegin@ + OsAS5Install, + far + +

+
+
+

+ + Install + the + device + driver + + + Out: + Carry + clear + -happy + to + install + +

+
+
+
+
+
+

+ + cld + + + mov + cx, + NumberOfChannels + + + mov + di, + offset + Chan0od + + + mov + si, + offset + SetupTable + + + pushf + + + cli + + + push + ds + + + mov + ax, + Cs + + + mov + ds, + ax + + + ResetAllChannelsLoop: + + + mov + di].Sr50pen, + 0 + + + lodsw + + + mov + di].Sr5IntRoutineVec, + ax + + + lodsb + + + mov + di].Sr5IntVector, + al + + + lodsb + + + mov + di].Sr5Mask, + al + + + lodsb + + + mov + di].Sr5Channel, + al + + + lodsb + + + mov + di].Sr5ClockEnable, + al + + + add + di, + size + Sr5ChannelStruct + + + loop + ResetAllChannelsLoop + + + pop + ds + + + popft + + + AllChannelsOkay: + + + cle + + + ret + +

+
+
+

+ + Mee + Ne + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + GotChan: + +

+
+
+

+ + Revision + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + OsAS5Remove, + far + +

+
+
+

+ + Remove + the + device + driver + + + Out: + Carry + clear + -happy + to + remove + +

+
+
+

+ + + + + + +

+
+
+

+ + ~ + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Clear + the + channels + + + and + set + up + fixed + + + parameters + such + +

+ +

+ + as + the + interrupt + + + vectors + and + masks + + + for + each + channel + +

+
+
+

+ + Channel + not + open + +

+
+
+

+ + Set + the + interrupt + + + handler + to + call + + + hich + Interrupt + +

+
+
+

+ + = + +

+
+
+

+ + Mask + for + that + + + interrupt + +

+ +

+ + Which + Psion + serial + + + channel + +

+ +

+ + Baud + rate + clocking + + + enable + +

+
+
+
+

+ + Returns + with + + + Carry + clear + +

+
+
+

+ + Carry + set + -we + have + an + open + channel + and + cant + be + removed. + +

+
+
+

+ + xor + ax, + ax + + + or + al, + Chan0O.Sr50pen + + + or + al, + Chanl.Sr50pen + + + or + al, + Chan2.Sr50pen + + + jz + AllChannelsOkay + + + mov + ax, + InUseErr + +

+ +

+ + stc + +

+ +

+ + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + OsAS5Open, + far + +

+
+
+

+ + Open + a + serial + channel + +

+
+
+

+ + see + +

+
+
+

+ + In: + SS:SI + is + a + pointer + to + the + open + Ent + Structure + +

+
+
+

+ + Out: + Carry + clear, + control + block + in + BX + +

+
+
+

+ + Carry + set, + error + in + AX + +

+
+
+
+

+ + cld + +

+ +

+ + mov + si, + [si] + .OpenNamePtr + + + mov + al, + [sitl] + + + CharToFoldedChar + +

+ +

+ + cmp + al, + 'A' + +

+ +

+ + jb + ErrorInOpen + +

+ +

+ + sub + al, + ‘'A' + +

+ +

+ + cmp + al, + NumberOfChannels + + + jae + ErrorInOpen + +

+ +

+ + xoOr + ah, + ah + +

+ +

+ + mov + bx, + offset + Chan0O + +

+ +

+ + cmp + al, + 1 + +

+ +

+ + jb + GotChan + +

+ +

+ + mov + bx, + offset + Chan2 + +

+ +

+ + ja + GotChan + +

+ +

+ + mov + bx, + offset + Chanl + +

+ +

+ + mov + al, + 1 + +

+ +

+ + 1.00 + +

+
+
+

+ + If + we + have + a + + + channel + Still + open + + + then + return + a + can't + + + do + error + else + + + complete + okay + +

+
+
+

+ + Open + the + channel + + + Get + the + channel + + + Make + Upper + Case + + + Indicator + which + is + + + Part + of + the + name + + + Should + be + A,B,C + +

+
+
+

+ + What + Channel + are + + + We + Openning + + + Pointer + to + Control + + + Block + in + bx + +

+
+
+

+ + Page + 104 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + xchg + al, + cs: + [bx].Sr50Open + + + cmp + al, + 0 + + + je + OkayToOpen + + + CantOpen: + + + mov + ax, + InUseErr + + + CantOpenDiffErr: + + + stc + + + ret + + + ErroriInOpen: + + + mov + ax, + NameErr + + + stc + + + ret + + + OkayToOpen: + + + xor + al, + al + + + mov + cs: + [bx].Sr5Running, + al + + + mov + cs: + [bx].Sr5TheLines, + al + + + mov + cs: + [bx].Sr5Ctrl, + al + + + mov + al, + cs: + [bx].Sr5Mask + + + HwGetChannel + + + jc + CantOpenSoClose + + + call + CheckHardwarePresent + + + jne + OpenedOkay + + + mov + al, + cs: + [bx].Sr5Mask + + + HwF + reeChannel + + + CantOpenSoClose: + + + mov + cs: + [bx].Sr50pen, + 0 + + + mov + ax, + DeviceErr + + + jmp + short + CantOpenDiffErr + + + OpenedOkay: + + + xor + ax, + ax + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + AS5StrategyJumpTable + label + word + +

+
+
+

+ + dw + offset + AS50Open + +

+ +

+ + dw + offset + AS5Close + +

+ +

+ + dw + offset + AS5Start + + + channel + +

+ +

+ + dw + offset + AS5Stop + +

+ +

+ + dw + offset + AS5Set + +

+ +

+ + dw + offset + AS5Sense + +

+ +

+ + dw + offset + AS5Control + +

+ +

+ + dw + offset + ASS5Enquire + +

+ +

+ + dw + offset + AS5Enable + +

+ +

+ + dw + offset + AS5SetHandlerCs + +

+
+
+

+ + ProcBegin@ + OsAS5Strategy, + far + +

+
+
+

+ + Strategy + functions + entry + point + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + 7 + Now + try + to + Open + + + ; + That + channel + +

+
+
+

+ + ; + Check + that + we + have + + + ; + The + right + Hardware + +

+
+
+

+ + Return + with + the + + + Offset + of + our + + + Control + Block + + + In + bx + +

+
+
+

+ + Ne + Ne + Ne + Ne + +

+
+
+

+ + ; + Load + Handler + offsets + + + ; + Close + the + channel + + + ; + Start + the + +

+
+
+

+ + 7 + Stop + the + channel + + + ; + Does + nothing + + + ; + Returns + chan + status + + + ; + Drive + the + lines + + + ; + Returns + baud + rate + + + ; + Begin + Output + + + ; + Get + Handler + segments + +

+
+
+

+ + In: + vector + number + in + AX + + + various + data + in + other + registers + +

+
+
+

+ + ; + Select + the + correct + +

+ +

+ + ; + Output + channel + + + Then + Call + the + right + + + Function + to + deal + +

+ +

+ + ; + With + the + strategy + +

+ +

+ + 7; + request + +

+
+
+

+ + + + + + +

+
+
+

+ + ; + Interrupts + off + + + ;, + and + flags + are + on + + + ; + the + stack + +

+
+
+

+ + 7 + + + 7 + Warning! + This + can + be + called + from + within + Interrupt + + + 7 + + + iH + DS + is + OsDataGroup + (and + MUST + be + preserved) + + + ; + Out: + DI + is + pointer + to + control + block + + + H + Old + channel + and + flags + on + stack + +

+ +

+ + cld + +

+ +

+ + mov + bx, + sp + +

+ +

+ + mov + bx, + ss: + [bx+4] + +

+ +

+ + mov + bl, + cs: + [bx].Sr5Channel + +

+ +

+ + xchg + bx, + ax + +

+ +

+ + pushf + +

+ +

+ + cli + +

+ +

+ + HwSelectChannel + +

+ +

+ + mov + ah, + bh + +

+ +

+ + xOr + bh, + bh + +

+ +

+ + push + ax + +

+ +

+ + mov + ax, + di + +

+ +

+ + mov + di, + sp + +

+ +

+ + mov + di, + ss: + [dit+8] + +

+ +

+ + jmp + AS5StrategyJumpTable + [bx] + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Open, + far + +

+
+
+

+ + ; + Old + channel + and + flags + on + the + stack, + + + mov + cs: + [di].Sr5LddData, + cx + + + mov + word + ptr + cs: + [di].Sr5StatusInt, + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + interrupts + off + +

+
+
+

+ + ; + Load + the + offsets + of + +

+
+
+

+ + ax + ; + the + data + send + and + +

+
+
+

+ + Page + 105 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + if + +

+
+
+

+ + else + +

+
+
+

+ + endif + +

+
+
+

+ + mov + word + ptr + cs:[di].Sr5RecvInt, + si + + + mov + word + ptr + cs:[di].Sr5XmitInt, + dx + + + xor + ax, + ax + +

+ +

+ + pop + ax + +

+ +

+ + HwSelectChannel + +

+ +

+ + popft + +

+ +

+ + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Close, + far + +

+
+
+

+ + Old + channel + and + flags + on + the + stack, + +

+
+
+

+ + and + cs:[di].Sr50Open, + 0 + + + mov + al, + cs: + [di].Sr5Mask + + + HwF + reeChannel + +

+ +

+ + pop + ax + +

+ +

+ + HwSelectChannel + +

+ +

+ + popft + +

+ +

+ + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Start, + far + +

+
+
+

+ + Old + channel + and + flags + on + the + stack, + +

+
+
+
+
+
+
+
+
+

+ + call + CheckHardwareFromStart + +

+ +

+ + mov + dx, + 0 + +

+ +

+ + je + CantStartSomethingWhichIsntThere + + + Asic9 + +

+ +

+ + in + ax, + AQWControlExtraRW + +

+ +

+ + or + ah, + cs: + [di].Sr5ClockEnable + +

+ +

+ + out + A9QWControlExtraRW, + ax + +

+ +

+ + mov + al, + cs: + [di].Sr5ClockEnable + + + HwSetA2Control2Bits + +

+ +

+ + mov + al, + SerialWriteSingle + or + A5USR + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + mov + al, + cs: + [di].Sr5Ctrl + +

+ +

+ + SBUSY + +

+ +

+ + SDATAOUT + +

+ +

+ + mov + al, + SerialWriteSingle + or + A5BDLSB + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + mov + al, + byte + ptr + cs: + [di].Sr5Baud + + + SBUSY + +

+ +

+ + SDATAOUT + +

+ +

+ + mov + al, + SerialWriteSingle + or + A5BDMSB + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + mov + al, + byte + ptr + cs: + [dit+1].Sr5Baud + + + SBUSY + +

+ +

+ + SDATAOUT + +

+ +

+ + call + Get + TheInterrupt + +

+ +

+ + xor + CX), + Cx + +

+ +

+ + call + DriveRts + +

+ +

+ + mov + al, + SerialWriteSingle + or + A5CtrlReg + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + mov + al, + (S_CENTON + or + S_RS2320N + or + + + SBUSY + +

+ +

+ + SDATAOUT + +

+ +

+ + mov + cx, + 8 + ; + 8 + ms + +

+ +

+ + pop + dx + +

+ +

+ + call + WaitTimer + +

+ +

+ + push + dx + +

+ +

+ + mov + ah, + (S_RXENB + or + S_TXENB + or + S_MDINT) + + + call + EnableTheInterrupt + +

+ +

+ + mov + cs:[di].Sr5Running, + 1 + +

+ +

+ + mov + bx, + Asic5SerialCurrent + + + HwSetPCurrent + +

+ +

+ + call + Status + +

+
+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + interrupts + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ; + veceive + routines + in + + + ; + the + Ldd + above + us + + + ; + DX=0 + —-We + don't + support + + + 7; + power + management + + + ; + Return + the + old + + + ; + Channel + +

+
+
+

+ + interrupts + off + +

+
+
+

+ + ; + Close + the + Channel + +

+ +

+ + ; + Free + up + our + channel + + + ; + And + the + Hardware + +

+ +

+ + ; + Channel + +

+ +

+ + ; + Return + the + old + +

+ +

+ + ; + channel + +

+
+
+

+ + off + +

+
+
+

+ + ; + Start + the + S3s + clock + + + ; + Generator + +

+
+
+

+ + ; + Set + the + baud + rate + + + ; + and + other + + + ; + Characteristics + +

+
+
+

+ + Get + the + interrupt + + + and + clear + down + +

+ +

+ + the + RTS + line + (DTR + + + stays + at + the + state + + + ; + it + was + set) + +

+
+
+

+ + + + + + +

+
+
+

+ + + + + + +

+
+
+

+ + S_RSTTLON) + +

+
+
+

+ + ; + Switch + on + the + line + + + ; + QGrivers + and + wait + + + ; + for + them + to + power + up + +

+
+
+

+ + ; + Start + all + interrupts + +

+
+
+

+ + Page + 106 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + CantStartSomethingWhichIsntThere: + +

+
+
+

+ + pop + ax + + + HwSelectChannel + + + popft + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Stop, + far + +

+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ; + Return + the + old + + + ; + Channel + +

+
+
+

+ + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + + + xor + CX, + CX + ; + Clear + the + state + of + + + call + DriveRts + ; + the + modem + lines + + + mov + al, + SerialReadSingle + or + A5IntMask + ; + Stop + all + of + the + + + SBUSY + ; + interrupts + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + not + (S_TXENB + or + S_RXENB + or + S_MDINT) + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + pop + ax + + + cmp + dh, + DevHoldPowerFail + + + je + Dont + StopHardware + + + cmp + cs:[di].Sr5Running, + 1 + + + jne + DontWait + + + mov + cx, + StopTimeOut + + + jmp + short + CompareNow + + + WaitForEmpty: + + + call + TickTimer + + + CompareNow: + + + mov + al, + SerialReadSingle + or + A5USR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + al, + S_TXEMPTY + + + loopne + WaitForEmpty + + + DontWait: + + + cmp + bh, + DevHoldNormal + + + je + Dont + StopHardware + + + if + Asic9 + + + mov + cl, + cs: + [di].Sr5ClockEnable + ; + Turn + off + baud + rate + + + not + cl + ; + Clocking + from + the + + + in + ax, + A9WControlExtraRW + } + S3y3a + + + and + ah, + cl + + + out + A9WControlExtraRW, + ax + + + else + + + mov + al, + cs: + [di].Sr5ClockEnable + + + HwClearA2Control2Bits + + + endif + + + mov + al, + SerialWriteSingle + or + A5CtrlReg + ; + Stop + the + drivers + + + SBUSY + , + and + stuff + + + SCONTOUT + + + sub + al, + al + ; + Clear + S_CENTON, + + + SBUSY + 7 + S_RS2320N, + S_RSTTLON + + + SDATAOUT + + + Dont + StopHardware: + + + mov + al, + dl + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + popft + + + xor + bx, + bx + + + HwSetPCurrent + + + ret + + + ProcEnd + noret + + + ProcBegin@ + AS5Set, + far + + + ; + Se + SeSeees + ees + Sees + + + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 107 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+
+
+
+

+ + ; + In: + Information + required + is + on + the + stack + + + pop + ax + + + HwSelectChannel + + + popft + + + mov + ah, + ss:[si].SerialCharTbaud + + + cmp + ah, + ss: + [si] + .SerialCharRbaud + + + jnz + ErrorInSet + + + cmp + ah, + P_BAUD_50 + + + jb + ErroriInSet + + + cmp + ah, + P_BAUD_19200 + + + ja + ErroriInSet + + + Got + TheSpecialBaud: + + + dec + ah + + + mov + cl, + ss:[si].SerialCharFrame + + + mov + al, + ss:[si].SerialCharParity + + + dec + al + + + xor + ch, + ch + + + push + bx + + + test + cl, + P_TWOSTOP + + + jz + OnlyOneStopBit + + + or + ch, + 020h + + + OnlyOneStopBit: + + + test + cl, + P_PARITY + + + jz + NoParity + + + mov + bx, + offset + ParityTable + + + xlat + cs: + [ParityTable] + + + or + ch, + al + + + NoParity: + + + mov + bx, + offset + DataBitsTable + + + and + cl, + P_DATA_FRM + + + mov + al, + cl + + + xlat + cs: + [DataBitsTable] + + + Or + ch, + al + + + mov + bx, + offset + BaudRateTable + + + mov + al, + ah + + + xOr + ah, + ah + + + shl + ax, + 1 + + + add + bx, + ax + + + mov + ax, + cs: + [bx] + + + pop + bx + + + mov + es? + [dt] + .Sractrl; + ch + + + mov + cs:[di].Sr5Baud, + ax + + + xOr + al, + al + + + ret + + + ErroriInSet: + + + mov + al, + NotSupportedErr + + + stc + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Sense, + far + +

+
+
+

+ + seo + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + ~ + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Return + the + old + + + channel + +

+
+
+

+ + Set + the + Recieve, + + + Transmit + characteristics + + + First + set + the + Baud + +

+ +

+ + Rate + +

+
+
+

+ + Then + the + number + of + + + Stop + bits + +

+
+
+

+ + The + Parity + +

+
+
+

+ + And + finally + the + + + Number + of + data + bits + + + Per + frame + +

+
+
+

+ + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + + + ; + Out: + The + state + of + the + DCD,CTS,DSR + lines + returned + in + DX + + + call + Status + + + pop + ax + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + popft + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + Status + +

+
+
+

+ + i + Out: + State + of + modem + lines + in + DX + + + mov + al, + SerialReadSingle + or + A5USR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + (S_CTS + or + S_DSR + or + S_DCD) + + + xor + al, + (S_CTS + or + S_DSR + or + S_DCD) + + + xOr + ah, + ah + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + see + +

+
+
+

+ + Get + the + current + + + Modem + status + + + Lines + and + return + + + With + the + result + + + In + dx + +

+
+
+

+ + Get + the + lines + we + want + + + Invert + signals + +

+
+
+

+ + Page + 108 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + mov + ax, + ax + + + ret + + + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Control, + far + +

+
+
+

+ + ; + Old + channel + and + flags + on + the + stack, + interrupts + off + +

+ +

+ + 7 + In: + Lines + to + drive + and + state + to + drive + them + in + DX + + + mov + onl + emo + ie + ; + Set + the + state + of + one + + + test + dh, + P_SRCTRL_DTR + ; + of + the + modem + Lines + + + jz + DriveRtsNow + ; + DH + is + the + line + to + + + call + DriveDtr + ; + Drive + and + DL + is + the + + + pop + ax + ; + Stateto + drive + it + to + + + HwSelectChannel + ; + Return + the + old + + + popft + ; + channel + + + ret + +

+ +

+ + DriveRtsNow: + + + call + DriveRts + + + pop + ax + ; + Return + the + old + + + HwSelectChannel + ; + channel + + + popft + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + DriveDtr + +

+
+
+

+ + mov + ah, + S_DTR + ; + Set/Reset + the + DTR + + + jmp + short + DriveTheLine + ; + Line + + + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + DriveRts + +

+
+
+

+ + mov + ah, + S_RTS + ; + Set/Reset + RTS + + + DriveTheLine: + + + mov + al, + SerialWriteSingle + or + A5PortD + ; + Common + code + to + set + + + SBUSY + ; + and + reset + either + + + SCONTOUT + ; + line + while + + + mov + al, + cs:[di].Sr5TheLines + ; + preserving + the + + + test + cl, + cl + ; + states + of + the + other + + + IZ + ClearLine + ; + lines + + + or + al, + ah + + + jmp + DoTheOutput + + + ClearLine: + + + not + ah + + + and + al, + ah + + + DoTheOutput: + + + mov + cs:[di].Sr5TheLines, + al + + + SBUSY + + + SDATAOUT + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Enquire, + far + +

+
+
+

+ + 7 + Old + channel + and + flags + on + the + stack, + interrupts + off + + + - + Out: + DX,AX + are + the + supported + baud + rates + AX + for + 50 + to + 19200 + DX + for + above + + + ; + CX + says + what + data + bits, + parity, + etc + we + support + + + pop + ax + ; + Return + the + old + + + HwSelectChannel + ; + Channel + + + popf + + + if + Asic9 + + + mov + ax, + —-1 + + + else + + + mov + ax, + O7fffh + + + endif + + + xor + dx, + ax + + + mov + cx, + (Offffh + AND + (NOT + (P_SRINQ_SPLIT + OR + P_SRINQ_PARSPACE + OR + + + P_SRINQ_PARMARK) + ) + ) + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Enable, + far + +

+
+
+

+ + Revision + 1.00 + Page + 109 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + - + Old + channel + and + flags + on + the + stack, + interrupts + off + + + mov + ah, + S_TXENB + ; + Begin + Output + by + + + call + EnableTheInterrupt + ; + enabling + transmit + + + pop + ax + ; + interrupts + + + HwSelectChannel + ; + Return + the + old + + + popft + ; + channel + + + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5SetHandlerCs, + far + +

+
+
+

+ + CX + is + CS + of + above + LDD + +

+
+
+

+ + sew + +

+
+
+

+ + mov + word + ptr + cs: + [di]. + (Sr5StatusInt+2), + cx + + + mov + word + ptr + cs:[di].(Sr5RecvInt+2), + cx + + + mov + word + ptr + cs: + [di]. + (Sr5XmitInt+2), + cx + + + pop + ax + +

+ +

+ + HwSelectChannel + +

+ +

+ + popft + +

+ +

+ + ret + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Int3, + far + +

+
+
+

+ + mov + di, + offset + Chan2 + + + mov + ax, + PortCActive + + + jmp + ComInt + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Int2,far + +

+
+
+

+ + mov + di, + offset + Chanl + + + mov + ax, + PortBActive + + + jmp + ComIint + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + AS5Int1,far + +

+
+
+

+ + mov + di,offset + Chan0 + + + mov + ax, + PortAActive + + + 4 + FALL + THROUGH + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + ComInt, + far + +

+
+
+

+ + The + common + interrupt + handler + + + DS + points + to + OS + data + space + + + DI + is + our + control + block + +

+
+
+
+

+ + Mee + Ne + +

+
+
+

+ + ; + AX + is + the + Active + channel + + + ab + S3b + or + S3c + +

+ +

+ + or + ds: + [OsActivityMeter], + ax + + + endif + +

+ +

+ + mov + al, + cs: + [di].Sr5Channel + +

+ +

+ + HwSelectChannel + +

+ +

+ + push + ax + +

+ +

+ + mov + bx, + cs: + [di].Sr5LddData + + + TheInterruptLoop: + +

+ +

+ + mov + al, + SerialReadSingle + or + A5CtrlReg + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + XNOP + +

+ +

+ + SBUSY + +

+ +

+ + SDATAIN + +

+ +

+ + test + al, + al + +

+ +

+ + je + NothingToDo + + + HaveWeGotAModemStatusLineInterrupt: + +

+ +

+ + test + al, + S_MDINT + +

+ +

+ + 4z + HaveWeGotARecievelInterrupt + +

+ +

+ + mov + al, + SerialReadSingle + or + A5USR + +

+ +

+ + SBUSY + +

+ +

+ + SCONTOUT + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + ~ + +

+
+
+

+ + Mee + Ne + +

+
+
+

+ + Old + channel + and + flags + on + the + stack, + interrupts + off + +

+
+
+

+ + ; + Load + the + Segment + +

+ +

+ + ; + Within + which + the + + + The + Ldd + above + us + + + Return + the + old + + + channel + +

+ +

+ + ; + Resides + +

+
+
+

+ + Channel + 3 + interrupt + + + vector + + + Jumps + to + Comint + +

+
+
+

+ + see + +

+
+
+

+ + ~ + +

+
+
+

+ + Channel + 2 + interrupt + + + vector + + + Jumps + to + Comint + +

+
+
+

+ + seo + +

+
+
+

+ + ~ + +

+
+
+

+ + Channel + 1 + interrupt + + + 7; + vector + +

+ +

+ + ; + Falls + through + +

+ +

+ + 7 + to + Comint + +

+
+
+

+ + ; + Set + active + state + +

+
+
+

+ + ; + Select + our + + + ; + Channel + +

+
+
+

+ + ; + Data + for + LDD + above + + + ; + in + bx + +

+ +

+ + ; + Find + out + what + +

+ +

+ + ; + caused + the + +

+ +

+ + ; + interrupt + +

+
+
+

+ + Page + 110 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + ; + Something + has + been + + + ; + recieved + in + error + +

+
+
+

+ + ; + Establish + the + error + +

+
+
+

+ + ; + Get + the + character + + + ; + in + question + +

+
+
+

+ + ; + invert + signals + +

+
+
+

+ + XNOP + + + SBUSY + + + SDATAIN + + + test + al, + (OVERRUN_ERROR + or + PARITY_ERROR) + + + jz + ModemStatusInterruptOnly + + + push + ax + + + mov + ah, + SERPARITY_ERR + + + test + al, + PARITY_ERROR + + + jnz + IsAParityError + + + mov + ah, + SEROVERRUN_ERR + + + IsAParityError: + + + mov + al, + SerialReadSingle + or + A5RHR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + push + di + + + call + dword + ptr + cs: + [di] + .Sr5RecvInt + + + pop + di + + + pop + ax + + + ModemStatusInterruptOnly: + + + and + ax, + (S_CTS + or + S_DSR + or + S_DCD) + + + xor + al, + (S_CTS + or + S_DSR + or + S_DCD) + + + mov + ax, + ax + + + push + di + + + call + dword + ptr + cs: + [di].Sr5StatusInt + + + pop + di + + + jmp + short + TheInterruptLoop + +

+
+
+

+ + HaveWeGotARecievelInterrupt: + +

+
+
+

+ + ; + AX + has + character + received + +

+
+
+

+ + Resced + if + neccessary + +

+
+
+

+ + ; + Gisable + TX + interrupts + +

+
+
+

+ + test + al, + S_RXINT + + + jz + HaveWeGotATransmitInterrupt + + + mov + al, + SerialReadSingle + or + A5RHR + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + xOr + ah, + ah + + + push + di + + + call + dword + ptr + cs: + [di] + .Sr5RecvInt + + + pop + di + + + jmp + short + TheInterruptLoop + + + HaveWeGotATransmitInterrupt: + + + test + al, + S_TXINT + + + jz + NothingToDo + + + push + di + + + call + dword + ptr + cs: + [di] + .Sr5XmitInt + + + pop + di + + + test + ax, + ax + ; + —-l1 + if + disable + + + js + DisableTransmitInts + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5RHR + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + jmp + TheInterrupt + Loop + + + NothingToDo: + + + if + Asic9 + + + out + A9BNonSpecificEoiwW, + al + + + else + + + out + AlNonSpecificEoi, + al + + + endif + + + pop + ax + + + HwSelectChannel + + + cle + ; + + + ret + + + DisableTransmitInts: + + + mov + al, + SerialReadSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + not + S_TXENB + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Page + 111 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + SCONTOUT + + + mov + + + SBUSY + + + SDATAOUT + + + jmp + TheInterrupt + Loop + + + ProcEnd + noret + +

+
+
+

+ + al, + ah + +

+
+
+

+ + ProcBegin@ + GetTheInterrupt + +

+
+
+

+ + mov + al, + cs:[di].Sr5IntVector + H + + + mov + Cx, + CS + F + + + mov + bx, + cs:[di].Sr5IntRoutineVec + ; + + + GenSetRevector + A + + + ret + , + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + EnableTheInterrupt + +

+
+
+
+
+
+
+
+

+ + mov + al, + SerialReadSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + or + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + if + Asic9 + + + in + al, + A9BInterruptMaskRW + ; + + + or + al, + cs: + [di].Sr5Mask + ; + + + out + A9BInterruptMaskRwW, + al + + + else + + + in + al, + AlInterruptMask + + + or + al, + cs: + [di] + .Sr5Mask + + + out + AlInterruptMask, + al + + + endif + + + ret + + + ProcEnd + noret + + + ProcBegin@ + StopInterrupts + + + ; + StessSeSesee—e-Seeeseeese + + + mov + al, + SerialReadSingle + or + A5IntMask + H + + + SBUSY + ; + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + and + al, + not + (S_RXENB + or + S_TXENB + or + S_MDINT) + + + mov + ah, + al + + + mov + al, + SerialWriteSingle + or + A5IntMask + + + SBUSY + + + SCONTOUT + + + mov + al, + ah + + + SBUSY + + + SDATAOUT + + + mov + ah, + cs: + [di].Sr5Mask + + + not + ah + + + if + Asic9 + + + in + al, + A9BInterruptMaskRW + ; + + + and + al,ah + ; + + + out + A9BInterruptMaskRW, + al + ; + + + else + ; + + + in + al, + AlInterruptMask + + + and + al,ah + + + out + AlInterruptMask, + al + + + endif + + + mov + al, + cs:[di].Sr5IntVector + + + GenResetRevector + + + ret + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Load + the + address + of + + + the + appropriate + + + interrupt + routine + + + into + the + correct + + + vector + +

+
+
+

+ + Set + the + mask + + + to + enable + Interrupts + +

+
+
+

+ + Stop + interrupts + + + from + Asic5 + +

+
+
+

+ + Stop + Interrupts + + + By + clearing + the + +

+
+
+

+ + Mask + and + resetting + + + The + Vector + +

+
+
+

+ + Page + 112 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + +

+
+
+

+ + ProcEnd + noret + +

+
+
+

+ + ProcBegin@ + CheckHardwarePresent + +

+
+
+

+ + mov + al, + cs: + [bx] + .Sr5Channel + + + HwSelectChannel + + + HwNullFrame + + + mov + al, + (SerialSelect + or + Asic5Normalld) + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + al,al + + + je + ConnectionFailed + + + GotConnection: + + + popft + + + ous) + + + ret + + + ConnectionFailed: + + + mov + al, + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + + + jne + + + mov + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + test + + + jne + + + mov + + + SBUSY + + + SCONTOUT + + + XNOP + + + SBUSY + + + SDATAIN + + + ConnectionFailedExit: + + + popft + + + stc + + + ret + + + ProcEnd + noret + +

+
+
+

+ + SerialSelect + or + Asic4Id + +

+
+
+

+ + al, + al + + + ConnectionFailedExit + + + al, + SerialSelect + or + Asic8Id + +

+
+
+

+ + al, + al + + + ConnectionFailedExit + + + al, + SerialSelect + or + Asic5PackId + +

+
+
+

+ + ProcBegin@ + CheckHardwareFromStart + +

+
+
+

+ + pushf + +

+ +

+ + HwNullFrame + +

+ +

+ + mov + al, + (SerialSelect + or + Asic5Normalld) + + + SBUSY + +

+ +

+ + SCONTOUT + +

+ +

+ + XNOP + +

+ +

+ + SBUSY + +

+ +

+ + SDATAIN + +

+ +

+ + test + al,al + +

+ +

+ + je + ConnectionFailed + +

+ +

+ + test + al, + mask + A5MultiDrop + +

+ +

+ + jne + ConnectionFailedExit + +

+ +

+ + popft + + + mov + + + SBUSY + + + SCONTOUT + + + mov + + + SBUSY + + + SDATAOUT + + + cle + +

+ +

+ + ret + + + ProcEnd + noret + +

+
+
+

+ + al, + +

+
+
+

+ + al, + S_PERIPHERALMODE + +

+
+
+

+ + ProcBegin@ + WaitTimer + +

+
+
+

+ + Revision + 1.00 + +

+
+
+

+ + SerialWriteSingle + or + A5PortBMode + +

+
+
+

+ + Ne + Ne + Ne + Ne + te + +

+
+
+

+ + Ne + Ne + Ne + Ne + Ne + +

+
+
+

+ + + +

+
+
+

+ + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Check + that + the + + + ; + Harware + is + there + +

+
+
+

+ + And + that + it + is + what + + + It + should + be + +

+ +

+ + First + look + for + An + + + ASIC4 + at + the + other + + + End + of + the + link + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + + +

+
+
+

+ + Asic4 + Id + +

+
+
+

+ + Modem + chip + Id + +

+
+
+

+ + Asic5Spack + Id + +

+
+
+

+ + Check + that + the + + + Harware + is + there + + + First + look + for + An + + + ASIC5 + at + the + other + + + End + of + the + link + +

+
+
+

+ + + + + + + + + +

+
+
+

+ + If + not + a + 3link + or + + + if + in + multidrop + + + mode + then + we + are + + + in + trouble + +

+
+
+

+ + Put + the + 3Link + in + + + peripheral + mode + +

+
+
+

+ + Page + 113 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + In: + CX + number + of + ms + to + wait + for + + + Channel + store + in + DL + + + Out: + Channel + store + in + DL + +

+
+
+

+ + Wait + for + a + given + +

+
+
+

+ + inc + cx + i + +

+ +

+ + WaitTickLoop: + ; + Number + of + ms + + + call + TickTimer + ; + Plus + one + to + guarantee + + + loop + WaitTickLoop + ; + That + at + least + cx + ms + + + ret + 7 + Go + by + + + ProcEnd + +

+
+
+

+ + WaiterLoop: + +

+
+
+

+ + stack + + + stack + +

+
+
+

+ + ProcBegin@ + TickTimer + +

+
+
+

+ + Uses + writes + down + our + channel + to + simulate + tick + timer + waits + +

+ +

+ + Must + allow + interrupts + so + other + things + can + run + -we + will + be + here + + + for + 1/1000 + of + a + second + and + may + be + called + many + times + + + ChannelStore + in/out + in + DL + +

+
+
+

+ + mov + al, + dl + ; + Return + the + old + + + HwSelectChannel + ; + Channel + +

+ +

+ + mov + ah, + al + + + pushf + +

+ +

+ + sez + +

+ +

+ + push + Cx + +

+ +

+ + mov + cx, + 12 + ims + +

+ +

+ + 128 + frames + =1lms + +

+ +

+ + pushf + about + 12 + times + +

+ +

+ + cli + 7 + round + the + loop + +

+ +

+ + out + ResetWatchDog, + al + +

+ +

+ + mov + al, + ah + +

+ +

+ + HwSelectChannel + +

+ +

+ + mov + dl, + al + ; + Get + Correct + channel + + + mov + al, + (SerialWriteSingle + or + 0) + Do + a + write + to + +

+ +

+ + SBUSY + nowhere + and + +

+ +

+ + SCONTOUT + waste + some + time + +

+
+
+

+ + See + Ne + +

+
+
+

+ + See + Ne + +

+
+
+

+ + SCONTOUT + ; + Do + it + eight + times + +

+
+
+

+ + SBUSY + + + SCONTOUT + + + SBUSY + + + mov + al, + dl + + + HwSelectChannel + + + mov + ah, + al + + + popft + +

+ +

+ + loop + WaiterLoop + + + pop + CX + +

+ +

+ + popft + +

+ +

+ + mov + al, + ah + + + HwSelectChannel + + + mov + dl, + al + + + ret + +

+ +

+ + ProcEnd + +

+
+
+
+
+
+
+
+

+ + Return + the + old + + + channel + +

+
+
+
+

+ + + + + + +

+
+
+

+ + EndCodeSeg + +

+
+
+

+ + segment + stack + para + 'data' + + + ends + +

+
+
+

+ + end + OsAS5PDD + +

+
+
+

+ + Revision + 1.00 + Page + 114 + of + 115 + pages + +

+
+
+ +
+
+

+ + The + Psion + SIBO + Hardware + Development + Kit + Psion + PLC + (c) + May + 1995 + +

+
+
+

+ + Assembler + Macros + +

+
+
+

+ + Excerpts + from + the + include + file + ossibo.inc. + +

+
+
+
+
+
+
+

+ + if + ASIC1 + + + SCONTOUT + macro + + + out + A2SerialControl, + al + + + endm + + + SDATAOUT + macro + + + out + A2SerialData, + al + + + endm + + + SBUSY + macro + + + wait + + + endm + + + SREAD + macro + _REG + + + mov + al, + SerialReadSingle + or + _REG + + + out + A2SerialControl, + al + + + nop + + + SBUSY + + + in + al, + A2SerialData + + + endm + + + SREADM + macro + _REG + + + mov + al, + SerialReadMulti + or + _REG + + + out + A2SerialControl, + al + + + nop + + + SBUSY + + + in + al, + A2SerialData + + + endm + + + SWRITE + macro + _REG,_VAL + + + mov + al, + SerialWriteSingle + or + _REG + + + out + A2SerialControl, + al + + + SBUSY + + + mov + al, + _VAL + + + out + A2SerialData, + al + + + endm + + + SWRITEM + macro + _REG,_VAL + + + mov + al, + SerialWriteMulti, + _REG + + + out + A2SerialControl, + al + + + SBUSY + + + mov + al, + _VAL + + + out + A2SerialData, + al + + + endm + + + endif + + + ach + ASIC9 + + + SCONTOUT + macro + + + out + A9BSerialControlW, + al + + + endm + + + SDATAOUT + macro + + + out + A9BSerialDataRW, + al + + + endm + + + SDATAIN + macro + + + in + al, + A9BSerialDataRW + + + endm + + + SBUSY + macro + + + endm + + + SREAD + macro + _REG + + + mov + al, + SerialReadSingle + or + _REG + + + out + A9BSerialControlwW, + al + + + in + al, + A9BSerialDataRW + + + endm + + + SREADM + macro + _REG + + + mov + al, + SerialReadMulti + or + _REG + + + out + A9BSerialControlwW, + al + + + in + al, + A9BSerialDataRW + + + endm + + + SWRITE + macro + _REG,_VAL + + + mov + al, + SerialWriteSingle + or + _REG + + + out + A9BSerialControlwW, + al + + + mov + al, + _VAL + + + out + A9BSerialDataRW, + al + + + endm + + + SWRITEM + macro + _REG,_VAL + + + mov + al, + SerialWriteMulti + or + _REG + + + out + A9BSerialControlwW, + al + + + mov + al, + _VAL + + + out + A9BSerialDataRW, + al + + + endm + + + endif + +

+
+
+

+ + Revision + 1.00 + Page + 115 + of + 115 + pages + +

+
+
+ + \ No newline at end of file diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr_pageindex.json.gz b/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr_pageindex.json.gz new file mode 100755 index 0000000..e036655 Binary files /dev/null and b/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr_pageindex.json.gz differ diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr_searchtext.txt.gz b/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr_searchtext.txt.gz new file mode 100755 index 0000000..cc8418f Binary files /dev/null and b/code/HDK/Psion SIBO Hardware Development Kit 1.0_hocr_searchtext.txt.gz differ diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_jp2.zip b/code/HDK/Psion SIBO Hardware Development Kit 1.0_jp2.zip new file mode 100755 index 0000000..ae846d4 Binary files /dev/null and b/code/HDK/Psion SIBO Hardware Development Kit 1.0_jp2.zip differ diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_page_numbers.json b/code/HDK/Psion SIBO Hardware Development Kit 1.0_page_numbers.json new file mode 100755 index 0000000..893ca0e --- /dev/null +++ b/code/HDK/Psion SIBO Hardware Development Kit 1.0_page_numbers.json @@ -0,0 +1,834 @@ +{ + "identifier": "psion-sibo-c-sdk", + "format-version": "2", + "archive-hocr-tools-version": "1.1.54", + "confidence": 87, + "pages": [ + { + "leafNum": 0, + "confidence": null, + "pageNumber": "", + "pageProb": null, + "wordConf": null + }, + { + "leafNum": 1, + "confidence": null, + "pageNumber": "", + "pageProb": null, + "wordConf": null + }, + { + "leafNum": 2, + "confidence": null, + "pageNumber": "", + "pageProb": null, + "wordConf": null + }, + { + "leafNum": 3, + "confidence": null, + "pageNumber": "", + "pageProb": null, + "wordConf": null + }, + { + "leafNum": 4, + "confidence": 81, + "pageNumber": "2", + "pageProb": 71, + "wordConf": 96 + }, + { + "leafNum": 5, + "confidence": 97, + "pageNumber": "3", + "pageProb": 87, + "wordConf": 96 + }, + { + "leafNum": 6, + "confidence": 81, + "pageNumber": "4", + "pageProb": 71, + "wordConf": 95 + }, + { + "leafNum": 7, + "confidence": 97, + "pageNumber": "5", + "pageProb": 87, + "wordConf": 96 + }, + { + "leafNum": 8, + "confidence": 81, + "pageNumber": "6", + "pageProb": 71, + "wordConf": 96 + }, + { + "leafNum": 9, + "confidence": 97, + "pageNumber": "7", + "pageProb": 87, + "wordConf": 96 + }, + { + "leafNum": 10, + "confidence": 81, + "pageNumber": "8", + "pageProb": 71, + "wordConf": 96 + }, + { + "leafNum": 11, + "confidence": 97, + "pageNumber": "9", + "pageProb": 87, + "wordConf": 96 + }, + { + "leafNum": 12, + "confidence": 79, + "pageNumber": "10", + "pageProb": 69, + "wordConf": 95 + }, + { + "leafNum": 13, + "confidence": 96, + "pageNumber": "11", + "pageProb": 86, + "wordConf": 87 + }, + { + "leafNum": 14, + "confidence": 78, + "pageNumber": "12", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 15, + "confidence": 96, + "pageNumber": "13", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 16, + "confidence": 78, + "pageNumber": "14", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 17, + "confidence": 96, + "pageNumber": "15", + "pageProb": 86, + "wordConf": 93 + }, + { + "leafNum": 18, + "confidence": 87, + "pageNumber": "16", + "pageProb": 77, + "wordConf": 96 + }, + { + "leafNum": 19, + "confidence": 96, + "pageNumber": "17", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 20, + "confidence": 79, + "pageNumber": "18", + "pageProb": 69, + "wordConf": 96 + }, + { + "leafNum": 21, + "confidence": 96, + "pageNumber": "19", + "pageProb": 86, + "wordConf": 97 + }, + { + "leafNum": 22, + "confidence": 78, + "pageNumber": "20", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 23, + "confidence": 96, + "pageNumber": "21", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 24, + "confidence": 86, + "pageNumber": "22", + "pageProb": 76, + "wordConf": 96 + }, + { + "leafNum": 25, + "confidence": 96, + "pageNumber": "23", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 26, + "confidence": 78, + "pageNumber": "24", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 27, + "confidence": 96, + "pageNumber": "25", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 28, + "confidence": 78, + "pageNumber": "26", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 29, + "confidence": 96, + "pageNumber": "27", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 30, + "confidence": 78, + "pageNumber": "28", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 31, + "confidence": 96, + "pageNumber": "29", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 32, + "confidence": 78, + "pageNumber": "30", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 33, + "confidence": 96, + "pageNumber": "31", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 34, + "confidence": 78, + "pageNumber": "32", + "pageProb": 68, + "wordConf": 97 + }, + { + "leafNum": 35, + "confidence": 96, + "pageNumber": "33", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 36, + "confidence": 78, + "pageNumber": "34", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 37, + "confidence": 96, + "pageNumber": "35", + "pageProb": 86, + "wordConf": 95 + }, + { + "leafNum": 38, + "confidence": 78, + "pageNumber": "36", + "pageProb": 68, + "wordConf": 95 + }, + { + "leafNum": 39, + "confidence": 96, + "pageNumber": "37", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 40, + "confidence": 78, + "pageNumber": "38", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 41, + "confidence": 96, + "pageNumber": "39", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 42, + "confidence": 78, + "pageNumber": "40", + "pageProb": 68, + "wordConf": 95 + }, + { + "leafNum": 43, + "confidence": 96, + "pageNumber": "41", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 44, + "confidence": 78, + "pageNumber": "42", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 45, + "confidence": 96, + "pageNumber": "43", + "pageProb": 86, + "wordConf": 95 + }, + { + "leafNum": 46, + "confidence": 78, + "pageNumber": "44", + "pageProb": 68, + "wordConf": 95 + }, + { + "leafNum": 47, + "confidence": 96, + "pageNumber": "45", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 48, + "confidence": 78, + "pageNumber": "46", + "pageProb": 68, + "wordConf": 95 + }, + { + "leafNum": 49, + "confidence": 96, + "pageNumber": "47", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 50, + "confidence": 78, + "pageNumber": "48", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 51, + "confidence": 96, + "pageNumber": "49", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 52, + "confidence": 78, + "pageNumber": "50", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 53, + "confidence": 96, + "pageNumber": "51", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 54, + "confidence": 78, + "pageNumber": "52", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 55, + "confidence": 96, + "pageNumber": "53", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 56, + "confidence": 78, + "pageNumber": "54", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 57, + "confidence": 96, + "pageNumber": "55", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 58, + "confidence": 78, + "pageNumber": "56", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 59, + "confidence": 96, + "pageNumber": "57", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 60, + "confidence": 78, + "pageNumber": "58", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 61, + "confidence": 96, + "pageNumber": "59", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 62, + "confidence": 78, + "pageNumber": "60", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 63, + "confidence": 96, + "pageNumber": "61", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 64, + "confidence": 78, + "pageNumber": "62", + "pageProb": 68, + "wordConf": 97 + }, + { + "leafNum": 65, + "confidence": 96, + "pageNumber": "63", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 66, + "confidence": 78, + "pageNumber": "64", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 67, + "confidence": 96, + "pageNumber": "65", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 68, + "confidence": 78, + "pageNumber": "66", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 69, + "confidence": 96, + "pageNumber": "67", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 70, + "confidence": 78, + "pageNumber": "68", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 71, + "confidence": 96, + "pageNumber": "69", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 72, + "confidence": 78, + "pageNumber": "70", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 73, + "confidence": 96, + "pageNumber": "71", + "pageProb": 86, + "wordConf": 95 + }, + { + "leafNum": 74, + "confidence": 78, + "pageNumber": "72", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 75, + "confidence": 96, + "pageNumber": "73", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 76, + "confidence": 78, + "pageNumber": "74", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 77, + "confidence": 96, + "pageNumber": "75", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 78, + "confidence": 78, + "pageNumber": "76", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 79, + "confidence": 96, + "pageNumber": "77", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 80, + "confidence": 78, + "pageNumber": "78", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 81, + "confidence": 96, + "pageNumber": "79", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 82, + "confidence": 78, + "pageNumber": "80", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 83, + "confidence": 96, + "pageNumber": "81", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 84, + "confidence": 78, + "pageNumber": "82", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 85, + "confidence": 96, + "pageNumber": "83", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 86, + "confidence": 78, + "pageNumber": "84", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 87, + "confidence": 96, + "pageNumber": "85", + "pageProb": 86, + "wordConf": 95 + }, + { + "leafNum": 88, + "confidence": 78, + "pageNumber": "86", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 89, + "confidence": 96, + "pageNumber": "87", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 90, + "confidence": 78, + "pageNumber": "88", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 91, + "confidence": 96, + "pageNumber": "89", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 92, + "confidence": 78, + "pageNumber": "90", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 93, + "confidence": 96, + "pageNumber": "91", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 94, + "confidence": 78, + "pageNumber": "92", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 95, + "confidence": 96, + "pageNumber": "93", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 96, + "confidence": 78, + "pageNumber": "94", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 97, + "confidence": 96, + "pageNumber": "95", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 98, + "confidence": 78, + "pageNumber": "96", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 99, + "confidence": 96, + "pageNumber": "97", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 100, + "confidence": 78, + "pageNumber": "98", + "pageProb": 68, + "wordConf": 96 + }, + { + "leafNum": 101, + "confidence": 96, + "pageNumber": "99", + "pageProb": 86, + "wordConf": 96 + }, + { + "leafNum": 102, + "confidence": 76, + "pageNumber": "100", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 103, + "confidence": 95, + "pageNumber": "101", + "pageProb": 85, + "wordConf": 96 + }, + { + "leafNum": 104, + "confidence": 76, + "pageNumber": "102", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 105, + "confidence": 95, + "pageNumber": "103", + "pageProb": 85, + "wordConf": 96 + }, + { + "leafNum": 106, + "confidence": 76, + "pageNumber": "104", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 107, + "confidence": 95, + "pageNumber": "105", + "pageProb": 85, + "wordConf": 96 + }, + { + "leafNum": 108, + "confidence": 76, + "pageNumber": "106", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 109, + "confidence": 95, + "pageNumber": "107", + "pageProb": 85, + "wordConf": 96 + }, + { + "leafNum": 110, + "confidence": 76, + "pageNumber": "108", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 111, + "confidence": 95, + "pageNumber": "109", + "pageProb": 85, + "wordConf": 96 + }, + { + "leafNum": 112, + "confidence": 76, + "pageNumber": "110", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 113, + "confidence": 95, + "pageNumber": "111", + "pageProb": 85, + "wordConf": 95 + }, + { + "leafNum": 114, + "confidence": 76, + "pageNumber": "112", + "pageProb": 66, + "wordConf": 96 + }, + { + "leafNum": 115, + "confidence": 95, + "pageNumber": "113", + "pageProb": 85, + "wordConf": 96 + }, + { + "leafNum": 116, + "confidence": 75, + "pageNumber": "114", + "pageProb": 65, + "wordConf": 95 + }, + { + "leafNum": 117, + "confidence": 95, + "pageNumber": "115", + "pageProb": 85, + "wordConf": 95 + } + ] +} \ No newline at end of file diff --git a/code/HDK/Psion SIBO Hardware Development Kit 1.0_scandata.xml b/code/HDK/Psion SIBO Hardware Development Kit 1.0_scandata.xml new file mode 100755 index 0000000..44a4a57 --- /dev/null +++ b/code/HDK/Psion SIBO Hardware Development Kit 1.0_scandata.xml @@ -0,0 +1,1660 @@ + + + + 300 + psion-sibo-c-sdk + 118 + 5 + + + + Title + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + true + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 2 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 3 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 4 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 5 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 6 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 7 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 8 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 9 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 10 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 11 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 12 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 13 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 14 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 15 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 16 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 17 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 18 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 19 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 20 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 21 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 22 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 23 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 24 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 25 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 26 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 27 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 28 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 29 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 30 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 31 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 32 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 33 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 34 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 35 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 36 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 37 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 38 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 39 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 40 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 41 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 42 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 43 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 44 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 45 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 46 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 47 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 48 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 49 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 50 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 51 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 52 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 53 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 54 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 55 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 56 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 57 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 58 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 59 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 60 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 61 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 62 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 63 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 64 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 65 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 66 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 67 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 68 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 69 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 70 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 71 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 72 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 73 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 74 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 75 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 76 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 77 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 78 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 79 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 80 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 81 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 82 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 83 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 84 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 85 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 86 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 87 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 88 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 89 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 90 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 91 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 92 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 93 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 94 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 95 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 96 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 97 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 98 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 99 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 100 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 101 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 102 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 103 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 104 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 105 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 106 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 107 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 108 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 109 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 110 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 111 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 112 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 113 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 114 + + + Normal + true + 2480 + 3509 + + 0 + 0 + 2480 + 3509 + + 300 + 115 + + + \ No newline at end of file diff --git a/code/HDK/README.TXT b/code/HDK/README.TXT new file mode 100644 index 0000000..74da790 --- /dev/null +++ b/code/HDK/README.TXT @@ -0,0 +1,29 @@ +Copyright (c) Psion PLC (1995) + +26th May 1995 + + CONTENTS OF FILES ON DISK + ========================= + +readme.txt + +ASSEMBLER INCLUDE FILES +epoc.inc +epocser.inc +epoclib.inc +epocsibo.inc +ossibo.inc +ospack.inc + +C FILES +a4test.c ;Fully comprehensive test program for A4EXIF.LDD +a4test.pr ;TopSpeed Project file for the above test program + +ASM FILES +a4exif.asm ;Source code file for A4EXIF.LDD +sys$as5.asm ;Source code file for SYS$AS5.PDD +tmpsaldd.asm ;Standard stand-alone LDD template +tmpa4ldd.asm ;Template LDD for ASIC4/5-based peripherals + + + diff --git a/code/HDK/SYS$AS5.ASM b/code/HDK/SYS$AS5.ASM new file mode 100644 index 0000000..5d5a53f --- /dev/null +++ b/code/HDK/SYS$AS5.ASM @@ -0,0 +1,1023 @@ + title AS5PDD Epoc Serial physical device driver for the 16550 + subttl Copyright Psion PLC 1993 + name SYS$AS5 + +; VERSION DATE DESCRIPTION +; ------- -------- --------------- +; 1.0 08/12/94 Initial version + +; Written by Jason December 1994 + +; Serial Driver for Epoc based around ASIC5 + +Sr5S3 = 0 +Sr5S3a = 1 + +ifdef BUILDS3 +Sr5S3 = 1 +Sr5S3a = 0 +BUILDHH equ 1 +endif + +if Sr5S3a +BUILDSB equ 1 +endif + + include ..\inc\epoc.inc + include ..\inc\epocser.inc + include ..\inc\epoclib.inc + include ..\inc\epocsibo.inc + include ..\srcs\ossibo.inc + include ..\srcs\ospack.inc + +Sr5ChannelStruct struc + Sr5Open db ? ; Is the channel open + Sr5Ctrl db ? ; State of control lines + Sr5IntVector db ? ; The Vector number + Sr5Channel db ? ; Which channel are we + Sr5Mask db ? ; InterruptMask + Sr5Running db ? ; Are we running + Sr5IntRoutineVec dw ? ; Vector to Interrupt + Sr5Baud dw ? ; The baud rate + Sr5LddData dw ? ; Info from Ldd above + Sr5StatusInt dd ? ; Vectors in serial + Sr5RecvInt dd ? ; Above to be called + Sr5XmitInt dd ? ; On input/output + Sr5ClockEnable db ? ; Reason to stop + Sr5TheLines db ? ; State of the modem lines +Sr5ChannelStruct ends + +A5Ent struc ; ASIC5 Read/Write + A5PortA db ? ; Port A R/W + A5PortB db ? ; Port B R/W + A5PortBMode db ? ; Inc/Mode + A5PortD db ? ; Port CD Write only + A5Swipe1 db ? + A5Swipe2 db ? + A5IntMask db ? ; Interrupt mask R/W + A5CtrlReg db ? ; IntType/Ctrl register + A5USR db ? ; UART Status/Ctrl + A5RHR db ? ; Receive/Transmit + A5BDLSB db ? ; Baud Rate write only + A5BDMSB db ? ; Baud Rate write only + A5MCR1Eoi db ? ; MCR shift register + A5MCRPresentEoi db ? ; Barcode data&ints + A5MCR2Eoi db ? + A5DUMMYF db ? +A5Ent ends + +if Consumer + NumberOfChannels equ 1 ; S3 Single Channel +else + NumberOfChannels equ 3 ; HC,S3C Three Channel +endif + OsActivityMeter equ 158ch ; Activity Channel + StopTimeOut equ 1000 ; ~1s (1000ms) wait + + S_RS232ON equ 00000001b ; RS232 on + S_RSTTLON equ 00000100b ; Line drivers on + S_CENTON equ 00010000b ; Line drivers enable + S_RXENB equ 00000001b ; Receive interrupt on + S_TXENB equ 00000010b ; Transmit interrupt on + S_TXEMPTY equ 00010000b ; transmit buffer empty + S_RXINT equ 00000001b ; Receive interrupt? + S_TXINT equ 00000010b ; transmit interrupt? + S_MDINT equ 00000100b ; Modem status interrupt + S_CTS equ 00000001b ; CTS + S_RTS equ 00000010b ; RTS + S_DCD equ 00000100b ; DCD + S_DSR equ 00000010b ; DCR + S_DTR equ 00000100b ; DTR + OVERRUN_ERROR equ 01000000b ; Character overrun + PARITY_ERROR equ 10000000b ; Parity error + S_PERIPHERALMODE equ 00000011b ; ASIC5 RS232 mode + S_UART_OFF equ 00000010b ; ASIC5 peripheral mode + +dgroup group stack + assume ds:dgroup,es:dgroup,ss:dgroup + + CodeSeg + + ProcBegin@ OsAS5PDD +; ==================== + + dw PDDSignature + db 'TTY.SR5',0 + dw (VectorEnd-Vector)/2 +Vector: + dw OsAS5Install + dw OsAS5Remove + dw OsAS5Open + dw OsAS5Strategy +VectorEnd: + + BaudRateTable dw -077fh,-04ffh,-0368h,-02cch,-027fh,-013fh + dw -009fh,-004fh,-0035h,-0030h,-0027h,-0019h + dw -0013h,-000ch,-0009h,-0004h + DataBitsTable db 0,2,4,6 ; 5,6,7,8 bits per char frame + ParityTable db 08h,18h,0h,0h ; Even,Odd,Mark,Space parity + + Chan0 Sr5ChannelStruct <> + Chan1 Sr5ChannelStruct <> + Chan2 Sr5ChannelStruct <> + +if Consumer + if Asic9 + SetupTable dw offset AS5Int1 + db HwIrq2Revector,mask A9MSlave + db SelectChannel5,(mask A9MClockEnable5 shr 8) + else + SetupTable dw offset AS5Int1 + db HwIrq4Revector,mask Asic2Int + db SelectChannel7,(mask ClockEnable7 shr 8) + endif +else + if Asic9 + SetupTable dw offset AS5Int1 + db HwIrq4Revector,mask A9MExpIntA + db SelectChannel3,(mask A9MClockEnable3 shr 8) + dw offset AS5Int2 + db HwIrq5Revector,mask A9MExpIntB + db SelectChannel4,(mask A9MClockEnable4 shr 8) + dw offset AS5Int3 + db HwIrq2Revector,mask A9MSlave + db SelectChannel5,(mask A9MClockEnable5 shr 8) + else + SetupTable dw offset AS5Int1 + db HwIrq3Revector,mask ExpIntLeftA + db ExpChannelLeftA,(mask ClockEnable6 shr 8) + dw offset AS5Int2 + db HwIrq2Revector,mask ExpIntRightB + db ExpChannelRightB,(mask ClockEnable5 shr 8) + dw offset AS5Int3 + db HwIrq4Revector,mask Asic2Int + db SelectChannel7,(mask ClockEnable7 shr 8) + endif +endif + ProcEnd noret + + ProcBegin@ OsAS5Install,far +; ============================ + +; Install the device driver +; Out: Carry clear -happy to install + + cld ; Clear the channels + mov cx, NumberOfChannels ; and set up fixed + mov di, offset Chan0 ; parameters such + mov si, offset SetupTable ; as the interrupt + pushf ; vectors and masks + cli ; for each channel + push ds + mov ax, cs + mov ds, ax +ResetAllChannelsLoop: + mov [di].Sr5Open, 0 ; Channel not open + lodsw + mov [di].Sr5IntRoutineVec, ax ; Set the interrupt + lodsb ; handler to call + mov [di].Sr5IntVector, al ; Which Interrupt + lodsb + mov [di].Sr5Mask, al ; Mask for that + lodsb ; interrupt + mov [di].Sr5Channel, al ; Which Psion serial + lodsb ; channel + mov [di].Sr5ClockEnable, al ; Baud rate clocking + add di, size Sr5ChannelStruct ; enable + loop ResetAllChannelsLoop + pop ds + popf +AllChannelsOkay: + clc ; Returns with + ret ; Carry clear + ProcEnd noret + + ProcBegin@ OsAS5Remove,far +; ========================== + +; Remove the device driver +; Out: Carry clear -happy to remove +; Carry set -we have an open channel and cant be removed. + + xor ax, ax ; If we have a + or al, Chan0.Sr5Open ; channel Still open + or al, Chan1.Sr5Open ; then return a can't + or al, Chan2.Sr5Open ; do error else + jz AllChannelsOkay ; complete okay + mov ax, InUseErr + stc + ret + ProcEnd noret + + ProcBegin@ OsAS5Open,far +; ======================== + +; Open a serial channel +; In: SS:SI is a pointer to the open Ent Structure +; Out: Carry clear, control block in BX +; Carry set, error in AX + + cld + mov si, [si].OpenNamePtr ; Open the channel + mov al, [si+1] ; Get the channel + CharToFoldedChar ; Make Upper Case + cmp al, 'A' ; Indicator which is + jb ErrorInOpen ; Part of the name + sub al, 'A' ; Should be A,B,C + cmp al, NumberOfChannels + jae ErrorInOpen + xor ah, ah + mov bx, offset Chan0 ; What Channel are + cmp al, 1 ; We Openning + jb GotChan ; Pointer to Control + mov bx, offset Chan2 ; Block in bx + ja GotChan + mov bx, offset Chan1 +GotChan: + mov al, 1 + xchg al, cs:[bx].Sr5Open + cmp al, 0 ; Now try to Open + je OkayToOpen ; That channel +CantOpen: + mov ax, InUseErr +CantOpenDiffErr: + stc + ret +ErrorInOpen: + mov ax, NameErr + stc + ret +OkayToOpen: + xor al, al + mov cs:[bx].Sr5Running, al + mov cs:[bx].Sr5TheLines, al + mov cs:[bx].Sr5Ctrl, al + mov al, cs:[bx].Sr5Mask + HwGetChannel + jc CantOpenSoClose ; Check that we have + call CheckHardwarePresent ; The right Hardware + jnc OpenedOkay + mov al, cs:[bx].Sr5Mask + HwFreeChannel +CantOpenSoClose: + mov cs:[bx].Sr5Open, 0 + mov ax, DeviceErr + jmp short CantOpenDiffErr ; Return with the +OpenedOkay: ; Offset of our + xor ax, ax ; Control Block + ret ; In bx + ProcEnd noret + +AS5StrategyJumpTable label word + dw offset AS5Open ; Load Handler offsets + dw offset AS5Close ; Close the channel + dw offset AS5Start ; Start the channel + dw offset AS5Stop ; Stop the channel + dw offset AS5Set ; Does nothing + dw offset AS5Sense ; Returns chan status + dw offset AS5Control ; Drive the lines + dw offset AS5Enquire ; Returns baud rate + dw offset AS5Enable ; Begin Output + dw offset AS5SetHandlerCS ; Get Handler segments + + ProcBegin@ OsAS5Strategy,far +; ============================= + +; Strategy functions entry point +; Warning! This can be called from within Interrupt +; In: vector number in AX + various data in other registers +; DS is OsDataGroup (and MUST be preserved) +; Out: DI is pointer to control block +; Old channel and flags on stack + + cld + mov bx, sp + mov bx, ss:[bx+4] + mov bl, cs:[bx].Sr5Channel ; Select the correct + xchg bx, ax ; Output channel + pushf ; Then Call the right + cli ; Function to deal + HwSelectChannel ; With the strategy + mov ah, bh ; request + xor bh, bh + push ax ; Interrupts off + mov ax, di ; and flags are on + mov di, sp ; the stack + mov di, ss:[di+8] + jmp AS5StrategyJumpTable[bx] + ProcEnd noret + + ProcBegin@ AS5Open,far +; ====================== + +; Old channel and flags on the stack, interrupts off + + mov cs:[di].Sr5LddData, cx ; Load the offsets of + mov word ptr cs:[di].Sr5StatusInt, ax ; the data send and + mov word ptr cs:[di].Sr5RecvInt, si ; recieve routines in + mov word ptr cs:[di].Sr5XmitInt, dx ; the Ldd above us + xor dx, dx ; DX=0 -We don't support + pop ax ; power management + HwSelectChannel ; Return the old + popf ; channel + ret + ProcEnd noret + + ProcBegin@ AS5Close,far +; ======================= + +; Old channel and flags on the stack, interrupts off + + and cs:[di].Sr5Open, 0 ; Close the Channel + mov al, cs:[di].Sr5Mask ; Free up our channel + HwFreeChannel ; And the Hardware + pop ax ; Channel + HwSelectChannel ; Return the old + popf ; channel + ret + ProcEnd noret + + ProcBegin@ AS5Start,far +; ======================= + +; Old channel and flags on the stack, interrupts off + + call CheckHardwareFromStart + mov dx, 0 + jc CantStartSomethingWhichIsntThere + +if Asic9 + in ax, A9WControlExtraRW ; Start the S3s clock + or ah, cs:[di].Sr5ClockEnable ; Generator + out A9WControlExtraRW, ax +else + mov al, cs:[di].Sr5ClockEnable + HwSetA2Control2Bits +endif + + mov al, SerialWriteSingle or A5USR ; Set the baud rate + SBUSY ; and other + SCONTOUT ; characteristics + mov al, cs:[di].Sr5Ctrl + SBUSY + SDATAOUT + mov al, SerialWriteSingle or A5BDLSB + SBUSY + SCONTOUT + mov al, byte ptr cs:[di].Sr5Baud + SBUSY + SDATAOUT + mov al, SerialWriteSingle or A5BDMSB + SBUSY + SCONTOUT + mov al, byte ptr cs:[di+1].Sr5Baud + SBUSY + SDATAOUT + + call GetTheInterrupt ; Get the interrupt + xor cx, cx ; and clear down + call DriveRts ; the RTS line (DTR + ; stays at the state + mov al, SerialWriteSingle or A5CtrlReg ; it was set) + SBUSY + SCONTOUT + mov al, (S_CENTON or S_RS232ON or S_RSTTLON) + SBUSY + SDATAOUT ; Switch on the line + mov cx, 8 ; 8 ms ; drivers and wait + pop dx ; for them to power up + call WaitTimer + push dx + mov ah, (S_RXENB or S_TXENB or S_MDINT) ; Start all interrupts + call EnableTheInterrupt + mov cs:[di].Sr5Running, 1 + mov bx, Asic5SerialCurrent + HwSetPCurrent + call Status +CantStartSomethingWhichIsntThere: + pop ax ; Return the old + HwSelectChannel ; channel + popf + ret + ProcEnd noret + + ProcBegin@ AS5Stop,far +; ======================= + +; Old channel and flags on the stack, interrupts off + + + xor cx, cx ; Clear the state of + call DriveRts ; the modem lines + mov al, SerialReadSingle or A5IntMask ; Stop all of the + SBUSY ; interrupts + SCONTOUT + XNOP + SBUSY + SDATAIN + and al, not (S_TXENB or S_RXENB or S_MDINT) + mov ah, al + mov al, SerialWriteSingle or A5IntMask + SBUSY + SCONTOUT + mov al, ah + SBUSY + SDATAOUT + pop dx + cmp dh, DevHoldPowerFail + je DontStopHardware + cmp cs:[di].Sr5Running, 1 + jne DontWait + mov cx, StopTimeOut + jmp short CompareNow +WaitForEmpty: + call TickTimer +CompareNow: + mov al, SerialReadSingle or A5USR + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + test al, S_TXEMPTY + loopne WaitForEmpty +DontWait: + cmp bh,DevHoldNormal + je DontStopHardware + +if Asic9 + mov cl, cs:[di].Sr5ClockEnable ; Turn off baud rate + not cl ; clocking from the + in ax, A9WControlExtraRW ; S3/3a + and ah, cl + out A9WControlExtraRW, ax +else + mov al, cs:[di].Sr5ClockEnable + HwClearA2Control2Bits +endif + mov al, SerialWriteSingle or A5CtrlReg ; Stop the drivers + SBUSY ; and stuff + SCONTOUT + sub al, al ; clear S_CENTON, + SBUSY ; S_RS232ON, S_RSTTLON + SDATAOUT +DontStopHardware: + mov al, dl ; Return the old + HwSelectChannel ; channel + popf + xor bx, bx + HwSetPCurrent + ret + ProcEnd noret + + ProcBegin@ AS5Set,far +; ===================== + +; Old channel and flags on the stack, interrupts off +; In: Information required is on the stack + + pop ax ; Return the old + HwSelectChannel ; channel + popf + mov ah, ss:[si].SerialCharTbaud ; Set the Recieve, + cmp ah, ss:[si].SerialCharRbaud ; Transmit characteristics + jnz ErrorInSet ; First set the Baud + cmp ah, P_BAUD_50 ; Rate + jb ErrorInSet + cmp ah, P_BAUD_19200 + ja ErrorInSet +GotTheSpecialBaud: + dec ah + mov cl, ss:[si].SerialCharFrame ; Then the number of + mov al, ss:[si].SerialCharParity ; Stop bits + dec al + xor ch, ch + push bx + test cl, P_TWOSTOP + jz OnlyOneStopBit + or ch, 020h +OnlyOneStopBit: + test cl, P_PARITY ; The Parity + jz NoParity + mov bx, offset ParityTable + xlat cs:[ParityTable] + or ch, al +NoParity: + mov bx, offset DataBitsTable ; And finally the + and cl, P_DATA_FRM ; Number of data bits + mov al, cl ; Per frame + xlat cs:[DataBitsTable] + or ch, al + mov bx, offset BaudRateTable + mov al, ah + xor ah, ah + shl ax, 1 + add bx, ax + mov ax, cs:[bx] + pop bx + mov cs:[di].Sr5Ctrl, ch + mov cs:[di].Sr5Baud, ax + xor al, al + ret +ErrorInSet: + mov al, NotSupportedErr + stc + ret + ProcEnd noret + + ProcBegin@ AS5Sense,far +; ======================= + +; Old channel and flags on the stack, interrupts off +; Out: The state of the DCD,CTS,DSR lines returned in DX + + call Status + pop ax ; Return the old + HwSelectChannel ; channel + popf + ret + ProcEnd noret + + ProcBegin@ Status +; ================= + +; Out: State of modem lines in DX + + mov al, SerialReadSingle or A5USR ; Get the current + SBUSY ; Modem status + SCONTOUT ; Lines and return + XNOP ; With the result + SBUSY ; In dx + SDATAIN + and al, (S_CTS or S_DSR or S_DCD) ; Get the lines we want + xor al, (S_CTS or S_DSR or S_DCD) ; Invert signals + xor ah, ah + mov dx, ax + ret + ProcEnd noret + + ProcBegin@ AS5Control,far +; ========================= + +; Old channel and flags on the stack, interrupts off +; In: Lines to drive and state to drive them in DX + + mov cl, dl ; Set the state of one + test dh, P_SRCTRL_DTR ; of the modem Lines + jz DriveRtsNow ; DH is the line to + call DriveDtr ; Drive and DL is the + pop ax ; State to drive it to + HwSelectChannel ; Return the old + popf ; channel + ret +DriveRtsNow: + call DriveRts + pop ax ; Return the old + HwSelectChannel ; channel + popf + ret + ProcEnd noret + + ProcBegin@ DriveDtr +; =================== + + mov ah, S_DTR ; Set/Reset the DTR + jmp short DriveTheLine ; Line + ProcEnd noret + + ProcBegin@ DriveRts +; =================== + + mov ah, S_RTS ; Set/Reset RTS +DriveTheLine: + mov al, SerialWriteSingle or A5PortD ; Common code to set + SBUSY ; and reset either + SCONTOUT ; line while + mov al, cs:[di].Sr5TheLines ; preserving the + test cl, cl ; states of the other + jz ClearLine ; lines + or al, ah + jmp DoTheOutput +ClearLine: + not ah + and al, ah +DoTheOutput: + mov cs:[di].Sr5TheLines, al + SBUSY + SDATAOUT + ret + ProcEnd noret + + ProcBegin@ AS5Enquire,far +; ========================= + +; Old channel and flags on the stack, interrupts off +; Out: DX,AX are the supported baud rates AX for 50 to 19200 DX for above +; CX says what data bits, parity, etc we support + + pop ax ; Return the old + HwSelectChannel ; channel + popf +if Asic9 + mov ax, -1 +else + mov ax, 07fffh +endif + xor dx, dx + mov cx, (0ffffh AND (NOT (P_SRINQ_SPLIT OR P_SRINQ_PARSPACE OR P_SRINQ_PARMARK))) + ret + ProcEnd noret + + ProcBegin@ AS5Enable,far +; ======================== + +; Old channel and flags on the stack, interrupts off + + mov ah, S_TXENB ; Begin Output by + call EnableTheInterrupt ; enabling transmit + pop ax ; interrupts + HwSelectChannel ; Return the old + popf ; channel + ret + ProcEnd noret + + ProcBegin@ AS5SetHandlerCS,far +; ============================== + +; Old channel and flags on the stack, interrupts off +; CX is CS of above LDD + + mov word ptr cs:[di].(Sr5StatusInt+2), cx ; Load the Segment + mov word ptr cs:[di].(Sr5RecvInt+2), cx ; Within which the + mov word ptr cs:[di].(Sr5XmitInt+2), cx ; The Ldd above us + pop ax ; Return the old + HwSelectChannel ; channel + popf ; Resides + ret + ProcEnd noret + + ProcBegin@ AS5Int3,far +; ====================== + + mov di, offset Chan2 ; Channel 3 interrupt + mov ax, PortCActive ; vector + jmp ComInt ; Jumps to Comint + ProcEnd noret + + ProcBegin@ AS5Int2,far +; ====================== + + mov di, offset Chan1 ; Channel 2 interrupt + mov ax, PortBActive ; vector + jmp ComInt ; Jumps to Comint + ProcEnd noret + + ProcBegin@ AS5Int1,far +; ====================== + + mov di,offset Chan0 ; Channel 1 interrupt + mov ax,PortAActive ; vector +; FALL THROUGH ; Falls through + ProcEnd noret ; to Comint + + ProcBegin@ ComInt,far +; ===================== + +; The common interrupt handler +; DS points to OS data space +; DI is our control block +; AX is the Active channel + +if S3b or S3c + or ds:[OsActivityMeter], ax ; Set active state +endif + mov al, cs:[di].Sr5Channel ; Select our + HwSelectChannel ; channel + push ax + mov bx, cs:[di].Sr5LddData ; Data for LDD above +TheInterruptLoop: ; in bx + mov al, SerialReadSingle or A5CtrlReg ; Find out what + SBUSY ; caused the + SCONTOUT ; interrupt + XNOP + SBUSY + SDATAIN + test al, al + je NothingToDo +HaveWeGotAModemStatusLineInterrupt: + test al, S_MDINT + jz HaveWeGotARecieveInterrupt + mov al, SerialReadSingle or A5USR + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + test al, (OVERRUN_ERROR or PARITY_ERROR) + jz ModemStatusInterruptOnly + push ax ; Something has been + mov ah, SERPARITY_ERR ; recieved in error + test al, PARITY_ERROR + jnz IsAParityError ; Establish the error + mov ah, SEROVERRUN_ERR +IsAParityError: + mov al, SerialReadSingle or A5RHR ; Get the character + SBUSY ; in question + SCONTOUT + XNOP + SBUSY + SDATAIN + push di + call dword ptr cs:[di].Sr5RecvInt + pop di + pop ax +ModemStatusInterruptOnly: + and ax, (S_CTS or S_DSR or S_DCD) + xor al, (S_CTS or S_DSR or S_DCD) ; invert signals + mov dx, ax + push di + call dword ptr cs:[di].Sr5StatusInt + pop di + jmp short TheInterruptLoop +HaveWeGotARecieveInterrupt: + test al, S_RXINT + jz HaveWeGotATransmitInterrupt + mov al, SerialReadSingle or A5RHR + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + xor ah, ah ; AX has character received + push di + call dword ptr cs:[di].Sr5RecvInt + pop di + jmp short TheInterruptLoop +HaveWeGotATransmitInterrupt: + test al, S_TXINT + jz NothingToDo + push di + call dword ptr cs:[di].Sr5XmitInt + pop di + test ax, ax ; -1 if disable + js DisableTransmitInts + mov ah, al + mov al, SerialWriteSingle or A5RHR + SBUSY + SCONTOUT + mov al, ah + SBUSY + SDATAOUT + jmp TheInterruptLoop +NothingToDo: +if Asic9 + out A9BNonSpecificEoiW,al +else + out A1NonSpecificEoi, al +endif + pop ax + HwSelectChannel + clc ; Resced if neccessary + ret +DisableTransmitInts: ; disable TX interrupts + mov al, SerialReadSingle or A5IntMask + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + and al, not S_TXENB + mov ah, al + mov al, SerialWriteSingle or A5IntMask + SBUSY + SCONTOUT + mov al, ah + SBUSY + SDATAOUT + jmp TheInterruptLoop + ProcEnd noret + + ProcBegin@ GetTheInterrupt +; ========================== + + mov al, cs:[di].Sr5IntVector ; Load the address of + mov cx, cs ; the appropriate + mov bx, cs:[di].Sr5IntRoutineVec ; interrupt routine + GenSetRevector ; into the correct + ret ; vector + ProcEnd noret + + ProcBegin@ EnableTheInterrupt +; ============================= + + mov al, SerialReadSingle or A5IntMask + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + or ah, al + mov al, SerialWriteSingle or A5IntMask + SBUSY + SCONTOUT + mov al, ah + SBUSY + SDATAOUT +if Asic9 + in al,A9BInterruptMaskRW ; Set the mask + or al, cs:[di].Sr5Mask ; to enable Interrupts + out A9BInterruptMaskRW,al +else + in al, A1InterruptMask + or al, cs:[di].Sr5Mask + out A1InterruptMask, al +endif + ret + ProcEnd noret + + + ProcBegin@ StopInterrupts +; ========================= + + mov al, SerialReadSingle or A5IntMask ; Stop interrupts + SBUSY ; from Asic5 + SCONTOUT + XNOP + SBUSY + SDATAIN + and al, not (S_RXENB or S_TXENB or S_MDINT) + mov ah, al + mov al, SerialWriteSingle or A5IntMask + SBUSY + SCONTOUT + mov al, ah + SBUSY + SDATAOUT + + mov ah, cs:[di].Sr5Mask + not ah +if Asic9 + in al,A9BInterruptMaskRW ; Stop Interrupts + and al,ah ; By clearing the + out A9BInterruptMaskRW,al ; Mask and resetting +else ; The Vector + in al, A1InterruptMask + and al,ah + out A1InterruptMask, al +endif + + mov al, cs:[di].Sr5IntVector + GenResetRevector + ret + ProcEnd noret + + ProcBegin@ CheckHardwarePresent +; =============================== + + pushf + cli + mov al, cs:[bx].Sr5Channel ; Check that the + HwSelectChannel ; Harware is there + HwNullFrame ; And that it is what + mov al,(SerialSelect or Asic5NormalId) ; It should be + SBUSY ; First look for An + SCONTOUT ; ASIC4 at the other + XNOP ; End of the link + SBUSY + SDATAIN + test al,al + je ConnectionFailed +GotConnection: + popf + clc + ret +ConnectionFailed: + mov al, SerialSelect or Asic4Id ; Asic4 Id + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + test al, al + jne ConnectionFailedExit + mov al, SerialSelect or Asic8Id ; Modem chip Id + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + test al, al + jne ConnectionFailedExit + mov al, SerialSelect or Asic5PackId ; Asic5pack Id + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN +ConnectionFailedExit: + popf + stc + ret + ProcEnd noret + + ProcBegin@ CheckHardwareFromStart +; ================================= + + pushf + HwNullFrame ; Check that the + mov al,(SerialSelect or Asic5NormalId) ; Harware is there + SBUSY ; First look for An + SCONTOUT ; ASIC5 at the other + XNOP ; End of the link + SBUSY + SDATAIN + test al,al + je ConnectionFailed ; If not a 3link or + test al, mask A5MultiDrop ; if in multidrop + jne ConnectionFailedExit ; mode then we are + popf ; in trouble + mov al, SerialWriteSingle or A5PortBMode + SBUSY + SCONTOUT ; Put the 3Link in + mov al, S_PERIPHERALMODE ; peripheral mode + SBUSY + SDATAOUT + clc + ret + ProcEnd noret + + ProcBegin@ WaitTimer +; ==================== + +; In: CX number of ms to wait for +; Channel store in DL +; Out: Channel store in DL + + inc cx ; Wait for a given +WaitTickLoop: ; Number of ms + call TickTimer ; Plus one to guarantee + loop WaitTickLoop ; That at least cx ms + ret ; Go by + ProcEnd +; + ProcBegin@ TickTimer +; ==================== + +; Uses writes down our channel to simulate tick timer waits +; Must allow interrupts so other things can run -we will be here +; for 1/1000 of a second and may be called many times +; ChannelStore in/out in DL + + mov al, dl ; Return the old + HwSelectChannel ; channel + mov ah, al + pushf + sti + push cx + mov cx, 12 ; 1ms +WaiterLoop: ; 128 frames =1ms + pushf ; about 12 times + cli ; round the loop + out ResetWatchDog,al + mov al, ah + HwSelectChannel + mov dl, al ; Get Correct channel + mov al, (SerialWriteSingle or 0) ; Do a write to + SBUSY ; nowhere and + SCONTOUT ; waste some time + SBUSY + SCONTOUT ; Do it eight times + SBUSY + SCONTOUT + SBUSY + SCONTOUT + SBUSY + SCONTOUT + SBUSY + SCONTOUT + SBUSY + SCONTOUT + SBUSY + SCONTOUT + SBUSY + mov al, dl ; Return the old + HwSelectChannel ; channel + mov ah, al + popf + loop WaiterLoop + pop cx + popf + mov al, ah + HwSelectChannel + mov dl, al + ret + ProcEnd + + EndCodeSeg + +stack segment stack para 'data' +stack ends + + end OsAS5PDD + + diff --git a/code/HDK/TMPA4LDD.ASM b/code/HDK/TMPA4LDD.ASM new file mode 100644 index 0000000..3c6271c --- /dev/null +++ b/code/HDK/TMPA4LDD.ASM @@ -0,0 +1,808 @@ + title NAME.LDD device driver for S3/S3a/S3c/S3../HC + subttl Copyright PSION PLC November 1995 + name NAME + +; VERSION DATE DESCRIPTION +; ------- -------- --------------- +; 1.0 12/01/95 Template Asic4/5 LDD + +; Written by Jason Robinson January 1995 + + BUILDSB equ 1 + Asic4Type =0 + Asic5Type =0 + NeedTheInterrupt =0 + NeedClocking =0 + StartChannelInOpen =0 + + include ..\inc\epoc.inc + include ..\inc\epocser.inc + include ..\inc\epoclib.inc + include ..\inc\epocsibo.inc + include ..\srcs\ossibo.inc + include ..\srcs\ospack.inc + + WeSupportS3Only equ Lcd240X80 + WeSupportS3aOnly equ Lcd480X160 + WeSupportS3cOnly equ Lcd240X100 + WeSupportHCOnly equ Lcd160X80 +if Consumer + NumberOfChannels equ 1 + if Asic9 + TheMachineWeSupport equ WeSupportS3aOnly + else + TheMachineWeSupport equ WeSupportS3Only + endif +else + NumberOfChannels equ 3 + if Asic9 + TheMachineWeSupport equ WeSupportS3cOnly + else + TheMachineWeSupport equ WeSupportHCOnly + endif +endif + A4PERIPH_MASK equ 0f0h + TheInfoByteThatWeWant equ 1 + +TmpltEnt struc + TmpltEntOpen db ? ; Channel open flag + TmpltChannelStarted db ? ; Channel should be running + TmpltHwChannel dw ? ; The harware we want + TmpltStructPtr dw ? ; Ptr to CB in Apps DS + TmpltTckHandle dw ? ; Tick Handle + TmpltChannelRunning db ? ; Can channel really run + TmpltInterruptMask db ? ; InterruptMask + TmpltChannel db ? ; Channel +if NeedTheInterrupt + TmpltInterruptNumber db ? ; Interrupt Number + TmpltInterruptVector dw ? ; Were to Jump To +if Asic5Type and NeedClocking + TmpltA5Clocking db ? ; Asic5 baud rate clocking + TmpltSpare db ? +endif +else + TmpltSpare db ? +endif + +TmpltEnt ends + +TmpltStruct struc + Tmpltblk ChanEnt <> ; I/O control block + TmpltEntPtr dw ? ; Ptr to our CS CB +TmpltStruct ends + + dgroup group stack + assume ds:dgroup,es:dgroup,ss:dgroup + + CodeSeg + + ProcBegin@ TmpltLDD +; =================== + + dw LDDSignature + db 'HSB',0,0,0,0,0 + dw (TableEnd-TableStart)/2 +TableStart: + dw TmpltInstall + dw TmpltRemove + dw TmpltHold + dw TmpltResume + dw TmpltReset + dw TmpltUnits + dw TmpltOpen + dw TmpltStrategy +MonitorVector: + dw MonitorInt +TableEnd: + +if Consumer + if Asic9 + SetupTable db mask A9MSlave,SelectChannel5 + db (mask A9MClockEnable5 shr 8),HwIrq2Revector + if NeedTheInterrupt + dw offset Interrupt0 + endif + + else + SetupTable db mask Asic2Int,SelectChannel7 + db (mask ClockEnable7 shr 8),HwIrq4Revector + if NeedTheInterrupt + dw offset Interrupt0 + endif + endif +else + if Asic9 + SetupTable db mask A9MExpIntA,SelectChannel3 + db (mask A9MClockEnable3 shr 8),HwIrq4Revector + if NeedTheInterrupt + dw offset Interrupt0 + endif + db mask A9MExpIntB,SelectChannel4 + db (mask A9MClockEnable4 shr 8),HwIrq5Revector + if NeedTheInterrupt + dw offset Interrupt1 + endif + db mask A9MSlave,SelectChannel5 + db (mask A9MClockEnable5 shr 8),HwIrq2Revector + if NeedTheInterrupt + dw offset Interrupt2 + endif + else + SetupTable db mask ExpIntLeftA,ExpChannelLeftA + db (mask ClockEnable6 shr 8),HwIrq3Revector + if NeedTheInterrupt + dw offset Interrupt0 + endif + db mask ExpIntRightB,ExpChannelRightB + db (mask ClockEnable5 shr 8),HwIrq2Revector + if NeedTheInterrupt + dw offset Interrupt1 + endif + db mask Asic2Int,SelectChannel7 + db (mask ClockEnable7 shr 8),HwIrq4Revector + if NeedTheInterrupt + dw offset Interrupt2 + endif + endif +endif + CsHeldFlag db 0 ; Ldd under a hold? + MachineType db 0 +if Consumer + Channel0 TmpltEnt <> +else + Channel0 TmpltEnt <> + Channel1 TmpltEnt <> + Channel2 TmpltEnt <> +endif + + ProcEnd noret + + ProcBegin@ TmpltInstall,far +; =========================== + +; Install the driver +; Exit with carry clear for okay + + GenLcdType ; Do we only run on + mov MachineType,al ; particular machines? + cmp al,TheMachineWeSupport + jne CannotInstallOnThisMachine + + pushf + cli + push ds + mov ax, cs + mov ds, ax + mov CsHeldFlag, 0 ; Initialise all + mov cx, NumberOfChannels ; the variables + mov di, offset Channel0 + mov si, offset SetupTable +ResetAllChannelsLoop: + mov [di].TmpltEntOpen, 0 + lodsb + mov [di].TmpltInterruptMask, al + lodsb + mov [di].TmpltChannel, al + lodsb +if NeedClocking + mov [di].TmpltA5Clocking, al +endif + lodsb +if NeedTheInterrupt + mov [di].TmpltInterruptNumber, al + lodsw + mov [di].TmpltInterruptVector, ax +endif + + add di,size TmpltEnt + loop ResetAllChannelsLoop + pop ds + popf +FinishedOkay: + clc + ret +CannotInstallOnThisMachine: + mov ax,NotSupportedErr + stc + ret + ProcEnd noret + + ProcBegin@ TmpltRemove,far +; ========================== + +; Remove the driver +; Exit with carry clear for okay +; Exit with carry set if channel still open + + mov cx,NumberOfChannels + mov di,offset Channel0 + xor ax,ax +CheckAllChannelsClosedLoop: + cmp cs:[di].TmpltEntOpen,al + jne WeHaveAnOpenChannelSoFail + add di,size TmpltEnt + loop CheckAllChannelsClosedLoop + jmp FinishedOkay +WeHaveAnOpenChannelSoFail: + mov ax,InUseErr + stc + ret + ProcEnd noret + + ProcBegin@ TmpltUnits,far +; ========================= + +; Return the Number of channels that can be opened in AX + + mov ax,NumberOfChannels ; We have ? channels + ret + ProcEnd noret + + ProcBegin@ TmpltReset,far +; ========================= + +; Reset the open channel + + mov di,cx + cmp cs:[di].TmpltEntOpen,0 ; Somethings gone + je NotOpenToReset ; wrong with the + mov ah,DevHoldPowerDown ; application that + call StopTheChannel ; opened us. + call FreeHardware ; Stop interupts and + mov cs:[di].TmpltEntOpen,0 ; free the channel +NotOpenToReset: + ret + ProcEnd noret + + ProcBegin@ TmpltHold,far +; ======================== + +; Hold the channels +; Hold reason in AH + + mov cx,1 + xchg cl,CsHeldFlag ; Stop any interrupts + cmp cl,0 ; Mark channel as + jne AlreadyHeld ; under a normal hold +DoHold: + mov cx,NumberOfChannels + mov di,offset Channel0 +HoldAllTheChannelsLoop: + cmp cs:[di].TmpltEntOpen,0 + je DontHoldBecauseNotOpen + cmp cs:[di].TmpltChannelStarted,0 + je DontHoldBecauseNotOpen + push ax + push cx + call StopTheChannel + pop cx + pop ax +DontHoldBecauseNotOpen: + add di,size TmpltEnt + loop HoldAllTheChannelsLoop +AlreadyHeld: + ret + ProcEnd noret + + ProcBegin@ TmpltResume,far +; ========================== + +; Resume the channel + + xor cx,cx ; Be warned during an + xchg cl,CsHeldFlag ; on/off the power to + cmp cl,0 ; ASIC4 is not restored + je AlreadyResumed ; until after this + GenDataSegment ; A resume is pointless + HwGetSsdData ; if there is still no + mov bx,ax ; power to the port + cmp es:[bx].SsdDoorStatus,DoorOpen ; Leave the resume + je DoorsAreOpen ; to the tick +DoResume: + mov cx,NumberOfChannels + mov di,offset Channel0 ; Right hardware? +ResumeAllTheChannelsLoop: ; Else restart + cmp cs:[di].TmpltEntOpen,0 ; interrupts + je DontResumeBecauseNotOpen + cmp cs:[di].TmpltChannelStarted,0 + je DontResumeBecauseNotOpen + push cx + call StartTheChannel + pop cx +DontResumeBecauseNotOpen: + add di,size TmpltEnt + loop ResumeAllTheChannelsLoop +AlreadyResumed: + ret +DoorsAreOpen: + mov CsHeldFlag,2 + ret + ProcEnd noret + + ProcBegin@ TmpltOpen,far +; ======================== + +; Open the channel +; DS,ES,SS Applications data space +; Handle in DX + + cld + pushf + cli + call FindFreeChannel + jnc GotFreeChannel + popf +LockedError: + mov ax,LockedErr + stc + ret +AllErrorsExitHere: + push ax + HeapFreeCell + pop ax +FreeTckAndChannel: + push ax + call FreeHardware + pop ax +FreeTckAndExit: + push ax + mov bx,cs:[di].TmpltTckHandle + IoClose + pop ax +CloseThenFree: + mov cs:[di].TmpltEntOpen,0 + stc + ret +GotFreeChannel: + mov cs:[di].TmpltEntOpen,1 + mov cs:[di].TmpltChannelStarted,0 + mov cs:[di].TmpltChannelRunning,0 + popf + xor ax,ax + push ax + mov ax,((':' shl 8)+'K') + push ax + mov ax,(('C' shl 8)+'T') + push ax + mov bx,sp + IoOpen + jnc GotATickChannel + add sp,6 + mov ax,LockedErr + jmp CloseThenFree +GotATickChannel: + add sp,6 + mov cs:[di].TmpltTckHandle,ax + push dx + mov bx,ax + mov ax,IoFuncStart + mov cx,1 + push cx ; Frequency 1 tick + push di ; Data is our CS CB + push dx ; Our device handle + mov cx,(MonitorVector-TableStart)/2 ; Vector to call + push cx + mov cx,sp + IoWithWait + add sp,8 + pop dx + call GetHardware + jc FreeTckAndExit + + mov cx,(size TmpltStruct) ; Get ourselfs a CB + HeapAllocateCell ; In the applications + jc FreeTckAndChannel ; Data space + + mov bx,ax + mov [bx].Tmpltblk.ChanNext,bx + mov [bx].Tmpltblk.ChanSignature,IoChanSignature + mov [bx].Tmpltblk.ChanLibHandle,dx + mov [bx].TmpltEntPtr,di + push bx + mov bx,dx + mov cx,di + IoRequestReset + pop bx +if StartChannelInOpen + call StartChannelFromOpen +endif + xor ax,ax + ret + ProcEnd noret + +StrategyVectorTable label word + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset TmpltClose + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + + ProcBegin@ TmpltStrategy,far +; ============================ + +; BX is our control block +; SI points to the parameters +; DS,ES Applications data space + + mov ax,[si].RqFunction + mov dx,[si].RqA1Ptr + cmp ax,IoFuncSuperFrame + ja StrategyDefault + shl ax,1 + mov di,ax + push StrategyVectorTable[di] + mov di,[bx].TmpltEntPtr + retn +StrategyDefault: + IoRoot + ret +ExitStrategyOkay: + xor ax,ax +ExitStrategy: + mov di,[si].RqStatusPtr + mov word ptr [di],ax + cmp ax,PendingErr + je JustExit + IoSignal +JustExit: + xor ax,ax + ret + ProcEnd noret + + ProcBegin@ TmpltClose,far +; ========================= + +; Close a channel +; DI CS control block +; BX DS control block +; SI points to aurguments on stack +; DX Argument one pointer + + mov ah,DevHoldPowerDown + call StopTheChannel + call FreeHardware + mov cs:[di].TmpltChannelStarted,0 + push bx + mov bx,[bx].Tmpltblk.ChanLibHandle + mov cx,di + IoRequestResetCancel + pop bx + HeapFreeCell + mov bx,cs:[di].TmpltTckHandle + IoClose + mov cs:[di].TmpltEntOpen,0 + jmp short ExitStrategyOkay + ProcEnd noret + + ProcBegin@ StartTheChannel +; ========================== + +; Start the Channel Running +; Assume channel set up and interrupts off + + cmp cs:[di].TmpltChannelRunning,0 + jne ChannelAlreadyRunning + +if Asic5Type and NeedClocking +if Asic9 + in ax, A9WControlExtraRW ; Start the S3s clock + or ah, [bx].TmpltA5Clocking ; Generator + out A9WControlExtraRW, ax +else + mov al, [bx].TmpltA5Clocking + HwSetA2Control2Bits +endif +endif +if NeedTheInterrupt + mov al, cs:[di].TmpltInterruptNumber ; Load the address of + mov cx, cs ; the appropriate + mov bx, cs:[di].TmpltInterruptVector ; interrupt routine + GenSetRevector ; into the correct vector +if Asic9 + in al,A9BInterruptMaskRW ; Set the mask + or al,cs:[di].TmpltInterruptMask ; to enable Interrupts + out A9BInterruptMaskRW,al +else + in al, A1InterruptMask + or al,cs:[di].TmpltInterruptMask + out A1InterruptMask, al +endif +endif + mov cs:[di].TmpltChannelRunning,1 +ChannelAlreadyRunning: + ret + ProcEnd noret + + ProcBegin@ StopTheChannel +; ========================= + +; Stop the Channel Running +; Assume channel set up and interrupts off +; Stop reason in AH + + cmp byte ptr cs:[di].TmpltChannelRunning,0 + je ChannelAlreadyStopped +if NeedTheInterrupt + mov ah,cs:[di].TmpltInterruptMask + not ah +if Asic9 + in al,A9BInterruptMaskRW ; Stop Interrupts + and al,ah ; By clearing the + out A9BInterruptMaskRW,al ; Mask and resetting +else ; The Vector + in al, A1InterruptMask + and al,ah + out A1InterruptMask, al +endif + mov al, cs:[di].TmpltInterruptNumber + GenResetRevector +endif +if Asic5Type and NeedClocking +if Asic9 + mov cl, [bx].TmpltA5Clocking ; Turn off baud rate + not cl ; clocking from the + in ax, A9WControlExtraRW ; S3/3a + and ah, cl + out A9WControlExtraRW, ax +else + mov al, [bx].TmpltA5Clocking + HwClearA2Control2Bits +endif +endif + mov cs:[di].TmpltChannelRunning,0 +ChannelAlreadyStopped: + ret + ProcEnd noret + +if StartChannelInOpen + ProcBegin@ StartChannelFromOpen +; =============================== + + pushf + cli + mov cs:[di].TmpltChannelStarted,1 + mov al,cs:[di].TmpltChannel + HwSelectChannel + push ax + call StartTheChannel + pop ax + HwSelectChannel + popf + ret + ProcEnd noret +endif + ProcBegin@ GetHardware +; ====================== + + mov al, cs:[di].TmpltInterruptMask + HwGetChannel + jc ChannelNotAvailable + pushf + cli + mov al,cs:[di].TmpltChannel + HwSelectChannel + push ax + call CheckForHardware + pop ax + jc NoHardwareFreeTheChannel + HwSelectChannel + popf + clc + ret +NoHardwareFreeTheChannel: + HwSelectChannel + popf + mov al, cs:[di].TmpltInterruptMask + HwFreeChannel +ChannelNotAvailable: + stc + ret + ProcEnd noret + + ProcBegin@ FreeHardware +; ======================= + + mov al, cs:[di].TmpltInterruptMask + HwFreeChannel + ret + ProcEnd noret + + ProcBegin@ FindFreeChannel +; ========================== + + mov si,[si].OpenNamePtr + mov al,[si+1] + CharToFoldedChar + cmp al,'A' + jb CantGetThatChannel + sub al,'A' + cmp al,NumberOfChannels + jae CantGetThatChannel + xor ah,ah + push dx + mov dx,size TmpltEnt + mul dx + pop dx + mov di,ax + add di,offset Channel0 + cmp cs:[di].TmpltEntOpen,0 + je FoundAFreeChannel +CantGetThatChannel: + stc + ret +FoundAFreeChannel: + clc + ret + ProcEnd noret + + ProcBegin@ CheckForHardware +; =========================== + +; Assume Interrupts are off +; Correct channel should be selected +; Out: clc - got correct hardware +; stc - wrong or no hardware + +if Asic5Type + HwNullFrame ; Check that the + mov al,(SerialSelect or Asic5NormalId) ; Harware is there + SBUSY ; And that it is what + SCONTOUT ; It should be + XNOP ; First look for An + SBUSY ; ASIC5 at the other + SDATAIN ; End of the link + test al,al + je ConnectionFailed +GotConnection: + popf + clc + ret +ConnectionFailed: + mov al, SerialSelect or Asic4Id ; Asic4 Id + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + test al, al + jne ConnectionFailedExit +else + HwNullFrame + mov al,(SerialSelect or Asic4Id) + SBUSY ; First look for An + SCONTOUT ; ASIC4 at the other + XNOP ; End of the link + SBUSY + SDATAIN + test al, al + je ConnectionFailed + mov al,SerialReadSingle or A4InfoR ; Now see if we have + SBUSY ; The right card + SCONTOUT + XNOP ; Allows the busy signal to come through for the wait + SBUSY + SDATAIN + and al,A4PERIPH_MASK + cmp al,TheInfoByteThatWeWant + jne ConnectionFailedExit + clc + ret +ConnectionFailed: + mov al,(SerialSelect or Asic5NormalId) ; Select as an + SBUSY ; Asic5 peripheral + SCONTOUT + XNOP + SDATAIN + test al,al + jne ConnectionFailedExit +endif + mov al, SerialSelect or Asic8Id ; Modem chip Id + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN + test al, al + jne ConnectionFailedExit + mov al, SerialSelect or Asic5PackId ; Asic5pack Id + SBUSY + SCONTOUT + XNOP + SBUSY + SDATAIN +ConnectionFailedExit: + stc + ret + ProcEnd noret + + ProcBegin@ MonitorInt,far +; ========================= + +; Called on every tick +; Issues pack door hold and resumes +; In: Door state in SI + + cmp si,DoorOpen + je TheDoorIsOpenSoCantDoAnything + cmp CsHeldFlag,2 + je NeedToDoTheResume + ret +NeedToDoTheResume: + mov CsHeldFlag,0 + jmp DoResume +TheDoorIsOpenSoCantDoAnything: + cmp CsHeldFlag,0 + jne DontNeedToHold + mov CsHeldFlag,2 + mov ah,DevHoldPowerFail + jmp DoHold +DontNeedToHold: + ret + ProcEnd noret + +if NeedTheInterrupt + ife Consumer + ProcBegin@ Interrupt2,far +; ========================= + + mov di,offset Channel2 + mov ax,PortCActive + jmp ComInt + ProcEnd noret + + ProcBegin@ Interrupt1,far +; ========================= + + mov di,offset Channel1 + mov ax,PortBActive + jmp ComInt + ProcEnd noret + endif + + ProcBegin@ Interrupt0,far +; ========================= + + mov di,offset Channel0 + mov ax,PortAActive +; FALLTHROUGH to ComInt + ProcEnd noret + + ProcBegin@ ComInt,far +; ===================== + +if Asic9 + out A9BNonSpecificEoiW,al +else + out A1NonSpecificEoi, al +endif + clc + ret + ProcEnd noret +endif + + + EndCodeSeg + stack segment stack para 'data' + stack ends + end TmpltLDD + + + + + + + + + + + + diff --git a/code/HDK/TMPSALDD.ASM b/code/HDK/TMPSALDD.ASM new file mode 100644 index 0000000..e26bc13 --- /dev/null +++ b/code/HDK/TMPSALDD.ASM @@ -0,0 +1,531 @@ + title NAME.LDD device driver for S3/S3a/S3c/S3../HC + subttl Copyright PSION PLC November 1995 + name NAME + +; VERSION DATE DESCRIPTION +; ------- -------- --------------- +; 1.0 12/01/95 Template LDD + +; Written by Jason Robinson January 1995 + +BUILDSB equ 1 + + include ..\inc\epoc.inc + include ..\inc\epocser.inc + include ..\inc\epoclib.inc + include ..\inc\epocsibo.inc + include ..\srcs\ossibo.inc + include ..\srcs\ospack.inc + + OpenSpecificChannel =0 + MachineSpecific =0 + PeripheralTypeDriver =0 + TickRequired =0 + + NumberOfChannels equ 1 + WeSupportS3Only equ Lcd240X80 + WeSupportS3aOnly equ Lcd480X160 + WeSupportS3cOnly equ Lcd240X100 + WeSupportHCOnly equ Lcd160X80 + TheMachineWeSupport equ WeSupportS3aOnly + +TmpltEnt struc + TmpltEntOpen db ? ; Channel open flag + TmpltChannelStarted db ? ; Channel should be running + TmpltChannelRunning db ? ; Can channel really run + TmpltSpare db ? + TmpltHwChannel dw ? ; The harware we want + TmpltStructPtr dw ? ; Ptr to CB in Apps DS +if PeripheralTypeDriver or TickRequired + TmpltTckHandle dw ? ; Tick Handle +endif +TmpltEnt ends + +TmpltStruct struc + Tmpltblk ChanEnt <> ; I/O control block + TmpltEntPtr dw ? ; Ptr to our CS CB +TmpltStruct ends + + dgroup group stack + assume ds:dgroup,es:dgroup,ss:dgroup + + CodeSeg + + ProcBegin@ TmpltLDD +; =================== + + dw LDDSignature + db 'HSB',0,0,0,0,0 + dw (TableEnd-TableStart)/2 +TableStart: + dw TmpltInstall + dw TmpltRemove + dw TmpltHold + dw TmpltResume + dw TmpltReset + dw TmpltUnits + dw TmpltOpen + dw TmpltStrategy +if PeripheralTypeDriver or TickRequired +MonitorVector: + dw MonitorInt +endif +TableEnd: + + CsHeldFlag db 0 ; Ldd under a hold? + MachineType db 0 + + Channel0 TmpltEnt <> + + ProcEnd noret + + ProcBegin@ TmpltInstall,far +; =========================== + +; Install the driver +; Exit with carry clear for okay + +if MachineSpecific + GenLcdType ; Do we only run on + mov MachineType,al ; particular machines? + cmp al,TheMachineWeSupport + jne CannotInstallOnThisMachine +endif + mov CsHeldFlag,0 ; Initialise all + mov cx,NumberOfChannels ; the variables + mov di,offset Channel0 + xor ax,ax +ResetAllChannelsLoop: + mov cs:[di].TmpltEntOpen,al + add di,size TmpltEnt + loop ResetAllChannelsLoop +FinishedOkay: + clc + ret +CannotInstallOnThisMachine: + mov ax,NotSupportedErr + stc + ret + ProcEnd noret + + ProcBegin@ TmpltRemove,far +; ========================== + +; Remove the driver +; Exit with carry clear for okay +; Exit with carry set if channel still open + + mov cx,NumberOfChannels + mov di,offset Channel0 + xor ax,ax +CheckAllChannelsClosedLoop: + cmp cs:[di].TmpltEntOpen,al + jne WeHaveAnOpenChannelSoFail + add di,size TmpltEnt + loop CheckAllChannelsClosedLoop + jmp FinishedOkay +WeHaveAnOpenChannelSoFail: + mov ax,InUseErr + stc + ret + ProcEnd noret + + ProcBegin@ TmpltUnits,far +; ========================= + +; Return the Number of channels that can be opened in AX + + mov ax,NumberOfChannels ; We have ? channels + ret + ProcEnd noret + + ProcBegin@ TmpltReset,far +; ========================= + +; Reset the open channel + + mov di,cx + cmp cs:[di].TmpltEntOpen,0 ; Somethings gone + je NotOpenToReset ; wrong with the + mov ah,DevHoldPowerDown ; application that + call StopTheChannel ; opened us. + call FreeHardware ; Stop interupts and + mov cs:[di].TmpltEntOpen,0 ; free the channel +NotOpenToReset: + ret + ProcEnd noret + + ProcBegin@ TmpltHold,far +; ======================== + +; Hold the channels +; Hold reason in AH + + mov cx,1 + xchg cl,CsHeldFlag ; Stop any interrupts + cmp cl,0 ; Mark channel as + jne AlreadyHeld ; under a normal hold +DoHold: + mov cx,NumberOfChannels + mov di,offset Channel0 +HoldAllTheChannelsLoop: + cmp cs:[di].TmpltEntOpen,0 + je DontHoldBecauseNotOpen + cmp cs:[di].TmpltChannelStarted,0 + je DontHoldBecauseNotOpen + push ax + push cx + call StopTheChannel + pop cx + pop ax +DontHoldBecauseNotOpen: + add di,size TmpltEnt + loop HoldAllTheChannelsLoop +AlreadyHeld: + ret + ProcEnd noret + + ProcBegin@ TmpltResume,far +; ========================== + +; Resume the channel + + xor cx,cx ; Be warned during an + xchg cl,CsHeldFlag ; on/off the power to + cmp cl,0 ; ASIC4 is not restored + je AlreadyResumed ; until after this +if PeripheralTypeDriver + GenDataSegment ; A resume is pointless + HwGetSsdData ; if there is still no + mov bx,ax ; power to the port + cmp es:[bx].SsdDoorStatus,DoorOpen ; Leave the resume + je DoorsAreOpen ; to the tick +endif +DoResume: + mov cx,NumberOfChannels + mov di,offset Channel0 ; Right hardware? +ResumeAllTheChannelsLoop: ; Else restart + cmp cs:[di].TmpltEntOpen,0 ; interrupts + je DontResumeBecauseNotOpen + cmp cs:[di].TmpltChannelStarted,0 + je DontResumeBecauseNotOpen + push cx + call StartTheChannel + pop cx +DontResumeBecauseNotOpen: + add di,size TmpltEnt + loop ResumeAllTheChannelsLoop +AlreadyResumed: + ret +if PeripheralTypeDriver +DoorsAreOpen: + mov CsHeldFlag,2 + ret +endif + ProcEnd noret + + ProcBegin@ TmpltOpen,far +; ======================== + +; Open the channel +; DS,ES,SS Applications data space +; Handle in DX + + cld + pushf + cli + call FindFreeChannel + jnc GotFreeChannel + popf +LockedError: + mov ax,LockedErr + stc + ret +AllErrorsExitHere: + push ax + HeapFreeCell + pop ax +FreeTckAndChannel: + push ax + call FreeHardware + pop ax +FreeTckAndExit: +if PeripheralTypeDriver or TickRequired + push ax + mov bx,cs:[di].TmpltTckHandle + IoClose + pop ax +endif +CloseThenFree: + mov cs:[di].TmpltEntOpen,0 + stc + ret +GotFreeChannel: + mov cs:[di].TmpltEntOpen,1 + mov cs:[di].TmpltChannelStarted,0 + mov cs:[di].TmpltChannelRunning,0 + popf +if PeripheralTypeDriver or TickRequired + xor ax,ax + push ax + mov ax,((':' shl 8)+'K') + push ax + mov ax,(('C' shl 8)+'T') + push ax + mov bx,sp + IoOpen + jnc GotATickChannel + add sp,6 + mov ax,LockedErr + jmp CloseThenFree +GotATickChannel: + add sp,6 + mov cs:[di].TmpltTckHandle,ax + push dx + mov bx,ax + mov ax,IoFuncStart + mov cx,1 + push cx ; Frequency 1 tick + push di ; Data is our CS CB + push dx ; Our device handle + mov cx,(MonitorVector-TableStart)/2 ; Vector to call + push cx + mov cx,sp + IoWithWait + add sp,8 + pop dx +endif + call GetHardware + jc FreeTckAndExit + + mov cx,(size TmpltStruct) ; Get ourselfs a CB + HeapAllocateCell ; In the applications + jc FreeTckAndChannel ; Data space + + mov bx,ax + mov [bx].Tmpltblk.ChanNext,bx + mov [bx].Tmpltblk.ChanSignature,IoChanSignature + mov [bx].Tmpltblk.ChanLibHandle,dx + mov [bx].TmpltEntPtr,di + push bx + mov bx,dx + mov cx,di + IoRequestReset + pop bx + xor ax,ax + ret + ProcEnd noret + +StrategyVectorTable label word + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset TmpltClose + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + dw offset StrategyDefault + + ProcBegin@ TmpltStrategy,far +; ============================ + +; BX is our control block +; SI points to the parameters +; DS,ES Applications data space + + mov ax,[si].RqFunction + mov dx,[si].RqA1Ptr + cmp ax,IoFuncSuperFrame + ja StrategyDefault + shl ax,1 + mov di,ax + push StrategyVectorTable[di] + mov di,[bx].TmpltEntPtr + retn +StrategyDefault: + IoRoot + ret +ExitStrategyOkay: + xor ax,ax +ExitStrategy: + mov di,[si].RqStatusPtr + mov word ptr [di],ax + cmp ax,PendingErr + je JustExit + IoSignal +JustExit: + xor ax,ax + ret + ProcEnd noret + + ProcBegin@ TmpltClose,far +; ========================= + +; Close a channel +; DI CS control block +; BX DS control block +; SI points to aurguments on stack +; DX Argument one pointer + + mov ah,DevHoldPowerDown + call StopTheChannel + call FreeHardware + push bx + mov bx,[bx].Tmpltblk.ChanLibHandle + mov cx,di + IoRequestResetCancel + pop bx + HeapFreeCell +if PeripheralTypeDriver or TickRequired + mov bx,cs:[di].TmpltTckHandle + IoClose +endif + mov cs:[di].TmpltEntOpen,0 + jmp short ExitStrategyOkay + ProcEnd noret + + ProcBegin@ StartTheChannel +; ========================== + +; Start the Channel Running + + cmp byte ptr cs:[di].TmpltChannelRunning,0 + jne ChannelAlreadyRunning + + mov cs:[di].TmpltChannelRunning,1 +ChannelAlreadyRunning: + clc + ret + ProcEnd noret + + ProcBegin@ StopTheChannel +; ========================= + +; Stop the Channel Running + + cmp byte ptr cs:[di].TmpltChannelRunning,0 + je ChannelAlreadyStopped + + mov cs:[di].TmpltChannelRunning,0 +ChannelAlreadyStopped: + clc + ret + ProcEnd noret + + ProcBegin@ GetHardware +; ====================== + + clc + ret + ProcEnd noret + + ProcBegin@ FreeHardware +; ======================= + + clc + ret + ProcEnd noret + +If OpenSpecificChannel + ProcBegin@ FindFreeChannel +; ========================== + +; Called from Open +; Must preserve DX,SI +; Channel out in DI or carry set if failure + + mov si,[si].OpenNamePtr + mov al,[si+1] + CharToFoldedChar + cmp al,'A' + jb CantGetThatChannel + sub al,'A' + cmp al,NumberOfChannels + jae CantGetThatChannel + xor ah,ah + push dx + mov dx,size TmpltEnt + mul dx + pop dx + mov di,ax + add di,offset Channel0 + cmp cs:[di].TmpltEntOpen,0 + je FoundAFreeChannel +CantGetThatChannel: + stc + ret +FoundAFreeChannel: + clc + ret + ProcEnd noret +else + ProcBegin@ FindFreeChannel +; ========================== + + mov cx,NumberOfChannels + mov di,offset Channel0 +HuntAllChannelsLoop: + cmp cs:[di].TmpltEntOpen,0 + je FoundAFreeChannel + add di,size TmpltEnt + loop HuntAllChannelsLoop + stc + ret +FoundAFreeChannel: + clc + ret + ProcEnd noret +endif + +if PeripheralTypeDriver or TickRequired + ProcBegin@ MonitorInt,far +; ========================= + +if PeripheralTypeDriver +; Called on every tick +; Issues pack door hold and resumes +; In: Door state in SI + + cmp si,DoorOpen + je TheDoorIsOpenSoCantDoAnything + cmp CsHeldFlag,2 + je NeedToDoTheResume + ret +NeedToDoTheResume: + mov CsHeldFlag,0 + jmp DoResume +TheDoorIsOpenSoCantDoAnything: + cmp CsHeldFlag,0 + jne DontNeedToHold + mov CsHeldFlag,2 + mov ah,DevHoldPowerFail + jmp DoHold +DontNeedToHold: +endif + ret + ProcEnd noret +endif + + EndCodeSeg + stack segment stack para 'data' + stack ends + end TmpltLDD + + + + + + + + + + + + + diff --git a/code/SIBOSDK/ats/checkvid.bat b/code/SIBOSDK/ats/checkvid.bat new file mode 100644 index 0000000..5c6199f --- /dev/null +++ b/code/SIBOSDK/ats/checkvid.bat @@ -0,0 +1,2 @@ +@if not "%jpivid%"=="v2" set jpivid=v0 + diff --git a/code/SIBOSDK/ats/kats.afl b/code/SIBOSDK/ats/kats.afl new file mode 100644 index 0000000..e3981ed --- /dev/null +++ b/code/SIBOSDK/ats/kats.afl @@ -0,0 +1,2 @@ +kats.pic +kats.rsc diff --git a/code/SIBOSDK/ats/kats.c b/code/SIBOSDK/ats/kats.c new file mode 100644 index 0000000..4be199a --- /dev/null +++ b/code/SIBOSDK/ats/kats.c @@ -0,0 +1,498 @@ +/* + File: KATS.C +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#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; iname[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; iname[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); + } diff --git a/code/SIBOSDK/ats/kats.pic b/code/SIBOSDK/ats/kats.pic new file mode 100644 index 0000000..f9206fe Binary files /dev/null and b/code/SIBOSDK/ats/kats.pic differ diff --git a/code/SIBOSDK/ats/kats.pr b/code/SIBOSDK/ats/kats.pr new file mode 100644 index 0000000..99b81f0 --- /dev/null +++ b/code/SIBOSDK/ats/kats.pr @@ -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 + + diff --git a/code/SIBOSDK/ats/kats.rss b/code/SIBOSDK/ats/kats.rss new file mode 100644 index 0000000..e550b56 --- /dev/null +++ b/code/SIBOSDK/ats/kats.rss @@ -0,0 +1,102 @@ +#include +#include + +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; }; + } + }; + } diff --git a/code/SIBOSDK/ats/make.bat b/code/SIBOSDK/ats/make.bat new file mode 100644 index 0000000..319ca30 --- /dev/null +++ b/code/SIBOSDK/ats/make.bat @@ -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 diff --git a/code/SIBOSDK/ats/vid.bat b/code/SIBOSDK/ats/vid.bat new file mode 100644 index 0000000..4ccb4d5 --- /dev/null +++ b/code/SIBOSDK/ats/vid.bat @@ -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 + diff --git a/code/SIBOSDK/demo/alert.c b/code/SIBOSDK/demo/alert.c new file mode 100644 index 0000000..878ba01 --- /dev/null +++ b/code/SIBOSDK/demo/alert.c @@ -0,0 +1,50 @@ +#include +#include + +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;pdhposition=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); + } diff --git a/code/SIBOSDK/demo/bldall.bat b/code/SIBOSDK/demo/bldall.bat new file mode 100644 index 0000000..09612ff --- /dev/null +++ b/code/SIBOSDK/demo/bldall.bat @@ -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 diff --git a/code/SIBOSDK/demo/button.c b/code/SIBOSDK/demo/button.c new file mode 100644 index 0000000..1d1b345 --- /dev/null +++ b/code/SIBOSDK/demo/button.c @@ -0,0 +1,75 @@ +/* +BUTTON.C +*/ + +#include +#include + +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(); + } diff --git a/code/SIBOSDK/demo/cc.bat b/code/SIBOSDK/demo/cc.bat new file mode 100644 index 0000000..42c025d --- /dev/null +++ b/code/SIBOSDK/demo/cc.bat @@ -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 diff --git a/code/SIBOSDK/demo/checkvid.bat b/code/SIBOSDK/demo/checkvid.bat new file mode 100644 index 0000000..5c6199f --- /dev/null +++ b/code/SIBOSDK/demo/checkvid.bat @@ -0,0 +1,2 @@ +@if not "%jpivid%"=="v2" set jpivid=v0 + diff --git a/code/SIBOSDK/demo/clock.c b/code/SIBOSDK/demo/clock.c new file mode 100644 index 0000000..83570c3 --- /dev/null +++ b/code/SIBOSDK/demo/clock.c @@ -0,0 +1,40 @@ +/* +CLOCK.C +*/ + +#include +#include + +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(); + } diff --git a/code/SIBOSDK/demo/demo.prj b/code/SIBOSDK/demo/demo.prj new file mode 100644 index 0000000..e75a6e5 --- /dev/null +++ b/code/SIBOSDK/demo/demo.prj @@ -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 diff --git a/code/SIBOSDK/demo/events.c b/code/SIBOSDK/demo/events.c new file mode 100644 index 0000000..2bcbe22 --- /dev/null +++ b/code/SIBOSDK/demo/events.c @@ -0,0 +1,136 @@ +/* EVENTS.C */ + +#include +#include +#include +#include +#include + + +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(); + } + } + } diff --git a/code/SIBOSDK/demo/events2.c b/code/SIBOSDK/demo/events2.c new file mode 100644 index 0000000..4cd58b4 --- /dev/null +++ b/code/SIBOSDK/demo/events2.c @@ -0,0 +1,200 @@ +/* EVENTS2.C */ + +#include +#include +#include +#include +#include +#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(); + } + } diff --git a/code/SIBOSDK/demo/events3.c b/code/SIBOSDK/demo/events3.c new file mode 100644 index 0000000..308bd58 --- /dev/null +++ b/code/SIBOSDK/demo/events3.c @@ -0,0 +1,252 @@ +/* EVENTS3.C */ + +#include +#include +#include +#include +#include +#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(); + } + } + } diff --git a/code/SIBOSDK/demo/events4.c b/code/SIBOSDK/demo/events4.c new file mode 100644 index 0000000..643b119 --- /dev/null +++ b/code/SIBOSDK/demo/events4.c @@ -0,0 +1,278 @@ +/* EVENTS4.C */ + +#include +#include +#include +#include +#include +#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(); + } + } + } diff --git a/code/SIBOSDK/demo/fonts.c b/code/SIBOSDK/demo/fonts.c new file mode 100644 index 0000000..bcb211f --- /dev/null +++ b/code/SIBOSDK/demo/fonts.c @@ -0,0 +1,218 @@ +/* +FONTS.C - Display fonts + +This program was used to produce the font displays in the Window Server +Reference manual. +*/ + +#include +#include + +#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); + } diff --git a/code/SIBOSDK/demo/gauge.c b/code/SIBOSDK/demo/gauge.c new file mode 100644 index 0000000..b4086fa --- /dev/null +++ b/code/SIBOSDK/demo/gauge.c @@ -0,0 +1,212 @@ +#include +#include +#include + +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(); + } + } + } + } diff --git a/code/SIBOSDK/demo/hcshell.c b/code/SIBOSDK/demo/hcshell.c new file mode 100644 index 0000000..e351e68 --- /dev/null +++ b/code/SIBOSDK/demo/hcshell.c @@ -0,0 +1,70 @@ +/* +HCSHELL.C - Sample shell for the HC +*/ + +#include +#include + +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); + } diff --git a/code/SIBOSDK/demo/hello.c b/code/SIBOSDK/demo/hello.c new file mode 100644 index 0000000..41730c0 --- /dev/null +++ b/code/SIBOSDK/demo/hello.c @@ -0,0 +1,15 @@ +/* +HELLO.C + +CLIB Hello World application +*/ + +#include + + +int main(VOID) + { + printf("Hello World"); + getchar(); + return(0); + } diff --git a/code/SIBOSDK/demo/hello.pr b/code/SIBOSDK/demo/hello.pr new file mode 100644 index 0000000..7d915c9 --- /dev/null +++ b/code/SIBOSDK/demo/hello.pr @@ -0,0 +1,7 @@ +#system epoc img +#model small jpi + +#compile hello +#link hello + + diff --git a/code/SIBOSDK/demo/lined.c b/code/SIBOSDK/demo/lined.c new file mode 100644 index 0000000..9194314 --- /dev/null +++ b/code/SIBOSDK/demo/lined.c @@ -0,0 +1,396 @@ +#include +#include + +#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); + } + } + } + diff --git a/code/SIBOSDK/demo/lined.h b/code/SIBOSDK/demo/lined.h new file mode 100644 index 0000000..7b08687 --- /dev/null +++ b/code/SIBOSDK/demo/lined.h @@ -0,0 +1,43 @@ +#define LINED_H + +#ifndef P_STD_H +#include +#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); diff --git a/code/SIBOSDK/demo/lkshell.c b/code/SIBOSDK/demo/lkshell.c new file mode 100644 index 0000000..01cd86d --- /dev/null +++ b/code/SIBOSDK/demo/lkshell.c @@ -0,0 +1,79 @@ +/* +LKSHELL.C - Just starts up the link +*/ + +#include +#include + +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(); + } diff --git a/code/SIBOSDK/demo/lkshell.pr b/code/SIBOSDK/demo/lkshell.pr new file mode 100644 index 0000000..131b53d --- /dev/null +++ b/code/SIBOSDK/demo/lkshell.pr @@ -0,0 +1,5 @@ +#system epoc img +#set epocinit=iplib2 +#model small jpi +#compile lkshell +#link lkshell diff --git a/code/SIBOSDK/demo/make.bat b/code/SIBOSDK/demo/make.bat new file mode 100644 index 0000000..f260a39 --- /dev/null +++ b/code/SIBOSDK/demo/make.bat @@ -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 diff --git a/code/SIBOSDK/demo/p_comp.c b/code/SIBOSDK/demo/p_comp.c new file mode 100644 index 0000000..d992140 --- /dev/null +++ b/code/SIBOSDK/demo/p_comp.c @@ -0,0 +1,96 @@ +/* +P_COMP.C +*/ + +#include + +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 ?\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); + } diff --git a/code/SIBOSDK/demo/p_dlist.c b/code/SIBOSDK/demo/p_dlist.c new file mode 100644 index 0000000..85f326f --- /dev/null +++ b/code/SIBOSDK/demo/p_dlist.c @@ -0,0 +1,65 @@ +/* +P_DLIST.C +*/ + +#include + +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); + } diff --git a/code/SIBOSDK/demo/p_hello.c b/code/SIBOSDK/demo/p_hello.c new file mode 100644 index 0000000..02dc07d --- /dev/null +++ b/code/SIBOSDK/demo/p_hello.c @@ -0,0 +1,15 @@ +/* +P_HELLO.C + +PLIB Hello World application +*/ + +#include + + +GLDEF_C INT main(VOID) + { + p_printf("Hello World"); + p_getch(); + return(0); + } diff --git a/code/SIBOSDK/demo/p_hello.pr b/code/SIBOSDK/demo/p_hello.pr new file mode 100644 index 0000000..37acebf --- /dev/null +++ b/code/SIBOSDK/demo/p_hello.pr @@ -0,0 +1,7 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile p_hello +#link p_hello + diff --git a/code/SIBOSDK/demo/p_prndir.c b/code/SIBOSDK/demo/p_prndir.c new file mode 100644 index 0000000..197bf7e --- /dev/null +++ b/code/SIBOSDK/demo/p_prndir.c @@ -0,0 +1,75 @@ +/* +P_PRNDIR.C +*/ + +#include + +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); + } diff --git a/code/SIBOSDK/demo/p_search.c b/code/SIBOSDK/demo/p_search.c new file mode 100644 index 0000000..59f03e7 --- /dev/null +++ b/code/SIBOSDK/demo/p_search.c @@ -0,0 +1,56 @@ +/* +P_SEARCH.C +*/ + +#include + +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); + } diff --git a/code/SIBOSDK/demo/pcxsave.c b/code/SIBOSDK/demo/pcxsave.c new file mode 100644 index 0000000..2fa11a8 --- /dev/null +++ b/code/SIBOSDK/demo/pcxsave.c @@ -0,0 +1,139 @@ +/* +Save the screen to PCX file +*/ + +#include +#include + +#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 +#include +#include +#include + +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); + } diff --git a/code/SIBOSDK/demo/scapt.c b/code/SIBOSDK/demo/scapt.c new file mode 100644 index 0000000..a3b0d3a --- /dev/null +++ b/code/SIBOSDK/demo/scapt.c @@ -0,0 +1,31 @@ +/* +SCAPT.C - Capture the screen to a file +*/ + +#include +#include + +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); + } diff --git a/code/SIBOSDK/demo/scapt.pr b/code/SIBOSDK/demo/scapt.pr new file mode 100644 index 0000000..2936529 --- /dev/null +++ b/code/SIBOSDK/demo/scapt.pr @@ -0,0 +1,7 @@ +#system epoc img +#set epocinit=iplib2 +#model small jpi + +#compile scapt +#compile pcxsave +#link scapt diff --git a/code/SIBOSDK/demo/sound.c b/code/SIBOSDK/demo/sound.c new file mode 100644 index 0000000..514672e --- /dev/null +++ b/code/SIBOSDK/demo/sound.c @@ -0,0 +1,94 @@ +#include +#include +#include + +/* 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); +} + diff --git a/code/SIBOSDK/demo/subproc.c b/code/SIBOSDK/demo/subproc.c new file mode 100644 index 0000000..5231243 --- /dev/null +++ b/code/SIBOSDK/demo/subproc.c @@ -0,0 +1,31 @@ +/* SUBPROC.C */ + +#include +#include +#include +#include +#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); + } diff --git a/code/SIBOSDK/demo/subproc.h b/code/SIBOSDK/demo/subproc.h new file mode 100644 index 0000000..d21441c --- /dev/null +++ b/code/SIBOSDK/demo/subproc.h @@ -0,0 +1,6 @@ +typedef struct + { + HANDLE pid; + VOID *poff; + ULONG data; + } SUBPROC_CL; diff --git a/code/SIBOSDK/demo/unnamed.pr b/code/SIBOSDK/demo/unnamed.pr new file mode 100644 index 0000000..ce7f97b --- /dev/null +++ b/code/SIBOSDK/demo/unnamed.pr @@ -0,0 +1,5 @@ +#system epoc img +#set epocinit=iplib +#model small jpi +#compile %main +#link %main diff --git a/code/SIBOSDK/demo/vid.bat b/code/SIBOSDK/demo/vid.bat new file mode 100644 index 0000000..4ccb4d5 --- /dev/null +++ b/code/SIBOSDK/demo/vid.bat @@ -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 + diff --git a/code/SIBOSDK/demo/w_hello.c b/code/SIBOSDK/demo/w_hello.c new file mode 100644 index 0000000..c7e3b2b --- /dev/null +++ b/code/SIBOSDK/demo/w_hello.c @@ -0,0 +1,16 @@ +#include +#include + +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); + } diff --git a/code/SIBOSDK/ewdemo/ehbwin.c b/code/SIBOSDK/ewdemo/ehbwin.c new file mode 100644 index 0000000..c9924e6 --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehbwin.c @@ -0,0 +1,70 @@ +/* EHBWIN.C */ + +#include +#include +#include + +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); + } + } diff --git a/code/SIBOSDK/ewdemo/ehdlg.c b/code/SIBOSDK/ewdemo/ehdlg.c new file mode 100644 index 0000000..ab60147 --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehdlg.c @@ -0,0 +1,11 @@ +/* EHDLG.C */ + +#include +#include + +#pragma METHOD_CALL + +METHOD VOID ehdlg_dl_dyn_init(PR_DLGBOX *self) + { + hDlgSetText(1,self->dlgbox.rbuf); + } diff --git a/code/SIBOSDK/ewdemo/ehello.afl b/code/SIBOSDK/ewdemo/ehello.afl new file mode 100644 index 0000000..279ac4f --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehello.afl @@ -0,0 +1,2 @@ +ehello.pic +ehello.rzc diff --git a/code/SIBOSDK/ewdemo/ehello.cat b/code/SIBOSDK/ewdemo/ehello.cat new file mode 100644 index 0000000..ae208cf --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehello.cat @@ -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 + } diff --git a/code/SIBOSDK/ewdemo/ehello.pic b/code/SIBOSDK/ewdemo/ehello.pic new file mode 100644 index 0000000..d980c34 Binary files /dev/null and b/code/SIBOSDK/ewdemo/ehello.pic differ diff --git a/code/SIBOSDK/ewdemo/ehello.pr b/code/SIBOSDK/ewdemo/ehello.pr new file mode 100644 index 0000000..c75ea9c --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehello.pr @@ -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 diff --git a/code/SIBOSDK/ewdemo/ehello.re b/code/SIBOSDK/ewdemo/ehello.re new file mode 100644 index 0000000..c1b422f --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehello.re @@ -0,0 +1,3 @@ +#include + +_O_COM_EXIT diff --git a/code/SIBOSDK/ewdemo/ehello.rss b/code/SIBOSDK/ewdemo/ehello.rss new file mode 100644 index 0000000..818ec95 --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehello.rss @@ -0,0 +1,54 @@ +/* EHELLO.RSS */ + +#include +#include +#include + +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"; } diff --git a/code/SIBOSDK/ewdemo/ehmain.c b/code/SIBOSDK/ewdemo/ehmain.c new file mode 100644 index 0000000..16f9cf6 --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehmain.c @@ -0,0 +1,17 @@ +/* EHMAIN.C */ + +#include + +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); + } diff --git a/code/SIBOSDK/ewdemo/ehrel.prj b/code/SIBOSDK/ewdemo/ehrel.prj new file mode 100644 index 0000000..ee134eb --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehrel.prj @@ -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 diff --git a/code/SIBOSDK/ewdemo/ehwserv.c b/code/SIBOSDK/ewdemo/ehwserv.c new file mode 100644 index 0000000..3096862 --- /dev/null +++ b/code/SIBOSDK/ewdemo/ehwserv.c @@ -0,0 +1,11 @@ +/* EHWSERV.C */ + +#include + +#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); + } diff --git a/code/SIBOSDK/ewdemo/make.bat b/code/SIBOSDK/ewdemo/make.bat new file mode 100644 index 0000000..d0fea3a --- /dev/null +++ b/code/SIBOSDK/ewdemo/make.bat @@ -0,0 +1,3 @@ +@echo off +tscx /m ehello +tscx /m ehello diff --git a/code/SIBOSDK/fconv/s3fconv.lib b/code/SIBOSDK/fconv/s3fconv.lib new file mode 100644 index 0000000..b6a8229 Binary files /dev/null and b/code/SIBOSDK/fconv/s3fconv.lib differ diff --git a/code/SIBOSDK/fconv/txtread.c b/code/SIBOSDK/fconv/txtread.c new file mode 100644 index 0000000..4638bcb --- /dev/null +++ b/code/SIBOSDK/fconv/txtread.c @@ -0,0 +1,94 @@ +/* +TXTREAD.C +*/ + +#include +#include +#include +#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 *)¶code[0]='B'+('T'<<8); + para=SenseParaStyleBySC(¶code[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); + } diff --git a/code/SIBOSDK/fconv/txtwrite.c b/code/SIBOSDK/fconv/txtwrite.c new file mode 100644 index 0000000..f0f6c31 --- /dev/null +++ b/code/SIBOSDK/fconv/txtwrite.c @@ -0,0 +1,89 @@ +/* +TXTWRITE.C +*/ + +#include +#include +#include +#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;ptxtsave.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.curtagtxtsave.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); + } diff --git a/code/SIBOSDK/fconv/wl$txt.cat b/code/SIBOSDK/fconv/wl$txt.cat new file mode 100644 index 0000000..f4b5c4b --- /dev/null +++ b/code/SIBOSDK/fconv/wl$txt.cat @@ -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 + } + } diff --git a/code/SIBOSDK/fconv/wl$txt.dyl b/code/SIBOSDK/fconv/wl$txt.dyl new file mode 100644 index 0000000..0b1bdf8 Binary files /dev/null and b/code/SIBOSDK/fconv/wl$txt.dyl differ diff --git a/code/SIBOSDK/fconv/wl$txt.pr b/code/SIBOSDK/fconv/wl$txt.pr new file mode 100644 index 0000000..1499df0 --- /dev/null +++ b/code/SIBOSDK/fconv/wl$txt.pr @@ -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 + diff --git a/code/SIBOSDK/fconv/word.app b/code/SIBOSDK/fconv/word.app new file mode 100644 index 0000000..5d80d9f Binary files /dev/null and b/code/SIBOSDK/fconv/word.app differ diff --git a/code/SIBOSDK/fconv/wpfconv.h b/code/SIBOSDK/fconv/wpfconv.h new file mode 100644 index 0000000..ae6cf13 --- /dev/null +++ b/code/SIBOSDK/fconv/wpfconv.h @@ -0,0 +1,82 @@ +/* +WPFCONV.H + +Public word processor structures and prototypes for file conversion DYL code. +*/ + +#ifndef SCRLAY_G +#include +#endif +#ifndef PRINTER_G +#include +#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 *); diff --git a/code/SIBOSDK/fconv/ws$txt.cat b/code/SIBOSDK/fconv/ws$txt.cat new file mode 100644 index 0000000..ebe9581 --- /dev/null +++ b/code/SIBOSDK/fconv/ws$txt.cat @@ -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]; + } + } diff --git a/code/SIBOSDK/fconv/ws$txt.dyl b/code/SIBOSDK/fconv/ws$txt.dyl new file mode 100644 index 0000000..0c7e50a Binary files /dev/null and b/code/SIBOSDK/fconv/ws$txt.dyl differ diff --git a/code/SIBOSDK/fconv/ws$txt.pr b/code/SIBOSDK/fconv/ws$txt.pr new file mode 100644 index 0000000..8505a6b --- /dev/null +++ b/code/SIBOSDK/fconv/ws$txt.pr @@ -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 + diff --git a/code/SIBOSDK/font/bold.fsc b/code/SIBOSDK/font/bold.fsc new file mode 100644 index 0000000..b952859 --- /dev/null +++ b/code/SIBOSDK/font/bold.fsc @@ -0,0 +1,2311 @@ +*name Sys$bold +*special 1 +*descent 1 +*height 8 +*maxwid 8 +*flag ascii +*flag cp850 + +0000011 ;0 +0000011 +0000011 +0010011 +0110011 +1111111 +0110000 +0010000 + +00000000 ;1 +00000000 +00000000 +00000000 +00000000 +11010110 +11010110 +00000000 + +110110 ;2 +110110 +011100 +000000 +111110 +000000 +000000 +000000 + +110110 ;3 +011100 +011100 +110110 +000000 +000000 +000000 +000000 + +1111110 ;4 +1100110 +1100110 +1100110 +1101110 +1101100 +1111000 +0000000 + +0000000 ;5 +0111100 +1000010 +0011000 +1100110 +1100110 +1111110 +0000000 + +001000 ;6 +010100 +010100 +111110 +110110 +110110 +011100 +000000 + +000000 ;7 +000000 +000000 +000000 +111110 +000000 +000000 +000000 + +000 ;8 +000 +000 +000 +000 +000 +010 +010 + +0000000 ;9 +0000000 +0011000 +0011100 +1111110 +0011100 +0011000 +0000000 + +0011000 ;10 +0011000 +0011000 +0011000 +0011000 +1111110 +0111100 +0011000 + +0001110 ;11 +0001100 +0001100 +0001100 +0001100 +1101100 +0111000 +0000000 + +00000011 ;12 +00000110 +00000110 +00001100 +00001100 +10011000 +11011000 +01110000 + +00000000 ;13 +00000000 +00111000 +00111000 +11111110 +01111100 +00111000 +00000000 + +000000 ;14 +000000 +000000 +110110 +000000 +000000 +000000 +000000 + +000 ;15 +000 +000 +000 +000 +000 +000 +000 + +0000000 ;16 +0011000 +0011100 +1111110 +1111110 +0011100 +0011000 +0000000 + +0000000 ;17 +0011000 +0111000 +1111110 +1111110 +0111000 +0011000 +0000000 + +001111 ;18 +011000 +011000 +011000 +011000 +011000 +011000 +001111 + +11100 ;19 +00110 +00110 +00110 +00110 +00110 +00110 +11100 + +001111 ;20 +011010 +011101 +011010 +011101 +011010 +011101 +001111 + +11100 ;21 +10110 +01110 +10110 +01110 +10110 +01110 +11100 + +001111 ;22 +011111 +011111 +011111 +011111 +011111 +011111 +001111 + +11100 ;23 +11110 +11110 +11110 +11110 +11110 +11110 +11100 + +0011000 ;24 +0111100 +1111110 +0011000 +0011000 +0011000 +0011000 +0000000 + +0011000 ;25 +0011000 +0011000 +0011000 +1111110 +0111100 +0011000 +0000000 + +00000000 ;26 +00011000 +00011100 +11111110 +00011100 +00011000 +00000000 +00000000 + +00000000 ;27 +00110000 +01110000 +11111110 +01110000 +00110000 +00000000 +00000000 + +110000 ;28 +111000 +111100 +111110 +111100 +111000 +110000 +000000 + +0000000 ;29 +0011000 +0111100 +0111100 +1111110 +1111110 +0011000 +0000000 + +00000000 ;30 +00000000 +00111000 +01111100 +11111110 +00111000 +00111000 +00000000 + +0000000 ;31 +0000000 +0000000 +0000000 +0000000 +0000000 +0000000 +0000000 + +000 ;32 ' ' +000 +000 +000 +000 +000 +000 +000 + +0110 ;33 '!' +0110 +0110 +0110 +0110 +0000 +0110 +0000 + +110110 ;34 '"' +110110 +110110 +000000 +000000 +000000 +000000 +000000 + +00000000 ;35 '#' +01101100 +11111110 +01101100 +01101100 +11111110 +01101100 +00000000 + +0011000 ;36 '$' +0111110 +1011000 +0111100 +0011010 +1111100 +0011000 +0000000 + +1100000 ;37 '%' +1100110 +0001100 +0011000 +0110000 +1100110 +0000110 +0000000 + +0111100 ;38 '&' +1100110 +1101100 +0110000 +1101010 +1100100 +0111010 +0000000 + +1110 ;39 ''' +0110 +1100 +0000 +0000 +0000 +0000 +0000 + +00110 ;40 '(' +01100 +11000 +11000 +11000 +01100 +00110 +00000 + +11000 ;41 ')' +01100 +00110 +00110 +00110 +01100 +11000 +00000 + +0000000 ;42 '*' +0011000 +1011010 +0111100 +1011010 +0011000 +0000000 +0000000 + +0000000 ;43 '+' +0011000 +0011000 +1111110 +0011000 +0011000 +0000000 +0000000 + +0000 ;44 ',' +0000 +0000 +0000 +1110 +1110 +0110 +1100 + +000000 ;45 '-' +000000 +000000 +111110 +000000 +000000 +000000 +000000 + +0000 ;46 '.' +0000 +0000 +0000 +0000 +1110 +1110 +0000 + +0000000 ;47 '/' +0000110 +0001100 +0011000 +0110000 +1100000 +0000000 +0000000 + +0111100 ;48 '0' +1100110 +1101110 +1111110 +1110110 +1100110 +0111100 +0000000 + +0011000 ;49 '1' +0111000 +0011000 +0011000 +0011000 +0011000 +0111100 +0000000 + +0111100 ;50 '2' +1100110 +0000110 +0001100 +0011000 +0110000 +1111110 +0000000 + +0111100 ;51 '3' +1100110 +0000110 +0011100 +0000110 +1100110 +0111100 +0000000 + +0001100 ;52 '4' +0011100 +0111100 +1101100 +1111110 +0001100 +0001100 +0000000 + +1111110 ;53 '5' +1100000 +1111100 +0000110 +0000110 +1100110 +0111100 +0000000 + +0111100 ;54 '6' +1100110 +1100000 +1111100 +1100110 +1100110 +0111100 +0000000 + +1111110 ;55 '7' +0000110 +0001100 +0011000 +0110000 +0110000 +0110000 +0000000 + +0111100 ;56 '8' +1100110 +1100110 +0111100 +1100110 +1100110 +0111100 +0000000 + +0111100 ;57 '9' +1100110 +1100110 +0111110 +0000110 +1100110 +0111100 +0000000 + +0000 ;58 ':' +1110 +1110 +0000 +1110 +1110 +0000 +0000 + +0000 ;59 ';' +1110 +1110 +0000 +1110 +0110 +1100 +0000 + +000110 ;60 '<' +001100 +011000 +110000 +011000 +001100 +000110 +000000 + +000000 ;61 '=' +000000 +111110 +000000 +111110 +000000 +000000 +000000 + +110000 ;62 '>' +011000 +001100 +000110 +001100 +011000 +110000 +000000 + +0111100 ;63 '?' +1100110 +0000110 +0001100 +0011000 +0000000 +0011000 +0000000 + +0111100 ;64 '@' +1100110 +0000110 +0110110 +1010110 +1010110 +0111100 +0000000 + +0111100 ;65 'A' +1100110 +1100110 +1111110 +1100110 +1100110 +1100110 +0000000 + +1111100 ;66 'B' +1100110 +1100110 +1111100 +1100110 +1100110 +1111100 +0000000 + +0111100 ;67 'C' +1100110 +1100000 +1100000 +1100000 +1100110 +0111100 +0000000 + +1111000 ;68 'D' +1101100 +1100110 +1100110 +1100110 +1101100 +1111000 +0000000 + +111110 ;69 'E' +110000 +110000 +111100 +110000 +110000 +111110 +000000 + +111110 ;70 'F' +110000 +110000 +111100 +110000 +110000 +110000 +000000 + +0111100 ;71 'G' +1100110 +1100000 +1101110 +1100110 +1100110 +0111110 +0000000 + +1100110 ;72 'H' +1100110 +1100110 +1111110 +1100110 +1100110 +1100110 +0000000 + +11110 ;73 'I' +01100 +01100 +01100 +01100 +01100 +11110 +00000 + +0011110 ;74 'J' +0001100 +0001100 +0001100 +0001100 +1101100 +0111000 +0000000 + +1100110 ;75 'K' +1101100 +1111000 +1110000 +1111000 +1101100 +1100110 +0000000 + +110000 ;76 'L' +110000 +110000 +110000 +110000 +110000 +111110 +000000 + +11000110 ;77 'M' +11101110 +11010110 +11010110 +11000110 +11000110 +11000110 +00000000 + +1100110 ;78 'N' +1100110 +1110110 +1111110 +1101110 +1100110 +1100110 +0000000 + +0111100 ;79 'O' +1100110 +1100110 +1100110 +1100110 +1100110 +0111100 +0000000 + +1111100 ;80 'P' +1100110 +1100110 +1111100 +1100000 +1100000 +1100000 +0000000 + +0111100 ;81 'Q' +1100110 +1100110 +1100110 +1100110 +1101110 +0111100 +0000110 + +1111100 ;82 'R' +1100110 +1100110 +1111100 +1111000 +1101100 +1100110 +0000000 + +0111100 ;83 'S' +1100110 +1100000 +0111100 +0000110 +1100110 +0111100 +0000000 + +1111110 ;84 'T' +0011000 +0011000 +0011000 +0011000 +0011000 +0011000 +0000000 + +1100110 ;85 'U' +1100110 +1100110 +1100110 +1100110 +1100110 +0111100 +0000000 + +1100110 ;86 'V' +1100110 +1100110 +0111100 +0111100 +0011000 +0011000 +0000000 + +11000110 ;87 'W' +11000110 +11000110 +11000110 +11010110 +11010110 +01101100 +00000000 + +1100110 ;88 'X' +1100110 +0111100 +0111100 +0111100 +1100110 +1100110 +0000000 + +1100110 ;89 'Y' +1100110 +0111100 +0011000 +0011000 +0011000 +0011000 +0000000 + +1111110 ;90 'Z' +0000110 +0001100 +0011000 +0110000 +1100000 +1111110 +0000000 + +11110 ;91 '[' +11000 +11000 +11000 +11000 +11000 +11110 +00000 + +0000000 ;92 '\' +1100000 +0110000 +0011000 +0001100 +0000110 +0000000 +0000000 + +11110 ;93 ']' +00110 +00110 +00110 +00110 +00110 +11110 +00000 + +0011000 ;94 '^' +0111100 +1100110 +0000000 +0000000 +0000000 +0000000 +0000000 + +000000 ;95 '_' +000000 +000000 +000000 +000000 +000000 +111110 +000000 + +1110 ;96 '`' +1100 +0110 +0000 +0000 +0000 +0000 +0000 + +0000000 ;97 'a' +0000000 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +1100000 ;98 'b' +1100000 +1101100 +1110110 +1100110 +1100110 +1111100 +0000000 + +000000 ;99 'c' +000000 +011110 +110000 +110000 +110000 +011110 +000000 + +0000110 ;100 'd' +0000110 +0110110 +1101110 +1100110 +1100110 +0111110 +0000000 + +0000000 ;101 'e' +0000000 +0111100 +1100110 +1111110 +1100000 +0111100 +0000000 + +001110 ;102 'f' +011010 +011000 +111100 +011000 +011000 +011000 +000000 + +0000000 ;103 'g' +0000000 +0111110 +1100110 +1100110 +0111110 +0000110 +0111100 + +1100000 ;104 'h' +1100000 +1101100 +1110110 +1100110 +1100110 +1100110 +0000000 + +01100 ;105 'i' +00000 +11100 +01100 +01100 +01100 +11110 +00000 + +000110 ;106 'j' +000000 +001110 +000110 +000110 +000110 +110110 +011100 + +110000 ;107 'k' +110000 +110110 +111100 +111000 +111100 +110110 +000000 + +11100 ;108 'l' +01100 +01100 +01100 +01100 +01100 +11110 +00000 + +00000000 ;109 'm' +00000000 +11101100 +11010110 +11010110 +11000110 +11000110 +00000000 + +0000000 ;110 'n' +0000000 +1101100 +1110110 +1100110 +1100110 +1100110 +0000000 + +0000000 ;111 'o' +0000000 +0111100 +1100110 +1100110 +1100110 +0111100 +0000000 + +0000000 ;112 'p' +0000000 +1111100 +1100110 +1100110 +1111100 +1100000 +1100000 + +0000000 ;113 'q' +0000000 +0110110 +1101110 +1100110 +0111110 +0000110 +0000110 + +0000000 ;114 'r' +0000000 +1101100 +1110110 +1100000 +1100000 +1100000 +0000000 + +000000 ;115 's' +000000 +011110 +110000 +011100 +000110 +111100 +000000 + +011000 ;116 't' +011000 +111100 +011000 +011000 +011010 +001110 +000000 + +0000000 ;117 'u' +0000000 +1100110 +1100110 +1100110 +1101110 +0110110 +0000000 + +0000000 ;118 'v' +0000000 +1100110 +1100110 +1100110 +0111100 +0011000 +0000000 + +00000000 ;119 'w' +00000000 +11000110 +11000110 +11010110 +11010110 +01101100 +00000000 + +000000 ;120 'x' +000000 +110110 +110110 +011100 +110110 +110110 +000000 + +0000000 ;121 'y' +0000000 +1100110 +1100110 +1100110 +0111110 +0000110 +0111100 + +000000 ;122 'z' +000000 +111110 +000110 +011100 +110000 +111110 +000000 + +00110 ;123 '{' +01100 +01100 +11000 +01100 +01100 +00110 +00000 + +0110 ;124 '|' +0110 +0110 +0000 +0110 +0110 +0110 +0000 + +11000 ;125 '}' +01100 +01100 +00110 +01100 +01100 +11000 +00000 + +0110110 ;126 '~' +1101100 +0000000 +0000000 +0000000 +0000000 +0000000 +0000000 + +0000000 ;127 +0000000 +0011000 +0111100 +1100110 +1100110 +1111110 +0000000 + +0111100 ;128 '' +1100110 +1100000 +1100000 +1100000 +1100110 +0111100 +0011000 + +1100110 ;129 '' +0000000 +1100110 +1100110 +1100110 +1101110 +0110110 +0000000 + +0001100 ;130 '' +0011000 +0111100 +1100110 +1111110 +1100000 +0111100 +0000000 + +0011000 ;131 '' +0100100 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +1100110 ;132 '' +0000000 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +0110000 ;133 '' +0011000 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +0011000 ;134 '' +0000000 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +000000 ;135 '' +000000 +011110 +110000 +110000 +110000 +011110 +001100 + +0011000 ;136 '' +0100100 +0111100 +1100110 +1111110 +1100000 +0111100 +0000000 + +1100110 ;137 '' +0000000 +0111100 +1100110 +1111110 +1100000 +0111100 +0000000 + +0110000 ;138 '' +0011000 +0111100 +1100110 +1111110 +1100000 +0111100 +0000000 + +00000 ;139 '' +10010 +00000 +11100 +01100 +01100 +11110 +00000 + +01100 ;140 '' +10010 +00000 +11100 +01100 +01100 +11110 +00000 + +11000 ;141 '' +01100 +00000 +11100 +01100 +01100 +11110 +00000 + +1100110 ;142 '' +0000000 +0111100 +1100110 +1111110 +1100110 +1100110 +0000000 + +0011000 ;143 '' +0000000 +0111100 +1100110 +1111110 +1100110 +1100110 +0000000 + +001100 ;144 '' +011000 +111110 +110000 +111100 +110000 +111110 +000000 + +00000000 ;145 '' +00000000 +11101100 +00110110 +11111110 +11011000 +01111110 +00000000 + +01111110 ;146 '' +11011000 +11011000 +11011100 +11111000 +11011000 +11011110 +00000000 + +0011000 ;147 '' +0100100 +0000000 +0111100 +1100110 +1100110 +0111100 +0000000 + +0000000 ;148 '' +1100110 +0000000 +0111100 +1100110 +1100110 +0111100 +0000000 + +0110000 ;149 '' +0011000 +0000000 +0111100 +1100110 +1100110 +0111100 +0000000 + +0011000 ;150 '' +0100100 +0000000 +1100110 +1100110 +1101110 +0110110 +0000000 + +0110000 ;151 '' +0011000 +0000000 +1100110 +1100110 +1101110 +0110110 +0000000 + +0000000 ;152 '' +1100110 +0000000 +1100110 +1100110 +0111110 +0000110 +0111100 + +1100110 ;153 '' +0000000 +0111100 +1100110 +1100110 +1100110 +0111100 +0000000 + +1100110 ;154 '' +0000000 +1100110 +1100110 +1100110 +1100110 +0111100 +0000000 + +00000000 ;155 '' +00000010 +01111100 +11001110 +11010110 +11100110 +01111100 +10000000 + +0011100 ;156 '' +0110110 +0110000 +1111000 +0110000 +0110000 +1111110 +0000000 + +00000110 ;157 '' +01111100 +11001110 +11011110 +11110110 +11100110 +01111100 +11000000 + +000000 ;158 '' +000000 +110110 +011100 +011100 +110110 +000000 +000000 + +00001110 ;159 '' +00011010 +00011000 +01111100 +00110000 +00110000 +10110000 +11100000 + +0001100 ;160 '' +0011000 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +00110 ;161 '' +01100 +00000 +11100 +01100 +01100 +11110 +00000 + +0001100 ;162 '' +0011000 +0000000 +0111100 +1100110 +1100110 +0111100 +0000000 + +0001100 ;163 '' +0011000 +0000000 +1100110 +1100110 +1101110 +0110110 +0000000 + +0110110 ;164 '' +1101100 +0000000 +1101100 +1110110 +1100110 +1100110 +0000000 + +0110110 ;165 '' +1101100 +1100110 +1110110 +1101110 +1100110 +1100110 +0000000 + +0111100 ;166 '' +1101100 +1101100 +0111110 +0000000 +1111110 +0000000 +0000000 + +011100 ;167 '' +110110 +110110 +011100 +000000 +111110 +000000 +000000 + +0011000 ;168 '' +0000000 +0011000 +0110000 +1100000 +1100110 +0111100 +0000000 + +01111100 ;169 '' +11000110 +10110010 +10101010 +10110010 +10101010 +11000110 +01111100 + +000000 ;170 '' +000000 +000000 +111110 +000110 +000110 +000000 +000000 + +1001100 ;171 '' +1011000 +0110000 +1101100 +1010010 +0000100 +0001110 +0000000 + +1001100 ;172 '' +1011000 +0110100 +1101100 +1010100 +0011110 +0000100 +0000000 + +0110 ;173 '' +0000 +0110 +0110 +0110 +0110 +0110 +0000 + +00000000 ;174 '' +00110110 +01101100 +11011000 +01101100 +00110110 +00000000 +00000000 + +00000000 ;175 '' +11011000 +01101100 +00110110 +01101100 +11011000 +00000000 +00000000 + +11010110 ;176 '' +00000000 +11010110 +00000000 +11010110 +00000000 +11010110 +00000000 + +10101010 ;177 '' +01010101 +10101010 +01010101 +10101010 +01010101 +10101010 +01010101 + +10010010 ;178 '' +01001001 +10010010 +01001001 +10010010 +01001001 +10010010 +01001001 + +00011000 ;179 '' +00011000 +00011000 +00011000 +00011000 +00011000 +00011000 +00011000 + +00011000 ;180 '' +00011000 +00011000 +11111000 +00011000 +00011000 +00011000 +00011000 + +0001100 ;181 '' +0011000 +0111100 +1100110 +1111110 +1100110 +1100110 +0000000 + +0011000 ;182 '' +0100100 +0111100 +1100110 +1111110 +1100110 +1100110 +0000000 + +0110000 ;183 '' +0011000 +0111100 +1100110 +1111110 +1100110 +1100110 +0000000 + +01111100 ;184 '' +11000110 +10010010 +10100010 +10100010 +10010010 +11000110 +01111100 + +01100110 ;185 '' +01100110 +11100110 +00000110 +11100110 +01100110 +01100110 +01100110 + +01100110 ;186 '' +01100110 +01100110 +01100110 +01100110 +01100110 +01100110 +01100110 + +00000000 ;187 '' +00000000 +11111110 +00000110 +11100110 +01100110 +01100110 +01100110 + +01100110 ;188 '' +01100110 +11100110 +00000110 +11111110 +00000000 +00000000 +00000000 + +0000000 ;189 '' +0001100 +0111110 +1101100 +1101100 +1101100 +0111110 +0001100 + +1100110 ;190 '' +0111100 +1111110 +0011000 +1111110 +0011000 +0011000 +0000000 + +00000000 ;191 '' +00000000 +00000000 +11111000 +00011000 +00011000 +00011000 +00011000 + +00011000 ;192 '' +00011000 +00011000 +00011111 +00000000 +00000000 +00000000 +00000000 + +00011000 ;193 '' +00011000 +00011000 +11111111 +00000000 +00000000 +00000000 +00000000 + +00000000 ;194 '' +00000000 +00000000 +11111111 +00011000 +00011000 +00011000 +00011000 + +00011000 ;195 '' +00011000 +00011000 +00011111 +00011000 +00011000 +00011000 +00011000 + +00000000 ;196 '' +00000000 +00000000 +11111111 +00000000 +00000000 +00000000 +00000000 + +00011000 ;197 '' +00011000 +00011000 +11111111 +00011000 +00011000 +00011000 +00011000 + +0110110 ;198 '' +1101100 +0111100 +0000110 +0111110 +1100110 +0111110 +0000000 + +0110110 ;199 '' +1101100 +0111100 +1100110 +1111110 +1100110 +1100110 +0000000 + +01100110 ;200 '' +01100110 +01100111 +01100000 +01111111 +00000000 +00000000 +00000000 + +00000000 ;201 '' +00000000 +01111111 +01100000 +01100111 +01100110 +01100110 +01100110 + +01100110 ;202 '' +01100110 +11100111 +00000000 +11111111 +00000000 +00000000 +00000000 + +00000000 ;203 '' +00000000 +11111111 +00000000 +11100111 +01100110 +01100110 +01100110 + +01100110 ;204 '' +01100110 +01100111 +01100000 +01100111 +01100110 +01100110 +01100110 + +00000000 ;205 '' +00000000 +11111111 +00000000 +11111111 +00000000 +00000000 +00000000 + +01100110 ;206 '' +01100110 +11100111 +00000000 +11100111 +01100110 +01100110 +01100110 + +0000000 ;207 '' +0000000 +1100110 +0111100 +0100100 +0111100 +1100110 +0000000 + +0010110 ;208 '' +0001100 +0011110 +0000110 +0111110 +1100110 +0111100 +0000000 + +01111100 ;209 '' +01100110 +01100110 +11110110 +01100110 +01100110 +01111100 +00000000 + +011000 ;210 '' +100100 +111110 +110000 +111100 +110000 +111110 +000000 + +110110 ;211 '' +000000 +111110 +110000 +111100 +110000 +111110 +000000 + +011000 ;212 '' +001100 +111110 +110000 +111100 +110000 +111110 +000000 + +00000 ;213 '' +11100 +01100 +01100 +01100 +11110 +00000 +00000 + +00110 ;214 '' +01100 +11110 +01100 +01100 +01100 +11110 +00000 + +01100 ;215 '' +10010 +11110 +01100 +01100 +01100 +11110 +00000 + +10010 ;216 '' +00000 +11110 +01100 +01100 +01100 +11110 +00000 + +00011000 ;217 '' +00011000 +00011000 +11111000 +00000000 +00000000 +00000000 +00000000 + +00000000 ;218 '' +00000000 +00000000 +00011111 +00011000 +00011000 +00011000 +00011000 + +11111111 ;219 '' +11111111 +11111111 +11111111 +11111111 +11111111 +11111111 +11111111 + +00000000 ;220 '' +00000000 +00000000 +00000000 +11111111 +11111111 +11111111 +11111111 + +0110 ;221 '' +0110 +0110 +0000 +0000 +0110 +0110 +0110 + +11000 ;222 '' +01100 +11110 +01100 +01100 +01100 +11110 +00000 + +11111111 ;223 '' +11111111 +11111111 +11111111 +00000000 +00000000 +00000000 +00000000 + +0001100 ;224 '' +0011000 +0111100 +1100110 +1100110 +1100110 +0111100 +0000000 + +0000000 ;225 '' +0111100 +1100110 +1111100 +1100110 +1100110 +1111100 +1100000 + +0011000 ;226 '' +0100100 +0111100 +1100110 +1100110 +1100110 +0111100 +0000000 + +0110000 ;227 '' +0011000 +0111100 +1100110 +1100110 +1100110 +0111100 +0000000 + +0110110 ;228 '' +1101100 +0000000 +0111100 +1100110 +1100110 +0111100 +0000000 + +0110110 ;229 '' +1101100 +0111100 +1100110 +1100110 +1100110 +0111100 +0000000 + +0000000 ;230 '' +0000000 +1100110 +1100110 +1100110 +1101110 +1110110 +1100000 + +1100000 ;231 '' +1101100 +1110110 +1110110 +1101100 +1100000 +1100000 +1100000 + +1111000 ;232 '' +0110000 +0111100 +0110110 +0110110 +0111100 +0110000 +1111000 + +0001100 ;233 '' +0011000 +1100110 +1100110 +1100110 +1100110 +0111100 +0000000 + +0011000 ;234 '' +0100100 +1100110 +1100110 +1100110 +1100110 +0111100 +0000000 + +0110000 ;235 '' +0011000 +1100110 +1100110 +1100110 +1100110 +0111100 +0000000 + +0001100 ;236 '' +0011000 +0000000 +1100110 +1100110 +0111110 +0000110 +0111100 + +0001100 ;237 '' +0011000 +1100110 +1100110 +0111100 +0011000 +0011000 +0000000 + +0000 ;238 '' +0000 +1110 +0000 +0000 +0000 +0000 +0000 + +00110 ;239 '' +01100 +00000 +00000 +00000 +00000 +00000 +00000 + +0000 ;240 '' +0000 +0000 +0000 +1110 +0000 +0000 +0000 + +0011000 ;241 '' +0011000 +1111110 +0011000 +0011000 +0000000 +1111110 +0000000 + +000000 ;242 '' +000000 +000000 +000000 +000000 +111110 +000000 +111110 + +11000000 ;243 '' +01100000 +11100000 +01100000 +11001100 +00011100 +00111110 +00001100 + +01111110 ;244 '' +10110110 +10110110 +01110110 +00110110 +00110110 +00110110 +00000000 + +01110 ;245 '' +01100 +11110 +10010 +11110 +01100 +11100 +00000 + +0000000 ;246 '' +0011000 +0000000 +1111110 +0000000 +0011000 +0000000 +0000000 + +0000000 ;247 '' +0000000 +0000000 +0000000 +0000000 +0000000 +0001000 +0011000 + +011100 ;248 '' +110110 +110110 +011100 +000000 +000000 +000000 +000000 + +1100110 ;249 '' +0000000 +0000000 +0000000 +0000000 +0000000 +0000000 +0000000 + +0000 ;250 '' +0000 +0000 +1110 +1110 +0000 +0000 +0000 + +01100 ;251 '' +11100 +01100 +01100 +11110 +00000 +00000 +00000 + +11100 ;252 '' +00110 +01100 +00110 +11100 +00000 +00000 +00000 + +01100 ;253 '' +10110 +00110 +01100 +11110 +00000 +00000 +00000 + +00000 ;254 '' +00000 +00000 +11100 +11100 +00000 +00000 +00000 + +00000000 ;255 '' +00000000 +00000000 +00000000 +00000000 +00000000 +00000000 +00000000 diff --git a/code/SIBOSDK/font/diary.fsc b/code/SIBOSDK/font/diary.fsc new file mode 100644 index 0000000..3b8ba19 --- /dev/null +++ b/code/SIBOSDK/font/diary.fsc @@ -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 + + diff --git a/code/SIBOSDK/font/digit.fsc b/code/SIBOSDK/font/digit.fsc new file mode 100644 index 0000000..8586f65 --- /dev/null +++ b/code/SIBOSDK/font/digit.fsc @@ -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 + diff --git a/code/SIBOSDK/font/font.prj b/code/SIBOSDK/font/font.prj new file mode 100644 index 0000000..9f45d81 --- /dev/null +++ b/code/SIBOSDK/font/font.prj @@ -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 diff --git a/code/SIBOSDK/font/norm.fsc b/code/SIBOSDK/font/norm.fsc new file mode 100644 index 0000000..cc98101 --- /dev/null +++ b/code/SIBOSDK/font/norm.fsc @@ -0,0 +1,2311 @@ +*name Sys$norm +*special 1 +*descent 1 +*height 8 +*maxwid 6 +*flag ascii +*flag cp850 + +000001 ;0 +000001 +000001 +001001 +011001 +111111 +011000 +001000 + +000000 ;1 +000000 +000000 +000000 +000000 +101010 +101010 +000000 + +10010 ;2 +10010 +01100 +00000 +11110 +00000 +00000 +00000 + +10010 ;3 +01100 +01100 +10010 +00000 +00000 +00000 +00000 + +111110 ;4 +100010 +100010 +100010 +101110 +101100 +111000 +000000 + +000000 ;5 +011100 +100010 +001000 +010100 +010100 +011100 +000000 + +001000 ;6 +010100 +010100 +111110 +110110 +110110 +011100 +000000 + +000000 ;7 +000000 +000000 +000000 +111110 +000000 +000000 +000000 + +000 ;8 +000 +000 +000 +000 +000 +010 +010 + +000000 ;9 +000000 +001000 +001100 +111110 +001100 +001000 +000000 + +001000 ;10 +001000 +001000 +001000 +001000 +111110 +011100 +001000 + +001110 ;11 +001000 +001000 +001000 +001000 +101000 +010000 +000000 + +00000011 ;12 +00000110 +00000110 +00001100 +00001100 +10011000 +11011000 +01110000 + +0000000 ;13 +0000000 +0011000 +0011000 +1111110 +0111100 +0011000 +0000000 + +000000 ;14 +000000 +000000 +110110 +000000 +000000 +000000 +000000 + +000 ;15 +000 +000 +000 +000 +000 +000 +000 + +000000 ;16 +001000 +001100 +111110 +111110 +001100 +001000 +000000 + +000000 ;17 +001000 +011000 +111110 +111110 +011000 +001000 +000000 + +001111 ;18 +010000 +010000 +010000 +010000 +010000 +010000 +001111 + +11100 ;19 +00010 +00010 +00010 +00010 +00010 +00010 +11100 + +001111 ;20 +011010 +010101 +011010 +010101 +011010 +010101 +001111 + +11100 ;21 +10110 +01010 +10110 +01010 +10110 +01010 +11100 + +001111 ;22 +011111 +011111 +011111 +011111 +011111 +011111 +001111 + +11100 ;23 +11110 +11110 +11110 +11110 +11110 +11110 +11100 + +001000 ;24 +011100 +111110 +001000 +001000 +001000 +001000 +000000 + +001000 ;25 +001000 +001000 +001000 +111110 +011100 +001000 +000000 + +00000000 ;26 +00001000 +00001100 +11111110 +00001100 +00001000 +00000000 +00000000 + +00000000 ;27 +00100000 +01100000 +11111110 +01100000 +00100000 +00000000 +00000000 + +10000 ;28 +11000 +11100 +11110 +11100 +11000 +10000 +00000 + +000000 ;29 +001000 +011100 +011100 +111110 +111110 +001000 +000000 + +0000000 ;30 +0000000 +0011000 +0111100 +1111110 +0011000 +0011000 +0000000 + +000000 ;31 +000000 +000000 +000000 +000000 +000000 +000000 +000000 + +000 ;32 ' ' +000 +000 +000 +000 +000 +000 +000 + +010 ;33 '!' +010 +010 +010 +010 +000 +010 +000 + +1010 ;34 '"' +1010 +1010 +0000 +0000 +0000 +0000 +0000 + +000000 ;35 '#' +010100 +111110 +010100 +010100 +111110 +010100 +000000 + +001000 ;36 '$' +011110 +101000 +011100 +001010 +111100 +001000 +000000 + +110000 ;37 '%' +110010 +000100 +001000 +010000 +100110 +000110 +000000 + +011000 ;38 '&' +100100 +101000 +010000 +101010 +100100 +011010 +000000 + +110 ;39 ''' +010 +100 +000 +000 +000 +000 +000 + +0010 ;40 '(' +0100 +1000 +1000 +1000 +0100 +0010 +0000 + +1000 ;41 ')' +0100 +0010 +0010 +0010 +0100 +1000 +0000 + +000000 ;42 '*' +001000 +101010 +011100 +101010 +001000 +000000 +000000 + +000000 ;43 '+' +001000 +001000 +111110 +001000 +001000 +000000 +000000 + +000 ;44 ',' +000 +000 +000 +110 +110 +010 +100 + +000000 ;45 '-' +000000 +000000 +111110 +000000 +000000 +000000 +000000 + +000 ;46 '.' +000 +000 +000 +000 +110 +110 +000 + +000000 ;47 '/' +000010 +000100 +001000 +010000 +100000 +000000 +000000 + +011100 ;48 '0' +100010 +100110 +101010 +110010 +100010 +011100 +000000 + +001000 ;49 '1' +011000 +001000 +001000 +001000 +001000 +011100 +000000 + +011100 ;50 '2' +100010 +000010 +000100 +001000 +010000 +111110 +000000 + +011100 ;51 '3' +100010 +000010 +001100 +000010 +100010 +011100 +000000 + +000100 ;52 '4' +001100 +010100 +100100 +111110 +000100 +000100 +000000 + +111110 ;53 '5' +100000 +111100 +000010 +000010 +100010 +011100 +000000 + +011100 ;54 '6' +100010 +100000 +111100 +100010 +100010 +011100 +000000 + +111110 ;55 '7' +000010 +000100 +001000 +010000 +010000 +010000 +000000 + +011100 ;56 '8' +100010 +100010 +011100 +100010 +100010 +011100 +000000 + +011100 ;57 '9' +100010 +100010 +011110 +000010 +100010 +011100 +000000 + +000 ;58 ':' +110 +110 +000 +110 +110 +000 +000 + +000 ;59 ';' +110 +110 +000 +110 +010 +100 +000 + +00010 ;60 '<' +00100 +01000 +10000 +01000 +00100 +00010 +00000 + +000000 ;61 '=' +000000 +111110 +000000 +111110 +000000 +000000 +000000 + +10000 ;62 '>' +01000 +00100 +00010 +00100 +01000 +10000 +00000 + +011100 ;63 '?' +100010 +000010 +000100 +001000 +000000 +001000 +000000 + +011100 ;64 '@' +100010 +000010 +011010 +101010 +101010 +011100 +000000 + +011100 ;65 'A' +100010 +100010 +111110 +100010 +100010 +100010 +000000 + +111100 ;66 'B' +100010 +100010 +111100 +100010 +100010 +111100 +000000 + +011100 ;67 'C' +100010 +100000 +100000 +100000 +100010 +011100 +000000 + +111000 ;68 'D' +100100 +100010 +100010 +100010 +100100 +111000 +000000 + +111110 ;69 'E' +100000 +100000 +111100 +100000 +100000 +111110 +000000 + +111110 ;70 'F' +100000 +100000 +111100 +100000 +100000 +100000 +000000 + +011100 ;71 'G' +100010 +100000 +100110 +100010 +100010 +011110 +000000 + +100010 ;72 'H' +100010 +100010 +111110 +100010 +100010 +100010 +000000 + +1110 ;73 'I' +0100 +0100 +0100 +0100 +0100 +1110 +0000 + +001110 ;74 'J' +000100 +000100 +000100 +000100 +100100 +011000 +000000 + +100010 ;75 'K' +100100 +101000 +110000 +101000 +100100 +100010 +000000 + +10000 ;76 'L' +10000 +10000 +10000 +10000 +10000 +11110 +00000 + +100010 ;77 'M' +110110 +101010 +101010 +100010 +100010 +100010 +000000 + +100010 ;78 'N' +110010 +101010 +101010 +100110 +100010 +100010 +000000 + +011100 ;79 'O' +100010 +100010 +100010 +100010 +100010 +011100 +000000 + +111100 ;80 'P' +100010 +100010 +111100 +100000 +100000 +100000 +000000 + +011100 ;81 'Q' +100010 +100010 +100010 +100010 +101010 +011100 +000010 + +111100 ;82 'R' +100010 +100010 +111100 +101000 +100100 +100010 +000000 + +011100 ;83 'S' +100010 +100000 +011100 +000010 +100010 +011100 +000000 + +111110 ;84 'T' +001000 +001000 +001000 +001000 +001000 +001000 +000000 + +100010 ;85 'U' +100010 +100010 +100010 +100010 +100010 +011100 +000000 + +100010 ;86 'V' +100010 +100010 +010100 +010100 +001000 +001000 +000000 + +100010 ;87 'W' +100010 +100010 +100010 +101010 +101010 +010100 +000000 + +100010 ;88 'X' +100010 +010100 +001000 +010100 +100010 +100010 +000000 + +100010 ;89 'Y' +100010 +010100 +001000 +001000 +001000 +001000 +000000 + +111110 ;90 'Z' +000010 +000100 +001000 +010000 +100000 +111110 +000000 + +1110 ;91 '[' +1000 +1000 +1000 +1000 +1000 +1110 +0000 + +000000 ;92 '\' +100000 +010000 +001000 +000100 +000010 +000000 +000000 + +1110 ;93 ']' +0010 +0010 +0010 +0010 +0010 +1110 +0000 + +001000 ;94 '^' +010100 +100010 +000000 +000000 +000000 +000000 +000000 + +000000 ;95 '_' +000000 +000000 +000000 +000000 +000000 +111110 +000000 + +110 ;96 '`' +100 +010 +000 +000 +000 +000 +000 + +000000 ;97 'a' +000000 +011100 +000010 +011110 +100010 +011110 +000000 + +100000 ;98 'b' +100000 +101100 +110010 +100010 +100010 +111100 +000000 + +00000 ;99 'c' +00000 +01110 +10000 +10000 +10000 +01110 +00000 + +000010 ;100 'd' +000010 +011010 +100110 +100010 +100010 +011110 +000000 + +000000 ;101 'e' +000000 +011100 +100010 +111110 +100000 +011100 +000000 + +00100 ;102 'f' +01010 +01000 +11100 +01000 +01000 +01000 +00000 + +000000 ;103 'g' +000000 +011110 +100010 +100010 +011110 +000010 +011100 + +100000 ;104 'h' +100000 +101100 +110010 +100010 +100010 +100010 +000000 + +0100 ;105 'i' +0000 +1100 +0100 +0100 +0100 +1110 +0000 + +00010 ;106 'j' +00000 +00110 +00010 +00010 +00010 +10010 +01100 + +10000 ;107 'k' +10000 +10010 +10100 +11000 +10100 +10010 +00000 + +1100 ;108 'l' +0100 +0100 +0100 +0100 +0100 +1110 +0000 + +000000 ;109 'm' +000000 +110100 +101010 +101010 +100010 +100010 +000000 + +000000 ;110 'n' +000000 +101100 +110010 +100010 +100010 +100010 +000000 + +000000 ;111 'o' +000000 +011100 +100010 +100010 +100010 +011100 +000000 + +000000 ;112 'p' +000000 +111100 +100010 +100010 +111100 +100000 +100000 + +000000 ;113 'q' +000000 +011010 +100110 +100010 +011110 +000010 +000010 + +000000 ;114 'r' +000000 +101100 +110010 +100000 +100000 +100000 +000000 + +00000 ;115 's' +00000 +01110 +10000 +01100 +00010 +11100 +00000 + +01000 ;116 't' +01000 +11100 +01000 +01000 +01010 +00100 +00000 + +000000 ;117 'u' +000000 +100010 +100010 +100010 +100110 +011010 +000000 + +000000 ;118 'v' +000000 +100010 +100010 +100010 +010100 +001000 +000000 + +000000 ;119 'w' +000000 +100010 +100010 +101010 +101010 +010100 +000000 + +00000 ;120 'x' +00000 +10010 +10010 +01100 +10010 +10010 +00000 + +000000 ;121 'y' +000000 +100010 +100010 +100010 +011110 +000010 +011100 + +00000 ;122 'z' +00000 +11110 +00010 +01100 +10000 +11110 +00000 + +0010 ;123 '{' +0100 +0100 +1000 +0100 +0100 +0010 +0000 + +010 ;124 '|' +010 +010 +000 +010 +010 +010 +000 + +1000 ;125 '}' +0100 +0100 +0010 +0100 +0100 +1000 +0000 + +01010 ;126 '~' +10100 +00000 +00000 +00000 +00000 +00000 +00000 + +000000 ;127 +000000 +001000 +010100 +100010 +100010 +111110 +000000 + +011100 ;128 '' +100010 +100000 +100000 +100000 +100010 +011100 +001000 + +010100 ;129 '' +000000 +100010 +100010 +100010 +100110 +011010 +000000 + +000100 ;130 '' +001000 +011100 +100010 +111110 +100000 +011100 +000000 + +001000 ;131 '' +010100 +011100 +000010 +011110 +100010 +011110 +000000 + +010100 ;132 '' +000000 +011100 +000010 +011110 +100010 +011110 +000000 + +010000 ;133 '' +001000 +011100 +000010 +011110 +100010 +011110 +000000 + +001000 ;134 '' +000000 +011100 +000010 +011110 +100010 +011110 +000000 + +00000 ;135 '' +00000 +01110 +10000 +10000 +10000 +01110 +00100 + +001000 ;136 '' +010100 +011100 +100010 +111110 +100000 +011100 +000000 + +010100 ;137 '' +000000 +011100 +100010 +111110 +100000 +011100 +000000 + +010000 ;138 '' +001000 +011100 +100010 +111110 +100000 +011100 +000000 + +0000 ;139 '' +1010 +0000 +1100 +0100 +0100 +1110 +0000 + +0100 ;140 '' +1010 +0000 +1100 +0100 +0100 +1110 +0000 + +1000 ;141 '' +0100 +0000 +1100 +0100 +0100 +1110 +0000 + +010100 ;142 '' +000000 +011100 +100010 +111110 +100010 +100010 +000000 + +001000 ;143 '' +000000 +011100 +100010 +111110 +100010 +100010 +000000 + +000100 ;144 '' +001000 +111110 +100000 +111100 +100000 +111110 +000000 + +000000 ;145 '' +000000 +110100 +001010 +111100 +101000 +010110 +000000 + +011110 ;146 '' +101000 +101000 +101100 +111000 +101000 +101110 +000000 + +001000 ;147 '' +010100 +000000 +011100 +100010 +100010 +011100 +000000 + +000000 ;148 '' +010100 +000000 +011100 +100010 +100010 +011100 +000000 + +010000 ;149 '' +001000 +000000 +011100 +100010 +100010 +011100 +000000 + +001000 ;150 '' +010100 +000000 +100010 +100010 +100110 +011010 +000000 + +010000 ;151 '' +001000 +000000 +100010 +100010 +100110 +011010 +000000 + +000000 ;152 '' +010100 +000000 +100010 +100010 +011110 +000010 +011100 + +010100 ;153 '' +000000 +011100 +100010 +100010 +100010 +011100 +000000 + +010100 ;154 '' +000000 +100010 +100010 +100010 +100010 +011100 +000000 + +000000 ;155 '' +000010 +011100 +100110 +101010 +110010 +011100 +100000 + +001100 ;156 '' +010010 +010000 +111000 +010000 +010000 +111110 +000000 + +000010 ;157 '' +011100 +100110 +101010 +101010 +110010 +011100 +100000 + +00000 ;158 '' +00000 +10010 +01100 +01100 +10010 +00000 +00000 + +000110 ;159 '' +001010 +001000 +011100 +001000 +001000 +101000 +110000 + +000100 ;160 '' +001000 +011100 +000010 +011110 +100010 +011110 +000000 + +0010 ;161 '' +0100 +0000 +1100 +0100 +0100 +1110 +0000 + +000100 ;162 '' +001000 +000000 +011100 +100010 +100010 +011100 +000000 + +000100 ;163 '' +001000 +000000 +100010 +100010 +100110 +011010 +000000 + +001010 ;164 '' +010100 +000000 +101100 +110010 +100010 +100010 +000000 + +001010 ;165 '' +010100 +100010 +110010 +101010 +100110 +100010 +000000 + +011100 ;166 '' +100100 +100100 +011110 +000000 +111110 +000000 +000000 + +011000 ;167 '' +100100 +100100 +011000 +000000 +111100 +000000 +000000 + +001000 ;168 '' +000000 +001000 +010000 +100000 +100010 +011100 +000000 + +00111000 ;169 '' +01000100 +10110010 +10101010 +10110010 +10101010 +01000100 +00111000 + +00000 ;170 '' +00000 +00000 +11110 +00010 +00010 +00000 +00000 + +100100 ;171 '' +101000 +010000 +101100 +010010 +000100 +001110 +000000 + +100100 ;172 '' +101000 +010100 +101100 +010100 +011110 +000100 +000000 + +010 ;173 '' +000 +010 +010 +010 +010 +010 +000 + +000000 ;174 '' +001010 +010100 +101000 +010100 +001010 +000000 +000000 + +000000 ;175 '' +101000 +010100 +001010 +010100 +101000 +000000 +000000 + +101010 ;176 '' +000000 +101010 +000000 +101010 +000000 +101010 +000000 + +101010 ;177 '' +010101 +101010 +010101 +101010 +010101 +101010 +010101 + +100100 ;178 '' +010010 +100100 +010010 +100100 +010010 +100100 +010010 + +001000 ;179 '' +001000 +001000 +001000 +001000 +001000 +001000 +001000 + +001000 ;180 '' +001000 +001000 +111000 +001000 +001000 +001000 +001000 + +000100 ;181 '' +001000 +011100 +100010 +111110 +100010 +100010 +000000 + +001000 ;182 '' +010100 +011100 +100010 +111110 +100010 +100010 +000000 + +010000 ;183 '' +001000 +011100 +100010 +111110 +100010 +100010 +000000 + +00111000 ;184 '' +01000100 +10010010 +10100010 +10100010 +10010010 +01000100 +00111000 + +010100 ;185 '' +010100 +110100 +000100 +110100 +010100 +010100 +010100 + +010100 ;186 '' +010100 +010100 +010100 +010100 +010100 +010100 +010100 + +000000 ;187 '' +000000 +111100 +000100 +110100 +010100 +010100 +010100 + +010100 ;188 '' +010100 +110100 +000100 +111100 +000000 +000000 +000000 + +00000 ;189 '' +00100 +01110 +10100 +10100 +10100 +01110 +00100 + +100010 ;190 '' +010100 +111110 +001000 +111110 +001000 +001000 +000000 + +000000 ;191 '' +000000 +000000 +111000 +001000 +001000 +001000 +001000 + +001000 ;192 '' +001000 +001000 +001111 +000000 +000000 +000000 +000000 + +001000 ;193 '' +001000 +001000 +111111 +000000 +000000 +000000 +000000 + +000000 ;194 '' +000000 +000000 +111111 +001000 +001000 +001000 +001000 + +001000 ;195 '' +001000 +001000 +001111 +001000 +001000 +001000 +001000 + +000000 ;196 '' +000000 +000000 +111111 +000000 +000000 +000000 +000000 + +001000 ;197 '' +001000 +001000 +111111 +001000 +001000 +001000 +001000 + +001010 ;198 '' +010100 +011100 +000010 +011110 +100010 +011110 +000000 + +001010 ;199 '' +010100 +011100 +100010 +111110 +100010 +100010 +000000 + +010100 ;200 '' +010100 +010111 +010000 +011111 +000000 +000000 +000000 + +000000 ;201 '' +000000 +011111 +010000 +010111 +010100 +010100 +010100 + +010100 ;202 '' +010100 +110111 +000000 +111111 +000000 +000000 +000000 + +000000 ;203 '' +000000 +111111 +000000 +110111 +010100 +010100 +010100 + +010100 ;204 '' +010100 +010111 +010000 +010111 +010100 +010100 +010100 + +000000 ;205 '' +000000 +111111 +000000 +111111 +000000 +000000 +000000 + +010100 ;206 '' +010100 +110111 +000000 +110111 +010100 +010100 +010100 + +000000 ;207 '' +000000 +100010 +011100 +010100 +011100 +100010 +000000 + +001010 ;208 '' +000100 +001010 +000010 +011110 +100010 +011100 +000000 + +011100 ;209 '' +010010 +010010 +111010 +010010 +010010 +011100 +000000 + +001000 ;210 '' +010100 +111110 +100000 +111100 +100000 +111110 +000000 + +010100 ;211 '' +000000 +111110 +100000 +111100 +100000 +111110 +000000 + +010000 ;212 '' +001000 +111110 +100000 +111100 +100000 +111110 +000000 + +0000 ;213 '' +1100 +0100 +0100 +0100 +1110 +0000 +0000 + +0010 ;214 '' +0100 +1110 +0100 +0100 +0100 +1110 +0000 + +0100 ;215 '' +1010 +1110 +0100 +0100 +0100 +1110 +0000 + +1010 ;216 '' +0000 +1110 +0100 +0100 +0100 +1110 +0000 + +001000 ;217 '' +001000 +001000 +111000 +000000 +000000 +000000 +000000 + +000000 ;218 '' +000000 +000000 +001111 +001000 +001000 +001000 +001000 + +111111 ;219 '' +111111 +111111 +111111 +111111 +111111 +111111 +111111 + +000000 ;220 '' +000000 +000000 +000000 +111111 +111111 +111111 +111111 + +010 ;221 '' +010 +010 +000 +000 +010 +010 +010 + +1000 ;222 '' +0100 +1110 +0100 +0100 +0100 +1110 +0000 + +111111 ;223 '' +111111 +111111 +111111 +000000 +000000 +000000 +000000 + +000100 ;224 '' +001000 +011100 +100010 +100010 +100010 +011100 +000000 + +000000 ;225 '' +011100 +100010 +111100 +100010 +100010 +111100 +100000 + +001000 ;226 '' +010100 +011100 +100010 +100010 +100010 +011100 +000000 + +010000 ;227 '' +001000 +011100 +100010 +100010 +100010 +011100 +000000 + +001010 ;228 '' +010100 +000000 +011100 +100010 +100010 +011100 +000000 + +001010 ;229 '' +010100 +011100 +100010 +100010 +100010 +011100 +000000 + +000000 ;230 '' +000000 +100010 +100010 +100010 +100110 +111010 +100000 + +100000 ;231 '' +101100 +110010 +110010 +101100 +100000 +100000 +100000 + +111000 ;232 '' +010000 +011100 +010010 +010010 +011100 +010000 +111000 + +000100 ;233 '' +001000 +100010 +100010 +100010 +100010 +011100 +000000 + +001000 ;234 '' +010100 +100010 +100010 +100010 +100010 +011100 +000000 + +010000 ;235 '' +001000 +100010 +100010 +100010 +100010 +011100 +000000 + +000100 ;236 '' +001000 +000000 +100010 +100010 +011110 +000010 +011100 + +000100 ;237 '' +001000 +100010 +100010 +010100 +001000 +001000 +000000 + +0000 ;238 '' +0000 +1110 +0000 +0000 +0000 +0000 +0000 + +000100 ;239 '' +001000 +000000 +000000 +000000 +000000 +000000 +000000 + +0000 ;240 '' +0000 +0000 +0000 +1110 +0000 +0000 +0000 + +001000 ;241 '' +001000 +111110 +001000 +001000 +000000 +111110 +000000 + +000000 ;242 '' +000000 +000000 +000000 +000000 +111110 +000000 +111110 + +100000 ;243 '' +010000 +110000 +010000 +100100 +001100 +011110 +000100 + +011110 ;244 '' +101010 +101010 +011010 +001010 +001010 +001010 +000000 + +0110 ;245 '' +0100 +1110 +1010 +1110 +0100 +1100 +0000 + +000000 ;246 '' +001000 +000000 +111110 +000000 +001000 +000000 +000000 + +000000 ;247 '' +000000 +000000 +000000 +000000 +000000 +001000 +001000 + +01100 ;248 '' +10010 +10010 +01100 +00000 +00000 +00000 +00000 + +010100 ;249 '' +000000 +000000 +000000 +000000 +000000 +000000 +000000 + +000 ;250 '' +000 +000 +110 +110 +000 +000 +000 + +0100 ;251 '' +1100 +0100 +0100 +1110 +0000 +0000 +0000 + +1100 ;252 '' +0010 +0100 +0010 +1100 +0000 +0000 +0000 + +0100 ;253 '' +1010 +0010 +0100 +1110 +0000 +0000 +0000 + +0000 ;254 '' +0000 +0000 +1100 +1100 +0000 +0000 +0000 + +000000 ;255 '' +000000 +000000 +000000 +000000 +000000 +000000 +000000 diff --git a/code/SIBOSDK/font/read.me b/code/SIBOSDK/font/read.me new file mode 100644 index 0000000..d9886cd --- /dev/null +++ b/code/SIBOSDK/font/read.me @@ -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 The descent for the font + +*height The height for the font + +*maxwid Not the real maximum width, but the width of the + widest normal character + +*flag Some informational flags + +*char 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. diff --git a/code/SIBOSDK/hcmast/big.fon b/code/SIBOSDK/hcmast/big.fon new file mode 100644 index 0000000..1de7bed Binary files /dev/null and b/code/SIBOSDK/hcmast/big.fon differ diff --git a/code/SIBOSDK/hcmast/cheng.cfo b/code/SIBOSDK/hcmast/cheng.cfo new file mode 100644 index 0000000..29da13a Binary files /dev/null and b/code/SIBOSDK/hcmast/cheng.cfo differ diff --git a/code/SIBOSDK/hcmast/chengel.cfo b/code/SIBOSDK/hcmast/chengel.cfo new file mode 100644 index 0000000..c7d5030 Binary files /dev/null and b/code/SIBOSDK/hcmast/chengel.cfo differ diff --git a/code/SIBOSDK/hcmast/chfrn.cfo b/code/SIBOSDK/hcmast/chfrn.cfo new file mode 100644 index 0000000..cd410e6 Binary files /dev/null and b/code/SIBOSDK/hcmast/chfrn.cfo differ diff --git a/code/SIBOSDK/hcmast/chfrnel.cfo b/code/SIBOSDK/hcmast/chfrnel.cfo new file mode 100644 index 0000000..c7d5030 Binary files /dev/null and b/code/SIBOSDK/hcmast/chfrnel.cfo differ diff --git a/code/SIBOSDK/hcmast/chnzl.cfo b/code/SIBOSDK/hcmast/chnzl.cfo new file mode 100644 index 0000000..bdcb246 Binary files /dev/null and b/code/SIBOSDK/hcmast/chnzl.cfo differ diff --git a/code/SIBOSDK/hcmast/chnzlel.cfo b/code/SIBOSDK/hcmast/chnzlel.cfo new file mode 100644 index 0000000..c7d5030 Binary files /dev/null and b/code/SIBOSDK/hcmast/chnzlel.cfo differ diff --git a/code/SIBOSDK/hcmast/chswe.cfo b/code/SIBOSDK/hcmast/chswe.cfo new file mode 100644 index 0000000..2a5049e Binary files /dev/null and b/code/SIBOSDK/hcmast/chswe.cfo differ diff --git a/code/SIBOSDK/hcmast/chsweel.cfo b/code/SIBOSDK/hcmast/chsweel.cfo new file mode 100644 index 0000000..c7d5030 Binary files /dev/null and b/code/SIBOSDK/hcmast/chsweel.cfo differ diff --git a/code/SIBOSDK/hcmast/custom$.dat b/code/SIBOSDK/hcmast/custom$.dat new file mode 100644 index 0000000..941f728 --- /dev/null +++ b/code/SIBOSDK/hcmast/custom$.dat @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/code/SIBOSDK/hcmast/makemast.bat b/code/SIBOSDK/hcmast/makemast.bat new file mode 100644 index 0000000..e4ecb60 --- /dev/null +++ b/code/SIBOSDK/hcmast/makemast.bat @@ -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 diff --git a/code/SIBOSDK/hcmast/mclinkpa.trm b/code/SIBOSDK/hcmast/mclinkpa.trm new file mode 100644 index 0000000..ae987b4 Binary files /dev/null and b/code/SIBOSDK/hcmast/mclinkpa.trm differ diff --git a/code/SIBOSDK/hcmast/mon_5x8.fon b/code/SIBOSDK/hcmast/mon_5x8.fon new file mode 100644 index 0000000..bce02a3 Binary files /dev/null and b/code/SIBOSDK/hcmast/mon_5x8.fon differ diff --git a/code/SIBOSDK/hcmast/mono.fon b/code/SIBOSDK/hcmast/mono.fon new file mode 100644 index 0000000..71b334f Binary files /dev/null and b/code/SIBOSDK/hcmast/mono.fon differ diff --git a/code/SIBOSDK/hcmast/mrchv.bat b/code/SIBOSDK/hcmast/mrchv.bat new file mode 100644 index 0000000..7c0cdf1 --- /dev/null +++ b/code/SIBOSDK/hcmast/mrchv.bat @@ -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 diff --git a/code/SIBOSDK/hcmast/olib.dyl b/code/SIBOSDK/hcmast/olib.dyl new file mode 100644 index 0000000..34d4d2e Binary files /dev/null and b/code/SIBOSDK/hcmast/olib.dyl differ diff --git a/code/SIBOSDK/hcmast/olibx.dyl b/code/SIBOSDK/hcmast/olibx.dyl new file mode 100644 index 0000000..04ef26a Binary files /dev/null and b/code/SIBOSDK/hcmast/olibx.dyl differ diff --git a/code/SIBOSDK/hcmast/oplch.dyl b/code/SIBOSDK/hcmast/oplch.dyl new file mode 100644 index 0000000..e0befa8 Binary files /dev/null and b/code/SIBOSDK/hcmast/oplch.dyl differ diff --git a/code/SIBOSDK/hcmast/oplterr.rsc b/code/SIBOSDK/hcmast/oplterr.rsc new file mode 100644 index 0000000..21426fd Binary files /dev/null and b/code/SIBOSDK/hcmast/oplterr.rsc differ diff --git a/code/SIBOSDK/hcmast/repro.app b/code/SIBOSDK/hcmast/repro.app new file mode 100644 index 0000000..b3c55c4 Binary files /dev/null and b/code/SIBOSDK/hcmast/repro.app differ diff --git a/code/SIBOSDK/hcmast/sch.rom b/code/SIBOSDK/hcmast/sch.rom new file mode 100644 index 0000000..a7ee048 --- /dev/null +++ b/code/SIBOSDK/hcmast/sch.rom @@ -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 diff --git a/code/SIBOSDK/hcmast/small.fon b/code/SIBOSDK/hcmast/small.fon new file mode 100644 index 0000000..a8c9689 Binary files /dev/null and b/code/SIBOSDK/hcmast/small.fon differ diff --git a/code/SIBOSDK/hcmast/sys$bold.fon b/code/SIBOSDK/hcmast/sys$bold.fon new file mode 100644 index 0000000..44cf92b Binary files /dev/null and b/code/SIBOSDK/hcmast/sys$bold.fon differ diff --git a/code/SIBOSDK/hcmast/sys$env.ini b/code/SIBOSDK/hcmast/sys$env.ini new file mode 100644 index 0000000..a9ef960 Binary files /dev/null and b/code/SIBOSDK/hcmast/sys$env.ini differ diff --git a/code/SIBOSDK/hcmast/sys$norm.fon b/code/SIBOSDK/hcmast/sys$norm.fon new file mode 100644 index 0000000..59f90c4 Binary files /dev/null and b/code/SIBOSDK/hcmast/sys$norm.fon differ diff --git a/code/SIBOSDK/hcmast/sys$rem.pdd b/code/SIBOSDK/hcmast/sys$rem.pdd new file mode 100644 index 0000000..20dc33d Binary files /dev/null and b/code/SIBOSDK/hcmast/sys$rem.pdd differ diff --git a/code/SIBOSDK/hcmast/ukdatach.cfo b/code/SIBOSDK/hcmast/ukdatach.cfo new file mode 100644 index 0000000..ffe0d00 Binary files /dev/null and b/code/SIBOSDK/hcmast/ukdatach.cfo differ diff --git a/code/SIBOSDK/hwdemo/cc.bat b/code/SIBOSDK/hwdemo/cc.bat new file mode 100644 index 0000000..42c025d --- /dev/null +++ b/code/SIBOSDK/hwdemo/cc.bat @@ -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 diff --git a/code/SIBOSDK/hwdemo/checkvid.bat b/code/SIBOSDK/hwdemo/checkvid.bat new file mode 100644 index 0000000..5c6199f --- /dev/null +++ b/code/SIBOSDK/hwdemo/checkvid.bat @@ -0,0 +1,2 @@ +@if not "%jpivid%"=="v2" set jpivid=v0 + diff --git a/code/SIBOSDK/hwdemo/days.afl b/code/SIBOSDK/hwdemo/days.afl new file mode 100644 index 0000000..560d29b --- /dev/null +++ b/code/SIBOSDK/hwdemo/days.afl @@ -0,0 +1,3 @@ +days.pic +days.rsc +days.shd diff --git a/code/SIBOSDK/hwdemo/days.c b/code/SIBOSDK/hwdemo/days.c new file mode 100644 index 0000000..82a8151 --- /dev/null +++ b/code/SIBOSDK/hwdemo/days.c @@ -0,0 +1,1817 @@ +/* + DAYS.C + +Written by DavidW +Started on 4/12/91 +*/ + +#include /* basic Psion header file */ +#include /* defines E_FILE_ error values, etc */ +#include /* defines DbfXXX functions */ +#include /* defines date and time functions */ +#include /* defines E_CONFIG struct */ +#include /* general Epoc definitions */ +#include /* defines al Window Server library functions */ +#include /* defines all Hwif library functions */ + +GLREF_D UWORD DatLocked; /* non-zero when application "busy" */ +GLREF_D TEXT *DatUsedPathNamePtr; /* full path name of current file */ + +LOCAL_D TEXT *cmds[]= + { /* the commands in the menu bar */ + "nNew", + "oOpen", + "mMerge", + "aSave as", + "kCompress", + "xExit", + "iInsert text", + "cCopy text", + "vEvaluate", + "hShow symbols", + "sSave", + "rRevert", + "eEnter anniversary", + "dDelete anniversary", + "uChange date", + "fFind", + "gFind next", + "bFind back", + "tFind date", + "jJump to", + "lList view", + "wWander through", + "pPrint", + "yPrint setup", + NULL + }; + +#define FILE_ITEMS 6 /* how many items in each menu */ +#define EDIT_ITEMS 6 +#define CHANGE_ITEMS 3 +#define SEARCH_ITEMS 5 +#define SPECIAL_ITEMS 4 + +#define ITEMS_BEFORE_FILE 0 +#define ITEMS_BEFORE_EDIT FILE_ITEMS +#define ITEMS_BEFORE_CHANGE (ITEMS_BEFORE_EDIT+EDIT_ITEMS) +#define ITEMS_BEFORE_SEARCH (ITEMS_BEFORE_CHANGE+CHANGE_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_SEARCH+SEARCH_ITEMS) + +#define LIST_ITEM ITEMS_BEFORE_SPECIAL +#define SYMBOLS_ITEM ITEMS_BEFORE_EDIT+3 + +LOCAL_D H_MENU_DATA mdata[]= + { /* the menus in the menu bar */ + "File",FILE_ITEMS, + "Edit",EDIT_ITEMS, + "Change",CHANGE_ITEMS, + "Search",SEARCH_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); /* Hwif code expects this */ +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); /* Hwif code expects this */ + +LOCAL_D UINT MainWid; /* ID of main window */ + +LOCAL_D struct + { /* format of data at start of Days DBF file */ + UWORD dataStart; + UWORD needVersion; + UWORD firHeader; + UBYTE fir[3]; + } ModelHeader= + { + DbfHeaderLength, + 0x100f, /* DBF code version number required */ + (DbfRecordTypeFir<<12)|3, /* 3 fields defined */ + { + DbfFieldTypeWord, /* word field ("DayInYear") */ + DbfFieldTypeString, /* string field ("name") */ + DbfFieldTypeString /* string field ("notes") */ + } + }; + +LOCAL_D TEXT filename[P_FNAMESIZE]; /* for current filename */ +LOCAL_D VOID *dH; /* handle for DbfXXX services */ +LOCAL_D UBYTE dBuf[512]; /* buffer used by DbfXXX services */ +LOCAL_D UWORD dOff; /* current offset into dBuf[] */ + +typedef struct + { /* structure of INDex ENTry */ + UWORD diy; /* no of Day In Year */ + UWORD no; /* no of record in file (secondary key) */ + } INDENT; + +LOCAL_D INDENT index[500]; /* cope with up to 500 entries */ +LOCAL_D WORD count; /* how many entries */ +LOCAL_D WORD where; /* current entry */ + +LOCAL_D WORD top; /* entry at top of screen (list view) */ +LOCAL_D UWORD ViewList=FALSE; /* TRUE if in list view */ + +LOCAL_D VOID *edit[3]; /* the three editors */ +LOCAL_D UWORD show_statwin=TRUE; /* whether Status Window is showing */ +LOCAL_D UWORD ScreenWidth; /* width of main display area */ +LOCAL_D INT emph=0; /* which editor is emphasised */ + +LOCAL_D UWORD lastbflags=W_BORD_CORNER_4; /* state of border flags */ + +LOCAL_D UWORD ShowSymbols=FALSE; /* whether editors display symbols */ + +LOCAL_D WORD currdiy; /* Day In Year of current entry */ +LOCAL_D WORD origdiy; /* currdiy before operation started */ +LOCAL_D WORD dummdiy; /* DIY of dummy entry (placeholder for real one) */ + +LOCAL_D WORD DummyEntry=FALSE; /* whether dummy entry in place */ +LOCAL_D WORD lastchanged=FALSE; /* last state of "changed" flag */ + +LOCAL_D UBYTE daysim[]={31,29,31,30,31,30,31,31,30,31,30,31}; + +LOCAL_D TEXT find[20]={0}; /* the current find string */ +LOCAL_D UWORD findtype=1; /* which type of find is being done */ + +LOCAL_D UWORD PrintNamesOnly=1; /* whether only to print names */ +LOCAL_D UWORD PrintRec; /* which record is being printed */ +LOCAL_D UWORD PrintState; /* which part of the record is being printed */ +LOCAL_D UBYTE *PrintBuf; /* the text being printed */ +LOCAL_D WORD PrintLen; /* length of text being printed */ +LOCAL_D WORD PrintIndent; /* indent before text being printed */ +LOCAL_D TEXT PrintDate[40]; /* text of date of entry being printed */ + +LOCAL_D UWORD tly[]={0,17,35}; /* top left y-positions of three editors */ +LOCAL_D UWORD bry[]={15,32,80}; /* bottom right y-positions of editors */ + + +LOCAL_C VOID DrawBorder(INT i) + { /* draw border round i-th editor and emphasise */ + P_RECT rect; /* appropriate rectangle */ + + rect.tl.x=0; + rect.br.x=ScreenWidth; + if (!i) + rect.br.x-=54; + else if (i==1) + rect.br.x-=10; + rect.tl.y=tly[i]; + rect.br.y=bry[i]; + gBorderRect(&rect, /* should border be emphasised? */ + W_BORD_CORNER_4|W_BORD_SHADOW_S|(i==emph? W_BORD_SHADOW_ON: 0)); + hEBEmphasise(edit[i],i==emph); /* emphasise or de-emphasise editor */ + } + +LOCAL_C VOID DrawWhereAndCount(VOID) + { /* draw the text "n/m" */ + TEXT buf[10]; + P_RECT box; /* where to draw the text */ + + p_atos(&buf[0],"%d/%d",where+1,count); /* construct text to display */ + box.tl.x=ScreenWidth-54; + box.tl.y=2; + box.br.x=ScreenWidth; + box.br.y=12; + gPrintBoxText(&box,8,G_TEXT_ALIGN_CENTRE,0,buf,p_slen(buf)); + } + +LOCAL_C INT CheckIfChanged(VOID) + { /* return TRUE if current entry has been changed */ + if (ViewList) + return(0); + return(origdiy!=currdiy + || hEBSenseChanged(edit[1]) || hEBSenseChanged(edit[2])); + } + +LOCAL_C INT FindMonNo(INT *pdiy) + { /* find month number corresponding to day-in-year */ + INT monno; + + monno=0; + while (*pdiy>=daysim[monno]) + (*pdiy)-=daysim[monno++]; + return(monno); + } + +LOCAL_C VOID DiyToBuf(INT diy,TEXT *pb) + { /* get full textual representation of day in year */ + E_CONFIG cfg; /* current system defaults */ + TEXT mon[32]; /* name of month */ + TEXT suff[31][3]; /* numerical suffices */ + + p_nmmon(&mon[0],FindMonNo(&diy)); + p_getsuffixes(&suff[0][0]); + p_getctd(&cfg); + if (cfg.dateType==E_DATE_EUROPE) + p_atos(pb,"%u%s %s",diy+1,&suff[diy][0],&mon[0]); + else + p_atos(pb,"%s %u%s",&mon[0],diy+1,&suff[diy][0]); + } + +LOCAL_C VOID DiyToShortBuf(INT diy,TEXT *pb) + { /* get short textual representation of day in year */ + INT mon; + E_CONFIG cfg; /* to find date separator */ + INT first; /* either day number or month number */ + INT second; /* the other */ + + mon=FindMonNo(&diy)+1; + diy++; + p_getctd(&cfg); + if (cfg.dateType==E_DATE_EUROPE) + { + first=diy; + second=mon; + } + else + { + first=mon; + second=diy; + } + p_atos(pb,"%u%c%u",first,cfg.dateSeparator,second); + } + +LOCAL_C INT SetDateText(INT diy) + { /* set date text into the date "editor" */ + TEXT date[40]; + + DiyToBuf(diy,&date[0]); + return(hEBSetText(edit[0],&date[0],p_slen(&date[0]))); + } + +LOCAL_C VOID ClearChangedFlags(VOID) + { /* acknowledge that changes have been absorbed */ + origdiy=currdiy; + hEBClearChanged(edit[1]); + hEBClearChanged(edit[2]); + } + +LOCAL_C VOID ZeroBufferStart(VOID) + { /* put dummy entry at start of dBuf[] */ + *(UWORD *)(&dBuf[2])=dummdiy; + *(UWORD *)(&dBuf[4])=0; + dOff=0; + DbfTrash(dH); + } + +LOCAL_C VOID Check(INT val) + { /* terminate application on file error */ + TEXT buf[64]; + + if (val<0 && val!=E_FILE_EOF) + { + uForceToFront(); /* come into foreground */ + DatLocked=TRUE; + p_errs(&buf[0],val); /* get error string */ + wsAlertW(WS_ALERT_CLIENT,&buf[0],"Terminating application",0); + p_exit(0); /* exit cleanly */ + } + } + +LOCAL_C VOID SeekTo(UINT current) + { /* read the specified record into dBuf[] */ + Check(DbfAbsRead(dH,current,&dOff)); + } + +LOCAL_C INT LoadBuffer(INT j) + { /* read the specified record (maybe dummy) into dBuf[] */ + INT no; + + if (j>=count) + return(-1); /* no such record */ + no=index[j].no; + if (DummyEntry && no==count-1) + ZeroBufferStart(); /* record in process of being added */ + else + SeekTo(no); /* real record */ + return(0); + } + +LOCAL_C VOID LoadEditors(VOID) + { /* load editors in preparation to edit current entry */ + UBYTE *psrc; /* points into dBuf[] */ + INT len; /* length of text field */ + + LoadBuffer(where); /* read current record into dBuf[] */ + psrc=(&dBuf[dOff+2]); /* position psrc to start of record */ + ClearChangedFlags(); /* no changes made yet */ + DrawWhereAndCount(); /* display new "n/m" text */ + origdiy=currdiy=(*(UWORD *)psrc); /* read the Day In Year */ + if (SetDateText(currdiy)) /* set text of date "editor" */ + return; + psrc+=2; /* increment to first text field */ + len=(*psrc); /* length of first text field */ + if (hEBSetText(edit[1],(TEXT *)psrc+1,len)) + return; + psrc+=len+1; /* increment to second text field */ + hEBSetText(edit[2],(TEXT *)psrc+1,*psrc); + } + +LOCAL_C INT AddMonthChoiceList(UWORD *pmonno) + { /* add choice list of all month names to current dialog */ + H_DI_CHOICE ch; + TEXT mon[32]; /* for name of current month */ + INT i; + + if (uBeginDCL(&ch)) + return(-1); + for (i=0; i<12; i++) + { /* for each month */ + p_nmmon(&mon[0],i); /* look up month name */ + if (uGrowDCL(&ch,&mon[0])) /* try to add next entry */ + return(-1); + } + return(uAddDCL("Month",pmonno,&ch)); + } + +LOCAL_C INT FindDiy(INT monno,INT dayinm) + { /* find DayInYear for given day in given month */ + while (monno) + dayinm+=daysim[--monno]; + return(dayinm); + } + +LOCAL_C VOID IndexDelete(VOID) + { /* delete an item from the index */ + UWORD deleted; /* the record number of item deleted */ + UWORD i; + INDENT *pindent; + UWORD tomove; + + deleted=index[where].no; + count--; /* decrement total count number */ + tomove=count-where; /* how many index entries to move to close gap */ + p_bcpy(&index[where],&index[where+1],tomove*sizeof(INDENT)); + pindent=(&index[0]); /* to scan through all index entries */ + i=count; + while (i--) + { + if (pindent->no>deleted) + (pindent->no)--; /* since this record number now one less */ + pindent++; + } + } + +LOCAL_C UWORD FindKey(VOID) + { /* read the DayInYear of the current entry */ + return(*(UWORD *)(&dBuf[dOff+2])); + } + +LOCAL_C INT compare(INDENT *p1,INDENT *p2) + { /* find which of two entries is first in order */ + UWORD diff; + + diff=p1->diy-p2->diy; + return(diff? diff: p1->no-p2->no); + } + +LOCAL_C INT cmp(INT r,VOID *pindent) + { /* routine expected by p_bsrch */ + return(compare(pindent,&index[r])); + } + +LOCAL_C INT LocateByDate(INDENT *pent) + { /* locate index position matching (or nearest after) given entry */ + INT dir; /* direction to nearest hit (as given by p_bsrch) */ + INT mid; /* nearest hit (as given by p_bsrch) */ + + if (!count) + mid=0; + else + { + dir=p_bsrch(count,cmp,&mid,pent); + if (dir>0) + mid++; + } + return(mid); + } + +LOCAL_C VOID IndexAppend() + { /* add index entry for new record at end of file */ + INT mid; + UWORD tomove; + INDENT new; + + new.no=count; /* new record added at end of file */ + new.diy=currdiy; + mid=LocateByDate(&new); /* find where to insert index entry */ + tomove=count-mid; /* how many entries to move down */ + count++; /* increment total count of records */ + p_bcpy(&index[mid+1],&index[mid],tomove*sizeof(INDENT)); + index[mid]=new; /* write in the new entry */ + where=mid; /* this entry is now current */ + } + +LOCAL_C VOID IndexUpdate(VOID) + { /* update index entry for record updated */ + IndexDelete(); /* delete the old entry... */ + IndexAppend(); /* ...and construct a new one */ + } + +LOCAL_C INT Try(INT ret,TEXT *msg) + { /* in case of file error, give user chance to retry */ + TEXT buf[64]; + + if (ret>=0) + return(0); /* no error */ + uForceToFront(); /* come to foreground */ + DatLocked=TRUE; /* mark application as "busy" */ + p_errs(&buf[0],ret); + if (wsAlertW(WS_ALERT_CLIENT,msg,&buf[0],"Continue","Exit",0)) + p_exit(0); /* user is willing to exit application */ + DatLocked=FALSE; + return(-1); + } + +LOCAL_C VOID SeekToCurrent(VOID) + { /* read the current record into dBuf[] */ + SeekTo(index[where].no); + } + +LOCAL_C INT DoUpdate(INT len) + { /* user has finished updating record */ + INT state; + + if (DummyEntry) + { /* was editing dummy record - so append real one */ + if (Try(DbfAppend(dH,len),"Failed to save changes")) + return(-1); + DummyEntry=FALSE; + } + else + { + SeekToCurrent(); /* find the record to update */ + state=DbfStateDisabled; /* instant update */ + if (Try(DbfUpdate(&state,dH,len),"Failed to save changes")) + return(-1); + } + IndexUpdate(); /* update the corresponding index entry */ + return(0); + } + +LOCAL_C VOID EditEmphasise(INT flag) + { /* pass emphasis or de-emphasis message to current editor */ + if (!ViewList) + hEBEmphasise(edit[emph],flag); + } /* else no editors */ + +LOCAL_C INT RunDialog(VOID) + { /* layer round dialog code to handle cursor flashing */ + INT ret; + + EditEmphasise(FALSE); /* remove any flashing cursor */ + ret=uRunDialog(); /* run the dialog */ + EditEmphasise(TRUE); /* reinstate any flashing cursor */ + return(ret); + } + +LOCAL_C INT Confirm(TEXT *pb) + { /* present a "No/Yes" dialog */ + if (uOpenDialog(pb)) /* title text supplied by caller */ + return(-1); + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return(-1); + return(RunDialog()!='y'); /* return TRUE iff user answered Yes */ + } + +LOCAL_C INT SizeRecord(VOID) + { /* return the length of first text field in current record */ + return(*(UWORD *)&dBuf[dOff+4]); + } + +LOCAL_C VOID AddDummyEntry() + { /* add index position for record in process of being defined */ + DummyEntry=TRUE; + dummdiy=currdiy; + IndexAppend(); + } + +LOCAL_C INT CalculateBflags(VOID) + { /* find whether scroll arrows should be displayed on border */ + INT bflags; + + if (top) /* check if more records off top of screen */ + bflags=W_BORD_CORNER_4|W_BORD_TOP_ON; + else + bflags=W_BORD_CORNER_4|W_BORD_TOP_OFF; + if (top+8tl.y=4+y*9; + pbox->br.y=pbox->tl.y+9; + } + +LOCAL_C VOID LineToScreen(INT y,INT x1,INT x2,INT align,TEXT *pb,INT tlen) + { /* utility layer around gPrintBoxText */ + P_RECT box; + + box.tl.x=x1; + box.br.x=x2; + LoadYs(&box,y); + gPrintBoxText(&box,8,align,0,pb,tlen); + } + +LOCAL_C VOID ClrLine(INT y) + { /* clear a line on the screen */ + P_RECT box; + + box.tl.x=4; + box.br.x=ScreenWidth-4; + LoadYs(&box,y); + gClrRect(&box,G_TRMODE_CLR); + } + +LOCAL_C VOID SetBold(INT flag) + { /* prepare to print in bold (or in non-bold) */ + G_GC gc; + + gc.font=WS_FONT_BASE+flag; + gSetGC(0,G_GC_MASK_FONT,&gc); + } + +LOCAL_C VOID GetCursorBox(INT i,P_RECT *pbox) + { /* get rectangle to draw cursor for specified entry */ + pbox->tl.x=4; + pbox->br.x=10; + LoadYs(pbox,i); + } + +LOCAL_C VOID DrawCursor(INT i,INT on) + { /* draw (or clear) cursor alongside given entry */ + P_RECT box; + + GetCursorBox(i,&box); + gPrintBoxText(&box,8,G_TEXT_ALIGN_LEFT,0,"\034",on); + } + +LOCAL_C VOID DrawLine(INT i) + { /* display a given entry on a line on screen */ + INT entno; + UBYTE *psrc; /* pointer into dBuf[] */ + TEXT date[6]; /* for short textual representation of date */ + + entno=i+top; /* offset by no of entry at screen top */ + if (LoadBuffer(entno)) + { /* no such entry */ + ClrLine(i); + return; + } + psrc=(&dBuf[dOff+2]); /* point to start of record */ + DiyToShortBuf(*(UWORD *)psrc,&date[0]); /* get short date text */ + DrawCursor(i,entno==where); /* draw or clear cursor */ + SetBold(TRUE); /* draw date in bold */ + LineToScreen(i,14,49,G_TEXT_ALIGN_RIGHT,&date[0],p_slen(&date[0])); + psrc+=2; /* position to first text field */ + SetBold(FALSE); /* print remainder in non-bold */ + LineToScreen(i,54,ScreenWidth-4,G_TEXT_ALIGN_LEFT,(TEXT *)psrc+1,*psrc); + } + +LOCAL_C VOID ListDisplay(VOID) + { /* redraw all visible entries (in list view) */ + INT i; + + for (i=0; i<8; i++) + DrawLine(i); + } + +LOCAL_C VOID WholeListDisplay(VOID) + { /* re-display whole screen (in list view) */ + if (top+8>count) + top=count-8; /* wasted spaced at end of display */ + if (top<0) + top=0; + if (wheretop+7) + top=where-7; + lastbflags=CalculateBflags(); + gBorder(lastbflags); /* draw border */ + ListDisplay(); /* draw the entries themselves */ + } + +LOCAL_C INT LookFor(UBYTE *pb) + { /* look for find text in given text field */ + return(p_bsubi((TEXT *)pb+1,*pb,&find[1],find[0])); + } + +LOCAL_C VOID RotateTo(INT newemph) + { /* change which editor is emphasised */ + INT oldemph; + + if (newemph!=emph) + { + oldemph=emph; + emph=newemph; + DrawBorder(oldemph); /* clear former emphasis */ + DrawBorder(newemph); /* apply new emphasis */ + } + } + +LOCAL_C INT SaveChanges(VOID) + { /* save changes made to current record */ + INT len1; /* length of first text field */ + INT len2; /* length of second text field */ + UBYTE *pb; /* pointer into dBuf[] */ + TEXT *psrc; /* pointer into editor's text */ + + pb=(&dBuf[2]); /* start at beginning of dBuf[] */ + *(UWORD *)pb=currdiy; /* fill in word DIY field */ + pb+=2; /* position to first text field */ + psrc=hEBSenseText(edit[1]); /* sense text in editor */ + len1=p_slen(psrc); + *pb++=len1; /* record the length of the text */ + pb=p_bcpy(pb,psrc,len1); /* record the text itself */ + psrc=hEBSenseText(edit[2]); /* sense text in next editor */ + len2=p_slen(psrc); + *pb++=len2; /* record the length of the text */ + p_bcpy(pb,psrc,len2); /* record the text itself */ + dOff=0; + if (DoUpdate(len1+len2+4)) /* give length of record being added */ + return(-1); + ClearChangedFlags(); /* acknowledge editors are no longer "changed" */ + DrawWhereAndCount(); /* position in index may be different now */ + return(0); + } + +LOCAL_C INT SaveIfChanged(VOID) + { /* save changes made, if any */ + if (!CheckIfChanged()) + return(0); + return(SaveChanges()); + } + +LOCAL_C VOID CompressFile(VOID) + { /* user has requested file be compressed */ + UINT state; + + if (!hIsDbfCompressible(dH)) + wInfoMsg("Cannot compress on Flash"); + else + { + state=DbfStateDisabled; + Check(DbfCompress(&state,dH)); + wInfoMsg("File compressed"); + } + } + +LOCAL_C VOID ChangeName(TEXT *newname) + { /* name of file being edited has changed */ + p_scpy(&filename[0],newname); /* copy to own buffer */ + hSetUpStatusNames(&filename[0]); /* inform system of the change */ + wsUpdate(WS_UPDATE_NAME); /* force status window update */ + } + +LOCAL_C INT ordf(INT r1,INT r2,VOID *junk) + { /* ordering function required by p_qsort() */ + return(compare(&index[r1],&index[r2])); + } + +LOCAL_C VOID excf(INT r1,INT r2,VOID *junk) + { /* exchange function required by p_qsort() */ + p_bswap(&index[r1],&index[r2],sizeof(INDENT)); + } + +LOCAL_C VOID BuildIndex(VOID) + { /* build index for current file */ + INDENT *pindent; + UWORD no; + + no=0; + count=DbfCount(dH); + pindent=(&index[0]); /* to pass through whole index */ + while (nodiy=FindKey(); /* extract its DayInYear value */ + pindent->no=no++; /* record secondary key */ + pindent++; + } + p_qsort(no,ordf,excf,NULL); /* sort the index */ + } + +LOCAL_C VOID DoScroll(INT dely) + { /* scroll part of the screen display vertically */ + P_POINT offset; /* offset to scroll by */ + P_RECT src; /* source region for the scroll */ + + offset.x=0; + offset.y=dely*9; /* each line is 9 pixels high */ + src.tl.x=4; + src.br.x=ScreenWidth-4; + if (dely>0) + { /* scrolling down - so omit display bottom from source */ + src.tl.y=4; + src.br.y=4+(8-dely)*9; + } + else + { /* scrolling up - so omit display top from source */ + src.tl.y=4-dely*9; + src.br.y=4+8*9; + } + wScrollRect(MainWid,&src,&offset); + } + +LOCAL_C VOID MakeHighlight(INT newcent) + { /* move the cursor to the specified new value */ + INT toscroll; + + if (newcent==where) + return; /* cursor already there */ + DrawCursor(where-top,FALSE); /* remove old cursor */ + toscroll=top-newcent; + if (toscroll>0) + { /* new cursor position off top of screen */ + top-=toscroll; + if (toscroll<8) + DoScroll(toscroll); + else + toscroll=8; /* toscroll now gives number of lines to redraw */ + while (toscroll) + DrawLine(--toscroll); /* draw lines not handled by scroll */ + } + else + { + toscroll=-7-toscroll; + if (toscroll>0) /* new cursor position off bottom of screen */ + { + top+=toscroll; + if (toscroll<8) + DoScroll(-toscroll); + else + toscroll=8; + while (toscroll) + DrawLine(8-toscroll--);/* draw lines not handled by scroll */ + } + } + where=newcent; + DrawCursor(where-top,TRUE); /* draw cursor in new position */ + } + +LOCAL_C VOID NewWhere(UWORD new) + { /* there is a new current record */ + if (ViewList) + MakeHighlight(new); /* scroll if need be */ + else + { /* editors view - so change all editor contents */ + where=new; + LoadEditors(); + } + } + +LOCAL_C VOID WholeDisplay(VOID) + { /* the whole screen needs redrawn */ + if (ViewList) + WholeListDisplay(); + else + LoadEditors(); + } + +LOCAL_C VOID DisplayStart(VOID) + { /* a new file needs loading and displaying */ + BuildIndex(); + if (!count) + AddDummyEntry(); + where=0; + WholeDisplay(); + } + +LOCAL_C VOID ChangeOverTo(VOID *newdH,TEXT *newname) + { /* change the file being edited */ + DbfClose(dH); + dH=newdH; /* (new file is already successfully opened) */ + ChangeName(newname); + DisplayStart(); + } + +LOCAL_C INT doOpen(VOID **pdH,TEXT *pb,INT flags,DbfHeader *pHead) + { /* utility layer over DbfOpen */ + INT state; + + state=DbfStateDisabled; + p_scpy((TEXT *)&pHead->fileType[0],"OPLDatabaseFile"); + return(uErrorValue(DbfOpen(&state,pdH,pb,flags,pHead,&dBuf[0],512,1))); + } + +LOCAL_C INT TryOpenDbf(TEXT *pb,VOID **pdH) + { /* save any current changes, and try to open named file */ + DbfHeader Header; + + if (SaveIfChanged()) + return(-1); + return(doOpen(pdH,pb,P_FOPEN|P_FUPDATE|P_FRANDOM,&Header)); + } + +LOCAL_C VOID SetupFilename(TEXT *pb) + { /* initialise text for editor from current filename */ + p_bcpy(pb+1,DatUsedPathNamePtr,*pb=p_slen(DatUsedPathNamePtr)); + } + +LOCAL_C VOID OpenDbf(VOID) + { /* user wants to open another file */ + H_DI_FSEL open; + TEXT openbuf[P_FNAMESIZE+2]; + VOID *newdH; /* open new file before closing old */ + + SetupFilename(open.fname=(&openbuf[0])); /* seed filename */ + open.flags=H_FILE_PICK_SELECTOR|H_FILE_RESTRICT_LIST|H_FILE_SET_DEFEXT; + FOREVER + { /* loop until success or user cancels */ + if (uOpenDialog("Open anniversary file")) + break; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&open)) + break; + if (RunDialog()<=0) + break; + openbuf[1+openbuf[0]]=0; /* convert from lbc to zts */ + if (!TryOpenDbf(&openbuf[1],&newdH)) + { /* new file opened successfully */ + ChangeOverTo(newdH,&openbuf[1]); + return; + } + } + } + +LOCAL_C INT TryNewDbf(TEXT *pb,VOID **pdH) + { /* save any changes, and try to create new named file */ + DbfHeader Header; /* values defined at top of this file */ + + if (SaveIfChanged()) + return(-1); + hEnsurePath(pb); /* check the directory exists */ + Header.createVersion=DbfVersion(); + p_bcpy(&Header.dataStart,&ModelHeader,sizeof(ModelHeader)); + return(doOpen(pdH,pb,P_FREPLACE|P_FUPDATE|P_FRANDOM,&Header)); + } + +LOCAL_C VOID NewDbf(VOID) + { /* user wants to create a new file */ + H_DI_FSEL new; + TEXT newbuf[P_FNAMESIZE+2]; + VOID *newdH; /* create new file before closing old */ + + SetupFilename(new.fname=(&newbuf[0])); /* seed filename */ + new.flags=H_FILE_NEW_EDITOR|H_FILE_SET_DEFEXT; + FOREVER + { /* loop until success or user cancels */ + if (uOpenDialog("New anniversary file")) + break; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&new)) + break; + if (RunDialog()<=0) + break; + newbuf[1+newbuf[0]]=0; /* convert from lbc to zts */ + if (!TryNewDbf(&newbuf[1],&newdH)) + { /* new file created successfully */ + ChangeOverTo(newdH,&newbuf[1]); + return; + } + } + } + +LOCAL_C INT DoMerge(TEXT *pb,INT flags,INT dir) + { /* common code for Merge and SaveAs */ + UINT state; + + state=DbfStateDisabled; + return(uErrorValue(DbfCopyFile(&state,dH,pb,flags,1,dir))); + } + +LOCAL_C VOID MergeDbf(VOID) + { /* user wants to merge two files */ + H_DI_FSEL merge; + TEXT mergebuf[P_FNAMESIZE+2]; + + if (SaveIfChanged()) /* save any changes first */ + return; + SetupFilename(merge.fname=(&mergebuf[0])); /* seed filename */ + merge.flags=H_FILE_PICK_SELECTOR|H_FILE_RESTRICT_LIST|H_FILE_SET_DEFEXT; + FOREVER + { + if (uOpenDialog("Merge anniversary file")) + break; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&merge)) + break; + if (RunDialog()<=0) + break; + mergebuf[1+mergebuf[0]]=0; /* convert lbc to zts */ + if (!DoMerge(&mergebuf[1],P_FOPEN,DbfCopyToHandle)) + { /* merging handled by Dbf services */ + wInfoMsg("File merged"); + DisplayStart(); + return; + } + } + } + +LOCAL_C VOID DoSave(TEXT *pb,INT usenew) + { /* Save to new filename and optionally use new file */ + VOID *newdH; /* use separate Dbf handle */ + INT i; + INT len; + + if (TryNewDbf(pb,&newdH)) /* start by creating the new file */ + return; + DbfTrash(dH); /* NB dBuf[] shared between two handles */ + for (i=0; i0) + { + savebuf[1+savebuf[0]]=0; + DoSave(&savebuf[1],usenew==2); + } + } + +LOCAL_C VOID SetSymbolsState(VOID) + { /* Set the "show symbols" state of the editors */ + hEBShowSymbols(edit[2],ShowSymbols); + } + +LOCAL_C VOID ToggleShowSymbols(VOID) + { /* toggle the "show symbols" state of the editors */ + ShowSymbols^=TRUE; + if (!ViewList) + SetSymbolsState(); + cmds[SYMBOLS_ITEM]=(ShowSymbols? "hHide symbols": "hShow symbols"); + } + +LOCAL_C VOID ExitApplication(VOID) + { /* user wants to exit */ + if (!SaveIfChanged()) + p_exit(0); + } + +LOCAL_C INT DateDialog(TEXT *title,INT *pdiy) + { /* present a date dialog with given title (common code) */ + UWORD monno; /* month number in year */ + INT dayinm; /* day number in month */ + LONG ldayinm; /* dayinm as a LONG */ + H_DI_NUMBER num; + + dayinm=(*pdiy); + monno=FindMonNo(&dayinm)+1; /* crack the given DayInYear */ + ldayinm=dayinm+1; + num.value=(&ldayinm); + num.low=1; + num.high=31; /* this limit is generally correct */ + FOREVER + { + if (uOpenDialog(title)) + return(-1); + if (AddMonthChoiceList(&monno)) + return(-1); + if (uAddDialogItem(H_DIALOG_NUMBER,"Day in month",&num)) + return(-1); + if (RunDialog()<=0) + return(-1); + dayinm=(INT)ldayinm-1; + if (dayinm=count) + try=0; /* handle wrap round forwards */ + else if (try<0) + try=count-1; /* handle wrap round backwards */ + SeekTo(index[try].no); /* load text of specified record */ + pb=(&dBuf[dOff+4]); /* position to name field */ + if (findtype&1) + { /* if searching in name field */ + newemph=1; + off=LookFor(pb); + if (off>=0) + break; /* found */ + } + pb+=(*pb)+1; /* position to notes field */ + if (findtype&2) + { /* if searching in notes field */ + newemph=2; + off=LookFor(pb); + if (off>=0) + break; /* found */ + } + } + if (ViewList) + { + if (newemph==1) + { /* can position to name field in list view... */ + MakeHighlight(try); + return(0); + } + if (ToggleListMode()) /* ...but not to notes field */ + return(0); + } + NewWhere(try); /* load editors with relevant record */ + hEBSetSelect(edit[newemph],off,off+find[0]); /* highlight match */ + RotateTo(newemph); /* emphasise correct editor */ + return(0); + } + +LOCAL_C VOID FindAnniversary(VOID) + { /* user wants to Find */ + H_DI_EDIT edfind; + + if (SaveIfChanged()) + return; /* failed to save changes */ + edfind.str=(&find[0]); /* seed with previous find string */ + edfind.len=19; + FOREVER + { + if (uOpenDialog("Find text")) + return; + if (uAddDialogItem(H_DIALOG_EDIT,"Text",&edfind)) + return; + if (uAddChoiceList("Search",&findtype,"Just names", + "Just notes","Names and notes",NULL)) + return; + if (RunDialog()<=0) + return; + if (!DoFind(count,+1,count)) + return; /* match found */ + wInfoMsg("Not found"); + } + } + +LOCAL_C VOID FindAgain(INT dir) + { /* user wants to Find Again */ + if (SaveIfChanged()) + return; + if (DoFind(where,dir,count-1)) + wInfoMsg("No more found"); + } + +LOCAL_C VOID JumpTo(VOID) + { /* user wants to jump to record by index number */ + LONG curr; + H_DI_NUMBER num; + INT new; + + if (SaveIfChanged()) + return; /* failed to save changes */ + if (uOpenDialog(NULL)) /* this dialog has no title */ + return; + curr=where+1; /* seed with current value */ + num.value=(&curr); + num.low=1; + num.high=count; + if (uAddDialogItem(H_DIALOG_NUMBER,"Jump to record",&num)) + return; + if (RunDialog()<=0) + return; + new=(UINT)(curr-1); + NewWhere(new); + } + +LOCAL_C INT Today(VOID) + { /* return DayInYear for today */ + P_DAYSEC ds; + P_DATE dt; + ULONG now; + + now=p_date(); + p_sttods(&now,&ds); + p_dstodt(&ds,&dt); + return(FindDiy(dt.month,dt.day)); + } + +LOCAL_C VOID FindDate(VOID) + { /* user wants to find record on given date */ + INT diy; + INT mid; + INDENT ent; + + diy=Today(); /* seed with today */ + if (DateDialog("Find date",&diy)) + return; /* user cancelled or out of memory */ + ent.diy=diy; + ent.no=0; + mid=LocateByDate(&ent); + if (mid>=count) + mid=count-1; + NewWhere(mid); + } + +LOCAL_C INT PrintLine(H_PRINT *pr) + { /* call-back function to print line of data */ + INT ind; + + switch (PrintState++) + { + case 0: /* reached only at very beginning: set up print indent */ + PrintIndent=hPrintSenseBufWidth(" ",1)*4; + hPrintSetSI(PrintIndent); /* indent for word-wrapped lines */ + PrintState++; + case 1: /* print date */ + LoadBuffer(PrintRec); /* load record into dBuf[] */ + PrintBuf=(&dBuf[dOff+2]); /* position to DayInYear field */ + DiyToBuf(*(UWORD *)PrintBuf,&PrintDate[0]); + PrintBuf+=2; /* position to name text field */ + pr->buf=(&PrintDate[0]); /* print text version of date */ + pr->blen=p_slen(&PrintDate[0]); + pr->style|=H_PRINT_STY_BOLD; /* print in bold */ + break; + case 2: /* print name */ + pr->blen=(*PrintBuf++); + pr->buf=(TEXT *)PrintBuf; + PrintBuf+=pr->blen; /* position to notes text field */ + PrintLen=(*PrintBuf++); /* how many characters in note */ + break; + default: /* print (next section of) notes */ + if (PrintNamesOnly==1) + { /* if NOT only printing names */ + pr->buf=(TEXT *)PrintBuf; + pr->indent=PrintIndent; + ind=p_bloc(PrintBuf,PrintLen,'\n'); /* search for '\n' */ + if (ind<0) + { /* all (remaining) text is one "paragraph" */ + pr->blen=PrintLen; /* print it all */ + PrintLen=0; /* none left */ + } + else + { + pr->blen=ind; /* print rest of "paragraph" */ + PrintLen-=ind+1; /* still some of note left to print */ + PrintBuf+=ind+1; /* position to next "paragraph" */ + } + if (pr->blen || PrintLen) + break; /* not finished note yet */ + } + pr->blen=0; /* print blank line */ + PrintState=1; /* ready for date of next record */ + return(++PrintRec!=count); /* return FALSE if finished */ + } + pr->flags|=H_PRINT_KEEP; /* keep record together, if possible */ + return(TRUE); /* still more to print */ + } + +LOCAL_C VOID PrintAnniversaries(VOID) + { /* user wants to Print */ + if (SaveIfChanged()) + return; /* failed to save changes */ + if (uOpenDialog("Print")) + return; + if (uAddChoiceList("Names only",&PrintNamesOnly,"No","Yes",0)) + return; + if (RunDialog()<=0) + return; + PrintRec=0; /* initialise print state variables */ + PrintState=0; + hPrint(PrintLine); /* specify call-back function */ + } + +LOCAL_C VOID DeleteAnniversary(VOID) + { /* user wants to delete anniversary */ + INT state; + + if (count==1 && !SizeRecord()) + { + wInfoMsg("Nothing to delete"); + return; + } + if (Confirm("Delete this anniversary")) + return; /* user failed to confirm */ + SeekToCurrent(); /* load current entry into dBuf[] */ + state=DbfStateDisabled; + Check(DbfEraseRead(&state,dH,&dOff)); + IndexDelete(); /* remove current entry from index too */ + if (!count) + AddDummyEntry(); /* don't leave index completely empty */ + if (where==count) + where=count-1; + WholeDisplay(); + } + +LOCAL_C VOID ManageCommand(INT index) + { /* switch on command index to appropriate function */ + switch (index) + { + case ITEMS_BEFORE_FILE: + NewDbf(); + break; + case ITEMS_BEFORE_FILE+1: + OpenDbf(); + break; + case ITEMS_BEFORE_FILE+2: + MergeDbf(); + break; + case ITEMS_BEFORE_FILE+3: + SaveDbfAs(); + break; + case ITEMS_BEFORE_FILE+4: + CompressFile(); + break; + case ITEMS_BEFORE_FILE+5: + ExitApplication(); + break; + case ITEMS_BEFORE_EDIT: + if (!CheckEditing()) + { /* insert text - handled by editor */ + if (hEBPaste(edit[2])>0) + wInfoMsg("No text to insert"); + } + break; + case ITEMS_BEFORE_EDIT+1: + if (!CheckEditing()) + { /* copy text - handled by editor */ + if (hEBCopy(edit[2])>0) + wInfoMsg("No text to copy"); + else + wInfoMsg("Text copied"); + } + break; + case ITEMS_BEFORE_EDIT+2: + if (!CheckEditing()) + hEBEvaluate(edit[2]); /* evaluate - handled by editor */ + break; + case ITEMS_BEFORE_EDIT+3: + ToggleShowSymbols(); + break; + case ITEMS_BEFORE_EDIT+4: + SaveAnniversary(); + break; + case ITEMS_BEFORE_EDIT+5: + UndoEditing(); + break; + case ITEMS_BEFORE_CHANGE: + EnterAnniversary(); + break; + case ITEMS_BEFORE_CHANGE+1: + DeleteAnniversary(); + break; + case ITEMS_BEFORE_CHANGE+2: + ChangeDate(); + break; + case ITEMS_BEFORE_SEARCH: + FindAnniversary(); + break; + case ITEMS_BEFORE_SEARCH+1: + FindAgain(+1); + break; + case ITEMS_BEFORE_SEARCH+2: + FindAgain(-1); /* this is "Find Backwards" */ + break; + case ITEMS_BEFORE_SEARCH+3: + FindDate(); + break; + case ITEMS_BEFORE_SEARCH+4: + JumpTo(); + break; + case ITEMS_BEFORE_SPECIAL: + ToggleListMode(); + break; + case ITEMS_BEFORE_SPECIAL+1: + WanderThrough(); + break; + case ITEMS_BEFORE_SPECIAL+2: + PrintAnniversaries(); + break; + case ITEMS_BEFORE_SPECIAL+3: + PrintSetupDialog(); + } + } + +LOCAL_C INT ObeySystemCommand(INT cmd,TEXT *pb,VOID **pdH) + { /* respond to SwitchFiles command from System Screen */ + return((cmd=='O'? TryOpenDbf: TryNewDbf)(pb,pdH)); + } + +LOCAL_C VOID ProcessSystemCommand(VOID) + { /* respond to message from System Screen */ + TEXT buf[P_FNAMESIZE+2]; + VOID *newdH; + + wGetCommand((UBYTE *)&buf[0]); + if (buf[0]=='X') + ExitApplication(); + if (!ObeySystemCommand(buf[0],&buf[1],&newdH)) + ChangeOverTo(newdH,&buf[1]); + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { /* try to find command to execute matching accelerator passed */ + keycode=uLocateCommand(keycode); /* look up accelerator table */ + if (keycode>=0) /* found - keycode converted to index */ + ManageCommand(keycode); + } + +LOCAL_C VOID RotateFocus(INT shifted) + { /* respond to TAB key */ + INT newemph; + + if (ViewList) + ToggleListMode(); + else + { + newemph=emph; + if (shifted) + { /* go backwards for SHIFT TAB */ + if (!newemph--) + newemph=2; + } + else if (++newemph==3) + newemph=0; + RotateTo(newemph); + } + } + +LOCAL_C VOID MoveTo(INT newwhere) + { /* move to given record (works in either list or editors view */ + if (SaveIfChanged()) + return; + if (newwhere<0) + newwhere=count-1; + else if (newwhere>=count) + newwhere=0; + NewWhere(newwhere); + } + +LOCAL_C INT ResizeWidth(UWORD width) + { /* try to change the width of the main display region */ + INT ret; + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=width; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + ret=uErrorValue(wCheckPoint()); /* check whether successful */ + if (!ret) + ScreenWidth=width; + return(ret); + } + +LOCAL_C VOID ToggleStatusWindow(VOID) + { /* attempt to toggle the visibility of the status window */ + if (show_statwin) + { /* status window is currently showing */ + if (ResizeWidth(240)) + return; + wsDisable(); /* remove status window */ + } + else + { /* status window not currently showing */ + if (ResizeWidth(189)) + return; + wsEnable(); /* display status window */ + } + show_statwin^=TRUE; + ClearWholeWindow(); + if (ViewList) + { + gBorder(lastbflags); + ListDisplay(); + } + else + { + lastchanged=FALSE; + DrawFramework(); + hEBChangeWidth(edit[0],ScreenWidth-12-32-54); + hEBChangeWidth(edit[1],ScreenWidth-12-32-10); + hEBChangeWidth(edit[2],ScreenWidth-12); /* change editor widths */ + } + } + +LOCAL_C VOID UpdateDateDisplays(VOID) + { /* system time format defaults may have changed */ + if (ViewList) + ListDisplay(); + else + SetDateText(currdiy); + } + +LOCAL_C VOID KeyToEditors(WMSG_KEY *pkey) + { /* pass key to emphasised editor */ + if (!emph) + { /* emphasis on date "editor" */ + switch (pkey->keycode) + { + case W_KEY_LEFT: + MoveTo(pkey->modifiers&W_PSION_MODIFIER? 0: where-1); + break; + case W_KEY_RIGHT: + MoveTo(pkey->modifiers&W_PSION_MODIFIER? count-1: where+1); + break; + case W_KEY_RETURN: + ChangeDate(); + } + return; + } + if (pkey->keycode==W_KEY_RETURN && emph!=2) + return; + hEBHandleKey(edit[emph],pkey->keycode,pkey->modifiers); + } + +LOCAL_C VOID ScrollPageBy(INT delta) + { /* implementation of PgUp / PgDn */ + if (delta<(-7)) + delta=(-7); + else if (delta>7) + delta=7; + top+=delta; + where+=delta; + ListDisplay(); + } + +LOCAL_C VOID KeyToList(WMSG_KEY *pkey) + { /* key handling routine for list view */ + switch (pkey->keycode) + { + case W_KEY_UP: + if (where) + MakeHighlight(where-1); + break; + case W_KEY_DOWN: + if (wheremodifiers&W_CTRL_MODIFIER) + MakeHighlight(0); + else if (!top) + MakeHighlight(0); + else + ScrollPageBy(-top); + break; + case W_KEY_PAGE_DOWN: + if (pkey->modifiers&W_CTRL_MODIFIER) + MakeHighlight(count-1); + else if (top+8>=count) + MakeHighlight(count-1); + else + ScrollPageBy(count-top-8); + break; + } + } + +LOCAL_C VOID CheckEmbellishments(VOID) + { /* called regularly (once every event) */ + INT bflags; + INT changed; + P_RECT box; /* rectangle to draw "changed" asterisk in */ + + if (ViewList) + { /* see if scroll arrows in border need changing */ + bflags=CalculateBflags(); + if (bflags!=lastbflags) + gBorder(lastbflags=bflags); + } + else + { /* see if "changed" asterisk after name editor needs changing */ + changed=CheckIfChanged(); + if (changed==lastchanged) + return; + lastchanged=changed; + box.tl.x=ScreenWidth-10; + box.tl.y=19; + box.br.x=ScreenWidth; + box.br.y=29; + gPrintBoxText(&box,8,G_TEXT_ALIGN_CENTRE,0,"*",changed); + } + } + +LOCAL_C VOID MainLoop(VOID) + { /* central event processing loop */ + INT ret; + WMSG_KEY key; + + FOREVER + { + CheckEmbellishments(); /* check display up-to-date */ + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + switch (key.keycode) + { + case CONS_EVENT_FOREGROUND: + UpdateDateDisplays(); + break; + case CONS_EVENT_COMMAND: + ProcessSystemCommand(); + } + } + else if (key.keycode&W_SPECIAL_KEY) /* Psion key pressed */ + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else + { + switch (key.keycode) + { + case W_KEY_MENU: + if (key.modifiers&W_CTRL_MODIFIER) + ToggleStatusWindow(); + else + { /* display menu bar */ + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + break; + case W_KEY_MODE: /* if assigned app button pressed */ + ToggleListMode(); + break; + case W_KEY_TAB: + RotateFocus(key.modifiers&W_SHIFT_MODIFIER); + break; + default: + (ViewList? KeyToList: KeyToEditors)(&key); + } + } + } + } + +LOCAL_C VOID SmallScreen(VOID) + { /* attempt to make room for status window */ + if (ResizeWidth(189)) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { /* attempt to create default graphics context on main window */ + INT hgc; /* graphics context handle (if successful) */ + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { /* application initialisation specific to Days */ + INT command; + + uEscape(FALSE); /* disable Psion-Esc */ + MainWid=uFindMainWid(); /* find id of main display window */ + CreateGC(); /* create default graphics context */ + SmallScreen(); /* make room for status window */ + wsEnable(); /* display status window */ + CreateEditors(); /* start in editor mode */ + command=hCrackCommandLine(); /* analyse command line */ + if (ObeySystemCommand(command,DatUsedPathNamePtr,&dH)) + p_exit(0); + DrawFramework(); + DisplayStart(); + } + +GLDEF_C VOID main(VOID) + { /* the main() for all Hwif programs */ + uCommonInit(); /* initialisation common to all Hwif programs */ + SpecificInit(); /* initialisation specific to Days */ + MainLoop(); /* the central event processing loop */ + } diff --git a/code/SIBOSDK/hwdemo/days.ms b/code/SIBOSDK/hwdemo/days.ms new file mode 100644 index 0000000..9b02cf8 --- /dev/null +++ b/code/SIBOSDK/hwdemo/days.ms @@ -0,0 +1,3 @@ +Days.ANN +\ANN\ +3 diff --git a/code/SIBOSDK/hwdemo/days.pic b/code/SIBOSDK/hwdemo/days.pic new file mode 100644 index 0000000..4162ee4 Binary files /dev/null and b/code/SIBOSDK/hwdemo/days.pic differ diff --git a/code/SIBOSDK/hwdemo/days.rsc b/code/SIBOSDK/hwdemo/days.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/days.shd b/code/SIBOSDK/hwdemo/days.shd new file mode 100644 index 0000000..99283ee Binary files /dev/null and b/code/SIBOSDK/hwdemo/days.shd differ diff --git a/code/SIBOSDK/hwdemo/dump.afl b/code/SIBOSDK/hwdemo/dump.afl new file mode 100644 index 0000000..f6c3bae --- /dev/null +++ b/code/SIBOSDK/hwdemo/dump.afl @@ -0,0 +1,3 @@ +dump.pic +dump.rsc +dump.shd diff --git a/code/SIBOSDK/hwdemo/dump.c b/code/SIBOSDK/hwdemo/dump.c new file mode 100644 index 0000000..412cd7e --- /dev/null +++ b/code/SIBOSDK/hwdemo/dump.c @@ -0,0 +1,660 @@ +/* + DUMP.C + +Written by DavidW +Started on 27/11/91 + +*/ + +#include +#include +#include +#include + +GLREF_D UWORD DatLocked; +GLREF_D TEXT *DatUsedPathNamePtr; + + +LOCAL_D TEXT *cmds[]= + { + "oOpen", + "wWrite", + "fFind text", + "bFind bytes", + "aFind again", + "gGoto", + "xExit", + NULL + }; + +#define FILE_ITEMS 2 +#define FIND_ITEMS 3 +#define SPECIAL_ITEMS 2 + +#define ITEMS_BEFORE_FILE 0 +#define ITEMS_BEFORE_FIND FILE_ITEMS +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_FIND+FIND_ITEMS) + +LOCAL_D H_MENU_DATA mdata[]= + { + "File",FILE_ITEMS, + "Find",FIND_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D TEXT filename[P_FNAMESIZE+2]; +LOCAL_D VOID *fcb; + +LOCAL_D LONG lpos; +LOCAL_D LONG last; + +LOCAL_D UWORD DisplayPending; + +LOCAL_D VOID *wfcb; + +LOCAL_D TEXT findt[14]={0}; +LOCAL_D UWORD caset=1; +LOCAL_D TEXT findb[14]={0}; +LOCAL_D TEXT *pfind; +LOCAL_D UWORD casef; +LOCAL_D LONG fpos=(-1); + + +LOCAL_C VOID Check(INT val) + { + TEXT buf[64]; + + if (val<0) + { + wCancelBusyMsg(); + uForceToFront(); + DatLocked=TRUE; + p_errs(&buf[0],val); + wsAlertW(WS_ALERT_CLIENT,&buf[0],"Terminating application",0); + p_exit(0); + } + } + +LOCAL_C VOID DoSeek(INT sense,LONG *ppos) + { + Check(p_seek(fcb,sense,ppos)); + } + +LOCAL_C INT WriteLine(INT ignore,TEXT *pb) + { + return(p_write(wfcb,pb,38)); + } + +LOCAL_C INT PrintLine(INT lineno,TEXT *pb) + { + P_RECT box; + + box.tl.x=6; + box.tl.y=4+9*lineno; + box.br.x=234; + box.br.y=box.tl.y+9; + gPrintBoxText(&box,8,G_TEXT_ALIGN_LEFT,0,pb,38); + return(0); + } + +LOCAL_C VOID Output(INT len,INT nlines,INT DoLine(INT,TEXT *)) + { + TEXT inbuf[64]; + TEXT outbuf[38]; + INT i; + LONG loclpos; + INT linelen; + TEXT *pin; + TEXT *pout1; + TEXT *pout2; + INT val; + + Check(p_read(fcb,&inbuf[0],len)); + pin=(&inbuf[0]); + loclpos=lpos; + for (i=0; i64) + len=64; + else + { + len=(INT)diff; + stop=TRUE; + } + Output(len,len/8,WriteLine); + if (stop) + break; + diff-=64; + } + p_close(wfcb); + wInfoMsg("Dump written to file"); + } + +LOCAL_C VOID GotoLpos(VOID) + { + H_DI_NUMBER num; + + if (last<=64) + { + wInfoMsg("Whole file is already visible"); + return; + } + if (uOpenDialog(NULL)) + return; + num.value=(&lpos); + num.low=0; + num.high=last-64; + if (uAddDialogItem(H_DIALOG_NUMBER,"Goto",&num)) + return; + if (uRunDialog()<=0) + return; + Display(); + } + +LOCAL_C VOID HighlightBlock(INT x,INT y) + { + P_RECT box; + + box.tl.y=4+9*y; + box.br.y=box.tl.y+9; + if (&findb[0]==pfind) + { + box.tl.x=41+18*x; + box.br.x=box.tl.x+13; + } + else + { + box.tl.x=185+6*x; + box.br.x=box.tl.x+7; + } + gClrRect(&box,G_TRMODE_INV); + wFlush(); + p_sleep(10); + gClrRect(&box,G_TRMODE_INV); + } + +LOCAL_C VOID HighlightFpos(VOID) + { + INT offset; + + if (fposlpos+63) + { + lpos=fpos; + if (lpos>last-64) + lpos=last-64; + } + Display(); + offset=(INT)(fpos-lpos); + HighlightBlock(offset%8,offset/8); + } + +LOCAL_C INT DoSearch(LONG *ptot) + { + TEXT buf[256]; + INT toread; + TEXT *pb; + INT j; + INT offset; + INT len; + + DoSeek(P_FABS,ptot); + toread=256; + pb=(&buf[0]); + offset=0; + wSetBusyMsg("Searching",W_CORNER_BOTTOM_LEFT|2); + FOREVER + { + len=p_read(fcb,pb,toread); + if (len==E_FILE_EOF) + break; + Check(len); + if (casef==2) + j=p_bsub(&buf[0],len+offset,pfind+1,*pfind); + else + j=p_bsubi(&buf[0],len+offset,pfind+1,*pfind); + if (j>=0) + { + fpos=(*ptot)+j; + wCancelBusyMsg(); + HighlightFpos(); + return(0); + } + if (len=0) + { + wInfoMsg("Don't type any spaces"); + return(-1); + } + if (*pin&1) + { + wInfoMsg("Type bytes as two characters each"); + return(-1); + } + len=buf[0]=(*pin++)/2; + pout=(&buf[1]); + while (len--) + { + newpin=pin+2; + tmp=(*newpin); + *newpin=0; + if (p_stog(&pin,(UWORD *)pout,16) || pin!=newpin) + { + p_atos(&buf[0],"Conversion failure at %s",newpin-2); + wInfoMsg(&buf[0]); + *newpin=tmp; + return(-1); + } + *newpin=tmp; + pout++; + } + p_bcpy(&findb[0],&buf[0],buf[0]+1); + return(0); + } + +LOCAL_C VOID FindBytes(VOID) + { + TEXT bytes[26]; + H_DI_EDIT ed; + + LoadBytes(&bytes[0]); + ed.str=(&bytes[0]); + ed.len=24; + do + { + if (uOpenDialog("Find")) + return; + if (uAddDialogItem(H_DIALOG_EDIT,"Bytes",&ed)) + return; + if (uRunDialog()<=0) + return; + } while (RecoverBytes(&bytes[0])); + pfind=(&findb[0]); + casef=2; + SearchAll(); + } + +LOCAL_C VOID FindAgain(VOID) + { + LONG tot; + + if (fpos<0) + { + wInfoMsg("Nothing to find again"); + return; + } + tot=fpos+1; + if (tot==last || DoSearch(&tot)) + wInfoMsg("No more found"); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_FILE: + OpenFile(); + break; + case ITEMS_BEFORE_FILE+1: + WriteFile(); + break; + case ITEMS_BEFORE_FIND: + FindText(); + break; + case ITEMS_BEFORE_FIND+1: + FindBytes(); + break; + case ITEMS_BEFORE_FIND+2: + FindAgain(); + break; + case ITEMS_BEFORE_SPECIAL: + GotoLpos(); + break; + case ITEMS_BEFORE_SPECIAL+1: + p_exit(0); + } + } + +LOCAL_C VOID MoveToTop(VOID) + { + lpos=0; + DisplayPending=TRUE; + } + +LOCAL_C VOID CheckAndDisplay(VOID) + { + if (lpos<0) + lpos=0; + DisplayPending=TRUE; + } + +LOCAL_C VOID MoveToBottom(VOID) + { + lpos=last-64; + CheckAndDisplay(); + } + +LOCAL_C VOID MoveBy(INT delta) + { + lpos+=delta; + if (lpos>last-64) + lpos=last-64; + CheckAndDisplay(); + } + +LOCAL_C VOID EnsureDisplay(VOID) + { + if (DisplayPending) + Display(); + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + p_exit(0); + } + else if (key.keycode&W_SPECIAL_KEY) + { + EnsureDisplay(); + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + } + else + { + switch (key.keycode) + { + case W_KEY_MENU: + if (!(key.modifiers&W_CTRL_MODIFIER)) + { + EnsureDisplay(); + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + break; + case W_KEY_LEFT: + MoveBy(-1); + break; + case W_KEY_RIGHT: + MoveBy(1); + break; + case W_KEY_UP: + if (key.modifiers&W_CTRL_MODIFIER) + MoveToTop(); + else + MoveBy(-8); + break; + case W_KEY_DOWN: + if (key.modifiers&W_CTRL_MODIFIER) + MoveToBottom(); + else + MoveBy(8); + break; + case W_KEY_HOME: + MoveBy(-4); + break; + case W_KEY_END: + MoveBy(4); + break; + case W_KEY_PAGE_UP: + if (key.modifiers&W_CTRL_MODIFIER) + MoveToTop(); + else + MoveBy(-56); + break; + case W_KEY_PAGE_DOWN: + if (key.modifiers&W_CTRL_MODIFIER) + MoveToBottom(); + else + MoveBy(56); + break; + } + } + if (DisplayPending && !uKeyPressOutstanding()) + Display(); + } + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + G_GC gc; + + gc.style=G_STY_MONO; + hgc=gCreateGC(uFindMainWid(),G_GC_MASK_STYLE,&gc); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + CreateGC(); + gBorder(W_BORD_CORNER_4); + hCrackCommandLine(); + if (TryOpenFile(DatUsedPathNamePtr,&fcb)) + p_exit(0); + ResetDisplay(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/dump.ms b/code/SIBOSDK/hwdemo/dump.ms new file mode 100644 index 0000000..783c98e --- /dev/null +++ b/code/SIBOSDK/hwdemo/dump.ms @@ -0,0 +1,3 @@ +Dump.DMP +\DMP\ +8004 diff --git a/code/SIBOSDK/hwdemo/dump.pic b/code/SIBOSDK/hwdemo/dump.pic new file mode 100644 index 0000000..a72c839 Binary files /dev/null and b/code/SIBOSDK/hwdemo/dump.pic differ diff --git a/code/SIBOSDK/hwdemo/dump.rsc b/code/SIBOSDK/hwdemo/dump.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/dump.shd b/code/SIBOSDK/hwdemo/dump.shd new file mode 100644 index 0000000..cec4279 Binary files /dev/null and b/code/SIBOSDK/hwdemo/dump.shd differ diff --git a/code/SIBOSDK/hwdemo/iconed.afl b/code/SIBOSDK/hwdemo/iconed.afl new file mode 100644 index 0000000..aab4c51 --- /dev/null +++ b/code/SIBOSDK/hwdemo/iconed.afl @@ -0,0 +1,3 @@ +iconed.pic +iconed.rsc +iconed.shd diff --git a/code/SIBOSDK/hwdemo/iconed.c b/code/SIBOSDK/hwdemo/iconed.c new file mode 100644 index 0000000..4e67cd8 --- /dev/null +++ b/code/SIBOSDK/hwdemo/iconed.c @@ -0,0 +1,1364 @@ +/* + ICONED.C + +Written by DavidW +Started on 12/9/91 + +Based in part on work by Robert, May 91 +*/ + +#include +#include +#include +#include +#include + +GLREF_D UWORD DatLocked; +GLREF_D TEXT *DatUsedPathNamePtr; + + +LOCAL_D TEXT *cmds[]= + { + "nNew icon", + "oOpen icon", + "aSave as", + "sSave", + "rRevert", + "xExit", + "iInsert", + "cCopy", + "uUse", + "pPlaster", + "mMove", + "gGoto", + "zSet", + "qClear", + "tToggle", + "fFrame off", + "kCursor off", + "hHighlight select", + "wWrite text", + "bBorder", + "yInterrogation", + NULL + }; + +#define FILE_ITEMS 6 +#define EDIT_ITEMS 6 +#define BRUSH_ITEMS 3 +#define SPECIAL_ITEMS 6 + +#define ITEMS_BEFORE_FILE 0 +#define ITEMS_BEFORE_EDIT FILE_ITEMS +#define ITEMS_BEFORE_BRUSH (ITEMS_BEFORE_EDIT+EDIT_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_BRUSH+BRUSH_ITEMS) + +#define FRAME_ITEM ITEMS_BEFORE_SPECIAL +#define CURSOR_ITEM ITEMS_BEFORE_SPECIAL+1 + +LOCAL_D H_MENU_DATA mdata[]= + { + "File",FILE_ITEMS, + "Edit",EDIT_ITEMS, + "Brush",BRUSH_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_D WMSG_KEY key; + +LOCAL_D WORD bid; +LOCAL_D VOID *fcb; +LOCAL_D TEXT filename[P_FNAMESIZE]; + +LOCAL_D WORD clipbid[6]={0,0,0,0,0,0}; +LOCAL_D P_POINT clipsize[6]; + +#define MOVE_BACKUP 0 +#define MOVE_RAFT 5 + +LOCAL_D UWORD MoveUpdatePending; +LOCAL_D P_RECT moveorigin; +LOCAL_D P_RECT movedto; +LOCAL_D UWORD MoveSingle; + +LOCAL_D UWORD using=1; +LOCAL_D UWORD brush=2; +LOCAL_D UWORD changed=FALSE; +LOCAL_D UWORD show_cursor=TRUE; + +LOCAL_D UWORD show_frame=FALSE; +LOCAL_D UWORD show_statwin=FALSE; +LOCAL_D UWORD require_query=TRUE; + +LOCAL_D P_POINT anch; +LOCAL_D P_POINT curs; +LOCAL_D UWORD issel; + +LOCAL_D TEXT ToWrite[10]={0}; +LOCAL_D UWORD font=1; +LOCAL_D UWORD italic=1; + +LOCAL_D UWORD BordCorner=2; +LOCAL_D UWORD BordShadow=1; +LOCAL_D UWORD BordCushion=1; + +#define ICON_SIZE 24 +#define LARGE_ICON_SCALE 3 + +#define SMALL_ICON_X 41 +#define SMALL_ICON_WIDTH ICON_SIZE +#define SMALL_ICON_Y 8 +#define SMALL_ICON_HEIGHT ICON_SIZE + +#define LEFT_CURSOR_X 106 +#define TOP_CURSOR_Y 0 + +#define LARGE_ICON_X 110 +#define LARGE_ICON_Y 4 + +#define RIGHT_CURSOR_X 185 +#define BOTTOM_CURSOR_Y 79 + +#define TEXT_TL_X 4 +#define BRUSH_TEXT_Y 41 +#define USING_TEXT_Y 50 +#define CURSOR_TEXT_Y 59 +#define ANCHOR_TEXT_Y 68 +#define TEXT_BR_X 104 +#define TEXT_HEIGHT 9 +#define TEXT_ASCENT 8 + + +LOCAL_C VOID CDECL WriteAt(INT y,TEXT *str,...) + { + P_RECT box; + TEXT buf[40]; + INT len; + + len=p_atob(&buf[0],str,&str+1); + box.tl.x=TEXT_TL_X; + box.tl.y=y; + box.br.x=TEXT_BR_X; + box.br.y=y+TEXT_HEIGHT; + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_LEFT,0,&buf[0],len); + } + +LOCAL_C VOID WriteBrushText(VOID) + { + WriteAt(BRUSH_TEXT_Y,"Brush is `%s'",cmds[brush+ITEMS_BEFORE_BRUSH]+1); + } + +LOCAL_C VOID WriteCursorText(VOID) + { + WriteAt(CURSOR_TEXT_Y,"Cursor: X %d, Y %d",curs.x,curs.y); + WriteAt(ANCHOR_TEXT_Y,(issel? "Anchor: X %d, Y %d": ""),anch.x,anch.y); + } + +LOCAL_C VOID WriteClipboardText(VOID) + { + WriteAt(USING_TEXT_Y,"Using clipboard %d",using); + } + +LOCAL_C VOID ScaleUp(P_RECT *pbox) + { + pbox->tl.x=LARGE_ICON_X+pbox->tl.x*LARGE_ICON_SCALE; + pbox->tl.y=LARGE_ICON_Y+pbox->tl.y*LARGE_ICON_SCALE; + pbox->br.x=LARGE_ICON_X+pbox->br.x*LARGE_ICON_SCALE; + pbox->br.y=LARGE_ICON_Y+pbox->br.y*LARGE_ICON_SCALE; + } + +LOCAL_C VOID GetSmallSelectRegion(P_RECT *pbox) + { + if (anch.x>curs.x) + { + pbox->tl.x=curs.x; + pbox->br.x=anch.x+1; + } + else + { + pbox->tl.x=anch.x; + pbox->br.x=curs.x+1; + } + if (anch.y>curs.y) + { + pbox->tl.y=curs.y; + pbox->br.y=anch.y+1; + } + else + { + pbox->tl.y=anch.y; + pbox->br.y=curs.y+1; + } + } + +LOCAL_C VOID GetSelectRegion(P_RECT *pbox) + { + GetSmallSelectRegion(pbox); + ScaleUp(pbox); + } + +LOCAL_C VOID GetCursorBox(P_RECT *pbox) + { + pbox->tl.x=LARGE_ICON_X+curs.x*LARGE_ICON_SCALE; + pbox->tl.y=LARGE_ICON_Y+curs.y*LARGE_ICON_SCALE; + pbox->br.x=pbox->tl.x+LARGE_ICON_SCALE; + pbox->br.y=pbox->tl.y+LARGE_ICON_SCALE; + } + +LOCAL_C VOID MakeCursorFlash(P_RECT *pbox) + { + W_CURSOR wc; + + wc.pos.x=pbox->tl.x+1; + wc.pos.y=pbox->tl.y+1; + wc.height=1; + wc.width=1; + wc.ascent=0; + wDrawTextCursor(MainWid,&wc); + } + +LOCAL_C VOID ReassertCursor(VOID) + { + P_RECT box; + + if (show_cursor) + { + GetCursorBox(&box); + MakeCursorFlash(&box); + } + } + +LOCAL_C INT RunDialog(VOID) + { + INT ret; + + ret=uRunDialog(); + ReassertCursor(); + return(ret); + } + +LOCAL_C VOID ToggleHorizCurs(P_RECT *pbox,INT tly,INT dely) + { + P_RECT box; + + box=(*pbox); + box.tl.y=tly; + box.br.y=tly+1; + gClrRect(&box,G_TRMODE_INV); + p_offrec(&box,0,dely); + p_insrec(&box,1,0); + gClrRect(&box,G_TRMODE_INV); + } + +LOCAL_C VOID ToggleVertCurs(P_RECT *pbox,INT tlx,INT delx) + { + P_RECT box; + + box=(*pbox); + box.tl.x=tlx; + box.br.x=tlx+1; + gClrRect(&box,G_TRMODE_INV); + p_offrec(&box,delx,0); + p_insrec(&box,0,1); + gClrRect(&box,G_TRMODE_INV); + } + +LOCAL_C VOID ToggleSelectBox(VOID) + { + P_RECT box; + + GetSelectRegion(&box); + gDrawBox(&box); + } + +LOCAL_C VOID ToggleCursor(VOID) + { + P_RECT box; + + if (show_cursor) + { + GetCursorBox(&box); + ToggleHorizCurs(&box,TOP_CURSOR_Y,1); + ToggleHorizCurs(&box,BOTTOM_CURSOR_Y,-1); + ToggleVertCurs(&box,LEFT_CURSOR_X,1); + ToggleVertCurs(&box,RIGHT_CURSOR_X,-1); + MakeCursorFlash(&box); + if (issel) + ToggleSelectBox(); + } + } + +LOCAL_C VOID DrawSmallIcon(VOID) + { + P_POINT offset; + P_RECT size; + + offset.x=SMALL_ICON_X; + offset.y=SMALL_ICON_Y; + size.tl.x=size.tl.y=0; + size.br.x=SMALL_ICON_WIDTH; + size.br.y=SMALL_ICON_HEIGHT; + gCopyBit(&offset,bid,&size,G_TRMODE_REPL); + } + +LOCAL_C VOID DrawLargeIcon(VOID) + { + ULONG bits[2]; + P_POINT log; + P_RECT box; + INT j; + + log.x=0; + box.tl.y=LARGE_ICON_Y; + for (log.y=0; log.ytl.x=pbox->tl.y=0; + pbox->br.x=pbox->br.y=ICON_SIZE; + } + +LOCAL_C VOID InvertOrGrey(VOID) + { + INT keycode; + P_RECT box; + + if (uOpenDialog(issel? "Plaster selection": "Plaster whole icon")) + return; + if (uAddButtonList("Cancel",W_KEY_ESCAPE,"Grey",'g',"Invert",'i',NULL)) + return; + if (!(keycode=RunDialog())) + return; + if (!issel) + GetWholeIcon(&box); + else + { + ToggleSelectBox(); + GetSmallSelectRegion(&box); + } + gCreateTempGC0(bid); + if (keycode=='i') + gClrRect(&box,G_TRMODE_INV); + else + gFillPattern(&box,WS_BITMAP_GREY,G_TRMODE_INV); + changed=TRUE; + gFreeTempGC(); + DrawIcons(); + if (issel) + ToggleSelectBox(); + } + +LOCAL_C VOID ToggleCursorVisibility(VOID) + { + cmds[CURSOR_ITEM]=(show_cursor? "kCursor on": "kCursor off"); + if (show_cursor) + { + ToggleCursor(); + show_cursor=FALSE; + wEraseTextCursor(); + } + else + { + show_cursor=TRUE; + ToggleCursor(); + } + } + +LOCAL_C VOID WriteText(VOID) + { + H_DI_EDIT edit; + G_GC gc; + INT gcflags; + + if (uOpenDialog("Write text")) + return; + edit.str=(&ToWrite[0]); + edit.len=9; + if (uAddDialogItem(H_DIALOG_EDIT,"Text",&edit)) + return; + if (uAddChoiceList("Font",&font,"Standard","Bold","Small digits",NULL)) + return; + if (AddNoYesChoice("Italic",&italic)) + return; + if (RunDialog()<=0) + return; + gCreateTempGC0(bid); + gcflags=G_GC_MASK_TEXTMODE|G_GC_MASK_FONT; + gc.textmode=brush; + gc.font=WS_FONT_BASE+font-1; + if (italic==2) + { + gcflags|=G_GC_MASK_STYLE; + gc.style=G_STY_ITALIC; + } + gSetGC(0,gcflags,&gc); + gPrintText(curs.x,curs.y,&ToWrite[1],ToWrite[0]); + changed=TRUE; + gFreeTempGC(); + DrawIcons(); + } + +LOCAL_C VOID DrawBorder(VOID) + { + INT bflags; + G_GC gc; + + if (uOpenDialog("Draw border")) + return; + if (uAddChoiceList("Corner",&BordCorner,"Simple","Gentle","Round",NULL)) + return; + if (uAddChoiceList("Shadow",&BordShadow,"None","Single","Double",NULL)) + return; + if (AddNoYesChoice("Cushion",&BordCushion)) + return; + if (RunDialog()<=0) + return; + gc.gmode=brush; + gCreateTempGC(bid,G_GC_MASK_GMODE,&gc); + bflags=W_BORD_SHADOW_ON; + if (BordCorner==1) + bflags|=W_BORD_CORNER_1; + else if (BordCorner==3) + bflags|=W_BORD_CORNER_4; + if (BordShadow==2) + bflags|=W_BORD_SHADOW_S; + else if (BordShadow==3) + bflags|=W_BORD_SHADOW_D; + if (BordCushion==2) + bflags|=W_BORD_CUSHION; + gBorder(bflags); + changed=TRUE; + gFreeTempGC(); + DrawIcons(); + } + +LOCAL_C VOID ChangeClipboardUsed(VOID) + { + if (uOpenDialog("Use")) + return; + if (uAddChoiceList("Clipboard",&using,"1","2","3","4",NULL)) + return; + if (RunDialog()<=0) + return; + WriteClipboardText(); + } + +LOCAL_C VOID CancelSelect(VOID) + { + ToggleSelectBox(); + issel=FALSE; + WriteCursorText(); + } + +LOCAL_C VOID CheckIfSelectStatusChanging(VOID) + { + if (!(key.modifiers&W_SHIFT_MODIFIER)) + issel=FALSE; + else if (!issel) + { + issel=TRUE; + anch=curs; + } + } + +LOCAL_C VOID CheckForNullSelect(VOID) + { + if (anch.x==curs.x && anch.y==curs.y) + issel=FALSE; + } + +LOCAL_C VOID MoveCursorAbsolute(INT newx,INT newy) + { + ToggleCursor(); + CheckIfSelectStatusChanging(); + if (newx>=0) + curs.x=newx; + if (newy>=0) + curs.y=newy; + CheckForNullSelect(); + ToggleCursor(); + WriteCursorText(); + } + +LOCAL_C VOID RepositionCursor(VOID) + { + H_DI_NUMBER posx; + H_DI_NUMBER posy; + LONG curx; + LONG cury; + UWORD extend; + + curx=curs.x; + cury=curs.y; + posx.low=0; + posx.high=23; + posx.value=(&curx); + posy.low=0; + posy.high=23; + posy.value=(&cury); + extend=(issel? 2: 1); + if (uOpenDialog("Go to")) + return; + if (uAddDialogItem(H_DIALOG_NUMBER,"Cursor x",&posx)) + return; + if (uAddDialogItem(H_DIALOG_NUMBER,"Cursor y",&posy)) + return; + if (AddNoYesChoice("Extend select",&extend)) + return; + if (RunDialog()<=0) + return; + key.modifiers=(extend==2? W_SHIFT_MODIFIER: 0); + MoveCursorAbsolute((INT)curx,(INT)cury); + } + +LOCAL_C VOID FlashHighlightRegion(VOID) + { + P_RECT select; + + if (!issel) + { + wInfoMsg("No select region"); + return; + } + GetSelectRegion(&select); + wInfoMsgCorner("Showing select region",W_CORNER_TOP_LEFT); + gFillPattern(&select,WS_BITMAP_GREY,G_TRMODE_INV); + wFlush(); + p_sleep(20L); + gFillPattern(&select,WS_BITMAP_GREY,G_TRMODE_INV); + } + +LOCAL_C INT DoCopy(P_RECT *prect,INT clipindex) + { + P_POINT size; + P_POINT origin; + INT newclipbid; + + size.x=prect->br.x-prect->tl.x; + size.y=prect->br.y-prect->tl.y; + newclipbid=gCreateBit(0,&size); + if (newclipbid<0) + { + uErrorValue(newclipbid); + return(-1); + } + gCreateTempGC0(newclipbid); + origin.x=origin.y=0; + gCopyBit(&origin,bid,prect,G_TRMODE_REPL); + gFreeTempGC(); + wFree(clipbid[clipindex]); + clipbid[clipindex]=newclipbid; + clipsize[clipindex]=size; + return(0); + } + +LOCAL_C VOID CopyToClipboard(VOID) + { + P_RECT rect; + + if (issel) + { + if (!CheckUserConfirms("Copy select region to clipboard")) + return; + GetSmallSelectRegion(&rect); + } + else + { + if (!CheckUserConfirms("Copy whole icon to clipboard")) + return; + GetWholeIcon(&rect); + } + if (DoCopy(&rect,using)) + return; + wInfoMsg("Copied"); + } + +LOCAL_C VOID DoDelete(P_RECT *prect) + { + gCreateTempGC0(bid); + gClrRect(prect,G_TRMODE_CLR); + gFreeTempGC(); + } + +LOCAL_C VOID CutToClipboard(VOID) + { + P_RECT rect; + + if (issel) + { + if (!CheckUserConfirms("Cut select region into clipboard")) + return; + GetSmallSelectRegion(&rect); + } + else + { + if (!CheckUserConfirms("Cut whole icon into clipboard")) + return; + GetWholeIcon(&rect); + } + if (DoCopy(&rect,using)) + return; + key.modifiers=0; + MoveCursorAbsolute(rect.tl.x,rect.tl.y); + DoDelete(&rect); + changed=TRUE; + DrawIcons(); + } + +LOCAL_C VOID DoInsert(P_POINT *target,INT clipindex,INT mode) + { + P_RECT rect; + + rect.tl.x=rect.tl.y=0; + rect.br.x=clipsize[clipindex].x; + rect.br.y=clipsize[clipindex].y; + gCreateTempGC0(bid); + gCopyBit(target,clipbid[clipindex],&rect,mode); + gFreeTempGC(); + } + +LOCAL_C VOID InsertFromClipboard(VOID) + { + if (!clipbid[using]) + { + wInfoMsg("Current clipboard is empty"); + return; + } + if (!CheckUserConfirms("Insert from clipboard")) + return; + if (issel) + CancelSelect(); + DoInsert(&curs,using,brush); + DrawIcons(); + changed=TRUE; + } + +LOCAL_C VOID ConsiderInterrogation(VOID) + { + UWORD nsel; + + if (uOpenDialog("Before cut/copy/insert")) + return; + nsel=(require_query? 2: 1); + if (AddNoYesChoice("Request confirmation",&nsel)) + return; + if (RunDialog()<=0) + return; + require_query=(nsel==2); + } + +LOCAL_C VOID ResetStateBeforeMove(VOID) + { + P_POINT origin; + + origin.x=origin.y=0; + DoInsert(&origin,MOVE_BACKUP,G_TRMODE_REPL); + } + +LOCAL_C VOID MoveBy(INT offx,INT offy) + { + if (issel || !MoveSingle) + ResetStateBeforeMove(); + if (MoveSingle) + DoDelete(&moveorigin); + p_offrec(&movedto,offx,offy); + DoInsert(&movedto.tl,MOVE_RAFT,G_TRMODE_REPL); + MoveUpdatePending=TRUE; + } + +LOCAL_C VOID EnterMoveState(VOID) + { + TEXT *title; + INT keycode; + + GetWholeIcon(&moveorigin); + if (DoCopy(&moveorigin,MOVE_BACKUP)) + return; + if (issel) + { + title="Move select region"; + GetSmallSelectRegion(&moveorigin); + } + else + title="Move whole icon"; + if (uOpenDialog(title)) + goto TidyUp; + if (uAddButtonList("Single copy",'s',"Double copy",'d',NULL)) + goto TidyUp; + if (!(keycode=RunDialog())) + goto TidyUp; + MoveSingle=(keycode=='s'); + if (DoCopy(&moveorigin,MOVE_RAFT)) + goto TidyUp; + movedto=moveorigin; + ToggleCursor(); + wEraseTextCursor(); + DatLocked=TRUE; + wSetBusyMsg("Moving",W_CORNER_BOTTOM_LEFT); + MoveUpdatePending=FALSE; + FOREVER + { + uGetKey(&key); + switch (key.keycode) + { + case W_KEY_UP: + MoveBy(0,-1); + break; + case W_KEY_DOWN: + MoveBy(0,1); + break; + case W_KEY_LEFT: + MoveBy(-1,0); + break; + case W_KEY_RIGHT: + MoveBy(1,0); + break; + case W_KEY_ESCAPE: + ResetStateBeforeMove(); + DrawIcons(); + goto ExitMoveState; + case W_KEY_RETURN: + changed=TRUE; + goto ExitMoveState; + default: + p_sound(-5,320); + wInfoMsg("ENTER or ESC exits `Moving'"); + } + if (MoveUpdatePending && !uKeyPressOutstanding()) + { + DrawIcons(); + MoveUpdatePending=FALSE; + } + } +ExitMoveState: + DatLocked=FALSE; + ToggleCursor(); + wCancelBusyMsg(); + wFree(clipbid[MOVE_RAFT]); + clipbid[MOVE_RAFT]=0; +TidyUp: + wFree(clipbid[MOVE_BACKUP]); + clipbid[MOVE_BACKUP]=0; + } + +LOCAL_C INT IncrementAndFix(INT value,INT delta) + { + value+=delta; + if (value<0) + value+=ICON_SIZE; + else if (value>=ICON_SIZE) + value-=ICON_SIZE; + return(value); + } + +LOCAL_C VOID AlterBit(INT gmode) + { + P_RECT box; + + gCreateTempGC0(bid); + box.tl=curs; + box.br.x=curs.x+1; + box.br.y=curs.y+1; + gClrRect(&box,gmode); + changed=TRUE; + gFreeTempGC(); + DrawSmallIcon(); + ScaleUp(&box); + gClrRect(&box,gmode); + } + +LOCAL_C VOID MoveCursorRelative(INT delx,INT dely) + { + if (key.modifiers&W_CTRL_MODIFIER) + AlterBit(brush); + ToggleCursor(); + CheckIfSelectStatusChanging(); + curs.x=IncrementAndFix(curs.x,delx); + curs.y=IncrementAndFix(curs.y,dely); + CheckForNullSelect(); + ToggleCursor(); + WriteCursorText(); + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C INT ObeySystemCommand(INT cmd,TEXT *pb,VOID **newfcb) + { + return((cmd=='O'? TryOpenIconFile: TryNewIconFile)(pb,newfcb)); + } + +LOCAL_C VOID CreateGC(VOID) + { + G_GC gc; + INT hgc; + + gc.gmode=G_TRMODE_INV; + hgc=gCreateGC(MainWid,G_GC_MASK_GMODE,&gc); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + INT command; + + MainWid=uFindMainWid(); + CreateGC(); + ToggleFrame(); + command=hCrackCommandLine(); + bid=ObeySystemCommand(command,DatUsedPathNamePtr,&fcb); + if (bid<=0) + p_exit(0); + ReduceScreenSize(); + ToggleStatusWindow(); + RestartDisplay(); + WriteBrushText(); + WriteClipboardText(); + wInfoMsg("Press `Help' for tips on usage"); + } + +LOCAL_C VOID ProcessSystemCommand(VOID) + { + TEXT buf[P_FNAMESIZE+2]; + INT newbid; + VOID *newfcb; + + wGetCommand((UBYTE *)&buf[0]); + if (buf[0]=='X') + ExitApplication(); + SaveIfChanged(); + newbid=ObeySystemCommand(buf[0],&buf[1],&newfcb); + if (newbid>0) + ChangeOverTo(newbid,newfcb,&buf[1]); + } + +LOCAL_C VOID DisplayHelpText(VOID) + { + INT choice; + + FOREVER + { + choice=uDialogMenu("Help on which topic", + "Cursor position", + "Select regions", + "Drawing lines", + "Brushes", + "Using clipboards", + "Borders and frames",NULL); + switch (choice) + { + case 0: + return; + case 2: + uDisplayText("To move the cursor:", + "use the usual cursor keys", + "including Home, End, PgUp and PgDn", + "or use `Goto' in the `Edit' menu.", + "Use Enter or Space to toggle the pixel", + "at the cursor position.",NULL); + break; + case 3: + uDisplayText("To create a select region:", + "use SHIFTed cursor keys.", + "To emphasise a select region:", + "use `Highlight' in the `Special' menu.", + "`Move', Delete, `Copy' and `Plaster'", + "all operate on the current select region.",NULL); + break; + case 4: + uDisplayText("To draw vertical or horizontal lines:", + "use the cursor keys plus CONTROL.", + "Lines are drawn in the current Brush.",NULL); + break; + case 5: + uDisplayText("The Brush setting affects:", + "horizontal and vertical lines drawn", + "borders drawn using `Border'", + "text written using `Write'", + "and contents inserted from clipboards.", + "`Toggle' is the most useful setting.",NULL); + break; + case 6: + uDisplayText("Choose between 4 clipboards with `Use'.", + "Cut into a clipboard with the Delete key.", + "To eliminate `Are you sure?' queries:", + "use `Interrogation' in the `Special' menu.",NULL); + break; + case 7: + uDisplayText("To apply one of many types of border:", + "use `Border' in the `Special' menu.", + "To hide or show a frame round the icon:", + "use `Frame' in the `Special' menu.", + "To control cursor indicators in the frame:", + "use `Cursor' in the `Special' menu.",NULL); + break; + } + } + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_FILE: + NewIconFile(); + break; + case ITEMS_BEFORE_FILE+1: + OpenIconFile(); + break; + case ITEMS_BEFORE_FILE+2: + SaveIconAs(); + break; + case ITEMS_BEFORE_FILE+3: + SaveIcon(); + break; + case ITEMS_BEFORE_FILE+4: + RevertIfConfirmed(); + break; + case ITEMS_BEFORE_FILE+5: + ExitApplication(); + break; + case ITEMS_BEFORE_EDIT: + InsertFromClipboard(); + break; + case ITEMS_BEFORE_EDIT+1: + CopyToClipboard(); + break; + case ITEMS_BEFORE_EDIT+2: + ChangeClipboardUsed(); + break; + case ITEMS_BEFORE_EDIT+3: + InvertOrGrey(); + break; + case ITEMS_BEFORE_EDIT+4: + EnterMoveState(); + break; + case ITEMS_BEFORE_EDIT+5: + RepositionCursor(); + break; + case ITEMS_BEFORE_BRUSH: + case ITEMS_BEFORE_BRUSH+1: + case ITEMS_BEFORE_BRUSH+2: + brush=index-ITEMS_BEFORE_BRUSH; + WriteBrushText(); + break; + case ITEMS_BEFORE_SPECIAL: + ToggleFrame(); + break; + case ITEMS_BEFORE_SPECIAL+1: + ToggleCursorVisibility(); + break; + case ITEMS_BEFORE_SPECIAL+2: + FlashHighlightRegion(); + break; + case ITEMS_BEFORE_SPECIAL+3: + WriteText(); + break; + case ITEMS_BEFORE_SPECIAL+4: + DrawBorder(); + break; + case ITEMS_BEFORE_SPECIAL+5: + ConsiderInterrogation(); + break; + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ProcessSystemCommand(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else + { + switch (key.keycode) + { + case W_KEY_MENU: + if (key.modifiers&W_CTRL_MODIFIER) + ToggleStatusWindow(); + else + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + break; + case W_KEY_RETURN: + case ' ': + AlterBit(G_TRMODE_INV); + break; + case W_KEY_LEFT: + MoveCursorRelative(-1,0); + break; + case W_KEY_RIGHT: + MoveCursorRelative(1,0); + break; + case W_KEY_UP: + MoveCursorRelative(0,-1); + break; + case W_KEY_DOWN: + MoveCursorRelative(0,1); + break; + case W_KEY_HOME: + MoveCursorAbsolute(0,-1); + break; + case W_KEY_END: + MoveCursorAbsolute(ICON_SIZE-1,-1); + break; + case W_KEY_PAGE_UP: + MoveCursorAbsolute(-1,0); + break; + case W_KEY_PAGE_DOWN: + MoveCursorAbsolute(-1,ICON_SIZE-1); + break; + case W_KEY_ESCAPE: + if (issel) + CancelSelect(); + break; + case W_KEY_DELETE_LEFT: + CutToClipboard(); + break; + case W_KEY_HELP: + DisplayHelpText(); + } + } + } + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/iconed.ms b/code/SIBOSDK/hwdemo/iconed.ms new file mode 100644 index 0000000..0f86baa --- /dev/null +++ b/code/SIBOSDK/hwdemo/iconed.ms @@ -0,0 +1,3 @@ +Iconed.PIC +\PIC\ +3 diff --git a/code/SIBOSDK/hwdemo/iconed.pic b/code/SIBOSDK/hwdemo/iconed.pic new file mode 100644 index 0000000..97e81e4 Binary files /dev/null and b/code/SIBOSDK/hwdemo/iconed.pic differ diff --git a/code/SIBOSDK/hwdemo/iconed.rsc b/code/SIBOSDK/hwdemo/iconed.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/iconed.shd b/code/SIBOSDK/hwdemo/iconed.shd new file mode 100644 index 0000000..f435236 Binary files /dev/null and b/code/SIBOSDK/hwdemo/iconed.shd differ diff --git a/code/SIBOSDK/hwdemo/joker.afl b/code/SIBOSDK/hwdemo/joker.afl new file mode 100644 index 0000000..38248ad --- /dev/null +++ b/code/SIBOSDK/hwdemo/joker.afl @@ -0,0 +1,3 @@ +joker.pic +joker.rsc +joker.shd diff --git a/code/SIBOSDK/hwdemo/joker.c b/code/SIBOSDK/hwdemo/joker.c new file mode 100644 index 0000000..a3785ea --- /dev/null +++ b/code/SIBOSDK/hwdemo/joker.c @@ -0,0 +1,338 @@ +/* + JOKER.C + +Written by DavidW +Started on 15/11/91 + +*/ + +#include +#include +#include +#include +#include + + +LOCAL_D TEXT *cmds[]= + { + "oOverwrite", + "dDouble free", + "fFaulty free", + "wWind up stack", + "bBusy", + "sSlow exit", + "xExit", + NULL + }; + +#define CORRUPT_ITEMS 3 +#define SPECIAL_ITEMS 4 + +#define ITEMS_BEFORE_CORRUPT 0 +#define ITEMS_BEFORE_SPECIAL CORRUPT_ITEMS + +LOCAL_D H_MENU_DATA mdata[]= + { + "Corrupt heap",CORRUPT_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_D LONG delay=50l; + + +LOCAL_C VOID DoSleep(VOID) + { + TEXT buf[30]; + + p_atos(&buf[0],"Waiting %ld/10 secs",delay); + wSetBusyMsg(&buf[0],W_CORNER_BOTTOM_LEFT); + p_sleep(delay); + wCancelBusyMsg(); + } + +LOCAL_C INT AddInDelayItem(VOID) + { + H_DI_NUMBER num; + + num.value=(&delay); + num.low=0; + num.high=1000; + return(uAddDialogItem(H_DIALOG_NUMBER,"Delay (10ths of secs)",&num)); + } + +LOCAL_C INT AddNumberEditor(TEXT *prompt,LONG *pnum,INT low,INT high) + { + H_DI_NUMBER num; + + num.value=pnum; + num.low=low; + num.high=high; + return(uAddDialogItem(H_DIALOG_NUMBER,prompt,&num)); + } + +LOCAL_C VOID OverwriteAllocCell(VOID) + { + LONG cellen; + LONG overwlen; + UBYTE *cell; + + if (uOpenDialog("Overwrite alloc cell")) + return; + cellen=0x100; + if (AddNumberEditor("Length of cell to alloc",&cellen,4,0x1000)) + return; + overwlen=4; + if (AddNumberEditor("Length of overwrite",&overwlen,1,0x100)) + return; + if (AddInDelayItem()) + return; + if (uRunDialog()<=0) + return; + cell=p_alloc((UWORD)cellen); + if (!cell) + { + wInfoMsg("Cell too large to alloc"); + return; + } + DoSleep(); + p_bfil(cell,(UWORD)(cellen+overwlen),0xee); + } + +LOCAL_C VOID FreeCellTwice(VOID) + { + LONG cellen; + UBYTE *cell; + + if (uOpenDialog("Free cell twice")) + return; + cellen=0x100; + if (AddNumberEditor("Length of cell to free twice",&cellen,4,0x1000)) + return; + if (AddInDelayItem()) + return; + if (uRunDialog()<=0) + return; + cell=p_alloc((UWORD)cellen); + if (!cell) + { + wInfoMsg("Cell too large to alloc"); + return; + } + p_free(cell); + DoSleep(); + p_free(cell); + } + +LOCAL_C VOID FreeWrongCell(VOID) + { + LONG cellen; + UBYTE *cell; + + if (uOpenDialog("Free wrong cell")) + return; + cellen=0x100; + if (AddNumberEditor("Length of correct cell",&cellen,4,0x1000)) + return; + if (AddInDelayItem()) + return; + if (uRunDialog()<=0) + return; + cell=p_alloc((UWORD)cellen); + if (!cell) + { + wInfoMsg("Cell too large to alloc"); + return; + } + DoSleep(); + p_free(cell+1); + } + +LOCAL_C VOID MainLoop(VOID); + +LOCAL_C VOID DoWindupStack(VOID) + { + UBYTE junk[256]; + + p_bfil(&junk[0],256,0); + MainLoop(); + } + +LOCAL_C VOID WindupStack(VOID) + { + if (uOpenDialog("Wind up stack")) + return; + if (AddInDelayItem()) + return; + if (uRunDialog()<=0) + return; + DoSleep(); + DoWindupStack(); + } + +#define Y_BUSY_LOW 10 +#define Y_BUSY_HIGH 78 +#define X_BUSY 83 +#define BUSY_SCALE 1000 + +LOCAL_C VOID DoPrint(UINT y) + { + gPrintText(X_BUSY,y,"Busy",4); + wFlush(); + } + +LOCAL_C VOID GoBusy(VOID) + { + LONG nloops; + UWORD y; + UWORD lasty; + ULONG j; + + if (uOpenDialog("Go busy")) + return; + nloops=3; + if (AddNumberEditor("Number of loops of activity",&nloops,1,10)) + return; + if (AddInDelayItem()) + return; + if (uRunDialog()<=0) + return; + DoSleep(); + while (nloops--) + { + lasty=Y_BUSY_LOW; + DoPrint(lasty); + j=Y_BUSY_LOW*BUSY_SCALE; + FOREVER + { + j++; + y=(UWORD)(j/BUSY_SCALE); + if (y!=lasty) + { + DoPrint(lasty); + if (y>Y_BUSY_HIGH) + break; + lasty=y; + DoPrint(y); + } + } + } + } + +LOCAL_C VOID SlowExit(VOID) + { + if (uOpenDialog("Slow exit")) + return; + if (AddInDelayItem()) + return; + if (uRunDialog()<=0) + return; + DoSleep(); + p_exit(0); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_CORRUPT: + OverwriteAllocCell(); + break; + case ITEMS_BEFORE_CORRUPT+1: + FreeCellTwice(); + break; + case ITEMS_BEFORE_CORRUPT+2: + FreeWrongCell(); + break; + case ITEMS_BEFORE_SPECIAL: + WindupStack(); + break; + case ITEMS_BEFORE_SPECIAL+1: + GoBusy(); + break; + case ITEMS_BEFORE_SPECIAL+2: + SlowExit(); + break; + case ITEMS_BEFORE_SPECIAL+3: + p_exit(0); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID GoToSystemScreen(VOID) + { + wClientPosition(0,p_pidfind("SYS$SHLL.*")); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + else if (key.keycode==26) + GoToSystemScreen(); + } + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + G_GC gc; + INT hgc; + + gc.textmode=G_TRMODE_INV; + hgc=gCreateGC(MainWid,G_GC_MASK_TEXTMODE,&gc); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + MainWid=uFindMainWid(); + CreateGC(); + ReduceScreenSize(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + wCaptureKey(26,W_CTRL_MODIFIER,W_CTRL_MODIFIER); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/joker.ms b/code/SIBOSDK/hwdemo/joker.ms new file mode 100644 index 0000000..c4dfc59 --- /dev/null +++ b/code/SIBOSDK/hwdemo/joker.ms @@ -0,0 +1 @@ +Joker diff --git a/code/SIBOSDK/hwdemo/joker.pic b/code/SIBOSDK/hwdemo/joker.pic new file mode 100644 index 0000000..27bf496 Binary files /dev/null and b/code/SIBOSDK/hwdemo/joker.pic differ diff --git a/code/SIBOSDK/hwdemo/joker.rsc b/code/SIBOSDK/hwdemo/joker.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/joker.shd b/code/SIBOSDK/hwdemo/joker.shd new file mode 100644 index 0000000..a30768f Binary files /dev/null and b/code/SIBOSDK/hwdemo/joker.shd differ diff --git a/code/SIBOSDK/hwdemo/make.bat b/code/SIBOSDK/hwdemo/make.bat new file mode 100644 index 0000000..f260a39 --- /dev/null +++ b/code/SIBOSDK/hwdemo/make.bat @@ -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 diff --git a/code/SIBOSDK/hwdemo/notes.afl b/code/SIBOSDK/hwdemo/notes.afl new file mode 100644 index 0000000..7578d91 --- /dev/null +++ b/code/SIBOSDK/hwdemo/notes.afl @@ -0,0 +1,3 @@ +notes.pic +notes.rsc +notes.shd diff --git a/code/SIBOSDK/hwdemo/notes.c b/code/SIBOSDK/hwdemo/notes.c new file mode 100644 index 0000000..a7d0326 --- /dev/null +++ b/code/SIBOSDK/hwdemo/notes.c @@ -0,0 +1,1121 @@ +/* + NOTES.C + +Written by DavidW +Started on 17/12/91 + +*/ + +#include +#include +#include +#include +#include +#include + + +LOCAL_D TEXT *cmds[]= + { + "aNew note", + "jInsert note", + "kCopy note", + "dDelete note", + "iInsert text", + "cCopy text", + "vEvaluate", + "zSum", + "rRecord", + "uUndo", + "tTitle window", + "nNotes window", + "fFind window", + "oOptions", + "sSearch forwards", + "bSearch backwards", + "qSearch first", + "lSearch last", + "+Set", + "-Clear", + "*Tag all", + "/Clear all", + "gGo to", + "mMove to", + "hShow symbols", + "pPrint", + "yPrint setup", + "xExit", + NULL + }; + +#define NOTES_ITEMS 4 +#define EDIT_ITEMS 6 +#define WINDOW_ITEMS 3 +#define SEARCH_ITEMS 5 +#define TAG_ITEMS 4 +#define SPECIAL_ITEMS 6 + +#define ITEMS_BEFORE_NOTES 0 +#define ITEMS_BEFORE_EDIT NOTES_ITEMS +#define ITEMS_BEFORE_WINDOW (ITEMS_BEFORE_EDIT+EDIT_ITEMS) +#define ITEMS_BEFORE_SEARCH (ITEMS_BEFORE_WINDOW+WINDOW_ITEMS) +#define ITEMS_BEFORE_TAG (ITEMS_BEFORE_SEARCH+SEARCH_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_TAG+TAG_ITEMS) + +#define SYMBOLS_ITEM ITEMS_BEFORE_SPECIAL+2 + +LOCAL_D H_MENU_DATA mdata[]= + { + "Notes",NOTES_ITEMS, + "Edit",EDIT_ITEMS, + "Windows",WINDOW_ITEMS, + "Search",SEARCH_ITEMS, + "Tag",TAG_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +typedef struct + { + UBYTE len; + TEXT *buf; + } LENBUF; + +typedef struct + { + LENBUF title; + LENBUF note; + UWORD tagged; + } NOTE; + +LOCAL_D NOTE index[99]; +LOCAL_D WORD count=1; +LOCAL_D WORD where; + +LOCAL_D WORD changed=TRUE; + +LOCAL_D VOID *edit[3]; +LOCAL_D UWORD show_statwin=TRUE; +LOCAL_D UWORD ScreenWidth; +LOCAL_D INT emph=0; + +LOCAL_D INT sumflag='='; +LOCAL_D INT sumndp=2; + +LOCAL_D NOTE clip; + +LOCAL_D UWORD PrintTagsOnly; +LOCAL_D UWORD PrintRec; +LOCAL_D UWORD PrintState; +LOCAL_D TEXT *PrintBuf; +LOCAL_D WORD PrintLen; +LOCAL_D UWORD PrintCount; +LOCAL_D UWORD PrintNewPage=1; + +LOCAL_D UWORD casesens=1; +LOCAL_D UWORD findtype=1; +LOCAL_D TEXT *pattern; +LOCAL_D WORD pattlen; + +LOCAL_D UWORD ShowSymbols=FALSE; + +LOCAL_D TEXT FindStack[6][21]; +LOCAL_D WORD FindSP=0; + +LOCAL_D UWORD tly[]={0,17,65}; +LOCAL_D UWORD bry[]={15,62,80}; + +LOCAL_C VOID DrawBorder(INT i) + { + P_RECT rect; + + rect.tl.x=(i? 0: 8); + rect.br.x=ScreenWidth; + if (i==2) + rect.br.x-=30; + rect.tl.y=tly[i]; + rect.br.y=bry[i]; + gBorderRect(&rect, + W_BORD_CORNER_4|W_BORD_SHADOW_S|(i==emph? W_BORD_SHADOW_ON: 0)); + hEBEmphasise(edit[i],i==emph); + } + +LOCAL_C VOID RotateTo(INT newemph) + { + INT oldemph; + + if (newemph!=emph) + { + oldemph=emph; + emph=newemph; + DrawBorder(oldemph); + DrawBorder(newemph); + } + } + +LOCAL_C INT CheckEditing(VOID) + { + if (emph==1) + return(0); + wInfoMsg("Only available in notes window"); + return(-1); + } + +LOCAL_C INT RecordChange(VOID *ebH,LENBUF *lb) + { + TEXT *buf; + INT len; + TEXT *newbuf; + + if (!hEBSenseChanged(ebH)) + return(0); + buf=hEBSenseText(ebH); + len=p_slen(buf); + newbuf=p_realloc(lb->buf,len); + if (!newbuf) + { + wInfoMsg("No memory to store changes in note"); + return(-1); + } + lb->buf=newbuf; + lb->len=len; + p_bcpy(newbuf,buf,len); + hEBClearChanged(ebH); + return(0); + } + +LOCAL_C INT RecordChanges(VOID) + { + return(RecordChange(edit[0],&index[where].title) + || RecordChange(edit[1],&index[where].note)); + } + +LOCAL_C VOID DrawWhereAndCount(VOID) + { + TEXT buf[10]; + P_RECT box; + + p_atos(&buf[0],"%d/%d",where+1,count); + box.tl.x=ScreenWidth-30; + box.br.x=ScreenWidth; + box.tl.y=67; + box.br.y=77; + gPrintBoxText(&box,8,G_TEXT_ALIGN_CENTRE,0,&buf[0],p_slen(&buf[0])); + } + +LOCAL_C VOID DrawTagStatus(VOID) + { + P_RECT box; + + box.tl.y=2; + box.br.y=12; + box.tl.x=0; + box.br.x=8; + gPrintBoxText(&box,8,G_TEXT_ALIGN_LEFT,0,"\014",index[where].tagged); + } + +LOCAL_C INT LoadEditors(VOID) + { + if (hEBSetText(edit[0],index[where].title.buf,index[where].title.len)) + return(-1); + hEBClearChanged(edit[0]); + if (hEBSetText(edit[1],index[where].note.buf,index[where].note.len)) + return(-1); + hEBClearChanged(edit[1]); + DrawWhereAndCount(); + DrawTagStatus(); + return(0); + } + +LOCAL_C INT LocateNewWhere(VOID) + { + if (index[where].title.len || index[where].note.len) + { + if (count==99) + { + wInfoMsg("Maximum number of notes reached"); + return(-1); + } + where=count++; + } + return(0); + } + +LOCAL_C VOID StartNewNote(VOID) + { + if (RecordChanges()) + return; + if (LocateNewWhere()) + return; + if (LoadEditors()) + return; + RotateTo(0); + } + +LOCAL_C INT CheckChanged(VOID) + { + if (!hEBSenseChanged(edit[0]) && !hEBSenseChanged(edit[1])) + { + wInfoMsg("Not changed"); + return(-1); + } + return(0); + } + +LOCAL_C VOID RecordNote(VOID) + { + if (CheckChanged()) + return; + if (RecordChanges()) + return; + wInfoMsg("Note recorded"); + } + +LOCAL_C INT RunDialog(VOID) + { + INT ret; + + hEBEmphasise(edit[emph],FALSE); + ret=uRunDialog(); + hEBEmphasise(edit[emph],TRUE); + return(ret); + } + +LOCAL_C INT Confirm(TEXT *pb) + { + if (uOpenDialog(pb)) + return(-1); + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return(-1); + return(RunDialog()!='y'); + } + +LOCAL_C VOID UndoEditing(VOID) + { + if (CheckChanged()) + return; + if (Confirm("Undo editing")) + return; + LoadEditors(); + } + +LOCAL_C VOID GoToNote(VOID) + { + LONG newwhere; + H_DI_NUMBER num; + + newwhere=where+1; + if (uOpenDialog("Go to")) + return; + num.value=(&newwhere); + num.low=1; + num.high=count; + if (uAddDialogItem(H_DIALOG_NUMBER,"Note number",&num)) + return; + if (RunDialog()<=0) + return; + if (RecordChanges()) + return; + where=(INT)newwhere-1; + LoadEditors(); + } + +LOCAL_C VOID MoveNote(VOID) + { + LONG newwhere; + H_DI_NUMBER num; + INT neww; + INT tomove; + NOTE moving; + NOTE *targ; + NOTE *src; + + newwhere=1; + if (uOpenDialog("Move note")) + return; + num.value=(&newwhere); + num.low=1; + num.high=count; + if (uAddDialogItem(H_DIALOG_NUMBER,"New note number",&num)) + return; + if (RunDialog()<=0) + return; + neww=(INT)newwhere-1; + tomove=(neww-where)*sizeof(NOTE); + if (!tomove) + return; + moving=index[where]; + targ=(&index[where]); + src=targ+1; + if (tomove<0) + { + src=(&index[neww]); + targ=src+1; + tomove=(-tomove); + } + p_bcpy(targ,src,tomove); + index[neww]=moving; + where=neww; + DrawWhereAndCount(); + } + +LOCAL_C INT AddCentredTextItem(TEXT *pb) + { + H_DI_TEXT txt; + TEXT buf[64]; + + txt.type=H_DTEXT_ALIGN_CENTRE; + txt.str=(&buf[0]); + uZTStoBCS(&buf[0],pb); + return(uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)); + } + +LOCAL_C VOID SumData(VOID) + { + TEXT flag[2]; + H_DI_EDIT ed; + LONG newndp; + H_DI_NUMBER num; + WORD datacount; + INT badcount; + DOUBLE datasum; + DOUBLE value; + TEXT *pb; + INT ind; + TEXT buf[30]; + P_DTOB dtob; + + if (uOpenDialog("Sum data")) + return; + flag[0]=1; + flag[1]=(BYTE)sumflag; + ed.len=1; + ed.str=(&flag[0]); + if (uAddDialogItem(H_DIALOG_EDIT,"Sum values flagged by",&ed)) + return; + newndp=sumndp; + num.value=(&newndp); + num.low=0; + num.high=10; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number of dec places",&num)) + return; + if (RunDialog()<=0) + return; + sumndp=(INT)newndp; + if (flag[1]) + sumflag=flag[1]; + datacount=0; + badcount=0; + p_itof(&datasum,&datacount); + pb=hEBSenseText(edit[1]); + FOREVER + { + ind=p_sloc(pb,sumflag); + if (ind<0) + break; + pb+=ind+1; + if (p_stod(&pb,&value,'.')) + badcount++; + else + { + datacount++; + p_fadd(&datasum,&value); + } + } + if (badcount) + { + if (uOpenDialog("Warning")) + return; + p_atos(&buf[0],"%d bad flagged value(s)",badcount); + if (AddCentredTextItem(&buf[0])) + return; + RunDialog(); + } + p_atos(&buf[0],"Sum of %d values",datacount); + if (uOpenDialog(&buf[0])) + return; + dtob.type=P_DTOB_FIXED; + dtob.width=29; + dtob.ndec=sumndp; + dtob.point='.'; + dtob.trilen=0; + buf[p_dtob(&buf[0],&datasum,&dtob)]=0; + if (AddCentredTextItem(&buf[0])) + return; + if (AddCentredTextItem("(Sum will be copied into clipboard)")) + return; + if (RunDialog()<=0) + return; + hEBSetClipText(edit[1],&buf[0],p_slen(&buf[0])); + } + +LOCAL_C VOID PrintSetupDialog(VOID) + { + hEBEmphasise(edit[emph],FALSE); + hPrintSetupDialog(); + hEBEmphasise(edit[emph],TRUE); + } + +LOCAL_C VOID ZeroLenbuf(LENBUF *lb) + { + p_free(lb->buf); + lb->buf=NULL; + lb->len=0; + } + +LOCAL_C VOID ZeroNote(NOTE *pn) + { + ZeroLenbuf(&pn->title); + ZeroLenbuf(&pn->note); + pn->tagged=FALSE; + } + +LOCAL_C VOID DeleteNote(VOID) + { + INT tomove; + + if (Confirm("Delete this note")) + return; + tomove=count-1-where; + if (tomove>0) + p_bcpy(&index[where],&index[where+1],tomove*sizeof(NOTE)); + else + ZeroNote(&index[where]); + if (count>1) + count--; + if (where==count) + where=count-1; + LoadEditors(); + } + +LOCAL_C VOID ExitIfConfirmed(VOID) + { + if (uOpenDialog("Warning")) + return; + if (AddCentredTextItem("Exiting will delete all notes")) + return; + if (uAddButtonList("Cancel",W_KEY_ESCAPE,"Exit",W_KEY_RETURN,NULL)) + return; + if (RunDialog()!=W_KEY_RETURN) + return; + p_exit(0); + } + +LOCAL_C INT TakeCopyLenbuf(LENBUF *targ,LENBUF *src) + { + targ->buf=p_alloc(src->len); + if (!targ->buf) + { + uErrorValue(E_GEN_NOMEMORY); + return(-1); + } + p_bcpy(targ->buf,src->buf,src->len); + targ->len=src->len; + return(0); + } + +LOCAL_C INT TakeCopy(NOTE *targ,NOTE *src) + { + if (TakeCopyLenbuf(&targ->title,&src->title)) + return(-1); + if (TakeCopyLenbuf(&targ->note,&src->note)) + { + p_free(targ->title.buf); + targ->title.buf=0; + return(-1); + } + targ->tagged=src->tagged; + return(0); + } + +LOCAL_C VOID CopyNote(VOID) + { + NOTE new; + + if (RecordChanges()) + return; + if (!index[where].title.len && !index[where].note.len) + { + wInfoMsg("No note to copy"); + return; + } + if (TakeCopy(&new,&index[where])) + return; + ZeroNote(&clip); + clip=new; + wInfoMsg("Note copied"); + } + +LOCAL_C VOID InsertNote(VOID) + { + if (!clip.title.len && !clip.note.len) + { + wInfoMsg("No note to insert"); + return; + } + if (LocateNewWhere()) + return; + TakeCopy(&index[where],&clip); + LoadEditors(); + } + +LOCAL_C INT TagCount(VOID) + { + INT i; + INT tagcount; + + tagcount=0; + for (i=0; iblen=0; + if (PrintNewPage==2) + pr->flags|=H_PRINT_PAGE; + return(TRUE); + } + PrintState++; + case 1: + pr->style|=H_PRINT_STY_BOLD; + pr->blen=index[PrintRec].title.len; + pr->buf=index[PrintRec].title.buf; + break; + case 2: + PrintBuf=index[PrintRec].note.buf; + PrintLen=index[PrintRec].note.len; + default: + pr->buf=PrintBuf; + ind=p_bloc(PrintBuf,PrintLen,'\n'); + if (ind>=0) + { + pr->blen=ind; + PrintLen-=ind+1; + PrintBuf+=ind+1; + } + else + { + pr->blen=PrintLen; + PrintCount++; + PrintState=0; + PrintRec++; + } + } + pr->flags|=H_PRINT_KEEP; + return(TRUE); + } + +LOCAL_C VOID PrintNotes(VOID) + { + if (uOpenDialog("Print")) + return; + if (uAddChoiceList("New page for each note",&PrintNewPage,"No","Yes",0)) + return; + if (uAddButtonList("Tagged notes",'t',"All notes",'a',NULL)) + return; + PrintTagsOnly=FALSE; + switch (RunDialog()) + { + case 't': + PrintTagsOnly=TRUE; + case 'a': + if (RecordChanges()) + return; + PrintRec=0; + PrintState=0; + PrintCount=0; + hPrint(PrintLine); + InfoMsg("%d note(s) printed",PrintCount); + } + } + +LOCAL_C VOID OptionsForSearch(VOID) + { + if (uOpenDialog("Options for search")) + return; + if (uAddChoiceList("Case sensitive",&casesens,"No","Yes",NULL)) + return; + if (uAddChoiceList("Search",&findtype,"Just notes", + "Just title","Title and notes",NULL)) + return; + RunDialog(); + } + +LOCAL_C INT Search(INT here,INT window) + { + LENBUF *lb; + INT ind; + + lb=(&index[here].title)+window; + if (casesens==1) + ind=p_bsubi(lb->buf,lb->len,pattern,pattlen); + else + ind=p_bsub(lb->buf,lb->len,pattern,pattlen); + if (ind<0) + return(-1); + if (here!=where) + { + where=here; + if (LoadEditors()) + return(0); + } + if (pattlen) + { + if (window!=emph) + { + hEBEmphasise(edit[emph],FALSE); + hEBSetCWidth(edit[window],0); + hEBEmphasise(edit[window],TRUE); + } + hEBSetSelect(edit[window],ind,ind+pattlen); + if (window!=emph) + { + wFlush(); + p_sleep(5L); + hEBEmphasise(edit[window],FALSE); + hEBSetCWidth(edit[window],2); + hEBEmphasise(edit[emph],TRUE); + } + } + return(0); + } + +LOCAL_C INT CheckSearchTitle(INT here) + { + if (!(findtype&0x02)) + return(-1); + return(Search(here,0)); + } + +LOCAL_C INT CheckSearchNote(INT here) + { + if (!(findtype&0x01)) + return(-1); + return(Search(here,1)); + } + +LOCAL_C VOID DoSearch(INT here,INT direction) + { + INT k; + + if (RecordChanges()) + return; + pattern=hEBSenseText(edit[2]); + pattlen=p_slen(pattern); + hEBClearChanged(edit[2]); + k=count; + while (k--) + { + here+=direction; + if (here<0) + here=count-1; + else if (here>=count) + here=0; + if (!CheckSearchTitle(here)) + return; + if (!CheckSearchNote(here)) + return; + } + wInfoMsg("Not found"); + } + +LOCAL_C VOID ToggleShowSymbols(VOID) + { + ShowSymbols^=TRUE; + hEBShowSymbols(edit[1],ShowSymbols); + cmds[SYMBOLS_ITEM]=(ShowSymbols? "hHide symbols": "hShow symbols"); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_NOTES: + StartNewNote(); + break; + case ITEMS_BEFORE_NOTES+1: + InsertNote(); + break; + case ITEMS_BEFORE_NOTES+2: + CopyNote(); + break; + case ITEMS_BEFORE_NOTES+3: + DeleteNote(); + break; + case ITEMS_BEFORE_EDIT: + if (!CheckEditing()) + { + if (hEBPaste(edit[1])>0) + wInfoMsg("No text to insert"); + } + break; + case ITEMS_BEFORE_EDIT+1: + if (!CheckEditing()) + { + if (hEBCopy(edit[1])>0) + wInfoMsg("No text to copy"); + else + wInfoMsg("Text copied"); + } + break; + case ITEMS_BEFORE_EDIT+2: + if (!CheckEditing()) + hEBEvaluate(edit[1]); + break; + case ITEMS_BEFORE_EDIT+3: + if (!CheckEditing()) + SumData(); + break; + case ITEMS_BEFORE_EDIT+4: + RecordNote(); + break; + case ITEMS_BEFORE_EDIT+5: + UndoEditing(); + break; + case ITEMS_BEFORE_WINDOW: + case ITEMS_BEFORE_WINDOW+1: + case ITEMS_BEFORE_WINDOW+2: + RotateTo(index-ITEMS_BEFORE_WINDOW); + break; + case ITEMS_BEFORE_SEARCH: + OptionsForSearch(); + break; + case ITEMS_BEFORE_SEARCH+1: + DoSearch(where, +1); + break; + case ITEMS_BEFORE_SEARCH+2: + DoSearch(where, -1); + break; + case ITEMS_BEFORE_SEARCH+3: + DoSearch(count,+1); + break; + case ITEMS_BEFORE_SEARCH+4: + DoSearch(count,-1); + break; + case ITEMS_BEFORE_TAG: + case ITEMS_BEFORE_TAG+1: + SetTag(ITEMS_BEFORE_TAG+1-index); + break; + case ITEMS_BEFORE_TAG+2: + case ITEMS_BEFORE_TAG+3: + TagAll(ITEMS_BEFORE_TAG+3-index); + break; + case ITEMS_BEFORE_SPECIAL: + GoToNote(); + break; + case ITEMS_BEFORE_SPECIAL+1: + MoveNote(); + break; + case ITEMS_BEFORE_SPECIAL+2: + ToggleShowSymbols(); + break; + case ITEMS_BEFORE_SPECIAL+3: + PrintNotes(); + break; + case ITEMS_BEFORE_SPECIAL+4: + PrintSetupDialog(); + break; + case ITEMS_BEFORE_SPECIAL+5: + ExitIfConfirmed(); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C INT ResizeWidth(UWORD width) + { + INT ret; + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=width; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + ret=uErrorValue(wCheckPoint()); + if (!ret) + ScreenWidth=width; + return(ret); + } + +LOCAL_C VOID SetStyle(INT style) + { + G_GC gc; + + gc.style=style; + gSetGC(0,G_GC_MASK_STYLE,&gc); + } + +LOCAL_C VOID DrawFindPrompt(VOID) + { + SetStyle(G_STY_ITALIC); + gPrintText(5,67+8,"Find:",5); + SetStyle(0); + } + +LOCAL_C VOID DrawBorders(VOID) + { + INT i; + + for (i=0; i<3; i++) + DrawBorder(i); + DrawFindPrompt(); + DrawWhereAndCount(); + } + +LOCAL_C VOID ClearWholeWindow(VOID) + { + P_RECT whole; + + whole.tl.x=whole.tl.y=0; + whole.br.x=240; + whole.br.y=80; + gClrRect(&whole,G_TRMODE_CLR); + } + +LOCAL_C VOID ToggleStatusWindow(VOID) + { + if (show_statwin) + { + if (ResizeWidth(240)) + return; + wsDisable(); + } + else + { + if (ResizeWidth(189)) + return; + wsEnable(); + } + show_statwin^=TRUE; + ClearWholeWindow(); + DrawBorders(); + hEBChangeWidth(edit[0],ScreenWidth-12-8); + hEBChangeWidth(edit[1],ScreenWidth-12); + hEBChangeWidth(edit[2],ScreenWidth-12-32-30); + } + +LOCAL_C VOID RotateFocus(INT shifted) + { + INT newemph; + + newemph=emph; + if (shifted) + { + if (!newemph--) + newemph=2; + } + else if (++newemph==3) + newemph=0; + RotateTo(newemph); + } + +LOCAL_C VOID QuickSearch(INT dir) + { + INT here; + + here=(hEBSenseChanged(edit[2])? count: where); + DoSearch(here,dir); + } + +LOCAL_C VOID ToFindStack(VOID) + { + TEXT *buf; + INT len; + + if (!hEBSenseChanged(edit[2])) + return; + buf=hEBSenseText(edit[2]); + len=p_slen(buf); + FindStack[FindSP][0]=len; + p_bcpy(&FindStack[FindSP][1],buf,len); + } + +LOCAL_C VOID ChangeFindSP(INT dir) + { + FindSP+=dir; + if (FindSP<0) + FindSP=5; + else if (FindSP>5) + FindSP=0; + if (hEBSetText(edit[2],&FindStack[FindSP][1],FindStack[FindSP][0])) + return; + hEBSetSelect(edit[2],0,FindStack[FindSP][0]); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else + { + switch (key.keycode) + { + case W_KEY_MENU: + if (key.modifiers&W_CTRL_MODIFIER) + ToggleStatusWindow(); + else + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + break; + case W_KEY_TAB: + RotateFocus(key.modifiers&W_SHIFT_MODIFIER); + break; + case W_KEY_RETURN: + if (!emph) + { + RotateTo(1); + break; + } + default: + if (emph==2) + { + if (key.keycode==W_KEY_RETURN) + { + ToFindStack(); + QuickSearch(key.modifiers&W_SHIFT_MODIFIER? -1: +1); + break; + } + else if (key.keycode==W_KEY_UP) + { + ToFindStack(); + ChangeFindSP(-1); + break; + } + else if (key.keycode==W_KEY_DOWN || key.keycode==W_KEY_ESCAPE) + { + ToFindStack(); + ChangeFindSP(+1); + break; + } + } + hEBHandleKey(edit[emph],key.keycode,key.modifiers); + } + } + } + } + +LOCAL_C VOID OpenEditors(VOID) + { + H_EDIT_BOX heb; + + heb.win=MainWid; + heb.maxchars=40; + heb.vulen=177-8; + heb.pos.x=5+8; + heb.pos.y=2; + heb.font=0x4001; + heb.style=0; + edit[0]=hEBOpen(H_EDIT_BOX_FONT,&heb); + heb.maxchars=256; + heb.vulen=177; + heb.vislines=4; + heb.pos.x=5; + heb.pos.y=19; + edit[1]=hEBOpen(H_EDIT_BOX_VISLINES| + H_EDIT_BOX_LEFT_CURSOR|H_EDIT_BOX_CLIPBOARD,&heb); + heb.maxchars=20; + heb.vulen=177-32-30; + heb.pos.x=5+32; + heb.pos.y=67; + edit[2]=hEBOpen(0,&heb); + } + +LOCAL_C VOID SmallScreen(VOID) + { + if (ResizeWidth(189)) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + uEscape(FALSE); + MainWid=uFindMainWid(); + CreateGC(); + hCrackCommandLine(); + SmallScreen(); + OpenEditors(); + DrawBorders(); + wsEnable(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/notes.ms b/code/SIBOSDK/hwdemo/notes.ms new file mode 100644 index 0000000..80e8176 --- /dev/null +++ b/code/SIBOSDK/hwdemo/notes.ms @@ -0,0 +1,3 @@ +Notes + +4000 diff --git a/code/SIBOSDK/hwdemo/notes.pic b/code/SIBOSDK/hwdemo/notes.pic new file mode 100644 index 0000000..63d830f Binary files /dev/null and b/code/SIBOSDK/hwdemo/notes.pic differ diff --git a/code/SIBOSDK/hwdemo/notes.rsc b/code/SIBOSDK/hwdemo/notes.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/notes.shd b/code/SIBOSDK/hwdemo/notes.shd new file mode 100644 index 0000000..dbd95a9 Binary files /dev/null and b/code/SIBOSDK/hwdemo/notes.shd differ diff --git a/code/SIBOSDK/hwdemo/qu1.c b/code/SIBOSDK/hwdemo/qu1.c new file mode 100644 index 0000000..ccfcb5a --- /dev/null +++ b/code/SIBOSDK/hwdemo/qu1.c @@ -0,0 +1,18 @@ +/* + QU1.C +*/ + +#include +#include +#include + +GLDEF_C VOID main(VOID) + { + WMSG_KEY key; + + uCommonInit(); + wSetBusyMsg("Hello world",W_CORNER_BOTTOM_LEFT); + uGetKey(&key); + uGetKey(&key); + p_exit(0); + } diff --git a/code/SIBOSDK/hwdemo/qu2.c b/code/SIBOSDK/hwdemo/qu2.c new file mode 100644 index 0000000..8c8b98a --- /dev/null +++ b/code/SIBOSDK/hwdemo/qu2.c @@ -0,0 +1,32 @@ +/* + QU2.C +*/ + +#include +#include +#include + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(uFindMainWid()); + if (hgc<0) + p_exit(hgc); + } + +GLDEF_C VOID main(VOID) + { + WMSG_KEY key; + + uCommonInit(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wSetBusyMsg("Hello world",W_CORNER_BOTTOM_LEFT); + FOREVER + { + uGetKey(&key); + if (key.keycode==(W_SPECIAL_KEY|'x')) + p_exit(0); + } + } diff --git a/code/SIBOSDK/hwdemo/qu3.c b/code/SIBOSDK/hwdemo/qu3.c new file mode 100644 index 0000000..d5dab36 --- /dev/null +++ b/code/SIBOSDK/hwdemo/qu3.c @@ -0,0 +1,120 @@ +/* + QU3.C +*/ + +#include +#include +#include + + +LOCAL_D TEXT *cmds[]= + { + "iInches/Centimetres", + "mMiles/Kilometres", + "lPounds/Kilogrammes", + "pPints/Litres", + "fFahrenheit/Centigrade", + "dDay of week", + "cCombinations", + "tTime difference", + "hHoroscope", + "nNow", + "wPassword", + "eEncrypt", + "uDecrypt", + "sSignificance", + "zFile size", + "xExit", + NULL + }; + +LOCAL_D H_MENU_DATA mdata[]= + { + "Conversions",5, + "Calendar",5, + "Secret",3, + "Special",3, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_C VOID ManageCommand(INT keycode) + { + INT index; + TEXT buf[40]; + + switch (keycode) + { + case 'x': + p_exit(0); + default: + index=uLocateCommand(keycode); + if (index>=0) + { + p_atos(&buf[0],"You chose `%s'",cmds[index]+1); + wInfoMsg(&buf[0]); + } + } + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_SPECIAL_KEY) + ManageCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + ManageCommand(ret); + } + } + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + wInfoMsg("Hello world"); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/qu4.afl b/code/SIBOSDK/hwdemo/qu4.afl new file mode 100644 index 0000000..3336f13 --- /dev/null +++ b/code/SIBOSDK/hwdemo/qu4.afl @@ -0,0 +1 @@ +query.pic diff --git a/code/SIBOSDK/hwdemo/qu4.c b/code/SIBOSDK/hwdemo/qu4.c new file mode 100644 index 0000000..eb942b9 --- /dev/null +++ b/code/SIBOSDK/hwdemo/qu4.c @@ -0,0 +1,250 @@ +/* + QU4.C +*/ + +#include +#include +#include +#include +#include + + +LOCAL_D TEXT *cmds[]= + { + "iInches/Centimetres", + "mMiles/Kilometres", + "lPounds/Kilogrammes", + "pPints/Litres", + "fFahrenheit/Centigrade", + "dDay of week", + "cCombinations", + "tTime difference", + "hHoroscope", + "nNow", + "wPassword", + "eEncrypt", + "uDecrypt", + "sSignificance", + "zFile size", + "xExit", + NULL + }; + +LOCAL_D H_MENU_DATA mdata[]= + { + "Conversions",5, + "Calendar",5, + "Secret",3, + "Special",3, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_D VOID *ttH; +LOCAL_D UWORD ttMonth=1; +LOCAL_D UWORD ttSuffix=1; +LOCAL_D UWORD ttDay=1; +LOCAL_D UWORD ttCentury=2; +LOCAL_D UWORD ttSeconds=2; + + +LOCAL_C INT AddNoYesChoiceList(TEXT *pmt,UWORD *pval) + { + return(uAddChoiceList(pmt,pval,"No","Yes",NULL)); + } + +LOCAL_C VOID TimeNow(VOID) + { + INT values; + H_DI_TEXT txt; + TEXT buf[48]; + + txt.str=(&buf[0]); + do + { + if (uOpenDialog(NULL)) + return; + uZTStoBCS(&buf[0],"Time is now"); + txt.type=H_DTEXT_ALIGN_CENTRE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + values=0; + if (ttMonth==2) + values=H_TIME_FORMAT_MONTH_NAME; + if (ttDay==2) + values|=H_TIME_FORMAT_DAY_NAME; + if (ttSuffix==2) + values|=H_TIME_FORMAT_SUFFIX; + if (ttCentury==1) + values|=H_TIME_FORMAT_NO_CENTURY; + if (ttSeconds==1) + values|=H_TIME_FORMAT_NO_SECONDS; + hTTSetFormat(ttH,values); + hTTSetTime(ttH,H_TIME_SET_NOW,NULL); + buf[0]=hTTSenseString(ttH,H_TIME_SENSE_BOTH,&buf[1]); + txt.type=H_DTEXT_ALIGN_CENTRE|H_DTEXT_UNDERLINE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + if (AddNoYesChoiceList("Give month name",&ttMonth)) + return; + if (AddNoYesChoiceList("Give day name",&ttDay)) + return; + if (AddNoYesChoiceList("Use date suffix",&ttSuffix)) + return; + if (AddNoYesChoiceList("Show century",&ttCentury)) + return; + if (AddNoYesChoiceList("Show seconds",&ttSeconds)) + return; + } while (uRunDialog()>0); + } + +LOCAL_C VOID SetUpDiDate(H_DI_DATE *pdate,P_DAYSEC *pds) + { + ULONG sdate; + + sdate=p_date(); + p_sttods(&sdate,pds); + pdate->value=(&pds->day); + pdate->low=0; + pdate->high=H_LAST_DAY; + } + +LOCAL_C VOID DayOfWeek(VOID) + { + P_DAYSEC ds; + H_DI_DATE date; + TEXT buf[40]; + H_DI_TEXT txt; + + SetUpDiDate(&date,&ds); + do + { + p_nmday(&buf[1],p_wkday(ds.day)); + buf[0]=p_slen(&buf[1]); + txt.str=(&buf[0]); + txt.type=H_DTEXT_ALIGN_LEFT; + if (uOpenDialog("Find day of week")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"Date",&date)) + return; + if (uAddDialogItem(H_DIALOG_TEXT,"Day of week",&txt)) + return; + } while (uRunDialog()>0); + } + +LOCAL_C VOID FileSize(VOID) + { + TEXT fname[P_FNAMESIZE+2]; + H_DI_FSEL fsel; + P_INFO info; + TEXT buf[30]; + + fname[0]=0; + fsel.fname=(&fname[0]); + fsel.flags=H_FILE_PICK_SELECTOR; + FOREVER + { + if (uOpenDialog("Find file size")) + return; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&fsel)) + return; + if (uRunDialog()<=0) + return; + fname[1+fname[0]]=0; + if (!uErrorValue(p_finfo(&fname[1],&info))) + { + p_atos(&buf[0],"File size is %lu bytes",info.size); + wInfoMsg(&buf[0]); + } + } + } + +LOCAL_C VOID ManageCommand(INT keycode) + { + INT index; + TEXT buf[40]; + + switch (keycode) + { + case 'd': + DayOfWeek(); + break; + case 'n': + TimeNow(); + break; + case 'z': + FileSize(); + break; + case 'x': + p_exit(0); + default: + index=uLocateCommand(keycode); + if (index>=0) + { + p_atos(&buf[0],"You chose `%s'",cmds[index]+1); + wInfoMsg(&buf[0]); + } + } + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_SPECIAL_KEY) + ManageCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + ManageCommand(ret); + } + } + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + ttH=hTTOpen(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/query.afl b/code/SIBOSDK/hwdemo/query.afl new file mode 100644 index 0000000..45e3789 --- /dev/null +++ b/code/SIBOSDK/hwdemo/query.afl @@ -0,0 +1,3 @@ +query.pic +query.rsc +query.shd diff --git a/code/SIBOSDK/hwdemo/query.c b/code/SIBOSDK/hwdemo/query.c new file mode 100644 index 0000000..995f400 --- /dev/null +++ b/code/SIBOSDK/hwdemo/query.c @@ -0,0 +1,796 @@ +/* + QUERY.C + +Written by DavidW +Started on 28/11/91 + +*/ + +#include +#include +#include +#include +#include +#include +#include + + +LOCAL_D TEXT *cmds[]= + { + "iInches/Centimetres", + "mMiles/Kilometres", + "lPounds/Kilogrammes", + "pPints/Litres", + "fFahrenheit/Centigrade", + "dDay of week", + "cCombinations", + "tTime difference", + "hHoroscope", + "nNow", + "wPassword", + "eEncrypt", + "uDecrypt", + "sSignificance", + "zFile size", + "xExit", + NULL + }; + +#define CONVERT_ITEMS 5 +#define CALENDAR_ITEMS 5 +#define SECRET_ITEMS 3 +#define SPECIAL_ITEMS 3 + +#define ITEMS_BEFORE_CONVERT 0 +#define ITEMS_BEFORE_CALENDAR CONVERT_ITEMS +#define ITEMS_BEFORE_SECRET (ITEMS_BEFORE_CALENDAR+CALENDAR_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_SECRET+SECRET_ITEMS) + +LOCAL_D H_MENU_DATA mdata[]= + { + "Conversions",CONVERT_ITEMS, + "Calendar",CALENDAR_ITEMS, + "Secret",SECRET_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_D WORD ndp=2; +LOCAL_D DOUBLE small; +LOCAL_D DOUBLE vsmall; + +LOCAL_D TEXT pass[10]; + +LOCAL_D VOID *ttH; +LOCAL_D UWORD ttMonth=1; +LOCAL_D UWORD ttSuffix=1; +LOCAL_D UWORD ttDay=1; +LOCAL_D UWORD ttCentury=2; +LOCAL_D UWORD ttSeconds=2; + + +LOCAL_C VOID CalcSmall(VOID) + { + DOUBLE dndp; + DOUBLE ten; + + dndp=(-ndp); + ten=10; + p_pow(&small,&ten,&dndp); + vsmall=small/2; + } + +LOCAL_C VOID Clip(DOUBLE *pval) + { + DOUBLE remain; + + if (*pval>=0) + (*pval)+=vsmall; + else + (*pval)-=vsmall; + p_mod(&remain,pval,&small); + (*pval)-=remain; + } + +LOCAL_C VOID Temperatures(VOID) + { + DOUBLE fahr; + DOUBLE cent; + H_DI_FLOAT ffahr; + H_DI_FLOAT fcent; + INT index; + + fahr=32; + cent=0; + ffahr.value=(&fahr); + ffahr.low=(-17968); + ffahr.high=18032; + fcent.value=(¢); + fcent.low=(-10000); + fcent.high=10000; + FOREVER + { + if (uOpenDialog("Convert temperature")) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,"Fahrenheit",&ffahr)) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,"Centigrade",&fcent)) + return; + index=uRunDialog(); + if (index<=0) + break; + if (index==2) + { + cent=(fahr-32)*5/9; + Clip(¢); + } + else + { + fahr=32+cent*9/5; + Clip(&fahr); + } + } + } + +LOCAL_C VOID Convert(TEXT *pmt1,TEXT *pmt2,INT high1,INT high2) + { + DOUBLE val1; + DOUBLE val2; + H_DI_FLOAT fled1; + H_DI_FLOAT fled2; + INT index; + DOUBLE ratio; + + val1=0; + val2=0; + fled1.value=(&val1); + fled1.low=0; + fled1.high=high1; + fled2.value=(&val2); + fled2.low=0; + fled2.high=high2; + ratio=fled2.high/fled1.high; + FOREVER + { + if (uOpenDialog("Convert")) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,pmt1,&fled1)) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,pmt2,&fled2)) + return; + index=uRunDialog(); + if (index<=0) + break; + if (index==2) + { + val2=val1*ratio; + Clip(&val2); + } + else + { + val1=val2/ratio; + Clip(&val1); + } + } + } + +LOCAL_C VOID InchAndCm(VOID) + { + Convert("Inches","Centimetres",10000,25400); + } + +LOCAL_C VOID MileAndKm(VOID) + { + Convert("Miles","Kilometres",20000,32187); + } + +LOCAL_C VOID PoundAndKg(VOID) + { + Convert("Pounds","Kilograms",31938,14500); + } + +LOCAL_C VOID PintAndL(VOID) + { + Convert("Pints","Litres",28156,16000); + } + +LOCAL_C VOID ChangeNdp(VOID) + { + LONG lndp; + H_DI_NUMBER num; + + if (uOpenDialog("Level of significance")) + return; + lndp=ndp; + num.value=(&lndp); + num.low=0; + num.high=4; + if (uAddDialogItem(H_DIALOG_NUMBER,"Decimal places",&num)) + return; + if (uRunDialog()<=0) + return; + ndp=(WORD)lndp; + CalcSmall(); + } + +LOCAL_C VOID SetUpDiDate(H_DI_DATE *pdate,P_DAYSEC *pds) + { + ULONG sdate; + + sdate=p_date(); + p_sttods(&sdate,pds); + pdate->value=(&pds->day); + pdate->low=0; + pdate->high=H_LAST_DAY; + } + +LOCAL_C VOID DayOfWeek(VOID) + { + P_DAYSEC ds; + H_DI_DATE date; + TEXT buf[40]; + H_DI_TEXT txt; + + SetUpDiDate(&date,&ds); + do + { + p_nmday(&buf[1],p_wkday(ds.day)); + buf[0]=p_slen(&buf[1]); + txt.str=(&buf[0]); + txt.type=H_DTEXT_ALIGN_LEFT; + if (uOpenDialog("Find day of week")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"Date",&date)) + return; + if (uAddDialogItem(H_DIALOG_TEXT,"Day of week",&txt)) + return; + } while (uRunDialog()>0); + } + +LOCAL_D TEXT *orient[]= + { + "Rat","Cow","Tiger","Rabbit","Dragon","Snake", + "Horse","Sheep","Monkey","Rooster","Dog","Pig" + }; + +LOCAL_D TEXT *western[]= + { + "Capricorn","Aquarius","Pisces","Aries","Taurus","Gemini", + "Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius" + }; + +LOCAL_C INT Zodiac(P_DATE *pdt) + { + INT ret; + LOCAL_D changeover[12]={19,18,19,19,20,20,22,22,22,22,21,20}; + + ret=pdt->month; + if (pdt->day>changeover[ret]) + { + if (ret++==11) + ret=0; + } + return(ret); + } + +LOCAL_C VOID Horoscope(VOID) + { + P_DAYSEC ds; + H_DI_DATE date; + P_DATE dt; + INT key; + TEXT buf[40]; + + SetUpDiDate(&date,&ds); + FOREVER + { + if (uOpenDialog("Horoscope")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"Date of birth",&date)) + return; + if (uAddButtonList("Stop",W_KEY_ESCAPE, + "Western",'w',"Oriental",'o',NULL)) + return; + key=uRunDialog(); + if (key<=0) + return; + p_dstodt(&ds,&dt); + if (key=='o') + p_atos(&buf[0],"Oriental horoscope is %s",orient[dt.year%12]); + else + p_atos(&buf[0],"Western horoscope is %s",western[Zodiac(&dt)]); + wInfoMsg(&buf[0]); + } + } + +LOCAL_C INT AddListOfDays(UWORD *pdiw) + { + H_DI_CHOICE ch; + TEXT nam[32]; + INT i; + + if (uBeginDCL(&ch)) + return(-1); + for (i=0; i<7; i++) + { + p_nmday(&nam[0],i); + if (uGrowDCL(&ch,&nam[0])) + return(-1); + } + return(uAddDCL("Day in week",pdiw,&ch)); + } + +LOCAL_C VOID Combinations(VOID) + { + P_DAYSEC ds; + H_DI_DATE date; + P_DATE dt; + INT key; + UWORD diw; + LONG dim; + H_DI_NUMBER num; + INT diff; + ULONG reset; + INT inc; + + SetUpDiDate(&date,&ds); + p_dstodt(&ds,&dt); + diw=p_wkday(ds.day)+1; + dim=dt.day+1; + num.value=(&dim); + num.low=1; + num.high=31; + FOREVER + { + if (uOpenDialog("Find date combinations")) + return; + if (AddListOfDays(&diw)) + return; + if (uAddDialogItem(H_DIALOG_NUMBER,"Day in month",&num)) + return; + if (uAddDialogItem(H_DIALOG_DATE,"Found date",&date)) + return; + if (uAddButtonList("Stop",W_KEY_ESCAPE,"Backwards",W_KEY_MENU, + "Forwards",W_KEY_RETURN,0)) + return; + key=uRunDialog(); + if (key<=0) + return; + reset=ds.day; + diff=diw-p_wkday(ds.day)-1; + if (key==W_KEY_RETURN) + { + if (diff<=0) + diff+=7; + inc=7; + } + else + { + if (diff>=0) + diff-=7; + inc=(-7); + } + ds.day+=diff; + dim-=1; + FOREVER + { + if (ds.day>H_LAST_DAY) + { + wInfoMsg("No further matches"); + ds.day=reset; + break; + } + p_dstodt(&ds,&dt); + if (dt.day==dim) + break; + ds.day+=inc; + } + dim+=1; + } + } + +LOCAL_C VOID SetUpTime(H_DI_TIME *ptime,P_DAYSEC *pds) + { + ptime->value=(&pds->sec); + ptime->low=0; + ptime->high=P_NSECDAY-1; + ptime->type=H_DTIME_SHOW_SECONDS; + } + +LOCAL_C VOID TimeDifference(VOID) + { + P_DAYSEC ds1; + H_DI_DATE date1; + H_DI_TIME time1; + P_DAYSEC ds2; + H_DI_DATE date2; + H_DI_TIME time2; + LONG diff; + TEXT buf[40]; + + SetUpDiDate(&date1,&ds1); + SetUpDiDate(&date2,&ds2); + SetUpTime(&time1,&ds1); + SetUpTime(&time2,&ds2); + FOREVER + { + if (uOpenDialog("Time difference")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"From",&date1)) + return; + if (uAddDialogItem(H_DIALOG_TIME,"",&time1)) + return; + if (uAddDialogItem(H_DIALOG_DATE,"To",&date2)) + return; + if (uAddDialogItem(H_DIALOG_TIME,"",&time2)) + return; + if (uRunDialog()<=0) + return; + diff=ds2.day-ds1.day; + if (diff<0 || !diff && ds2.sec0x7fffffffl/P_NSECDAY) + { + wInfoMsg("Dates are too far apart"); + continue; + } + p_atos(&buf[0],"Dates are %ld seconds apart", + diff*P_NSECDAY+ds2.sec-ds1.sec); + wInfoMsg(&buf[0]); + } + } + +LOCAL_C INT AddNoYesChoiceList(TEXT *pmt,UWORD *pval) + { + return(uAddChoiceList(pmt,pval,"No","Yes",NULL)); + } + +LOCAL_C VOID TimeNow(VOID) + { + INT values; + H_DI_TEXT txt; + TEXT buf[48]; + + txt.str=(&buf[0]); + do + { + if (uOpenDialog(NULL)) + return; + uZTStoBCS(&buf[0],"Time is now"); + txt.type=H_DTEXT_ALIGN_CENTRE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + values=0; + if (ttMonth==2) + values=H_TIME_FORMAT_MONTH_NAME; + if (ttDay==2) + values|=H_TIME_FORMAT_DAY_NAME; + if (ttSuffix==2) + values|=H_TIME_FORMAT_SUFFIX; + if (ttCentury==1) + values|=H_TIME_FORMAT_NO_CENTURY; + if (ttSeconds==1) + values|=H_TIME_FORMAT_NO_SECONDS; + hTTSetFormat(ttH,values); + hTTSetTime(ttH,H_TIME_SET_NOW,NULL); + buf[0]=hTTSenseString(ttH,H_TIME_SENSE_BOTH,&buf[1]); + txt.type=H_DTEXT_ALIGN_CENTRE|H_DTEXT_UNDERLINE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + if (AddNoYesChoiceList("Give month name",&ttMonth)) + return; + if (AddNoYesChoiceList("Give day name",&ttDay)) + return; + if (AddNoYesChoiceList("Use date suffix",&ttSuffix)) + return; + if (AddNoYesChoiceList("Show century",&ttCentury)) + return; + if (AddNoYesChoiceList("Show seconds",&ttSeconds)) + return; + } while (uRunDialog()>0); + } + +LOCAL_C VOID EnterPassword(VOID) + { + TEXT pass1[10]; + TEXT pass2[10]; + H_DI_XINPUT x1; + H_DI_XINPUT x2; + + x1.str=(&pass1[0]); + x2.str=(&pass2[0]); + FOREVER + { + if (uOpenDialog(NULL)) + return; + if (uAddDialogItem(H_DIALOG_XINPUT,"Define password",&x1)) + return; + if (uAddDialogItem(H_DIALOG_XINPUT,"Confirm password",&x2)) + return; + if (uRunDialog()<=0) + return; + if (p_bcmpi(&pass1[1],pass1[0],&pass2[1],pass2[0])) + { + wInfoMsg("Password not confirmed"); + continue; + } + if (pass1[0]) + break; + wInfoMsg("Please supply password"); + } + p_bfil(&pass[0],10,0); + p_bcpy(&pass[0],&pass1[0],pass1[0]+1); + } + +LOCAL_C VOID MakeReadable(TEXT *out,TEXT *in) + { + INT len; + INT i; + INT val; + + i=32; + len=(*in++); + *out++=len*2; + while (len--) + { + val=(*in++); + *out++=i+(val&0xf); + i+=16; + *out++=i+(val>>4); + if (i==112) + i=32; + else + i+=16; + } + } + +LOCAL_C VOID MakeUnreadable(TEXT *out,TEXT *in) + { + INT len; + INT i; + INT val; + + i=32; + len=(*in++)/2; + *out++=len; + while (len--) + { + val=(*in++)-i; + i+=16; + val+=((*in++)-i)<<4; + *out++=val; + if (i==112) + i=32; + else + i+=16; + } + } + +LOCAL_C VOID Report(TEXT *title,TEXT *mess) + { + H_DI_TEXT txt; + + if (uOpenDialog(title)) + return; + txt.str=mess; + txt.type=H_DTEXT_ALIGN_CENTRE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + uRunDialog(); + } + +LOCAL_C VOID EncryptMessage(VOID) + { + P_MASK mask; + H_DI_EDIT ed; + TEXT in[20]; + TEXT out[38]; + + if (!pass[0]) + { + wInfoMsg("Can't encrypt with no password set"); + return; + } + p_setmask((VOID **)&mask,&pass[1]); /** bug in prototype **/ + if (uOpenDialog("Encrypt message")) + return; + ed.str=(&in[0]); + ed.len=18; + in[0]=0; + if (uAddDialogItem(H_DIALOG_EDIT,"Message",&ed)) + return; + if (uRunDialog()<=0) + return; + p_encrypt(&mask,&in[1],in[0]); + MakeReadable(&out[0],&in[0]); + Report("Encrypted message",&out[0]); + } + +LOCAL_C VOID DecryptMessage(VOID) + { + P_MASK mask; + H_DI_SEDIT sed; + TEXT in[38]; + TEXT out[20]; + + if (!pass[0]) + { + wInfoMsg("Can't decrypt with no password set"); + return; + } + p_setmask((VOID **)&mask,&pass[1]); + if (uOpenDialog("Decrypt message")) + return; + sed.str=(&in[0]); + sed.len=36; + sed.width=16; + in[0]=0; + if (uAddDialogItem(H_DIALOG_SEDIT,"Message",&sed)) + return; + if (uRunDialog()<=0) + return; + MakeUnreadable(&out[0],&in[0]); + p_decrypt(&mask,&out[1],out[0]); + Report("Decrypted message",&out[0]); + } + +LOCAL_C VOID FileSize(VOID) + { + TEXT fname[P_FNAMESIZE+2]; + H_DI_FSEL fsel; + P_INFO info; + TEXT buf[30]; + + fname[0]=0; + fsel.fname=(&fname[0]); + fsel.flags=H_FILE_PICK_SELECTOR; + FOREVER + { + if (uOpenDialog("Find file size")) + return; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&fsel)) + return; + if (uRunDialog()<=0) + return; + fname[1+fname[0]]=0; + if (!uErrorValue(p_finfo(&fname[1],&info))) + { + p_atos(&buf[0],"File size is %lu bytes",info.size); + wInfoMsg(&buf[0]); + } + } + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_CONVERT: + InchAndCm(); + break; + case ITEMS_BEFORE_CONVERT+1: + MileAndKm(); + break; + case ITEMS_BEFORE_CONVERT+2: + PoundAndKg(); + break; + case ITEMS_BEFORE_CONVERT+3: + PintAndL(); + break; + case ITEMS_BEFORE_CONVERT+4: + Temperatures(); + break; + case ITEMS_BEFORE_CALENDAR: + DayOfWeek(); + break; + case ITEMS_BEFORE_CALENDAR+1: + Combinations(); + break; + case ITEMS_BEFORE_CALENDAR+2: + TimeDifference(); + break; + case ITEMS_BEFORE_CALENDAR+3: + Horoscope(); + break; + case ITEMS_BEFORE_CALENDAR+4: + TimeNow(); + break; + case ITEMS_BEFORE_SECRET: + EnterPassword(); + break; + case ITEMS_BEFORE_SECRET+1: + EncryptMessage(); + break; + case ITEMS_BEFORE_SECRET+2: + DecryptMessage(); + break; + case ITEMS_BEFORE_SPECIAL: + ChangeNdp(); + break; + case ITEMS_BEFORE_SPECIAL+1: + FileSize(); + break; + case ITEMS_BEFORE_SPECIAL+2: + p_exit(0); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + p_exit(0); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + } + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + CalcSmall(); + ttH=hTTOpen(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/query.ms b/code/SIBOSDK/hwdemo/query.ms new file mode 100644 index 0000000..900368a --- /dev/null +++ b/code/SIBOSDK/hwdemo/query.ms @@ -0,0 +1 @@ +Query diff --git a/code/SIBOSDK/hwdemo/query.pic b/code/SIBOSDK/hwdemo/query.pic new file mode 100644 index 0000000..8ab3856 Binary files /dev/null and b/code/SIBOSDK/hwdemo/query.pic differ diff --git a/code/SIBOSDK/hwdemo/query.rsc b/code/SIBOSDK/hwdemo/query.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/query.shd b/code/SIBOSDK/hwdemo/query.shd new file mode 100644 index 0000000..97e58fc Binary files /dev/null and b/code/SIBOSDK/hwdemo/query.shd differ diff --git a/code/SIBOSDK/hwdemo/remind.afl b/code/SIBOSDK/hwdemo/remind.afl new file mode 100644 index 0000000..8841d6e --- /dev/null +++ b/code/SIBOSDK/hwdemo/remind.afl @@ -0,0 +1,3 @@ +remind.pic +remind.rsc +remind.shd diff --git a/code/SIBOSDK/hwdemo/remind.c b/code/SIBOSDK/hwdemo/remind.c new file mode 100644 index 0000000..c6bcaba --- /dev/null +++ b/code/SIBOSDK/hwdemo/remind.c @@ -0,0 +1,875 @@ +/* + REMIND.C + +Written by DavidW +Started on 6/12/91 +Resource file version 1/11/92 +*/ + +#include /* basic Psion header file */ +#include /* defines object oriented functions */ +#include /* defines E_GEN_ error values, etc */ +#include /* defines E_FILE_ error values, etc */ +#include /* defines date and time functions */ +#include /* defines C_RSCFILE and related constants */ +#include /* defines all Window Server library functions */ +#include /* defines all Hwif Library functions */ +#include "remind.rh" /* definitions common to remind.rss & remind.c */ +#include "remind.rsg" /* GENERATED resource file header */ + +GLREF_D VOID *DatCommandPtr; /* where run from */ + +GLDEF_D TEXT ** _cmds; /* for menu commands */ +GLDEF_D H_MENU_DATA * _mdata; /* for menu titles */ + +LOCAL_C VOID *rcb; /* resource file object handle */ +LOCAL_D UINT MainWid; /* ID of main window */ + +typedef struct + { + ULONG sdate; /* date when reminder due */ + UBYTE ref; /* TRUE iff this is the reminder queued to ALM: */ + UBYTE tlen; /* length of text message */ + TEXT *pb; /* the text message itself (another alloc cell) */ + } ENTRY; /* represents one reminder */ + +LOCAL_D ENTRY table[500]; /* handle up to 500 reminders */ +LOCAL_D UWORD nent=0; /* number of entries */ +LOCAL_D INT cent=0; /* entry at cursor */ +LOCAL_D INT tent=0; /* entry at top of screen */ + +LOCAL_D ENTRY clipent; /* entry in clipboard */ + +LOCAL_D UWORD show_statwin=FALSE; /* is Status Window showing */ +LOCAL_D UWORD ScreenWidth; /* width of remaining screen */ + +LOCAL_D UWORD lastbflags=W_BORD_CORNER_4; /* which kind of Border flags */ + +LOCAL_D VOID *ttH; /* handle of Time Text object */ + +LOCAL_D VOID *aH; /* handle of channel to ALM: alarm device */ +LOCAL_D WORD almstat; /* status word for ALM: services */ +LOCAL_D WORD almactive; /* active word for ALM: services */ + +LOCAL_D UWORD PrintRec; /* which entry is being printed */ +LOCAL_D UWORD PrintState; /* which part of entry is being printed */ +LOCAL_D TEXT PrintBuf[48]; /* holds text about to be printed */ + + +LOCAL_C VOID LoadStr(INT rid,TEXT *pb) + { /* load resource into given buffer (assumed long enough) */ + while (p_entersend4(rcb,O_RS_READ_BUF,rid,pb)<0) + hRequestReplacePack(rcb,DatCommandPtr); + } + +LOCAL_C TEXT *str(INT rid) + { /* load specified resource into scratch buffer and return address */ + LOCAL_D TEXT scratch[50]; /* static "scratch" buffer */ + + LoadStr(rid,&scratch[0]); + return(&scratch[0]); + } + +LOCAL_C INT cmp(INT r,VOID *pent) + { /* comparison function used in binary searching */ + return(table[r].sdate>(*(ULONG *)pent)? -1: 1); + } + +LOCAL_C INT LocateEntry(ULONG *psdate) + { /* find entry at (or nearest after) given date */ + INT dir; /* direction to nearest hit (as given by p_bsrch) */ + INT ret; /* nearest hit (as given by p_bsrch) */ + + dir=p_bsrch(nent,cmp,&ret,psdate); + if (dir>0) + ret++; + return(ret); + } + +LOCAL_C ENTRY *LocateRef(VOID) + { /* find the entry that was queued to ALM: */ + ENTRY *pent; + + pent=(&table[0]); + while (!pent->ref) + pent++; + return(pent); + } + +LOCAL_C VOID RequeueAlarm(VOID) + { /* recalculate the next alarm due, and queue it (if any) */ + ULONG sdate; /* current time and date */ + INT entno; /* no of entry to queue */ + ENTRY *pent; /* entry to queue */ + ULONG times[2]; /* needed for service to ALM: */ + TEXT buf[66]; /* needed for service to ALM: */ + + if (almactive) + { /* cancel any alarm currently queued */ + p_iow2(aH,P_FCANCEL); + p_waitstat(&almstat); + almactive=FALSE; + LocateRef()->ref=FALSE; + } + if (!nent) + return; /* no entries hence none to queue */ + sdate=p_date(); + entno=LocateEntry(&sdate); + if (entno>=nent) + return; /* no entries with dates in the future */ + pent=(&table[entno]); + *p_bcpy(&buf[0],pent->pb,pent->tlen)=0; /* copy the text */ + pent->ref=TRUE; /* mark this entry as the one queued */ + times[0]=pent->sdate; /* fill in the time the alarm is due */ + times[1]=pent->sdate; /* and the time to DISPLAY */ + p_ioc5(aH,P_FWRITE,&almstat,×,&buf); + almactive=TRUE; /* set active word TRUE */ + } + +LOCAL_C VOID UpdateTimeFormat(VOID) + { /* Update time-text object's record of time format */ + hTTSetFormat(ttH,H_TIME_FORMAT_NO_SECONDS|H_TIME_FORMAT_SUFFIX| + H_TIME_FORMAT_DAY_NAME|H_TIME_FORMAT_MONTH_NAME); + } + +LOCAL_C INT SdateToBuf(TEXT *pb,ULONG *psdate) + { /* convert time and date to text, as per system preferences */ + hTTSetTime(ttH,H_TIME_SET_SDATE,psdate); + return(hTTSenseString(ttH,H_TIME_SENSE_BOTH,pb)); + } + +LOCAL_C VOID SetGmode(INT gmode) + { /* set Gmode of current graphics context */ + G_GC gc; + + gc.gmode=gmode; + gSetGC(0,G_GC_MASK_GMODE,&gc); + } + +LOCAL_C VOID SetBold(INT flag) + { /* prepare to print in bold (if flag TRUE) or non-bold */ + G_GC gc; + + gc.font=WS_FONT_BASE+flag; + gSetGC(0,G_GC_MASK_FONT,&gc); + } + +LOCAL_C VOID GetCursorBox(INT i,P_RECT *pbox) + { /* where should the cursor be drawn */ + pbox->tl.x=4; + pbox->br.x=10; + pbox->tl.y=4+i*18; + pbox->br.y=pbox->tl.y+9; + } + +LOCAL_C VOID DrawCursor(INT i) + { /* draw the cursor (character octal 34) */ + P_RECT box; + + GetCursorBox(i,&box); + gPrintBoxText(&box,8,G_TEXT_ALIGN_LEFT,0,"\034",1); + } + +LOCAL_C VOID EraseCursor(INT i) + { /* remove the cursor (from the specified row) */ + P_RECT box; + + GetCursorBox(i,&box); + gClrRect(&box,G_TRMODE_CLR); /* clear all pixels in the rectangle */ + } + +LOCAL_C VOID LineToScreen(INT y,INT xoff,TEXT *pb,INT tlen) + { /* print the given line of text on the screen */ + P_RECT box; + + box.tl.x=4; + box.tl.y=4+y*9; + box.br.x=ScreenWidth-4; + box.br.y=box.tl.y+9; + gPrintBoxText(&box,8,G_TEXT_ALIGN_LEFT,xoff,pb,tlen); + } + +LOCAL_C VOID ClearLine(INT y) + { /* clear all text from the given line */ + LineToScreen(y,0,NULL,0); + } + +LOCAL_C VOID DrawLine(INT i) + { /* draw the two lines of text for the specified entry */ + INT len; + INT entno; + ENTRY *pent; + TEXT buf[48]; + + entno=i+tent; /* offset by no. of first on-screen entry */ + if (entno>=nent) + { /* no entry for this position - hence clear */ + ClearLine(i*2); + ClearLine(i*2+1); + } + else + { + pent=(&table[entno]); + SetBold(TRUE); /* draw the date and time in bold */ + len=SdateToBuf(&buf[0],&pent->sdate); + LineToScreen(i*2,10,&buf[0],len); + SetBold(FALSE); /* draw the text (and any cursor) in non-bold */ + if (entno==cent) + DrawCursor(i); + LineToScreen(i*2+1,22,pent->pb,pent->tlen); + } + } + +LOCAL_C VOID Display(VOID) + { /* draw all four entry slots on the screen */ + INT i; + + if (!nent) + { /* no entries set - so display text to this effect */ + SetBold(TRUE); + LineToScreen(0,10,str(STR_NO_REMINDERS_SET),16); + ClearLine(1); /* clear the line under the message */ + return; + } + for (i=0; i<4; i++) + DrawLine(i); + } + +LOCAL_C INT ResizeWidth(UWORD width) + { /* try to change the width of the main display region */ + INT ret; + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=width; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + ret=uErrorValue(wCheckPoint()); /* check whether successful */ + if (!ret) + ScreenWidth=width; /* only record new value if successful */ + return(ret); + } + +LOCAL_C INT ToggleStatusWindow(VOID) + { /* attempt to toggle the visibility of the status window */ + if (show_statwin) + { /* status window is currently showing */ + if (ResizeWidth(240)) + return(-1); + wsDisable(); /* remove status window */ + } + else + { /* status window not currently showing */ + if (ResizeWidth(189)) + return(-1); + wsEnable(); /* display status window */ + } + show_statwin^=TRUE; + gBorder(lastbflags); /* redraw the border */ + Display(); /* redraw the main display */ + return(0); + } + +LOCAL_C VOID EnsureGoodTent(VOID) + { /* find good value for tent - top entry on screen */ + if (nent<5) + tent=0; /* show ALL entries if less than five in total */ + else if (tentcent) + tent=cent; /* cursor was off top of screen */ + } + +LOCAL_C VOID AppendEntry(ENTRY *pent) + { /* add the given entry */ + INT tomove; + + if (!nent) + cent=0; + else + { /* find where to insert the entry */ + cent=LocateEntry(&pent->sdate); /* uses binary search */ + tomove=nent-cent; /* how many entries to "move along */ + p_bcpy(&table[cent+1],&table[cent],tomove*sizeof(ENTRY)); + } + nent++; /* increment count of number of entries */ + table[cent]=(*pent); /* copy the entry details into the table */ + EnsureGoodTent(); /* check whether need to scroll */ + Display(); /* redraw the main display */ + RequeueAlarm(); /* ensure correct alarm is queued */ + } + +LOCAL_C VOID DoDeleteEntry(VOID) + { /* delete the current entry */ + INT tomove; /* how many records to "move back" */ + + p_free(table[cent].pb); /* free alloc cell holding the text */ + nent--; /* decrement total count of entries */ + tomove=nent-cent; /* now fill up the gap in the table */ + p_bcpy(&table[cent],&table[cent+1],tomove*sizeof(ENTRY)); + } + +LOCAL_C VOID CleanEntry(ENTRY *pent) + { /* prepare a blank entry */ + p_bfil(pent,sizeof(ENTRY),0); + pent->sdate=p_date()+3600; /* seed to one hour in the future */ + } + +LOCAL_C INT EditEntry(ENTRY *pent) + { /* allow the user to edit an entry */ + P_DAYSEC ds; + H_DI_DATE date; + H_DI_TIME time; + TEXT buf[66]; + H_DI_SEDIT sed; + + if (uOpenDialog(str(STR_REMINDER))) /* title line of dialog */ + return(-1); + p_bcpy(&buf[1],pent->pb,buf[0]=pent->tlen); + sed.str=(&buf[0]); /* prepare to edit the text of the reminder */ + sed.len=64; /* maximum allowed length */ + sed.width=25; /* width of "viewing" region */ + if (uAddDialogItem(H_DIALOG_SEDIT,str(STR_MESSAGE),&sed)) + return(-1); + p_sttods(&pent->sdate,&ds); /* crack into "time" and "date" */ + time.value=(&ds.sec); /* prepare to edit the time of the reminder */ + time.low=0; + time.high=P_NSECDAY-1; + time.type=0; + if (uAddDialogItem(H_DIALOG_TIME,str(STR_TIME),&time)) + return(-1); + date.value=(&ds.day); /* prepare to edit the date of the reminder */ + date.low=H_FIRST_SYS_DAY; + date.high=H_LAST_SYS_DAY; + if (uAddDialogItem(H_DIALOG_DATE,str(STR_DATE),&date)) + return(-1); + if (uRunDialog()<=0) + return(-1); /* user cancelled (or insufficient memory) */ + p_dstost(&ds,&pent->sdate); /* reconstitute system time */ + pent->pb=p_realloc(pent->pb,buf[0]); /* check text alloc cell length */ + if (!pent->pb) + { /* no memory left to grow the text alloc cell */ + uErrorValue(E_GEN_NOMEMORY); + return(-1); + } + pent->tlen=buf[0]; + p_bcpy(pent->pb,&buf[1],buf[0]); + return(0); /* signal successful edit */ + } + +LOCAL_C VOID AddEntry(VOID) + { /* the user wants to add an entry */ + ENTRY ent; + + CleanEntry(&ent); /* prepare a "clean" initial starting point */ + if (EditEntry(&ent)) /* allow the user to edit it */ + return; + AppendEntry(&ent); /* insert the entry */ + } + +LOCAL_C VOID InfoMsg(INT rid) + { /* present info message with text with given resource id */ + wInfoMsg(str(rid)); + } + +LOCAL_C VOID UpdateEntry(VOID) + { /* the user wants to update the current entry */ + ENTRY *pent; + ENTRY ent; + + if (!nent) + { /* no current entry to update */ + InfoMsg(STR_NO_ENTRY_UPDATE); + return; + } + pent=(&table[cent]); /* find the current entry */ + if (EditEntry(pent)) /* allow the user to edit it */ + return; + ent=(*pent); + pent->pb=0; + DoDeleteEntry(); /* delete the existing entry... */ + AppendEntry(&ent); /* ... and re-insert it with the new contents */ + } + +LOCAL_C VOID DeleteEntry(VOID) + { /* the user wants to delete the current entry */ + TEXT ny[4]; /* for the characters 'n' then 'y' */ + TEXT yes[10]; /* for the string "yes" */ + TEXT no[10]; /* for the string "no" */ + + if (!nent) + { /* no entry to delete */ + InfoMsg(STR_NO_ENTRY_DELETE); + return; + } + if (uOpenDialog(str(STR_DELETE_REMINDER))) /* title of dialog */ + return; + LoadStr(STR_NY,&ny[0]); /* find the text for the existing language */ + LoadStr(STR_NO,&no[0]); + LoadStr(STR_YES,&yes[0]); + if (uAddButtonList(&no[0],-ny[0],&yes[0],ny[1],NULL)) /* no-yes buttons */ + return; + if (uRunDialog()!=ny[1]) /* check if user pressed 'y' button */ + return; + DoDeleteEntry(); /* delete the entry */ + if (cent==nent && nent) /* change the cursor position */ + cent=nent-1; + EnsureGoodTent(); /* check whether need to scroll display */ + Display(); /* redraw main display area */ + RequeueAlarm(); /* recalculate which alarm to queue */ + } + +LOCAL_C INT TakeCopy(ENTRY *targ,ENTRY *src) + { /* copy specified entry */ + targ->pb=p_alloc(src->tlen); /* prepare an alloc cell for the text */ + if (!targ->pb) + { + uErrorValue(E_GEN_NOMEMORY); + return(-1); + } + p_bcpy(targ->pb,src->pb,src->tlen); /* copy the text */ + p_bcpy(targ,src,sizeof(ENTRY)-sizeof(TEXT *)); /* copy everything else */ + return(0); + } + +LOCAL_C VOID CopyEntry(VOID) + { /* the user wants to copy the current entry */ + ENTRY new; + + if (!nent) + { /* no current entry to copy */ + InfoMsg(STR_NO_ENTRY_COPY); + return; + } + if (TakeCopy(&new,&table[cent])) + return; /* no memory to make copy */ + p_free(clipent.pb); /* free any existing clipboard text */ + clipent=new; + InfoMsg(STR_REMINDER_COPIED); /* signal success to user */ + } + +LOCAL_C VOID InsertEntry(VOID) + { /* the user wants to insert the clipboard contents */ + ENTRY new; + + if (!clipent.pb) + { /* the clipboard contents are empty */ + InfoMsg(STR_NO_ENTRY_INSERT); + return; + } + if (TakeCopy(&new,&clipent)) + return; /* no memory for new entry */ + AppendEntry(&new); /* insert the entry */ + } + +LOCAL_C VOID ExitIfConfirmed(VOID) + { /* the user wants to exit - request confirmation */ + H_DI_TEXT txt; + TEXT cancel[10]; /* for the text "cancel" */ + TEXT exit[10]; /* for the text "exit" */ + + if (nent) + { /* only need confirmation if there are entries */ + if (uOpenDialog(str(STR_WARNING))) /* dialog title */ + return; + txt.str=str(LSTR_DELETE_ALL); /* lbc text from resource file */ + txt.type=H_DTEXT_ALIGN_CENTRE; /* centre alignment */ + if (uAddDialogItem(H_DIALOG_TEXT,0,&txt)) + return; + LoadStr(STR_CANCEL,&cancel[0]); /* load correct language text */ + LoadStr(STR_EXIT,&exit[0]); + if (uAddButtonList(&cancel[0],W_KEY_ESCAPE, + &exit[0],W_KEY_RETURN,NULL)) + return; + if (uRunDialog()!=W_KEY_RETURN) + return; /* the user failed to confirm */ + } + p_exit(0); /* exit cleanly */ + } + +LOCAL_C INT PrintLine(H_PRINT *pr) + { /* print next line of data */ + ENTRY *pent; + + pent=(&table[PrintRec]); /* which entry to print */ + switch (PrintState++) + { + case 0: /* need to print the date and time */ + pr->blen=SdateToBuf(&PrintBuf[0],&pent->sdate); + pr->buf=(&PrintBuf[0]); + pr->style|=H_PRINT_STY_BOLD; /* print date and time in bold */ + break; + case 1: /* need to print the text */ + pr->buf=pent->pb; + pr->blen=pent->tlen; + break; + case 2: /* gap between entries */ + pr->blen=0; + PrintState=0; + PrintRec++; + return(PrintRec!=nent); /* return FALSE if no more to print */ + } + pr->flags|=H_PRINT_KEEP;/* keep different parts of entry on same page */ + return(TRUE); /* return TRUE since printing not yet finished */ + } + +LOCAL_C VOID PrintAll(VOID) + { /* the user wants to print the reminders */ + if (!nent) + { /* no entries to print */ + InfoMsg(STR_NOTHING_PRINT); + return; + } + PrintRec=0; /* initialise print state variables */ + PrintState=0; + hPrint(PrintLine); /* specify call-back function */ + } + +LOCAL_C VOID ManageCommand(INT index) + { /* switch on command index to appropriate function */ + switch (index) + { + case ITEMS_BEFORE_EDIT: + InsertEntry(); + break; + case ITEMS_BEFORE_EDIT+1: + CopyEntry(); + break; + case ITEMS_BEFORE_EDIT+2: + UpdateEntry(); + break; + case ITEMS_BEFORE_EDIT+3: + AddEntry(); + break; + case ITEMS_BEFORE_EDIT+4: + DeleteEntry(); + break; + case ITEMS_BEFORE_SPECIAL: + PrintAll(); + break; + case ITEMS_BEFORE_SPECIAL+1: + hPrintSetupDialog(); + break; + case ITEMS_BEFORE_SPECIAL+2: + ExitIfConfirmed(); + break; + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { /* try to find command to execute matching accelerator passed */ + keycode=uLocateCommand(keycode); /* look up accelerator table */ + if (keycode>=0) /* found - keycode converted to index */ + ManageCommand(keycode); + } + +LOCAL_C VOID DoScroll(INT dely) + { /* scroll the display vertically by given amount */ + P_POINT offset; /* offset to scroll */ + P_RECT src; /* source region for scroll */ + + offset.x=0; + offset.y=dely*18; /* each entry is two lines each 9 pixels high */ + src.tl.x=4; + src.br.x=ScreenWidth-4; + if (dely>0) + { /* scrolling down - so exclude bottom from source */ + src.tl.y=4; + src.br.y=4+(4-dely)*18; + } + else + { /* scrolling up - so exclude top from source */ + src.tl.y=4-dely*18; + src.br.y=4+4*18; + } + wScrollRect(MainWid,&src,&offset); + } + +LOCAL_C VOID MakeHighlight(INT newcent) + { /* change the cursor position as specified, with smooth scrolling */ + INT toscroll; /* amount of scroll needed (if any) */ + + if (!nent) + return; /* no entries - hence nothing to do */ + if (newcent==cent) + return; /* cursor already at specified position */ + EraseCursor(cent-tent); /* remove existing cursor */ + toscroll=tent-newcent; + if (toscroll>0) + { /* new cursor position off top of screen */ + tent-=toscroll; /* adjust record of entry at top of screen */ + if (toscroll<4) + DoScroll(toscroll); /* only actually scroll if less than 4 */ + else + toscroll=4; /* toscroll now holds number of lines to redraw */ + while (toscroll) + DrawLine(--toscroll); /* redraw lines not scrolled */ + } + else + { + toscroll=-3-toscroll; + if (toscroll>0) + { /* new cursor position off bottom of screen */ + tent+=toscroll; /* adjust record of entry at top of screen */ + if (toscroll<4) + DoScroll(-toscroll); + else + toscroll=4; + while (toscroll) + DrawLine(4-toscroll--); /* redraw lines not scrolled */ + } + } + cent=newcent; + DrawCursor(cent-tent); /* draw the cursor back in */ + } + +LOCAL_C VOID ScrollPageBy(INT delta) + { /* implementation of PgUp / PgDn */ + if (!nent) + return; /* no entries to display */ + if (delta<(-3)) + delta=(-3); /* scroll at most three records */ + else if (delta>3) + delta=3; + tent+=delta; + cent+=delta; + Display(); + } + +LOCAL_C VOID HandleAlarmEvent(VOID) + { /* an alarm has expired (or time has been put back) */ + ENTRY *pent; /* the alarm that was queued */ + INT expired; /* whether alarm really did expire */ + + pent=LocateRef(); + expired=(pent->sdate<=p_date()); /* find if alarm time has elapsed */ + almactive=FALSE; + pent->ref=FALSE; + RequeueAlarm(); /* find which is next alarm to queue */ + if (expired) + { + uForceToFront(); /* come into foreground */ + MakeHighlight(pent-(&table[0])); /* highlight the elapsed alarm */ + UpdateEntry(); /* allow user to edit the reminder */ + } + } + +LOCAL_C VOID CheckBorderArrows(VOID) + { /* see if border needs redisplaying (on account of "scroll arrows") */ + INT bflags; /* the flags that ought to be displayed */ + + if (!nent) + return; /* no entries */ + if (tent) /* check if more entries off screen top */ + bflags=W_BORD_CORNER_4|W_BORD_TOP_ON; + else + bflags=W_BORD_CORNER_4|W_BORD_TOP_OFF; + if (tent+40) + TryExecuteCommand(ret); + } + break; + case W_KEY_DELETE_LEFT: + DeleteEntry(); /* user wants to delete entry */ + break; + case W_KEY_RETURN: + if (!nent || key.modifiers&W_SHIFT_MODIFIER) + AddEntry(); /* user wants to add entry */ + else + UpdateEntry(); /* user wants to update entry */ + break; + case W_KEY_UP: + if (cent) + MakeHighlight(cent-1); + break; + case W_KEY_DOWN: + if (cent=nent) + MakeHighlight(nent-1); + else + ScrollPageBy(nent-tent-4); + break; + } + } + } + } + +LOCAL_C VOID CreateGC(VOID) + { /* attempt to create default graphics context on main window */ + INT hgc; /* graphics context handle (if successful) */ + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID *InitRcb(VOID) + { /* create and initialise resource file object */ + INT ret; + VOID *rcb; /* resource file object handle */ + + rcb=p_new(1,C_RSCFILE); + ret=p_entersend3(rcb,O_RS_INIT,DatCommandPtr); /* pass file name */ + if (ret<0) /* no resource file found */ + p_exit(ret); /* fatal (programmer) error */ + return(rcb); + } + +LOCAL_C H_MENU_DATA *LoadMenuTitles(VOID *rcb,INT rid) + { /* load menu titles from specified resource file */ + H_MENU_DATA *pmdata,*pi; /* for created alloc cell */ + TEXT *titles; /* for loaded alloc cell */ + WORD count; /* how many menus */ + INT ret; + + ret=p_entersend4(rcb,O_RS_READ,rid,&titles); + if (ret<0) + return(NULL); /* couldn't access resource file */ + count=(*(WORD *)titles); /* first WORD gives count of menus */ + pmdata=p_alloc((count+1)*sizeof(H_MENU_DATA)); + if (!pmdata) + { /* no memory to alloc H_MENU_DATA array */ + p_free(titles); /* clean up partially constructed data */ + return(NULL); + } + pi=pmdata; /* prepare to walk through H_MENU_DATA array */ + titles+=2; /* skip over leading WORD count */ + while (count--) /* for each menu */ + { + pi->title=titles; /* store pointer to title text */ + titles+=p_slen(titles)+1; /* skip the text and terminating zero */ + pi->nlines=(*titles++); /* store the number of lines */ + pi++; /* increment to next H_MENU_DATA element */ + } + pi->title=0; /* place NULL at end of array */ + return(pmdata); /* return pointer to created struct */ + } + +LOCAL_C TEXT **LoadMenuCommands(VOID *rcb,INT rid) + { /* load menu commands from specified resource file */ + TEXT **pcmds,**pi; /* for created alloc cell */ + TEXT *cmds; /* for loaded alloc cell */ + WORD count; /* how many commands */ + INT ret; + + ret=p_entersend4(rcb,O_RS_READ,rid,&cmds); + if (ret<0) + return(NULL); /* couldn't access resource file */ + count=(*(WORD *)cmds); /* first WORD gives count of commands */ + pcmds=p_alloc((count+1)*sizeof(TEXT *)); + if (!pcmds) + { /* no memory to allow TEXT * array */ + p_free(cmds); /* clean up partially constructed data */ + return(NULL); + } + pi=pcmds; /* prepare to walk through TEXT * array */ + cmds+=2; /* skip over leading WORD count */ + while (count--) /* for each menu command */ + { + *pi++=cmds; /* store pointer to command details */ + cmds+=p_slen(cmds)+1; /* skip the text and terminating zero */ + } + *pi=0; /* place NULL at end of array */ + return(pcmds); /* return pointer to created struct */ + } + +LOCAL_C VOID LoadMenus(VOID) + { /* load all menu data */ + rcb=InitRcb(); /* create and initialise resource file object */ + _cmds=LoadMenuCommands(rcb,REMIND_CMDS); /* load commands */ + _mdata=LoadMenuTitles(rcb,REMIND_MENUS); /* load menu titles */ + if (!_cmds || !_mdata) /* test if either load failed */ + p_exit(E_GEN_START); /* report fatal initialisation error */ + } + +LOCAL_C VOID SpecificInit(VOID) + { /* application initialisation specific to Remind */ + uEscape(FALSE); /* disable Psion-Esc */ + LoadMenus(); /* load all menu data */ + MainWid=uFindMainWid(); /* find id of main display window */ + CreateGC(); /* create default graphics context */ + p_open(&aH,"ALM:",-1); /* open channel to ALM: device */ + ttH=hTTOpen(); /* open channel to time-text object */ + hTTSetAbbreviations(ttH,3,3); /* set abbreviations to use */ + UpdateTimeFormat(); /* check current system time format */ + hCrackCommandLine(); /* crack incoming command line */ + if (ToggleStatusWindow()) /* attempt to display status window */ + p_exit(0); + } + +GLDEF_C VOID main(VOID) + { /* the main() for all Hwif programs */ + uCommonInit(); /* initialisation common to all Hwif programs */ + SpecificInit(); /* initialisation specific to Remind */ + MainLoop(); /* the central event processing loop */ + } diff --git a/code/SIBOSDK/hwdemo/remind.ms b/code/SIBOSDK/hwdemo/remind.ms new file mode 100644 index 0000000..eedb219 --- /dev/null +++ b/code/SIBOSDK/hwdemo/remind.ms @@ -0,0 +1,3 @@ +Remind + +4000 diff --git a/code/SIBOSDK/hwdemo/remind.pic b/code/SIBOSDK/hwdemo/remind.pic new file mode 100644 index 0000000..25dea78 Binary files /dev/null and b/code/SIBOSDK/hwdemo/remind.pic differ diff --git a/code/SIBOSDK/hwdemo/remind.pr b/code/SIBOSDK/hwdemo/remind.pr new file mode 100644 index 0000000..9be274e --- /dev/null +++ b/code/SIBOSDK/hwdemo/remind.pr @@ -0,0 +1,8 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#run "rs remind" no_window no_abort +#compile remind.c +#pragma link(hwif.lib) +#link remind diff --git a/code/SIBOSDK/hwdemo/remind.rh b/code/SIBOSDK/hwdemo/remind.rh new file mode 100644 index 0000000..c530b8d --- /dev/null +++ b/code/SIBOSDK/hwdemo/remind.rh @@ -0,0 +1,9 @@ +/* +Constants shared between remind.rss and remind.c +*/ + +#define EDIT_ITEMS 5 +#define SPECIAL_ITEMS 3 + +#define ITEMS_BEFORE_EDIT 0 +#define ITEMS_BEFORE_SPECIAL EDIT_ITEMS diff --git a/code/SIBOSDK/hwdemo/remind.rss b/code/SIBOSDK/hwdemo/remind.rss new file mode 100644 index 0000000..9152e29 --- /dev/null +++ b/code/SIBOSDK/hwdemo/remind.rss @@ -0,0 +1,66 @@ +#include "remind.rh" + +STRUCT STRING + { + TEXT str; + } + +STRUCT LSTRING + { + LTEXT lstr; + } + +STRUCT MENU_TITLE + { + TEXT str; + BYTE ncommands; + } + +STRUCT STRING_ARRAY + { + STRUCT strlst[]; + } + +RESOURCE STRING_ARRAY remind_cmds + { + strlst= + { + STRING {str="iInsert";}, + STRING {str="cCopy";}, + STRING {str="uUpdate";}, + STRING {str="aAdd";}, + STRING {str="dDelete";}, + STRING {str="pPrint";}, + STRING {str="yPrint setup";}, + STRING {str="xExit";} + }; + } + +RESOURCE STRING_ARRAY remind_menus + { + strlst= + { + MENU_TITLE {str="Edit"; ncommands=EDIT_ITEMS;}, + MENU_TITLE {str="Special"; ncommands=SPECIAL_ITEMS;} + }; + } + +RESOURCE STRING str_no_reminders_set {str="No reminders set";} +RESOURCE STRING str_reminder {str="Reminder";} +RESOURCE STRING str_message {str="Message";} +RESOURCE STRING str_time {str="Time";} +RESOURCE STRING str_date {str="Date";} +RESOURCE STRING str_no_entry_update {str="No entry to update";} +RESOURCE STRING str_no_entry_delete {str="No entry to delete";} +RESOURCE STRING str_no_entry_copy {str="No entry to copy";} +RESOURCE STRING str_no_entry_insert {str="No entry to insert";} +RESOURCE STRING str_reminder_copied {str="Reminder copied";} +RESOURCE STRING str_nothing_print {str="Nothing to print";} +RESOURCE STRING str_delete_reminder {str="Delete this reminder";} +RESOURCE STRING str_warning {str="Warning";} +RESOURCE LSTRING lstr_delete_all {lstr="Exiting will delete all reminders";} +RESOURCE STRING str_ny {str="ny";} +RESOURCE STRING str_no {str="No";} +RESOURCE STRING str_yes {str="Yes";} +RESOURCE STRING str_cancel {str="Cancel";} +RESOURCE STRING str_exit {str="Exit";} diff --git a/code/SIBOSDK/hwdemo/remind.shd b/code/SIBOSDK/hwdemo/remind.shd new file mode 100644 index 0000000..1751b95 Binary files /dev/null and b/code/SIBOSDK/hwdemo/remind.shd differ diff --git a/code/SIBOSDK/hwdemo/rs.bat b/code/SIBOSDK/hwdemo/rs.bat new file mode 100644 index 0000000..393704e --- /dev/null +++ b/code/SIBOSDK/hwdemo/rs.bat @@ -0,0 +1,2 @@ +@echo off +rcomp.exe -S%1 -O%1 -I\sibosdk\include\ -G\sibosdk\include\%1 diff --git a/code/SIBOSDK/hwdemo/spy.afl b/code/SIBOSDK/hwdemo/spy.afl new file mode 100644 index 0000000..e48715c --- /dev/null +++ b/code/SIBOSDK/hwdemo/spy.afl @@ -0,0 +1,3 @@ +spy.pic +spy.rsc +spy.shd diff --git a/code/SIBOSDK/hwdemo/spy.c b/code/SIBOSDK/hwdemo/spy.c new file mode 100644 index 0000000..c234f01 --- /dev/null +++ b/code/SIBOSDK/hwdemo/spy.c @@ -0,0 +1,1043 @@ +/* + SPY.C + +Written by DavidW +Started on 12/11/91 + +Derived from earlier work by Poh Siew, GeoffO, Joe, CharlesD, JohnH, & PeterM. +*/ + +#include +#include +#include +#include +#include + +GLREF_C VOID wsReport(HANDLE); +GLREF_C VOID MonitorBandWidth(VOID); +GLREF_C VOID DisableReads(UINT flag); + +GLREF_D UBYTE DatHeapLocked; + +LOCAL_D TEXT *cmds[]= + { + "dChange data", + "hUse decimal", + "pChange processes", + "uUpdate", + "bBand width", + "tTimer off", + "rRefresh rate", + "nLog client", + "mLog all clients", + "cCompress heaps", + "wRewalk failed process", + "gGoto process", + "lReset least stack", + "kKill process", + "xExit", + NULL + }; + +#define DISPLAY_ITEMS 5 +#define TIMER_ITEMS 2 +#define LOG_ITEMS 2 +#define SPECIAL_ITEMS 6 + +#define ITEMS_BEFORE_DISPLAY 0 +#define ITEMS_BEFORE_TIMER DISPLAY_ITEMS +#define ITEMS_BEFORE_LOG (ITEMS_BEFORE_TIMER+TIMER_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_LOG+LOG_ITEMS) + +#define USE_ITEM 1 +#define TIMER_ITEM ITEMS_BEFORE_TIMER + +LOCAL_D H_MENU_DATA mdata[]= + { + "Display",DISPLAY_ITEMS, + "Timer",TIMER_ITEMS, + "Log",LOG_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +#define TEXT_HEIGHT 10 +#define TEXT_ASCENT 8 + +#define LAY_TOP_BORDER 4 +#define Y_TO_FIRST_PROCESS 15 + +#define SCREEN_WIDTH 240 +#define LAY_LEFT_BORDER 4 +#define LAY_RIGHT_BORDER 4 + +#define NAME_COLUMN_INDENT 4 +#define NAME_COLUMN_WIDTH 74 +#define X_TO_FIRST_COLUMN (LAY_LEFT_BORDER+NAME_COLUMN_INDENT+NAME_COLUMN_WIDTH) +#define FIRST_COLUMN_WIDTH 32 +#define SECOND_COLUMN_WIDTH 50 +#define THIRD_COLUMN_WIDTH 72 +#define TRAILING_INDENT 4 +#define X_TO_END (SCREEN_WIDTH-LAY_RIGHT_BORDER) + +LOCAL_D UWORD cwid[3]={FIRST_COLUMN_WIDTH,SECOND_COLUMN_WIDTH,THIRD_COLUMN_WIDTH}; + +typedef struct + { + TEXT name[E_MAX_NAME+2]; + UWORD bytes_allocated; + UWORD bytes_free; + UWORD seg_size; + UWORD last_free; + UWORD least_stack; + UWORD priority; + UWORD stack_pointer; + UWORD pid; + UWORD cells_allocated; + UWORD cells_free; + UWORD iosemcnt; + UWORD status; + } PROCESS_DATA; + +#define PROCESS_SYSTEM 1 +#define PROCESS_APPLICATION 2 +#define PROCESS_ALL 3 + +LOCAL_D UWORD which_processes=PROCESS_ALL; + +LOCAL_D UWORD using_decimal=FALSE; +LOCAL_D UWORD lastbflags=0; + +#define DISPLAY_PROCESS_NAME 0 +#define DISPLAY_BYTES_ALLOCED 1 +#define DISPLAY_BYTES_FREE 2 +#define DISPLAY_SEG_SIZE 3 +#define DISPLAY_LAST_FREE 4 +#define DISPLAY_LEAST_STACK 5 +#define DISPLAY_PRIORITY 6 +#define DISPLAY_STACK_POINTER 7 +#define DISPLAY_PID 8 +#define DISPLAY_CELLS_ALLOCED 9 +#define DISPLAY_CELLS_FREE 10 +#define DISPLAY_IOSEMCNT 11 +#define DISPLAY_STATUS 12 + +LOCAL_D TEXT *titles[13]= + { + "Process name", + "Alloc bytes", + "Bytes free", + "Seg size", + "Last free", + "Lst stack", + "Priority", + "Stack ptr", + "Proc ID", + "Alloc cells", + "Cells free", + "IO count", + "Status" + }; + +LOCAL_D TEXT *statuses[]= + { + "Curr", + "Busy", + "TimQ", + "Susp", + "Wait" + }; + +LOCAL_D UWORD col[4]= + { + DISPLAY_PROCESS_NAME, + DISPLAY_BYTES_ALLOCED, + DISPLAY_CELLS_ALLOCED, + DISPLAY_LEAST_STACK + }; + +LOCAL_D PROCESS_DATA proc[E_MAX_PROCESSES-1]; +LOCAL_D UWORD numproc; +LOCAL_D HANDLE failpid=NULL; + +typedef struct mblock + { + UWORD mlen; + struct mblock *mnext; + } MBLOCK; + +#define SZMBLK sizeof(MBLOCK) +#define SZHD sizeof(UWORD) + +#define ERR_FREECELL_BEYOND_MEMHIGH 1 +#define ERR_FREECELL_GOES_BACKWARDS 2 +#define ERR_CELL_LENGTH_TOO_SMALL 3 +#define ERR_CELL_LENGTH_ODD 4 +#define ERR_ALLOCED_CELLS_OVERRUN_FREE 5 +#define ERR_TOTALS_DONT_MATCH 6 + +LOCAL_D TEXT *heap_errors[]= + { + "Free cell beyond memhigh", + "Free cell goes backwards", + "Cell length too small", + "Cell length odd", + "Alloced cells don't end at next free cell", + "Total free + total alloced != segment size" + }; + +#define STACK_READ_SIZE 256 + +LOCAL_D UWORD selproc=0; +LOCAL_D UWORD topproc=0; + +LOCAL_D LONG timint=50; +LOCAL_D VOID *timcb; +LOCAL_D WORD timstat; +LOCAL_D UWORD using_timer=TRUE; + + +LOCAL_C VOID QueueTimer(VOID) + { + if (using_timer) + p_ioa4(timcb,P_FRELATIVE,&timstat,&timint); + } + +LOCAL_C VOID CancelTimer(VOID) + { + if (using_timer) + { + p_iow2(timcb,P_FCANCEL); + p_waitstat(&timstat); + } + } + +LOCAL_C INT GetWidth(TEXT *pb) + { + return(gTextWidth(WS_FONT_BASE,G_STY_NORMAL,pb,p_slen(pb))); + } + +LOCAL_C VOID DrawTitles(VOID) + { + INT i; + INT totwid; + INT width[4]; + INT gap; + TEXT *buf; + P_RECT box; + + totwid=0; + for (i=0; i<=3; i++) + totwid+=(width[i]=GetWidth(titles[col[i]])); + gap=(X_TO_END-LAY_LEFT_BORDER-totwid)/3; + box.tl.x=LAY_LEFT_BORDER; + box.tl.y=LAY_TOP_BORDER; + box.br.y=LAY_TOP_BORDER+TEXT_HEIGHT; + for (i=0; i<=3; i++) + { + if (i==3) + box.br.x=X_TO_END; + else + box.br.x=box.tl.x+width[i]+gap; + buf=(titles[col[i]]); + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_LEFT,0,buf,p_slen(buf)); + box.tl.x=box.br.x; + } + } + +LOCAL_C VOID InvertLine(INT j) + { + P_EXTENT ext; + + ext.tl.x=LAY_LEFT_BORDER; + ext.tl.y=Y_TO_FIRST_PROCESS+(j-topproc)*TEXT_HEIGHT; + ext.width=X_TO_END-LAY_LEFT_BORDER; + ext.height=TEXT_HEIGHT; + gInvObloid(&ext); + } + +LOCAL_C VOID DrawLine(INT j) + { + P_RECT box; + INT len; + UWORD *base; + TEXT *fmt; + TEXT *buf; + INT margin; + TEXT out[20]; + INT i; + INT val; + + box.tl.x=LAY_LEFT_BORDER; + box.tl.y=Y_TO_FIRST_PROCESS+j*TEXT_HEIGHT; + box.br.y=box.tl.y+TEXT_HEIGHT; + j+=topproc; + if (j>=numproc) + { + box.br.x=X_TO_END; + gClrRect(&box,G_TRMODE_CLR); + return; + } + box.br.x=X_TO_FIRST_COLUMN; + buf=(&proc[j].name[0]); + len=p_slen(buf); + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_LEFT, + NAME_COLUMN_INDENT,buf,len); + base=(&proc[j].bytes_allocated)-1; + for (i=0; i<3; ) + { + box.tl.x=box.br.x; + box.br.x=box.tl.x+cwid[i]; + val=(*(base+col[++i])); + if (col[i]==DISPLAY_STATUS) + buf=statuses[val]; + else + { + if (col[i]==DISPLAY_IOSEMCNT) + fmt="%d"; + else if (using_decimal || col[i]>=DISPLAY_CELLS_ALLOCED) + fmt="%u"; + else + fmt="%x"; + p_atos(buf=(&out[0]),fmt,val); + } + margin=(i==3? TRAILING_INDENT: 0); + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_RIGHT, + margin,buf,p_slen(buf)); + } + if (j==selproc) + InvertLine(j); + } + +LOCAL_C VOID DrawList(VOID) + { + INT j; + + for (j=0; j<6; j++) + DrawLine(j); + } + +LOCAL_C VOID SetPriority(INT prio) + { + p_setpri(p_getpid(),prio); + } + +LOCAL_C VOID PriorityHigh(VOID) + { + SetPriority(E_MAX_PRIORITY); + } + +LOCAL_C VOID PriorityLow(VOID) + { + SetPriority(E_PRIORITY_BACK+1); + } + +LOCAL_C INT SystemProcessName(TEXT *pname) + { + return(!p_bcmp(pname,4,"SYS$",4)); + } + +LOCAL_C VOID GetMblock(HANDLE pid,MBLOCK *ofs,MBLOCK *buf) + { + p_pcpyfr(pid,ofs,buf,SZMBLK); + } + +LOCAL_C INT WalkHeap(HANDLE pid,UWORD *poffset,PROCESS_DATA *pdata, + MBLOCK *MemBasePtr) + { + MBLOCK *p1,*p2,*memhigh; + MBLOCK m1,m2; + + memhigh=(MBLOCK *)pdata->seg_size; + p2=MemBasePtr; + p1=p2+1; /* first allocated cell starts at an mblock after memBasePtr */ + FOREVER + { /* walk every cell from memlow to memhigh */ + GetMblock(pid,p2,&m2); + *poffset=(UWORD)p2; + p2=m2.mnext; /* next free cell */ + if (!p2) + p2=memhigh; /* last free cell */ + else + { + GetMblock(pid,p2,&m2); + if (p2>(memhigh-1)) + return(ERR_FREECELL_BEYOND_MEMHIGH); + else if (m2.mnext && m2.mnextcells_allocated++; + pdata->bytes_allocated+=m1.mlen; + if (m1.mlen>((UBYTE *)p2-(UBYTE *)p1)) + return(ERR_ALLOCED_CELLS_OVERRUN_FREE); + p1=(MBLOCK *)(((UBYTE *)p1)+m1.mlen); + } + if (p2==memhigh) + { + *poffset=0; + break; + } + p1=(MBLOCK *)(((UBYTE *)p2)+m2.mlen); /* next allocated cell */ + pdata->cells_free++; + pdata->bytes_free+=m2.mlen; + pdata->last_free=m2.mlen; + } + if (pdata->seg_size!=(UINT)(MemBasePtr)+SZMBLK + +pdata->bytes_allocated+pdata->bytes_free) + return(ERR_TOTALS_DONT_MATCH); + return(0); /* all OK */ + } + +LOCAL_C VOID NotifyError(INT ret,UWORD offset,TEXT *pname) + { + TEXT buf[40]; + + p_atos(&buf[0],"%s: heap corrupt at %u",pname,offset); + p_notify(&buf[0],heap_errors[ret-1],0,0,0); + } + +LOCAL_C VOID CollectProcessData(HANDLE pid,TEXT *pname) + { + PROCESS_DATA *pdata; + E_PROC epc; + UBYTE sbuf[STACK_READ_SIZE+2]; + UBYTE *p; + UBYTE *pEnd; + UWORD segoffset; + WORD locked; + UWORD offset; + INT ret; + UWORD sem[3]; + + pdata=(&proc[numproc++]); + p_bfil(pdata,sizeof(PROCESS_DATA),0); + p_scpy(&pdata->name[0],pname); + pdata->pid=pid; + p_getosd(&epc,(VOID *)(E_PIDMASK&pid),sizeof(E_PROC)); + pdata->seg_size=p_sgsize(epc.dataSeg)<<4; + pdata->stack_pointer=(UWORD)epc.saveSP; + pdata->status=epc.status-E_PROC_CURRENT; + pdata->priority=p_getpri(pid); + p_getosd(&sem[0],(VOID *)epc.semaphore,6); + pdata->iosemcnt=sem[2]; + segoffset=0x80; + pEnd=(&sbuf[STACK_READ_SIZE]); + *pEnd=0; + do + { + p_pcpyfr(pid,(VOID *)segoffset,&sbuf[0],STACK_READ_SIZE); + p=(&sbuf[0]); + while (*p==255) + p++; + segoffset+=STACK_READ_SIZE; + } while (p==pEnd); + pdata->least_stack=segoffset-STACK_READ_SIZE+p-(&sbuf[0]); + if (epc.memBasePtr && !epc.isTask && pid!=failpid) + { + locked=0; + p_pcpyfr(pid,&DatHeapLocked,&locked,1); + if (!locked) + { + ret=WalkHeap(pid,&offset,pdata,(MBLOCK *)epc.memBasePtr); + if (ret) + { + NotifyError(ret,offset,pname); + failpid=pid; + } + } + } + } + +LOCAL_C VOID BuildList(VOID) + { + HANDLE prchand; + TEXT name[E_MAX_NAME+2]; + HANDLE pid; + INT first; + + numproc=0; + first=TRUE; + prchand=NULL; + PriorityHigh(); + while ((prchand=p_pfind(prchand,"*",&name[0]))!=E_FILE_NXIST) + { + if (first) + { + first=FALSE; + continue; + } + if (which_processes!=PROCESS_ALL) + { + if (SystemProcessName(&name[0])) + { + if (which_processes==PROCESS_APPLICATION) + continue; + } + else if (which_processes==PROCESS_SYSTEM) + continue; + } + if ((pid=p_pidfind(&name[0]))<0) + continue; + CollectProcessData(pid,&name[0]); + } + PriorityLow(); + if (topproc>numproc-6) + topproc=numproc-6; + if (selproc>numproc-1) + selproc=numproc-1; + } + +LOCAL_C VOID UpdateList(VOID) + { + BuildList(); + DrawList(); + } + +LOCAL_C VOID ResetList(VOID) + { + CancelTimer(); + UpdateList(); + QueueTimer(); + } + +LOCAL_C VOID ChangeColumnsViewed(VOID) + { + UWORD copy[3]; + INT j; + TEXT prompt[10]; + TEXT *pb; + + p_bcpy(©[0],&col[1],6); + pb=(&prompt[7]); /* points to '1' of "Column 1" */ + FOREVER + { + p_scpy(&prompt[0],"Column 1"); + if (uOpenDialog("Change display for each column")) + return; + for (j=0; j<3; j++) + { + if (uAddChoiceList(&prompt[0],©[j],"Bytes allocated", + "Bytes free","Segment size","Last free cell", + "Least stack","Process priority","Stack pointer", + "Process ID","Cells allocated","Cells free", + "IO semaphore count","Process status",NULL)) + return; + (*pb)++; + } + if (uRunDialog()<=0) + return; + if (copy[0]!=copy[1] && copy[0]!=copy[2] && copy[1]!=copy[2]) + break; + wInfoMsg("Duplicate columns"); + } + p_bcpy(&col[1],©[0],6); + DrawTitles(); + ResetList(); + } + +LOCAL_C VOID ChangeRefreshRate(VOID) + { + H_DI_NUMBER num; + + if (uOpenDialog("Refresh rate")) + return; + num.value=(&timint); + num.low=5; + num.high=1000; + if (uAddDialogItem(H_DIALOG_NUMBER,"Tenths of seconds",&num)) + return; + if (uRunDialog()<=0) + return; + CancelTimer(); + QueueTimer(); + } + +LOCAL_C VOID ChangeProcessesViewed(VOID) + { + if (uOpenDialog(NULL)) + return; + if (uAddChoiceList("View which processes",&which_processes, + "System","Application","All",NULL)) + return; + if (uRunDialog()<=0) + return; + ResetList(); + } + +LOCAL_C VOID ToggleBaseUsed(VOID) + { + if (using_decimal^=TRUE) + { + wInfoMsg("Display now using decimal"); + cmds[USE_ITEM]="hUse hex"; + } + else + { + wInfoMsg("Display now using hexadecimal"); + cmds[USE_ITEM]="hUse decimal"; + } + ResetList(); + } + +LOCAL_C VOID ToggleTimer(VOID) + { + CancelTimer(); + if (using_timer^=TRUE) + { + wInfoMsg("Timer re-enabled"); + cmds[TIMER_ITEM]="tTimer off"; + } + else + { + wInfoMsg("Timer suspended"); + cmds[TIMER_ITEM]="tTimer on"; + } + QueueTimer(); + } + +LOCAL_C VOID CompressAllHeaps(VOID) + { + p_sgcreate("t$t$",0x7FFF,E_SEGMENT_HIGH); + wInfoMsg("All heaps compressed"); + ResetList(); + } + +LOCAL_C VOID WalkAllHeapsAgain(VOID) + { + if (!failpid) + wInfoMsg("No failed process"); + else + { + failpid=NULL; + wInfoMsg("Now rewalking ALL processes"); + ResetList(); + } + } + +LOCAL_C TEXT *CurrentTaskName(VOID) + { + return(&proc[selproc].name[0]); + } + +LOCAL_C VOID NamedInfoMsg(TEXT *fmt) + { + TEXT buf[40]; + + p_atos(&buf[0],fmt,CurrentTaskName()); + wInfoMsg(&buf[0]); + } + +LOCAL_C VOID GotoCurrentProcess(VOID) + { + HANDLE pid; + + pid=proc[selproc].pid; + if ((INT)wClientInfo(pid)>=0) + wClientPosition(0,pid); + else + NamedInfoMsg("Cannot go to %s"); + } + +LOCAL_C INT TryResetLeastStack(VOID) + { + HANDLE pid; + E_PROC epc; + UBYTE *offset; + TEXT buf[STACK_READ_SIZE]; + + PriorityHigh(); + if (proc[selproc].priority>=E_MAX_PRIORITY) + { + PriorityLow(); + NamedInfoMsg("Cannot reset stack of %s"); + return; + } + p_bfil(&buf[0],STACK_READ_SIZE,0xFF); + pid=proc[selproc].pid; + p_getosd(&epc,(VOID *)(E_PIDMASK&pid),sizeof(E_PROC)); + offset=(UBYTE *)0x80; + while (offset+STACK_READ_SIZE=0) + ManageCommand(keycode); + } + +LOCAL_C VOID DoScroll(INT dely) + { + P_POINT offset; + P_RECT src; + + offset.x=0; + offset.y=dely*TEXT_HEIGHT; + src.tl.x=LAY_LEFT_BORDER; + src.br.x=X_TO_END; + if (dely>0) + { + src.tl.y=Y_TO_FIRST_PROCESS; + src.br.y=Y_TO_FIRST_PROCESS+(6-dely)*TEXT_HEIGHT; + } + else + { + src.tl.y=Y_TO_FIRST_PROCESS-dely*TEXT_HEIGHT; + src.br.y=Y_TO_FIRST_PROCESS+6*TEXT_HEIGHT; + } + wScrollRect(MainWid,&src,&offset); + } + +LOCAL_C VOID MakeHighlight(INT newselproc) + { + INT toscroll; + + if (newselproc==selproc) + return; + InvertLine(selproc); + toscroll=topproc-newselproc; + if (toscroll>0) + { + topproc-=toscroll; + if (toscroll<6) + DoScroll(toscroll); + else + toscroll=6; + while (toscroll) + DrawLine(--toscroll); + } + else + { + toscroll=-5-toscroll; + if (toscroll>0) + { + topproc+=toscroll; + if (toscroll<6) + DoScroll(-toscroll); + else + toscroll=6; + while (toscroll) + DrawLine(6-toscroll--); + } + } + selproc=newselproc; + InvertLine(selproc); + } + +LOCAL_C VOID ScrollPageBy(INT delta) + { + if (delta<(-5)) + delta=(-5); + else if (delta>5) + delta=5; + topproc+=delta; + selproc+=delta; + DrawList(); + } + +LOCAL_C VOID TryMatchFirstLetter(INT upper) + { + INT k; + INT i; + + k=numproc; + i=selproc; + while (k--) + { + if (++i==numproc) + i=0; + if (proc[i].name[0]==upper) + { + MakeHighlight(i); + return; + } + } + p_sound(-5,320); + } + +LOCAL_C VOID CheckBorderArrows(VOID) + { + INT bflags; + + if (topproc) + bflags=W_BORD_CORNER_4|W_BORD_TOP_ON; + else + bflags=W_BORD_CORNER_4|W_BORD_TOP_OFF; + if (topproc+60) + TryExecuteCommand(ret); + } + break; + case W_KEY_UP: + if (selproc) + MakeHighlight(selproc-1); + break; + case W_KEY_DOWN: + if (selproc=numproc) + MakeHighlight(numproc-1); + else + ScrollPageBy(numproc-topproc-6); + break; + default: + if (p_isprint(key.keycode)) + TryMatchFirstLetter(p_toupper(key.keycode)); + } + } + } + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + MainWid=uFindMainWid(); + CreateGC(); + hCrackCommandLine(); + p_unmarka(); + DrawTitles(); + UpdateList(); + p_open(&timcb,"TIM:",-1); + QueueTimer(); + if (wCaptureKey('n'|W_SPECIAL_KEY,W_CTRL_MODIFIER|W_PSION_MODIFIER, + W_CTRL_MODIFIER|W_PSION_MODIFIER)<0) + wInfoMsg("'n' key capture failed"); + if (wCaptureKey('p'|W_SPECIAL_KEY,W_CTRL_MODIFIER|W_PSION_MODIFIER, + W_CTRL_MODIFIER|W_PSION_MODIFIER)<0) + wInfoMsg("'p' key capture failed"); + if (wCaptureKey('s'|W_SPECIAL_KEY,W_CTRL_MODIFIER|W_PSION_MODIFIER, + W_CTRL_MODIFIER|W_PSION_MODIFIER)<0) + wInfoMsg("'s' key capture failed"); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/spy.ms b/code/SIBOSDK/hwdemo/spy.ms new file mode 100644 index 0000000..1d6a7e4 --- /dev/null +++ b/code/SIBOSDK/hwdemo/spy.ms @@ -0,0 +1 @@ +Spy diff --git a/code/SIBOSDK/hwdemo/spy.pic b/code/SIBOSDK/hwdemo/spy.pic new file mode 100644 index 0000000..9a4063f Binary files /dev/null and b/code/SIBOSDK/hwdemo/spy.pic differ diff --git a/code/SIBOSDK/hwdemo/spy.pr b/code/SIBOSDK/hwdemo/spy.pr new file mode 100644 index 0000000..479517d --- /dev/null +++ b/code/SIBOSDK/hwdemo/spy.pr @@ -0,0 +1,8 @@ +#system epoc img +#set epocinit=iplib +#model small jpi +#compile spy +#compile spybw +#compile wsreport +#pragma link(hwif.lib) +#link spy diff --git a/code/SIBOSDK/hwdemo/spy.rsc b/code/SIBOSDK/hwdemo/spy.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/spy.shd b/code/SIBOSDK/hwdemo/spy.shd new file mode 100644 index 0000000..762f780 Binary files /dev/null and b/code/SIBOSDK/hwdemo/spy.shd differ diff --git a/code/SIBOSDK/hwdemo/spybw.c b/code/SIBOSDK/hwdemo/spybw.c new file mode 100644 index 0000000..5c7b08f --- /dev/null +++ b/code/SIBOSDK/hwdemo/spybw.c @@ -0,0 +1,293 @@ +/* + SPYBW.C + +Written by SteveT +Started on 20/7/92 + +Part of Spy to monitor CPU band width usage. +*/ + +#include +#include + +#define DLG_WIDTH 190 +#define DLG_HEIGHT 49 +#define DLG_LINE 13 +#define STACK_SIZE 500 + +GLREF_D TEXT *DatCommandPtr; +GLREF_D VOID *winHandle; +GLREF_D TEXT *DatProcessNamePtr; + +LOCAL_D UINT TaskCount; + +LOCAL_D INT Debug=FALSE; +LOCAL_D UINT oldPri; +LOCAL_D INT winId; +LOCAL_D HANDLE bwPid; +LOCAL_D HANDLE spyPid; +LOCAL_D VOID *TimCB; +LOCAL_D ULONG bwTotal; +LOCAL_D UINT bwCount; +LOCAL_D ULONG bwCabTotal; +LOCAL_D UINT bwCabCount; +LOCAL_D UINT bwCabBase; +LOCAL_D ULONG bwCabDisplayTotal; +LOCAL_D UINT bwCabDisplayCount; +LOCAL_D UINT bwCabDisplayBase; +LOCAL_D UWORD LastCount; +LOCAL_D UWORD SampleCount; + +LOCAL_D UBYTE TaskStack[STACK_SIZE]; + +/***********************************************************/ +/* This section of code is used by the task to measure the */ +/* available band width. */ +/***********************************************************/ + +LOCAL_C VOID MonitorLoop(VOID) + { + UINT i; + + p_unmarka(); + FOREVER + { + for(i=0;i<500;i++); + TaskCount++; + } + } + +/*********************/ +/* Main body of code */ +/*********************/ + +LOCAL_C VOID DebugInfo(VOID) + { + TEXT buf[80]; + + p_atos(&buf[0],"%u/%u",LastCount,SampleCount); + wInfoMsg(&buf[0]); + } + +GLDEF_C VOID DisableReads(UINT flag) + { + UINT tmp; + + tmp=P_SCR_DISABLE_READS; + p_iow(winHandle,P_FSET,&tmp,&flag); + } + +LOCAL_C INT CreateDialog(VOID) + { + W_WINDATA windata; + INT w_id; + + windata.extent.width=DLG_WIDTH; + windata.extent.height=DLG_HEIGHT; + windata.extent.tl.x=(240-DLG_WIDTH)>>1; + windata.extent.tl.y=(80-DLG_HEIGHT)>>1; + w_id=wCreateWindow(0,W_WIN_EXTENT,&windata,1); + wInitialiseWindowTree(w_id); + return(w_id); + } + +LOCAL_C VOID pTxt(UINT line,TEXT *txt,ULONG *pTotal,INT count,INT count2) + { + P_RECT rect; + TEXT buf[20]; + ULONG Percentage,lCount; + + rect.tl.x=4; + rect.br.x=96; + rect.tl.y=DLG_LINE+3+line*10; + rect.br.y=rect.tl.y+8; + gPrintBoxText(&rect,7,G_TEXT_ALIGN_LEFT,0,txt,p_slen(txt)); + buf[0]=0; + if (bwCount>0 && count!=0) + { + lCount=(ULONG)(count==-1?1:count); + Percentage=(*pTotal)*100l; + Percentage/=lCount; + Percentage/=(ULONG)SampleCount; + if (count!=0) + { + if (count2>=0) + p_atos(&buf[0],"%U%% [%u-%u]",Percentage,count2,count+count2); + else + p_atos(&buf[0],count>0?"%U%% [%u]":"%U%%",Percentage,count); + } + } + rect.tl.x=rect.br.x; + rect.br.x=DLG_WIDTH-6; + gPrintBoxText(&rect,7,G_TEXT_ALIGN_LEFT,0,&buf[0],p_slen(&buf[0])); + } + +LOCAL_C VOID redrawWin(UINT update) + { + P_RECT rect; + ULONG tmp; + + if (update) + gCreateTempGC0(winId); + else + { + wBeginRedrawWinGC0(winId); + gBorder(W_BORD_CORNER_4|W_BORD_SHADOW_D|W_BORD_SHADOW_ON); + rect.tl.x=4; + rect.br.x=DLG_WIDTH-6; + rect.tl.y=3; + rect.br.y=11; + gPrintBoxText(&rect,7,G_TEXT_ALIGN_CENTRE,0,"Available CPU band width",24); + gDrawLine(1,DLG_LINE,DLG_WIDTH-2,DLG_LINE); + } + pTxt(0,"Average",&bwTotal,bwCount,-1); + tmp=LastCount; + pTxt(1,"Last",&tmp,-1,-1); + pTxt(2,"\002B",&bwCabDisplayTotal,bwCabDisplayCount,bwCabDisplayBase); + if (update) + gFreeTempGC(); + else + wEndRedraw(); + } + +LOCAL_C VOID GetCount(UWORD *pCount) + { + LONG time; + WORD tstat; + + p_presume(bwPid); + time=10l; + TaskCount=0; + p_ioc(TimCB,P_FREAD,&tstat,&time); + p_waitstat(&tstat); + *pCount=TaskCount; + if (TaskCount>SampleCount) + SampleCount=TaskCount; + p_psuspend(bwPid); + p_allowoff(); + } + +LOCAL_C VOID InitBW(VOID) + { + UWORD oldSample,Count2; + INT i; + + f_leave(bwPid=p_ptask("SYS$SPY",E_MAX_PRIORITY-1,MonitorLoop,&TaskStack[STACK_SIZE-1])); + f_open(&TimCB,"TIM:",-1); + spyPid=p_getpid(); + oldPri=p_getpri(spyPid); + p_setpri(spyPid,E_MAX_PRIORITY); + if (SampleCount==0) + for(i=0;i<5;i++) + { /* If no matching samples in 5 then just take the best so far */ + oldSample=SampleCount; + GetCount(&Count2); + if (Count2==oldSample || (Count2+1)==oldSample || Count2==(oldSample+1)) + break; /* Two matching samples, must be good! */ + } + p_setpri(bwPid,E_MIN_PRIORITY); + p_setpri(spyPid,E_PRIORITY_WSERV-1); + } + +#ifdef JPIC +#pragma save,ENTER_CALL +#endif +LOCAL_C INT xMonitorBandWidth(VOID) + { + WS_EV event; + + bwCabDisplayCount=bwCabCount=bwCount=bwCabDisplayBase=bwCabBase=LastCount=0; + bwCabDisplayTotal=bwCabTotal=bwTotal=0; + DisableReads(TRUE); + winId=CreateDialog(); + redrawWin(FALSE); + wFlush(); + InitBW(); + wGetEvent(&event); + FOREVER + { + p_ioyield(); + if (event.type!=E_FILE_PENDING) + { + p_iowait(); + if (event.type==WM_KEY) + { + if (event.p.key.keycode==27) + break; + if (event.p.key.keycode==(W_SPECIAL_KEY|'p')) + wClientPosition(0,0); + else if (event.p.key.keycode==(W_SPECIAL_KEY|'b')) + { + p_sound(-5,320); + bwCabDisplayTotal=bwCabTotal; + bwCabDisplayCount=bwCabCount; + bwCabDisplayBase=bwCabBase; + bwCabTotal=0; + bwCabCount=0; + bwCabBase=bwCount; + redrawWin(TRUE); + } + else if (event.p.key.keycode=='d') + Debug=!Debug; + } + else switch (event.type) + { + case WM_REDRAW: + if (event.handle!=1) + wInfoMsg("Redraw to unknown window!"); + else + redrawWin(FALSE); + break; + case WM_FOREGROUND: + case WM_BACKGROUND: + p_setpri(spyPid,E_PRIORITY_WSERV-1); + break; + } + wGetEvent(&event); + } + else + { + GetCount(&LastCount); + if (Debug) + DebugInfo(); + bwTotal+=LastCount; + if (bwCount++==9999) + bwCount=1; + bwCabTotal+=LastCount; + bwCabCount++; + redrawWin(TRUE); + wFlush(); + } + } + return(0); + } +#ifdef JPIC +#pragma restore +#endif + +GLDEF_C VOID MonitorBandWidth(VOID) + { + INT err; + TEXT *name; + + name=DatProcessNamePtr; + bwPid=spyPid=0; + DatProcessNamePtr=0; + if (wCaptureKey(W_SPECIAL_KEY|'b',W_PSION_MODIFIER|W_CTRL_MODIFIER,W_PSION_MODIFIER|W_CTRL_MODIFIER)<0) + wInfoMsg("'b' key capture failed"); + wDisableLeaves(FALSE); + err=p_enter1(xMonitorBandWidth); + wDisableLeaves(TRUE); + p_close(TimCB); + wCancelCaptureKey(W_SPECIAL_KEY|'b',W_PSION_MODIFIER|W_CTRL_MODIFIER,W_PSION_MODIFIER|W_CTRL_MODIFIER); + if (bwPid>0) + p_pkill(bwPid,0); + wCloseWindowTree(winId); + DisableReads(FALSE); + if (spyPid>0) + p_setpri(spyPid,oldPri); + if (err<0) + p_notifyerr(err,"Band width monitor failed",NULL,NULL,NULL); + DatProcessNamePtr=name; + wDisableLeaves(FALSE); + } diff --git a/code/SIBOSDK/hwdemo/ta1.afl b/code/SIBOSDK/hwdemo/ta1.afl new file mode 100644 index 0000000..b866e4f --- /dev/null +++ b/code/SIBOSDK/hwdemo/ta1.afl @@ -0,0 +1,3 @@ +tables.pic +tables.rsc +tables.shd diff --git a/code/SIBOSDK/hwdemo/ta1.c b/code/SIBOSDK/hwdemo/ta1.c new file mode 100644 index 0000000..b30a5b8 --- /dev/null +++ b/code/SIBOSDK/hwdemo/ta1.c @@ -0,0 +1,244 @@ +/* + TA1.C +*/ + +#include +#include +#include +#include + +LOCAL_D TEXT *cmds[]= + { + "rReset score", + "lLimits", + "mMode", + "tTiming", + "xExit", + NULL + }; + +#define TABLES_ITEMS 5 + +LOCAL_D H_MENU_DATA mdata[]= + { + "Tables",TABLES_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +typedef struct + { + UWORD TableEnd; + UWORD MaxTable; + UWORD Tested; + UWORD Correct; + UWORD Timing; + UWORD Mode; + } TSTATE; + +LOCAL_D TSTATE state={12,12,0,0,5,1}; + +LOCAL_D TEXT *EnvName="TABLES"; +#define ENV_NAME_LEN 6 + + +LOCAL_C VOID ResetScore(VOID) + { + if (!state.Tested) + { + wInfoMsg("No score to reset"); + return; + } + if (uOpenDialog("Reset score to zero")) + return; + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return; + if (uRunDialog()=='y') + { + state.Tested=0; + state.Correct=0; + } + } + +LOCAL_C VOID ChangeLimits(VOID) + { + LONG lTableEnd; + LONG lMaxTable; + H_DI_NUMBER end; + H_DI_NUMBER last; + + lTableEnd=state.TableEnd; + lMaxTable=state.MaxTable; + if (uOpenDialog("Limits for testing")) + return; + end.value=(&lTableEnd); + end.low=10; + end.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Tables end at",&end)) + return; + last.value=(&lMaxTable); + last.low=2; + last.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Highest table",&last)) + return; + if (uRunDialog()<=0) + return; + state.TableEnd=lTableEnd; + state.MaxTable=lMaxTable; + if (state.Mode>state.MaxTable) + state.Mode=state.MaxTable; + } + +LOCAL_C VOID ChangeTiming(VOID) + { + LONG lTiming; + H_DI_NUMBER tim; + + lTiming=state.Timing; + if (uOpenDialog("Timing")) + return; + tim.value=(&lTiming); + tim.low=1; + tim.high=20; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number of seconds allowed",&tim)) + return; + if (uRunDialog()<=0) + return; + state.Timing=lTiming; + } + +LOCAL_C VOID ChangeMode(VOID) + { + H_DI_CHOICE ch; + INT j; + TEXT buf[20]; + + if (uOpenDialog("Mode")) + return; + if (uBeginDCL(&ch)) + return; + if (uGrowDCL(&ch,"All tables")) + return; + for (j=2; j<=state.MaxTable; j++) + { + p_atos(&buf[0],"%d times table",j); + if (uGrowDCL(&ch,&buf[0])) + return; + } + if (uAddDCL("Test which tables",&state.Mode,&ch)) + return; + uRunDialog(); + } + +LOCAL_C VOID ExitApplication(VOID) + { + uErrorValue(p_setenviron(EnvName,ENV_NAME_LEN,&state,sizeof(TSTATE))); + p_exit(0); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case 0: + ResetScore(); + break; + case 1: + ChangeLimits(); + break; + case 2: + ChangeMode(); + break; + case 3: + ChangeTiming(); + break; + case 4: + ExitApplication(); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ExitApplication(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + } + } + +LOCAL_C VOID ReadState(VOID) + { + INT len; + UBYTE buf[P_ENVMAX]; + + len=p_getenviron(EnvName,ENV_NAME_LEN,&buf[0]); + if (len<0 || len!=sizeof(TSTATE)) + return; + p_bcpy(&state,&buf[0],sizeof(TSTATE)); + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(uFindMainWid()); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + ReadState(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/ta2.afl b/code/SIBOSDK/hwdemo/ta2.afl new file mode 100644 index 0000000..b866e4f --- /dev/null +++ b/code/SIBOSDK/hwdemo/ta2.afl @@ -0,0 +1,3 @@ +tables.pic +tables.rsc +tables.shd diff --git a/code/SIBOSDK/hwdemo/ta2.c b/code/SIBOSDK/hwdemo/ta2.c new file mode 100644 index 0000000..491ab46 --- /dev/null +++ b/code/SIBOSDK/hwdemo/ta2.c @@ -0,0 +1,340 @@ +/* + TA2.C +*/ + +#include +#include +#include +#include + +LOCAL_D TEXT *cmds[]= + { + "rReset score", + "lLimits", + "mMode", + "tTiming", + "xExit", + NULL + }; + +#define TABLES_ITEMS 5 + +LOCAL_D H_MENU_DATA mdata[]= + { + "Tables",TABLES_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +typedef struct + { + UWORD TableEnd; + UWORD MaxTable; + UWORD Tested; + UWORD Correct; + UWORD Timing; + UWORD Mode; + } TSTATE; + +LOCAL_D TSTATE state={12,12,0,0,5,1}; + +LOCAL_D TEXT *EnvName="TABLES"; +#define ENV_NAME_LEN 6 + + +LOCAL_C VOID DrawLine(INT j,TEXT *pb) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+9*j; + box.br.y=box.tl.y+9; + gPrintBoxText(&box,8,G_TEXT_ALIGN_CENTRE,0,pb,p_slen(pb)); + } + +LOCAL_C VOID DisplayScores(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"Score: %u correct out of %u",state.Correct,state.Tested); + DrawLine(0,&buf[0]); + } + +LOCAL_C VOID DisplayMode(VOID) + { + TEXT *pb; + TEXT buf[40]; + + if (state.Mode==1) + pb="Testing all tables"; + else + { + p_atos(&buf[0],"Testing %d times table",state.Mode); + pb=(&buf[0]); + } + DrawLine(1,pb); + } + +LOCAL_C VOID DisplayLimits(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"(up to %d times %d)", + (state.Mode==1? state.MaxTable: state.Mode),state.TableEnd); + DrawLine(2,&buf[0]); + } + +LOCAL_C VOID DrawButton(INT state) + { + P_RECT box; + + box.tl.x=34+36; + box.br.x=34+36+38; + box.tl.y=47; + box.br.y=47+14; + wDrawButton(&box,"Enter",state); + } + +LOCAL_C VOID DisplayPressButton(VOID) + { + gPrintText(34,56,"Press",5); + DrawButton(FALSE); + gPrintText(34+36+38+6,56,"to test",7); + } + +LOCAL_C VOID Display(VOID) + { + DisplayScores(); + DisplayMode(); + DisplayLimits(); + DisplayPressButton(); + } + +LOCAL_C VOID ResetScore(VOID) + { + if (!state.Tested) + { + wInfoMsg("No score to reset"); + return; + } + if (uOpenDialog("Reset score to zero")) + return; + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return; + if (uRunDialog()=='y') + { + state.Tested=0; + state.Correct=0; + DisplayScores(); + } + } + +LOCAL_C VOID ChangeLimits(VOID) + { + LONG lTableEnd; + LONG lMaxTable; + H_DI_NUMBER end; + H_DI_NUMBER last; + + lTableEnd=state.TableEnd; + lMaxTable=state.MaxTable; + if (uOpenDialog("Limits for testing")) + return; + end.value=(&lTableEnd); + end.low=10; + end.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Tables end at",&end)) + return; + last.value=(&lMaxTable); + last.low=2; + last.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Highest table",&last)) + return; + if (uRunDialog()<=0) + return; + state.TableEnd=lTableEnd; + state.MaxTable=lMaxTable; + if (state.Mode>state.MaxTable) + state.Mode=state.MaxTable; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ChangeTiming(VOID) + { + LONG lTiming; + H_DI_NUMBER tim; + + lTiming=state.Timing; + if (uOpenDialog("Timing")) + return; + tim.value=(&lTiming); + tim.low=1; + tim.high=20; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number of seconds allowed",&tim)) + return; + if (uRunDialog()<=0) + return; + state.Timing=lTiming; + } + +LOCAL_C VOID ChangeMode(VOID) + { + H_DI_CHOICE ch; + INT j; + TEXT buf[20]; + + if (uOpenDialog("Mode")) + return; + if (uBeginDCL(&ch)) + return; + if (uGrowDCL(&ch,"All tables")) + return; + for (j=2; j<=state.MaxTable; j++) + { + p_atos(&buf[0],"%d times table",j); + if (uGrowDCL(&ch,&buf[0])) + return; + } + if (uAddDCL("Test which tables",&state.Mode,&ch)) + return; + if (uRunDialog()<=0) + return; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ExitApplication(VOID) + { + uErrorValue(p_setenviron(EnvName,ENV_NAME_LEN,&state,sizeof(TSTATE))); + p_exit(0); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case 0: + ResetScore(); + break; + case 1: + ChangeLimits(); + break; + case 2: + ChangeMode(); + break; + case 3: + ChangeTiming(); + break; + case 4: + ExitApplication(); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MakeButtonDance(VOID) + { + DrawButton(TRUE); + wFlush(); + p_sleep(2); + DrawButton(FALSE); + wFlush(); + p_sleep(2); + } + +LOCAL_C VOID DoTest(VOID) + { + MakeButtonDance(); + state.Tested++; + state.Correct++; + DisplayScores(); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ExitApplication(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + else if (key.keycode==W_KEY_RETURN) + DoTest(); + } + } + +LOCAL_C VOID ReadState(VOID) + { + INT len; + UBYTE buf[P_ENVMAX]; + + len=p_getenviron(EnvName,ENV_NAME_LEN,&buf[0]); + if (len<0 || len!=sizeof(TSTATE)) + return; + p_bcpy(&state,&buf[0],sizeof(TSTATE)); + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(uFindMainWid()); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + ReadState(); + Display(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/ta3.afl b/code/SIBOSDK/hwdemo/ta3.afl new file mode 100644 index 0000000..b866e4f --- /dev/null +++ b/code/SIBOSDK/hwdemo/ta3.afl @@ -0,0 +1,3 @@ +tables.pic +tables.rsc +tables.shd diff --git a/code/SIBOSDK/hwdemo/ta3.c b/code/SIBOSDK/hwdemo/ta3.c new file mode 100644 index 0000000..6df7e2e --- /dev/null +++ b/code/SIBOSDK/hwdemo/ta3.c @@ -0,0 +1,517 @@ +/* + TA3.C +*/ + +#include +#include +#include +#include + + +GLREF_D UWORD DatLocked; + +LOCAL_D TEXT *cmds[]= + { + "rReset score", + "lLimits", + "mMode", + "tTiming", + "xExit", + NULL + }; + +#define TABLES_ITEMS 5 + +LOCAL_D H_MENU_DATA mdata[]= + { + "Tables",TABLES_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +typedef struct + { + UWORD TableEnd; + UWORD MaxTable; + UWORD Tested; + UWORD Correct; + UWORD Timing; + UWORD Mode; + } TSTATE; + +LOCAL_D TSTATE state={12,12,0,0,5,1}; + +LOCAL_D TEXT *EnvName="TABLES"; +#define ENV_NAME_LEN 6 + +LOCAL_D ULONG seed; + + +LOCAL_C VOID DrawLine(INT j,TEXT *pb) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+9*j; + box.br.y=box.tl.y+9; + gPrintBoxText(&box,8,G_TEXT_ALIGN_CENTRE,0,pb,p_slen(pb)); + } + +LOCAL_C VOID DisplayScores(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"Score: %u correct out of %u",state.Correct,state.Tested); + DrawLine(0,&buf[0]); + } + +LOCAL_C VOID DisplayMode(VOID) + { + TEXT *pb; + TEXT buf[40]; + + if (state.Mode==1) + pb="Testing all tables"; + else + { + p_atos(&buf[0],"Testing %d times table",state.Mode); + pb=(&buf[0]); + } + DrawLine(1,pb); + } + +LOCAL_C VOID DisplayLimits(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"(up to %d times %d)", + (state.Mode==1? state.MaxTable: state.Mode),state.TableEnd); + DrawLine(2,&buf[0]); + } + +LOCAL_C VOID DrawButton(INT state) + { + P_RECT box; + + box.tl.x=34+36; + box.br.x=34+36+38; + box.tl.y=47; + box.br.y=47+14; + wDrawButton(&box,"Enter",state); + } + +LOCAL_C VOID DisplayPressButton(VOID) + { + gPrintText(34,56,"Press",5); + DrawButton(FALSE); + gPrintText(34+36+38+6,56,"to test",7); + } + +LOCAL_C VOID Display(VOID) + { + DisplayScores(); + DisplayMode(); + DisplayLimits(); + DisplayPressButton(); + } + +LOCAL_C VOID ResetScore(VOID) + { + if (!state.Tested) + { + wInfoMsg("No score to reset"); + return; + } + if (uOpenDialog("Reset score to zero")) + return; + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return; + if (uRunDialog()=='y') + { + state.Tested=0; + state.Correct=0; + DisplayScores(); + } + } + +LOCAL_C VOID ChangeLimits(VOID) + { + LONG lTableEnd; + LONG lMaxTable; + H_DI_NUMBER end; + H_DI_NUMBER last; + + lTableEnd=state.TableEnd; + lMaxTable=state.MaxTable; + if (uOpenDialog("Limits for testing")) + return; + end.value=(&lTableEnd); + end.low=10; + end.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Tables end at",&end)) + return; + last.value=(&lMaxTable); + last.low=2; + last.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Highest table",&last)) + return; + if (uRunDialog()<=0) + return; + state.TableEnd=lTableEnd; + state.MaxTable=lMaxTable; + if (state.Mode>state.MaxTable) + state.Mode=state.MaxTable; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ChangeTiming(VOID) + { + LONG lTiming; + H_DI_NUMBER tim; + + lTiming=state.Timing; + if (uOpenDialog("Timing")) + return; + tim.value=(&lTiming); + tim.low=1; + tim.high=20; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number of seconds allowed",&tim)) + return; + if (uRunDialog()<=0) + return; + state.Timing=lTiming; + } + +LOCAL_C VOID ChangeMode(VOID) + { + H_DI_CHOICE ch; + INT j; + TEXT buf[20]; + + if (uOpenDialog("Mode")) + return; + if (uBeginDCL(&ch)) + return; + if (uGrowDCL(&ch,"All tables")) + return; + for (j=2; j<=state.MaxTable; j++) + { + p_atos(&buf[0],"%d times table",j); + if (uGrowDCL(&ch,&buf[0])) + return; + } + if (uAddDCL("Test which tables",&state.Mode,&ch)) + return; + if (uRunDialog()<=0) + return; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ExitApplication(VOID) + { + uErrorValue(p_setenviron(EnvName,ENV_NAME_LEN,&state,sizeof(TSTATE))); + p_exit(0); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case 0: + ResetScore(); + break; + case 1: + ChangeLimits(); + break; + case 2: + ChangeMode(); + break; + case 3: + ChangeTiming(); + break; + case 4: + ExitApplication(); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C INT FindRandom(INT low,INT high) + { + INT range; + + range=high-low+1; + return(low+(INT)(p_randl(&seed)%range)); + } + +LOCAL_C VOID FindFactors(WORD *pa,WORD *pb) + { + *pa=(state.Mode==1? FindRandom(2,state.MaxTable): state.Mode); + *pb=FindRandom(2,state.TableEnd); + } + +LOCAL_C VOID SwitchStyle(INT style) + { + G_GC gc; + + gc.style=style; + gSetGC(0,G_GC_MASK_STYLE,&gc); + } + +LOCAL_C VOID *CreateEditor(VOID) + { + H_EDIT_BOX heb; + + heb.maxchars=4; + heb.vulen=30; + heb.pos.x=113; + heb.pos.y=45; + heb.win=MainWid; + heb.font=WS_FONT_BASE; + heb.style=G_STY_DOUBLE; + return(hEBOpen(H_EDIT_BOX_FONT,&heb)); + } + +LOCAL_C VOID ClearBottomArea(VOID) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+3*9; + box.br.y=80-4; + gClrRect(&box,G_TRMODE_CLR); + } + +LOCAL_C VOID Beep(VOID) + { + p_sound(-5,320); + } + +LOCAL_C VOID SelectAll(VOID *ebH) + { + hEBSetSelect(ebH,0,p_slen(hEBSenseText(ebH))); + } + +LOCAL_C INT SenseNumberTyped(VOID *ebH) + { + TEXT *pb; + WORD num; + + pb=hEBSenseText(ebH); + p_stoi(&pb,&num); + return(num); + } + +LOCAL_C INT AddTextItem(TEXT *pmt,TEXT *pbod) + { + H_DI_TEXT txt; + TEXT buf[20]; + + txt.type=H_DTEXT_ALIGN_CENTRE; + uZTStoBCS(txt.str=(&buf[0]),pbod); + return(uAddDialogItem(H_DIALOG_TEXT,pmt,&txt)); + } + +LOCAL_C INT Complain(INT a,INT b,INT c) + { + TEXT buf[20]; + + if (uOpenDialog("Incorrect")) + return(-1); + p_atos(&buf[0],"%d \236 %d",a,b); + if (AddTextItem("The question",&buf[0])) + return(-1); + buf[p_itob(&buf[0],c)]=0; + if (AddTextItem("Your answer",&buf[0])) + return(-1); + if (uAddButtonList("Help",W_KEY_ESCAPE,"Retry",W_KEY_RETURN,NULL)) + return(-1); + if (uRunDialog()==W_KEY_RETURN) + return(0); + p_atos(&buf[0],"%d \236 %d = %d",a,b,a*b); + if (uOpenDialog(&buf[0])) + return(-1); + if (uAddButtonList("Continue",W_KEY_RETURN,NULL)) + return(-1); + uRunDialog(); + return(-1); + } + +LOCAL_C INT BadKey(INT k) + { + return(k<256 && p_isprint(k) && !p_isdigit(k)); + } + +LOCAL_C VOID DisplayQuestion(VOID) + { + TEXT buf[30]; + WMSG_KEY key; + P_RECT box; + VOID *ebH; + WORD a; + WORD b; + WORD c; + WORD ans; + + ebH=CreateEditor(); + if (!ebH) + return; + ClearBottomArea(); + hEBEmphasise(ebH,TRUE); + FindFactors(&a,&b); + ans=a*b; + p_atos(&buf[0],"%d \236 %d = ",a,b); + box.tl.x=53; + box.br.x=113; + box.tl.y=45; + box.br.y=45+17; + SwitchStyle(G_STY_DOUBLE); + gPrintBoxText(&box,15,G_TEXT_ALIGN_RIGHT,0,&buf[0],p_slen(&buf[0])); + SwitchStyle(G_STY_NORMAL); + DatLocked=TRUE; + state.Tested++; + FOREVER + { + uGetKey(&key); + if (BadKey(key.keycode)) + Beep(); + else if (key.keycode!=W_KEY_RETURN) + hEBHandleKey(ebH,key.keycode,key.modifiers); + else + { + c=SenseNumberTyped(ebH); + if (c==ans) + { + state.Correct++; + break; + } + Beep(); + hEBEmphasise(ebH,FALSE); + if (Complain(a,b,c)) + break; + DisplayScores(); + state.Tested++; + hEBEmphasise(ebH,TRUE); + SelectAll(ebH); + } + } + DatLocked=FALSE; + hEBClose(ebH); + ClearBottomArea(); + DisplayPressButton(); + } + +LOCAL_C VOID MakeButtonDance(VOID) + { + DrawButton(TRUE); + wFlush(); + p_sleep(2); + DrawButton(FALSE); + wFlush(); + p_sleep(2); + } + +LOCAL_C VOID DoTest(VOID) + { + MakeButtonDance(); + DisplayQuestion(); + DisplayScores(); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ExitApplication(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + else if (key.keycode==W_KEY_RETURN) + DoTest(); + } + } + +LOCAL_C VOID ReadState(VOID) + { + INT len; + UBYTE buf[P_ENVMAX]; + + len=p_getenviron(EnvName,ENV_NAME_LEN,&buf[0]); + if (len<0 || len!=sizeof(TSTATE)) + return; + p_bcpy(&state,&buf[0],sizeof(TSTATE)); + } + +LOCAL_C VOID InitSeed(VOID) + { + seed=p_date(); + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(uFindMainWid()); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + uEscape(FALSE); + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + ReadState(); + Display(); + InitSeed(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/tables.afl b/code/SIBOSDK/hwdemo/tables.afl new file mode 100644 index 0000000..b866e4f --- /dev/null +++ b/code/SIBOSDK/hwdemo/tables.afl @@ -0,0 +1,3 @@ +tables.pic +tables.rsc +tables.shd diff --git a/code/SIBOSDK/hwdemo/tables.c b/code/SIBOSDK/hwdemo/tables.c new file mode 100644 index 0000000..9624a50 --- /dev/null +++ b/code/SIBOSDK/hwdemo/tables.c @@ -0,0 +1,626 @@ +/* + + TABLES.C + +Written by DavidW +Started on 21/1/92 + +*/ + +#include +#include +#include +#include +#include + + +GLREF_D UWORD DatLocked; + +LOCAL_D TEXT *cmds[]= + { + "rReset score", + "lLimits", + "mMode", + "tTiming", + "xExit", + NULL + }; + +#define TABLES_ITEMS 5 + +LOCAL_D H_MENU_DATA mdata[]= + { + "Tables",TABLES_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +typedef struct + { + UWORD TableEnd; + UWORD MaxTable; + UWORD Tested; + UWORD Correct; + UWORD Timing; + UWORD Mode; + } TSTATE; + +LOCAL_D TSTATE state={12,12,0,0,5,1}; + +LOCAL_D TEXT *EnvName="TABLES"; +#define ENV_NAME_LEN 6 + +LOCAL_D ULONG seed; + +LOCAL_D VOID *timH; +LOCAL_D WORD timactive; +LOCAL_D WORD timstat; +LOCAL_D ULONG timint; +LOCAL_D WORD timcount; +LOCAL_D WORD timtotcnt; + + +LOCAL_C VOID DrawLine(INT j,TEXT *pb) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+9*j; + box.br.y=box.tl.y+9; + gPrintBoxText(&box,8,G_TEXT_ALIGN_CENTRE,0,pb,p_slen(pb)); + } + +LOCAL_C VOID DisplayScores(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"Score: %u correct out of %u",state.Correct,state.Tested); + DrawLine(0,&buf[0]); + } + +LOCAL_C VOID DisplayMode(VOID) + { + TEXT *pb; + TEXT buf[40]; + + if (state.Mode==1) + pb="Testing all tables"; + else + { + p_atos(&buf[0],"Testing %d times table",state.Mode); + pb=(&buf[0]); + } + DrawLine(1,pb); + } + +LOCAL_C VOID DisplayLimits(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"(up to %d times %d)", + (state.Mode==1? state.MaxTable: state.Mode),state.TableEnd); + DrawLine(2,&buf[0]); + } + +LOCAL_C VOID DrawButton(INT state) + { + P_RECT box; + + box.tl.x=34+36; + box.br.x=34+36+38; + box.tl.y=47; + box.br.y=47+14; + wDrawButton(&box,"Enter",state); + } + +LOCAL_C VOID DisplayPressButton(VOID) + { + gPrintText(34,56,"Press",5); + DrawButton(FALSE); + gPrintText(34+36+38+6,56,"to test",7); + } + +LOCAL_C VOID Display(VOID) + { + DisplayScores(); + DisplayMode(); + DisplayLimits(); + DisplayPressButton(); + } + +LOCAL_C VOID ResetScore(VOID) + { + if (!state.Tested) + { + wInfoMsg("No score to reset"); + return; + } + if (uOpenDialog("Reset score to zero")) + return; + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return; + if (uRunDialog()=='y') + { + state.Tested=0; + state.Correct=0; + DisplayScores(); + } + } + +LOCAL_C VOID ChangeLimits(VOID) + { + LONG lTableEnd; + LONG lMaxTable; + H_DI_NUMBER end; + H_DI_NUMBER last; + + lTableEnd=state.TableEnd; + lMaxTable=state.MaxTable; + if (uOpenDialog("Limits for testing")) + return; + end.value=(&lTableEnd); + end.low=10; + end.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Tables end at",&end)) + return; + last.value=(&lMaxTable); + last.low=2; + last.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Highest table",&last)) + return; + if (uRunDialog()<=0) + return; + state.TableEnd=lTableEnd; + state.MaxTable=lMaxTable; + if (state.Mode>state.MaxTable) + state.Mode=state.MaxTable; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ChangeTiming(VOID) + { + LONG lTiming; + H_DI_NUMBER tim; + + lTiming=state.Timing; + if (uOpenDialog("Timing")) + return; + tim.value=(&lTiming); + tim.low=1; + tim.high=20; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number of seconds allowed",&tim)) + return; + if (uRunDialog()<=0) + return; + state.Timing=lTiming; + } + +LOCAL_C VOID ChangeMode(VOID) + { + H_DI_CHOICE ch; + INT j; + TEXT buf[20]; + + if (uOpenDialog("Mode")) + return; + if (uBeginDCL(&ch)) + return; + if (uGrowDCL(&ch,"All tables")) + return; + for (j=2; j<=state.MaxTable; j++) + { + p_atos(&buf[0],"%d times table",j); + if (uGrowDCL(&ch,&buf[0])) + return; + } + if (uAddDCL("Test which tables",&state.Mode,&ch)) + return; + if (uRunDialog()<=0) + return; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ExitApplication(VOID) + { + uErrorValue(p_setenviron(EnvName,ENV_NAME_LEN,&state,sizeof(TSTATE))); + p_exit(0); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case 0: + ResetScore(); + break; + case 1: + ChangeLimits(); + break; + case 2: + ChangeMode(); + break; + case 3: + ChangeTiming(); + break; + case 4: + ExitApplication(); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C INT FindRandom(INT low,INT high) + { + INT range; + + range=high-low+1; + return(low+(INT)(p_randl(&seed)%range)); + } + +LOCAL_C VOID FindFactors(WORD *pa,WORD *pb) + { + *pa=(state.Mode==1? FindRandom(2,state.MaxTable): state.Mode); + *pb=FindRandom(2,state.TableEnd); + } + +LOCAL_C VOID SwitchStyle(INT style) + { + G_GC gc; + + gc.style=style; + gSetGC(0,G_GC_MASK_STYLE,&gc); + } + +LOCAL_C VOID *CreateEditor(VOID) + { + H_EDIT_BOX heb; + + heb.maxchars=4; + heb.vulen=30; + heb.pos.x=113; + heb.pos.y=38; + heb.win=MainWid; + heb.font=WS_FONT_BASE; + heb.style=G_STY_DOUBLE; + return(hEBOpen(H_EDIT_BOX_FONT,&heb)); + } + +LOCAL_C VOID ClearBottomArea(VOID) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+3*9; + box.br.y=80-4; + gClrRect(&box,G_TRMODE_CLR); + } + +LOCAL_C VOID Beep(VOID) + { + p_sound(-5,320); + } + +LOCAL_C VOID SelectAll(VOID *ebH) + { + hEBSetSelect(ebH,0,p_slen(hEBSenseText(ebH))); + } + +LOCAL_C INT SenseNumberTyped(VOID *ebH) + { + TEXT *pb; + WORD num; + + pb=hEBSenseText(ebH); + if (!*pb) + return(0); + p_stoi(&pb,&num); + return(num); + } + +LOCAL_C INT AddTextItem(TEXT *pmt,TEXT *pbod) + { + H_DI_TEXT txt; + TEXT buf[20]; + + txt.type=H_DTEXT_ALIGN_CENTRE; + uZTStoBCS(txt.str=(&buf[0]),pbod); + return(uAddDialogItem(H_DIALOG_TEXT,pmt,&txt)); + } + +LOCAL_C INT Complain(INT a,INT b,INT c) + { + TEXT buf[20]; + + if (uOpenDialog("Incorrect")) + return(-1); + p_atos(&buf[0],"%d \236 %d",a,b); + if (AddTextItem("The question",&buf[0])) + return(-1); + buf[p_itob(&buf[0],c)]=0; + if (AddTextItem("Your answer",&buf[0])) + return(-1); + if (uAddButtonList("Help",W_KEY_ESCAPE,"Retry",W_KEY_RETURN,NULL)) + return(-1); + if (uRunDialog()==W_KEY_RETURN) + return(0); + p_atos(&buf[0],"%d \236 %d = %d",a,b,a*b); + if (uOpenDialog(&buf[0])) + return(-1); + if (uAddButtonList("Continue",W_KEY_RETURN,NULL)) + return(-1); + uRunDialog(); + return(-1); + } + +LOCAL_C INT BadKey(INT k) + { + return(k<256 && p_isprint(k) && !p_isdigit(k)); + } + +LOCAL_C VOID CancelTimer(VOID) + { + if (timactive) + { + p_iow2(timH,P_FCANCEL); + p_waitstat(&timstat); + } + timactive=FALSE; + } + +LOCAL_C VOID QueueTimer(VOID) + { + CancelTimer(); + p_ioa4(timH,P_FRELATIVE,&timstat,&timint); + timactive=TRUE; + } + +LOCAL_C VOID InitialiseTimer(VOID) + { + if (state.Timing<=4) + { + timint=5; + timcount=2*state.Timing; + } + else + { + timint=10; + timcount=state.Timing; + } + timtotcnt=timcount; + QueueTimer(); + } + +LOCAL_C VOID GetBarChartRect(P_RECT *pbox) + { + pbox->tl.x=9; + pbox->br.x=180; + pbox->tl.y=62; + pbox->br.y=68; + } + +LOCAL_C VOID IncrementBarChart(VOID) + { + P_RECT box; + + timcount--; + GetBarChartRect(&box); + box.br.x=9+171*(timtotcnt-timcount)/timtotcnt; + gFillPattern(&box,WS_BITMAP_GREY,G_TRMODE_REPL); + } + +LOCAL_C VOID ClearBarChart(VOID) + { + P_RECT box; + + GetBarChartRect(&box); + gClrRect(&box,G_TRMODE_CLR); + } + +LOCAL_C VOID DisplayQuestion(VOID) + { + TEXT buf[30]; + WMSG_KEY key; + WORD keyactive; + WORD keystat; + P_RECT box; + VOID *ebH; + WORD a; + WORD b; + WORD c; + WORD ans; + + ebH=CreateEditor(); + if (!ebH) + return; + ClearBottomArea(); + hEBEmphasise(ebH,TRUE); + FindFactors(&a,&b); + ans=a*b; + p_atos(&buf[0],"%d \236 %d = ",a,b); + box.tl.x=53; + box.br.x=113; + box.tl.y=38; + box.br.y=38+17; + SwitchStyle(G_STY_DOUBLE); + gPrintBoxText(&box,15,G_TEXT_ALIGN_RIGHT,0,&buf[0],p_slen(&buf[0])); + SwitchStyle(G_STY_NORMAL); + box.tl.x=8; + box.br.x=189-8; + box.tl.y=61; + box.br.y=61+8; + gBorderRect(&box,W_BORD_CORNER_1); + DatLocked=TRUE; + state.Tested++; + keyactive=FALSE; + InitialiseTimer(); + FOREVER + { + if (keyactive) + wFlush(); + else + { + uGetKeyA(&keystat,&key); + keyactive=TRUE; + } + p_iowait(); + if (keystat==E_FILE_PENDING) + { + timactive=FALSE; + IncrementBarChart(); + if (!timcount) + { + wFlush(); + p_sleep(2); + goto CheckAnswer; + } + QueueTimer(); + continue; + } + keyactive=FALSE; + if (BadKey(key.keycode)) + Beep(); + else if (key.keycode!=W_KEY_RETURN) + hEBHandleKey(ebH,key.keycode,key.modifiers); + else + { + CheckAnswer: + c=SenseNumberTyped(ebH); + if (c==ans) + { + state.Correct++; + break; + } + Beep(); + hEBEmphasise(ebH,FALSE); + if (Complain(a,b,c)) + break; + DisplayScores(); + state.Tested++; + hEBEmphasise(ebH,TRUE); + SelectAll(ebH); + ClearBarChart(); + InitialiseTimer(); + } + } + DatLocked=FALSE; + hEBClose(ebH); + ClearBottomArea(); + DisplayPressButton(); + CancelTimer(); + } + +LOCAL_C VOID MakeButtonDance(VOID) + { + DrawButton(TRUE); + wFlush(); + p_sleep(2); + DrawButton(FALSE); + wFlush(); + p_sleep(2); + } + +LOCAL_C VOID DoTest(VOID) + { + MakeButtonDance(); + DisplayQuestion(); + DisplayScores(); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ExitApplication(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + else if (key.keycode==W_KEY_RETURN) + DoTest(); + } + } + +LOCAL_C VOID ReadState(VOID) + { + INT len; + UBYTE buf[P_ENVMAX]; + + len=p_getenviron(EnvName,ENV_NAME_LEN,&buf[0]); + if (len<0 || len!=sizeof(TSTATE)) + return; + p_bcpy(&state,&buf[0],sizeof(TSTATE)); + } + +LOCAL_C VOID InitSeed(VOID) + { + seed=p_date(); + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(uFindMainWid()); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + uEscape(FALSE); + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + ReadState(); + Display(); + InitSeed(); + p_open(&timH,"TIM:",-1); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/tables.ms b/code/SIBOSDK/hwdemo/tables.ms new file mode 100644 index 0000000..5f173d5 --- /dev/null +++ b/code/SIBOSDK/hwdemo/tables.ms @@ -0,0 +1 @@ +Tables diff --git a/code/SIBOSDK/hwdemo/tables.pic b/code/SIBOSDK/hwdemo/tables.pic new file mode 100644 index 0000000..67f7507 Binary files /dev/null and b/code/SIBOSDK/hwdemo/tables.pic differ diff --git a/code/SIBOSDK/hwdemo/tables.rsc b/code/SIBOSDK/hwdemo/tables.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/tables.shd b/code/SIBOSDK/hwdemo/tables.shd new file mode 100644 index 0000000..9e5433e Binary files /dev/null and b/code/SIBOSDK/hwdemo/tables.shd differ diff --git a/code/SIBOSDK/hwdemo/tele.afl b/code/SIBOSDK/hwdemo/tele.afl new file mode 100644 index 0000000..3b8eaf6 --- /dev/null +++ b/code/SIBOSDK/hwdemo/tele.afl @@ -0,0 +1,3 @@ +tele.pic +tele.rsc +tele.shd diff --git a/code/SIBOSDK/hwdemo/tele.c b/code/SIBOSDK/hwdemo/tele.c new file mode 100644 index 0000000..a141443 --- /dev/null +++ b/code/SIBOSDK/hwdemo/tele.c @@ -0,0 +1,1055 @@ +/* + TELE.C + +Written by DavidW +Started on 20/11/91 + +*/ + +#include +#include +#include +#include +#include + +GLREF_D UWORD DatLocked; +GLREF_D TEXT *DatUsedPathNamePtr; + + +LOCAL_D TEXT *cmds[]= + { + "nNew", + "oOpen", + "mMerge", + "sSave as", + "kCompress", + "xExit", + "iInsert", + "cCopy", + "uUpdate", + "aAdd", + "dDelete", + "rFind previous", + "fFind", + "gFind next", + "jJump to", + "zSort", + "lDial", + "yPrint setup", + "pPrint", + NULL + }; + +#define FILE_ITEMS 6 +#define EDIT_ITEMS 5 +#define FIND_ITEMS 3 +#define SPECIAL_ITEMS 5 + +#define ITEMS_BEFORE_FILE 0 +#define ITEMS_BEFORE_EDIT FILE_ITEMS +#define ITEMS_BEFORE_FIND (ITEMS_BEFORE_EDIT+EDIT_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_FIND+FIND_ITEMS) + +LOCAL_D H_MENU_DATA mdata[]= + { + "File",FILE_ITEMS, + "Edit",EDIT_ITEMS, + "Find",FIND_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_D struct + { + UWORD dataStart; + UWORD needVersion; + UWORD firHeader; + UBYTE fir[3]; + } ModelHeader= + { + DbfHeaderLength, + 0x100f, + (DbfRecordTypeFir<<12)|3, + { + DbfFieldTypeString, + DbfFieldTypeString, + DbfFieldTypeWord + } + }; + +LOCAL_D TEXT filename[P_FNAMESIZE]; +LOCAL_D VOID *dH; +LOCAL_D UBYTE dBuf[512]; +LOCAL_D UWORD dOff; + +typedef struct + { + TEXT nam[20]; + TEXT dep[4]; + WORD nmb; + } ENTRY; + +LOCAL_D ENTRY clip; +LOCAL_D UWORD clipfill=FALSE; + +LOCAL_D TEXT find[22]={0}; + +LOCAL_D UWORD PrintState; +LOCAL_D TEXT PrintBuf[10]; +LOCAL_D UWORD PrintRec; +LOCAL_D ENTRY PrintEnt; + +#define NAME_TLY 4 +#define DEPT_TLY 24 +#define TELE_TLY 44 +#define COUNT_TLY 58 +#define TEXT_HEIGHT 18 +#define TEXT_ASCENT 16 + +#define LABEL_TLX 15 +#define LABEL_WID 30 +#define FIELD_TLX 65 +#define FIELD_WID 120 +#define COUNT_TLX 105 +#define COUNT_WID 75 + +#define TRN_CALL call(reg_param=>(bx,si),reg_saved=>(cx,dx,di,EPOC_SAVE)) + + +LOCAL_C VOID DisplayPrompt(INT tly,TEXT *buf) + { + P_RECT box; + + box.tl.y=tly; + box.tl.x=LABEL_TLX; + box.br.x=LABEL_TLX+LABEL_WID; + box.br.y=tly+TEXT_HEIGHT; + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_CENTRE,0,buf,p_slen(buf)); + } + +LOCAL_C VOID DisplayPrompts(VOID) + { + DisplayPrompt(NAME_TLY,"Name"); + DisplayPrompt(DEPT_TLY,"Dept"); + DisplayPrompt(TELE_TLY,"\05"); + } + +LOCAL_C VOID DisplayField(INT tly,TEXT *buf,INT len) + { + P_RECT box; + + box.tl.y=tly; + box.tl.x=FIELD_TLX; + box.br.x=FIELD_TLX+FIELD_WID; + box.br.y=tly+TEXT_HEIGHT; + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_LEFT,0,buf,len); + } + +LOCAL_C VOID DisplayCount(TEXT *buf) + { + P_RECT box; + + box.tl.x=COUNT_TLX; + box.tl.y=COUNT_TLY; + box.br.x=COUNT_TLX+COUNT_WID; + box.br.y=COUNT_TLY+TEXT_HEIGHT; + gPrintBoxText(&box,TEXT_ASCENT,G_TEXT_ALIGN_RIGHT,0,buf,p_slen(buf)); + } + +LOCAL_C VOID BufToEntry(ENTRY *pent) + { + UBYTE *psrc; + INT len; + + psrc=(&dBuf[dOff+2]); + len=(*psrc)+1; + p_bcpy(&pent->nam[0],psrc,len); + psrc+=len; + len=(*psrc)+1; + p_bcpy(&pent->dep[0],psrc,len); + psrc+=len; + pent->nmb=(*(WORD *)psrc); + } + +LOCAL_C VOID CleanEntry(ENTRY *pent) + { + p_bfil(pent,sizeof(ENTRY),0); + } + +LOCAL_C VOID Display(VOID) + { + ENTRY ent; + UWORD count; + TEXT buf[12]; + TEXT num[4]; + INT len; + + count=DbfCount(dH); + if (count) + { + p_atos(&buf[0],"%u/%u",DbfSense(dH)+1,count); + BufToEntry(&ent); + } + else + { + p_scpy(&buf[0],"Empty"); + CleanEntry(&ent); + } + DisplayField(NAME_TLY,&ent.nam[1],ent.nam[0]); + DisplayField(DEPT_TLY,&ent.dep[1],ent.dep[0]); + if (ent.nmb) + len=p_itob(&num[0],ent.nmb); + else + len=0; + DisplayField(TELE_TLY,&num[0],len); + DisplayCount(&buf[0]); + } + +LOCAL_C INT EditEntry(ENTRY *pent,TEXT *title) + { + H_DI_EDIT edname; + H_DI_EDIT eddept; + LONG lnumb; + H_DI_NUMBER numb; + + if (uOpenDialog(title)) + return(-1); + edname.len=19; + edname.str=(&pent->nam[0]); + if (uAddDialogItem(H_DIALOG_EDIT,"Name",&edname)) + return(-1); + eddept.len=3; + eddept.str=(&pent->dep[0]); + if (uAddDialogItem(H_DIALOG_EDIT,"Dept",&eddept)) + return(-1); + lnumb=pent->nmb; + numb.value=(&lnumb); + numb.low=100; + numb.high=999; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number",&numb)) + return(-1); + if (uRunDialog()<=0) + return(-1); + pent->nmb=lnumb; + return(0); + } + +LOCAL_C INT EntryToBuf(ENTRY *pent) + { + INT len1; + INT len2; + UBYTE *pb; + + len1=pent->nam[0]+1; + pb=(&dBuf[2]); + pb=p_bcpy(pb,&pent->nam[0],len1); + len2=pent->dep[0]+1; + pb=p_bcpy(pb,&pent->dep[0],len2); + *(WORD *)pb=pent->nmb; + dOff=0; + return(len1+len2+2); + } + +LOCAL_C INT Check(INT val) + { + TEXT buf[64]; + + if (val<0 && val!=E_FILE_EOF) + { + uForceToFront(); + DatLocked=TRUE; + p_errs(&buf[0],val); + wsAlertW(WS_ALERT_CLIENT,&buf[0],"Terminating application",0); + p_exit(0); + } + return(val); + } + +LOCAL_C VOID DoUpdate(INT len) + { + INT state; + + state=DbfStateDisabled; + Check(DbfUpdate(&state,dH,len)); + } + +LOCAL_C VOID DoAppend(INT len) + { + Check(DbfAppend(dH,len)); + Display(); + } + +LOCAL_C VOID AddRecord(VOID) + { + ENTRY new; + + CleanEntry(&new); + if (!EditEntry(&new,"Add new record")) + DoAppend(EntryToBuf(&new)); + } + +LOCAL_C VOID UpdateRecord(VOID) + { + ENTRY ent; + + if (!DbfCount(dH)) + { + wInfoMsg("No record to update"); + return; + } + BufToEntry(&ent); + if (!EditEntry(&ent,"Update record")) + { + DoUpdate(EntryToBuf(&ent)); + Display(); + } + } + +LOCAL_C INT Transition( +#pragma save,TRN_CALL + INT pf(VOID *,UWORD *)) +#pragma restore + { + return(Check(pf(dH,&dOff))); + } + +LOCAL_C VOID DeleteRecord(VOID) + { + INT state; + + if (!DbfCount(dH)) + { + wInfoMsg("No record to delete"); + return; + } + if (uOpenDialog("Delete current record")) + return; + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return; + if (uRunDialog()!='y') + return; + state=DbfStateDisabled; + if (Check(DbfEraseRead(&state,dH,&dOff))<0) + Transition(DbfBackRead); + Display(); + } + +LOCAL_C VOID InsertFromClipboard(VOID) + { + if (!clipfill) + { + wInfoMsg("No record to insert"); + return; + } + DoAppend(EntryToBuf(&clip)); + } + +LOCAL_C VOID CopyToClipboard(VOID) + { + if (!DbfCount(dH)) + { + wInfoMsg("No record to copy"); + return; + } + BufToEntry(&clip); + clipfill=TRUE; + wInfoMsg("Record copied"); + } + +LOCAL_C INT Search(INT dir) + { + UINT state; + INT len; + INT ret; + + len=find[0]; + find[0]='*'; + find[len+1]='*'; + state=DbfStateDisabled; + ret=Check(DbfFindRead(&state,dH,&find[0],len+2, + 255|dir|DbfFindCaseIndependent,2,&dOff)); + find[0]=len; + return(ret); + } + +LOCAL_C INT ResetTo(UINT current) + { + return(Check(DbfAbsRead(dH,current,&dOff))); + } + +LOCAL_C VOID DoFind(INT dir) + { + UINT current; + + current=DbfSense(dH); + if (Search(dir)>=0) + Display(); + else + { + ResetTo(current); + wInfoMsg("Not found"); + } + } + +LOCAL_C VOID FindAgain(INT dir1,INT dir2, +#pragma save,TRN_CALL + INT pf(VOID *,UWORD *)) +#pragma restore + { + UINT current; + + current=DbfSense(dH); + if (Transition(pf)>=0 && Search(dir1)>=0 + || Search(dir2)>=0 && DbfSense(dH)!=current) + Display(); + else + { + ResetTo(current); + wInfoMsg("No more found"); + } + } + +LOCAL_C VOID FindNext(VOID) + { + FindAgain(DbfFindForwards,DbfFindFirst,DbfNextRead); + } + +LOCAL_C VOID FindPrevious(VOID) + { + FindAgain(DbfFindBackwards,DbfFindLast,DbfBackRead); + } + +LOCAL_C VOID FindRecord(VOID) + { + H_DI_EDIT edfind; + + if (uOpenDialog(NULL)) + return; + edfind.str=(&find[0]); + edfind.len=19; + if (uAddDialogItem(H_DIALOG_EDIT,"Find",&edfind)) + return; + if (uAddButtonList("Cancel",W_KEY_ESCAPE,"Find backwards",W_KEY_TAB, + "Find forwards",W_KEY_RETURN,NULL)) + return; + switch (uRunDialog()) + { + case W_KEY_TAB: + DoFind(DbfFindLast); + case 0: + return; + case W_KEY_RETURN: + DoFind(DbfFindFirst); + } + } + +LOCAL_C VOID DialNumber(VOID) + { + ENTRY tmp; + TEXT buf[4]; + + if (!DbfCount(dH)) + { + wInfoMsg("No number to dial"); + return; + } + BufToEntry(&tmp); + buf[p_itob(&buf[0],tmp.nmb)]=0; + if (hDTMFString(&buf[0])) + wInfoMsg("Sound device busy"); + } + +LOCAL_C VOID CompressFile(VOID) + { + UINT state; + + if (!hIsDbfCompressible(dH)) + wInfoMsg("Cannot compress on Flash"); + else + { + state=DbfStateDisabled; + Check(DbfCompress(&state,dH)); + wInfoMsg("File compressed"); + } + } + +LOCAL_C VOID ChangeName(TEXT *newname) + { + p_scpy(&filename[0],newname); + hSetUpStatusNames(&filename[0]); + wsUpdate(WS_UPDATE_NAME); + } + +LOCAL_C VOID DisplayStart(VOID) + { + Transition(DbfFirstRead); + Display(); + } + +LOCAL_C VOID ChangeOverTo(VOID *newdH,TEXT *newname) + { + DbfClose(dH); + dH=newdH; + ChangeName(newname); + DisplayStart(); + } + +LOCAL_C INT doOpen(VOID **pdH,TEXT *pb,INT flags,DbfHeader *pHead) + { + INT state; + + state=DbfStateDisabled; + p_scpy((TEXT *)&pHead->fileType[0],"OPLDatabaseFile"); + return(uErrorValue(DbfOpen(&state,pdH,pb,flags,pHead,&dBuf[0],512,1))); + } + +LOCAL_C INT TryOpenDbf(TEXT *pb,VOID **pdH) + { + DbfHeader Header; + + return(doOpen(pdH,pb,P_FOPEN|P_FUPDATE|P_FRANDOM,&Header)); + } + +LOCAL_C VOID SetupFilename(TEXT *pb) + { + p_bcpy(pb+1,DatUsedPathNamePtr,*pb=p_slen(DatUsedPathNamePtr)); + } + +LOCAL_C VOID OpenDbf(VOID) + { + H_DI_FSEL open; + TEXT openbuf[P_FNAMESIZE+2]; + VOID *newdH; + UINT current; + + current=DbfSense(dH); + SetupFilename(open.fname=(&openbuf[0])); + open.flags=H_FILE_PICK_SELECTOR|H_FILE_RESTRICT_LIST|H_FILE_SET_DEFEXT; + FOREVER + { + if (uOpenDialog("Open telephone file")) + break; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&open)) + break; + if (uRunDialog()<=0) + break; + openbuf[1+openbuf[0]]=0; + if (!TryOpenDbf(&openbuf[1],&newdH)) + { + ChangeOverTo(newdH,&openbuf[1]); + return; + } + } + ResetTo(current); + } + +LOCAL_C INT TryNewDbf(TEXT *pb,VOID **pdH) + { + DbfHeader Header; + + hEnsurePath(pb); + Header.createVersion=DbfVersion(); + p_bcpy(&Header.dataStart,&ModelHeader,sizeof(ModelHeader)); + return(doOpen(pdH,pb,P_FREPLACE|P_FUPDATE|P_FRANDOM,&Header)); + } + +LOCAL_C VOID NewDbf(VOID) + { + H_DI_FSEL new; + TEXT newbuf[P_FNAMESIZE+2]; + VOID *newdH; + UINT current; + + current=DbfSense(dH); + SetupFilename(new.fname=(&newbuf[0])); + new.flags=H_FILE_NEW_EDITOR|H_FILE_SET_DEFEXT; + FOREVER + { + if (uOpenDialog("New telephone file")) + break; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&new)) + break; + if (uRunDialog()<=0) + break; + newbuf[1+newbuf[0]]=0; + if (!TryNewDbf(&newbuf[1],&newdH)) + { + ChangeOverTo(newdH,&newbuf[1]); + return; + } + } + ResetTo(current); + } + +LOCAL_C INT DoMerge(TEXT *pb,INT flags,INT dir) + { + UINT state; + + state=DbfStateDisabled; + return(uErrorValue(DbfCopyFile(&state,dH,pb,flags,1,dir))); + } + +LOCAL_C VOID MergeDbf(VOID) + { + H_DI_FSEL merge; + TEXT mergebuf[P_FNAMESIZE+2]; + UINT current; + + current=DbfSense(dH); + SetupFilename(merge.fname=(&mergebuf[0])); + merge.flags=H_FILE_PICK_SELECTOR|H_FILE_RESTRICT_LIST|H_FILE_SET_DEFEXT; + FOREVER + { + if (uOpenDialog("Merge telephone file")) + break; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&merge)) + break; + if (uRunDialog()<=0) + break; + mergebuf[1+mergebuf[0]]=0; + if (!DoMerge(&mergebuf[1],P_FOPEN,DbfCopyToHandle)) + { + wInfoMsg("File merged"); + DisplayStart(); + return; + } + } + ResetTo(current); + } + +LOCAL_C VOID DoSave(TEXT *pb,INT usenew) + { + if (DoMerge(pb,P_FUPDATE|P_FREPLACE,DbfCopyFromHandle)) + return; + if (usenew) + { + DbfClose(dH); + ChangeName(pb); + while (TryOpenDbf(pb,&dH)) + ; + DisplayStart(); + } + wInfoMsg("Saved"); + } + +LOCAL_C VOID SaveDbfAs(VOID) + { + H_DI_FSEL save; + TEXT savebuf[P_FNAMESIZE+2]; + UWORD usenew; + + if (uOpenDialog("Save as")) + return; + SetupFilename(save.fname=(&savebuf[0])); + save.flags=H_FILE_NEW_EDITOR|H_FILE_SET_DEFEXT; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&save)) + return; + usenew=1; + if (uAddChoiceList("Use new file",&usenew,"No","Yes",NULL)) + return; + if (uRunDialog()) + { + savebuf[1+savebuf[0]]=0; + hEnsurePath(&savebuf[1]); + DoSave(&savebuf[1],usenew==2); + } + } + +LOCAL_C INT ordf(INT r1,INT r2,VOID *base) + { + UBYTE *table; + UBYTE *e1; + UBYTE *e2; + INT entlen; + + table=(UBYTE *)base; + entlen=(*(UWORD *)table); + table+=2; + r1=(*(UWORD *)(table+r1*entlen)); + r2=(*(UWORD *)(table+r2*entlen)); + table+=2; + e1=table+r1*entlen; + e2=table+r2*entlen; + return(p_bcmp(e1+1,*e1,e2+1,*e2)); + } + +LOCAL_C VOID excf(INT r1,INT r2,VOID *base) + { + UBYTE *table; + INT entlen; + UWORD *p1; + UWORD *p2; + UWORD swap; + + table=(UBYTE *)base; + entlen=(*(UWORD *)table); + table+=2; + p1=(UWORD *)(table+r1*entlen); + p2=(UWORD *)(table+r2*entlen); + swap=(*p1); + *p1=(*p2); + *p2=swap; + } + +LOCAL_C INT DoSort(UINT k,INT len) + { + INT entlen; + UBYTE *table; + INT i,j; + INT thislen; + UBYTE *target; + UBYTE *source; + UWORD moved; + INT ret; + + entlen=len+3; + table=p_alloc(2+k*entlen); + if (!table) + { + uErrorString("Insufficient memory"); + return(-1); + } + *(UWORD *)table=entlen; + Transition(DbfFirstRead); + target=table+2; + for (i=0; ilen) + thislen=len; + *(UWORD *)target=i; + *(target+2)=thislen; + p_bcpy(target+3,source,thislen); + target+=entlen; + Transition(DbfNextRead); + } + if (p_qsort(k,ordf,excf,table)) + { + uErrorString("Internal sort stack overflow"); + ret=(-1); + } + else + { + for (i=0; imoved) + (*(UWORD *)target)--; + target+=entlen; + } + } + ret=0; + wInfoMsg("Sorted"); + DisplayStart(); + } + p_free(table); + return(ret); + } + +LOCAL_C VOID SortDbf(VOID) + { + UINT k; + LONG len; + H_DI_NUMBER num; + UINT current; + + k=DbfCount(dH); + if (!k) + { + wInfoMsg("No records to sort"); + return; + } + current=DbfSense(dH); + len=19; + num.low=1; + num.high=19; + num.value=(&len); + FOREVER + { + if (uOpenDialog("Sort file by name")) + break; + if (uAddDialogItem(H_DIALOG_NUMBER,"Key length",&num)) + break; + if (uRunDialog()<=0) + break; + if (DoSort(k,(INT)len)) + return; + } + ResetTo(current); + } + +LOCAL_C VOID JumpTo(VOID) + { + INT count; + LONG curr; + H_DI_NUMBER num; + + count=DbfCount(dH); + if (!count) + { + wInfoMsg("No records to jump to"); + return; + } + if (uOpenDialog(NULL)) + return; + curr=DbfSense(dH)+1; + num.value=(&curr); + num.low=1; + num.high=count; + if (uAddDialogItem(H_DIALOG_NUMBER,"Jump to record",&num)) + return; + if (uRunDialog()<=0) + return; + ResetTo((UINT)(curr-1)); + Display(); + } + +LOCAL_C INT PrintLine(H_PRINT *pr) + { + switch (PrintState++) + { + case 0: + if (ResetTo(PrintRec++)<0) + return(0); + BufToEntry(&PrintEnt); + pr->buf=(&PrintEnt.nam[1]); + pr->blen=PrintEnt.nam[0]; + pr->style|=2; + break; + case 1: + pr->buf=(&PrintEnt.dep[1]); + pr->blen=PrintEnt.dep[0]; + break; + case 2: + pr->buf=(&PrintBuf[0]); + pr->blen=p_itob(&PrintBuf[0],PrintEnt.nmb); + break; + case 3: + pr->blen=0; + PrintState=0; + return(TRUE); + } + pr->flags|=0x8000; + return(TRUE); + } + +LOCAL_C VOID DoPrint(VOID) + { + UINT current; + + current=DbfSense(dH); + PrintState=0; + PrintRec=0; + hPrint(PrintLine); + ResetTo(current); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_FILE: + NewDbf(); + break; + case ITEMS_BEFORE_FILE+1: + OpenDbf(); + break; + case ITEMS_BEFORE_FILE+2: + MergeDbf(); + break; + case ITEMS_BEFORE_FILE+3: + SaveDbfAs(); + break; + case ITEMS_BEFORE_FILE+4: + CompressFile(); + break; + case ITEMS_BEFORE_FILE+5: + p_exit(0); + case ITEMS_BEFORE_EDIT: + InsertFromClipboard(); + break; + case ITEMS_BEFORE_EDIT+1: + CopyToClipboard(); + break; + case ITEMS_BEFORE_EDIT+2: + UpdateRecord(); + break; + case ITEMS_BEFORE_EDIT+3: + AddRecord(); + break; + case ITEMS_BEFORE_EDIT+4: + DeleteRecord(); + break; + case ITEMS_BEFORE_FIND: + FindPrevious(); + break; + case ITEMS_BEFORE_FIND+1: + FindRecord(); + break; + case ITEMS_BEFORE_FIND+2: + FindNext(); + break; + case ITEMS_BEFORE_SPECIAL: + JumpTo(); + break; + case ITEMS_BEFORE_SPECIAL+1: + SortDbf(); + break; + case ITEMS_BEFORE_SPECIAL+2: + DialNumber(); + break; + case ITEMS_BEFORE_SPECIAL+3: + hPrintSetupDialog(); + break; + case ITEMS_BEFORE_SPECIAL+4: + DoPrint(); + } + } + +LOCAL_C INT ObeySystemCommand(INT cmd,TEXT *pb,VOID **pdH) + { + return((cmd=='O'? TryOpenDbf: TryNewDbf)(pb,pdH)); + } + +LOCAL_C VOID ProcessSystemCommand(VOID) + { + TEXT buf[P_FNAMESIZE+2]; + VOID *newdH; + + wGetCommand((UBYTE *)&buf[0]); + if (buf[0]=='X') + p_exit(0); + if (!ObeySystemCommand(buf[0],&buf[1],&newdH)) + ChangeOverTo(newdH,&buf[1]); + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ProcessSystemCommand(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else + { + switch (key.keycode) + { + case W_KEY_MENU: + if (!(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + break; + case W_KEY_LEFT: + if (Transition(DbfBackRead)>=0) + { + Display(); + break; + } + case W_KEY_HOME: + Transition(DbfFirstRead); + Display(); + break; + case W_KEY_RIGHT: + if (Transition(DbfNextRead)>=0) + { + Display(); + break; + } + case W_KEY_END: + Transition(DbfLastRead); + Display(); + break; + case W_KEY_DELETE_LEFT: + DeleteRecord(); + break; + case W_KEY_TAB: + key.modifiers^=W_SHIFT_MODIFIER; + case W_KEY_RETURN: + if (key.modifiers&W_SHIFT_MODIFIER) + FindPrevious(); + else + FindNext(); + break; + case W_KEY_HELP: + if (key.modifiers&W_PSION_MODIFIER) + DialNumber(); + } + } + } + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + G_GC gc; + INT hgc; + + gc.style=G_STY_DOUBLE; + hgc=gCreateGC(MainWid,G_GC_MASK_STYLE,&gc); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + INT command; + + MainWid=uFindMainWid(); + CreateGC(); + command=hCrackCommandLine(); + if (ObeySystemCommand(command,DatUsedPathNamePtr,&dH)) + p_exit(0); + ReduceScreenSize(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + DisplayPrompts(); + DisplayStart(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwdemo/tele.ms b/code/SIBOSDK/hwdemo/tele.ms new file mode 100644 index 0000000..2e16de8 --- /dev/null +++ b/code/SIBOSDK/hwdemo/tele.ms @@ -0,0 +1,3 @@ +Tele.TEL +\TEL\ +3 diff --git a/code/SIBOSDK/hwdemo/tele.pic b/code/SIBOSDK/hwdemo/tele.pic new file mode 100644 index 0000000..02d603a Binary files /dev/null and b/code/SIBOSDK/hwdemo/tele.pic differ diff --git a/code/SIBOSDK/hwdemo/tele.rsc b/code/SIBOSDK/hwdemo/tele.rsc new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/hwdemo/tele.shd b/code/SIBOSDK/hwdemo/tele.shd new file mode 100644 index 0000000..70357ff Binary files /dev/null and b/code/SIBOSDK/hwdemo/tele.shd differ diff --git a/code/SIBOSDK/hwdemo/unnamed.pr b/code/SIBOSDK/hwdemo/unnamed.pr new file mode 100644 index 0000000..408c49b --- /dev/null +++ b/code/SIBOSDK/hwdemo/unnamed.pr @@ -0,0 +1,6 @@ +#system epoc img +#set epocinit=iplib +#model small jpi +#compile %main +#pragma link(hwif.lib) +#link %main diff --git a/code/SIBOSDK/hwdemo/vid.bat b/code/SIBOSDK/hwdemo/vid.bat new file mode 100644 index 0000000..4ccb4d5 --- /dev/null +++ b/code/SIBOSDK/hwdemo/vid.bat @@ -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 + diff --git a/code/SIBOSDK/hwdemo/wsreport.c b/code/SIBOSDK/hwdemo/wsreport.c new file mode 100644 index 0000000..cc7efe8 --- /dev/null +++ b/code/SIBOSDK/hwdemo/wsreport.c @@ -0,0 +1,343 @@ +/* Module WSREPORT.C + Written by Steve Mar 1992 + + Write a log of one or all the applications window server resources. +*/ +#include +#include +#include + +GLREF_D VOID *DatApp1; +GLREF_D WSERV_SPEC *wserv_channel; + +#define MAX_OBJ 256 +#define G_SEG_SEL_MAX_ROM 63 + +typedef struct + { + G_FONT_INFO info; + UBYTE *addr; + P_RECT area; + UWORD bytewid; + UWORD segment; + UWORD work_spc_size; + UWORD work_spc_wid; + UBYTE *width_table; + } G_FONT; + +typedef struct + { + UWORD seg; + UBYTE *addr; + UWORD bytewid; + } BM_DATA; + +typedef struct + { + UBYTE flags; + UBYTE filler; + BM_DATA bm_data; + VOID *region; + P_POINT size; + TEXT name[14]; + } BITMAP; + +typedef union + { + G_FONT *font; + BITMAP *bit; + } IFOB; + +typedef struct + { + UBYTE type; + UBYTE usage; + IFOB addr; + UINT self_index; + } SHARED_HEADER; + +typedef struct s_shared_data /* Bitmap and font header structure */ + { + SHARED_HEADER head; + UWORD checksum; + struct s_shared_data *next; + struct s_shared_data **prev; + } S_SHARED_DATA; + +typedef struct s_window + { + UBYTE type; + UBYTE status; + UWORD flags; + P_POINT origin; + P_RECT abs; + P_RECT rel; + struct s_window *parent; + struct s_window *child; + struct s_window *sibling; + VOID *region; + VOID *area; + UWORD self_index; + } S_WINDOW; + +typedef struct s_gcb + { + UBYTE type; + UBYTE style; + BM_DATA bm_data; + UBYTE gmode; + UBYTE textmode; + P_POINT origin; + VOID *region; + UWORD draws_to; + G_FONT *font; + BM_DATA extra_bm_data; + P_RECT extra_rect; + } S_GCB; + +typedef union + { + S_WINDOW win; + S_GCB gcb; + S_SHARED_DATA shared; + } OBJECT; + +#define MAX_DEV_EVENTS 8 +#define DEQ_ENTRY_SIZE 16 +typedef struct + { + UWORD ready; + UBYTE front; + UBYTE n_entries; + UBYTE buffer[DEQ_ENTRY_SIZE][MAX_DEV_EVENTS]; + } S_DEQ; + +typedef struct + { + UBYTE *read_addr; + UWORD flags; + UBYTE *gcb; + UWORD os_id; + UBYTE SelfIndex; + BYTE error; + VOID *clock; + S_WINDOW *capture; + VOID *redrawq; + VOID *invalid_area; + S_WINDOW *redraw_win; + VOID *redraw_region; + S_WINDOW *cursor_win; + W_CURSOR cursor; + UWORD root_handle; + S_GCB *tempgcb; + S_WINDOW *front_window; + VOID *alert; + TEXT busy_txt[W_BUSY_MSG_MAX_LEN+1]; + UBYTE busy_corner; + VOID *bit_list; + S_GCB *static_gcb; + UBYTE *ipcbuf; + WORD death_stat; + UBYTE *cmd_buf; + UWORD open_mode; + ULONG open_addr; + S_DEQ deq; + UINT status[2]; + UWORD tab_size; + OBJECT *obj_tab[MAX_OBJ]; + } WS_CCB; + +typedef struct + { + WORD WservStaticInitGcb; + WORD WservStaticFontTable; + WORD WservStaticClients[WS_MAX_CLIENTS]; + WORD WservStaticRomSegments[G_SEG_SEL_MAX_ROM]; + WORD WservStaticFontTabSize; + WORD WservStaticBitmapTab; + WORD WservStaticBitmapTabSize; + WORD WservStaticIconTab; + WORD WservStaticIconTabSize; + } WSERV_STATICS; + +GLREF_D P_DEVICE p_file; +LOCAL_D VOID *FileCB=NULL; +LOCAL_D WSERV_STATICS *wsDatApp; +LOCAL_D WS_CCB *ClientCCBs[WS_MAX_CLIENTS]; +LOCAL_D WS_CCB ccb; + +LOCAL_C VOID wsRead(VOID *to,VOID *from,UINT len) + { + p_pcpyfr(wserv_channel->link.local.wserv_pid,from,to,len); + } + +LOCAL_C VOID fWrite(TEXT *str,...) + { + INT len; + TEXT buf[128]; + + len=p_atob(&buf[0],str,&str+1); + f_write(FileCB,&buf[0],len); + } + +LOCAL_C VOID ReportWindow(S_WINDOW *pWin,UINT inset) + { + S_WINDOW *pNext,win; + static TEXT *back[4]={"None","Clr","Set","Bit"}; + + for(pNext=pWin;pNext;) + { + wsRead(&win,pNext,sizeof(S_WINDOW)); + if (win.self_index>ccb.tab_size || + &ccb.obj_tab[win.self_index]->win!=pNext) + break; + fWrite("%- *fWindow(%d) %s%sisible %s,{{%d,%d},%d,%d}",inset, + win.self_index, + win.status&W_UNINITIALISED?"Uninitialised ":"", + win.status&W_SET_INVISIBLE?"Inv":"V", + back[win.status&3], + win.rel.tl.x,win.rel.tl.y, + win.rel.br.x-win.rel.tl.x, + win.rel.br.y-win.rel.tl.y); + ReportWindow(win.child,inset+1); + pNext=win.sibling; + } + } + +LOCAL_C VOID ReportClient(VOID *client) + { + UINT j; + OBJECT object; + BITMAP bitmap; + G_FONT font; + TEXT name[34]; + + wsRead(&ccb,client,sizeof(ccb)); + f_leave(p_pname(ccb.os_id,&name[0])); + fWrite(&name[0]); + fWrite("--------------"); + fWrite("Client slot %d",ccb.SelfIndex); + fWrite(ccb.read_addr?"Read outstanding":"No read outstanding"); + fWrite("Flags 0x%x",ccb.flags); + if (ccb.error) + fWrite("Pending error %d",ccb.error); + fWrite(ccb.redrawq ? "Redraws-pending":"No Redraws-pending"); + fWrite("PID=0x%x",ccb.os_id); + fWrite(""); + ReportWindow(ccb.front_window,0); + for(j=2;jWservStaticClients[0], + sizeof(ClientCCBs)); + index=nodlg=0; + if (pid==-1) /* Log the foreground clients resources */ + { + wGetProcessList(&buf[0]); + pid=buf[0]; + nodlg=TRUE; /* Log to the last file name used with no query */ + } + if (pid) /* Find the client index of the process to log */ + FOREVER + { + index++; + if (index==WS_MAX_CLIENTS) + { + wInfoMsg("Not a window server client"); + return; + } + if (ClientCCBs[index]) + { + wsRead(&ccb,ClientCCBs[index],sizeof(ccb)); + if (ccb.os_id==pid) + break; + } + } + fsel.fname= &fName[0]; + fsel.flags=H_FILE_SET_DEFEXT|H_FILE_NEW_EDITOR; + if (nodlg==TRUE || + (uOpenDialog("Select file to write report to")>=0 && + uAddDialogItem(H_DIALOG_FSEL,"File",&fsel)>=0 && + uRunDialog()>0)) + { + wsRead(&wsDatApp,&DatApp1,2); + fName[fName[0]+1]=0; + uErrorValue(p_enter3(report,&fName[1],index)); + p_close(FileCB); + FileCB=NULL; + } + } + diff --git a/code/SIBOSDK/hwifood/gbar.afl b/code/SIBOSDK/hwifood/gbar.afl new file mode 100644 index 0000000..905a7c4 --- /dev/null +++ b/code/SIBOSDK/hwifood/gbar.afl @@ -0,0 +1,2 @@ +gbar.pic +gbar.rsc diff --git a/code/SIBOSDK/hwifood/gbar.cat b/code/SIBOSDK/hwifood/gbar.cat new file mode 100644 index 0000000..58cb0b2 --- /dev/null +++ b/code/SIBOSDK/hwifood/gbar.cat @@ -0,0 +1,59 @@ +IMAGE gbar + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE lprinter.g +INCLUDE help.g +INCLUDE dlgbox.g + +CLASS hprinter lprinter + { + REPLACE lpr_read + REPLACE lpr_sense_text + PROPERTY + { + INT (*sense)(WDR_PRINT *); + } + } + +CLASS hhelpdlg helpdlg + { + REPLACE destroy + } + +CLASS data_dl dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + TYPES + { + typedef struct + { + UWORD exit_code; + UWORD totloops; + UWORD update; + UWORD esc; + UWORD loopsleft; + UWORD toupdate; + } RB_GBAR; + } + } + +CLASS gbar_dl dlgbox + { + REPLACE wn_sense_help + REPLACE dl_dyn_init + REPLACE dl_key + ADD gbar_update + } + +CLASS bar_ao active + { + REPLACE ao_init + REPLACE ao_run + PROPERTY + { + RB_GBAR *prb; + } + } diff --git a/code/SIBOSDK/hwifood/gbar.pic b/code/SIBOSDK/hwifood/gbar.pic new file mode 100644 index 0000000..8ab3856 Binary files /dev/null and b/code/SIBOSDK/hwifood/gbar.pic differ diff --git a/code/SIBOSDK/hwifood/gbar.pr b/code/SIBOSDK/hwifood/gbar.pr new file mode 100644 index 0000000..7f52c76 --- /dev/null +++ b/code/SIBOSDK/hwifood/gbar.pr @@ -0,0 +1,21 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile gbar.cat + +#if %remake #or (gbar.rsg #older gbar.rss) #or (gbar.rsc #older gbar.rss) #then + #run "rs gbar" no_window no_abort + #file delete gbar.img +#endif + +#compile growbar.c + +#pragma link(hwifo.lib) +#pragma link(hwim.lib) + +#if (gbar.img #older gbar.afl) #or (gbar.img #older gbar.pic) #then + #file delete gbar.img +#endif + +#link gbar.img diff --git a/code/SIBOSDK/hwifood/gbar.rss b/code/SIBOSDK/hwifood/gbar.rss new file mode 100644 index 0000000..4e633a2 --- /dev/null +++ b/code/SIBOSDK/hwifood/gbar.rss @@ -0,0 +1,60 @@ +#include +#include +#include + +RESOURCE DIALOG dl_data + { + title="Specify grow-bar data"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Total number of loops"; + info=NCEDIT + { + high=100; + low=1; + }; + }, + CONTROL + { + class=C_NCEDIT; + prompt="Update display every"; + info=NCEDIT + { + high=100; + low=1; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Allow escape"; + info=CHLIST { rid=-SYS_NO_YES; }; + } + }; + } + +RESOURCE CONTROL item_abandon + { + class=C_ACLIST; + info=ACLIST { rid=-SYS_AC_ABANDON; }; + } + +RESOURCE DIALOG dl_gbar + { + title="Example grow bar"; + flags=DLGBOX_NOTIFY_ESCAPE|DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_DONEWN; + } + }; + } + +RESOURCE STRING str_cancelled { str="Cancelled by user"; } +RESOURCE STRING str_finished { str="Looping finished"; } diff --git a/code/SIBOSDK/hwifood/growbar.c b/code/SIBOSDK/hwifood/growbar.c new file mode 100644 index 0000000..60dffc6 --- /dev/null +++ b/code/SIBOSDK/hwifood/growbar.c @@ -0,0 +1,164 @@ +/* + GROWBAR.C + +Written by DavidW +Started on 19/8/94 + +*/ + +#include +#include +#include +#include + +#include +#include +#include "gbar.rsg" + +GLREF_D VOID *w_am; +GLREF_D PR_WSERV *w_ws; +GLREF_D VOID *DatDialogPtr; + + +LOCAL_C VOID doDial(INT classno,INT resid,VOID *rbuf) + { + hOODialog(p_getlibh(CAT_GBAR_GBAR),classno,resid,rbuf); + } + +LOCAL_C VOID InitGbarData(RB_GBAR *pgb) + { + pgb->totloops=10; + pgb->update=1; + pgb->esc=TRUE; + } + +LOCAL_C VOID DisallowDialling(VOID) + { + w_ws->wserv.flags|=PR_WSERV_FREEFORM_DIALLING; + } + +LOCAL_C VOID MainLoop(VOID) + { + VOID *ao; + RB_GBAR gb_data; + + InitGbarData(&gb_data); + DisallowDialling(); + ao=f_newsend(CAT_GBAR_GBAR,C_BAR_AO,O_AO_INIT,&gb_data); + FOREVER + { + doDial(C_DATA_DL,DL_DATA,&gb_data); + if (gb_data.exit_code==W_KEY_ESCAPE) + continue; + p_send2(ao,O_AO_QUEUE); + doDial(C_GBAR_DL,DL_GBAR,&gb_data); + p_send2(ao,O_AO_CANCEL); + hInfoPrint(gb_data.exit_code==W_KEY_ESCAPE? + STR_CANCELLED: STR_FINISHED); + } + } + +LOCAL_C VOID SpecificInit(VOID) + { + hInitAppRcb(); + hCrackCommandLine(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } + +#pragma METHOD_CALL + +#define DL_DATA_TOT 1 +#define DL_DATA_UPD 2 +#define DL_DATA_ESC 3 + +METHOD VOID data_dl_dl_dyn_init(PR_DLGBOX *self) + { + RB_GBAR *prbuf; + + prbuf=self->dlgbox.rbuf; + hDlgSetNcedit(DL_DATA_TOT,prbuf->totloops); + hDlgSetNcedit(DL_DATA_UPD,prbuf->update); + hDlgSetChlist(DL_DATA_ESC,prbuf->esc); + } + +METHOD INT data_dl_dl_key(PR_DLGBOX *self) + { + RB_GBAR *prbuf; + + prbuf=self->dlgbox.rbuf; + prbuf->totloops=hDlgSenseNcedit(DL_DATA_TOT); + prbuf->update=hDlgSenseNcedit(DL_DATA_UPD); + prbuf->esc=hDlgSenseChlist(DL_DATA_ESC); + return(WN_KEY_CHANGED); + } + +METHOD VOID gbar_dl_dl_dyn_init(PR_DLGBOX *self) + { + RB_GBAR *prbuf; + SE_DONEWN set; + + prbuf=self->dlgbox.rbuf; + if (prbuf->esc) + p_send3(self,O_DL_ITEM_APPEND,ITEM_ABANDON); + set.flags=SE_DONEWN_RANGE; + set.range=prbuf->totloops; + hDlgSet(1,&set); + prbuf->toupdate=prbuf->update; + prbuf->loopsleft=prbuf->totloops; + } + +METHOD VOID gbar_dl_gbar_update(PR_DLGBOX *self) + { + RB_GBAR *prbuf; + SE_DONEWN set; + + prbuf=self->dlgbox.rbuf; + set.flags=SE_DONEWN_VALUE; + set.val=prbuf->totloops-prbuf->loopsleft; + hDlgSet(1,&set); + } + +METHOD INT gbar_dl_dl_key(PR_DLGBOX *self) + { + RB_GBAR *prbuf; + + prbuf=self->dlgbox.rbuf; + return(prbuf->esc? WN_KEY_CHANGED: WN_KEY_NO_CHANGE); + } + +METHOD VOID gbar_dl_wn_sense_help(VOID *self) + { + p_leave(RUN_ACTIVE_USED); + } + +METHOD VOID bar_ao_ao_init(PR_BAR_AO *self,RB_GBAR *prb) + { + p_send3(w_am,O_AM_ADD_TASK,self); + self->bar_ao.prb=prb; + } + +METHOD INT bar_ao_ao_run(PR_BAR_AO *self) + { + RB_GBAR *prb; + + p_sleep(5); /* the next stage of computation or drawing etc */ + p_send2(self,O_AO_QUEUE); + prb=self->bar_ao.prb; + if (!--(prb->loopsleft)) + { + p_send2(DatDialogPtr,O_DESTROY); + prb->exit_code=0; + } + else if (!--(prb->toupdate)) + { + p_send2(DatDialogPtr,O_GBAR_UPDATE); + prb->toupdate=prb->update; + } + return(RUN_ACTIVE_USED); + } diff --git a/code/SIBOSDK/hwifood/hwifood.prj b/code/SIBOSDK/hwifood/hwifood.prj new file mode 100644 index 0000000..f1fe7a7 --- /dev/null +++ b/code/SIBOSDK/hwifood/hwifood.prj @@ -0,0 +1,27 @@ +hwifood.prj ! release source files +ts.red ! redirection file +! +oqd.pr ! TS project file (OQuery dyl) +oquery.pr ! TS project file (OQuery app) +makeoq.bat ! makes OQUERY.IMG +! +oquery.c ! source for Oquery +oquery.rss ! resource script +oquery.afl ! add file list +query.ms ! shell data source +query.shd ! shell data file +query.pic ! icon +oquery.dfl ! DYL file list +! +oqd.cat ! dialog DYL definitions +oqdc.c ! dialog DYL methods + +gbar.pr ! TS project file (GBAR) +makegbar.bat ! makes GBAR.IMG +! +gbar.cat ! incorporates HWIF.CAT +growbar.c ! main source code +gbar.rss ! resource script +gbar.afl ! add file list +gbar.pic ! icon + diff --git a/code/SIBOSDK/hwifood/makegbar.bat b/code/SIBOSDK/hwifood/makegbar.bat new file mode 100644 index 0000000..4eb1356 --- /dev/null +++ b/code/SIBOSDK/hwifood/makegbar.bat @@ -0,0 +1,2 @@ +@echo off +tscx /m gbar diff --git a/code/SIBOSDK/hwifood/makeoq.bat b/code/SIBOSDK/hwifood/makeoq.bat new file mode 100644 index 0000000..75ec24e --- /dev/null +++ b/code/SIBOSDK/hwifood/makeoq.bat @@ -0,0 +1,3 @@ +@echo off +tscx /m oqd /%jpivid% +tscx /m oquery /%jpivid% diff --git a/code/SIBOSDK/hwifood/oqd.cat b/code/SIBOSDK/hwifood/oqd.cat new file mode 100644 index 0000000..35f949a --- /dev/null +++ b/code/SIBOSDK/hwifood/oqd.cat @@ -0,0 +1,12 @@ +LIBRARY oqd + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE dlgbox.g + +CLASS oqd_combins dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } diff --git a/code/SIBOSDK/hwifood/oqd.pr b/code/SIBOSDK/hwifood/oqd.pr new file mode 100644 index 0000000..5fbedf0 --- /dev/null +++ b/code/SIBOSDK/hwifood/oqd.pr @@ -0,0 +1,14 @@ +#system epoc dyl +#set epocinit=iplib +#model small jpi + +#compile oqd.cat + +#if %remake #or (oquery.rsg #older oquery.rss) #or (oquery.rsc #older oquery.rss) #then + #run "rs oquery" no_window no_abort + #file delete oquery.img +#endif + +#compile oqdc.c +#pragma link(hwim.lib) +#link oqd.dyl diff --git a/code/SIBOSDK/hwifood/oqdc.c b/code/SIBOSDK/hwifood/oqdc.c new file mode 100644 index 0000000..bf7a7ba --- /dev/null +++ b/code/SIBOSDK/hwifood/oqdc.c @@ -0,0 +1,88 @@ +/* + OQDC.C + +Methods of OO dialogs of OQUERY.C +Written by DavidW +Started on 5/9/93 + +*/ + +#include +#include +#include + +#include "oquery.rsg" + +#define COMBINS_DIW 1 +#define COMBINS_DIM 2 +#define COMBINS_FOUND 3 + +LOCAL_C VOID SetControls(P_DAYSEC *pds) + { + P_DATE dt; + + hDlgSetChlist(COMBINS_DIW,p_wkday(pds->day)); + p_dstodt(pds,&dt); + hDlgSetNcedit(COMBINS_DIM,dt.day+1); + hDlgSetDtedit(COMBINS_FOUND,pds->day); + } + +#pragma METHOD_CALL + +METHOD VOID oqd_combins_dl_dyn_init(PR_DLGBOX *self) + { + ULONG sdate; + P_DAYSEC ds; + + sdate=p_date(); + p_sttods(&sdate,&ds); + SetControls(&ds); + } + +METHOD INT oqd_combins_dl_key(PR_DLGBOX *self,INT index,INT key) + { + P_DAYSEC ds; + P_DATE dt; + INT diw; + INT dim; + INT diff; + ULONG reset; + INT inc; + + if (key==W_KEY_ESCAPE) + return(WN_KEY_CHANGED); + diw=hDlgSenseChlist(COMBINS_DIW); + dim=hDlgSenseNcedit(COMBINS_DIM)-1; + ds.day=hDlgSenseDtedit(COMBINS_FOUND); + ds.sec=0; + reset=ds.day; + diff=diw-p_wkday(ds.day); + if (key==W_KEY_RETURN) + { + if (diff<=0) + diff+=7; + inc=7; + } + else + { + if (diff>=0) + diff-=7; + inc=(-7); + } + ds.day+=diff; + FOREVER + { + if (ds.day>93501l) + { + hInfoPrint(OQS_NO_FURTHER_MATCHES); + ds.day=reset; + break; + } + p_dstodt(&ds,&dt); + if (dt.day==dim) + break; + ds.day+=inc; + } + SetControls(&ds); + return(WN_KEY_NO_CHANGE); + } diff --git a/code/SIBOSDK/hwifood/oquery.afl b/code/SIBOSDK/hwifood/oquery.afl new file mode 100644 index 0000000..0536df5 --- /dev/null +++ b/code/SIBOSDK/hwifood/oquery.afl @@ -0,0 +1,3 @@ +query.pic +oquery.rsc +query.shd diff --git a/code/SIBOSDK/hwifood/oquery.c b/code/SIBOSDK/hwifood/oquery.c new file mode 100644 index 0000000..190d414 --- /dev/null +++ b/code/SIBOSDK/hwifood/oquery.c @@ -0,0 +1,781 @@ +/* + OQUERY.C + +Written by DavidW +Started on 28/11/91 +OO aspects started 1/9/93 + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "oquery.rsg" + + +LOCAL_D INT DylHandle; + +LOCAL_D TEXT *cmds[]= + { + "iInches/Centimetres", + "mMiles/Kilometres", + "lPounds/Kilogrammes", + "pPints/Litres", + "fFahrenheit/Centigrade", + "dDay of week", + "cCombinations", + "tTime difference", + "hHoroscope", + "nNow", + "wPassword", + "eEncrypt", + "uDecrypt", + "sSignificance", + "zFile size", + "xExit", + NULL + }; + +#define CONVERT_ITEMS 5 +#define CALENDAR_ITEMS 5 +#define SECRET_ITEMS 3 +#define SPECIAL_ITEMS 3 + +#define ITEMS_BEFORE_CONVERT 0 +#define ITEMS_BEFORE_CALENDAR CONVERT_ITEMS +#define ITEMS_BEFORE_SECRET (ITEMS_BEFORE_CALENDAR+CALENDAR_ITEMS) +#define ITEMS_BEFORE_SPECIAL (ITEMS_BEFORE_SECRET+SECRET_ITEMS) + +LOCAL_D H_MENU_DATA mdata[]= + { + "Conversions",CONVERT_ITEMS, + "Calendar",CALENDAR_ITEMS, + "Secret",SECRET_ITEMS, + "Special",SPECIAL_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +LOCAL_D WORD ndp=2; +LOCAL_D DOUBLE small; +LOCAL_D DOUBLE vsmall; + +LOCAL_D TEXT pass[10]; + +LOCAL_D VOID *ttH; +LOCAL_D UWORD ttMonth=1; +LOCAL_D UWORD ttSuffix=1; +LOCAL_D UWORD ttDay=1; +LOCAL_D UWORD ttCentury=2; +LOCAL_D UWORD ttSeconds=2; + + +LOCAL_C VOID ZeroDouble(DOUBLE *pdbl) + { + p_bfil(pdbl,sizeof(DOUBLE),0); + } + +LOCAL_C VOID MakeDouble(DOUBLE *pdbl,WORD val) + { + p_itof(pdbl,&val); + } + +LOCAL_C VOID CalcSmall(VOID) + { + DOUBLE dndp; + DOUBLE temp; + + MakeDouble(&dndp,ndp); + p_fneg(&dndp); + MakeDouble(&temp,10); + p_pow(&small,&temp,&dndp); + MakeDouble(&temp,2); + p_fld(&vsmall,&small); + p_fdiv(&vsmall,&temp); + } + +LOCAL_C VOID Clip(DOUBLE *pval) + { + DOUBLE remain; + DOUBLE temp; + + MakeDouble(&temp,0); + if (p_fcmp(pval,&temp)>=0) + p_fadd(pval,&vsmall); + else + p_fsub(pval,&vsmall); + p_mod(&remain,pval,&small); + p_fsub(pval,&remain); + } + +LOCAL_C VOID FahrToCent(DOUBLE *pcent,DOUBLE *pfahr) + { + DOUBLE temp; + + p_fld(pcent,pfahr); + MakeDouble(&temp,32); + p_fsub(pcent,&temp); + MakeDouble(&temp,5); + p_fmul(pcent,&temp); + MakeDouble(&temp,9); + p_fdiv(pcent,&temp); + } + +LOCAL_C VOID CentToFahr(DOUBLE *pfahr,DOUBLE *pcent) + { + DOUBLE temp; + + p_fld(pfahr,pcent); + MakeDouble(&temp,9); + p_fmul(pfahr,&temp); + MakeDouble(&temp,5); + p_fdiv(pfahr,&temp); + MakeDouble(&temp,32); + p_fadd(pfahr,&temp); + } + +LOCAL_C VOID Temperatures(VOID) + { + DOUBLE fahr; + DOUBLE cent; + H_DI_FLOAT ffahr; + H_DI_FLOAT fcent; + INT index; + + MakeDouble(&fahr,32); + MakeDouble(¢,0); + ffahr.value=(&fahr); + MakeDouble(&ffahr.low,-17968); + MakeDouble(&ffahr.high,18032); + fcent.value=(¢); + MakeDouble(&fcent.low,-10000); + MakeDouble(&fcent.high,10000); + FOREVER + { + if (uOpenDialog("Convert temperature")) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,"Fahrenheit",&ffahr)) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,"Centigrade",&fcent)) + return; + index=uRunDialog(); + if (index<=0) + break; + if (index==2) + { + FahrToCent(¢,&fahr); + Clip(¢); + } + else + { + CentToFahr(&fahr,¢); + Clip(&fahr); + } + } + } + +LOCAL_C VOID Convert(TEXT *pmt1,TEXT *pmt2,INT high1,INT high2) + { + DOUBLE val1; + DOUBLE val2; + H_DI_FLOAT fled1; + H_DI_FLOAT fled2; + INT index; + DOUBLE ratio; + + ZeroDouble(&val1); + ZeroDouble(&val2); + fled1.value=(&val1); + ZeroDouble(&fled1.low); + MakeDouble(&fled1.high,high1); + fled2.value=(&val2); + ZeroDouble(&fled2.low); + MakeDouble(&fled2.high,high2); + p_fld(&ratio,&fled2.high); + p_fdiv(&ratio,&fled1.high); + FOREVER + { + if (uOpenDialog("Convert")) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,pmt1,&fled1)) + return; + if (uAddDialogItem(H_DIALOG_FLOAT,pmt2,&fled2)) + return; + index=uRunDialog(); + if (index<=0) + break; + if (index==2) + { + p_fld(&val2,&val1); + p_fmul(&val2,&ratio); + Clip(&val2); + } + else + { + p_fld(&val1,&val2); + p_fdiv(&val1,&ratio); + Clip(&val1); + } + } + } + +LOCAL_C VOID InchAndCm(VOID) + { + Convert("Inches","Centimetres",10000,25400); + } + +LOCAL_C VOID MileAndKm(VOID) + { + Convert("Miles","Kilometres",20000,32187); + } + +LOCAL_C VOID PoundAndKg(VOID) + { + Convert("Pounds","Kilograms",31938,14500); + } + +LOCAL_C VOID PintAndL(VOID) + { + Convert("Pints","Litres",28156,16000); + } + +LOCAL_C VOID ChangeNdp(VOID) + { + LONG lndp; + H_DI_NUMBER num; + + if (uOpenDialog("Level of significance")) + return; + lndp=ndp; + num.value=(&lndp); + num.low=0; + num.high=4; + if (uAddDialogItem(H_DIALOG_NUMBER,"Decimal places",&num)) + return; + if (uRunDialog()<=0) + return; + ndp=(WORD)lndp; + CalcSmall(); + } + +LOCAL_C VOID SetUpDiDate(H_DI_DATE *pdate,P_DAYSEC *pds) + { + ULONG sdate; + + sdate=p_date(); + p_sttods(&sdate,pds); + pdate->value=(&pds->day); + pdate->low=0; + pdate->high=H_LAST_DAY; + } + +LOCAL_C VOID DayOfWeek(VOID) + { + P_DAYSEC ds; + H_DI_DATE date; + TEXT buf[40]; + H_DI_TEXT txt; + + SetUpDiDate(&date,&ds); + do + { + p_nmday(&buf[1],p_wkday(ds.day)); + buf[0]=p_slen(&buf[1]); + txt.str=(&buf[0]); + txt.type=H_DTEXT_ALIGN_LEFT; + if (uOpenDialog("Find day of week")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"Date",&date)) + return; + if (uAddDialogItem(H_DIALOG_TEXT,"Day of week",&txt)) + return; + } while (uRunDialog()>0); + } + +LOCAL_D TEXT *orient[]= + { + "Rat","Cow","Tiger","Rabbit","Dragon","Snake", + "Horse","Sheep","Monkey","Rooster","Dog","Pig" + }; + +LOCAL_D TEXT *western[]= + { + "Capricorn","Aquarius","Pisces","Aries","Taurus","Gemini", + "Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius" + }; + +LOCAL_C INT Zodiac(P_DATE *pdt) + { + INT ret; + LOCAL_D changeover[12]={19,18,19,19,20,20,22,22,22,22,21,20}; + + ret=pdt->month; + if (pdt->day>changeover[ret]) + { + if (ret++==11) + ret=0; + } + return(ret); + } + +LOCAL_C VOID Horoscope(VOID) + { + P_DAYSEC ds; + H_DI_DATE date; + P_DATE dt; + INT key; + TEXT buf[40]; + + SetUpDiDate(&date,&ds); + FOREVER + { + if (uOpenDialog("Horoscope")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"Date of birth",&date)) + return; + if (uAddButtonList("Stop",W_KEY_ESCAPE, + "Western",'w',"Oriental",'o',NULL)) + return; + key=uRunDialog(); + if (key<=0) + return; + p_dstodt(&ds,&dt); + if (key=='o') + p_atos(&buf[0],"Oriental horoscope is %s",orient[dt.year%12]); + else + p_atos(&buf[0],"Western horoscope is %s",western[Zodiac(&dt)]); + wInfoMsg(&buf[0]); + } + } + +LOCAL_C INT AddListOfDays(UWORD *pdiw) + { + H_DI_CHOICE ch; + TEXT nam[32]; + INT i; + + if (uBeginDCL(&ch)) + return(-1); + for (i=0; i<7; i++) + { + p_nmday(&nam[0],i); + if (uGrowDCL(&ch,&nam[0])) + return(-1); + } + return(uAddDCL("Day in week",pdiw,&ch)); + } + +LOCAL_C VOID SetUpTime(H_DI_TIME *ptime,P_DAYSEC *pds) + { + ptime->value=(&pds->sec); + ptime->low=0; + ptime->high=P_NSECDAY-1; + ptime->type=H_DTIME_SHOW_SECONDS; + } + +LOCAL_C VOID TimeDifference(VOID) + { + P_DAYSEC ds1; + H_DI_DATE date1; + H_DI_TIME time1; + P_DAYSEC ds2; + H_DI_DATE date2; + H_DI_TIME time2; + LONG diff; + TEXT buf[40]; + + SetUpDiDate(&date1,&ds1); + SetUpDiDate(&date2,&ds2); + SetUpTime(&time1,&ds1); + SetUpTime(&time2,&ds2); + FOREVER + { + if (uOpenDialog("Time difference")) + return; + if (uAddDialogItem(H_DIALOG_DATE,"From",&date1)) + return; + if (uAddDialogItem(H_DIALOG_TIME,"",&time1)) + return; + if (uAddDialogItem(H_DIALOG_DATE,"To",&date2)) + return; + if (uAddDialogItem(H_DIALOG_TIME,"",&time2)) + return; + if (uRunDialog()<=0) + return; + diff=ds2.day-ds1.day; + if (diff<0 || !diff && ds2.sec0x7fffffffl/P_NSECDAY) + { + wInfoMsg("Dates are too far apart"); + continue; + } + p_atos(&buf[0],"Dates are %ld seconds apart", + diff*P_NSECDAY+ds2.sec-ds1.sec); + wInfoMsg(&buf[0]); + } + } + +LOCAL_C INT AddNoYesChoiceList(TEXT *pmt,UWORD *pval) + { + return(uAddChoiceList(pmt,pval,"No","Yes",NULL)); + } + +LOCAL_C VOID TimeNow(VOID) + { + INT values; + H_DI_TEXT txt; + TEXT buf[48]; + + txt.str=(&buf[0]); + do + { + if (uOpenDialog(NULL)) + return; + uZTStoBCS(&buf[0],"Time is now"); + txt.type=H_DTEXT_ALIGN_CENTRE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + values=0; + if (ttMonth==2) + values=H_TIME_FORMAT_MONTH_NAME; + if (ttDay==2) + values|=H_TIME_FORMAT_DAY_NAME; + if (ttSuffix==2) + values|=H_TIME_FORMAT_SUFFIX; + if (ttCentury==1) + values|=H_TIME_FORMAT_NO_CENTURY; + if (ttSeconds==1) + values|=H_TIME_FORMAT_NO_SECONDS; + hTTSetFormat(ttH,values); + hTTSetTime(ttH,H_TIME_SET_NOW,NULL); + buf[0]=hTTSenseString(ttH,H_TIME_SENSE_BOTH,&buf[1]); + txt.type=H_DTEXT_ALIGN_CENTRE|H_DTEXT_UNDERLINE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + if (AddNoYesChoiceList("Give month name",&ttMonth)) + return; + if (AddNoYesChoiceList("Give day name",&ttDay)) + return; + if (AddNoYesChoiceList("Use date suffix",&ttSuffix)) + return; + if (AddNoYesChoiceList("Show century",&ttCentury)) + return; + if (AddNoYesChoiceList("Show seconds",&ttSeconds)) + return; + } while (uRunDialog()>0); + } + +LOCAL_C VOID EnterPassword(VOID) + { + TEXT pass1[10]; + TEXT pass2[10]; + H_DI_XINPUT x1; + H_DI_XINPUT x2; + + x1.str=(&pass1[0]); + x2.str=(&pass2[0]); + FOREVER + { + if (uOpenDialog(NULL)) + return; + if (uAddDialogItem(H_DIALOG_XINPUT,"Define password",&x1)) + return; + if (uAddDialogItem(H_DIALOG_XINPUT,"Confirm password",&x2)) + return; + if (uRunDialog()<=0) + return; + if (p_bcmpi(&pass1[1],pass1[0],&pass2[1],pass2[0])) + { + wInfoMsg("Password not confirmed"); + continue; + } + if (pass1[0]) + break; + wInfoMsg("Please supply password"); + } + p_bfil(&pass[0],10,0); + p_bcpy(&pass[0],&pass1[0],pass1[0]+1); + } + +LOCAL_C VOID MakeReadable(TEXT *out,TEXT *in) + { + INT len; + INT i; + INT val; + + i=32; + len=(*in++); + *out++=len*2; + while (len--) + { + val=(*in++); + *out++=i+(val&0xf); + i+=16; + *out++=i+(val>>4); + if (i==112) + i=32; + else + i+=16; + } + } + +LOCAL_C VOID MakeUnreadable(TEXT *out,TEXT *in) + { + INT len; + INT i; + INT val; + + i=32; + len=(*in++)/2; + *out++=len; + while (len--) + { + val=(*in++)-i; + i+=16; + val+=((*in++)-i)<<4; + *out++=val; + if (i==112) + i=32; + else + i+=16; + } + } + +LOCAL_C VOID Report(TEXT *title,TEXT *mess) + { + H_DI_TEXT txt; + + if (uOpenDialog(title)) + return; + txt.str=mess; + txt.type=H_DTEXT_ALIGN_CENTRE; + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + uRunDialog(); + } + +LOCAL_C VOID EncryptMessage(VOID) + { + P_MASK mask; + H_DI_EDIT ed; + TEXT in[20]; + TEXT out[38]; + + if (!pass[0]) + { + wInfoMsg("Can't encrypt with no password set"); + return; + } + p_setmask((VOID **)&mask,&pass[1]); + if (uOpenDialog("Encrypt message")) + return; + ed.str=(&in[0]); + ed.len=18; + in[0]=0; + if (uAddDialogItem(H_DIALOG_EDIT,"Message",&ed)) + return; + if (uRunDialog()<=0) + return; + p_encrypt(&mask,&in[1],in[0]); + MakeReadable(&out[0],&in[0]); + Report("Encrypted message",&out[0]); + } + +LOCAL_C VOID DecryptMessage(VOID) + { + P_MASK mask; + H_DI_SEDIT sed; + TEXT in[38]; + TEXT out[20]; + + if (!pass[0]) + { + wInfoMsg("Can't decrypt with no password set"); + return; + } + p_setmask((VOID **)&mask,&pass[1]); + if (uOpenDialog("Decrypt message")) + return; + sed.str=(&in[0]); + sed.len=36; + sed.width=16; + in[0]=0; + if (uAddDialogItem(H_DIALOG_SEDIT,"Message",&sed)) + return; + if (uRunDialog()<=0) + return; + MakeUnreadable(&out[0],&in[0]); + p_decrypt(&mask,&out[1],out[0]); + Report("Decrypted message",&out[0]); + } + +LOCAL_C VOID FileSize(VOID) + { + TEXT fname[P_FNAMESIZE+2]; + H_DI_FSEL fsel; + P_INFO info; + TEXT buf[30]; + + fname[0]=0; + fsel.fname=(&fname[0]); + fsel.flags=H_FILE_PICK_SELECTOR; + FOREVER + { + if (uOpenDialog("Find file size")) + return; + if (uAddDialogItem(H_DIALOG_FSEL,"File:",&fsel)) + return; + if (uRunDialog()<=0) + return; + fname[1+fname[0]]=0; + if (!uErrorValue(p_finfo(&fname[1],&info))) + { + p_atos(&buf[0],"File size is %lu bytes",info.size); + wInfoMsg(&buf[0]); + } + } + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case ITEMS_BEFORE_CONVERT: + InchAndCm(); + break; + case ITEMS_BEFORE_CONVERT+1: + MileAndKm(); + break; + case ITEMS_BEFORE_CONVERT+2: + PoundAndKg(); + break; + case ITEMS_BEFORE_CONVERT+3: + PintAndL(); + break; + case ITEMS_BEFORE_CONVERT+4: + Temperatures(); + break; + case ITEMS_BEFORE_CALENDAR: + DayOfWeek(); + break; + case ITEMS_BEFORE_CALENDAR+1: + hOODialog(DylHandle,C_OQD_COMBINS,OQD_DATE_COMBINS,NULL); + break; + case ITEMS_BEFORE_CALENDAR+2: + TimeDifference(); + break; + case ITEMS_BEFORE_CALENDAR+3: + Horoscope(); + break; + case ITEMS_BEFORE_CALENDAR+4: + TimeNow(); + break; + case ITEMS_BEFORE_SECRET: + EnterPassword(); + break; + case ITEMS_BEFORE_SECRET+1: + EncryptMessage(); + break; + case ITEMS_BEFORE_SECRET+2: + DecryptMessage(); + break; + case ITEMS_BEFORE_SPECIAL: + ChangeNdp(); + break; + case ITEMS_BEFORE_SPECIAL+1: + FileSize(); + break; + case ITEMS_BEFORE_SPECIAL+2: + p_exit(0); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + p_exit(0); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + } + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=80; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(MainWid); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + hInitAppRcb(); + DylHandle=hLoadOwnDyl(0); + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + CalcSmall(); + ttH=hTTOpen(); + } + +GLDEF_C VOID main(VOID) + { + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/hwifood/oquery.dfl b/code/SIBOSDK/hwifood/oquery.dfl new file mode 100644 index 0000000..32b2b76 --- /dev/null +++ b/code/SIBOSDK/hwifood/oquery.dfl @@ -0,0 +1 @@ +oqd.dyl diff --git a/code/SIBOSDK/hwifood/oquery.pr b/code/SIBOSDK/hwifood/oquery.pr new file mode 100644 index 0000000..1e93326 --- /dev/null +++ b/code/SIBOSDK/hwifood/oquery.pr @@ -0,0 +1,17 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile oquery.c + +#if %remake #or (oqd.dyl #older oquery.img) #or (oquery.dfl #older oquery.img) #then + #file delete oquery.img +#endif + +#pragma link(hwif.lib) + +#if (oquery.img #older oquery.afl) #or (oquery.img #older oquery.pic) #then + #file delete oquery.img +#endif + +#link oquery.img diff --git a/code/SIBOSDK/hwifood/oquery.rss b/code/SIBOSDK/hwifood/oquery.rss new file mode 100644 index 0000000..830f0b5 --- /dev/null +++ b/code/SIBOSDK/hwifood/oquery.rss @@ -0,0 +1,80 @@ +#include +#include + +RESOURCE MENU oqm_daynames + { + items = + { + CHOICE_ITEM { str="Monday";}, + CHOICE_ITEM { str="Tuesday";}, + CHOICE_ITEM { str="Wednesday";}, + CHOICE_ITEM { str="Thursday";}, + CHOICE_ITEM { str="Friday";}, + CHOICE_ITEM { str="Saturday";}, + CHOICE_ITEM { str="Sunday";} + }; + } + +RESOURCE ACLIST_ARRAY oqa_date_combins + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Stop"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Backwards"; + }, + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Forwards"; + } + }; + } + +RESOURCE DIALOG oqd_date_combins + { + title="Find date combinations"; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Day in week"; + info=CHLIST { rid=oqm_daynames; }; + }, + CONTROL + { + class=C_NCEDIT; + prompt="Day in month"; + info=NCEDIT + { + low=1; + high=31; + }; + }, + CONTROL + { + class=C_DTEDIT; + prompt="Found date"; + info=DTEDIT + { + flags=IN_DTEDIT_DDMMYYYY|IN_DTEDIT_INIT; + low=0; + high=93501l; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST { rid=oqa_date_combins; }; + } + }; + } + +RESOURCE STRING oqs_no_further_matches { str="No further matches"; } diff --git a/code/SIBOSDK/hwifood/query.ms b/code/SIBOSDK/hwifood/query.ms new file mode 100644 index 0000000..900368a --- /dev/null +++ b/code/SIBOSDK/hwifood/query.ms @@ -0,0 +1 @@ +Query diff --git a/code/SIBOSDK/hwifood/query.pic b/code/SIBOSDK/hwifood/query.pic new file mode 100644 index 0000000..8ab3856 Binary files /dev/null and b/code/SIBOSDK/hwifood/query.pic differ diff --git a/code/SIBOSDK/hwifood/query.shd b/code/SIBOSDK/hwifood/query.shd new file mode 100644 index 0000000..97e58fc Binary files /dev/null and b/code/SIBOSDK/hwifood/query.shd differ diff --git a/code/SIBOSDK/hwifsrc/diyhwif.c b/code/SIBOSDK/hwifsrc/diyhwif.c new file mode 100644 index 0000000..40908f1 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/diyhwif.c @@ -0,0 +1,88 @@ +/* + DIYHWIF.C + +Started by DavidW, 6/11/92 + +Routines to access some dialog item classes + +*/ + +#include +#include +#include +#include + +GLREF_D PR_DLGBOX *DatDialogPtr; + +GLDEF_C VOID hDTClose(VOID *dte) + { + p_send2(dte,O_DESTROY); + } + +GLDEF_C VOID hDTSet(VOID *dte,H_SE_DTEDIT *sdte) + { + p_send3(dte,O_WN_SET,sdte); + } + +GLDEF_C VOID hDTSense(VOID *dte,H_SE_DTEDIT *sdte) + { + p_send3(dte,O_WN_SENSE,sdte); + } + +GLDEF_C INT hDTSelfCheck(VOID *dte) + { + INT ret; + + ret=p_send2(dte,O_LG_SELF_CHECK); + return(ret!=LG_CHECK_OK && ret!=LG_CHECK_OK_CHANGED); + } + +GLDEF_C VOID hDTEmphasise(VOID *dte,INT flag) + { + p_send3(dte,O_WN_EMPHASISE,flag); + } + +GLDEF_C INT hDTHandleKey(VOID *dte,INT keycode,INT modifier) + { + return(p_send4(dte,O_WN_KEY,keycode,modifier)); + } + +GLDEF_C VOID *hDTOpen(H_DTEDIT *dte) + { + VOID *self; + PR_WIN win; + + self=uCheckHandle(p_new(CAT_HWIF_HWIM,C_DTEDIT)); + if (self) + { + win.win.id=dte->win; + p_send4(self,O_WN_INIT,dte,&win); + p_send5(self,O_LG_SET_ID_POS,dte->win,&dte->pos,dte->width); + hDTEmphasise(self,dte->emph); + } + return(self); + } + +GLDEF_C VOID hSetVarrayInChlist(INT index,INT nsel,VOID *varray) + { + SE_CHLIST set; + + set.nsel=nsel; + set.data=varray; + set.set_flags=SE_CHLIST_DATA|SE_CHLIST_NSEL|SE_CHLIST_RETAIN; + p_send4(DatDialogPtr,O_WN_SET,index,&set); + } + +GLDEF_C VOID uSetDialogUline(INT pos,INT on) + { + DLGBOX_ITEM *pitm; + + pitm=(DatDialogPtr->dlgbox.count>7)? + DatDialogPtr->dlgbox.u.pitm+pos: + &DatDialogPtr->dlgbox.u.item[pos]; + if (on) + pitm->flags|=DLGBOX_ITEM_UNDERLINED; + else + pitm->flags&=(~DLGBOX_ITEM_UNDERLINED); + } + diff --git a/code/SIBOSDK/hwifsrc/ehwif.c b/code/SIBOSDK/hwifsrc/ehwif.c new file mode 100644 index 0000000..f69cab0 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/ehwif.c @@ -0,0 +1,276 @@ +/* + EHWIF.C + +Started by DavidW, 5/12/91 + +Edit box extension to h layer of hwif + +*/ + +#include +#include +#include +#include +#include + +GLDEF_D UWORD _ebControlFormat=FALSE; + +#define EebH ((PR_EDWIN *)ebH) + + +#pragma save,ENTER_CALL + +LOCAL_C INT DoEntersend(VOID *ebH,INT method,VOID *p1,VOID *p2,VOID *p3) + { + p_send5(ebH,method,p1,p2,p3); + return(0); + } + +#pragma restore + +LOCAL_C INT Entersend(VOID *ebH,INT method,VOID *p1,VOID *p2,VOID *p3) + { + INT ret; + + ret=p_enter6(DoEntersend,ebH,method,p1,p2,p3); + if (ret<-1) + uErrorValue(ret); + return(ret); + } + +#define V (VOID*) + +GLDEF_C INT hEBCompleteFormat(VOID *ebH) + { + PR_SCRIMG *scrimg; + INT ret; + + scrimg=EebH->edwin.scrimg; + if (!scrimg->scrimg.formatting) + return(0); + ret=Entersend(scrimg,O_SI_SET,0,0,0); + p_send2(scrimg->scrimg.wrap,O_AO_CANCEL); + return(ret); + } + +GLDEF_C INT hEBHandleKey(VOID *ebH,INT keycode,INT modifier) + { + INT ret; + + if (keycode==W_KEY_RETURN) + modifier|=W_SHIFT_MODIFIER; + ret=Entersend(ebH,O_WN_KEY,V keycode,V modifier,NULL); + if (!ret && !_ebControlFormat) + ret=hEBCompleteFormat(ebH); + return(ret); + } + +GLDEF_C VOID hEBClose(VOID *ebH) + { + p_send2(ebH,O_DESTROY); + } + +GLDEF_C TEXT *hEBSenseText(VOID *ebH) + { + SE_EDWIN sense; + + p_send3(ebH,O_WN_SENSE,&sense); + return(sense.buf); + } + +GLDEF_C INT hEBSetText(VOID *ebH,TEXT *pb,INT blen) + { + SE_EDWIN set; + + set.buf=pb; + set.len=blen; + return(Entersend(ebH,O_WN_SET,&set,NULL,NULL)); + } + +GLDEF_C VOID hEBEmphasise(VOID *ebH,INT flag) + { + p_send3(ebH,O_WN_EMPHASISE,flag); + } + +GLDEF_C INT hEBSetSelect(VOID *ebH,INT aoff,INT coff) + { + SET_EDWIN set; + + set.flags=SET_EDWIN_CURSOR|SET_EDWIN_ANCHOR; + set.anchor=aoff; + set.cursor=coff; + return(Entersend(ebH,O_EW_SET,&set,NULL,NULL)); + } + +GLDEF_C INT hEBSenseSelect(VOID *ebH,UWORD *top) + { + return(p_send3(EebH->edwin.scrimg,O_SI_GET_SELECT,top)); + } + +GLDEF_C INT hEBSetClipText(VOID *ebH,TEXT *pb,INT blen) + { + return(Entersend(EebH->edwin.clip,O_EP_SET_TEXT,pb,V blen,0)); + } + +GLDEF_C TEXT *hEBSenseClipText(VOID *ebH) + { + TEXT *pb; + + p_send3(EebH->edwin.clip,O_EF_SENSE_BUF,&pb); + return(pb); + } + +GLDEF_C INT hEBEvaluate(VOID *ebH) + { + return(Entersend(ebH,O_EW_EVALUATE,NULL,NULL,NULL)); + } + +GLDEF_C INT hEBChangeWidth(VOID *ebH,INT width) + { + P_EXTENT ext; + + p_send3(ebH,O_EW_SENSE_SIZE,&ext); + EebH->edwin.margins.right+=width-ext.width; + ext.width=width; + return(Entersend(ebH,O_EW_SET_SIZE,&ext,NULL,NULL)); + } + +GLDEF_C INT hEBSetMargin(VOID *ebH,UINT right) + { + INT ret; + UINT oright; + + oright=EebH->edwin.margins.right; + EebH->edwin.margins.right=right; + ret=Entersend(EebH->edwin.scrimg, + O_SI_STYLE_CHANGED,SCRIMG_STCHNG_DOC,NULL,NULL); + if (ret<0) + EebH->edwin.margins.right=oright; + return(ret); + } + +GLDEF_C UINT hEBSenseMargin(VOID *ebH) + { + return(EebH->edwin.margins.right); + } + +GLDEF_C INT hEBInsert(VOID *ebH,TEXT *pb,INT blen) + { + return(Entersend(ebH,O_EW_INSERT,pb,V blen,NULL)); + } + +GLDEF_C INT hEBReplace(VOID *ebH,TEXT *replace,INT backwards) + { + return(Entersend(ebH,O_EW_REPLACE,replace,V backwards,NULL)); + } + +GLDEF_C INT hEBCopy(VOID *ebH) + { + if (!(EebH->edwin.select)) + return(1); + return(Entersend(ebH,O_EW_REPLACE_CLIP,NULL,NULL,NULL)); + } + +GLDEF_C INT hEBPaste(VOID *ebH) + { + if (!(p_send2(EebH->edwin.clip,O_EP_SENSE_LEN))) + return(1); + return(Entersend(ebH,O_EW_PASTE_CLIP,NULL,NULL,NULL)); + } + +GLDEF_C INT hEBFind(VOID *ebH,TEXT *str,INT flags) + { + return(p_send4(ebH,O_EW_FIND,str,flags)); + } + +GLDEF_C INT hEBSenseChanged(VOID *ebH) + { + return(EebH->edwin.change); + } + +GLDEF_C VOID hEBClearChanged(VOID *ebH) + { + EebH->edwin.change=FALSE; + } + +GLDEF_C VOID hEBSetCWidth(VOID *ebH,INT cwidth) + { + SCRIMG_WIN win; + + p_send3(EebH->edwin.scrimg,O_SI_SENSE,&win); + win.cwidth=cwidth; + Entersend(EebH->edwin.scrimg,O_SI_SET,&win,NULL,NULL); + } + + +GLDEF_C INT hEBShowSymbols(VOID *ebH,INT flag) + { + SCRLAY_STYLE style; + + p_send3(EebH->edwin.scrlay,O_SL_SENSE,&style); + style.options=FALSE; + if (flag) + style.options=SCRLAY_SHOW_SPACES|SCRLAY_SHOW_LFS; + p_send3(EebH->edwin.scrlay,O_SL_SET,&style); + return(Entersend(EebH->edwin.scrimg,O_SI_STYLE_CHANGED,0,0,0)); + } + +GLDEF_C VOID *hEBOpen(INT flags,H_EDIT_BOX *heb) + { + VOID *ebH; + IN_EDWIN in; + IN_EDWIN_X inx; + PR_WIN win; + + ebH=uCheckHandle(p_new(CAT_HWIF_HWIM,C_EDWIN)); + if (!ebH) + return(NULL); + win.win.id=heb->win; + in.vulen=heb->vulen; + in.flags=flags|IN_EDWIN_VULEN_PIXELS + |IN_EDWIN_NO_AUTOSELECT|IN_EDWIN_POSITION_SUPPLIED; + in.maxlen=heb->maxchars; + in.contents[0]=0; + inx.vislines=heb->vislines; + inx.pos=heb->pos; + inx.font=heb->font; + inx.style=heb->style; + inx.leading.total=heb->lead_tot; + inx.leading.top=heb->lead_top; + inx.clip=NULL; + if (Entersend(ebH,O_WN_INIT,&in,&win,&inx)) + { + hEBClose(ebH); + return(NULL); + } + return(ebH); + } + +GLDEF_C VOID *hEBSenseDoc(VOID *ebH) + { + return(EebH->edwin.doc); + } + +GLDEF_C INT hEDCapacity(VOID *doc,UINT maxlen) + { + return(Entersend(doc,O_EP_CAPACITY,V (maxlen+1),NULL,NULL)); + } + +GLDEF_C INT hEDInsert(VOID *doc,UINT pos,VOID *buf,UINT len) + { + return(Entersend(doc,O_EP_INSERT,V pos,buf,V len)); + } + +GLDEF_C INT hEBDocChanged(VOID *ebH) + { + UINT doclen; + + doclen=p_send2(EebH->edwin.doc,O_EP_SENSE_LEN); + EebH->edwin.clen=doclen+1; + return(Entersend(EebH->edwin.scrimg,O_SI_DOC_CHANGED,V doclen,NULL,NULL)); + } + +GLDEF_C INT hEBPosToXL(void *ebH,H_SCRLAY_PLX *plx) + { + return(p_send3(EebH->edwin.scrlay,O_SL_POS_TO_XL,plx)); + } diff --git a/code/SIBOSDK/hwifsrc/hhwif.c b/code/SIBOSDK/hwifsrc/hhwif.c new file mode 100644 index 0000000..caa6d48 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/hhwif.c @@ -0,0 +1,209 @@ +/* + HHWIF.C + +Started by Huw 11/3/91 + +Routines for supplying menus and dialogs for non OOP users +such as OPL/W +*/ + +#include +#include +#include +#include +#include + +GLREF_D PR_GATE *DatGate; +GLDEF_D UWORD _UseFullScreen; +GLDEF_D UWORD *_GreyLines; +GLDEF_D UWORD *_MenuPositions; +GLDEF_D UWORD _SmallFontDialog; + +GLDEF_C INT hIFInit(VOID *console) +/* +Initialise HWIM interface +*/ + { + if (!(DatGate=p_new(CAT_HWIF_HWIM,C_GATE))) + return(E_GEN_NOMEMORY); + if (_UseFullScreen) + p_send2(DatGate,O_GT_XW_ENABLE); + return(p_send3(DatGate,O_GT_INIT,console)); + } + +GLDEF_C INT hMenuOpen() +/* +Create a new menu bar +*/ + { + return(p_send2(DatGate,O_GT_MENU_OPEN)); + } + +GLDEF_C INT hMenuAdd(TEXT *title,VOID *menu) +/* +Add another menu to the menu bar +*/ + { + return(p_send4(DatGate,O_GT_MENU_ADD,title,menu)); + } + +GLDEF_C INT hMenuRun() +/* +Display and use the menu bar + +Note that due to the addition of 'gate.g.dx' in os 356 and above, the +property 'gate.g.ulines' is in different places on different models. + +Older models will be expecting the greyline data to be where later +models look for 'gate.g.dx', so a test is required to determine where +to copy the greyline data to. +*/ + { + if (_GreyLines) + { + p_bcpy((BYTE *)&DatGate->gate.g.ulines[0]-((p_version()>0x355f)?0: + sizeof(DLG_X_CONSTANTS)),_GreyLines,16*sizeof(UWORD)); + } + return(p_send3(DatGate,O_GT_MENU_RUN,_MenuPositions)); + } + +GLDEF_C VOID hMenuClose() +/* +Close an incomplete menu bar down +*/ + { + p_send2(DatGate,O_GT_MENU_CLOSE); + } + +GLDEF_C INT hDlgOpen(TEXT *title) +/* +Create a new dialog +*/ + { + INT method; + + method=O_GT_DIAL_OPEN; + if (_SmallFontDialog) + { + method=O_GT_DIAL_SOPEN; + _SmallFontDialog=FALSE; + } + return(p_send3(DatGate,method,title)); + } + +GLDEF_C INT hDlgAdd(UWORD type,TEXT *prompt,VOID *data) +/* +Add an item to the dialog +*/ + { + return(p_send5(DatGate,O_GT_DIAL_ADD,type,prompt,data)); + } + +GLDEF_C INT hDlgRun() +/* +Display and use the dialog +*/ + { + return(p_send2(DatGate,O_GT_DIAL_RUN)); + } + +GLDEF_C VOID hDlgClose() +/* +Close an incomplete dialog down +*/ + { + p_send2(DatGate,O_GT_DIAL_CLOSE); + } + +GLDEF_C VOID *hCardOpen() +/* +Open a menu card for building +*/ + { + return((VOID *)p_send2(DatGate,O_GT_CARD_OPEN)); + } + +GLDEF_C INT hCardAdd(VOID *hand,INT index,INT accel,TEXT *str) +/* +Add an item to a menu card +*/ + { + H_CARD card; + + card.accel=accel; + card.str=str; + return(p_send5(DatGate,O_GT_CARD_ADD,hand,index,&card)); + } + +GLDEF_C VOID hCardClose(VOID *hand) +/* +Discard a menu card +*/ + { + p_send3(DatGate,O_GT_CARD_CLOSE,hand); + } + +GLDEF_C VOID *hChoiceOpen() +/* +Open a choice list for building +*/ + { + return((VOID *)p_send2(DatGate,O_GT_CHOICE_OPEN)); + } + +GLDEF_C INT hChoiceAdd(VOID *hand,INT index,TEXT *str) +/* +Add an item to a choice list +*/ + { + H_CHOICE choice; + + choice.str=str; + return(p_send5(DatGate,O_GT_CHOICE_ADD,hand,index,&choice)); + } + +GLDEF_C VOID hChoiceClose(VOID *hand) +/* +Discard a choice list +*/ + { + p_send3(DatGate,O_GT_CHOICE_CLOSE,hand); + } + +GLDEF_C VOID *hButtonOpen() +/* +Open a action list for building +*/ + { + return((VOID *)p_send2(DatGate,O_GT_BUTTON_OPEN)); + } + +GLDEF_C INT hButtonAdd(VOID *hand,INT index,INT key,TEXT *str) +/* +Add a button to an action list +*/ + { + H_BUTTON but; + + but.keycode=key; + but.str=str; + return(p_send5(DatGate,O_GT_BUTTON_ADD,hand,index,&but)); + } + +GLDEF_C VOID hButtonClose(VOID *hand) +/* +Discard an action list +*/ + { + p_send3(DatGate,O_GT_BUTTON_CLOSE,hand); + } + +GLDEF_C INT hDlgPosition(INT x,INT y) + { + return(p_send4(DatGate,O_GT_DIAL_POSITION,x,y)); + } + +GLDEF_C UINT hLastSystemKey(UINT *pmodifiers) + { + return(p_send3(DatGate,O_GT_LAST_KEY,pmodifiers)); + } diff --git a/code/SIBOSDK/hwifsrc/hwif.cat b/code/SIBOSDK/hwifsrc/hwif.cat new file mode 100644 index 0000000..2c49dec --- /dev/null +++ b/code/SIBOSDK/hwifsrc/hwif.cat @@ -0,0 +1,23 @@ +IMAGE hwif + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE lprinter.g +INCLUDE help.g + +CLASS hprinter lprinter + { + REPLACE lpr_read + REPLACE lpr_sense_text + PROPERTY + { + INT (*sense)(WDR_PRINT *); + } + } + +CLASS hhelpdlg helpdlg + { + REPLACE destroy + } + diff --git a/code/SIBOSDK/hwifsrc/hwif.h b/code/SIBOSDK/hwifsrc/hwif.h new file mode 100644 index 0000000..47015ec --- /dev/null +++ b/code/SIBOSDK/hwifsrc/hwif.h @@ -0,0 +1,339 @@ +/* HEADER - HWIF.H +Copyright (C) Psion PLC 1992 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.20F 08/11/92 DWW New version for Developers Conference +2.00F 01/12/93 DWW Version 2 C SDK +*/ +#ifndef HWIF_H +#define HWIF_H + +#include +#include + +#ifdef STDEPOC_H +# include +#else +# ifndef EPOCCONS_H +# include +# endif +#endif + +typedef struct + { + char *title; + unsigned short int nlines; + } H_MENU_DATA; +#define H_DIALOG_TEXT 0 +#define H_DIALOG_CHOICE 1 +#define H_DIALOG_NUMBER 2 +#define H_DIALOG_FLOAT 3 +#define H_DIALOG_TIME 4 +#define H_DIALOG_DATE 5 +#define H_DIALOG_EDIT 6 +#define H_DIALOG_SEDIT 7 +#define H_DIALOG_XINPUT 8 +#define H_DIALOG_FSEL 9 +#define H_DIALOG_BUTTONS 10 +typedef struct + { + char *str; + unsigned short int type; + } H_DI_TEXT; +#define H_DTEXT_ALIGN_LEFT 0 +#define H_DTEXT_ALIGN_RIGHT 1 +#define H_DTEXT_ALIGN_CENTRE 2 +#define H_DTEXT_BOLD 0x100 +#define H_DTEXT_UNDERLINE 0x200 +#define H_DTEXT_SELECTABLE 0x400 +typedef struct + { + union + { + unsigned short int *sel; + unsigned short int count; + } u; + void *menu; + } H_DI_CHOICE; +typedef struct + { + long int *value; + long int low; + long int high; + } H_DI_NUMBER; +typedef struct + { + double *value; + double low; + double high; + } H_DI_FLOAT; +typedef struct + { + unsigned long int *value; + unsigned long int low; + unsigned long int high; + unsigned short int type; + } H_DI_TIME; +#define H_DTIME_SHOW_SECONDS 1 +#define H_DTIME_DURATION 2 +typedef struct + { + unsigned long int *value; + unsigned long int low; + unsigned long int high; + } H_DI_DATE; +#define H_LAST_DAY 93501l +#define H_FIRST_SYS_DAY 25567l +#define H_LAST_SYS_DAY 75276l +typedef struct + { + char *str; + unsigned short int len; + } H_DI_EDIT; +typedef struct + { + char *str; + unsigned short int len; + unsigned short int width; + } H_DI_SEDIT; +typedef struct + { + char *str; + } H_DI_XINPUT; +typedef struct + { + char *fname; + unsigned short int flags; + } H_DI_FSEL; +typedef struct + { + char *str; + short int accel; + } H_CARD; +typedef struct + { + char *str; + } H_CHOICE; +typedef struct + { + char *str; + unsigned short int keycode; + } H_BUTTON; +#define W_EVENT_KEY (CONS_SPECIAL_EVENT*256) +#define H_FILE_ALLOW_DIRS 0x02 +#define H_FILE_JUST_DIRS 0x04 +#define H_FILE_FORCE_NXIST 0x08 +#define H_FILE_NO_AUTOQUERY 0x10 +#define H_FILE_ACCEPT_NULL 0x20 +#define H_FILE_SET_DEFEXT 0x40 +#define H_FILE_CAN_WILDCARD 0x80 +#define H_FILE_RESTRICT_LIST H_FILE_FORCE_NXIST +#define H_FILE_PICK_SELECTOR 0 +#define H_FILE_NEW_EDITOR 0x01 +#define H_PRINT_PAGE 0x01 +#define H_PRINT_LINE 0x02 +#define H_PRINT_RIGHT 0x04 +#define H_PRINT_TEXT 0x10 +#define H_PRINT_KEEP 0x8000 +#define H_PRINT_STY_UNDERLINE 0x01 +#define H_PRINT_STY_BOLD 0x02 +#define H_PRINT_STY_ITALIC 0x04 +#define H_PRINT_STY_SUPER 0x08 +#define H_PRINT_STY_SUB 0x10 +typedef struct + { + short int flags; + short int typf; + short int fheight; + short int style; + short int down; + short int indent; + short int height; + short int right; + char *buf; + unsigned short int blen; + } H_PRINT; +#define H_TIME_SET_SDATE 0 +#define H_TIME_SET_DATE 1 +#define H_TIME_SET_DAYSEC 2 +#define H_TIME_SET_NOW 3 +#define H_TIME_SENSE_BOTH 3 +#define H_TIME_SENSE_DATE 4 +#define H_TIME_SENSE_TIME 5 +#define H_TIME_FORMAT_NO_DAY 0x0004 +#define H_TIME_FORMAT_NO_MONTH 0x0008 +#define H_TIME_FORMAT_NO_YEAR 0x0010 +#define H_TIME_FORMAT_MONTH_NAME 0x0020 +#define H_TIME_FORMAT_SUFFIX 0x0040 +#define H_TIME_FORMAT_DAY_NAME 0x0080 +#define H_TIME_FORMAT_NO_CENTURY 0x0100 +#define H_TIME_FORMAT_NO_SECONDS 0x0200 +#define H_ALARM_TIMED 2 +#define H_ALARM_UNTIMED 1 +typedef struct + { + unsigned short int maxchars; + unsigned short int vulen; + unsigned short int vislines; + P_POINT pos; + unsigned short int win; + unsigned short int font; + unsigned short int style; + unsigned short int lead_tot; + unsigned short int lead_top; + } H_EDIT_BOX; +typedef struct + { + unsigned short int pos; + short int line; + short int x; + } H_SCRLAY_PLX; +#define H_EDIT_BOX_CLIPBOARD 0x0040 +#define H_EDIT_BOX_LEFT_CURSOR 0x0200 +#define H_EDIT_BOX_FONT 0x1000 +#define H_EDIT_BOX_LEADING 0x2000 +#define H_EDIT_BOX_VISLINES 0x4000 +#define HEB_FIND_BACKWARDS 0x01 +#define HEB_FIND_CASESENS 0x02 +#define H_DTEDIT_DDMMYYYY 0x0000 +#define H_DTEDIT_HHMMSS 0x1100 +#define H_DTEDIT_HHMM 0x0100 +#define H_DTEDIT_HHMMSS_D 0x1300 +#define H_DTEDIT_HHMM_D 0x0300 +#define H_DTEDIT_SET_VALUE 0x0001 +#define H_DTEDIT_SET_LOW 0x0002 +#define H_DTEDIT_SET_HIGH 0x0004 +typedef struct + { + unsigned short int flags; + long int value; + long int low; + long int high; + P_POINT pos; + unsigned short int win; + unsigned short int width; + unsigned short int emph; + } H_DTEDIT; +typedef struct + { + unsigned short int flags; + long int value; + long int low; + long int high; + } H_SE_DTEDIT; +#ifdef __cplusplus +extern "C" { +#endif +extern int hIFInit(void *); +extern int hMenuOpen(void); +extern int hMenuAdd(char *,void *); +extern int hMenuRun(void); +extern void hMenuClose(void); +extern int hDlgOpen(char *); +extern int hDlgAdd(unsigned short int,char *,void *); +extern int hDlgRun(void); +extern void hDlgClose(void); +extern int hDlgPosition(int x,int y); +extern void *hCardOpen(void); +extern int hCardAdd(void *,int,int,char *); +extern void hCardClose(void *); +extern void *hChoiceOpen(void); +extern int hChoiceAdd(void *,int,char *); +extern void hChoiceClose(void *); +extern void *hButtonOpen(void); +extern int hButtonAdd(void *,int,int,char *); +extern void hButtonClose(void *); +extern void hEnsurePath(char *fname); +extern void hSetUpStatusNames(char *pb); +extern int hCrackCommandLine(void); +extern int hIsDbfCompressible(void *dH); +extern int hDTMFString(char *zts); +extern unsigned int hLastSystemKey(unsigned int *pmodifiers); +extern void uCommonInit(void); +extern void uEnableGrey(void); +extern void uGetKey(WMSG_KEY *pkey); +extern void uGetKeyA(short int *pstat,WMSG_KEY *pkey); +extern void uCancelGetKeyA(void); +extern int uKeyPressOutstanding(void); +extern void uEscape(unsigned short int flag); +extern unsigned int uFindMainWid(void); +extern void uForceToFront(void); +extern void uErrorString(char *message); +extern int uErrorValue(int ret); +extern void *uCheckHandle(void *handle); +extern void uZTStoBCS(char *bcs,char *zts); +extern int uOpenDialog(char *title); +extern int uAddDialogItem(int type,char *prompt,void *data); +extern int uRunDialog(void); +extern int cdecl uAddButtonList(char *but,int code,...); +extern int uBeginDCL(H_DI_CHOICE *pch); +extern int uGrowDCL(H_DI_CHOICE *pch,char *choice); +extern int uAddDCL(char *prompt,unsigned short int *nsel,H_DI_CHOICE *pch); +extern int cdecl uAddChoiceList(char *prompt,unsigned short int *nsel,char *choice,...); +extern int cdecl uDialogMenu(char *title,char *pb,...); +extern void cdecl uDisplayText(char *pb,...); +extern int uPresentMenus(void); +extern void uAddGreyUline(unsigned char,unsigned short int *plines); +extern void uSetDialogUline(int pos,int on); +extern int uLocateCommand(int accel); +extern void hPrintSetupDialog(void); +extern void hPrint(int printline(H_PRINT *)); +extern void hPrinterSetupDialog(void); +extern void hPrintSetSI(unsigned int subsqind); +extern int hPrintSensePageWidth(void); +extern int hPrintSenseBufWidth(char *buf,int blen); +extern void hHelpSubSystem(int startid,int indexid); +extern void *hTTOpen(void); +extern int hTTSetTime(void *handle,int type,void *data); +extern int hTTSenseString(void *handle,int type,char *buf); +extern void hTTSetFormat(void *handle,int values); +extern void hTTSetAbbreviations(void *handle,int dayabb,int monabb); +extern void hTTClose(void *handle); +extern int hEBHandleKey(void *ebH,int keycode,int modifier); +extern int hEBCompleteFormat(void *ebH); +extern char *hEBSenseText(void *ebH); +extern int hEBSetText(void *ebH,char *pb,int blen); +extern void hEBEmphasise(void *ebH,int flag); +extern int hEBSetSelect(void *ebH,int aoff,int coff); +extern int hEBSenseSelect(void *ebH,unsigned short int *top); +extern int hEBSetClipText(void *ebH,char *pb,int blen); +extern char *hEBSenseClipText(void *ebH); +extern int hEBEvaluate(void *ebH); +extern int hEBSetMargin(void *ebH,unsigned int right); +extern unsigned int hEBSenseMargin(void *ebH); +extern int hEBChangeWidth(void *ebH,int width); +extern void hEBSetCWidth(void *ebH,int cwidth); +extern int hEBInsert(void *ebH,char *pb,int blen); +extern int hEBReplace(void *ebH,char *replace,int backwards); +extern int hEBCopy(void *ebH); +extern int hEBPaste(void *ebH); +extern int hEBFind(void *ebH,char *str,int flags); +extern int hEBSenseChanged(void *ebH); +extern void hEBClearChanged(void *ebH); +extern int hEBShowSymbols(void *ebH,int flag); +extern void *hEBOpen(int flags,H_EDIT_BOX *heb); +extern void hEBClose(void *ebH); +extern void *hEBSenseDoc(void *ebH); +extern int hEDCapacity(void *doc,unsigned int maxlen); +extern int hEDInsert(void *doc,unsigned int pos,void *buf,unsigned int len); +extern int hEBDocChanged(void *ebH); +extern int hEBPosToXL(void *ebH,H_SCRLAY_PLX *plx); +extern void hDeclareAppRcb(void *rcb); +extern void *hInitAppRcb(void); +extern int hSetSystemResLang(int lang); +extern void hRequestReplacePack(void *rcb,char *fname); +extern void *hDTOpen(H_DTEDIT *dte); +extern void hDTClose(void *dte); +extern void hDTSet(void *dte,H_SE_DTEDIT *sdte); +extern void hDTSense(void *dte,H_SE_DTEDIT *sdte); +extern int hDTSelfCheck(void *dte); +extern int hDTHandleKey(void *dte,int keycode,int modifier); +extern void hDTEmphasise(void *dte,int flag); +extern void hSetVarrayInChlist(int index,int nsel,void *varray); +extern void hOODialog(int catHandle,int classno,int resid,void *rbuf); +extern int hLoadOwnDyl(int index); +#ifdef __cplusplus +} +#endif + +#endif // HWIF_H diff --git a/code/SIBOSDK/hwifsrc/hwif.pr b/code/SIBOSDK/hwifsrc/hwif.pr new file mode 100644 index 0000000..82dfc30 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/hwif.pr @@ -0,0 +1,17 @@ +#system epoc img +#model small jpi + +#message "HWIF library project file" + +#compile hwif.cat + +#compile hhwif.c +#compile xhwif.c +#compile uhwif.c +#compile phwif.c +#compile thwif.c +#compile ehwif.c +#compile rhwif.c +#compile diyhwif.c + +#dolink hwif.lib diff --git a/code/SIBOSDK/hwifsrc/hwifo.pr b/code/SIBOSDK/hwifsrc/hwifo.pr new file mode 100644 index 0000000..03caf3a --- /dev/null +++ b/code/SIBOSDK/hwifsrc/hwifo.pr @@ -0,0 +1,18 @@ +#system epoc img +#model small jpi + +#message "HWIFO library project file" + +#compile hwif.cat +#dolink dummy.lib + +#compile hhwif.c +#compile xhwif.c +#compile uhwif.c +#compile phwif.c +#compile thwif.c +#compile ehwif.c +#compile rhwif.c +#compile diyhwif.c + +#dolink hwifo.lib diff --git a/code/SIBOSDK/hwifsrc/hwifsrc.prj b/code/SIBOSDK/hwifsrc/hwifsrc.prj new file mode 100644 index 0000000..74a0185 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/hwifsrc.prj @@ -0,0 +1,20 @@ +hwifsrc.prj ! releases source files +read.me ! read me for distribution +release.txt ! list of changes between releases +! +hwif.pr ! TS project file +hwifo.pr ! Alternative project file +make.bat ! Makes HWIF.LIB & HWIFO.LIB +ts.red ! Redirector (for completeness) +! +hwif.cat ! printing subclass definition +hhwif.c ! original h layer of hwif +xhwif.c ! later additions to h layer of hwif +uhwif.c ! u layer of hwif +phwif.c ! printing routines +thwif.c ! time manipulation routines +ehwif.c ! edit box routines +rhwif.c ! resource file routines +diyhwif.c ! DIY dialog item routines +! +hwif.h ! header file (releasable) diff --git a/code/SIBOSDK/hwifsrc/make.bat b/code/SIBOSDK/hwifsrc/make.bat new file mode 100644 index 0000000..d3aa98e --- /dev/null +++ b/code/SIBOSDK/hwifsrc/make.bat @@ -0,0 +1,4 @@ +@echo off +tscx /m hwif /v0 +tscx /m hwif /v0 +tscx /m hwifo /v0 diff --git a/code/SIBOSDK/hwifsrc/phwif.c b/code/SIBOSDK/hwifsrc/phwif.c new file mode 100644 index 0000000..4a01361 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/phwif.c @@ -0,0 +1,216 @@ +/* + PHWIF.C + +Started by DavidW, 5/12/91 + +Printing extension to h layer of hwif + +Help subsystem extension added 3/8/92 + +*/ + +#include +#include +#include +#include +#include +#include + +GLREF_D PR_WSERV *w_ws; +GLREF_D PR_HWIMMAN *w_am; +GLREF_D PR_GATE *DatGate; +GLREF_D UWORD DatLocked; + +typedef struct + { + INT (*f)(WDR_PRINT *); + } GATE_PRINTER; + +typedef struct + { + HANDLE catHand; + INT class; + DL_DATA d; + } GATE_OOD; + +#define GATE_FORCE_WSERV_LEAVE FALSE + + +#pragma save,ENTER_CALL + +LOCAL_C INT EditPrintContext(VOID *junk) + { + p_send2(w_ws,O_WS_EDIT_PRINT_CONTEXT); + return(0); + } + +LOCAL_C INT EditPrinterSetup(VOID *junk) + { + p_send2(w_ws,O_WS_EDIT_PDEV_SETUP); + return(0); + } + +#define _phand ((PR_HPRINTER *)(w_ws->wserv.filelist)) + +LOCAL_C INT DoPrint(VOID *par) + { + _phand=p_new(CAT_HWIF_HWIF,C_HPRINTER); + if (!_phand) + return(E_GEN_NOMEMORY); + _phand->hprinter.sense=((GATE_PRINTER *)par)->f; + p_send2(_phand,O_LPR_INIT); + return(0); + } + +LOCAL_C INT HelpSubSystem(VOID *par) + { + p_send3(w_ws,O_WS_DO_HELP,(INT)par); + p_reclass(CAT_HWIF_HWIF,C_HHELPDLG,w_ws->wserv.dial); + p_send2(w_am,O_AM_START); + return(0); + } + +#define _dld ((GATE_OOD *)par) + +LOCAL_C INT LaunchDialog(VOID *par) + { + p_send5(w_ws,O_WS_DO_DIAL,_dld->catHand,_dld->class,&_dld->d); + return(0); + } + +#pragma restore + +LOCAL_C UINT ConsoleOff(UWORD state,UINT leavestate) +/* +Set the console read off or on dependent on state +Also enable or disable leaves from the Window Server. +Return the old value of the disable leaves status. +*/ + { + UINT func; + + func=P_SCR_DISABLE_READS; + p_iow4(DatGate->gate.concb,P_FSET,&func,&state); + return(wDisableLeaves(leavestate)); + } + +LOCAL_C VOID ViaGate( +#pragma save,ENTER_CALL + INT func(VOID *),VOID *par) +#pragma restore + { + INT leavestate; + INT ret; + PR_WAOTSTAT *waotstat; + + leavestate=ConsoleOff(TRUE,GATE_FORCE_WSERV_LEAVE); + w_ws->wserv.flags&=(~PR_WSERV_FROM_HWIF); + DatLocked++; + ret=p_enter2(func,par); + DatLocked--; + w_ws->wserv.flags|=PR_WSERV_FROM_HWIF; + ConsoleOff(FALSE,leavestate); + if (ret) + uErrorValue(ret); + waotstat=DatGate->gate.waotstat; + while (waotstat->waotstat.count) + { + p_iosignal(); + (waotstat->waotstat.count)--; + } + } + +LOCAL_C VOID ViaClearGate( +#pragma save,ENTER_CALL + INT func(VOID *),VOID *par) +#pragma restore +/* new function for 2.04, avoid trouble when HELP pressed */ + { + INT old; + + old=w_ws->wserv.help_index_id; + w_ws->wserv.help_index_id=0; + ViaGate(func,par); + w_ws->wserv.help_index_id=old; + } + +GLDEF_C VOID hPrintSetupDialog(VOID) + { + ViaClearGate(EditPrintContext,NULL); + } + +GLDEF_C VOID hPrint(INT sense(H_PRINT *)) + { + GATE_PRINTER g; + + g.f=(INT (*)(WDR_PRINT *))sense; + ViaClearGate(DoPrint,&g); + if (_phand) + { + p_send2(_phand,O_DESTROY); + _phand=NULL; + } + } + +GLDEF_C VOID hPrinterSetupDialog(VOID) + { + ViaClearGate(EditPrinterSetup,NULL); + } + +GLDEF_C VOID hHelpSubSystem(INT startid,INT indexid) + { + INT old; + + old=w_ws->wserv.help_index_id; + w_ws->wserv.help_index_id=indexid; + ViaGate(HelpSubSystem,(VOID *)startid); + w_ws->wserv.help_index_id=old; + } + +GLDEF_C VOID hOODialog(INT catHandle,INT class,INT resid,VOID *rbuf) + { + GATE_OOD dld; + + dld.catHand=catHandle; + dld.class=class; + dld.d.id=resid; + dld.d.rbuf=rbuf; + dld.d.pdlg=NULL; + ViaClearGate(LaunchDialog,&dld); + } + +GLDEF_C VOID hPrintSetSI(UINT subsqind) + { + _phand->lprinter.subsqind=subsqind; + } + +GLDEF_C INT hPrintSensePageWidth(VOID) + { + return(_phand->lprinter.width); + } + +GLDEF_C INT hPrintSenseBufWidth(TEXT *buf,INT blen) + { + return(p_send4(_phand,O_LPR_SENSE_BUF_WIDTH,buf,blen)); + } + +#define S_METHOD_CALL call(reg_param =>(bx,dx,si,di),reg_saved =>(ds)) + +#pragma S_METHOD_CALL + +METHOD INT hprinter_lpr_sense_text(PR_HPRINTER *self,WDR_PRINT *pr) + { + return((self->hprinter.sense)(pr)); + } + +METHOD VOID hprinter_lpr_read(PR_HPRINTER *self,INT x,WDR_PRINT *pr) + { /* added for Hwif 2.02 as workaround for lprinter bug */ + self->lprinter.defer.flags&=(~WDR_PRINT_PAGE); + p_supersend4(self,O_LPR_READ,x,pr); + } + +METHOD VOID hhelpdlg_destroy(PR_HHELPDLG *self) + { + p_supersend2(self,O_DESTROY); + p_send2(w_am,O_AM_STOP); + } diff --git a/code/SIBOSDK/hwifsrc/read.me b/code/SIBOSDK/hwifsrc/read.me new file mode 100644 index 0000000..cb78b3e --- /dev/null +++ b/code/SIBOSDK/hwifsrc/read.me @@ -0,0 +1,11 @@ +To build your own copy of HWIF.LIB +---------------------------------- + +Make sure that the OOP component of the SDK has been installed, +as well as the CORE and HWIFSRC components. + +In the HWIFSRC directory, type "MAKE". + +The HWIF.LIB created should differ in only four bytes - a date stamp in +the library header - from that installed into \SIBOSDK\LIB from the HWIF +component of the SDK. diff --git a/code/SIBOSDK/hwifsrc/release.txt b/code/SIBOSDK/hwifsrc/release.txt new file mode 100644 index 0000000..96efb91 --- /dev/null +++ b/code/SIBOSDK/hwifsrc/release.txt @@ -0,0 +1,48 @@ +Version 2.05 - 7th Dec 94 +------------------------- +Made by DavidW: +1. Re-wrote uCommonInit to support W_CTBY_S3_SCR mode (if the new + static _S3UseFullScreen is set), to remove all hard-wired sizes + (these are now calculated dynamically at run-time), to resize the + default graphics window to use every pixel on the screen, and to + simplify the overall logic of the routine. +2. Now test in hDlgOpen for whether a new static _SmallFontDialog is + set, and if so create the dialog using O_GT_DIAL_SOPEN instead of + O_GT_DIAL_OPEN (and clear the flag so that it won't affect any + subsequent dialogs). + +Version 2.04 - 1st Aug 94 +------------------------- +Made by DavidW: +1. Introduced new function ViaClearGate as a layer around ViaGate + that clears w_ws->wserv.help_index_id before entry, and restores + the original value on completion. This is to avoid problems if + the user presses HELP when inside (a) an OO dialog (b) a + sub-dialog of the Print Setup or Printer Setup suites (c) the + Printing dialog. (These problems would only show up if another + menu item has been highlighted last, apart from the first item in + the first menu.) + + +Version 2.03 - 31st July 94 +--------------------------- +Made by DavidW: +1. Now creates HWIFO.LIB as well as HWIF.LIB, to ease the task of + HWIF programmers who want to add OO features to their apps. + HWIF.CAT is now a separate releasable. + +Version 2.02 - 23rd Mar 94 +-------------------------- +Made by DavidW: +1. Added new replacement method lpr_read to hprinter class, to clear + PRINT_PAGE bit in defer.flags, to workaround bug in lprinter class + in which a line printed with PRINT_PAGE which needed to be + word-wrapped would throw a new page for each extra line generated. + +Version 2.01 - 7th Feb 94 +------------------------- +Made by DavidW: +1. Added function hEBPosToXL and struct definition H_SCRLAY_PLX + allowing access to the scrlay method O_SL_POS_TO_XL. +2. Changed "class" to "classno" in one function definition, to be + more C++ friendly. diff --git a/code/SIBOSDK/hwifsrc/rhwif.c b/code/SIBOSDK/hwifsrc/rhwif.c new file mode 100644 index 0000000..3ff22bc --- /dev/null +++ b/code/SIBOSDK/hwifsrc/rhwif.c @@ -0,0 +1,74 @@ +/* + RHWIF.C + +Started by DavidW, 1/11/92 + +Resource file extension to Hwif + +*/ + +#include +#include +#include +#include +#include +#include +#include + +GLREF_D PR_APPMAN *w_am; +GLREF_D WORD DatLocked; +GLREF_D VOID *DatCommandPtr; + + +GLDEF_C VOID hDeclareAppRcb(VOID *rcb) + { + w_am->appman.rcb=rcb; + } + +GLDEF_C VOID *hInitAppRcb(VOID) + { /* create and initialise resource file object */ + INT ret; + VOID *rcb; /* resource file object handle */ + + rcb=p_new(1,C_RSCFILE); + ret=p_entersend3(rcb,O_RS_INIT,DatCommandPtr); /* pass file name */ + if (ret<0) /* no resource file found */ + p_exit(ret); /* fatal (programmer) error */ + hDeclareAppRcb(rcb); + return(rcb); + } + +GLDEF_C INT hSetSystemResLang(INT lang) + { + TEXT name[12]; /* eg "ROM::s_.~04" */ + P_INFO junk; + VOID *srcb; + INT ret; + + p_atos(&name[0],"ROM::S_.~%02d",lang); + if (p_finfo(&name[0],&junk)) + return(E_FILE_NXIST); + srcb=p_new(CAT_HWIF_OLIB,C_RSCFILE); + if (!srcb) + return(E_GEN_NOMEMORY); + ret=p_entersend3(srcb,O_RS_INIT,&name[0]); + if (!ret) + { + p_send2(w_am->appman.srcb,O_DESTROY); + w_am->appman.srcb=srcb; + } + return(ret); + } + +GLDEF_C VOID hRequestReplacePack(VOID *rcb,TEXT *fname) + { + TEXT buf[50]; + + p_send4(w_am,O_AM_LOAD_RES_BUF,-SYS_REPLACE_DISK,&buf[0]); + do + { + DatLocked++; + wsAlertW(WS_ALERT_CLIENT,0,&buf[0],0); + DatLocked--; + } while (p_entersend3(rcb,O_RS_INIT,fname)<0); + } diff --git a/code/SIBOSDK/hwifsrc/thwif.c b/code/SIBOSDK/hwifsrc/thwif.c new file mode 100644 index 0000000..5e3195d --- /dev/null +++ b/code/SIBOSDK/hwifsrc/thwif.c @@ -0,0 +1,48 @@ +/* + THWIF.C + +Started by DavidW, 6/12/91 + +Time text extension to h layer of hwif + +*/ + +#include +#include +#include + + +GLDEF_C VOID *hTTOpen(VOID) + { + return(uCheckHandle(p_new(CAT_HWIF_HWIM,C_HTIME))); + } + +GLDEF_C INT hTTSetTime(VOID *handle,INT type,VOID *data) + { + return(p_send4(handle,O_TO_SET,type,data)); + } + +GLDEF_C INT hTTSenseString(VOID *handle,INT type,TEXT *buf) + { + return(p_send4(handle,O_TO_SENSE,type,buf)); + } + +#define TIME_DEFAULTS (PR_TIME_NO_SECS|PR_TIME_DAY_NAME|PR_TIME_SUFFIX_NAME|PR_TIME_MONTH_NAME|PR_TIME_FORCE_UPDATE_FORMAT) + +GLDEF_C VOID hTTSetFormat(VOID *handle,INT values) + { + p_send3(handle,O_TO_SET_FORMAT,NULL); + ((PR_TIME *)handle)->time.f.flags&=(~TIME_DEFAULTS); + ((PR_TIME *)handle)->time.f.flags|=values; + } + +GLDEF_C VOID hTTSetAbbreviations(VOID *handle,INT dayabb,INT monabb) + { + p_send4(handle,O_TO_SET_ABBREVIATIONS,dayabb,monabb); + ((PR_TIME *)handle)->time.f.flags|=PR_TIME_ABBREVIATE; + } + +GLDEF_C VOID hTTClose(VOID *handle) + { + p_send2(handle,O_DESTROY); + } diff --git a/code/SIBOSDK/hwifsrc/uhwif.c b/code/SIBOSDK/hwifsrc/uhwif.c new file mode 100644 index 0000000..3863edb --- /dev/null +++ b/code/SIBOSDK/hwifsrc/uhwif.c @@ -0,0 +1,385 @@ +/* + UHWIF.C + +Started by DavidW, 8/11/91 + +Utility layer of hwif + +*/ + +#include +#include +#include +#include +#include +#include + +GLREF_D UWORD DatLocked; + +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D VOID *winHandle; +GLREF_D UWORD _UseFullScreen; +GLDEF_D UWORD _S3UseFullScreen; + +GLREF_D TEXT ** _cmds; +GLREF_D H_MENU_DATA * _mdata; + +LOCAL_C VOID Check(INT val) + { + if (val) + p_exit(val); + } + +GLDEF_C VOID uCommonInit(VOID) + { + INT val; + UINT func; + CONSOLE_INFO cinfo; + W_WINDATA wd; + + p_linklib(0); + if (winHandle) + { + val=FALSE; + func=P_SCR_CURSOR; + Check(p_iow4(winHandle,P_FSET,&func,&val)); + goto exit; + } + Check(p_open(&winHandle,"CON:",0)); + if (_UseFullScreen || _S3UseFullScreen) + { + if ((wserv_channel->conn.info.version_id&WS_VERSION_MASK) + conn.info.pixels.x+1)/cinfo.char_width; + wd.extent.height=(wserv_channel->conn.info.pixels.y+1)/cinfo.line_height; + func=P_SCR_WSET; + Check(p_iow4(winHandle,P_FSET,&func,&wd.extent)); + wd.extent.width=wserv_channel->conn.info.pixels.x; + wd.extent.height=wserv_channel->conn.info.pixels.y; + wSetWindow(cinfo.window_handle,W_WIN_EXTENT,&wd); + Check(wCheckPoint()); +exit: + hIFInit(winHandle); + } + +GLDEF_C VOID uEnableGrey(VOID) + { + UINT func; + UINT flags; + + func=P_SCR_GREY; + flags=TRUE; + Check(p_iow4(winHandle,P_FSET,&func,&flags)); + } + +GLDEF_C VOID uGetKey(WMSG_KEY *pkey) + { + p_iow3(winHandle,P_EVENT_READ,pkey); + } + +GLDEF_C VOID uGetKeyA(WORD *pstat,WMSG_KEY *pkey) + { + p_ioc4(winHandle,P_EVENT_READ,pstat,pkey); + } + +GLDEF_C VOID uCancelGetKeyA(VOID) + { + p_iow2(winHandle,P_FCANCEL); + } + +GLDEF_C INT uKeyPressOutstanding(VOID) + { + UWORD flag; + + p_iow3(winHandle,P_FTEST,&flag); + return(flag); + } + +GLDEF_C VOID uEscape(UWORD flag) + { + UINT func; + + func=P_SCR_ESCAPE; + p_iow4(winHandle,P_FSET,&func,&flag); + } + +GLDEF_C UINT uFindMainWid(VOID) + { + CONSOLE_INFO info; + + p_iow3(winHandle,P_FINQ,&info); + return(info.window_handle); + } + +GLDEF_C VOID uForceToFront(VOID) + { + wClientPosition(0,0); + wFlush(); + } + +GLDEF_C VOID uErrorString(TEXT *message) + { + uForceToFront(); + DatLocked++; + wsAlertW(WS_ALERT_CLIENT,0,message,0); + DatLocked--; + } + +GLDEF_C INT uErrorValue(INT ret) + { + TEXT buf[64]; + + if (ret) + { + p_errs(&buf[0],ret); + uErrorString(&buf[0]); + } + return(ret); + } + +GLDEF_C VOID *uCheckHandle(VOID *hand) + { + if (!hand) + uErrorValue(E_GEN_NOMEMORY); + return(hand); + } + +GLDEF_C VOID uZTStoBCS(TEXT *bcs,TEXT *zts) + { + p_bcpy(bcs+1,zts,*bcs=p_slen(zts)); + } + +GLDEF_C INT uOpenDialog(TEXT *title) + { + TEXT buf[64]; + + if (title) + { + uZTStoBCS(&buf[0],title); + title=(&buf[0]); + } + return(uErrorValue(hDlgOpen(title))); + } + +GLDEF_C INT uAddDialogItem(INT type,TEXT *prompt,VOID *data) + { + TEXT buf[64]; + + if (prompt) + { + uZTStoBCS(&buf[0],prompt); + prompt=(&buf[0]); + } + return(uErrorValue(hDlgAdd(type,prompt,data))); + } + +GLDEF_C INT uRunDialog(VOID) + { + INT ret; + + DatLocked++; + ret=hDlgRun(); + DatLocked--; + if (ret<0) + uErrorValue(ret); + return(ret); + } + +GLDEF_C INT CDECL uAddButtonList(TEXT *but,INT code,...) + { + TEXT buf[40]; + INT count; + TEXT **pbut; + INT *pcode; + VOID *buts; + + buts=uCheckHandle(hButtonOpen()); + if (!buts) + return(-1); + count=1; + pbut=(&but); + pcode=(&code); + while (*pbut) + { + uZTStoBCS(&buf[0],*pbut); + if (uErrorValue(hButtonAdd(buts,count++,*pcode,&buf[0]))) + goto CleanUp; + pcode+=2; + pbut+=2; + } + if (!uAddDialogItem(H_DIALOG_BUTTONS,0,(VOID *)buts)) + return(0); +CleanUp: + hButtonClose(buts); + return(-1); + } + +GLDEF_C INT uBeginDCL(H_DI_CHOICE *pch) + { + pch->u.count=1; + pch->menu=uCheckHandle(hChoiceOpen()); + return(!(INT)pch->menu); + } + +GLDEF_C INT uGrowDCL(H_DI_CHOICE *pch,TEXT *choice) + { + TEXT buf[64]; + + uZTStoBCS(&buf[0],choice); + if (!uErrorValue(hChoiceAdd(pch->menu,pch->u.count++,&buf[0]))) + return(0); + hChoiceClose(pch->menu); + return(-1); + } + +GLDEF_C INT uAddDCL(TEXT *prompt,UWORD *nsel,H_DI_CHOICE *pch) + { + pch->u.sel=nsel; + if (!uAddDialogItem(H_DIALOG_CHOICE,prompt,pch)) + return(0); + hChoiceClose(pch->menu); + return(-1); + } + +GLDEF_C INT CDECL uAddChoiceList(TEXT *prompt,UWORD *nsel,TEXT *choice,...) + { + TEXT **pchoice; + H_DI_CHOICE ch; + + if (uBeginDCL(&ch)) + return(-1); + pchoice=(&choice); + while (*pchoice) + { + if (uGrowDCL(&ch,*pchoice++)) + return(-1); + } + return(uAddDCL(prompt,nsel,&ch)); + } + +GLDEF_C INT uLocateCommand(INT accel) + { + INT i; + TEXT **pcmd; + TEXT *cmd; + + i=0; + pcmd=_cmds; + while ((cmd=*pcmd++)!=0) + { + if (*cmd==accel) + return(i); + i++; + } + return(-1); + } + +GLDEF_C INT uPresentMenus(VOID) + { + INT ret; + VOID *card[16]; + VOID *loc; + INT cardindex; + TEXT **pcmd; + TEXT *cmd; + H_MENU_DATA *mdata; + INT pos; + INT nitems; + TEXT buf[64]; + + if (uErrorValue(hMenuOpen())) + return(0); + mdata=_mdata; + pcmd=_cmds; + cardindex=0; + while (mdata->title) + { + loc=uCheckHandle(hCardOpen()); + if (!loc) + goto TidyUp; + card[cardindex++]=loc; + nitems=mdata->nlines; + pos=1; + while (nitems--) + { + cmd=(*pcmd++); + uZTStoBCS(&buf[0],cmd+1); + if (uErrorValue(hCardAdd(loc,pos++,*cmd,&buf[0]))) + goto TidyUp; + } + uZTStoBCS(&buf[0],mdata->title); + if (uErrorValue(hMenuAdd(&buf[0],loc))) + goto TidyUp; + mdata++; + } + DatLocked++; + ret=hMenuRun(); + DatLocked--; + if (ret>=0) + goto CleanUp; + uErrorValue(ret); +TidyUp: + hMenuClose(); + ret=0; +CleanUp: + while (cardindex) + hCardClose(card[--cardindex]); + return(ret); + } + +GLDEF_C VOID uAddGreyUline(UBYTE accel,UWORD *plines) + { + *(plines+(accel/16))|=(1<<(accel%16)); + } + +GLDEF_C INT CDECL uDialogMenu(TEXT *title,TEXT *pb,...) + { + TEXT **ppb; + H_DI_TEXT txt; + TEXT buf[64]; + + if (uOpenDialog(title)) + return(0); + txt.type=H_DTEXT_ALIGN_LEFT|H_DTEXT_SELECTABLE; + txt.str=(&buf[0]); + ppb=(&pb); + while (*ppb) + { + uZTStoBCS(&buf[0],*ppb++); + if (uAddDialogItem(H_DIALOG_TEXT," ",&txt)) + return(0); + } + return(uRunDialog()); + } + +GLDEF_C VOID CDECL uDisplayText(TEXT *pb,...) + { + TEXT **ppb; + H_DI_TEXT txt; + TEXT buf[64]; + + if (uOpenDialog(NULL)) + return; + txt.type=H_DTEXT_ALIGN_LEFT; + txt.str=(&buf[0]); + ppb=(&pb); + while (*ppb) + { + uZTStoBCS(&buf[0],*ppb++); + if (uAddDialogItem(H_DIALOG_TEXT,NULL,&txt)) + return; + } + uRunDialog(); + } diff --git a/code/SIBOSDK/hwifsrc/xhwif.c b/code/SIBOSDK/hwifsrc/xhwif.c new file mode 100644 index 0000000..28e447d --- /dev/null +++ b/code/SIBOSDK/hwifsrc/xhwif.c @@ -0,0 +1,144 @@ +/* + XHWIF.C + +Started by DavidW, 8/11/91 + +Later additions to h layer of hwif + +*/ + +#include +#include +#include +#include +#include + +GLREF_D TEXT *DatUsedPathNamePtr; +GLREF_D TEXT *DatCommandPtr; +GLREF_D TEXT *DatProcessNamePtr; +GLREF_D TEXT *DatStatusNamePtr; + + +GLDEF_C VOID hEnsurePath(TEXT *fname) +/* +Ensure that the path of the specified path exists. +All errors are ignored. +*/ + { + P_FPARSE crk; + TEXT buf[P_FNAMESIZE]; + + if (!p_fparse(fname,NULL,&buf[0],&crk)) + { + buf[crk.system+crk.device+crk.path]=0; + p_mkdir(&buf[0]); + } + } + +GLDEF_C VOID hSetUpStatusNames(TEXT *pb) + { + TEXT buf[P_FNAMESIZE]; + P_FPARSE crk; + + DatUsedPathNamePtr=pb; + p_fparse(pb,0,&buf[0],&crk); + DatStatusNamePtr=pb+P_FSYSNAMESIZE+crk.device+crk.path; + } + +GLDEF_C INT hCrackCommandLine(VOID) + { + INT ret; + TEXT *pb; + + pb=DatCommandPtr; + pb+=p_slen(pb)+1; + if (!*pb++) + ret=0; + else + { + ret=(*pb++); + DatProcessNamePtr=pb; + pb+=p_slen(pb)+1; + pb+=p_slen(pb)+1; + if (*pb) + hSetUpStatusNames(pb); + else + DatStatusNamePtr=DatProcessNamePtr; + } + return(ret); + } + +GLDEF_C INT hIsDbfCompressible(VOID *dH) + { + return(*((UWORD *)dH+19)&P_FMEDIA_COMPRESSIBLE); + } + +typedef struct + { + UWORD toneLengthTicks; + UWORD delayLengthTicks; + UWORD pauseLengthTicks; + UBYTE dialOutCode[6]; + } DTMF_ENVAR; + +LOCAL_C VOID ReadDTMFEnvar(DTMF_ENVAR *penv) + { + INT len; + UBYTE buf[P_ENVMAX]; + + len=p_getenviron("D$X",3,&buf[0]); + if (len==sizeof(DTMF_ENVAR)) + p_bcpy(penv,&buf[0],sizeof(DTMF_ENVAR)); + else + { + penv->toneLengthTicks=8; + penv->delayLengthTicks=8; + penv->pauseLengthTicks=48; + } + } + +GLDEF_C INT hDTMFString(TEXT *zts) + { + E_DIAL c; + DTMF_ENVAR env; + INT oldsnd_state; + INT ret; + VOID *snd; + INT i; + + ReadDTMFEnvar(&env); + c.toneLengthTicks=env.toneLengthTicks; + c.delayLengthTicks=env.delayLengthTicks; + c.pauseLengthTicks=env.pauseLengthTicks; + oldsnd_state=p_getsnd(); + p_setsnd((oldsnd_state&~E_SOUND_DISABLE)|E_SOUND_DEVICE); + for (i=3;i;i--) + { + if (!(ret=p_open(&snd,"SND:",0))) + break; + p_sleep(1); + } + if (!ret) + { + p_iow4(snd,E_FDIAL,zts,&c); + p_close(snd); + } + p_setsnd(oldsnd_state); + return(ret); + } + +GLDEF_C INT hLoadOwnDyl(INT index) + { + INT DylHandle; + VOID *fcb; + INT ret; + + DylHandle=0; + ret=p_openlib(&fcb,DatCommandPtr); + if (!ret) + { + p_loadfilelib(fcb,index,&DylHandle,TRUE); + p_close(fcb); + } + return(DylHandle); + } diff --git a/code/SIBOSDK/hwimdemo/dat.afl b/code/SIBOSDK/hwimdemo/dat.afl new file mode 100644 index 0000000..dc6c66d --- /dev/null +++ b/code/SIBOSDK/hwimdemo/dat.afl @@ -0,0 +1,3 @@ +dat.pic +dat.rzc +dat.shd diff --git a/code/SIBOSDK/hwimdemo/dat.cat b/code/SIBOSDK/hwimdemo/dat.cat new file mode 100644 index 0000000..42d0df2 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/dat.cat @@ -0,0 +1,58 @@ +IMAGE dat + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE p_gen.h +INCLUDE p_file.h +INCLUDE epoc.h +INCLUDE wlib.h +INCLUDE olib.g +INCLUDE hwimman.g +INCLUDE mfne.g +INCLUDE time.g + +CLASS datcom comman + { + ADD com_date + } + +CLASS datwserv wserv + { + REPLACE ws_dyn_init + } + +CLASS datwin bwin + { + REPLACE wn_init + REPLACE wn_dodraw + REPLACE wn_draw + PROPERTY + { + PR_TIME *time; + } + } + +CLASS datedlg dlgbox + { + REPLACE dl_item_new + REPLACE dl_dyn_init + REPLACE dl_key + } + +CLASS date mfne + { + REPLACE wn_init + REPLACE wn_set + REPLACE wn_sense + REPLACE lg_self_check + PROPERTY + { + WORD dType; + UINT day; + UINT month; + UINT year; + ULONG min; + ULONG max; + } + } diff --git a/code/SIBOSDK/hwimdemo/dat.ms b/code/SIBOSDK/hwimdemo/dat.ms new file mode 100644 index 0000000..494eed9 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/dat.ms @@ -0,0 +1,3 @@ +Dat + +1000 diff --git a/code/SIBOSDK/hwimdemo/dat.pic b/code/SIBOSDK/hwimdemo/dat.pic new file mode 100644 index 0000000..561851c Binary files /dev/null and b/code/SIBOSDK/hwimdemo/dat.pic differ diff --git a/code/SIBOSDK/hwimdemo/dat.pr b/code/SIBOSDK/hwimdemo/dat.pr new file mode 100644 index 0000000..e725c6b --- /dev/null +++ b/code/SIBOSDK/hwimdemo/dat.pr @@ -0,0 +1,39 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#set version=0x118F +#set priority=0x80 +#set heapsize=0x48 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort + #run "rch %main" no_window no_abort +#endif + +#compile datwserv.c +#compile datwin.c +#compile datcom.c +#compile date.c +#compile datdial.c + +#if %main.shd #older %main.ms #then + #run "makeshd %main" no_window no_abort + #file delete %main.img +#endif + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main diff --git a/code/SIBOSDK/hwimdemo/dat.re b/code/SIBOSDK/hwimdemo/dat.re new file mode 100644 index 0000000..e3e3fe6 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/dat.re @@ -0,0 +1,6 @@ +#include + +_C_DATE +_O_COM_EXIT +_O_COM_DATE +_C_DATCOM diff --git a/code/SIBOSDK/hwimdemo/dat.rss b/code/SIBOSDK/hwimdemo/dat.rss new file mode 100644 index 0000000..b4e2de2 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/dat.rss @@ -0,0 +1,69 @@ +/* +Resource file for timer demonstration program +*/ + +#include +#include +#include +#include + +RESOURCE WSERV_INFO tim_accs + { + menbar_id=tim_menu; + first_com=O_COM_EXIT; +/* follows order in cat file command manager */ + accel={'x', /* Exit */ + 's' /* Set current date */ + }; + } + +RESOURCE MENU_BAR tim_menu + { + items = + { + MENU_BAR_ITEM + { + menu_id=options_menu; + mb_item="Options"; + } + }; + } + +RESOURCE MENU options_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_DATE; + mn_item="Current date"; + }, + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +RESOURCE STRING month_day_reset + { + str="Day exceeds days in month: reset"; + } + +RESOURCE DIALOG date_dl_res + { + title="Current date"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_DATE; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_APPL_CAT; + } + }; + } + + + diff --git a/code/SIBOSDK/hwimdemo/datcom.c b/code/SIBOSDK/hwimdemo/datcom.c new file mode 100644 index 0000000..78954d2 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/datcom.c @@ -0,0 +1,27 @@ +/* +kalcom.c +*/ + +#include +#include +#include + +GLREF_D PR_WSERV * const w_ws; + +LOCAL_C INT LaunchDial(VOID *buf,INT id,INT class) + { + DL_DATA dl_data; + + dl_data.id=id; + dl_data.rbuf=buf; + dl_data.pdlg=NULL; + return(p_send5(w_ws,O_WS_DO_DIAL,p_getlibh(CAT_DAT_DAT),class,&dl_data)); + } + +#pragma METHOD_CALL + +METHOD VOID datcom_com_date(PR_DATCOM *self) + { + LaunchDial(NULL,DATE_DL_RES,C_DATEDLG); + } + diff --git a/code/SIBOSDK/hwimdemo/datdial.c b/code/SIBOSDK/hwimdemo/datdial.c new file mode 100644 index 0000000..1a15c70 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/datdial.c @@ -0,0 +1,31 @@ +#include +#include +#include + +GLREF_D PR_DATWSERV * const w_ws; + +#pragma METHOD_CALL + +METHOD VOID *datedlg_dl_item_new(PR_DATEDLG *self,AD_DLGBOX *par) + { + return(f_new(CAT_DAT_DAT,par->class)); + } + +METHOD VOID datedlg_dl_dyn_init(PR_DATEDLG *self) + { + P_DAYSEC ds; + + p_send4(((PR_DATWIN *)w_ws->wserv.cli)->datwin.time,O_TO_SENSE,SENSE_TIME_DAYSEC,&ds); + p_send4(self,O_WN_SET,1,&ds.day); + } + +METHOD INT datedlg_dl_key(PR_DATEDLG *self,INT index,INT keycode) + { + P_DAYSEC ds; + + p_send4(self,O_WN_SENSE,1,&ds.day); + ds.sec=0; + f_leave(p_send4(((PR_DATWIN *)w_ws->wserv.cli)->datwin.time,O_TO_SET,SET_TIME_DAYSEC,&ds)); + return(WN_KEY_CHANGED); + } + diff --git a/code/SIBOSDK/hwimdemo/date.c b/code/SIBOSDK/hwimdemo/date.c new file mode 100644 index 0000000..497f3bb --- /dev/null +++ b/code/SIBOSDK/hwimdemo/date.c @@ -0,0 +1,121 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +LOCAL_C VOID InitField(PR_DATE *self,UINT i,LONG val,LONG min,LONG max,UBYTE width) + { + self->mfne.f[i].value=val; + self->mfne.f[i].limits[MFNE_LOWER]=min; + self->mfne.f[i].limits[MFNE_UPPER]=max; + self->mfne.f[i].width=width; + } + +LOCAL_C VOID DayMonthYear(PR_DATE *self,INT i,INT j,INT k) + { + self->date.day=i; + self->date.month=j; + self->date.year=k; + } + +#pragma METHOD_CALL + +METHOD VOID date_wn_init(PR_DATE *self,VOID *par,PR_WIN *landlord) + { + P_DAYSEC ds; + P_DATE dt; + E_CONFIG cfg; + + p_getctd(&cfg); + self->lodger.landlord=landlord; + self->mfne.selected=FALSE; + self->mfne.changed=FALSE; + self->mfne.cField=0; + self->mfne.nField=3; + self->mfne.f[0].separator=cfg.dateSeparator; + self->mfne.f[1].separator=cfg.dateSeparator; + self->mfne.f[2].flags=MFNE_SUPPRESS_SEPARATOR; + self->date.dType=cfg.dateType; + if (self->date.dType==E_DATE_EUROPE) + { + DayMonthYear(self,0,1,2); + } + else if (self->date.dType==E_DATE_USA) + { + DayMonthYear(self,1,0,2); + } + else if (self->date.dType==E_DATE_JAPAN) + { + DayMonthYear(self,2,1,0); + } + InitField(self,self->date.day,1,1,31,2); + InitField(self,self->date.month,1,1,12,2); + InitField(self,self->date.year,1,1900,2154,4); + dt.year=254; + dt.month=11; + dt.day=30; + dt.hour=dt.minute=dt.second=dt.yrday=0; + p_dttods(&dt,&ds); + self->date.max=ds.day; + } + +METHOD VOID date_wn_set(PR_DATE *self,ULONG *par) + { + P_DAYSEC ds; + P_DATE dt; + + ds.day=*par; + ds.sec=0; + if (ds.day>self->date.max) + { + ds.day=self->date.max; + } + p_dstodt(&ds,&dt); + self->mfne.f[self->date.day].value=dt.day+1; + self->mfne.f[self->date.month].value=dt.month+1; + self->mfne.f[self->date.year].value=dt.year+1900; + p_supersend2(self,O_WN_SET); + } + +METHOD VOID date_wn_sense(PR_DATE *self,ULONG *par) + { + P_DATE dt; + P_DAYSEC ds; + + dt.second=0; + dt.minute=0; + dt.hour=0; + dt.day=self->mfne.f[self->date.day].value-1; + dt.month=self->mfne.f[self->date.month].value-1; + dt.year=self->mfne.f[self->date.year].value-1900; + p_dttods(&dt,&ds); + *par=ds.day; + } + +METHOD INT date_lg_self_check(PR_DATE *self,INT can_defer) + { + INT ret; + INT days; + + ret=p_supersend3(self,O_LG_SELF_CHECK,can_defer); + if ((can_defer==FALSE)&&(ret==LG_CHECK_OK_CHANGED)) + { + days=p_dayinm((INT)self->mfne.f[self->date.year].value-1900, + (INT)self->mfne.f[self->date.month].value-1); + if (self->mfne.f[self->date.day].value>(LONG)days) + { + hBeep(); + self->mfne.cField=self->date.day; + self->mfne.f[self->date.day].value=(LONG)days; + p_supersend3(self,O_LG_SELF_CHECK,TRUE); + hInfoPrint(MONTH_DAY_RESET); + ret=LG_CHECK_FAILED_CHANGED; + } + } + return(ret); + } diff --git a/code/SIBOSDK/hwimdemo/date.h b/code/SIBOSDK/hwimdemo/date.h new file mode 100644 index 0000000..67a50a3 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/date.h @@ -0,0 +1,18 @@ +typedef struct + { + WORD flags; + ULONG value; + ULONG min; + ULONG max; + } SE_DATE; + +typedef struct + { + ULONG value; + ULONG min; + ULONG max; + } IN_DATE; + +#define SE_DATE_VALUE 0x01 +#define SE_DATE_MIN 0x02 +#define SE_DATE_MAX 0x04 diff --git a/code/SIBOSDK/hwimdemo/datwin.c b/code/SIBOSDK/hwimdemo/datwin.c new file mode 100644 index 0000000..eff5c09 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/datwin.c @@ -0,0 +1,51 @@ +/* Written by Leif November 1993 */ + +#include +#include +#include +#include +#include +#include +#include + +GLREF_D PR_WSERV * const w_ws; +GLREF_D PR_APPMAN * const w_am; + +#pragma METHOD_CALL + +METHOD VOID datwin_wn_draw(PR_DATWIN *self) + { + TEXT buf[LN_TIME_DATE_STR]; + G_FONT_INFO fontinfo; + W_WINDATA windata; + P_RECT r; + + p_supersend2(self,O_WN_DRAW); + wInquireWindow(self->win.id,&windata); + gFontInfo(WS_FONT_SYSTEM,0,&fontinfo); + r.tl.x=2; + r.br.x=windata.extent.width-2; + r.tl.y=(windata.extent.height-fontinfo.height)>>1; + r.br.y=r.tl.y+fontinfo.height; + f_leave(p_send4(self->datwin.time,O_TO_SENSE,SENSE_TIME_DATESTR,&buf[0])); + gPrintBoxText(&r,fontinfo.ascent,G_TEXT_ALIGN_CENTRE,0,&buf[0],p_slen(&buf[0])); + } + +METHOD VOID datwin_wn_dodraw(PR_DATWIN *self) + { + gCreateTempGC0(self->win.id); + datwin_wn_draw(self); + gFreeTempGC(); + wFlush(); + } + +METHOD VOID datwin_wn_init(PR_DATWIN *self,PR_WIN *par,UINT fields,W_WINDATA *pwd) + { + p_supersend5(self,O_WN_CONNECT,par,fields,pwd); + p_send3(self,O_WN_VISIBLE,WV_INITVIS); + p_send3(self,O_WN_EMPHASISE,TRUE); + self->datwin.time=f_newsend(CAT_DAT_OLIB,C_TIME,O_TO_SET_FORMAT,NULL,NULL); + p_send4(self->datwin.time,O_TO_SET,SET_TIME_NOW,NULL); + datwin_wn_dodraw(self); + } + diff --git a/code/SIBOSDK/hwimdemo/datwserv.c b/code/SIBOSDK/hwimdemo/datwserv.c new file mode 100644 index 0000000..b8c28b5 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/datwserv.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +GLREF_D WSERV_SPEC *wserv_channel; + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV ws; + + p_linklib(0); + app.flags=FLG_APPMAN_FULLSCREEN|FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN| + FLG_APPMAN_SRSCFILE; + app.wserv_cat=ws.com_cat=p_getlibh(CAT_DAT_DAT); + app.wserv_class=C_DATWSERV; + ws.com_class=C_DATCOM; + p_send4(p_new(CAT_DAT_HWIM,C_HWIMMAN),O_AM_INIT,&app,&ws); + } + +#pragma METHOD_CALL + +METHOD VOID datwserv_ws_dyn_init(PR_DATWSERV *self) + { + W_WINDATA wd; + + wd.extent.tl.y=0; + wd.extent.tl.x=0; + wd.extent.width=wserv_channel->conn.info.pixels.x; + wd.extent.height=wserv_channel->conn.info.pixels.y; + wd.background=W_WIN_BACK_CLR|W_WIN_BACK_GREY_CLR; + self->wserv.cli=f_newsend(CAT_DAT_DAT,C_DATWIN,O_WN_INIT,NULL,W_WIN_EXTENT|W_WIN_BACKGROUND,&wd); + } + + + + diff --git a/code/SIBOSDK/hwimdemo/gaugedem.afl b/code/SIBOSDK/hwimdemo/gaugedem.afl new file mode 100644 index 0000000..04ce7a2 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/gaugedem.afl @@ -0,0 +1,3 @@ +gaugedem.pic +gaugedem.rzc +gaugedem.shd diff --git a/code/SIBOSDK/hwimdemo/gaugedem.cat b/code/SIBOSDK/hwimdemo/gaugedem.cat new file mode 100644 index 0000000..79de7f1 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/gaugedem.cat @@ -0,0 +1,43 @@ +IMAGE gaugedem + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE hwimman.g +INCLUDE timer.g + +CLASS gaugewsv wserv + { + REPLACE ws_dyn_init + } + +CLASS gaugewin bwin +main window + { + REPLACE wn_init + REPLACE wn_draw + } + +CLASS gaugecom comman +command manager + { + ADD com_run + } + +CLASS gaugetim timer + { + REPLACE ao_init + REPLACE ao_queue + REPLACE ao_run + PROPERTY + { + ULONG count; + ULONG total; + } + } + +CLASS gaugedlg dlgbox + { + REPLACE dl_dyn_init + } + diff --git a/code/SIBOSDK/hwimdemo/gaugedem.ms b/code/SIBOSDK/hwimdemo/gaugedem.ms new file mode 100644 index 0000000..f7a2a78 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/gaugedem.ms @@ -0,0 +1,3 @@ +Gauge + +1000 diff --git a/code/SIBOSDK/hwimdemo/gaugedem.pic b/code/SIBOSDK/hwimdemo/gaugedem.pic new file mode 100644 index 0000000..561851c Binary files /dev/null and b/code/SIBOSDK/hwimdemo/gaugedem.pic differ diff --git a/code/SIBOSDK/hwimdemo/gaugedem.pr b/code/SIBOSDK/hwimdemo/gaugedem.pr new file mode 100644 index 0000000..56dd738 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/gaugedem.pr @@ -0,0 +1,41 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#set version=0x100F +#set priority=0x80 +#set heapsize=0x80 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort +#endif + +#if %main.rzc #older %main.rsg #then + #run "rch %main" no_window no_abort +#endif + +#compile o_gauge.c + +#if %main.shd #older %main.ms #then + #run "makeshd %main" no_window no_abort + #file delete %main.img +#endif + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main + diff --git a/code/SIBOSDK/hwimdemo/gaugedem.re b/code/SIBOSDK/hwimdemo/gaugedem.re new file mode 100644 index 0000000..25ce936 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/gaugedem.re @@ -0,0 +1,5 @@ +#include +#include + +_O_COM_RUN +_O_COM_EXIT diff --git a/code/SIBOSDK/hwimdemo/gaugedem.rss b/code/SIBOSDK/hwimdemo/gaugedem.rss new file mode 100644 index 0000000..64f21f6 --- /dev/null +++ b/code/SIBOSDK/hwimdemo/gaugedem.rss @@ -0,0 +1,106 @@ +/* + GAUGEDEM.RSS + +English resource file for GAUGEDEM demonstration app + +*/ + +#include +#include +#include + +RESOURCE WSERV_INFO hello_accs + { + menbar_id=gauge3_menbar; + first_com=O_COM_EXIT; + accel={'x', /* Exit */ + 'r' /* Run */ + }; + } + +RESOURCE MENU_BAR gauge3_menbar + { + items= + { + MENU_BAR_ITEM + { + menu_id=gauge_menu; + mb_item="Gauge"; + }, + MENU_BAR_ITEM + { + menu_id=special_menu; + mb_item="Special"; + } + }; + } + +RESOURCE MENU gauge_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_RUN; + mn_item="Run"; + } + }; + } + +RESOURCE MENU special_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +RESOURCE STRING title_res {str="Welcome to GAUGEDEM";} + +RESOURCE ACLIST_ARRAY escape_ac + { + button= + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Cancel"; + } + }; + } + +RESOURCE DIALOG gauge_dl_res + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="Loading data"; + }; + }, + CONTROL + { + class=C_DONEWN; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=escape_ac; + }; + } + }; + } + + diff --git a/code/SIBOSDK/hwimdemo/o_gauge.c b/code/SIBOSDK/hwimdemo/o_gauge.c new file mode 100644 index 0000000..9a1cdde --- /dev/null +++ b/code/SIBOSDK/hwimdemo/o_gauge.c @@ -0,0 +1,140 @@ +/* +O_GAUGE: demonstrates a gauge used to monitor the progress + of a lengthy operation simulated using a timer. +*/ + + +#include +#include +#include +#include +#include +#include +#include + +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D PR_HWIMMAN *w_am; +GLREF_D PR_WSERV *w_ws; + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV ws; + + p_linklib(0); + app.flags=FLG_APPMAN_FULLSCREEN|FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN| + FLG_APPMAN_SRSCFILE; + app.wserv_cat=p_getlibh(CAT_GAUGEDEM_GAUGEDEM); + ws.com_cat=p_getlibh(CAT_GAUGEDEM_GAUGEDEM); + app.wserv_class=C_GAUGEWSV; + ws.com_class=C_GAUGECOM; + p_send4(p_new(CAT_GAUGEDEM_HWIM,C_HWIMMAN),O_AM_INIT,&app,&ws); + } + +LOCAL_C INT LaunchDial(VOID *buf,INT id,INT class) + { + DL_DATA dl_data; + + dl_data.id=id; + dl_data.rbuf=buf; + dl_data.pdlg=NULL; + return(p_send5(w_ws,O_WS_DO_DIAL,p_getlibh(CAT_GAUGEDEM_GAUGEDEM),class,&dl_data)); + } + +#pragma METHOD_CALL + +METHOD VOID gaugewsv_ws_dyn_init(PR_GAUGEWSV *self) + { + self->wserv.cli=f_new(CAT_GAUGEDEM_GAUGEDEM,C_GAUGEWIN); + p_send2(self->wserv.cli,O_WN_INIT); + } + +METHOD VOID gaugewin_wn_init(PR_GAUGEWIN *self) + { + W_WINDATA wd; + + wd.extent.tl.x=0; + wd.extent.tl.y=0; + wd.extent.width=wserv_channel->conn.info.pixels.x; + wd.extent.height=wserv_channel->conn.info.pixels.y; + p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + p_send3(self,O_WN_VISIBLE,WV_INITVIS); + p_send3(self,O_WN_EMPHASISE,TRUE); + } + +METHOD VOID gaugewin_wn_draw(PR_GAUGEWIN *self) + { + G_FONT_INFO fontinfo; + W_WINDATA windata; + TEXT buf[40]; + P_RECT r; + INT w,len; + + p_supersend2(self,O_WN_DRAW); + len=p_send(w_am,O_AM_LOAD_RES_BUF,TITLE_RES,&buf[0]); + w=gTextWidth(WS_FONT_SYSTEM,0,&buf[0],--len); + wInquireWindow(self->win.id,&windata); + r.tl.x=(windata.extent.width-w)/2; + r.br.x=r.tl.x+w; + gFontInfo(WS_FONT_SYSTEM,0,&fontinfo); + r.tl.y=(windata.extent.height-fontinfo.height)/2; + r.br.y=r.tl.y+fontinfo.height; + gPrintBoxText(&r,fontinfo.ascent,G_TEXT_ALIGN_CENTRE,0,&buf[0],len); + } + +METHOD VOID gaugecom_com_run(PR_GAUGECOM *self) + { + ULONG duration; + + duration=100; + f_newsend(CAT_GAUGEDEM_GAUGEDEM,C_GAUGETIM,O_AO_INIT,&duration); + LaunchDial(&duration,GAUGE_DL_RES,C_GAUGEDLG); + } + +METHOD VOID gaugedlg_dl_dyn_init(PR_GAUGEDLG *self) + { + SE_DONEWN se_donewn; + + se_donewn.val=0L; + se_donewn.range=*(ULONG *)self->dlgbox.rbuf; + se_donewn.flags=SE_DONEWN_RANGE|SE_DONEWN_VALUE; + p_send4(self,O_WN_SET,1,&se_donewn); + } + +METHOD VOID gaugetim_ao_queue(PR_GAUGETIM *self,UINT lsw,UINT msw) + { + self->active.stat=E_FILE_PENDING; + self->active.isactive=TRUE; + p_supersend4(self,O_AO_QUEUE,lsw,msw); + } + +METHOD VOID gaugetim_ao_init(PR_GAUGETIM *self,ULONG *ptotal) + { + p_send3(w_am,O_AM_ADD_TASK,self); + self->active.priority=PRIORITY_ACTIVE_WSERV-1; + self->gaugetim.count=0L; + self->gaugetim.total=*ptotal; + p_supersend2(self,O_AO_INIT); + p_send4(self,O_AO_QUEUE,1,0); + } + +METHOD INT gaugetim_ao_run(PR_GAUGETIM *self) + { + SE_DONEWN se_donewn; + + self->gaugetim.count++; + if (w_ws->wserv.dial) + { + se_donewn.flags=SE_DONEWN_INCREMENT; + p_send4(w_ws->wserv.dial,O_WN_SET,1,&se_donewn); + if (self->gaugetim.countgaugetim.total) + { + p_send4(self,O_AO_QUEUE,1,0); + return(RUN_ACTIVE_USED); + } + else + p_send2(w_ws->wserv.dial,O_DESTROY); + } + p_send2(self,O_DESTROY); + return(RUN_ACTIVE_USED); + } diff --git a/code/SIBOSDK/include/aclist.g b/code/SIBOSDK/include/aclist.g new file mode 100644 index 0000000..817cc9a --- /dev/null +++ b/code/SIBOSDK/include/aclist.g @@ -0,0 +1,60 @@ +/* Generated by Ctran from aclist.cl */ +#define ACLIST_G +#ifndef LODGER_G +#include +#endif +#ifndef VARES_G +#include +#endif +/* Class Numbers */ +#define C_SMACLIST 22 +#define C_ACLIST 23 +/* Method Numbers */ +/* Constants for smaclist */ +#define SMACLIST_MAX_STRING 80 +/* Types for smaclist */ +typedef struct +{ +short int width; +short int x; +} BUT_POS; +typedef struct +{ +short int rid; +} IN_ACLIST; +/* Property of smaclist */ +typedef struct { +PR_VARES *data; +BUT_POS *pos; +unsigned short int totalwidth; +unsigned short int num; +unsigned short int lwidth; +} PRS_SMACLIST; +typedef struct pr_smaclist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_SMACLIST smaclist; +} PR_SMACLIST; +/* Types for aclist */ +typedef struct +{ +short int keycode; +char str[1]; +} PUSH_BUT; +/* Property of aclist */ +typedef struct { +PR_VARES *text; +short int width; +unsigned short int y1; +unsigned short int y2; +} PRS_ACLIST; +typedef struct pr_aclist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_SMACLIST smaclist; +PRS_ACLIST aclist; +} PR_ACLIST; diff --git a/code/SIBOSDK/include/aclist.ing b/code/SIBOSDK/include/aclist.ing new file mode 100644 index 0000000..6297753 --- /dev/null +++ b/code/SIBOSDK/include/aclist.ing @@ -0,0 +1,55 @@ +; Generated by Ctran from aclist.cl +ACLIST_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF VARES_ING + INCLUDE ..\inc\VARES.ING +ENDIF +; Class Numbers +C_SMACLIST equ 22 +C_ACLIST equ 23 +; Method Numbers +; Constants for smaclist +SMACLIST_MAX_STRING equ (80) +; Types for smaclist +BUT_POS struc +BUT_POSWidth dw ? +BUT_POSX dw ? +BUT_POS ends +IN_ACLIST struc +IN_ACLISTRid dw ? +IN_ACLIST ends +; Property of smaclist +PRS_SMACLIST struc +SmaclistData dw ? +SmaclistPos dw ? +SmaclistTotalwidth dw ? +SmaclistNum dw ? +SmaclistLwidth dw ? +PRS_SMACLIST ends +PR_SMACLIST struc +SmaclistRoot PRS_ROOT <> +SmaclistWin PRS_WIN <> +SmaclistLodger PRS_LODGER <> +SmaclistSmaclist PRS_SMACLIST <> +PR_SMACLIST ends +; Types for aclist +PUSH_BUT struc +PUSH_BUTKeycode dw ? +PUSH_BUTStr db (1) * 1 dup (?) +PUSH_BUT ends +; Property of aclist +PRS_ACLIST struc +AclistText dw ? +AclistWidth dw ? +AclistY1 dw ? +AclistY2 dw ? +PRS_ACLIST ends +PR_ACLIST struc +AclistRoot PRS_ROOT <> +AclistWin PRS_WIN <> +AclistLodger PRS_LODGER <> +AclistSmaclist PRS_SMACLIST <> +AclistAclist PRS_ACLIST <> +PR_ACLIST ends diff --git a/code/SIBOSDK/include/agnsym.h b/code/SIBOSDK/include/agnsym.h new file mode 100644 index 0000000..1a7fea6 --- /dev/null +++ b/code/SIBOSDK/include/agnsym.h @@ -0,0 +1,17 @@ +/* +Symbols in the agn symbol fonts +*/ + +/* avoiding using 0 */ +#define AGN_SYM_BELL 1 +#define AGN_SYM_MEMO 2 +#define AGN_SYM_CHEVRON 3 /* could use CHAR 175 of standard fonts instead */ +#define AGN_SYM_CANDLE 4 +#define AGN_SYM_UNTIL_ARROW 5 +#define AGN_SYM_BULLET 6 +#define AGN_SYM_NONBRK_SPACE 7 +#define AGN_SYM_TODO_PTY(X) (11+X) +#define AGN_SYM_UP_ARROW 24 +#define AGN_SYM_DOWN_ARROW 25 +#define AGN_SYM_RIGHT_ARROW 26 +#define AGN_SYM_LEFT_ARROW 27 diff --git a/code/SIBOSDK/include/alloc.h b/code/SIBOSDK/include/alloc.h new file mode 100644 index 0000000..e618769 --- /dev/null +++ b/code/SIBOSDK/include/alloc.h @@ -0,0 +1,86 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* alloc.h - header file for memory allocation functions. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _ALLOC_INC_ +#define _ALLOC_INC_ + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +struct _heapinfo { + int * _pentry; + size_t _size; + int _useflag; + void * _secret; +}; + +#ifndef __STDC__ +struct _nheapinfo { + int * _pentry; + size_t _size; + int _useflag; + void * _secret; +}; +#endif + +#define _HEAPOK 0 +#define _HEAPEMPTY -1 +#define _HEAPBADBEGIN -2 +#define _HEAPBADNODE -3 +#define _HEAPOVERFLOW -4 +#define _HEAPEND -5 +#define _HEAPBADPTR -6 + +#ifdef __cplusplus +extern "C" { +#endif +extern void * calloc(size_t _num, size_t _size); +extern void free(void *_block); +extern void * malloc(size_t _size); +extern void * realloc(void *_block, size_t _size); +extern size_t stackavail(void); +#ifdef __cplusplus +} +#endif + +#ifndef __STDC__ +#ifdef __cplusplus +extern "C" { +#endif +extern int _msize(void *_buffer); +extern size_t _memmax(void); +extern size_t _memavl(void); +extern int _heapchk(void); +extern int _heapset(int _fill); +extern int _heapwalk(struct _heapinfo *_entry); +extern unsigned _freect(size_t _size); +extern unsigned coreleft(void); +extern void * _ncalloc(size_t num, size_t _size); +extern void _nfree(void *_block); +extern void * _nmalloc(size_t _size); +extern void * _nrealloc(void *_block, size_t _size); +extern int _nheapchk(void); +extern int _nheapset(int _fill); +extern int _nheapwalk(struct _nheapinfo *_nearentry); +extern int _nmsize(void *_buffer); +extern unsigned nearcoreleft(void); +#ifdef __cplusplus +} +#endif +#endif + +#endif diff --git a/code/SIBOSDK/include/appman.g b/code/SIBOSDK/include/appman.g new file mode 100644 index 0000000..57da990 --- /dev/null +++ b/code/SIBOSDK/include/appman.g @@ -0,0 +1,180 @@ +/* Generated by Ctran from appman.cat */ +#define APPMAN_G +#ifndef VARRAY_G +#include +#endif +/* Class Numbers */ +#define C_CLEANUP 9 +#define C_ACTIVE 10 +#define C_AIDLE 11 +#define C_RSCFILE 12 +#define C_SYSTEM 13 +#define C_IPCS 14 +#define C_APPMAN 15 +/* Method Numbers */ +#define O_RS_READ_BUF 3 +#define O_CL_REMOVE 26 +#define O_CL_CLEAN_LEVEL 28 +#define O_SY_ICON_POS 2 +#define O_CL_INIT 24 +#define O_SY_LINK_PASTE 4 +#define O_CL_SET_LEVEL 29 +#define O_SY_LINK_SERVER 3 +#define O_AM_NOTIFYERR 10 +#define O_AM_ADD_TASK 4 +#define O_AM_WAIT 5 +#define O_AO_ABRUN 3 +#define O_AM_START 2 +#define O_AM_NOTIFY 9 +#define O_AM_CLEAN_UP 11 +#define O_AO_CANCEL 2 +#define O_AO_QUEUE 4 +#define O_AM_RSCNAME 8 +#define O_SY_EXEC_OPEN 5 +#define O_AO_INIT 1 +#define O_CL_CLEAN_ITEM 27 +#define O_RS_READ 2 +#define O_CL_ADD 25 +#define O_AM_ONLYONE 12 +#define O_SY_INIT 1 +#define O_IP_ADD_SERVER 6 +#define O_AM_FINDIMG 13 +#define O_RS_INIT 1 +#define O_AM_LOAD_RES_BUF 7 +#define O_AO_RUN 5 +#define O_AM_STOP 3 +#define O_AM_CHANGE_PRI 14 +#define O_AM_INIT 1 +#define O_AM_LOAD_RESOURCE 6 +/* Constants for cleanup */ +#define TY_CLEANUP_DYL -5 +#define TY_CLEANUP_SHARED -4 +#define TY_CLEANUP_VOID -3 +#define TY_CLEANUP_ALLOC -2 +#define TY_CLEANUP_IOCHAN -1 +#define TY_CLEANUP_OBJECT 0 +/* Types for cleanup */ +typedef struct +{ +char type; +unsigned char level; +int h; +} RC_CLEANUP; +typedef struct +{ +unsigned short int nref; +} SHARED_ALLOC; +/* Property of cleanup */ +typedef struct { +unsigned short int level; +} PRS_CLEANUP; +typedef struct pr_cleanup +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VAFLAT vaflat; +PRS_CLEANUP cleanup; +} PR_CLEANUP; +/* Constants for active */ +#define PRIORITY_ACTIVE_POSTER 100 +#define PRIORITY_ACTIVE_IPCS 80 +#define PRIORITY_ACTIVE_VOICE 70 +#define PRIORITY_ACTIVE_WSERV 60 +#define PRIORITY_ACTIVE_COMMAND 40 +#define PRIORITY_ACTIVE_SERIAL 20 +#define PRIORITY_ACTIVE_ALARM 0 +#define PRIORITY_ACTIVE_FILES -20 +#define PRIORITY_ACTIVE_REPEATER -40 +#define PRIORITY_ACTIVE_PRINT -60 +#define PRIORITY_ACTIVE_COMPUTE -100 +/* Property of active */ +typedef struct { +P_QUE q; +char priority; +unsigned char isactive; +unsigned char *pcb; +short int stat; +} PRS_ACTIVE; +typedef struct pr_active +{ +PRS_ROOT root; +PRS_ACTIVE active; +} PR_ACTIVE; +/* Property of aidle */ +typedef struct pr_aidle +{ +PRS_ROOT root; +PRS_ACTIVE active; +} PR_AIDLE; +/* Types for rscfile */ +typedef struct +{ +unsigned short int pos; +unsigned short int len; +} PR_RSCFILE_HEAD; +/* Property of rscfile */ +typedef struct { +unsigned char *pcb; +PR_RSCFILE_HEAD ix; +unsigned short int offset; +unsigned long int hftree; +} PRS_RSCFILE; +typedef struct pr_rscfile +{ +PRS_ROOT root; +PRS_RSCFILE rscfile; +} PR_RSCFILE; +/* Constants for system */ +#define IC_SYSTEM_ALLOC 0 +#define IC_SYSTEM_REMOVE 1 +#define IC_SYSTEM_REPLACE 2 +/* Property of system */ +typedef struct { +unsigned short int pid; +} PRS_SYSTEM; +typedef struct pr_system +{ +PRS_ROOT root; +PRS_SYSTEM system; +} PR_SYSTEM; +/* Property of ipcs */ +typedef struct { +P_QUE hd; +} PRS_IPCS; +typedef struct pr_ipcs +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_IPCS ipcs; +} PR_IPCS; +/* Constants for appman */ +#define FLG_APPMAN_CLEAN 0x01 +#define FLG_APPMAN_SYSTEM 0x02 +#define FLG_APPMAN_RSCFILE 0x04 +#define FLG_APPMAN_SRSCFILE 0x08 +#define FLG_APPMAN_IPCS 0x10 +#define FLG_APPMAN_ONLYONE 0x20 +#define FLG_APPMAN_NODBG 0x40 +#define RUN_ACTIVE_UNUSED 0 +#define RUN_ACTIVE_USED 1 +#define ERR_APPMAN_APPL -512 +/* Property of appman */ +typedef struct { +PR_CLEANUP *clean; +PR_SYSTEM *system; +PR_RSCFILE *rcb; +PR_RSCFILE *srcb; +PR_IPCS *ipcs; +P_QUE task; +unsigned short int stop; +short int nrid; +short int err; +unsigned char *spare1; +unsigned char *spare2; +} PRS_APPMAN; +typedef struct pr_appman +{ +PRS_ROOT root; +PRS_APPMAN appman; +} PR_APPMAN; diff --git a/code/SIBOSDK/include/appman.ing b/code/SIBOSDK/include/appman.ing new file mode 100644 index 0000000..dc987e5 --- /dev/null +++ b/code/SIBOSDK/include/appman.ing @@ -0,0 +1,170 @@ +; Generated by Ctran from appman.cat +APPMAN_ING equ 1 +IFNDEF VARRAY_ING + INCLUDE ..\inc\VARRAY.ING +ENDIF +; Class Numbers +C_CLEANUP equ 9 +C_ACTIVE equ 10 +C_AIDLE equ 11 +C_RSCFILE equ 12 +C_SYSTEM equ 13 +C_IPCS equ 14 +C_APPMAN equ 15 +; Method Numbers +O_RS_READ_BUF equ 3 +O_CL_REMOVE equ 26 +O_CL_CLEAN_LEVEL equ 28 +O_SY_ICON_POS equ 2 +O_CL_INIT equ 24 +O_SY_LINK_PASTE equ 4 +O_CL_SET_LEVEL equ 29 +O_SY_LINK_SERVER equ 3 +O_AM_NOTIFYERR equ 10 +O_AM_ADD_TASK equ 4 +O_AM_WAIT equ 5 +O_AO_ABRUN equ 3 +O_AM_START equ 2 +O_AM_NOTIFY equ 9 +O_AM_CLEAN_UP equ 11 +O_AO_CANCEL equ 2 +O_AO_QUEUE equ 4 +O_AM_RSCNAME equ 8 +O_SY_EXEC_OPEN equ 5 +O_AO_INIT equ 1 +O_CL_CLEAN_ITEM equ 27 +O_RS_READ equ 2 +O_CL_ADD equ 25 +O_AM_ONLYONE equ 12 +O_SY_INIT equ 1 +O_IP_ADD_SERVER equ 6 +O_AM_FINDIMG equ 13 +O_RS_INIT equ 1 +O_AM_LOAD_RES_BUF equ 7 +O_AO_RUN equ 5 +O_AM_STOP equ 3 +O_AM_CHANGE_PRI equ 14 +O_AM_INIT equ 1 +O_AM_LOAD_RESOURCE equ 6 +; Constants for cleanup +TY_CLEANUP_DYL equ (-5) +TY_CLEANUP_SHARED equ (-4) +TY_CLEANUP_VOID equ (-3) +TY_CLEANUP_ALLOC equ (-2) +TY_CLEANUP_IOCHAN equ (-1) +TY_CLEANUP_OBJECT equ (0) +; Types for cleanup +RC_CLEANUP struc +RC_CLEANUPType db ? +RC_CLEANUPLevel db ? +RC_CLEANUPH dw ? +RC_CLEANUP ends +SHARED_ALLOC struc +SHARED_ALLOCNref dw ? +SHARED_ALLOC ends +; Property of cleanup +PRS_CLEANUP struc +CleanupLevel dw ? +PRS_CLEANUP ends +PR_CLEANUP struc +CleanupRoot PRS_ROOT <> +CleanupVaroot PRS_VAROOT <> +CleanupVafix PRS_VAFIX <> +CleanupVaflat PRS_VAFLAT <> +CleanupCleanup PRS_CLEANUP <> +PR_CLEANUP ends +; Constants for active +PRIORITY_ACTIVE_POSTER equ (100) +PRIORITY_ACTIVE_IPCS equ (80) +PRIORITY_ACTIVE_VOICE equ (70) +PRIORITY_ACTIVE_WSERV equ (60) +PRIORITY_ACTIVE_COMMAND equ (40) +PRIORITY_ACTIVE_SERIAL equ (20) +PRIORITY_ACTIVE_ALARM equ (0) +PRIORITY_ACTIVE_FILES equ (-20) +PRIORITY_ACTIVE_REPEATER equ (-40) +PRIORITY_ACTIVE_PRINT equ (-60) +PRIORITY_ACTIVE_COMPUTE equ (-100) +; Property of active +PRS_ACTIVE struc +ActiveQ P_QUE <> +ActivePriority db ? +ActiveIsactive db ? +ActivePcb dw ? +ActiveStat dw ? +PRS_ACTIVE ends +PR_ACTIVE struc +ActiveRoot PRS_ROOT <> +ActiveActive PRS_ACTIVE <> +PR_ACTIVE ends +; Property of aidle +PR_AIDLE struc +AidleRoot PRS_ROOT <> +AidleActive PRS_ACTIVE <> +PR_AIDLE ends +; Types for rscfile +PR_RSCFILE_HEAD struc +PR_RSCFILE_HEADPos dw ? +PR_RSCFILE_HEADLen dw ? +PR_RSCFILE_HEAD ends +; Property of rscfile +PRS_RSCFILE struc +RscfilePcb dw ? +RscfileIx PR_RSCFILE_HEAD <> +RscfileOffset dw ? +RscfileHftree dd ? +PRS_RSCFILE ends +PR_RSCFILE struc +RscfileRoot PRS_ROOT <> +RscfileRscfile PRS_RSCFILE <> +PR_RSCFILE ends +; Constants for system +IC_SYSTEM_ALLOC equ (0) +IC_SYSTEM_REMOVE equ (1) +IC_SYSTEM_REPLACE equ (2) +; Property of system +PRS_SYSTEM struc +SystemPid dw ? +PRS_SYSTEM ends +PR_SYSTEM struc +SystemRoot PRS_ROOT <> +SystemSystem PRS_SYSTEM <> +PR_SYSTEM ends +; Property of ipcs +PRS_IPCS struc +IpcsHd P_QUE <> +PRS_IPCS ends +PR_IPCS struc +IpcsRoot PRS_ROOT <> +IpcsActive PRS_ACTIVE <> +IpcsIpcs PRS_IPCS <> +PR_IPCS ends +; Constants for appman +FLG_APPMAN_CLEAN equ (001h) +FLG_APPMAN_SYSTEM equ (002h) +FLG_APPMAN_RSCFILE equ (004h) +FLG_APPMAN_SRSCFILE equ (008h) +FLG_APPMAN_IPCS equ (010h) +FLG_APPMAN_ONLYONE equ (020h) +FLG_APPMAN_NODBG equ (040h) +RUN_ACTIVE_UNUSED equ (0) +RUN_ACTIVE_USED equ (1) +ERR_APPMAN_APPL equ (-512) +; Property of appman +PRS_APPMAN struc +AppmanClean dw ? +AppmanSystem dw ? +AppmanRcb dw ? +AppmanSrcb dw ? +AppmanIpcs dw ? +AppmanTask P_QUE <> +AppmanStop dw ? +AppmanNrid dw ? +AppmanErr dw ? +AppmanSpare1 dw ? +AppmanSpare2 dw ? +PRS_APPMAN ends +PR_APPMAN struc +AppmanRoot PRS_ROOT <> +AppmanAppman PRS_APPMAN <> +PR_APPMAN ends diff --git a/code/SIBOSDK/include/assert.h b/code/SIBOSDK/include/assert.h new file mode 100644 index 0000000..1e161be --- /dev/null +++ b/code/SIBOSDK/include/assert.h @@ -0,0 +1,28 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* assert.h - assert macro. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifdef NDEBUG +#define assert(ignore) ((void) 0) +#else +#include + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort(void); +#ifdef __cplusplus +} +#endif + +#define assert(p) ((p) ? ((void) 0) : (( (void) fprintf(stderr,\ + "Assertion failed: %s, file %s, line %d\n",\ + #p, __FILE__, __LINE__)), (abort()))) +#endif diff --git a/code/SIBOSDK/include/ats.h b/code/SIBOSDK/include/ats.h new file mode 100644 index 0000000..3e83d8d --- /dev/null +++ b/code/SIBOSDK/include/ats.h @@ -0,0 +1,68 @@ +/* + File: ATS.H + Copyright (C) Psion PLC 1993 + Started by : DavidW + Started on: 12/02/93 +*/ +#ifndef ATS_H +#define ATS_H + +#include +#include + +typedef struct + { + UWORD main; + UWORD mainlen; + UWORD buts; + WORD butslen; + } ATS_DIAL_DEF; + +typedef struct + { + UWORD key; + UWORD mod; + } ATS_KEY_DEF; + +typedef union + { + UWORD position; + ATS_KEY_DEF k; + ATS_DIAL_DEF d; + UWORD delay; + VOID *offs; + WORD par; + UWORD wid; + } ATS_MESS_BODY; + +typedef struct + { + E_MESSAGE mess; + ATS_MESS_BODY u; + } ATS_MESS; + +#define TY_ATS_CLIENT_POS 0x30 +#define TY_ATS_KEY 0x31 +#define TY_ATS_PAUSE 0x32 +#define TY_ATS_MESSAGE 0x33 +#define TY_ATS_DIALOG 0x34 +#define TY_ATS_SELF_CHECK 0x35 +#define TY_ATS_WINDOW_XSUM 0x36 +#define TY_ATS_RECORD 0x37 +#define TY_ATS_GET_KEY 0x38 +#define TY_ATS_ALLCOUNT 0x39 + +#define TY_ATS_START_RANGE 0x30 +#define TY_ATS_END_RANGE 0x3f + +typedef struct + { + UWORD time; + UWORD keycode; + UBYTE modifiers; + UBYTE count; + } ATS_KEY; + +#define ATS_MAX_EDITOR_LEN 256 /* includes trailing zero */ + +#endif // ATS_H \ No newline at end of file diff --git a/code/SIBOSDK/include/atssv.g b/code/SIBOSDK/include/atssv.g new file mode 100644 index 0000000..0242caa --- /dev/null +++ b/code/SIBOSDK/include/atssv.g @@ -0,0 +1,40 @@ +/* Generated by Ctran from atssv.cl */ +#define ATSSV_G +#ifndef IPC_G +#include +#endif +#ifndef TIMER_G +#include +#endif +#ifndef ATS_H +#include +#endif +/* Class Numbers */ +#define C_ATSSV 13 +#define C_ATSTIM 14 +/* Method Numbers */ +#define O_SV_KEY 5 +#define O_SV_FREE 4 +/* Property of atssv */ +typedef struct { +PR_TIMER *timer; +void *pm; +short int freed; +void *pm_key; +} PRS_ATSSV; +typedef struct pr_atssv +{ +PRS_ROOT root; +PRS_SERVER server; +PRS_ATSSV atssv; +} PR_ATSSV; +/* Property of atstim */ +typedef struct { +void *owner; +} PRS_ATSTIM; +typedef struct pr_atstim +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_ATSTIM atstim; +} PR_ATSTIM; diff --git a/code/SIBOSDK/include/atssv.ing b/code/SIBOSDK/include/atssv.ing new file mode 100644 index 0000000..59e2912 --- /dev/null +++ b/code/SIBOSDK/include/atssv.ing @@ -0,0 +1,38 @@ +; Generated by Ctran from atssv.cl +ATSSV_ING equ 1 +IFNDEF IPC_ING + INCLUDE ..\inc\IPC.ING +ENDIF +IFNDEF TIMER_ING + INCLUDE ..\inc\TIMER.ING +ENDIF +IFNDEF ATS_INC + INCLUDE ..\inc\ATS.INC +ENDIF +; Class Numbers +C_ATSSV equ 13 +C_ATSTIM equ 14 +; Method Numbers +O_SV_KEY equ 5 +O_SV_FREE equ 4 +; Property of atssv +PRS_ATSSV struc +AtssvTimer dw ? +AtssvPm dw ? +AtssvFreed dw ? +AtssvPm_key dw ? +PRS_ATSSV ends +PR_ATSSV struc +AtssvRoot PRS_ROOT <> +AtssvServer PRS_SERVER <> +AtssvAtssv PRS_ATSSV <> +PR_ATSSV ends +; Property of atstim +PRS_ATSTIM struc +AtstimOwner dw ? +PRS_ATSTIM ends +PR_ATSTIM struc +AtstimRoot PRS_ROOT <> +AtstimActive PRS_ACTIVE <> +AtstimAtstim PRS_ATSTIM <> +PR_ATSTIM ends diff --git a/code/SIBOSDK/include/bcd.hpp b/code/SIBOSDK/include/bcd.hpp new file mode 100644 index 0000000..5e39a5c --- /dev/null +++ b/code/SIBOSDK/include/bcd.hpp @@ -0,0 +1,338 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* BCD.HPP - header file for BCD math. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef __BCD_INC_ +#define __BCD_INC_ + +#include +#include + +#define _BcdMaxDecimals 100 + +typedef enum { ExpZero, ExpNan }; + +class bcd { + +friend long double real(bcd&); + +friend bcd abs(bcd&); +friend bcd acos(bcd&); +friend bcd asin(bcd&); +friend bcd atan(bcd&); +friend bcd cos(bcd&); +friend bcd cosh(bcd&); +friend bcd exp(bcd&); +friend bcd log(bcd&); +friend bcd log10(bcd&); +friend bcd pow(bcd& base, bcd& expon); +friend bcd sin(bcd&); +friend bcd sinh(bcd&); +friend bcd sqrt(bcd&); +friend bcd tan(bcd&); +friend bcd tanh(bcd&); + +friend bcd operator+(bcd&, bcd&); +friend bcd operator+(long double, bcd&); +friend bcd operator+(bcd&, long double); +friend bcd operator-(bcd&, bcd&); +friend bcd operator-(long double, bcd&); +friend bcd operator-(bcd&, long double); +friend bcd operator*(bcd&, bcd&); +friend bcd operator*(long double, bcd&); +friend bcd operator*(bcd&, long double); +friend bcd operator/(bcd&, bcd&); +friend bcd operator/(long double, bcd&); +friend bcd operator/(bcd&, long double); +friend int operator==(bcd&, bcd&); +friend int operator!=(bcd&, bcd&); +friend int operator>=(bcd&, bcd&); +friend int operator<=(bcd&, bcd&); +friend int operator>(bcd&, bcd&); +friend int operator<(bcd&, bcd&); +friend ostream& operator<<(ostream&, bcd&); +friend istream& operator>>(istream&, bcd&); + +public: + + bcd(int x=0); + bcd(unsigned x); + bcd(long x); + bcd(unsigned long x); + bcd(double x, int decimals = _BcdMaxDecimals); + bcd(long double x, int decimals = _BcdMaxDecimals); + + bcd& operator+=(bcd&); + bcd& operator+=(long double); + bcd& operator-=(bcd&); + bcd& operator-=(long double); + bcd& operator*=(bcd&); + bcd& operator*=(long double); + bcd& operator/=(bcd&); + bcd& operator/=(long double); + bcd operator+(); + bcd operator-(); + + long double dec_to_real(); + void real_to_dec(long double num, int decimals = _BcdMaxDecimals); + +private: + + void int_to_dec(unsigned long); + void bcd_copy_from(unsigned char *dest); + void bcd_copy_to(unsigned char *source); + + unsigned char bcd_array[10]; + unsigned char exp; +}; + + +inline bcd::bcd(long double x, int decimals) { + + real_to_dec(x, decimals); +} + +inline bcd::bcd(double x, int decimals) { + + real_to_dec((long double) x, decimals); +} + + +inline long double real(bcd& z) { + + return z.dec_to_real(); +} + +inline bcd& bcd::operator+=(bcd& b) { + + real_to_dec(real(*this)+real(b)); + return *this; +} + +inline bcd& bcd::operator+=(long double b) { + + real_to_dec(real(*this)+b); + return *this; +} + +inline bcd& bcd::operator-=(bcd& b) { + + real_to_dec(real(*this)-real(b)); + return *this; +} + +inline bcd& bcd::operator-=(long double b) { + + real_to_dec(real(*this)-b); + return *this; +} + +inline bcd& bcd::operator*=(bcd& b) { + + real_to_dec(real(*this)*real(b)); + return *this; +} + +inline bcd& bcd::operator*=(long double b) { + + real_to_dec(real(*this)*b); + return *this; +} + +inline bcd& bcd::operator/=(bcd& b) { + + real_to_dec(real(*this)/real(b)); + return *this; +} + +inline bcd& bcd::operator/=(long double b) { + + real_to_dec(real(*this)/b); + return *this; +} + +inline bcd operator+(bcd& a, bcd& b) { + + return bcd(real(a)+real(b)); +} + +inline bcd operator+(long double a, bcd& b) { + + return bcd(a+real(b)); +} + +inline bcd operator+(bcd& a, long double b) { + + return bcd(real(a)+b); +} + +inline bcd operator-(bcd& a, bcd& b) { + + return bcd(real(a)-real(b)); +} + +inline bcd operator-(long double a, bcd& b) { + + return bcd(a-real(b)); +} + +inline bcd operator-(bcd& a, long double b) { + + return bcd(real(a)-b); +} + +inline bcd operator*(bcd& a, bcd& b) { + + return bcd(real(a)*real(b)); +} + +inline bcd operator*(long double a, bcd& b) { + + return bcd(a*real(b)); +} + +inline bcd operator*(bcd& a, long double b) { + + return bcd(real(a)*b); +} + +inline bcd operator/(bcd& a, bcd& b) { + + return bcd(real(a)/real(b)); +} + +inline bcd operator/(long double a, bcd& b) { + + return bcd(a/real(b)); +} + +inline bcd operator/(bcd& a, long double b) { + + return bcd(real(a)/b); +} + +inline int operator==(bcd& a, bcd& b) { + + return real(a) == real(b); +} + +inline int operator!=(bcd& a, bcd& b) { + + return real(a) != real(b); +} + +inline int operator>=(bcd& a, bcd& b) { + + return real(a) >= real(b); +} + +inline int operator<=(bcd& a, bcd& b) { + + return real(a) <= real(b); +} + +inline int operator<(bcd& a, bcd& b) { + + return real(a) < real(b); +} + +inline int operator>(bcd& a, bcd& b) { + + return real(a) > real(b); +} + +inline bcd bcd::operator+() { + + return *this; +} + +inline bcd abs(bcd& a) { + + return bcd(fabsl(real(a))); +} + +inline bcd acos(bcd& a) { + + return bcd(acosl(real(a))); +} + +inline bcd asin(bcd& a) { + + return bcd(asinl(real(a))); +} + +inline bcd atan(bcd& a) { + + return bcd(atanl(real(a))); +} + +inline bcd cos(bcd& a) { + + return bcd(cosl(real(a))); +} + +inline bcd cosh(bcd& a) { + + return bcd(coshl(real(a))); +} + +inline bcd exp(bcd& a) { + + return bcd(expl(real(a))); +} + +inline bcd log(bcd& a) { + + return bcd(logl(real(a))); +} + +inline bcd log10(bcd& a) { + + return bcd(log10l(real(a))); +} + +inline bcd sin(bcd& a) { + + return bcd(sinl(real(a))); +} + +inline bcd sinhl(bcd& a) { + + return bcd(sinhl(real(a))); +} + +inline bcd sqrt(bcd& a) { + + return bcd(sqrtl(real(a))); +} + +inline bcd tan(bcd& a) { + + return bcd(tanl(real(a))); +} + +inline bcd tanh(bcd& a) { + + return bcd(tanhl(real(a))); +} + +inline bcd pow(bcd& a, bcd& b) { + + return bcd(powl(real(a), real(b))); +} + +inline bcd pow10(int n, bcd& a) { + + return bcd( pow10(n) * real(a) ); +} + + +#endif + diff --git a/code/SIBOSDK/include/bwin.g b/code/SIBOSDK/include/bwin.g new file mode 100644 index 0000000..3c80d4b --- /dev/null +++ b/code/SIBOSDK/include/bwin.g @@ -0,0 +1,26 @@ +/* Generated by Ctran from bwin.cl */ +#define BWIN_G +#ifndef WIN_G +#include +#endif +/* Class Numbers */ +#define C_BWIN 2 +/* Method Numbers */ +/* Constants for bwin */ +#define IN_BWIN_CORNER_4 PR_BWIN_CORNER_4 +#define IN_BWIN_SHADOW_1 PR_BWIN_SHADOW_1 +#define IN_BWIN_SHADOW_2 PR_BWIN_SHADOW_2 +#define IN_BWIN_CUSHION PR_BWIN_CUSHION +#define IN_BWIN_OPEN PR_BWIN_OPEN +#define BWIN_CUSHION_X 1 +#define BWIN_CUSHION_Y 1 +#define BWIN_SHADOW_1_HEIGHT 1 +#define BWIN_SHADOW_1_WIDTH 1 +#define BWIN_SHADOW_2_HEIGHT 2 +#define BWIN_SHADOW_2_WIDTH 2 +/* Property of bwin */ +typedef struct pr_bwin +{ +PRS_ROOT root; +PRS_WIN win; +} PR_BWIN; diff --git a/code/SIBOSDK/include/bwin.ing b/code/SIBOSDK/include/bwin.ing new file mode 100644 index 0000000..ee1c516 --- /dev/null +++ b/code/SIBOSDK/include/bwin.ing @@ -0,0 +1,25 @@ +; Generated by Ctran from bwin.cl +BWIN_ING equ 1 +IFNDEF WIN_ING + INCLUDE ..\inc\WIN.ING +ENDIF +; Class Numbers +C_BWIN equ 2 +; Method Numbers +; Constants for bwin +IN_BWIN_CORNER_4 equ (PR_BWIN_CORNER_4) +IN_BWIN_SHADOW_1 equ (PR_BWIN_SHADOW_1) +IN_BWIN_SHADOW_2 equ (PR_BWIN_SHADOW_2) +IN_BWIN_CUSHION equ (PR_BWIN_CUSHION) +IN_BWIN_OPEN equ (PR_BWIN_OPEN) +BWIN_CUSHION_X equ (1) +BWIN_CUSHION_Y equ (1) +BWIN_SHADOW_1_HEIGHT equ (1) +BWIN_SHADOW_1_WIDTH equ (1) +BWIN_SHADOW_2_HEIGHT equ (2) +BWIN_SHADOW_2_WIDTH equ (2) +; Property of bwin +PR_BWIN struc +BwinRoot PRS_ROOT <> +BwinWin PRS_WIN <> +PR_BWIN ends diff --git a/code/SIBOSDK/include/calimg.g b/code/SIBOSDK/include/calimg.g new file mode 100644 index 0000000..1c2bad4 --- /dev/null +++ b/code/SIBOSDK/include/calimg.g @@ -0,0 +1,126 @@ +/* Generated by Ctran from calimg.cat */ +#define CALIMG_G +#ifndef WLIB_H +#include +#endif +/* Class Numbers */ +#define C_CALIMG 11 +/* Method Numbers */ +#define O_CI_SENSE 8 +#define O_CI_TODAY_CHANGED 11 +#define O_CI_MOVE_CURSOR 4 +#define O_CI_REDRAW 7 +#define O_CI_EMPHASISE 3 +#define O_CI_GOTO_DATE 5 +#define O_CI_POS_MXY 10 +#define O_CI_SET_TITLE 2 +#define O_CI_ADJUST_DATE 6 +#define O_CI_INIT 1 +#define O_CI_VIEW 9 +/* Constants for calimg */ +#define CI_MAX_MONTH 12 +#define CI_GRIDY TRUE +#define CI_GRIDX FALSE +#define CALIMG_CURSOR_NO_FLASH 0x01 +#define CALIMG_DOW_EVERY_ROW 0x02 +#define CALIMG_FONT_DATA_KNOWN 0x04 +#define CALIMG_LEFT 0x00 +#define CALIMG_HOME 0x01 +#define CALIMG_PREV_DAY 0x02 +#define CALIMG_PREV_MONTH 0x03 +#define CALIMG_RIGHT 0x04 +#define CALIMG_END 0x05 +#define CALIMG_NEXT_DAY 0x06 +#define CALIMG_NEXT_MONTH 0x07 +#define CALIMG_UP 0x08 +#define CALIMG_PAGEUP 0x09 +#define CALIMG_PREV_WEEK 0x0A +#define CALIMG_PREV_YEAR 0x0B +#define CALIMG_DOWN 0x0C +#define CALIMG_PAGEDN 0x0D +#define CALIMG_NEXT_WEEK 0x0E +#define CALIMG_NEXT_YEAR 0x0F +#define CALIMG_GOTO_TODAY 0x10 +#define CALIMG_WEST 0x01 +#define CALIMG_EAST 0x02 +#define CALIMG_NORTH 0x03 +#define CALIMG_SOUTH 0x04 +#define CALIMG_ADJ_DAY 0x01 +#define CALIMG_ADJ_MONTH 0x02 +#define CALIMG_ADJ_YEAR 0x04 +/* Types for calimg */ +typedef struct +{ +unsigned char title_ascent; +unsigned char title_lht; +unsigned char dow_ascent; +unsigned char dow_lht; +unsigned char mth_ascent; +unsigned char mth_lht; +unsigned char day_ascent; +unsigned char day_lht; +unsigned char daygapx; +unsigned char daywidth; +} CI_EXT_FONT; +typedef struct +{ +short int fid; +unsigned short int style; +unsigned short int leading; +} CI_FONT_DATA; +typedef struct +{ +unsigned short int wid; +unsigned short int width; +P_POINT tl; +unsigned char mrow; +unsigned char mcol; +unsigned short int flags; +CI_FONT_DATA title; +CI_FONT_DATA month; +CI_FONT_DATA dow; +CI_FONT_DATA day; +unsigned short int daygap; +unsigned char mthgapx; +unsigned char hscrlm; +unsigned short int startm; +unsigned long int days; +CI_EXT_FONT font; +} IN_CALIMG; +typedef struct +{ +unsigned char year; +unsigned char month; +P_POINT pos; +} CI_CURSOR; +typedef struct +{ +short int year; +short int month; +short int day; +}CI_DATE; +/* Property of calimg */ +typedef struct { +P_RECT rect[12]; +P_RECT title_rect; +CI_CURSOR crs; +char day; +unsigned char startOfWeek; +unsigned char thisyear; +unsigned char thismth; +unsigned char thisday; +unsigned char ystart; +unsigned char bwidth; +unsigned char filler; +char dayNameAbbrev[7]; +char deftitle[3]; +char *title; +short int emphasised; +IN_CALIMG img; +int bmid; +} PRS_CALIMG; +typedef struct pr_calimg +{ +PRS_ROOT root; +PRS_CALIMG calimg; +} PR_CALIMG; diff --git a/code/SIBOSDK/include/calimg.ing b/code/SIBOSDK/include/calimg.ing new file mode 100644 index 0000000..150d502 --- /dev/null +++ b/code/SIBOSDK/include/calimg.ing @@ -0,0 +1,120 @@ +; Generated by Ctran from calimg.cl +CALIMG_ING equ 1 +IFNDEF WLIB_INC + INCLUDE ..\inc\WLIB.INC +ENDIF +; Class Numbers +C_CALIMG equ 11 +; Method Numbers +O_CI_SENSE equ 8 +O_CI_TODAY_CHANGED equ 11 +O_CI_MOVE_CURSOR equ 4 +O_CI_REDRAW equ 7 +O_CI_EMPHASISE equ 3 +O_CI_GOTO_DATE equ 5 +O_CI_POS_MXY equ 10 +O_CI_SET_TITLE equ 2 +O_CI_ADJUST_DATE equ 6 +O_CI_INIT equ 1 +O_CI_VIEW equ 9 +; Constants for calimg +CI_MAX_MONTH equ (12) +CI_GRIDY equ (TRUE) +CI_GRIDX equ (FALSE) +CALIMG_CURSOR_NO_FLASH equ (001h) +CALIMG_DOW_EVERY_ROW equ (002h) +CALIMG_FONT_DATA_KNOWN equ (004h) +CALIMG_LEFT equ (000h) +CALIMG_HOME equ (001h) +CALIMG_PREV_DAY equ (002h) +CALIMG_PREV_MONTH equ (003h) +CALIMG_RIGHT equ (004h) +CALIMG_END equ (005h) +CALIMG_NEXT_DAY equ (006h) +CALIMG_NEXT_MONTH equ (007h) +CALIMG_UP equ (008h) +CALIMG_PAGEUP equ (009h) +CALIMG_PREV_WEEK equ (00Ah) +CALIMG_PREV_YEAR equ (00Bh) +CALIMG_DOWN equ (00Ch) +CALIMG_PAGEDN equ (00Dh) +CALIMG_NEXT_WEEK equ (00Eh) +CALIMG_NEXT_YEAR equ (00Fh) +CALIMG_GOTO_TODAY equ (010h) +CALIMG_WEST equ (001h) +CALIMG_EAST equ (002h) +CALIMG_NORTH equ (003h) +CALIMG_SOUTH equ (004h) +CALIMG_ADJ_DAY equ (001h) +CALIMG_ADJ_MONTH equ (002h) +CALIMG_ADJ_YEAR equ (004h) +; Types for calimg +CI_EXT_FONT struc +CI_EXT_FONTTitle_ascent db ? +CI_EXT_FONTTitle_lht db ? +CI_EXT_FONTDow_ascent db ? +CI_EXT_FONTDow_lht db ? +CI_EXT_FONTMth_ascent db ? +CI_EXT_FONTMth_lht db ? +CI_EXT_FONTDay_ascent db ? +CI_EXT_FONTDay_lht db ? +CI_EXT_FONTDaygapx db ? +CI_EXT_FONTDaywidth db ? +CI_EXT_FONT ends +CI_FONT_DATA struc +CI_FONT_DATAFid dw ? +CI_FONT_DATAStyle dw ? +CI_FONT_DATALeading dw ? +CI_FONT_DATA ends +IN_CALIMG struc +IN_CALIMGWid dw ? +IN_CALIMGWidth dw ? +IN_CALIMGTl P_POINT <> +IN_CALIMGMrow db ? +IN_CALIMGMcol db ? +IN_CALIMGFlags dw ? +IN_CALIMGTitle CI_FONT_DATA <> +IN_CALIMGMonth CI_FONT_DATA <> +IN_CALIMGDow CI_FONT_DATA <> +IN_CALIMGDay CI_FONT_DATA <> +IN_CALIMGDaygap dw ? +IN_CALIMGMthgapx db ? +IN_CALIMGHscrlm db ? +IN_CALIMGStartm dw ? +IN_CALIMGDays dd ? +IN_CALIMGFont CI_EXT_FONT <> +IN_CALIMG ends +CI_CURSOR struc +CI_CURSORYear db ? +CI_CURSORMonth db ? +CI_CURSORPos P_POINT <> +CI_CURSOR ends +CI_DATE struc +CI_DATEYear dw ? +CI_DATEMonth dw ? +CI_DATEDay dw ? +CI_DATE ends +; Property of calimg +PRS_CALIMG struc +CalimgRect db (size P_RECT)* 12 dup (?) +CalimgTitle_rect P_RECT <> +CalimgCrs CI_CURSOR <> +CalimgDay db ? +CalimgStartOfWeek db ? +CalimgThisyear db ? +CalimgThismth db ? +CalimgThisday db ? +CalimgYstart db ? +CalimgBwidth db ? +CalimgFiller db ? +CalimgDayNameAbbrev db (1) * 7 dup (?) +CalimgDeftitle db (1) * 3 dup (?) +CalimgTitle dw ? +CalimgEmphasised dw ? +CalimgImg IN_CALIMG <> +CalimgBmid dw ? +PRS_CALIMG ends +PR_CALIMG struc +CalimgRoot PRS_ROOT <> +CalimgCalimg PRS_CALIMG <> +PR_CALIMG ends diff --git a/code/SIBOSDK/include/calwin.g b/code/SIBOSDK/include/calwin.g new file mode 100644 index 0000000..6fccd7f --- /dev/null +++ b/code/SIBOSDK/include/calwin.g @@ -0,0 +1,48 @@ +/* Generated by Ctran from calwin.cl */ +#define CALWIN_G +#ifndef BWIN_G +#include +#endif +/* Class Numbers */ +#define C_CALIMGWN 9 +#define C_CALWIN 10 +/* Method Numbers */ +/* Property of calimgwn */ +typedef struct { +void *calimg; +} PRS_CALIMGWN; +typedef struct pr_calimgwn +{ +PRS_ROOT root; +PRS_WIN win; +PRS_CALIMGWN calimgwn; +} PR_CALIMGWN; +/* Constants for calwin */ +#define IN_CALWIN_1_MONTH 0x0001 +#define IN_CALWIN_3_MONTH 0x0002 +#define IN_CALWIN_12_MONTH 0x0004 +#define IN_CALWIN_STD_FLAGS 0x0007 +#define IN_CALWIN_USER_SPEC 0x0010 +#define PR_CALWIN_TODAY_HOOKED 0x0020 +/* Types for calwin */ +typedef struct +{ +unsigned short int flags; +unsigned long int days; +P_POINT pos; +void *calimg; +void **self_ptr; +} IN_CALWIN; +/* Property of calwin */ +typedef struct { +PR_CALIMGWN *calimgwn; +void *calimg; +unsigned short int flags; +void **self_ptr; +} PRS_CALWIN; +typedef struct pr_calwin +{ +PRS_ROOT root; +PRS_WIN win; +PRS_CALWIN calwin; +} PR_CALWIN; diff --git a/code/SIBOSDK/include/calwin.ing b/code/SIBOSDK/include/calwin.ing new file mode 100644 index 0000000..3aebe82 --- /dev/null +++ b/code/SIBOSDK/include/calwin.ing @@ -0,0 +1,45 @@ +; Generated by Ctran from calwin.cl +CALWIN_ING equ 1 +IFNDEF BWIN_ING + INCLUDE ..\inc\BWIN.ING +ENDIF +; Class Numbers +C_CALIMGWN equ 9 +C_CALWIN equ 10 +; Method Numbers +; Property of calimgwn +PRS_CALIMGWN struc +CalimgwnCalimg dw ? +PRS_CALIMGWN ends +PR_CALIMGWN struc +CalimgwnRoot PRS_ROOT <> +CalimgwnWin PRS_WIN <> +CalimgwnCalimgwn PRS_CALIMGWN <> +PR_CALIMGWN ends +; Constants for calwin +IN_CALWIN_1_MONTH equ (00001h) +IN_CALWIN_3_MONTH equ (00002h) +IN_CALWIN_12_MONTH equ (00004h) +IN_CALWIN_STD_FLAGS equ (00007h) +IN_CALWIN_USER_SPEC equ (00010h) +PR_CALWIN_TODAY_HOOKED equ (00020h) +; Types for calwin +IN_CALWIN struc +IN_CALWINFlags dw ? +IN_CALWINDays dd ? +IN_CALWINPos P_POINT <> +IN_CALWINCalimg dw ? +IN_CALWINSelf_ptr dw ? +IN_CALWIN ends +; Property of calwin +PRS_CALWIN struc +CalwinCalimgwn dw ? +CalwinCalimg dw ? +CalwinFlags dw ? +CalwinSelf_ptr dw ? +PRS_CALWIN ends +PR_CALWIN struc +CalwinRoot PRS_ROOT <> +CalwinWin PRS_WIN <> +CalwinCalwin PRS_CALWIN <> +PR_CALWIN ends diff --git a/code/SIBOSDK/include/chlist.g b/code/SIBOSDK/include/chlist.g new file mode 100644 index 0000000..642498d --- /dev/null +++ b/code/SIBOSDK/include/chlist.g @@ -0,0 +1,54 @@ +/* Generated by Ctran from chlist.cl */ +#define CHLIST_G +#ifndef LODGER_G +#include +#endif +#ifndef VARES_G +#include +#endif +#ifndef MATCHER_G +#include +#endif +#ifndef LISTBOX_G +#include +#endif +/* Class Numbers */ +#define C_CHLIST 21 +/* Method Numbers */ +/* Constants for chlist */ +#define SE_CHLIST_NSEL 0x01 +#define SE_CHLIST_DATA 0x02 +#define SE_CHLIST_RETAIN 0x04 +#define IN_CHLIST_INCREMENTAL 0x01 +#define PR_CHLIST_RETAIN 0x04 +#define PR_CHLIST_SUSPENDED 0x08 +#define PR_CHLIST_FIXED_WIDTH 0x10 +/* Types for chlist */ +typedef struct +{ +short int rid; +unsigned char nsel; +unsigned char flags; +} IN_CHLIST; +typedef struct +{ +unsigned short int set_flags; +PR_VAROOT *data; +unsigned short int nsel; +} SE_CHLIST; +/* Property of chlist */ +typedef struct { +PR_LISTBOX *pop; +PR_VMATCHER *matcher; +PR_VARES *data; +unsigned short int nsel; +unsigned short int flags; +unsigned short int matchlen; +} PRS_CHLIST; +typedef struct pr_chlist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_CHLIST chlist; +} PR_CHLIST; diff --git a/code/SIBOSDK/include/chlist.ing b/code/SIBOSDK/include/chlist.ing new file mode 100644 index 0000000..f07a616 --- /dev/null +++ b/code/SIBOSDK/include/chlist.ing @@ -0,0 +1,51 @@ +; Generated by Ctran from chlist.cl +CHLIST_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF VARES_ING + INCLUDE ..\inc\VARES.ING +ENDIF +IFNDEF MATCHER_ING + INCLUDE ..\inc\MATCHER.ING +ENDIF +IFNDEF LISTBOX_ING + INCLUDE ..\inc\LISTBOX.ING +ENDIF +; Class Numbers +C_CHLIST equ 21 +; Method Numbers +; Constants for chlist +SE_CHLIST_NSEL equ (001h) +SE_CHLIST_DATA equ (002h) +SE_CHLIST_RETAIN equ (004h) +IN_CHLIST_INCREMENTAL equ (001h) +PR_CHLIST_RETAIN equ (004h) +PR_CHLIST_SUSPENDED equ (008h) +PR_CHLIST_FIXED_WIDTH equ (010h) +; Types for chlist +IN_CHLIST struc +IN_CHLISTRid dw ? +IN_CHLISTNsel db ? +IN_CHLISTFlags db ? +IN_CHLIST ends +SE_CHLIST struc +SE_CHLISTSet_flags dw ? +SE_CHLISTData dw ? +SE_CHLISTNsel dw ? +SE_CHLIST ends +; Property of chlist +PRS_CHLIST struc +ChlistPop dw ? +ChlistMatcher dw ? +ChlistData dw ? +ChlistNsel dw ? +ChlistFlags dw ? +ChlistMatchlen dw ? +PRS_CHLIST ends +PR_CHLIST struc +ChlistRoot PRS_ROOT <> +ChlistWin PRS_WIN <> +ChlistLodger PRS_LODGER <> +ChlistChlist PRS_CHLIST <> +PR_CHLIST ends diff --git a/code/SIBOSDK/include/clib.h b/code/SIBOSDK/include/clib.h new file mode 100644 index 0000000..9994588 --- /dev/null +++ b/code/SIBOSDK/include/clib.h @@ -0,0 +1,290 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* clib.h - internal header file for C library. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _CLIB_INC_ +#define _CLIB_INC_ + +#pragma warn(wall => on) /* enable all warnings */ + +#define _STATIC static /* hide local stuff */ + +#define _IO_MTF +#define _CT_MTF + +#define LONGDOUBLE long double +#define FLOORL(x) floorl(x) +#define LOG10L(x) log10l(x) + +#include +#include +#ifdef _USE_CONIO +#include +#endif +#include +#include +#include +#include +#include +#ifdef _USE_FLOAT +#include +#endif +#ifndef _NO_IO +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _USE_TIME +#include +#include +#endif + +typedef struct sfc { /* control structure for vscanner */ + FILE *_stream; /* file pointer */ + int (*_vs_fill)(FILE *st); /* filler function pointer */ + int _vs_count; /* character count */ + int _s_args; /* argument count */ + jmp_buf _EOFhandler; /* EOF jump environment */ +} SF ; + +typedef struct pf { + FILE *_stream; /* file pointer */ + int (*_vp_flush)(FILE *st); /* output function pointer */ + int _vp_ret; /* character count */ + } PF; + +extern int (*_vs_fill)(FILE *st); /* filler function pointer */ +extern int (*_vp_flush)(FILE *st); /* output function pointer */ + +#ifdef __cplusplus +extern "C" { +#endif +extern int _filler(FILE *st); +extern int _flusher(FILE *st); + +extern int _dup(int handle); /* low level I/O */ +extern int _dup2(int h1, int h2); +extern void _ioerr(int code); +extern unsigned lsl(unsigned sel); + +extern void _exit1(void); +extern void _exit2(void); +extern void _exitf(void); + +extern char *_d_cgets(char *s); +extern int _d_putch(int c); +extern int (*_i_putch)(int c); +extern char *(*_i_cgets)(char *s); + +extern char *_ld_format(char *fmt_buf, LONGDOUBLE num, int flag, int prec); +extern char *_v_format(unsigned long l, char *s); + +extern int _matherr(struct exception *x); +extern int _flsbuf(int ch, FILE *st); +extern int _filbuf(FILE *st); + +#ifdef _USE_TIME +extern clock_t _clock_time(void); +extern size_t _set_date(char *s, size_t scount, size_t lim, char *st); +extern unsigned long _t_calc(struct date dte, struct time tme); +extern int _t_to_struct(unsigned long val, struct date *dte, struct time *tme); +extern struct tm * _t_to_tm(unsigned long clock); +extern unsigned long _t_norm(struct tm *timeptr); +extern unsigned long _ytable(int n); +#endif + +extern va_list _rreal_out(va_list _v_argptr, int flag, int wid, int prec); +extern va_list _real_pdef(va_list _v_argptr, int flag, int wid, int prec); +extern va_list _rreal_in(int pmod, int smod, unsigned flag, int width, va_list _v_argptr); +extern va_list _real_sdef(int pmod, int smod, unsigned flag, int width, va_list _v_argptr); + +extern char *_f_fmt(char *_fmt_buf, LONGDOUBLE num, int flag, int prec); +extern char *_fptoa(unsigned long, char *s); + +extern double _atof(const char *s, int flag, int *pos); + +extern int _pf_entry(FILE *st); +extern void _pf_exit(FILE *st, int flag); +extern void _vp_setbuf(FILE *st, char *buf); +extern void _vp_freebuf(FILE *st); + +extern FILE *_alloc_stream(FILE *stream, int handle, int flag); +extern void _flushall(void); +extern int _free_stream(void); +extern int _getfmode(const char *path); +extern int _open_stream(const char *path, int *fptr, int mode); +extern int _scan_type(const char *type, int *fptr, int *mptr); +extern int _valid_stream(FILE *st); + +#pragma save +#pragma call(reg_saved=>(ds, di, si,st1,st2), reg_param=>(ax,bx,cx,dx)) +extern int _vgetc(void); +extern int _vungetc(int c); + +extern void _justify(char *s, int flag, int width); +extern void _str_out(char *s, int flag, int width, int precision); +extern void _vputc(int ch); +#pragma restore + +extern unsigned char _exists(const char *path); + +extern void _swap(void *b1, void *b2, size_t width); + +extern LONGDOUBLE _acvt(int flag, char *mbuf, int exp, int len); +extern void _cvt(LONGDOUBLE x, int n, int *dec, int *sign, char * buf); +extern void _seterrno(int type); + +extern LONGDOUBLE _pow_int(LONGDOUBLE x,int y); +extern LONGDOUBLE _round( LONGDOUBLE x ); +extern void _bcd(LONGDOUBLE x,char * p); + +extern void _FatalError(unsigned address, int code); +extern unsigned _FatalErrorPos(void); + +extern void (*_exit_stk[32])(void); /* at/onexit function stack */ + +#pragma save,check(index=>off) +extern void (**_exit_ptr)(void); +extern void (**_exit_top)(void); +#pragma restore + +extern void (*_exit_io)(void); +extern void (*_exit_tmp)(void); + +extern va_list (*_real_in)(int pmod, int smod, unsigned flag, int width, va_list _v_argptr); +extern va_list (*_real_out)(va_list _v_argptr, int flag, int wid, int prec); + +extern void (*_exit_proc)(void); +#ifdef __cplusplus +} +#endif + +/* Internal Data Declarations. */ + +extern char _cvt_buf[64]; /* real number conversion buffer */ +extern char _ctype[257]; /* ctype data */ +extern struct lconv _lconv; +#ifdef _USE_TIME +extern time_t _proc_time; /* time at beginning of process */ +#endif +extern char _sys_errbuf[128];/* error message buffer */ +extern char *sys_errlist[]; /* error messages */ +extern int sys_nerr; /* number of system error strings */ +extern double _tens[32]; +extern char _upperHex; /* conversion case */ + +extern jmp_buf _EOFhandler; /* EOF error jump environment */ +extern unsigned _fmask; +extern _iosetup; /* initialisation flag */ +extern int _p_init; +extern int _s_args; /* argument count */ +extern FILE *_stream; /* file pointer */ +extern int _ungotchar; /* temporary storage for console I/O */ +extern int _vp_ret; /* character count */ +extern int _vs_count; /* character count */ +extern int _open_max; /* maximum number of open files */ +extern char *_tmpfiles[]; +extern FILE *_tmpfptrs[]; + +extern char _argbuf[128]; /* command line buffer */ +extern unsigned _assign_init_magic; + +/*****************************************************************************/ +/* CPP Definitions. */ +/*****************************************************************************/ + +typedef void *(*ctor_t)(void *); +typedef void (*dtor_t)(void *); + +#pragma save, call(reg_param=>(), reg_saved=>(ds,si,di,st1,st2), near_call=>on, c_conv=>on) +#ifdef __cplusplus +extern "C" { +#endif +extern void _call_ctors(ctor_t, char *obj_ptr, int vbnum, int n, int siz); +extern void _call_dtors(dtor_t, char *obj_ptr, int vbnum, int n, int siz); +#ifdef __cplusplus +} +#endif +#pragma restore + +/* Macro Definitions. */ + +#define TRUE 1 +#define FALSE 0 + +#define _CTLZ 0x01A +#define _O_LRD 0x400 +#define _WRITE 2 +#define _NODEFMODE 4 +#define _READ 8 + +#define _MNEG 1 +#define _ENEG 2 +#define _STD 8 +#define _HMAX 54 +#define _HEX 1 +#define _OCT 2 +#define _NEG 4 +#define _OFL 8 + +#define _DAYSECS 86400L /* seconds in year */ +#define _SEVENTIES 315532800L /* seconds between 1970 and 1980 */ + +#define InternalError(c) _FatalError(_FatalErrorPos(), (c)) + +#define PF_VBSIZE 256 +#define PF_TEMP_BUF 128 + +#define DEC_POINT _lconv.decimal_point[0] + +#define PF_LEFT 0x0001 /* justification */ +#define PF_SIGN 0x0002 /* force leading PF_SIGN */ +#define PF_SPACE 0x0004 /* force leading PF_SPACE */ +#define PF_HASH 0x0008 /* PF_HASH flag */ +#define PF_NOPOINT 0x0010 /* supress radix point */ +#define PF_UPPER 0x0020 /* PF_UPPER case type */ +#define PF_IS_SIGNED 0x0040 /* signed data-type */ +#define PF_ZFLAG 0x0080 /* format with 0 */ +#define PF_HEX 0x0100 /* PF_HEX integer */ +#define PF_OCT 0x0200 /* octal integer */ +#define PF_GTYPE 0x0400 /* g real type */ +#define PF_EXP 0x0800 /* e real type */ +#define PF_PSET 0x1000 /* precison set */ +#define PF_LDMOD 0x2000 /* long real */ +#define PF_CPP 0x4000 /* C++ formatting rules */ + +#define SF_WILD 0x0004 /* any int type */ +#define SF_SUPRESS 0x0008 /* star flag */ +#define SF_UPPER 0x0010 /* upper case type */ +#define SF_NSIGNED 0x0020 /* unsigned data-type */ +#define SF_HEX 0x0040 /* hex integer */ +#define SF_OCT 0x0080 /* octal integer */ +#define SF_LDMOD 0x0100 /* LONGDOUBLE */ + +#endif + + + + + + diff --git a/code/SIBOSDK/include/comman.g b/code/SIBOSDK/include/comman.g new file mode 100644 index 0000000..d6c3a43 --- /dev/null +++ b/code/SIBOSDK/include/comman.g @@ -0,0 +1,24 @@ +/* Generated by Ctran from comman.cl */ +#define COMMAN_G +#ifndef OLIB_G +#include +#endif +/* Class Numbers */ +#define C_COMMAN 17 +/* Method Numbers */ +#define O_COM_MODE_CHANGE 5 +#define O_COM_INIT 1 +#define O_COM_STATWIN 2 +#define O_COM_MENU 4 +#define O_COM_EXIT 7 +#define O_COM_FILE_CHANGE 6 +#define O_COM_ACCL_CHECK 3 +/* Constants for comman */ +#define O_COM_SYS_LAST O_COM_EXIT +#define BREAK_LINE_FOLLOWS 0x80 +#define PURE_COM_ID 0x7f +/* Property of comman */ +typedef struct pr_comman +{ +PRS_ROOT root; +} PR_COMMAN; diff --git a/code/SIBOSDK/include/comman.ing b/code/SIBOSDK/include/comman.ing new file mode 100644 index 0000000..61106a1 --- /dev/null +++ b/code/SIBOSDK/include/comman.ing @@ -0,0 +1,23 @@ +; Generated by Ctran from comman.cl +COMMAN_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +; Class Numbers +C_COMMAN equ 17 +; Method Numbers +O_COM_MODE_CHANGE equ 5 +O_COM_INIT equ 1 +O_COM_STATWIN equ 2 +O_COM_MENU equ 4 +O_COM_EXIT equ 7 +O_COM_FILE_CHANGE equ 6 +O_COM_ACCL_CHECK equ 3 +; Constants for comman +O_COM_SYS_LAST equ (O_COM_EXIT) +BREAK_LINE_FOLLOWS equ (080h) +PURE_COM_ID equ (07fh) +; Property of comman +PR_COMMAN struc +CommanRoot PRS_ROOT <> +PR_COMMAN ends diff --git a/code/SIBOSDK/include/complex.hpp b/code/SIBOSDK/include/complex.hpp new file mode 100644 index 0000000..04c9884 --- /dev/null +++ b/code/SIBOSDK/include/complex.hpp @@ -0,0 +1,228 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* COMPLEX.HPP - header file for complex math. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef __COMPLEX_INC_ +#define __COMPLEX_INC_ + +#include +#include + +class complex { + +friend double real(const complex&); +friend double imag(const complex&); +friend complex conj(const complex&); +friend double norm(const complex&); +friend double arg(const complex&); +friend complex polar(double _mag, double _angle = 0.0); + +friend double abs(const complex&); +friend complex acos(const complex&); +friend complex asin(const complex&); +friend complex atan(const complex&); +friend complex cos(const complex&); +friend complex cosh(const complex&); +friend complex exp(const complex&); +friend complex log(const complex&); +friend complex log10(const complex&); +friend complex pow(const complex& _base, double _exp); +friend complex pow(double _base, const complex& _exp); +friend complex pow(const complex& _base, const complex& _exp); +friend complex sin(const complex&); +friend complex sinh(const complex&); +friend complex sqrt(const complex&); +friend complex tan(const complex&); +friend complex tanh(const complex&); + +friend complex operator+(const complex&, const complex&); +friend complex operator+(double, const complex&); +friend complex operator+(const complex&, double); +friend complex operator-(const complex&, const complex&); +friend complex operator-(double, const complex&); +friend complex operator-(const complex&, double); +friend complex operator*(const complex&, const complex&); +friend complex operator*(double, const complex&); +friend complex operator*(const complex&, double); +friend complex operator/(const complex&, const complex&); +friend complex operator/(double, const complex&); +friend complex operator/(const complex&, double); +friend int operator==(const complex&, const complex&); +friend int operator!=(const complex&, const complex&); + + + +public: + + complex(double _re_val, double _im_val=0); + complex(); + + const complex& operator+=(const complex&) ; + const complex& operator+=(double) ; + const complex& operator-=(const complex&) ; + const complex& operator-=(double) ; + const complex& operator*=(const complex&) ; + const complex& operator*=(double) ; + const complex& operator/=(const complex&) ; + const complex& operator/=(double) ; + complex operator+() const; + complex operator-() const; + +private: + + double re; + double im; + +}; + +inline complex::complex(double _re_val, double _im_val) { + + re = _re_val; + im = _im_val; +} + +inline complex::complex() { + + re = 0.0; + im = 0.0; +} + +inline complex complex::operator+() const { + + return *this; +} + +inline complex complex::operator-() const { + + return complex(-re, -im); +} + +inline const complex& complex::operator+=(const complex& _z) { + + re += _z.re; + im += _z.im; + return *this; +} + +inline const complex& complex::operator+=(double _r) { + + re += _r; + return *this; +} + +inline const complex& complex::operator-=(const complex& _z) { + + re -= _z.re; + im -= _z.im; + return *this; +} + +inline const complex& complex::operator-=(double _r) { + + re -= _r; + return *this; +} + +inline const complex& complex::operator*=(double _r) { + + re *= _r; + im *= _r; + return *this; +} + +inline const complex& complex::operator/=(double _r) { + + re /= _r; + im /= _r; + return *this; +} + + +inline double real(const complex& _z) { + + return _z.re; +} + +inline double imag(const complex& _z) { + + return _z.im; +} + +inline complex conj(const complex& _z) { + + return complex(_z.re, -_z.im); +} + +inline complex polar(double _mag, double _ang) { + + return complex(_mag*cos(_ang), _mag*sin(_ang)); +} + + +inline complex operator+(const complex& _z1, const complex& _z2) { + + return complex(_z1.re + _z2.re, _z1.im + _z2.im); +} + +inline complex operator+(double _r, const complex& _z) { + + return complex(_r + _z.re, _z.im); +} + +inline complex operator+(const complex& _z, double _r) { + + return complex(_r + _z.re, _z.im); +} + +inline complex operator-(const complex& _z1, const complex& _z2) { + + return complex(_z1.re - _z2.re, _z1.im - _z2.im); +} + +inline complex operator-(double _r, const complex& _z) { + + return complex(_r - _z.re, -_z.im); +} + +inline complex operator-(const complex& _z, double _r) { + + return complex(_r - _z.re, _z.im); +} + +inline complex operator*(double _r, const complex& _z) { + + return complex(_r * _z.re, _r * _z.im); +} + +inline complex operator*(const complex& _z, double _r) { + + return complex(_r * _z.re, _r * _z.im); +} + +inline complex operator/(const complex& _z, double _r) { + + return complex(_z.re/_r, _z.im/_r); +} + +inline int operator==(const complex& _z1, const complex& _z2) { + + return (_z1.re == _z2.re) && (_z1.im == _z2.im); +} + +inline int operator!=(const complex& _z1, const complex& _z2) { + + return (_z1.re != _z2.re) || (_z1.im != _z2.im); +} + +ostream& operator<<(ostream&, const complex&); +istream& operator>>(istream&, complex&); + +#endif + diff --git a/code/SIBOSDK/include/conio.h b/code/SIBOSDK/include/conio.h new file mode 100644 index 0000000..c55349b --- /dev/null +++ b/code/SIBOSDK/include/conio.h @@ -0,0 +1,102 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* conio.h - header file for console input and output. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _CONIO_INC_ +#define _CONIO_INC_ + +#ifdef __cplusplus +extern "C" { +#endif +extern char * cgets(char *_str); +extern void cputs(const char *_str); +extern int cprintf(const char *_format, ...); +extern int cscanf(const char *_format, ...); +extern int getch(void); +extern int getche(void); +extern int kbhit(void); +extern int putch(int _ch); +extern int ungetch(unsigned _ch); + +#ifndef _PORTIO_DEF +#define _PORTIO_DEF +#if (defined _IL_MTF) | ( defined __STDC__) + +extern unsigned char inportb(int _portid); +extern void outportb(int _portid, unsigned char _value); +extern unsigned int inportw(int _portid); +extern void outportw(int _portid, unsigned int _value); +extern void _disable(void); +extern void _enable(void); + +#define inp(portid) inportb(portid) +#define outp(portid, v) outportb(portid, v) +#define inpw(portid) inportw(portid) +#define outpw(portid, v) outportw(portid, v) + +#else + +#define RET 0xC3 + +#pragma save,call(reg_param=>(dx,ax),reg_saved=>(bx,cx,si,di,es,ds,st1,st2), inline=>on) +static void __outportb__(int _port, unsigned char _byte) = +{ + 0xEE, RET /* out dx,al */ +}; + +static unsigned char __inportb__(int _port) = +{ + 0xEC, RET /* in dx,al */ +}; + +static void __outportw__(int _port, unsigned _word) = +{ + 0xEF, RET /* out dx,ax */ +}; + +static unsigned int __inportw__(int _port) = +{ + 0xED, RET /* in dx,ax */ +}; + +static void _enable(void)= +{ + 0xFB, RET +}; + +static void _disable(void)= +{ + 0xFA, RET +}; + +#pragma restore + +#define inportb(portid) __inportb__(portid) /* Byte IN instruction */ +#define outportb(portid, v) __outportb__(portid,v) /* Byte OUT instruction */ +#define inportw(portid) __inportw__(portid) /* Word IN instruction */ +#define outportw(portid, v) __outportw__(portid,v) /* Word OUT instruction */ + +/* some compilers use inp, outp for inportb, outportb */ + +#define inp(portid) __inportb__(portid) +#define outp(portid, v) __outportb__(portid, v) +#define inpw(portid) __inportw__(portid) +#define outpw(portid, v) __outportw__(portid, v) + +#endif +#define enable() _enable() +#define disable() _disable() +#endif + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/code/SIBOSDK/include/coniostr.hpp b/code/SIBOSDK/include/coniostr.hpp new file mode 100644 index 0000000..a9c069b --- /dev/null +++ b/code/SIBOSDK/include/coniostr.hpp @@ -0,0 +1,36 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* CONIOSTR.HPP - header file for console stream input and output. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _CONIOSTR_INC_ +#define _CONIOSTR_INC_ + +#include + + +class conbuf : public streambuf { + +public: + + virtual int underflow(); + virtual int pbackfail(int); + virtual int overflow(int _c = EOF); + virtual int sync(); + +private: + + unsigned flush_magic; + +}; + +extern istream conin; +extern ostream conout; + +#endif diff --git a/code/SIBOSDK/include/corelib.inc b/code/SIBOSDK/include/corelib.inc new file mode 100644 index 0000000..04b0f09 --- /dev/null +++ b/code/SIBOSDK/include/corelib.inc @@ -0,0 +1,271 @@ +frame = 4 (* standard stack frame, near call *) +bxframe = 2 (* bx stack frame, near call *) + +PopParam = 0 (* Dummy value for changing real return convention *) +DOSHUGESHIFT = 12 + +(***************************** Data Type Sizes *****************************) + +CodePtrSize = 2 (* Code pointer, near calls *) +DataPtrSize = 2 (* Data pointer, 16 bit data pointer models *) + +_ptr = 0 (* _iob structure *) +_cnt = 2 +_size = 4 +_base = 6 +_flag = 8 +_file = 10 +_pback = 12 +_iobSize = 14 (* size of _iob structure *) + +(***************************** OS Error Codes ******************************) + +EFAULT = -1 +ENOENT = -33 +ENOPATH = -42 +EMFILE = -18 +EACCESS = -39 +EBADF = -15 +E2BIG = -6 +ENOMEM = -10 +ENOSPC = -37 +EINVAL = -2 +EDOM = -2 +ERANGE = -7 + +(***************************** IO Constants*********************************) + +BUFSIZ = 512 (* IO Buffer size *) + +_IOFBF = 0 (* setvbuf - full buffering *) +_IOLBF = 1 (* setvbuf - line buffering *) +_IONBF = 2 (* setvbuf - no buffering *) + +_F_RDWR = 0003H (* Read/write *) +_F_READ = 0001H (* Read only file *) +_F_WRIT = 0002H (* Write only file *) +_F_UBUF = 0004H (* User allocated buffer *) +_F_APP = 0008H (* Append data *) +_F_ERR = 0010H (* Error *) +_F_EOF = 0020H (* EOF *) +_F_BIN = 0040H (* Binary file *) +_F_IN = 0080H (* Data is incoming *) +_F_OUT = 0100H (* Data is outgoing *) +_F_DEV = 0200H (* File is terminal *) +_F_RST = 0400H (* Newly opened stream *) +_F_LBUF = 0800H (* line buffered stream *) +_F_CTZ = 1000H + +SEEK_SET = 0 (* lseek - origin beginning of file *) +SEEK_CUR = 1 (* lseek - origin current position *) +SEEK_END = 2 (* lseek - origin end of file *) + +CTLZ = 1AH (* Text mode EOF character *) +EOF = -1 (* end of file return value *) + +O_RDONLY = 0 +O_WRONLY = 1 +O_RDWR = 2 + +O_CREAT = 0100H (* create and open file *) +O_TRUNC = 0200H (* open with truncation *) +O_EXCL = 0400H (* exclusive open *) + +_O_EOF = 0200H (* set when text file hits ^Z *) + +O_APPEND = 0800H (* write to end of file *) + +O_CHANGED = 1000H (* File has been written *) +O_DEVICE = 2000H (* user read only flag *) +O_TEXT = 4000H (* CR-LF translation *) +O_BINARY = 8000H (* no translation *) + +SH_NOINHERIT = 80H (* File sharing modes *) +SH_COMPAT = 00H +SH_DENYRW = 10H +SH_DENYWR = 20H +SH_DENYRD = 30H +SH_DENYNO = 40H + +SH_DENYNONE = SH_DENYNO (* MS documentation uses both *) + +S_IFDIR = 4000H (* directory *) +S_IFCHR = 2000H (* character device *) +S_IFREG = 8000H (* regular file *) +S_IREAD = 0100H (* owner may read *) +S_IWRITE = 0080H (* owner may write *) +S_IEXEC = 0040H (* owner may execute directory search *) + +FA_NORMAL = 00H (* normal file *) +FA_RDONLY = 01H (* Read only attribute *) +FA_HIDDEN = 02H (* Hidden file *) +FA_SYSTEM = 04H (* System file *) +FA_LABEL = 08H (* Volume label *) +FA_DIREC = 10H (* Directory *) +FA_ARCH = 20H (* Archive *) +FA_TEXT = 100H (* Open in text mode *) +FA_SHARE = 200H (* Open with sharing *) + +E_CONS = 8000H (* The console channel *) +E_DEVICE = 4000H (* Its a character device *) + +(************************ OS2 structures and constants ********************) + +fdateCreation = 0 +ftimeCreation = 2 +fdateLastAccess = 4 +ftimeLastAccess = 6 +fdateLastWrite = 8 +ftimeLastWrite = 10 +cbFile = 12 +cbFileAlloc = 16 +attrFile = 20 + +FileInfoSize = 22 + +IO_WAIT = 0 +IO_NOWAIT = 1 + +hours = 0 +minutes = 1 +seconds = 2 +hundredths = 3 +day = 4 +month = 5 +year = 6 +timezone = 8 +weekday = 10 + +DateTimeSize = 11 + +EXIT_THREAD = 0 +EXIT_PROCESS = 1 +EXLST_EXIT = 3 +EXLST_ADD = 1 + +(* Signal Numbers for DosSetSigHandler *) + +SIG_CTRLC = 1 (* Control C *) +SIG_BROKENPIPE = 2 (* Broken Pipe *) +SIG_KILLPROCESS = 3 (* Program Termination *) +SIG_CTRLBREAK = 4 (* Control Break *) +SIG_PFLG_A = 5 (* Process Flag A *) +SIG_PFLG_B = 6 (* Process Flag B *) +SIG_PFLG_C = 7 (* Process Flag C *) +SIG_CSIGNALS = 8 (* number of signals plus one *) + + +(* Flag Numbers for DosFlagProcess *) + +PFLG_A = 0 (* Process Flag A *) +PFLG_B = 1 (* Process Flag B *) +PFLG_C = 2 (* Process Flag C *) + +(* Signal actions *) + +SIGA_KILL = 0 +SIGA_IGNORE = 1 +SIGA_ACCEPT = 2 +SIGA_ERROR = 3 +SIGA_ACKNOWLEDGE = 4 + + +SIG_DFL = 0 +SIG_IGN = 1 +SIG_SGE = 3 +SIG_ACK = 4 + + +(************************ Library Internal Constants ***********************) +(* *) +(* These constants are internal to the run-time library and may NOT *) +(* changed. *) +(* *) +(***************************************************************************) + +TRUE = 1 +FALSE = 0 + +math_saved_regs = 8 + +ExpNeg = 80H +magic = 01234H (* value to flag exception handler *) +MAGIC = 01234H (* value to flag exception handler *) + +f_st5 = 10H (* arg1 is in st5 *) +f_two = 20H (* two arguments *) + +_DOMAIN = 1 (* parameter not in valid domain *) +_SING = 2 (* function is incalculable at this place *) +_OVERFLOW = 3 (* result exceeds representable range *) +_UNDERFLOW = 4 (* result too close to zero to be represented *) +_TLOSS = 5 (* total loss of precision (eg. Sine (2**65)) *) +_PLOSS = 6 (* partial precision loss *) + +ZFLAG = 80H (* Zero pad flag from printf *) + +stream = 0 +flush = 2 +count = 4 +args = 6 +handler = 8 + +InMathLib = 0 + +(* Priority = 0 *) +(* ProcVar = 2 *) +(* InitSize = 4 *) + +Priority = 2 +ProcVar = 3 +InitSize = 5 + +PR0 = 30 +PR1 = 29 +PR2 = 28 +PR3 = 27 +PR4 = 26 +PR5 = 25 +PRL = 20 + +PRMAX = 32 + +emu_fraction = 0 +emu_exponent = 8 +emu_sign = 10 +emu_spare = 11 +emu_temp_size = 12 + +by0 = 0 +by1 = 1 + +w0 = 0 +w1 = 2 +w2 = 4 +w3 = 6 + +dd0 = 0 +dd1 = 4 + +STACK_GUARD = 1234H + +GETSTATE_START = 0 +GETSTATE_END = 2 +GETSTATE_FIRST = 4 + +_j_flag = 0 +_j_ip = 2 +_j_sp = 4 +_j_bp = 6 +_j_si = 8 +_j_di = 10 +_j_dx = 12 +_j_cx = 14 +_j_bx = 16 +_j_classHandle = 18 +_j_classPtr = 20 +_j_enterFrame = 22 +_j_osFrame = 24 +_j_st1 = 26 +_j_st2 = 36 + diff --git a/code/SIBOSDK/include/ctype.h b/code/SIBOSDK/include/ctype.h new file mode 100644 index 0000000..25e7ffb --- /dev/null +++ b/code/SIBOSDK/include/ctype.h @@ -0,0 +1,81 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* ctype.h - header file for ctype macro definitions. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _CTYPE_INC_ +#define _CTYPE_INC_ + +#define _IS_SP 1 /* is space */ +#define _IS_DIG 2 /* is digit indicator */ +#define _IS_UPP 4 /* is upper case */ +#define _IS_LOW 8 /* is lower case */ +#define _IS_HEX 16 /* [A-F or [a-f] */ +#define _IS_CTL 32 /* Control */ +#define _IS_PUN 64 /* punctuation */ + +extern char _ctype[257]; /* Character type array */ + +#ifdef __cplusplus +extern "C" { +#endif +extern int isalnum(int _c); +extern int isalpha(int _c); +extern int isascii(int _c); +extern int iscntrl(int _c); +extern int isdigit(int _c); +extern int isgraph(int _c); +extern int islower(int _c); +extern int isprint(int _c); +extern int ispunct(int _c); +extern int isspace(int _c); +extern int isupper(int _c); +extern int isxdigit(int _c); + +extern int _toupper(int _c); +extern int _tolower(int _c); +extern int toascii(int _c); +extern int tolower(int _ch); /* function prototypes */ +extern int toupper(int _ch); +#ifdef __cplusplus +} +#endif + +#ifndef __STDC__ + +#ifdef _CT_FTM +#define toupper(c) ((islower(c)) ? _toupper(c) : (c) ) +#define tolower(c) ((isupper(c)) ? _tolower(c) : (c) ) +#endif + +#ifndef _CT_MTF /* defines conversion macros */ + +#define isalnum(c) (_ctype[(c)+1] & (_IS_DIG | _IS_UPP | _IS_LOW)) +#define isalpha(c) (_ctype[(c)+1] & (_IS_UPP | _IS_LOW)) +#define isascii(c) ((unsigned)((c)) < 0x80) +#define iscntrl(c) (_ctype[(c)+1] & _IS_CTL) +#define isdigit(c) (_ctype[(c)+1] & _IS_DIG) +#define isgraph(c) ((c) >= 0x21 && (c) <= 0x7e) +#define islower(c) (_ctype[(c)+1] & _IS_LOW) +#define isprint(c) ((c) >= 0x20 && (c) <= 0x7e) +#define ispunct(c) (_ctype[(c)+1] & _IS_PUN) +#define isspace(c) (_ctype[(c)+1] & _IS_SP) +#define isupper(c) (_ctype[(c)+1] & _IS_UPP) +#define isxdigit(c) (_ctype[(c)+1] & (_IS_DIG | _IS_HEX)) + +#define iscsymf(c) (isalpha(c) || ((c) == '_')) +#define iscsym(c) (isalnum(c) || ((c) == '_')) + +#define _toupper(c) ((c) + 'A' - 'a') +#define _tolower(c) ((c) + 'a' - 'A') +#define toascii(c) ((c) & 0x7f) + +#endif +#endif +#endif diff --git a/code/SIBOSDK/include/dialdlgs.g b/code/SIBOSDK/include/dialdlgs.g new file mode 100644 index 0000000..667160b --- /dev/null +++ b/code/SIBOSDK/include/dialdlgs.g @@ -0,0 +1,96 @@ +/* Generated by Ctran from dialdlgs.cl */ +#define DIALDLGS_G +#ifndef DLGBOX_G +#include +#endif +#ifndef WR_IO_H +#include +#endif +/* Class Numbers */ +#define C_DIALDLG 59 +#define C_FREEDIAL 60 +#define C_FDIALDLG 61 +#define C_CNTRYDLG 62 +#define C_SDIALDLG 63 +/* Method Numbers */ +/* Property of dialdlg */ +typedef struct { +void *dialao; +} PRS_DIALDLG; +typedef struct pr_dialdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_DIALDLG dialdlg; +} PR_DIALDLG; +/* Property of freedial */ +typedef struct { +short int current; +char str[WR_MAX_DIAL_STRING+2]; +} PRS_FREEDIAL; +typedef struct pr_freedial +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_FREEDIAL freedial; +} PR_FREEDIAL; +/* Property of fdialdlg */ +typedef struct pr_fdialdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_DIALDLG dialdlg; +} PR_FDIALDLG; +/* Property of cntrydlg */ +typedef struct pr_cntrydlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_CNTRYDLG; +/* Constants for sdialdlg */ +#define PAN_TONE_LENGTH_TICKS 4 +#define PAN_DELAY_LENGTH_TICKS 4 +#define PAN_PAUSE_LENGTH_TICKS 32 +#define PC_TONE_LENGTH_TICKS 6 +#define PC_DELAY_LENGTH_TICKS 4 +#define PC_PAUSE_LENGTH_TICKS 18 +#define SMART_DIAL_MAX_PROMPT 11 +/* Types for sdialdlg */ +typedef struct +{ +char pmt[SMART_DIAL_MAX_PROMPT+1]; +char str[WR_MAX_IN_STRING+2]; +} SMART_DIAL_ITEM; +typedef struct +{ +short int count; +SMART_DIAL_ITEM it[DLGBOX_MAX_ITEM-3]; +} SMART_DIAL_DATA; +typedef struct +{ +short int count; +SMART_DIAL_ITEM it; +} SMART_DIAL_DATA_S; +typedef struct +{ +unsigned short int toneLengthTicks; +unsigned short int delayLengthTicks; +unsigned short int pauseLengthTicks; +unsigned char dialOutCode[17]; +} DIAL_ENVAR; +/* Property of sdialdlg */ +typedef struct pr_sdialdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_DIALDLG dialdlg; +} PR_SDIALDLG; diff --git a/code/SIBOSDK/include/dialdlgs.ing b/code/SIBOSDK/include/dialdlgs.ing new file mode 100644 index 0000000..e59c0c9 --- /dev/null +++ b/code/SIBOSDK/include/dialdlgs.ing @@ -0,0 +1,87 @@ +; Generated by Ctran from dialdlgs.cl +DIALDLGS_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF WR_IO_INC + INCLUDE ..\inc\WR_IO.INC +ENDIF +; Class Numbers +C_DIALDLG equ 59 +C_FREEDIAL equ 60 +C_FDIALDLG equ 61 +C_CNTRYDLG equ 62 +C_SDIALDLG equ 63 +; Method Numbers +; Property of dialdlg +PRS_DIALDLG struc +DialdlgDialao dw ? +PRS_DIALDLG ends +PR_DIALDLG struc +DialdlgRoot PRS_ROOT <> +DialdlgWin PRS_WIN <> +DialdlgDlgchain PRS_DLGCHAIN <> +DialdlgDlgbox PRS_DLGBOX <> +DialdlgDialdlg PRS_DIALDLG <> +PR_DIALDLG ends +; Property of freedial +PRS_FREEDIAL struc +FreedialCurrent dw ? +FreedialStr db (1) * WR_MAX_DIAL_STRING+2 dup (?) +PRS_FREEDIAL ends +PR_FREEDIAL struc +FreedialRoot PRS_ROOT <> +FreedialWin PRS_WIN <> +FreedialLodger PRS_LODGER <> +FreedialFreedial PRS_FREEDIAL <> +PR_FREEDIAL ends +; Property of fdialdlg +PR_FDIALDLG struc +FdialdlgRoot PRS_ROOT <> +FdialdlgWin PRS_WIN <> +FdialdlgDlgchain PRS_DLGCHAIN <> +FdialdlgDlgbox PRS_DLGBOX <> +FdialdlgDialdlg PRS_DIALDLG <> +PR_FDIALDLG ends +; Property of cntrydlg +PR_CNTRYDLG struc +CntrydlgRoot PRS_ROOT <> +CntrydlgWin PRS_WIN <> +CntrydlgDlgchain PRS_DLGCHAIN <> +CntrydlgDlgbox PRS_DLGBOX <> +PR_CNTRYDLG ends +; Constants for sdialdlg +PAN_TONE_LENGTH_TICKS equ (4) +PAN_DELAY_LENGTH_TICKS equ (4) +PAN_PAUSE_LENGTH_TICKS equ (32) +PC_TONE_LENGTH_TICKS equ (6) +PC_DELAY_LENGTH_TICKS equ (4) +PC_PAUSE_LENGTH_TICKS equ (18) +SMART_DIAL_MAX_PROMPT equ (11) +; Types for sdialdlg +SMART_DIAL_ITEM struc +SMART_DIAL_ITEMPmt db (1) * SMART_DIAL_MAX_PROMPT+1 dup (?) +SMART_DIAL_ITEMStr db (1) * WR_MAX_IN_STRING+2 dup (?) +SMART_DIAL_ITEM ends +SMART_DIAL_DATA struc +SMART_DIAL_DATACount dw ? +SMART_DIAL_DATAIt db (size SMART_DIAL_ITEM)* DLGBOX_MAX_ITEM-3 dup (?) +SMART_DIAL_DATA ends +SMART_DIAL_DATA_S struc +SMART_DIAL_DATA_SCount dw ? +SMART_DIAL_DATA_SIt SMART_DIAL_ITEM <> +SMART_DIAL_DATA_S ends +DIAL_ENVAR struc +DIAL_ENVARToneLengthTicks dw ? +DIAL_ENVARDelayLengthTicks dw ? +DIAL_ENVARPauseLengthTicks dw ? +DIAL_ENVARDialOutCode db (1) * 17 dup (?) +DIAL_ENVAR ends +; Property of sdialdlg +PR_SDIALDLG struc +SdialdlgRoot PRS_ROOT <> +SdialdlgWin PRS_WIN <> +SdialdlgDlgchain PRS_DLGCHAIN <> +SdialdlgDlgbox PRS_DLGBOX <> +SdialdlgDialdlg PRS_DIALDLG <> +PR_SDIALDLG ends diff --git a/code/SIBOSDK/include/dir.h b/code/SIBOSDK/include/dir.h new file mode 100644 index 0000000..ed4693c --- /dev/null +++ b/code/SIBOSDK/include/dir.h @@ -0,0 +1,73 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* dir.h - structure and function definitions for MSDOS pathnames * +* and directories. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _DIR_INC_ +#define _DIR_INC_ + +#ifdef __cplusplus +extern "C" { +#endif +extern int chdir(const char *_path); +extern int getcurdir(int _drive, char *_buf); +extern char * getcwd(char *_buf, int _maxlen); +extern int _getdrive(void); +extern int mkdir(const char *_path); +extern int rmdir(const char *_path); +#ifdef __cplusplus +} +#endif + +#define WILDCARDS 0x01 +#define EXTENSION 0x02 +#define FILENAME 0x04 +#define DIRECTORY 0x08 +#define DRIVE 0x10 + +#define MAXPATH 80 +#define MAXDRIVE 4 +#define MAXDIR 66 +#define MAXFILE 9 +#define MAXEXT 5 + +#ifndef _FFBLK_DEF +#define _FFBLK_DEF + +struct ffblk { + char ff_reserved[21]; + char ff_attrib; + int ff_ftime; + int ff_fdate; + long ff_fsize; + char ff_name[13]; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern int findfirst(const char *_path, struct ffblk *_ffblk,int _attrib); +extern int findnext(struct ffblk *_ffblk); +extern void fnmerge(char *_path, const char *_drive,const char *_dir, + const char *_name, const char *_ext); +extern int fnsplit(const char *_path, char *_drive, char *_dir, + char *_name, char *_ext); +extern void _makepath(char *_path, const char *_drive, const char *_dir, + const char *_name, const char *_ext); +extern void _splitpath(const char *_path, char *_drive, char *_dir, + char *_name, char *_ext); +extern int getdisk(void); +extern char * searchpath(const char *_path); +extern int setdisk(int _drive); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/direct.h b/code/SIBOSDK/include/direct.h new file mode 100644 index 0000000..00cb4c5 --- /dev/null +++ b/code/SIBOSDK/include/direct.h @@ -0,0 +1,2 @@ +#include + \ No newline at end of file diff --git a/code/SIBOSDK/include/dlgbox.g b/code/SIBOSDK/include/dlgbox.g new file mode 100644 index 0000000..89cc33f --- /dev/null +++ b/code/SIBOSDK/include/dlgbox.g @@ -0,0 +1,165 @@ +/* Generated by Ctran from dlgbox.cl */ +#define DLGBOX_G +#ifndef BWIN_G +#include +#endif +#ifndef TEXTWIN_G +#include +#endif +/* Class Numbers */ +#define C_DLGCHAIN 12 +#define C_DLGBOX 13 +#define C_ERRORDLG 14 +#define C_QUERYDLG 15 +#define C_FLISTDLG 16 +/* Method Numbers */ +#define O_DL_SET_SIZE 27 +#define O_DL_DIMMED_MESSAGE 25 +#define O_DL_INQ_MINSIZE 28 +#define O_DL_ITEM_REPLACE 22 +#define O_DL_ITEM_APPEND 23 +#define O_DL_HANDLE_TO_INDEX 20 +#define O_DL_CLR_ITEM_FLAGS 17 +#define O_DL_TAKE_FOCUS 19 +#define O_DL_ITEM_ADD 26 +#define O_DL_FOCUS 32 +#define O_DL_SET_ITEM_FLAGS 16 +#define O_DL_ITEM_DIM 15 +#define O_DL_ITEM_NEW 34 +#define O_DL_INIT 24 +#define O_DL_KEY 30 +#define O_DL_DYN_INIT 29 +#define O_DL_INDEX_TO_HANDLE 21 +#define O_DL_CHANGED 31 +#define O_DL_LAUNCH_SUB 33 +#define O_DL_ITEM_LOCK 14 +#define O_DL_SET_PROMPT 18 +/* Constants for dlgchain */ +#define PR_WIN_NO_DDP PR_WIN_FORCE_TOP +#define HELPDLG_BASIC_HELP PR_WIN_FORCE_RIGHT +#define HELPDLG_HELP_INDEX PR_WIN_FORCE_LEFT +#define DLGCHAIN_WITH_MENU PR_WIN_FORCE_BOTTOM +/* Property of dlgchain */ +typedef struct { +PR_BWIN *next; +} PRS_DLGCHAIN; +typedef struct pr_dlgchain +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +} PR_DLGCHAIN; +/* Constants for dlgbox */ +#define DLGBOX_NOTIFY_ENTER 0x0001 +#define DLGBOX_NOTIFY_ESCAPE 0x0002 +#define DLGBOX_RBUF_FILLED 0x0004 +#define DLGBOX_ACTION_LIST 0x0008 +#define DLGBOX_FROM_HWIF 0x0010 +#define DLGBOX_SMALL_FONT DLGBOX_FROM_HWIF +#define DLGBOX_NO_WAIT 0x0020 +#define DLGBOX_NOTIFY_ALL_ACT 0x0040 +#define DLGBOX_REPORT_ACT_HORIZ 0x0080 +#define DLGBOX_APPEND_UNITS_TITLE 0x0100 +#define DLGBOX_SMALL_ACTION_LIST 0x0200 +#define DLGBOX_NO_SHADOW 0x0400 +#define DLGBOX_NO_DDP 0x0800 +#define DLGBOX_ITEM_NOTIFY_CHANGED 0x0001 +#define DLGBOX_ITEM_DIMMED 0x0002 +#define DLGBOX_ITEM_UNDERLINED 0x0004 +#define DLGBOX_ITEM_APPL_CAT 0x0008 +#define DLGBOX_ITEM_CENTRE 0x0010 +#define DLGBOX_ITEM_DEAD 0x0020 +#define DLGBOX_ITEM_NOTIFY_FOCUS 0x0080 +#define DLGBOX_ITEM_NEEDS_PACK 0x0100 +#define DLGBOX_ITEM_LOCKED 0x0200 +#define DLGBOX_ITEM_CAN_DEFER_X 0x0400 +#define DLGBOX_ITEM_X_PENDING 0x0800 +#define DLGBOX_ITEM_ACLIST 0x1000 +#define DLGBOX_LEFT_GAP (BWIN_CUSHION_X+7) +#define DLGBOX_BULLET_GAP 3 +#define DLGBOX_VERT_GAP (BWIN_CUSHION_Y+2) +#define DLGBOX_MAX_ITEM 9 +#define DLGBOX_MAX_ITEM_VINE 11 +#define UNDERLINE_DEPTH 3 +#define EXTRA_GUTTER_WIDTH 4 +#define DLGBOX_ROMAN8_FONT 5 +/* Types for dlgbox */ +typedef struct +{ +unsigned short int flags; +char title[1]; +} HD_DLGBOX_RSC; +typedef struct +{ +short int flags; +unsigned char class; +char prompt[1]; +} AD_DLGBOX; +typedef struct +{ +PR_LODGER *hand; +PR_TEXTWIN *prompt; +short int flags; +} DLGBOX_ITEM; +typedef union +{ +DLGBOX_ITEM item[7]; +DLGBOX_ITEM *pitm; +} DLGBOX_ITEM_UNION; +/* Property of dlgbox */ +typedef struct { +DLGBOX_ITEM_UNION u; +void *rbuf; +short int dimrid; +short int helprid; +unsigned short int flags; +unsigned char focus; +unsigned char count; +unsigned char current; +unsigned char font; +unsigned char absorb; +unsigned char changed; +} PRS_DLGBOX; +typedef struct pr_dlgbox +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_DLGBOX; +/* Types for errordlg */ +typedef struct +{ +short int error; +char message[80]; +} RBUF_ERROR; +/* Property of errordlg */ +typedef struct pr_errordlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_ERRORDLG; +/* Types for querydlg */ +typedef struct +{ +short int result; +char message[100]; +} RBUF_QUERY; +/* Property of querydlg */ +typedef struct pr_querydlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_QUERYDLG; +/* Property of flistdlg */ +typedef struct pr_flistdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_FLISTDLG; diff --git a/code/SIBOSDK/include/dlgbox.ing b/code/SIBOSDK/include/dlgbox.ing new file mode 100644 index 0000000..58ea0d4 --- /dev/null +++ b/code/SIBOSDK/include/dlgbox.ing @@ -0,0 +1,153 @@ +; Generated by Ctran from dlgbox.cl +DLGBOX_ING equ 1 +IFNDEF BWIN_ING + INCLUDE ..\inc\BWIN.ING +ENDIF +IFNDEF TEXTWIN_ING + INCLUDE ..\inc\TEXTWIN.ING +ENDIF +; Class Numbers +C_DLGBOX equ 12 +C_ERRORDLG equ 13 +C_QUERYDLG equ 14 +C_FLISTDLG equ 15 +; Method Numbers +O_DL_SET_SIZE equ 27 +O_DL_DIMMED_MESSAGE equ 25 +O_DL_INQ_MINSIZE equ 28 +O_DL_ITEM_REPLACE equ 22 +O_DL_ITEM_APPEND equ 23 +O_DL_HANDLE_TO_INDEX equ 20 +O_DL_CLR_ITEM_FLAGS equ 17 +O_DL_TAKE_FOCUS equ 19 +O_DL_ITEM_ADD equ 26 +O_DL_FOCUS equ 32 +O_DL_SET_ITEM_FLAGS equ 16 +O_DL_ITEM_DIM equ 15 +O_DL_ITEM_NEW equ 34 +O_DL_INIT equ 24 +O_DL_KEY equ 30 +O_DL_DYN_INIT equ 29 +O_DL_INDEX_TO_HANDLE equ 21 +O_DL_CHANGED equ 31 +O_DL_LAUNCH_SUB equ 33 +O_DL_ITEM_LOCK equ 14 +O_DL_SET_PROMPT equ 18 +; Constants for dlgchain +PR_WIN_NO_DDP equ (PR_WIN_FORCE_TOP) +HELPDLG_BASIC_HELP equ (PR_WIN_FORCE_RIGHT) +HELPDLG_HELP_INDEX equ (PR_WIN_FORCE_LEFT) +DLGCHAIN_WITH_MENU equ (PR_WIN_FORCE_BOTTOM) +; Property of dlgchain +PRS_DLGCHAIN struc +DlgchainNext dw ? +PRS_DLGCHAIN ends +PR_DLGCHAIN struc +DlgchainRoot PRS_ROOT <> +DlgchainWin PRS_WIN <> +DlgchainDlgchain PRS_DLGCHAIN <> +PR_DLGCHAIN ends +; Constants for dlgbox +DLGBOX_NOTIFY_ENTER equ (00001h) +DLGBOX_NOTIFY_ESCAPE equ (00002h) +DLGBOX_RBUF_FILLED equ (00004h) +DLGBOX_ACTION_LIST equ (00008h) +DLGBOX_FROM_HWIF equ (00010h) +DLGBOX_SMALL_FONT equ (DLGBOX_FROM_HWIF) +DLGBOX_NO_WAIT equ (00020h) +DLGBOX_NOTIFY_ALL_ACT equ (00040h) +DLGBOX_REPORT_ACT_HORIZ equ (00080h) +DLGBOX_APPEND_UNITS_TITLE equ (00100h) +DLGBOX_SMALL_ACTION_LIST equ (00200h) +DLGBOX_NO_SHADOW equ (00400h) +DLGBOX_NO_DDP equ (00800h) +DLGBOX_ITEM_NOTIFY_CHANGED equ (00001h) +DLGBOX_ITEM_DIMMED equ (00002h) +DLGBOX_ITEM_UNDERLINED equ (00004h) +DLGBOX_ITEM_APPL_CAT equ (00008h) +DLGBOX_ITEM_CENTRE equ (00010h) +DLGBOX_ITEM_DEAD equ (00020h) +DLGBOX_ITEM_NOTIFY_FOCUS equ (00080h) +DLGBOX_ITEM_NEEDS_PACK equ (00100h) +DLGBOX_ITEM_LOCKED equ (00200h) +DLGBOX_ITEM_CAN_DEFER_X equ (00400h) +DLGBOX_ITEM_X_PENDING equ (00800h) +DLGBOX_ITEM_ACLIST equ (01000h) +DLGBOX_LEFT_GAP equ (BWIN_CUSHION_X+7) +DLGBOX_BULLET_GAP equ (3) +DLGBOX_VERT_GAP equ (BWIN_CUSHION_Y+2) +DLGBOX_MAX_ITEM equ (9) +DLGBOX_MAX_ITEM_VINE equ (11) +UNDERLINE_DEPTH equ (3) +EXTRA_GUTTER_WIDTH equ (4) +DLGBOX_ROMAN8_FONT equ (5) +; Types for dlgbox +HD_DLGBOX_RSC struc +HD_DLGBOX_RSCFlags dw ? +HD_DLGBOX_RSCTitle db (1) * 1 dup (?) +HD_DLGBOX_RSC ends +AD_DLGBOX struc +AD_DLGBOXFlags dw ? +AD_DLGBOXClass db ? +AD_DLGBOXPrompt db (1) * 1 dup (?) +AD_DLGBOX ends +DLGBOX_ITEM struc +DLGBOX_ITEMHand dw ? +DLGBOX_ITEMPrompt dw ? +DLGBOX_ITEMFlags dw ? +DLGBOX_ITEM ends +DLGBOX_ITEM_UNION union +DLGBOX_ITEM_UNIONItem db (size DLGBOX_ITEM)* 7 dup (?) +DLGBOX_ITEM_UNIONPitm dw ? +DLGBOX_ITEM_UNION ends +; Property of dlgbox +PRS_DLGBOX struc +DlgboxU DLGBOX_ITEM_UNION <> +DlgboxRbuf dw ? +DlgboxDimrid dw ? +DlgboxHelprid dw ? +DlgboxFlags dw ? +DlgboxFocus db ? +DlgboxCount db ? +DlgboxCurrent db ? +DlgboxFont db ? +DlgboxAbsorb db ? +DlgboxChanged db ? +PRS_DLGBOX ends +PR_DLGBOX struc +DlgboxRoot PRS_ROOT <> +DlgboxWin PRS_WIN <> +DlgboxDlgchain PRS_DLGCHAIN <> +DlgboxDlgbox PRS_DLGBOX <> +PR_DLGBOX ends +; Types for errordlg +RBUF_ERROR struc +RBUF_ERRORError dw ? +RBUF_ERRORMessage db (1) * 80 dup (?) +RBUF_ERROR ends +; Property of errordlg +PR_ERRORDLG struc +ErrordlgRoot PRS_ROOT <> +ErrordlgWin PRS_WIN <> +ErrordlgDlgchain PRS_DLGCHAIN <> +ErrordlgDlgbox PRS_DLGBOX <> +PR_ERRORDLG ends +; Types for querydlg +RBUF_QUERY struc +RBUF_QUERYResult dw ? +RBUF_QUERYMessage db (1) * 100 dup (?) +RBUF_QUERY ends +; Property of querydlg +PR_QUERYDLG struc +QuerydlgRoot PRS_ROOT <> +QuerydlgWin PRS_WIN <> +QuerydlgDlgchain PRS_DLGCHAIN <> +QuerydlgDlgbox PRS_DLGBOX <> +PR_QUERYDLG ends +; Property of flistdlg +PR_FLISTDLG struc +FlistdlgRoot PRS_ROOT <> +FlistdlgWin PRS_WIN <> +FlistdlgDlgchain PRS_DLGCHAIN <> +FlistdlgDlgbox PRS_DLGBOX <> +PR_FLISTDLG ends diff --git a/code/SIBOSDK/include/donewn.g b/code/SIBOSDK/include/donewn.g new file mode 100644 index 0000000..0723b74 --- /dev/null +++ b/code/SIBOSDK/include/donewn.g @@ -0,0 +1,33 @@ +/* Generated by Ctran from donewn.cl */ +#define DONEWN_G +#ifndef GAUGE_G +#include +#endif +/* Class Numbers */ +#define C_DONEWN 25 +/* Method Numbers */ +/* Constants for donewn */ +#define SE_DONEWN_RANGE 0x01 +#define SE_DONEWN_VALUE 0x02 +#define SE_DONEWN_INCREMENT 0x04 +#define SE_DONEWN_INC_VAL 0x08 +/* Types for donewn */ +typedef struct +{ +unsigned short int flags; +unsigned long int val; +unsigned long int range; +} SE_DONEWN; +/* Property of donewn */ +typedef struct { +unsigned long int val; +unsigned long int range; +} PRS_DONEWN; +typedef struct pr_donewn +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_GAUGE gauge; +PRS_DONEWN donewn; +} PR_DONEWN; diff --git a/code/SIBOSDK/include/donewn.ing b/code/SIBOSDK/include/donewn.ing new file mode 100644 index 0000000..162144f --- /dev/null +++ b/code/SIBOSDK/include/donewn.ing @@ -0,0 +1,31 @@ +; Generated by Ctran from donewn.cl +DONEWN_ING equ 1 +IFNDEF GAUGE_ING + INCLUDE ..\inc\GAUGE.ING +ENDIF +; Class Numbers +C_DONEWN equ 25 +; Method Numbers +; Constants for donewn +SE_DONEWN_RANGE equ (001h) +SE_DONEWN_VALUE equ (002h) +SE_DONEWN_INCREMENT equ (004h) +SE_DONEWN_INC_VAL equ (008h) +; Types for donewn +SE_DONEWN struc +SE_DONEWNFlags dw ? +SE_DONEWNVal dd ? +SE_DONEWNRange dd ? +SE_DONEWN ends +; Property of donewn +PRS_DONEWN struc +DonewnVal dd ? +DonewnRange dd ? +PRS_DONEWN ends +PR_DONEWN struc +DonewnRoot PRS_ROOT <> +DonewnWin PRS_WIN <> +DonewnLodger PRS_LODGER <> +DonewnGauge PRS_GAUGE <> +DonewnDonewn PRS_DONEWN <> +PR_DONEWN ends diff --git a/code/SIBOSDK/include/dos.h b/code/SIBOSDK/include/dos.h new file mode 100644 index 0000000..2d0c1b8 --- /dev/null +++ b/code/SIBOSDK/include/dos.h @@ -0,0 +1,205 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* dos.h - structure, union, macro and function definitions for MSDOS and * +* Intel IAPX86 family. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _DOS_INC_ +#define _DOS_INC_ + +#ifndef __STDC__ +extern unsigned int _osmajor; +extern unsigned int _osminor; +extern int _argc; +extern char *_argv[32]; +#endif + +#define FA_NORMAL 0x00 /* normal file */ +#define FA_RDONLY 0x01 /* Read only attribute */ +#define FA_HIDDEN 0x02 /* Hidden file */ +#define FA_SYSTEM 0x04 /* System file */ +#define FA_LABEL 0x08 /* Volume label */ +#define FA_DIREC 0x10 /* Directory */ +#define FA_ARCH 0x20 /* Archive */ +#define FA_TEXT 0x100 /* Open in text mode */ +#define FA_SHARE 0x200 /* Open with sharing */ + +struct WORDREGS { + unsigned int ax, bx, cx, dx, si, di, cflag, flags; +}; + +struct BYTEREGS { + unsigned char al, ah, bl, bh, cl, ch, dl, dh; +}; + +union REGS { + struct WORDREGS x; + struct BYTEREGS h; +}; + +struct SREGS { + unsigned int es; + unsigned int cs; + unsigned int ss; + unsigned int ds; +}; + +struct REGPACK { + unsigned r_ax, r_bx, r_cx, r_dx; + unsigned r_bp, r_si, r_di, r_ds, r_es, r_flags; +}; + +#ifdef __cplusplus +extern "C" { +#endif +extern int int86(int _intno, const union REGS * _inregs, union REGS * _outregs); +extern int int86x(int _intno, const union REGS * _inregs, union REGS * _outregs, + struct SREGS * _segregs); +extern void intr(int _intno, struct REGPACK * _preg); +extern void segread(struct SREGS * _segs); +#ifdef __cplusplus +} +#endif + +#ifndef _FFBLK_DEF +#define _FFBLK_DEF + +struct ffblk { + char ff_reserved[21]; + char ff_attrib; + int ff_ftime; + int ff_fdate; + long ff_fsize; + char ff_name[13]; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern int findfirst(const char * _path, struct ffblk * _buffer, int _attrib); +extern int findnext(struct ffblk * _buffer); +#ifdef __cplusplus +} +#endif + +#ifndef _PORTIO_DEF +#define _PORTIO_DEF + +#if (defined _IL_MTF) | ( defined __STDC__) + +#ifdef __cplusplus +extern "C" { +#endif +extern unsigned char inportb(int _portid); +extern void outportb(int _portid, unsigned char _value); +extern unsigned int inportw(int _portid); +extern void outportw(int _portid, unsigned int _value); +extern void _disable(void); +extern void _enable(void); +#ifdef __cplusplus +} +#endif + +#define inp(portid) inportb(portid) +#define outp(portid, v) outportb(portid, v) +#define inpw(portid) inportw(portid) +#define outpw(portid, v) outportw(portid, v) +#else + +#define RET 0xC3 + +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_param=>(dx,ax),reg_saved=>(bx,cx,si,di,es,ds,st1,st2), inline=>on) +static void __outportb__(int _port, unsigned char _byte) = +{ + 0xEE, RET /* out dx,al */ +}; + +static unsigned char __inportb__(int _port) = +{ + 0xEC, RET /* in dx,al */ +}; + +static void __outportw__(int _port,int unsigned _word) = +{ + 0xEF, RET /* out dx,ax */ +}; + +static unsigned int __inportw__(int _port) = +{ + 0xED, RET /* in dx,ax */ +}; + +static void _enable(void)= +{ + 0xFB, RET +}; + +static void _disable(void)= +{ + 0xFA, RET +}; +#ifdef __cplusplus +} +#endif + +#pragma restore + +#define inportb(portid) __inportb__(portid) /* Byte IN instruction */ +#define outportb(portid, v) __outportb__(portid,v)/* Byte OUT instruction */ +#define inportw(portid) __inportw__(portid) /* Word IN instruction */ +#define outportw(portid, v) __outportw__(portid,v)/* Word OUT instruction */ + +/* some compilers use inp, outp for inportb, outportb */ + +#define inp(portid) __inportb__(portid) +#define outp(portid, v) __outportb__(portid, v) +#define inpw(portid) __inportw__(portid) +#define outpw(portid, v) __outportw__(portid, v) +#endif +#define enable() _enable() +#define disable() _disable() +#endif + +#define NFDS 20 /* Maximum number of fds */ + +#ifndef _TMT_DEF +#define _TMT_DEF +struct date { + int da_year; + unsigned char da_day; + unsigned char da_mon; +}; + +struct time { + unsigned char ti_hour; + unsigned char ti_min; + unsigned char ti_sec; + unsigned char ti_hund; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern void getdate(struct date * _dptr); +extern void gettime(struct time * _tptr); +extern void setdate(const struct date * _dptr); +extern void settime(const struct time * _tptr); +extern void sleep(unsigned _secs); +extern void *getRealHandle(int handle); +#ifdef __cplusplus +} +#endif +#endif + + diff --git a/code/SIBOSDK/include/dtedit.g b/code/SIBOSDK/include/dtedit.g new file mode 100644 index 0000000..4ead35a --- /dev/null +++ b/code/SIBOSDK/include/dtedit.g @@ -0,0 +1,61 @@ +/* Generated by Ctran from dtedit.cl */ +#define DTEDIT_G +#ifndef LODGER_G +#include +#endif +#ifndef MFNE_G +#include +#endif +/* Class Numbers */ +#define C_DTEDIT 31 +/* Method Numbers */ +/* Constants for dtedit */ +#define SE_DTEDIT_VALUE 0x01 +#define SE_DTEDIT_LOW 0x02 +#define SE_DTEDIT_HIGH 0x04 +#define PR_DTEDIT_DATE 0x0000 +#define PR_DTEDIT_TIME 0x0100 +#define PR_DTEDIT_DURATION 0x0200 +#define PR_DTEDIT_SECONDS 0x1000 +#define PR_DTEDIT_NEGATIVE 0x2000 +#define PR_DTEDIT_AMPM 0x4000 +#define PR_DTEDIT_NEG_DURATION (PR_DTEDIT_DURATION|PR_DTEDIT_NEGATIVE) +#define IN_DTEDIT_INIT (SE_DTEDIT_VALUE|SE_DTEDIT_LOW|SE_DTEDIT_HIGH) +#define IN_DTEDIT_DDMMYYYY (PR_DTEDIT_DATE) +#define IN_DTEDIT_HHMMSS (PR_DTEDIT_TIME|PR_DTEDIT_SECONDS) +#define IN_DTEDIT_HHMM (PR_DTEDIT_TIME) +#define IN_DTEDIT_HHMMSS_D (PR_DTEDIT_TIME|PR_DTEDIT_DURATION|PR_DTEDIT_SECONDS) +#define IN_DTEDIT_HHMM_D (PR_DTEDIT_TIME|PR_DTEDIT_DURATION) +#define IN_DTEDIT_HHMMSS_ND (PR_DTEDIT_TIME|PR_DTEDIT_NEG_DURATION|PR_DTEDIT_SECONDS) +#define IN_DTEDIT_HHMM_ND (PR_DTEDIT_TIME|PR_DTEDIT_NEG_DURATION) +/* Types for dtedit */ +typedef struct +{ +unsigned short int flags; +long int value; +long int low; +long int high; +} IN_DTEDIT; +typedef struct +{ +unsigned short int flags; +long int value; +long int low; +long int high; +} SE_DTEDIT; +/* Property of dtedit */ +typedef struct { +void *cal; +short int dType; +unsigned char changed; +unsigned char inSelfCheck; +IN_DTEDIT in; +} PRS_DTEDIT; +typedef struct pr_dtedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +PRS_DTEDIT dtedit; +} PR_DTEDIT; diff --git a/code/SIBOSDK/include/dtedit.ing b/code/SIBOSDK/include/dtedit.ing new file mode 100644 index 0000000..53458bc --- /dev/null +++ b/code/SIBOSDK/include/dtedit.ing @@ -0,0 +1,58 @@ +; Generated by Ctran from dtedit.cl +DTEDIT_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF MFNE_ING + INCLUDE ..\inc\MFNE.ING +ENDIF +; Class Numbers +C_DTEDIT equ 31 +; Method Numbers +; Constants for dtedit +SE_DTEDIT_VALUE equ (001h) +SE_DTEDIT_LOW equ (002h) +SE_DTEDIT_HIGH equ (004h) +PR_DTEDIT_DATE equ (00000h) +PR_DTEDIT_TIME equ (00100h) +PR_DTEDIT_DURATION equ (00200h) +PR_DTEDIT_SECONDS equ (01000h) +PR_DTEDIT_NEGATIVE equ (02000h) +PR_DTEDIT_AMPM equ (04000h) +PR_DTEDIT_NEG_DURATION equ (PR_DTEDIT_DURATION or PR_DTEDIT_NEGATIVE) +IN_DTEDIT_INIT equ (SE_DTEDIT_VALUE or SE_DTEDIT_LOW or SE_DTEDIT_HIGH) +IN_DTEDIT_DDMMYYYY equ (PR_DTEDIT_DATE) +IN_DTEDIT_HHMMSS equ (PR_DTEDIT_TIME or PR_DTEDIT_SECONDS) +IN_DTEDIT_HHMM equ (PR_DTEDIT_TIME) +IN_DTEDIT_HHMMSS_D equ (PR_DTEDIT_TIME or PR_DTEDIT_DURATION or PR_DTEDIT_SECONDS) +IN_DTEDIT_HHMM_D equ (PR_DTEDIT_TIME or PR_DTEDIT_DURATION) +IN_DTEDIT_HHMMSS_ND equ (PR_DTEDIT_TIME or PR_DTEDIT_NEG_DURATION or PR_DTEDIT_SECONDS) +IN_DTEDIT_HHMM_ND equ (PR_DTEDIT_TIME or PR_DTEDIT_NEG_DURATION) +; Types for dtedit +IN_DTEDIT struc +IN_DTEDITFlags dw ? +IN_DTEDITValue dd ? +IN_DTEDITLow dd ? +IN_DTEDITHigh dd ? +IN_DTEDIT ends +SE_DTEDIT struc +SE_DTEDITFlags dw ? +SE_DTEDITValue dd ? +SE_DTEDITLow dd ? +SE_DTEDITHigh dd ? +SE_DTEDIT ends +; Property of dtedit +PRS_DTEDIT struc +DteditCal dw ? +DteditDType dw ? +DteditChanged db ? +DteditInSelfCheck db ? +DteditIn IN_DTEDIT <> +PRS_DTEDIT ends +PR_DTEDIT struc +DteditRoot PRS_ROOT <> +DteditWin PRS_WIN <> +DteditLodger PRS_LODGER <> +DteditMfne PRS_MFNE <> +DteditDtedit PRS_DTEDIT <> +PR_DTEDIT ends diff --git a/code/SIBOSDK/include/edit.g b/code/SIBOSDK/include/edit.g new file mode 100644 index 0000000..272fd4b --- /dev/null +++ b/code/SIBOSDK/include/edit.g @@ -0,0 +1,102 @@ +/* Generated by Ctran from edit.cat */ +#define EDIT_G +#ifndef VARRAY_G +#include +#endif +/* Class Numbers */ +#define C_EPROOT 51 +#define C_EPFLAT 52 +#define C_EPSEG 53 +#define C_VTAB 54 +/* Method Numbers */ +#define O_EP_CAPACITY 14 +#define O_EP_MOD_CHARS 12 +#define O_EP_COPY_TO_BACK 10 +#define O_EP_SET_TEXT 1 +#define O_EP_SCAN_BLOCK 6 +#define O_EP_EXTRACT 22 +#define O_EP_INIT 16 +#define O_EP_COPY_INDENT 8 +#define O_EP_SCAN_WORD 2 +#define O_EP_SENSE_LEN 17 +#define O_EP_CLEAR 23 +#define O_EP_WORD_COUNT 3 +#define O_VT_STRIP 28 +#define O_EP_DELETE 21 +#define O_VT_SET 27 +#define O_EP_ADD_PARA 7 +#define O_EP_INSERT 20 +#define O_EP_SENSE_CHARS 18 +#define O_EP_SCAN_PARA 4 +#define O_EP_COPY_TO_FRONT 9 +#define O_EP_PASTE 11 +#define O_EF_SENSE_BUF 25 +#define O_EP_PARA_COUNT 5 +#define O_VT_GAPTONEXT 24 +#define O_VT_SET_COLWID 25 +#define O_EP_COMPRESS 15 +#define O_VT_SETINTV 26 +#define O_EP_BACK_CHARS 19 +#define O_EF_GRANULARITY 24 +#define O_EP_SENSE_TEXT 13 +/* Constants for eproot */ +#define EP_SCAN_BACKWARDS 0x01 +#define EP_SCAN_STAY 0x02 +#define EP_SCAN_TO_BEGIN 0x04 +#define EP_SCAN_TO_END 0x08 +#define EP_SCAN_JOIN_DELIM 0x10 +#define EP_SCAN_NOT_TO_END 0x20 +#define EP_RETURN_LENGTH -1 +#define EP_MOD_TOLOWER 0 +#define EP_MOD_TOUPPER 1 +#define EP_MOD_WRAP 2 +/* Property of eproot */ +typedef struct { +unsigned short int maxlen; +} PRS_EPROOT; +typedef struct pr_eproot +{ +PRS_ROOT root; +PRS_EPROOT eproot; +} PR_EPROOT; +/* Property of epflat */ +typedef struct { +unsigned short int alen; +unsigned short int gran; +unsigned short int len; +char *buf; +} PRS_EPFLAT; +typedef struct pr_epflat +{ +PRS_ROOT root; +PRS_EPROOT eproot; +PRS_EPFLAT epflat; +} PR_EPFLAT; +/* Property of epseg */ +typedef struct { +PR_SGBUF *b; +} PRS_EPSEG; +typedef struct pr_epseg +{ +PRS_ROOT root; +PRS_EPROOT eproot; +PRS_EPSEG epseg; +} PR_EPSEG; +/* Types for vtab */ +typedef struct +{ +short int *ploff1; +short int *ploff2; +} TABS_STRIP_OFFS; +/* Property of vtab */ +typedef struct { +unsigned short int c; +} PRS_VTAB; +typedef struct pr_vtab +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VAFLAT vaflat; +PRS_VTAB vtab; +} PR_VTAB; diff --git a/code/SIBOSDK/include/edit.ing b/code/SIBOSDK/include/edit.ing new file mode 100644 index 0000000..55b063f --- /dev/null +++ b/code/SIBOSDK/include/edit.ing @@ -0,0 +1,97 @@ +; Generated by Ctran from edit.cat +EDIT_ING equ 1 +IFNDEF VARRAY_ING + INCLUDE ..\inc\VARRAY.ING +ENDIF +; Class Numbers +C_EPROOT equ 51 +C_EPFLAT equ 52 +C_EPSEG equ 53 +C_VTAB equ 54 +; Method Numbers +O_EP_CAPACITY equ 14 +O_EP_MOD_CHARS equ 12 +O_EP_COPY_TO_BACK equ 10 +O_EP_SET_TEXT equ 1 +O_EP_SCAN_BLOCK equ 6 +O_EP_EXTRACT equ 22 +O_EP_INIT equ 16 +O_EP_COPY_INDENT equ 8 +O_EP_SCAN_WORD equ 2 +O_EP_SENSE_LEN equ 17 +O_EP_CLEAR equ 23 +O_EP_WORD_COUNT equ 3 +O_VT_STRIP equ 28 +O_EP_DELETE equ 21 +O_VT_SET equ 27 +O_EP_ADD_PARA equ 7 +O_EP_INSERT equ 20 +O_EP_SENSE_CHARS equ 18 +O_EP_SCAN_PARA equ 4 +O_EP_COPY_TO_FRONT equ 9 +O_EP_PASTE equ 11 +O_EF_SENSE_BUF equ 25 +O_EP_PARA_COUNT equ 5 +O_VT_GAPTONEXT equ 24 +O_VT_SET_COLWID equ 25 +O_EP_COMPRESS equ 15 +O_VT_SETINTV equ 26 +O_EP_BACK_CHARS equ 19 +O_EF_GRANULARITY equ 24 +O_EP_SENSE_TEXT equ 13 +; Constants for eproot +EP_SCAN_BACKWARDS equ (001h) +EP_SCAN_STAY equ (002h) +EP_SCAN_TO_BEGIN equ (004h) +EP_SCAN_TO_END equ (008h) +EP_SCAN_JOIN_DELIM equ (010h) +EP_SCAN_NOT_TO_END equ (020h) +EP_RETURN_LENGTH equ (-1) +EP_MOD_TOLOWER equ (0) +EP_MOD_TOUPPER equ (1) +EP_MOD_WRAP equ (2) +; Property of eproot +PRS_EPROOT struc +EprootMaxlen dw ? +PRS_EPROOT ends +PR_EPROOT struc +EprootRoot PRS_ROOT <> +EprootEproot PRS_EPROOT <> +PR_EPROOT ends +; Property of epflat +PRS_EPFLAT struc +EpflatAlen dw ? +EpflatGran dw ? +EpflatLen dw ? +EpflatBuf dw ? +PRS_EPFLAT ends +PR_EPFLAT struc +EpflatRoot PRS_ROOT <> +EpflatEproot PRS_EPROOT <> +EpflatEpflat PRS_EPFLAT <> +PR_EPFLAT ends +; Property of epseg +PRS_EPSEG struc +EpsegB dw ? +PRS_EPSEG ends +PR_EPSEG struc +EpsegRoot PRS_ROOT <> +EpsegEproot PRS_EPROOT <> +EpsegEpseg PRS_EPSEG <> +PR_EPSEG ends +; Types for vtab +TABS_STRIP_OFFS struc +TABS_STRIP_OFFSPloff1 dw ? +TABS_STRIP_OFFSPloff2 dw ? +TABS_STRIP_OFFS ends +; Property of vtab +PRS_VTAB struc +VtabC dw ? +PRS_VTAB ends +PR_VTAB struc +VtabRoot PRS_ROOT <> +VtabVaroot PRS_VAROOT <> +VtabVafix PRS_VAFIX <> +VtabVaflat PRS_VAFLAT <> +VtabVtab PRS_VTAB <> +PR_VTAB ends diff --git a/code/SIBOSDK/include/edwin.g b/code/SIBOSDK/include/edwin.g new file mode 100644 index 0000000..f51ca7f --- /dev/null +++ b/code/SIBOSDK/include/edwin.g @@ -0,0 +1,157 @@ +/* Generated by Ctran from edwin.cl */ +#define EDWIN_G +#ifndef LODGER_G +#include +#endif +#ifndef SCRLAY_G +#include +#endif +/* Class Numbers */ +#define C_EDWIN 34 +#define C_PUNCTUED 35 +#define C_EWLINKSV 36 +/* Method Numbers */ +#define O_EW_SET 21 +#define O_EWLS_INIT 1 +#define O_EW_REPLACE_CLIP 30 +#define O_EW_INSERT 23 +#define O_EW_BRING_IN 32 +#define O_EW_REPLACE 28 +#define O_EW_SENSE 22 +#define O_EW_SNUGGLE_INSERT 24 +#define O_EW_RETURN_KEY 34 +#define O_EW_EP_INSERT 33 +#define O_EW_TAB_KEY 35 +#define O_EW_PASTE_CLIP 31 +#define O_EW_FIND 27 +#define O_EW_SET_SIZE 20 +#define O_EW_LEAVE 26 +#define O_EWLS_EXTRACT 2 +#define O_EW_READONLY 37 +#define O_EW_SET_FONT 25 +#define O_EW_SENSE_SIZE 19 +#define O_EW_INIT_STYLE 36 +#define O_EW_EVALUATE 29 +/* Constants for edwin */ +#define PR_EDWIN_DIALLABLE 0x0001 +#define PR_EDWIN_ACCEPT_TABS 0x0002 +#define PR_EDWIN_ACCEPT_SOFT_HYPHENS 0x0004 +#define PR_EDWIN_AUTO_CUR_END 0x0008 +#define PR_EDWIN_AUTO_SELECT 0x0010 +#define PR_EDWIN_DOC_SUPPLIED 0x0020 +#define PR_EDWIN_CLIPBOARD 0x0040 +#define PR_EDWIN_NOTIFY_OVERFLOW 0x0080 +#define PR_EDWIN_READONLY 0x8000 +#define IN_EDWIN_DIALLABLE PR_EDWIN_DIALLABLE +#define IN_EDWIN_ACCEPT_TABS PR_EDWIN_ACCEPT_TABS +#define IN_EDWIN_ACCEPT_SOFT_HYPHENS PR_EDWIN_ACCEPT_SOFT_HYPHENS +#define IN_EDWIN_AUTO_CUR_END (PR_EDWIN_AUTO_CUR_END|PR_EDWIN_AUTO_SELECT) +#define IN_EDWIN_NO_AUTOSELECT PR_EDWIN_AUTO_SELECT +#define IN_EDWIN_DOC_SUPPLIED PR_EDWIN_DOC_SUPPLIED +#define IN_EDWIN_CLIPBOARD PR_EDWIN_CLIPBOARD +#define IN_EDWIN_VULEN 0x0080 +#define IN_EDWIN_VULEN_NOSCALE 0x0100 +#define IN_EDWIN_VULEN_CHARACTERS IN_EDWIN_VULEN +#define IN_EDWIN_VULEN_PIXELS (IN_EDWIN_VULEN|IN_EDWIN_VULEN_NOSCALE) +#define IN_EDWIN_LEFT_CURSOR 0x0200 +#define IN_EDWIN_TEXT_SEGMENTED 0x0400 +#define IN_EDWIN_POSITION_SUPPLIED 0x0800 +#define IN_EDWIN_FONT_SUPPLIED 0x1000 +#define IN_EDWIN_LEADING_SUPPLIED 0x2000 +#define IN_EDWIN_VISLINES_SUPPLIED 0x4000 +#define IN_EDWIN_PAGINATABLE 0x8000 +#define SET_EDWIN_TXT 0x01 +#define SET_EDWIN_EMPTY 0x02 +#define SET_EDWIN_CUR_END 0x04 +#define SET_EDWIN_SEL_ALL 0x08 +#define SET_EDWIN_CURSOR 0x10 +#define SET_EDWIN_ANCHOR 0x20 +#define EWF_BACKWARDS 0x0001 +#define EWF_CASESENS 0x0002 +#define EW_CHANGE_SINCE_SAVED 0x01 +#define EW_CHANGE_SINCE_PAGINATE 0x02 +#define EW_CHANGE 0xffff +#define EW_BRING_SINGLE_SHOT 0xf000 +/* Types for edwin */ +typedef struct +{ +unsigned short int vulen; +unsigned short int flags; +unsigned short int maxlen; +char contents[1]; +} IN_EDWIN; +typedef struct +{ +short int total; +short int top; +} EDWIN_LEADING; +typedef struct +{ +unsigned short int vislines; +P_POINT pos; +short int font; +unsigned short int style; +EDWIN_LEADING leading; +void *doc; +void *clip; +} IN_EDWIN_X; +typedef struct +{ +char *buf; +unsigned short int len; +} SE_EDWIN; +typedef struct +{ +unsigned short int flags; +SE_EDWIN txt; +unsigned short int cursor; +unsigned short int anchor; +} SET_EDWIN; +typedef struct +{ +unsigned short int cursor; +unsigned short int anchor; +} SENSE_EDWIN; +/* Property of edwin */ +typedef struct { +void *scrimg; +void *scrlay; +void *doc; +unsigned short int cpos; +unsigned short int clen; +void *clip; +unsigned short int select; +unsigned short int change; +unsigned short int flags; +SCRLAY_MARGINS margins; +SCRLAY_FONT font; +} PRS_EDWIN; +typedef struct pr_edwin +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_EDWIN edwin; +} PR_EDWIN; +/* Property of punctued */ +typedef struct pr_punctued +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_EDWIN edwin; +} PR_PUNCTUED; +/* Property of ewlinksv */ +typedef struct { +void *doc; +short int state; +unsigned short int pos; +unsigned short int parend; +unsigned short int posend; +char buf[256]; +} PRS_EWLINKSV; +typedef struct pr_ewlinksv +{ +PRS_ROOT root; +PRS_EWLINKSV ewlinksv; +} PR_EWLINKSV; diff --git a/code/SIBOSDK/include/edwin.ing b/code/SIBOSDK/include/edwin.ing new file mode 100644 index 0000000..3aec3b0 --- /dev/null +++ b/code/SIBOSDK/include/edwin.ing @@ -0,0 +1,148 @@ +; Generated by Ctran from edwin.cl +EDWIN_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +; Class Numbers +C_EDWIN equ 34 +C_PUNCTUED equ 35 +C_EWLINKSV equ 36 +; Method Numbers +O_EW_SET equ 21 +O_EWLS_INIT equ 1 +O_EW_REPLACE_CLIP equ 30 +O_EW_INSERT equ 23 +O_EW_BRING_IN equ 32 +O_EW_REPLACE equ 28 +O_EW_SENSE equ 22 +O_EW_SNUGGLE_INSERT equ 24 +O_EW_RETURN_KEY equ 34 +O_EW_EP_INSERT equ 33 +O_EW_TAB_KEY equ 35 +O_EW_PASTE_CLIP equ 31 +O_EW_FIND equ 27 +O_EW_SET_SIZE equ 20 +O_EW_LEAVE equ 26 +O_EWLS_EXTRACT equ 2 +O_EW_READONLY equ 37 +O_EW_SET_FONT equ 25 +O_EW_SENSE_SIZE equ 19 +O_EW_INIT_STYLE equ 36 +O_EW_EVALUATE equ 29 +; Constants for edwin +PR_EDWIN_DIALLABLE equ (00001h) +PR_EDWIN_ACCEPT_TABS equ (00002h) +PR_EDWIN_ACCEPT_SOFT_HYPHENS equ (00004h) +PR_EDWIN_AUTO_CUR_END equ (00008h) +PR_EDWIN_AUTO_SELECT equ (00010h) +PR_EDWIN_DOC_SUPPLIED equ (00020h) +PR_EDWIN_CLIPBOARD equ (00040h) +PR_EDWIN_NOTIFY_OVERFLOW equ (00080h) +PR_EDWIN_READONLY equ (08000h) +IN_EDWIN_DIALLABLE equ (PR_EDWIN_DIALLABLE) +IN_EDWIN_ACCEPT_TABS equ (PR_EDWIN_ACCEPT_TABS) +IN_EDWIN_ACCEPT_SOFT_HYPHENS equ (PR_EDWIN_ACCEPT_SOFT_HYPHENS) +IN_EDWIN_AUTO_CUR_END equ (PR_EDWIN_AUTO_CUR_END or PR_EDWIN_AUTO_SELECT) +IN_EDWIN_NO_AUTOSELECT equ (PR_EDWIN_AUTO_SELECT) +IN_EDWIN_DOC_SUPPLIED equ (PR_EDWIN_DOC_SUPPLIED) +IN_EDWIN_CLIPBOARD equ (PR_EDWIN_CLIPBOARD) +IN_EDWIN_VULEN equ (00080h) +IN_EDWIN_VULEN_NOSCALE equ (00100h) +IN_EDWIN_VULEN_CHARACTERS equ (IN_EDWIN_VULEN) +IN_EDWIN_VULEN_PIXELS equ (IN_EDWIN_VULEN or IN_EDWIN_VULEN_NOSCALE) +IN_EDWIN_LEFT_CURSOR equ (00200h) +IN_EDWIN_TEXT_SEGMENTED equ (00400h) +IN_EDWIN_POSITION_SUPPLIED equ (00800h) +IN_EDWIN_FONT_SUPPLIED equ (01000h) +IN_EDWIN_LEADING_SUPPLIED equ (02000h) +IN_EDWIN_VISLINES_SUPPLIED equ (04000h) +IN_EDWIN_PAGINATABLE equ (08000h) +SET_EDWIN_TXT equ (001h) +SET_EDWIN_EMPTY equ (002h) +SET_EDWIN_CUR_END equ (004h) +SET_EDWIN_SEL_ALL equ (008h) +SET_EDWIN_CURSOR equ (010h) +SET_EDWIN_ANCHOR equ (020h) +EWF_BACKWARDS equ (00001h) +EWF_CASESENS equ (00002h) +EW_CHANGE_SINCE_SAVED equ (001h) +EW_CHANGE_SINCE_PAGINATE equ (002h) +EW_CHANGE equ (0ffffh) +EW_BRING_SINGLE_SHOT equ (0f000h) +; Types for edwin +IN_EDWIN struc +IN_EDWINVulen dw ? +IN_EDWINFlags dw ? +IN_EDWINMaxlen dw ? +IN_EDWINContents db (1) * 1 dup (?) +IN_EDWIN ends +EDWIN_LEADING struc +EDWIN_LEADINGTotal dw ? +EDWIN_LEADINGTop dw ? +EDWIN_LEADING ends +IN_EDWIN_X struc +IN_EDWIN_XVislines dw ? +IN_EDWIN_XPos P_POINT <> +IN_EDWIN_XFont dw ? +IN_EDWIN_XStyle dw ? +IN_EDWIN_XLeading EDWIN_LEADING <> +IN_EDWIN_XDoc dw ? +IN_EDWIN_XClip dw ? +IN_EDWIN_X ends +SE_EDWIN struc +SE_EDWINBuf dw ? +SE_EDWINLen dw ? +SE_EDWIN ends +SET_EDWIN struc +SET_EDWINFlags dw ? +SET_EDWINTxt SE_EDWIN <> +SET_EDWINCursor dw ? +SET_EDWINAnchor dw ? +SET_EDWIN ends +SENSE_EDWIN struc +SENSE_EDWINCursor dw ? +SENSE_EDWINAnchor dw ? +SENSE_EDWIN ends +; Property of edwin +PRS_EDWIN struc +EdwinScrimg dw ? +EdwinScrlay dw ? +EdwinDoc dw ? +EdwinCpos dw ? +EdwinClen dw ? +EdwinClip dw ? +EdwinSelect dw ? +EdwinChange dw ? +EdwinFlags dw ? +EdwinMargins SCRLAY_MARGINS <> +EdwinFont SCRLAY_FONT <> +PRS_EDWIN ends +PR_EDWIN struc +EdwinRoot PRS_ROOT <> +EdwinWin PRS_WIN <> +EdwinLodger PRS_LODGER <> +EdwinEdwin PRS_EDWIN <> +PR_EDWIN ends +; Property of punctued +PR_PUNCTUED struc +PunctuedRoot PRS_ROOT <> +PunctuedWin PRS_WIN <> +PunctuedLodger PRS_LODGER <> +PunctuedEdwin PRS_EDWIN <> +PR_PUNCTUED ends +; Property of ewlinksv +PRS_EWLINKSV struc +EwlinksvDoc dw ? +EwlinksvState dw ? +EwlinksvPos dw ? +EwlinksvParend dw ? +EwlinksvPosend dw ? +EwlinksvBuf db (1) * 256 dup (?) +PRS_EWLINKSV ends +PR_EWLINKSV struc +EwlinksvRoot PRS_ROOT <> +EwlinksvEwlinksv PRS_EWLINKSV <> +PR_EWLINKSV ends diff --git a/code/SIBOSDK/include/epdoc.g b/code/SIBOSDK/include/epdoc.g new file mode 100644 index 0000000..b4f2841 --- /dev/null +++ b/code/SIBOSDK/include/epdoc.g @@ -0,0 +1,37 @@ +/* Generated by Ctran from epdoc.cat */ +#define EPDOC_G +#ifndef EDIT_G +#include +#endif +/* Class Numbers */ +#define C_EPFDOC 4 +#define C_EPDOC 5 +/* Method Numbers */ +#define O_EPFDOC_PARA_START 26 +#define O_EPFDOC_SENSE_CHARS 27 +#define O_EPDOC_POS_FILTER 30 +#define O_EPDOC_SENSE_CHARS 25 +#define O_EPDOC_SET_PAGES 26 +#define O_EPDOC_PARA_START 24 +#define O_EPDOC_GOTO_PAGE 28 +#define O_EPDOC_SET_FILTER 29 +#define O_EPDOC_ENQ_PAGE 27 +/* Property of epfdoc */ +typedef struct pr_epfdoc +{ +PRS_ROOT root; +PRS_EPROOT eproot; +PRS_EPFLAT epflat; +} PR_EPFDOC; +/* Property of epdoc */ +typedef struct { +PR_SGBUF *b; +PR_VAFLAT *pages; +PR_VAFLAT *filter; +} PRS_EPDOC; +typedef struct pr_epdoc +{ +PRS_ROOT root; +PRS_EPROOT eproot; +PRS_EPDOC epdoc; +} PR_EPDOC; diff --git a/code/SIBOSDK/include/epdoc.ing b/code/SIBOSDK/include/epdoc.ing new file mode 100644 index 0000000..bfd97bd --- /dev/null +++ b/code/SIBOSDK/include/epdoc.ing @@ -0,0 +1,35 @@ +; Generated by Ctran from epdoc.cl +EPDOC_ING equ 1 +IFNDEF EDIT_ING + INCLUDE ..\inc\EDIT.ING +ENDIF +; Class Numbers +C_EPFDOC equ 4 +C_EPDOC equ 5 +; Method Numbers +O_EPFDOC_PARA_START equ 26 +O_EPFDOC_SENSE_CHARS equ 27 +O_EPDOC_POS_FILTER equ 30 +O_EPDOC_SENSE_CHARS equ 25 +O_EPDOC_SET_PAGES equ 26 +O_EPDOC_PARA_START equ 24 +O_EPDOC_GOTO_PAGE equ 28 +O_EPDOC_SET_FILTER equ 29 +O_EPDOC_ENQ_PAGE equ 27 +; Property of epfdoc +PR_EPFDOC struc +EpfdocRoot PRS_ROOT <> +EpfdocEproot PRS_EPROOT <> +EpfdocEpflat PRS_EPFLAT <> +PR_EPFDOC ends +; Property of epdoc +PRS_EPDOC struc +EpdocB dw ? +EpdocPages dw ? +EpdocFilter dw ? +PRS_EPDOC ends +PR_EPDOC struc +EpdocRoot PRS_ROOT <> +EpdocEproot PRS_EPROOT <> +EpdocEpdoc PRS_EPDOC <> +PR_EPDOC ends diff --git a/code/SIBOSDK/include/epoc.h b/code/SIBOSDK/include/epoc.h new file mode 100644 index 0000000..5b4acb7 --- /dev/null +++ b/code/SIBOSDK/include/epoc.h @@ -0,0 +1,552 @@ +/* HEADER - EPOC.H +Copyright (C) Psion PLC 1991 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +*/ +#ifndef EPOC_H +#define EPOC_H + +#include + +#define E_PRIORITY_TIME_SUPERVISOR 0xf8 +#define E_PRIORITY_TIME_FSERV 0xf0 +#define E_PRIORITY_TIME_CRITICAL 0xb0 +#define E_PRIORITY_WSERV_MOUSE 0xa8 +#define E_PRIORITY_WSERV 0xa0 +#define E_PRIORITY_NOTIFY 0x90 +#define E_PRIORITY_FORE 0x80 +#define E_PRIORITY_BACK 0x70 +#define E_LCD_UNKNOWN (-1) +#define E_LCD_640_400 0 +#define E_LCD_640_200_SMALL 1 +#define E_LCD_640_200_BIG 2 +#define E_LCD_720_348 3 +#define E_LCD_160_80 4 +#define E_LCD_240_80 5 +#define E_PC_HERC E_LCD_720_348 +#define E_PC_CGA E_LCD_640_200_BIG +#define E_PC_MDA 6 +#define E_PC_EGA_MONO 7 +#define E_PC_EGA_COLOUR 8 +#define E_PC_VGA_MONO 9 +#define E_PC_VGA_COLOUR 10 +#define E_LCD_480_160 11 +#define E_LCD_240_100 12 +#define E_LCD_240_120 13 +#define E_LCD_240_160 14 +#define E_LCD_640_200 15 +#define E_PSU_OLD 0 +#define E_PSU_MAXIM 1 +#define E_PSU_S3 2 +#define E_PSU_S3_A9 3 +#define E_IS_A_COLD_START 0 +#define E_IS_A_POWERFAIL_START 1 +#define E_IS_A_RESET_START 2 +#define E_IS_A_KERNEL_FAULT 3 +#define E_IS_A_NEW_OS_START 4 +#define E_MAX_PROCESSES 24 +#define E_MAX_PRIORITY 0xc0 +#define E_MIN_PRIORITY 0x40 +#define E_MAX_NAME 12 +#define E_PIDMASK 0xfff +#define E_MAX_ERROR_TEXT_SIZE 64 +#define E_MAX_NOTIFY_TEXT_SIZE 64 +#define E_MAX_OPTION_TEXT_SIZE 16 +#define E_MAX_ENV_SIZE 16 +#define E_MAX_SUFFIXES 31 +#define E_MAX_MONTH_NAME 32 +#define E_MAX_DAY_NAME 32 +#define E_MAX_COMMAND_BUFFER 127 +#define E_MAX_GROWBY 0x400 +#define E_MAX_PASSWORD 8 +#define E_GROWBY_DEFAULT 0x80 +#define E_SEGMENT_LOW 0 +#define E_SEGMENT_HIGH 1 +#define E_SEGMENT_DEVICE 2 +#define E_LDD 0xdd01 +#define E_PDD 0xdd21 +#define E_NORMAL_EXIT 0 +#define E_PANIC_EXIT 1 +#define E_TASK_PANIC_EXIT 2 +#define E_FILE_SYSTEM_NAMESIZE 5 +#define E_SOUND_KEYBOARD 0x0001 +#define E_SOUND_BUZZER 0x0002 +#define E_SOUND_DEVICE 0x0004 +#define E_SOUND_LOUD 0x0008 +#define E_SOUND_LOUD_BUZZER 0x0010 +#define E_SOUND_DISABLE 0x8000 +#define E_SOUND_MAX_VOLUME 0 +#define E_SOUND_MIN_VOLUME 5 +#define E_SOUND_MAX_BPM 240 +#define E_SOUND_MIN_BPM 2 +#define E_MAX_ALARMS 2 +#define E_MAX_DTMF_DIAL 24 +#define E_MAX_DTMF_DIAL_B 40 +#define E_BATTERY_UNKNOWN 0 +#define E_BATTERY_ALKALINE 1 +#define E_BATTERY_NICAD_600 2 +#define E_BATTERY_NICAD_1000 3 +#define E_BATTERY_NICAD_500 4 +#define E_BATTERY_NICAD_850 5 +#define E_TICKS_PER_SECOND 32 +#define E_OPL_TEXT_MESSAGE 24 +#define E_BACKLIGHT_DISABLE 0x8000 +#define E_BACKLIGHT_OFF 0 +#define E_BACKLIGHT_ON 1 +#define E_BACKLIGHT_TOGGLE 2 +#define E_BACKLIGHT_QUERY 3 +#define E_FMEDIA_BATTERY_VALID 0x0400 +#define E_FMEDIA_BATTERY_GOOD 0x0200 +#define E_FRC_COUNTING 0 +#define E_FRC_REPEATING 1 +#define E_FSSOUNDCHANNEL1 1 +#define E_FSSOUNDCHANNEL2 2 +#define E_FRELATIVE 1 +#define E_FABSOLUTE 2 +#define E_FALARM 9 +#define E_FDIAL 10 +#define E_FSOUND_PLAY 0x10 +#define E_FSOUND_RECORD 0x11 + +#define E_KEY_DELETE_LEFT 0x0008 +#define E_KEY_TAB 0x0009 +#define E_KEY_RETURN 0x000d +#define E_KEY_ESCAPE 0x001b +#define E_KEY_DELETE_RIGHT 0x007f +#define E_KEY_UP 0x0100 +#define E_KEY_DOWN 0x0101 +#define E_KEY_RIGHT 0x0102 +#define E_KEY_LEFT 0x0103 +#define E_KEY_PAGE_UP 0x0104 +#define E_KEY_PAGE_DOWN 0x0105 +#define E_KEY_HOME 0x0106 +#define E_KEY_END 0x0107 +#define E_KEY_INSERT 0x0108 +#define E_KEY_VOICE 0x0109 +#define E_KEY_PSION_DOWN 0x010a +#define E_KEY_PSION_UP 0x010b +#define E_KEY_CAPS 0x10c +#define E_KEY_PSION 0x200 +#define E_KEY_BACKLIGHT 0x120 +#define E_KEY_INFO 0x121 +#define E_KEY_MENU 0x122 +#define E_KEY_HELP 0x123 +#define E_KEY_DIAMOND 0x124 + +#define E_KEY_APP1 0x131 +#define E_KEY_APP2 0x132 +#define E_KEY_APP3 0x133 +#define E_KEY_APP4 0x134 +#define E_KEY_APP5 0x135 +#define E_KEY_APP6 0x136 +#define E_KEY_APP7 0x137 +#define E_KEY_APP8 0x138 + +#define E_KEY_LCD 0x2000 +#define E_KEY_LCD_MINUS 0x2001 +#define E_KEY_ON 0x2002 +#define E_KEY_OFF 0x2003 + +#define E_STATE_KEY_VALID 0x0001 +#define E_STATE_SHIFT 0x0002 +#define E_STATE_CONTROL 0x0004 +#define E_STATE_PSION 0x0008 +#define E_STATE_CAPS_LOCKED 0x0010 +#define E_STATE_NUM_LOCKED 0x0020 +#define E_STATE_MOUSE_VALID 0x0040 +#define E_STATE_MOUSE_DOWN 0x0080 +#define E_STATE_MOUSE_MOVED 0x0100 +#define E_STATE_MOUSE_CHANGED 0x0200 +#define E_STATE_MOUSE_GONE 0x0400 +#define E_STATE_KEY_REPEATED 0x0800 +#define E_STATE_FN 0x0080 + +/* Additional I/O functions */ +#define P_FTIMER_RELATIVE 1 +#define P_FTIMER_ABSOLUTE 2 +#define P_FSOUND_CHANNEL1 1 +#define P_FSOUND_CHANNEL2 2 +#define P_FSOUND_PLAY P_FTEST +#define P_FSOUND_RECORD P_FCTRL + +typedef struct + { + unsigned char beatsPerMinute; + unsigned char volume; + } E_SOUND; + +typedef struct + { + unsigned short int code; + unsigned short int state; + unsigned short int tick; + unsigned short int mouseX; + unsigned short int mouseY; + } E_KEYS; + +typedef struct + { + unsigned char toneLengthTicks; + unsigned char delayLengthTicks; + unsigned short int pauseLengthTicks; + } E_DIAL; + +typedef struct message + { + struct message *next; + unsigned char *status; + unsigned int type; + int pid; + } E_MESSAGE; + +typedef struct + { + unsigned short int codeParagraphs; + unsigned short int initialIp; + unsigned short int stackParagraphs; + unsigned short int dataParagraphs; + unsigned short int heapParagraphs; + unsigned char *commandLine; + unsigned short int checkSum; + unsigned short int minHeap; + unsigned char priority; + unsigned char ramOrRom; + unsigned char name[E_MAX_NAME]; + } E_CPB; + +#define E_PROC_FREE 0xff +#define E_PROC_CURRENT 0x01 +#define E_PROC_READY 0x02 +#define E_PROC_DELTA 0x03 +#define E_PROC_SUSPENDED 0x04 +#define E_PROC_SEMAPHORE 0x05 +typedef struct e_proc + { + struct e_proc *next; + struct e_proc *prev; + short int queKey; + short int queData; + unsigned char deltaType; + unsigned char addressTrap; + unsigned char status; + unsigned char sstatus; + unsigned char priority; + unsigned char priorityH; + unsigned char ramOrRom; + unsigned char isTask; + unsigned char name[E_MAX_NAME+1]; + unsigned char active; + unsigned short int semaphore; + unsigned char *semHead; + unsigned char *memBasePtr; + unsigned short int memGrowBy; + unsigned char *mCtrlPtr; + unsigned short int minHeap; + int fServer; + int dataSeg; + int codeSeg; + unsigned char *saveSP; + unsigned char *saveBP; + unsigned char notify; + unsigned char sndSem; + unsigned short int magic; + unsigned short int checkSum; + unsigned short int terminate; + unsigned short int bankState; + } E_PROC; +typedef struct + { + unsigned short int mainBatteryReading; + unsigned short int lithiumBatteryReading; + short int mainsPresent; + } E_SUPPLY; +typedef struct + { + unsigned short int mainBatteryWarning; + unsigned short int lithiumBatteryWarning; + unsigned short int mainBatteryMax; + unsigned short int lithiumBatteryMax; + } E_SUPPLY_WARNINGS; +#define E_MBAT_ZERO 0 +#define E_MBAT_VERY_LOW 1 +#define E_MBAT_LOW 2 +#define E_MBAT_GOOD 3 +#define E_SUPPLY_SOUND_WARNING 0x0001 +#define E_SUPPLY_FLASH_WARNING 0x0002 +#define E_SUPPLY_SYSTEM_TIME_CHANGED 0x0004 +typedef struct + { + unsigned char mainBatteryLevel; + unsigned char mainBatteryStatus; + unsigned char backupBatteryLevel; + unsigned char dcLevel; + unsigned short int warningFlags; + unsigned long int insertionDate; + unsigned long int ticksInUseBattery; + unsigned long int ticksInUseDc; + unsigned long int maTicks; + } E_SUPPLY_INFO; +#define ImgVersion 0x200f +#define DevVersion 0x200f +#define SignatureSize 16 +#define ImageSignature "ImageFileType**" +#define LDDSignature "LDDFileType****" +#define PDDSignature "PDDFileType****" +#define LIBSignature "LIBFileType****" +#define HeaderSize 0x40 +#define MagicLandSize 0x40 +#define MaxAddFiles 4 +typedef struct + { + unsigned short int offset; + unsigned short int length; + } ADDFILE; +typedef struct + { + unsigned char name[E_MAX_NAME+2]; /* Dyl name zero terminated */ + unsigned long int offset; /* Offset in File */ + } DYLENTRY; +typedef struct + { + unsigned char Signature[SignatureSize]; + unsigned short int ImageVersion; + unsigned short int HeaderSizeBytes; + unsigned short int CodeParas; + unsigned short int InitialIP; + unsigned short int StackParas; + unsigned short int DataParas; + unsigned short int HeapParas; + unsigned short int InitializedData; + unsigned short int CodeCheckSum; + unsigned short int DataCheckSum; + unsigned short int CodeVersion; + unsigned short int Priority; + ADDFILE Add[MaxAddFiles]; + unsigned short int DylCount; + unsigned long int DylTableOffset; + unsigned short int Spare; + } ImgHeader; +typedef struct + { + unsigned char Signature[SignatureSize]; + unsigned short int DeviceVersion; + unsigned short int HeaderSizeBytes; + unsigned short int CodeParas; + unsigned short int CodeCheckSum; + unsigned short int CodeVersion; + } DevHeader; +#define ALawSignature "ALawSoundFile**" +typedef struct + { + char Signature[SignatureSize]; + unsigned short int Version; + unsigned long int Samples; + unsigned short int SilenceInTicks; + unsigned short int Repeats; + unsigned short int Spare[3]; + } SndFile; +#ifdef __cplusplus +extern "C" { +#endif +typedef void (*_CALL)(void); +#pragma save,call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_attachfile(char *); +extern int p_detachfile(char *); +#pragma call(reg_param =>(cx,ax),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +extern int p_dayinm(int,int); +#pragma call(reg_param =>(bx,dx),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +extern int p_devdel(const char *,int); +#pragma call(reg_param =>(bx,di,dx,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_devfnd(int,const char *,int,char *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_devqu(const char *); +#pragma restore +extern int cdecl p_exec(const char *); +extern int cdecl p_execasync(const char *,short int *,int *); +extern int cdecl p_execc(const char *,void *,int); +extern int cdecl p_execcasync(const char *,void *,int,short int *,int *); +#pragma save,call(reg_param =>(),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_totalK(void); +extern int p_getauto(void); +extern int p_getautomains(void); +extern int p_getsnd(void); +extern int p_getbat(void); +extern int p_detectsoaktestfixture(void); +extern int p_relogpacks(void); +extern int p_getlanguage(void); +extern int p_getlcd(void); +extern int p_getlcdcontrast(void); +extern int p_getpsu(void); +extern int p_getpid(void); +extern unsigned int p_getbacklight(void); +extern unsigned int p_getram(void); +extern int p_getres(void); +extern int p_getshiftstate(void); +extern int p_getnotify(void); +extern int p_getalarmid(void); +extern void p_allowoff(void); +extern unsigned int p_returntickcount(void); +extern unsigned int p_returnexpansionportinfo(void); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_setbacklight(unsigned int); +extern void p_setconfig(unsigned int); +extern unsigned int p_setirpowerlevel(unsigned int); +extern unsigned int p_setcapslockmode(int); +#pragma call(reg_param =>(di,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_getosd(void *,void *,unsigned int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_getpri(int); +extern int p_getowner(int); +extern void p_getscancodes(unsigned short int *); +#pragma call(reg_param =>(bx,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_getpthbyid(int,char *); +extern int p_getpthbyidasync(int,char *,short int *); +extern int p_locdevice(int,unsigned short int *); +extern int p_locdeviceasync(int,unsigned short int *,short int *); +#pragma call(reg_param =>(bx,cx,di,si,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_locreadpdd(int,long int *,void *,unsigned int); +extern int p_locreadpddasync(int,long int *,void *,unsigned int,short int *); +#pragma call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_setautomains(int); +extern void p_setnotify(int); +extern int p_backlight(int); +extern int p_setonevent(int); +extern int p_setbat(int); +extern void p_hwexit(void); +extern void p_lcdcontrastdelta(int); +extern void p_marka(void); +extern void p_mcancel(void); +extern void p_unmarka(void); +extern void p_notifyunhook(void); +extern void p_alarmunhook(void); +extern void p_osdummy(void); +extern unsigned int p_version(void); +extern unsigned int p_romversion(void); +#pragma call(reg_param =>(ax,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_gettext(int,char *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_hgran(int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_iogetkm(E_KEYS *); +extern void p_iogetkmasync(E_KEYS *); +extern int p_iosignalbypid(int); +#pragma call(reg_param =>(bx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_loadldd(const char *); +extern int p_loadlddasync(const char *,short int *); +extern int p_loadpdd(const char *); +extern int p_loadpddasync(const char *,short int *); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_logon(int,int); +extern int p_logoff(int,int); +extern int p_logoffx(int,int); +#pragma call(reg_param =>(bx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_logona(int,short int *); +extern int p_logoffa(int); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_mfree(void *,int); +#pragma call(reg_param =>(bx,ax),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern int p_minit(int,int); +#pragma call(reg_param =>(di,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_mreceive(short int *,void *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_mreceivew(void *); +#pragma call(reg_param =>(bx,cx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_msend(int,unsigned int,void *); +extern int p_msendreceivew(int,unsigned int,void *); +extern int p_msendreceivea(int,unsigned int,void *,short int *); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_notify(const char *,const char *,const char *,const char *,const char *); +#pragma call(reg_param =>(ax,bx,dx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_notifyerr(int,const char *,const char *,const char *,const char *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_notifyhook(int); +extern int p_alarmhook(int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_onterminate(int); +#pragma call(reg_param =>(cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_off(unsigned int); +#pragma call(reg_param =>(bx,di,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pcpyto(int,void *,void *,unsigned int); +#pragma call(reg_param =>(bx,si,di,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pcpyfr(int,void *,void *,unsigned int); +extern int p_piscpyfr(int,void *,char *,unsigned int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pcreate(E_CPB *); +extern int p_locchg(int mask); +#pragma call(reg_param =>(bx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pfind(int,const char *,char *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pidfind(const char *); +#pragma call(reg_param =>(bx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pkill(int,int); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pterminate(int,int); +#pragma call(reg_param =>(bx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_prename(int,const char *); +#pragma call(reg_param =>(bx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_pname(int,char *); +#pragma call(reg_param =>(bx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_ppanic(int,int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_presume(int); +extern int p_psuspend(int); +#pragma call(reg_param =>(bx,cx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_ptask(char *,int,_CALL,void *); +#pragma call(reg_param =>(dx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_sdate(unsigned long int); +#pragma call(reg_param =>(bx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_setauto(int); +extern void p_setsnd(int); +extern int p_setdefaultpath(const char *); +#pragma call(reg_param =>(bx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_setpri(int,int); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_signaln(int,int); +extern void p_signalnr(int); +#pragma call(reg_param =>(dx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sleept(long int); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_supply(E_SUPPLY *); +extern void p_supplyinfo(E_SUPPLY_INFO *); +extern void p_wsupply(E_SUPPLY_WARNINGS *); +#pragma call(reg_param =>(bx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_wait(int); +extern int p_watchall(unsigned int); +#pragma call(reg_param =>(si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_setpass(char *,char *); +#pragma call(reg_param =>(si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_testpass(char *); +#pragma call(reg_param =>(si,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_controlpass(char *,int); +#pragma call(reg_param =>(),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_querypass(void); +extern void p_tickle(void); +extern void p_nexthalfsecond(void); +#pragma call(reg_param =>(),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE),inline =>on) +static int p_iostatkm(void) = {0xcd,0xda}; +static int p_nexthalfsecondstatus(void) = {0xcd,0xdd}; +#pragma call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE),inline =>on) +static unsigned int p_setrombank(unsigned int) = {0xcd,0xdf}; +static unsigned int p_getrombank(void) = {0xcd,0xe0}; +#pragma restore +#pragma save,call(reg_param =>(bx,cx,dx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_playsounda(const char *,unsigned int,unsigned int,short int *); +extern int p_playsoundw(const char *,unsigned int,unsigned int); +extern void p_playsoundcancel(void); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_playsoundao(const char *,unsigned int,unsigned int,short int *,unsigned int); +extern int p_playsoundwo(const char *,unsigned int,unsigned int,unsigned int); +#pragma call(reg_param =>(bx,cx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_recordsounda(const char *,unsigned int,short int *); +extern int p_recordsoundw(const char *,unsigned int); +extern void p_recordsoundcancel(void); +#pragma call(reg_param =>(bx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_nmdaya(char *,int); +extern void p_nmmona(char *,int); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // EPOC_H diff --git a/code/SIBOSDK/include/epocdefs.h b/code/SIBOSDK/include/epocdefs.h new file mode 100644 index 0000000..4261fff --- /dev/null +++ b/code/SIBOSDK/include/epocdefs.h @@ -0,0 +1,326 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* string.h - Definitions for string and memory functions. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef EPOCDEFS_H +#define EPOCDEFS_H + +#ifndef _TIME_DEF +#define _TIME_DEF +typedef long time_t; +#endif + +typedef int INT,HANDLE; +typedef unsigned int UINT; +typedef signed char BYTE; +typedef unsigned char UBYTE; +typedef short int WORD; +typedef unsigned short int UWORD; +typedef long int LONG; +typedef unsigned long int ULONG; +typedef double DOUBLE; +typedef float FLOAT; +typedef char TEXT; + +typedef struct _mblock + { + unsigned int mlen; + struct _mblock *mnext; + } _MBLOCK; + +#define P_FOPEN 0x0000 +#define P_FCREATE 0x0001 +#define P_FREPLACE 0x0002 +#define P_FAPPEND 0x0003 +#define P_FUNIQUE 0x0004 +#define P_FSER_MASK 0x000f +#define P_FSTREAM 0x0000 +#define P_FSTREAM_TEXT 0x0010 +#define P_FTEXT 0x0020 +#define P_FDIR 0x0030 +#define P_FFORMAT 0x0040 +#define P_FDEVICE 0x0050 +#define P_FNODE 0x0060 +#define P_FMT_MASK 0x00f0 +#define P_FUPDATE 0x0100 +#define P_FRANDOM 0x0200 +#define P_FSHARE 0x0400 +#define P_FACC_MASK 0x0f00 +#define P_FLOWDENSITY 0x1000 + +#define P_FPANIC 0 +#define P_FREAD 1 +#define P_FWRITE 2 +#define P_FCLOSE 3 +#define P_FCANCEL 4 +#define P_FATTACH 5 +#define P_FDETACH 6 +#define P_FSET 7 +#define P_FSENSE 8 +#define P_FFLUSH 9 +#define P_FRELATIVE P_FREAD +#define P_FABSOLUTE P_FWRITE +#define P_FSEEK 10 +#define P_FSETEOF 11 +#define P_FWRITE_REPLY 12 +#define P_FTEST 10 +#define P_FCTRL 11 +#define P_FINQ 12 +#define P_FRSUPER 13 +#define P_FSTOP 14 +#define P_FSTART 15 +#define P_FENABLE 16 +#define P_FSETINT 17 +#define P_FABS 1 +#define P_FEND 2 +#define P_FCUR 3 +#define P_FRSENSE 4 +#define P_FRSET 5 +#define P_FREWIND 6 + +#define NoErr 0 +#define FailErr (-1) +#define ArgumentErr (-2) +#define OsErr (-3) +#define NotSupportedErr (-4) +#define UnderflowErr (-5) +#define OverflowErr (-6) +#define RangeErr (-7) +#define DivideByZeroErr (-8) +#define InUseErr (-9) +#define NoMemoryErr (-10) +#define NoSegmentsErr (-11) +#define NoSemaphoreErr (-12) +#define NoProcessErr (-13) +#define AlreadyOpenErr (-14) +#define NotOpenErr (-15) +#define ImageErr (-16) +#define NoReceiverErr (-17) +#define NoDevicesErr (-18) +#define NoFileSystemErr (-19) +#define FailedToStartErr (-20) +#define ExistsErr (-32) +#define NotExistsErr (-33) +#define WriteErr (-34) +#define ReadErr (-35) +#define EofErr (-36) +#define FullErr (-37) +#define NameErr (-38) +#define AccessErr (-39) +#define LockedErr (-40) +#define DeviceErr (-41) +#define DirErr (-42) +#define RecordErr (-43) +#define ReadOnlyErr (-44) +#define IoInvalidErr (-45) +#define PendingErr (-46) +#define VolumeErr (-47) +#define CancelErr (-48) +#define IoAllocErr (-10) +#define DisconnectErr (-50) +#define ConnectErr (-51) +#define ReTransmitErr (-52) +#define LineErr (-53) +#define InActivityErr (-54) +#define ParityErr (-55) +#define FrameErr (-56) +#define OverrunErr (-57) +#define ModemConnectErr (-58) +#define ModemBusyErr (-59) +#define ModemNoAnswerErr (-60) +#define ModemBlacklistErr (-61) +#define NotReadyErr (-62) +#define UnknownErr (-63) +#define DirFullErr (-64) +#define WriteProtectErr (-65) +#define CorruptMediaErr (-66) +#define AbortErr (-67) +#define EraseErr (-68) +#define InvalidFileErr (-69) + +#define P_CD_ROOT 0 +#define P_CD_PARENT 1 +#define P_CD_SUBDIR 2 + +#define P_FAWRITE 0x01 +#define P_FAHIDDEN 0x02 +#define P_FASYSTEM 0x04 +#define P_FAVOLUME 0x08 +#define P_FADIR 0x10 +#define P_FAMOD 0x20 +#define P_FAREAD 0x100 +#define P_FAEXEC 0x200 +#define P_FASTREAM 0x400 +#define P_FATEXT 0x800 + +typedef struct + { + UWORD version; + UWORD status; + ULONG size; + ULONG modst; + UBYTE spare[4]; + } P_INFO; + +#define P_VOLUMENAME 32 +#define P_FMEDIA_UNKNOWN 0 +#define P_FMEDIA_FLOPPY 1 +#define P_FMEDIA_HARDDISK 2 +#define P_FMEDIA_FLASH 3 +#define P_FMEDIA_RAM 4 +#define P_FMEDIA_ROM 5 +#define P_FMEDIA_WRITEPROTECTED 6 +#define P_FMEDIA_COMPRESSIBLE 0x8000 +#define P_FMEDIA_DYNAMIC 0x4000 +#define P_FMEDIA_INTERNAL 0x2000 +#define P_FMEDIA_DUAL_DENSITY 0x1000 +#define P_FMEDIA_FORMATTABLE 0x800 + +typedef struct { + UWORD version; + UWORD mediatype; + UWORD removable; + ULONG size; + ULONG free; + UBYTE name[P_VOLUMENAME]; + WORD batterystate; + UBYTE spare[16]; + } P_DINFO; + +#define P_FSYSTYPE_FLAT 0 +#define P_FSYSTYPE_HIER 1 +typedef struct { + UWORD version; + UWORD type; + UWORD formattable; + UBYTE spare[26]; + } P_NINFO; + +#define P_PWILD_ANY 0x01 +#define P_PWILD_NAME 0x02 +#define P_PWILD_EXT 0x04 +#define P_FSYSNAMESIZE 5 + +typedef struct { + UBYTE system; + UBYTE device; + UBYTE path; + UBYTE name; + UBYTE ext; + UBYTE flags; + } P_FPARSE; + +#define P_FBLKSHIFT 9 +#define P_FBLKSIZE 0x200 +#define P_FMAXRSIZE 0x100 +#define P_FMAXSSIZE 0x4000 +#define P_FSIZRPOS sizeof(LONG) +#define P_MAXDEV 128 +#define P_MAXPATH 128 +#define P_MAXNAME 128 +#define P_MAXEXTN 128 +#define P_FNAMESIZE 128 + +typedef struct + { + ULONG day; + ULONG sec; + } P_DAYSEC; + +typedef struct + { + UBYTE year; + UBYTE month; + UBYTE day; + UBYTE hour; + UBYTE minute; + UBYTE second; + UWORD yrday; + } P_DATE; + +#define P_SCR_ATTRB 0 +#define P_SCR_SCROLL 1 +#define P_SCR_CLR 2 +#define P_SCR_POSA 3 +#define P_SCR_POSR 4 +#define P_SCR_WSET 5 +#define P_SCR_SLOCK 6 +#define P_SCR_WLOCK 7 +#define P_SCR_NEL 8 +#define P_SCR_CURSOR 9 +#define P_SCR_ESCAPE 10 + +typedef struct + { + short int x; /* Horizontal coordinate */ + short int y; /* Vertical coordinate */ + } P_POINT; +typedef struct + { + P_POINT tl; /* Top left point */ + P_POINT br; /* Bottom right point */ + } P_RECT; +typedef struct + { + P_RECT r; /* Rectangle */ + P_POINT p; /* Point */ + } P_RECTP; +typedef struct + { + P_POINT tl; /* Top left point */ + unsigned short int width; /* Width */ + unsigned short int height; /* Height */ + } P_EXTENT; + +#define _E_SEARCH 0x10 +#define _E_EXEC 0x20 + +extern char _pname[P_FNAMESIZE]; +extern P_FPARSE _pinfo; +extern void *winHandle; + +#ifdef __cplusplus +extern "C" { +#endif +extern int _allocInfo(_MBLOCK **,_MBLOCK **); +extern _MBLOCK *_heapTop(void); +extern int _iopen(char **_handle,char *_name,int _mode); +extern int _iow2(char *handle,int _func); +extern int _iow3(char *handle,int _func,void *); +extern int _iow4(char *handle,int _func,void *,void *); +extern int _parse(const char *_in,char *_rel,char *_out,P_FPARSE *_info); +extern void _convTimeToDos(ULONG t,int *date,int *time); +extern void _FsChanToName(void *handle,char *name); +extern int _FsChanToMode(void *handle); +extern int _isloc(const char *path); +extern void _systemTimeToDaySeconds(time_t secs,P_DAYSEC *pDs); +extern time_t _daySecondsToSystemTime(P_DAYSEC *pDs); +extern void _daySecondsToDate(P_DAYSEC *pDs,P_DATE *pDate); +extern int _dateToDaySeconds(P_DATE *pDate,P_DAYSEC *pDs); +extern int _fileInfo(const char *path,P_INFO *pI); +extern int _fileSetModTime(const char *path,time_t time); +extern void _getPath(char *path); +extern void _setPath(char *path); +extern time_t _date(void); +extern void _sleepTenths(unsigned long tenths); +extern int _execc(const char *path,char **argv,int mode); +extern int __execc(char *path,char *command); +extern int _logon(int handle,WORD *stat); +extern void _waitStat(WORD *stat); +extern int _resume(int pid); +extern char *_getErrorText(int error,char *buffer); +#pragma save,call(inline=>on) +static void _dummy(void) = {0xCD,0xD4}; +#pragma restore +#ifdef __cplusplus +} +#endif +#endif + diff --git a/code/SIBOSDK/include/epocdefs.inc b/code/SIBOSDK/include/epocdefs.inc new file mode 100644 index 0000000..277c969 --- /dev/null +++ b/code/SIBOSDK/include/epocdefs.inc @@ -0,0 +1,867 @@ +OldPsu = 0 +MaximPsu = 1 +PanPsu = 2 +BatteryUnknown = 0 +BatteryAlkaline = 1 +BatteryNicad600 = 2 +BatteryNicad1000 = 3 +BatteryNicad500 = 4 +LcdUnknown = -1 +Lcd640X400 = 0 +Lcd640X200Small = 1 +Lcd640X200Big = 2 +Lcd720X348 = 3 +Lcd160X80 = 4 +Lcd240X80 = 5 +PcHerc = Lcd720X348 +PcCga = Lcd640X200Big +PcMda = 6 +PcEgaMono = 7 +PcEgaColour = 8 +PcVgaMono = 9 +PcVgaColour = 10 +Lcd480X160 = 11 +Lcd240X100 = 12 +Lcd240X120 = 13 +Lcd240X160 = 14 +Lcd640X200 = 15 +IsAColdStart = 0 +IsAPowerFailStart = 1 +IsAResetStart = 2 +IsAKernelFault = 3 +IsANewOsStart = 4 + +HwInt0Revector = 0 +HwInt1Revector = 1 +HwInt2Revector = 2 +HwInt3Revector = 3 +HwInt4Revector = 4 +HwIrq0Revector = 5 +HwIrq1Revector = 6 +HwIrq2Revector = 7 +HwIrq3Revector = 8 +HwIrq4Revector = 9 +HwIrq5Revector = 10 +HwIrq6Revector = 11 +HwIrq7Revector = 12 +FileSystemNameSize = 5 +MaxDeviceSize = 8 +MaxNameSize = 8 +MaxExtSize = 4 +MaxNameESize = (MaxNameSize+MaxExtSize) +MaxPathSize = 080H +DeviceSeparator = ':' +ExtSeparator = '.' +MatchAny = '*' +MatchSingle = '?' +MaxErrorTextSize = 64 +MaxNotifyTextSize = 64 +MaxOptionTextSize = 16 +MaxSuffixes = 31 +MaxCommandBuffer = 127 +PidMask = 0FFFH +MaxEnvNameSize = 16 +MaxAlarms = 2 + +SoundKeyboardEnable = 00001H +SoundBuzzerEnable = 00002H +SoundDeviceEnable = 00004H +SoundLoud = 00008H +SoundDisable = 08000H +SoundMaxVolume = 0 +SoundMinVolume = 5 +SoundMaxBpm = 240 +SoundMinBpm = 2 + +CPBInRom = 0 +CPBInRam = 1 +CPBMaxPriority = 0C0H +CPBMinPriority = 040H +MaxHeapGrowBy = 0400H +HeapGrowByDefault = 080H +MaxProcesses = 018H + +CreateSegmentLow = 0 +CreateSegmentHigh = 1 +CreateSegmentDevice = 2 +CreateSegmentLocked = 3 + +IoFuncPanic = 000H +IoFuncRead = 001H +TimerRelative = 001H +IoFuncWrite = 002H +TimerAbsolute = 002H +IoFuncClose = 003H +IoFuncCancel = 004H +IoFuncAttach = 005H +IoFuncDetach = 006H +IoFuncSet = 007H +IoFuncSense = 008H +IoFuncFlush = 009H +IoFuncAlarm = 009H +IoFuncSeek = 00AH +IoFuncSetEof = 00BH +IoFuncConnect = 00AH +IoFuncDisconnect = 00BH +IoFuncWriteReply = 00CH +IoFuncTest = 00AH +IoFuncControl = 00BH +IoFuncInquire = 00CH +IoFuncSuperFrame = 00DH +IoFuncStop = 00EH +IoFuncStart = 00FH +IoFuncEnable = 010H +IoFuncSetDevice = 011H +IoFuncModemInit = 010H +IoFuncModemDial = 011H +IoFuncModemWaitCall = 012H +IoFuncModemSense = 013H +IoFuncModemSet = 014H +IoFuncModemCancel = 015H +IoFuncModemWrite = 016H + +ModeOpen = 00000H +ModeCreate = 00001H +ModeReplace = 00002H +ModeAppend = 00003H +ModeUnique = 00004H +ModeStream = 00000H +ModeStreamText = 00010H +ModeText = 00020H +ModeDir = 00030H +ModeFormat = 00040H +ModeDevice = 00050H +ModeNode = 00060H +ModeUpdate = 00100H +ModeRandom = 00200H +ModeShare = 00400H +ModeLowDensity = 01000H +ModeServiceMask = 0000FH +ModeFormatMask = 000F0H +ModeAccessMask = 00F00H + +SeekAddress = 00H +SeekFromStart = 01H +SeekFromEnd = 02H +SeekFromCurrent = 03H +SeekRecordSense = 04H +SeekRecordSet = 05H +SeekRewind = 06H + +FileAttWrite = 00001H +FileAttHidden = 00002H +FileAttSystem = 00004H +FileAttVolume = 00008H +FileAttDirectory = 00010H +FileAttModified = 00020H +FileAttRead = 00100H +FileAttExecute = 00200H +FileAttStream = 00400H +FileAttText = 00800H + +FileChangeDirRoot = 0 +FileChangeDirParent = 1 +FileChangeDirSubdir = 2 + +MaxVolumeName = 32 +FileMediaUnknown = 0 +FileMediaFloppy = 1 +FileMediaHardDisk = 2 +FileMediaFlash = 3 +FileMediaRam = 4 +FileMediaRom = 5 +FileMediaWriteProtected = 6 +FileMediaCompressible = 08000H +FileMediaDynamic = 04000H +FileMediaInternal = 02000H +FileMediaDualDensity = 01000H +FileMediaFormattable = 00800H + +FileNodeFlat = 0 +FileNodeHierarchical = 1 + +FileBlockShift = 9 +FileBlockSize = 00200H +FileMaxRecordSize = 00100H +FileMaxStreamSize = 04000H + +JustifyLeft = 0 +JustifyRight = 1 +JustifyCentre = 2 + +ParseWildAny = 00001H +ParseWildName = 00002H +ParseWildExt = 00004H + +DtobTypeFixed = 00H +DtobTypeExponent = 01H +DtobTypeGeneral = 02H +DtobMaxExponent = 99 +FloatSignificantDigits = 15 + +IoChanSignature = 01101H +IoHandlerSignature = 01121H +DbfChanSignature = 01141H +LIBChanSignature = 01161H +LDDSignature = 0DD01H +PDDSignature = 0DD21H +LIBSignature = 0DD41H +VectorInfoSize = 8 + +KillExit = 0 +PanicExit = 1 +TaskPanicExit = 2 + +PointX = 0 +PointY = 2 +PointEnt = 4 +RectTl = 0 +RectBr = 4 +RectEnt = 8 + +NoErr = 0 +FailErr = -1 +ArgumentErr = -2 +OsErr = -3 +NotSupportedErr = -4 +UnderflowErr = -5 +OverflowErr = -6 +RangeErr = -7 +DivideByZeroErr = -8 +InUseErr = -9 +NoMemoryErr = -10 +IoAllocErr = -10 +NoSegmentsErr = -11 +NoSemaphoreErr = -12 +NoProcessErr = -13 +AlreadyOpenErr = -14 +NotOpenErr = -15 +ImageErr = -16 +NoReceiverErr = -17 +NoDevicesErr = -18 +NoFileSystemErr = -19 +FailedToStartErr = -20 +FontNotLoadedErr = -21 + +ExistsErr = -32 +NotExistsErr = -33 +WriteErr = -34 +ReadErr = -35 +EofErr = -36 +FullErr = -37 +NameErr = -38 +AccessErr = -39 +LockedErr = -40 +DeviceErr = -41 +DirErr = -42 +RecordErr = -43 +ReadOnlyErr = -44 +IoInvalidErr = -45 +PendingErr = -46 +VolumeErr = -47 +CancelErr = -48 +ReservedErr = -49 +DisconnectErr = -50 +ConnectErr = -51 +ReTransmitErr = -52 +LineErr = -53 +InActivityErr = -54 +ParityErr = -55 +FrameErr = -56 +OverrunErr = -57 +ModemConnectErr = -58 +ModemBusyErr = -59 +ModemNoAnswerErr = -60 +ModemBlacklistErr = -61 +NotReadyErr = -62 +UnknownErr = -63 +DirFullErr = -64 +WriteProtectErr = -65 +CorruptMediaErr = -66 +AbortErr = -67 +EraseErr = -68 +InvalidFileErr = -69 + +CDataCountryCode = 000H +CDataGmtOffset = 002H +CDataDateType = 004H +CDataTimeType = 005H +CDataCurrencySymbolPosition = 006H +CDataCurrencySpaceRequired = 007H +CDataCurrencyDecimalPlaces = 008H +CDataCurrencyNegativeInBrackets = 009H +CDataCurrencyTriadsAllowed = 00AH +CDataThousandsSeparator = 00BH +CDataDecimalSeparator = 00CH +CDataDateSeparator = 00DH +CDataTimeSeparator = 00EH +CDataCurrencySymbol = 00FH +CDataStartOfWeek = 018H +CDataSpare = 019H +CDataEnt = 028H +DateYear = 000H +DateMonth = 001H +DateDay = 002H +DateHour = 003H +DateMinute = 004H +DateSecond = 005H +DateYearDay = 006H +DateEnt = 008H +DeviceVersionNo = 000H +DeviceMediaType = 002H +DeviceIsRemovable = 004H +DeviceStatusSize = 006H +DeviceStatusFree = 00AH +DeviceStatusName = 00EH +DeviceBatteryState = 02EH +DeviceSpare = 030H +DeviceEnt = 040H +DtobType = 000H +DtobWidth = 001H +DtobNdec = 002H +DtobPoint = 003H +DtobTriad = 004H +DtobTrilen = 005H +DtobEnt = 006H +DyScDays = 000H +DyScSeconds = 004H +DyScEnt = 008H +FileVersionNo = 000H +FileAtt = 002H +FileSize = 004H +FileModDate = 008H +FileSpare = 00CH +FileEnt = 010H +FullParseSystem = 000H +FullParseDevice = 001H +FullParsePath = 002H +FullParseName = 003H +FullParseExt = 004H +FullParseFlags = 005H +FullParseEnt = 006H +GenParseSourceNamePtr = 000H +GenParseRelatedNamePtr = 002H +GenParseDefaultsPtr = 004H +GenParseTargetNamePtr = 006H +GenParseInfoPtr = 008H +GenParseDeviceSeparator = 00AH +GenParsePathSeparator = 00BH +GenParseExtSeparator = 00CH +GenParseMaxDeviceSize = 00DH +GenParseMaxPathSize = 00EH +GenParseMaxNameSize = 00FH +GenParseMaxExtSize = 010H +GenParseDummy = 011H +GenParseEnt = 012H +MemLength = 000H +MemNext = 002H +MemEnt = 004H +MessNext = 000H +MessStatusPtr = 002H +MessType = 004H +MessPid = 006H +MessEnt = 008H +NodeVersionNo = 000H +NodeType = 002H +NodeSupportsFormat = 004H +NodeStatusSpare = 006H +NodeEnt = 020H +ProcQue = 000H +ProcDeltaType = 008H +ProcAddressTrap = 009H +ProcStatus = 00AH +ProcSStatus = 00BH +ProcPriority = 00CH +ProcPriorityH = 00DH +ProcRamOrRom = 00EH +ProcTask = 00FH +ProcName = 010H +ProcActive = 01DH +ProcSemaphore = 01EH +ProcSemHead = 020H +ProcMemBasePtr = 022H +ProcMemGrowBy = 024H +ProcMCtrlPtr = 026H +ProcMinHeap = 028H +ProcFServer = 02AH +ProcDataSeg = 02CH +ProcCodeSeg = 02EH +ProcSavedSP = 030H +ProcSavedBP = 032H +ProcNotify = 034H +ProcSpare = 035H +ProcMagicNumber = 036H +ProcChecksum = 038H +ProcMTerminate = 03AH +ProcEnt = 03CH +QueNext = 000H +QuePrev = 002H +QueKey = 004H +QueData = 006H +QueEnt = 008H +SegBase = 000H +SegAccessCount = 002H +SegName = 004H +SegEnt = 012H +ConKeyValue = 000H +ConModifiers = 002H +ConCount = 003H +ConEnt = 004H +FsyFileQ = 000H +FsyFileSystem = 004H +FsyFileName = 006H +FsyFileMode = 008H +ChanSignature = 000H +ChanNext = 002H +ChanLibHandle = 004H +ChanEnt = 006H +FilChan = 000H +FilHandle = ChanEnt + +BufferCompare = 0A3H +BufferCompareFolded = 0A4H +BufferCopy = 0A1H +BufferJustify = 0ABH +BufferLocate = 0A7H +BufferLocateFolded = 0A8H +BufferMatch = 0A5H +BufferMatchFolded = 0A6H +BufferSubBuffer = 0A9H +BufferSubBufferFolded = 0AAH +BufferSwap = 0A2H +CharIsAlphaNumeric = 097H +CharIsAlphabetic = 096H +CharIsControl = 09DH +CharIsDigit = 093H +CharIsGraphic = 09CH +CharIsHexDigit = 094H +CharIsLowerCase = 099H +CharIsPrintable = 095H +CharIsPunctuation = 09BH +CharIsSpace = 09AH +CharIsUpperCase = 098H +CharToFoldedChar = 0A0H +CharToLowerChar = 09FH +CharToUpperChar = 09EH +ConvManager = 08AH +DbfManager = 0D8H +DevManager = 085H +WservOpcodes = 08DH +Dummy = 0D4H +FilManager = 087H +FloatAdd = 0C1H +FloatCompare = 0C5H +FloatDivide = 0C4H +FloatManager = 08CH +FloatMultiply = 0C3H +FloatNegate = 0C6H +FloatSubtract = 0C2H +FloatToInt = 0C7H +FloatToLong = 0C9H +FloatToUnsignedInt = 0C8H +FloatToUnsignedLong = 0CAH +GenDataSegment = 08FH +GenIntByNumber = 0D5H +GenManager = 08BH +HardwareManager = 08EH +HeapManager = 081H +IntToFloat = 0CBH +IoManager = 086H +IoNextHalfSecondStatus = 0DDH +IoSerManager = 0DEH +LibEnter = 0D2H +LibEnterSend = 0D9H +LibLeave = 0D3H +LibManager = 084H +LibSend = 0CFH +LibSendExact = 0D1H +LibSendExit = 0D7H +LibSendSuper = 0D0H +LongIntCompare = 0BBH +LongIntDivide = 0BDH +LongIntMultiply = 0BCH +LongToFloat = 0CDH +LongUnsignedIntCompare = 0BEH +LongUnsignedIntDivide = 0C0H +LongUnsignedIntMultiply = 0BFH +MessManager = 083H +ProcCopyFromById = 091H +ProcCopyToById = 092H +ProcIndStringCopyFromById = 0DCH +ProcManager = 088H +ProcPanic = 090H +SegManager = 080H +SemManager = 082H +StringCapitilise = 0DBH +StringCompare = 0AFH +StringCompareFolded = 0B0H +StringConvertToFolded = 0AEH +StringCopy = 0ACH +StringCopyFolded = 0ADH +StringLength = 0B9H +StringLocate = 0B3H +StringLocateFolded = 0B4H +StringLocateInReverse = 0B5H +StringLocateInReverseFolded = 0B6H +StringMatch = 0B1H +StringMatchFolded = 0B2H +StringSubString = 0B7H +StringSubStringFolded = 0B8H +StringValidateName = 0BAH +TimManager = 089H +UnsignedIntToFloat = 0CCH +UnsignedLongToFloat = 0CEH +WservFunctions = 0D6H +WservOpcodes = 08DH +NmConvArgumentsToBuffer = 004H +NmConvFloatToBuffer = 009H +NmConvIntToBuffer = 002H +NmConvLongIntToBuffer = 003H +NmConvStringToFloat = 00AH +NmConvStringToInt = 007H +NmConvStringToLongInt = 008H +NmConvStringToUnsignedInt = 005H +NmConvStringToUnsignedLongInt = 006H +NmConvUnsignedIntToBuffer = 000H +NmConvUnsignedLongIntToBuffer = 001H +NmDbfAbsRead = 00CH +NmDbfAbsReadSense = 00BH +NmDbfAppend = 011H +NmDbfBackRead = 00EH +NmDbfClose = 001H +NmDbfCompress = 005H +NmDbfCopyDown = 004H +NmDbfCopyFile = 006H +NmDbfCount = 016H +NmDbfDescRecordRead = 017H +NmDbfDescRecordWrite = 018H +NmDbfEraseRead = 012H +NmDbfExtHeaderRead = 008H +NmDbfExtHeaderWrite = 009H +NmDbfFileSize = 007H +NmDbfFindRead = 014H +NmDbfFirstRead = 00FH +NmDbfFlush = 002H +NmDbfLastRead = 010H +NmDbfNextRead = 00DH +NmDbfOpen = 000H +NmDbfSense = 015H +NmDbfTrash = 003H +NmDbfUpdate = 013H +NmDbfVersion = 00AH +NmDevDelete = 008H +NmDevFind = 00AH +NmDevGetPDDAddress = 002H +NmDevHold = 004H +NmDevInstall = 003H +NmDevLoadLDD = 006H +NmDevLoadPDD = 007H +NmDevOpenPDD = 001H +NmDevQueryUnits = 009H +NmDevRemove = 00BH +NmDevResume = 005H +NmDevVector = 00CH +NmFilChangeDirectory = 011H +NmFilConnect = 000H +NmFilDelete = 006H +NmFilExecute = 001H +NmFilLocChanged = 014H +NmFilLocDevice = 015H +NmFilLocReadPdd = 016H +NmFilMakeDirectory = 00CH +NmFilOpenUnique = 00DH +NmFilParse = 002H +NmFilPathGet = 003H +NmFilPathGetById = 010H +NmFilPathSet = 004H +NmFilPathTest = 005H +NmFilRename = 007H +NmFilSetFileDate = 013H +NmFilSetInitialPath = 012H +NmFilStatusDevice = 00AH +NmFilStatusGet = 008H +NmFilStatusSet = 009H +NmFilStatusSystem = 00BH +NmFilSystemAttach = 00EH +NmFilSystemDetach = 00FH +NmFloatACos = 004H +NmFloatASin = 003H +NmFloatATan = 005H +NmFloatCos = 001H +NmFloatExp = 006H +NmFloatInt = 00DH +NmFloatLn = 007H +NmFloatLog = 008H +NmFloatMod = 00CH +NmFloatPow = 00AH +NmFloatRand = 00BH +NmFloatSin = 000H +NmFloatSqrt = 009H +NmFloatTan = 002H + +NmGenVersion = 000H +NmGenLcdType = 001H +NmGenStartReason = 002H +NmGenParse = 003H +NmGenGetCountryData = 005H +NmGenGetErrorText = 006H +NmGenGetOsData = 007H +NmGenDeferredMode = 008H +NmGenNotify = 009H +NmGenNotifyError = 00AH +NmGenNotifyHook = 00BH +NmGenNotifyUnHook = 00CH +NmGenGetRamSizeInParas = 00DH +NmGenGetCommandLine = 00EH +NmGenGetSoundFlags = 00FH +NmGenSetSoundFlags = 010H +NmGenSound = 011H +NmGenMarkActive = 012H +NmGenMarkNonActive = 013H +NmGenGetText = 014H +NmGenGetNotifyState = 015H +NmGenSetNotifyState = 016H +NmGenGetAutoSwitchOffValue = 017H +NmGenSetAutoSwitchOffValue = 018H +NmGenSetRevector = 019H +NmGenResetRevector = 01AH +NmGenGetLanguageCode = 01BH +NmGenGetSuffixes = 01CH +NmGenGetAmPmText = 01DH +NmGenSetCountryData = 01EH +NmGenGetBatteryType = 01FH +NmGenSetBatteryType = 020H +NmGenEnvBufferGet = 021H +NmGenEnvBufferSet = 022H +NmGenEnvBufferDelete = 023H +NmGenEnvBufferFind = 024H +NmGenEnvStringGet = 025H +NmGenEnvStringSet = 026H +NmGenEnvStringDelete = 027H +NmGenEnvStringFind = 028H +NmGenCrc = 029H +NmGenRomVersion = 02AH +NmGenMaskInit = 034H +NmGenMaskEncrypt = 035H +NmGenMaskDecrypt = 036H +NmGenSetOnEvents = 037H +NmGenSetCapsLockMode = 03CH + +NmHeapAllocateCell = 000H +NmHeapReAllocateCell = 001H +NmHeapAdjustCellSize = 002H +NmHeapFreeCell = 003H +NmHeapCellSize = 004H +NmHeapSetGranularity = 005H +NmHeapFreeMemory = 006H + +NmHwComboOn = 000H +NmHwComboOff = 001H +NmHwPacksOn = 002H +NmHwPacksOff = 003H +NmHwSetA2Control1Bits = 004H +NmHwClearA2Control1Bits = 005H +NmHwReadA2Control1 = 006H +NmHwWriteA2Control1 = 007H +NmHwSetA2Control2Bits = 008H +NmHwClearA2Control2Bits = 009H +NmHwReadA2Control2 = 00AH +NmHwWriteA2Control2 = 00BH +NmHwSetA2Control3Bits = 00CH +NmHwClearA2Control3Bits = 00DH +NmHwReadA2Control3 = 00EH +NmHwWriteA2Control3 = 00FH +NmHwSelectChannel = 010H +NmHwGetSupplyStatus = 011H +NmHwLcdContrastDelta = 012H +NmHwReadLcdContrast = 013H +NmHwSwitchOff = 014H +NmHwNullFrame = 015H +NmHwExit = 016H +NmHwGetCombo = 017H +NmHwFreeCombo = 018H +NmHwGetChannel = 019H +NmHwFreeChannel = 01AH +NmHwGetPsuType = 01BH +NmHwSupplyWarnings = 01CH +NmHwForceSupplyReading = 01DH +NmHwGetBackLight = 01EH +NmHwSetBackLight = 01FH +NmHwBackLight = 020H +NmHwComboOnInput = 021H +NmHwSupplyInfo = 022H +NmHwScreenSeg = 023H +NmHwGetScreenMode = 024H +NmHwSetScreenMode = 025H +NmHwSetPCurrent = 026H +NmHwSetFCurrent = 027H +NmHwGetScanCodes = 028H +NmHwHwGetSsdData = 029H +NmHwResetBatteryStatus = 02AH +NmHwEnableAutoBatReset = 02BH +NmHwGetBatData = 02CH +NmHwDetectSoakTestFixture = 02DH +NmHwReLogPacks = 02EH +NmHwSetIRPowerLevel = 02FH +NmHwReturnTickCount = 030H +NmHwReturnExpansionPortState = 031H +NmHwExpansionOn = 032H +NmHwExpansionOff = 033H + +NmIoOpen = 000H +NmIoAsynchronous = 000H +NmIoAsynchronousNoError = 001H +NmIoWithWait = 002H +NmIoRoot = 003H +NmIoSuper = 004H +NmIoWaitForSignal = 005H +NmIoWaitForStatus = 006H +NmIoYield = 007H +NmIoSignal = 008H +NmIoSignalByPid = 009H +NmIoSignalByPidNoReSched = 00AH +NmIoAddHandler = 00BH +NmIoRemoveHandler = 00CH +NmIoEnableHandler = 00DH +NmIoRequestReset = 00EH +NmIoRequestResetCancel = 00FH +NmIoClose = 010H +NmIoRead = 011H +NmIoWrite = 012H +NmIoSeek = 013H +NmIoKeyAndMouseWithWait = 014H +NmIoAddApplicationHandler = 015H +NmIoRemoveApplicationHandler = 016H +NmIoEnableApplicationHandler = 017H +NmIoShiftStates = 018H +NmIoWaitForSignalNoHandler = 019H +NmIoSignalKillAsynchronous = 01AH +NmIoSignalKillCancel = 01BH +NmIoNextHalfSecond = 01DH +NmIoPlaySoundA = 01EH +NmIoPlaySoundW = 01FH +NmIoPlaySoundCancel = 020H +NmIoRecordSoundA = 021H +NmIoRecordSoundW = 022H +NmIoRecordSoundCancel = 023H +NmIoPlaySoundAO = 024H +NmIoPlaySoundWO = 025H + +NmIoSerAddHandler = 001H +NmIoSerAttachOnOpenChan = 00DH +NmIoSerCancelAllSignalUser = 01CH +NmIoSerCancelIoRequest = 01BH +NmIoSerCheckReadSi = 011H +NmIoSerCheckWriteSi = 010H +NmIoSerCloseTimerHandler = 008H +NmIoSerDetachFree = 009H +NmIoSerFree = 007H +NmIoSerHandlerSaveError = 004H +NmIoSerOnOpenChan = 00FH +NmIoSerOpen = 000H +NmIoSerOpenHandler = 005H +NmIoSerOpenTimerHandler = 006H +NmIoSerQueueRead = 017H +NmIoSerQueueSuper = 019H +NmIoSerQueueTimer = 01AH +NmIoSerQueueWrite = 018H +NmIoSerRemoveHandler = 002H +NmIoSerSenseOnOpenChan = 00EH +NmIoSerSetHandler = 003H +NmIoSerSignalComplete = 01EH +NmIoSerSignalCompleteOk = 01DH +NmIoSerSignalUser = 016H +NmIoSerSignalUserRead = 015H +NmIoSerSignalUserReadOk = 014H +NmIoSerSignalUserWrite = 013H +NmIoSerSignalUserWriteOk = 012H +NmIoSerSyncWrite = 01FH +NmIoSerTimerCancel = 00BH +NmIoSerTimerClose = 00CH +NmIoSerTimerOpen = 00AH +NmLibCopy = 008H +NmLibCreate = 005H +NmLibCreateByHandle = 006H +NmLibDestroy = 007H +NmLibFind = 003H +NmLibHandle = 004H +NmLibLink = 002H +NmLibLoad = 000H +NmLibLoadFile = 00AH +NmLibOpen = 009H +NmLibReClass = 00BH +NmLibReClassByHandle = 00CH +NmLibUnLoad = 001H +NmLongUnsignedIntRandom = 004H +NmMessFree = 007H +NmMessInit = 000H +NmMessReceiveAsynchronous = 001H +NmMessReceiveCancel = 003H +NmMessReceiveWithWait = 002H +NmMessSend = 004H +NmMessSendReceiveAsynchronous = 005H +NmMessSendReceiveWithWait = 006H +NmMessSignal = 008H +NmMessSignalCancel = 009H +NmProcCreate = 004H +NmProcCreateTask = 005H +NmProcFind = 00BH +NmProcGetOwner = 010H +NmProcGetPriority = 002H +NmProcId = 000H +NmProcIdByName = 001H +NmProcKill = 008H +NmProcNameById = 00AH +NmProcOnTerminate = 00EH +NmProcPanicById = 009H +NmProcRename = 00CH +NmProcResume = 006H +NmProcSetPriority = 003H +NmProcSuspend = 007H +NmProcTerminate = 00DH +NmProcWatchAllExits = 00FH +NmSegAdjustSize = 006H +NmSegClose = 004H +NmSegCloseLockedOrDevice = 00DH +NmSegCopyFrom = 009H +NmSegCopyTo = 008H +NmSegCreate = 001H +NmSegDelete = 002H +NmSegFind = 007H +NmSegFreeMemory = 000H +NmSegLock = 00AH +NmSegOpen = 003H +NmSegRamDiskUsed = 00CH +NmSegSize = 005H +NmSegUnLock = 00BH +NmSemCreate = 000H +NmSemDelete = 001H +NmSemSignalMany = 004H +NmSemSignalOnce = 003H +NmSemSignalOnceNoReSched = 005H +NmSemWait = 002H +NmTimDateToDaySeconds = 007H +NmTimDayOfWeek = 009H +NmTimDaySecondsToDate = 006H +NmTimDaySecondsToSystemTime = 005H +NmTimDaysInMonth = 008H +NmTimGetSystemTime = 002H +NmTimNameOfDay = 00AH +NmTimNameOfMonth = 00BH +NmTimSetSystemTime = 003H +NmTimSleepForTenths = 000H +NmTimSleepForTicks = 001H +NmTimSystemTimeToDaySeconds = 004H +NmTimWaitAbsolute = 00CH +NmTimWeekNumber = 00DH + +FatalOpenConsole = -1 +FatalMathException = -2 +FatalStackCheck = -3 +FatalSignal = -4 +FatalInitIo = -5 +FatalConIo = -6 + +wserv_spec_info_version = 13 + +Datawserv_channel = 24 diff --git a/code/SIBOSDK/include/errno.h b/code/SIBOSDK/include/errno.h new file mode 100644 index 0000000..08a2db2 --- /dev/null +++ b/code/SIBOSDK/include/errno.h @@ -0,0 +1,108 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* errno.h - defines variable errno and associated error codes. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _ERRNO_INC_ +#define _ERRNO_INC_ + +/* Dos Error Codes */ + +#ifdef OLDERRORS +#define EZERO 0 /* No Error */ +#define EINVFN 1 /* Invalid function code */ +#define ENOENT 2 /* File not found */ +#define ENOPATH 3 /* Path not found */ +#define EMFILE 4 /* Too many open files */ +#define EACCES 5 /* Access denied */ +#define EBADF 6 /* Invalid handle */ +#define E2BIG 7 /* Memory blocks destroyed */ +#define ENOMEM 8 /* Insufficient Memory */ +#define EINVMEM 9 /* Invalid memory block address */ +#define EINVENV 10 /* Invalid environment */ +#define EINVFMT 11 /* Invalid format */ +#define EINVACC 12 /* Invalid access code */ +#define EINVDAT 13 /* Invalid data */ +#define ENODEV 15 /* Invalid drive */ +#define ECURDIR 16 /* Attempt to remove CurDir */ +#define ENOTSAM 17 /* Not same device */ +#define ENMFILE 18 /* No more files */ + +/* RTL error codes */ + +#define EINVAL 19 /* Invalid argument */ +#define ENOTDIR 20 /* Not directory */ +#define EISDIR 21 /* Is directory */ +#define ENOEXEC 22 /* Corrupted exec file */ +#define EMLINK 32 /* Cross-device link */ + +#define EDOM 33 /* Math argument */ +#define ERANGE 34 /* Result too large */ +#define EDEADLOCK 36 /* file locking deadlock */ +#define EEXIST 80 /* File exists MSDOS 3.0 + */ +#define ENOSPC -1 /* UNIX - not in MSDOS */ +#else +#define EZERO 0 /* No Error */ +#define ENOENT (-33) /* File not found */ +#define ENOPATH (-42) /* Path not found */ +#define EMFILE (-18) /* Too many open files */ +#define EACCES (-39) /* Access denied */ +#define EBADF (-15) /* Invalid handle */ +#define E2BIG (-6) /* Memory blocks destroyed */ +#define ENOMEM (-10) /* Insufficient Memory */ +#define ENODEV (-41) /* Invalid drive */ +#define ECURDIR (-9) /* Attempt to remove CurDir */ +#define ENMFILE (-36) /* No more files */ +#define ENOSPC (-37) /* Disk full */ + +/* RTL error codes */ + +#define EINVAL (-2) /* Invalid argument */ +#define ENOEXEC (-16) /* Corrupted exec file */ +#define EMLINK (-66) /* Cross-device link */ + +#define EDOM (-2) /* Math argument */ +#define ERANGE (-7) /* Result too large */ +#define EDEADLOCK (-40) /* file locking deadlock */ +#define EEXIST (-32) /* File exists MSDOS 3.0 + */ + +#define ENOTSAM (-1) /* Not same device */ +#define ENOTDIR (-1) /* Not directory */ +#define EISDIR (-1) /* Is directory */ +#define EINVFN (-1) /* Invalid function code */ +#define EINVMEM (-1) /* Invalid memory block address */ +#define EINVENV (-1) /* Invalid environment */ +#define EINVFMT (-1) /* Invalid format */ +#define EINVACC (-1) /* Invalid access code */ +#define EINVDAT (-1) /* Invalid data */ +#endif + +#define EFAULT (-1) /* Unknown error */ +#define EPERM (-1) /* UNIX - not in MSDOS */ +#define ESRCH (-1) /* UNIX - not in MSDOS */ +#define EINTR (-1) /* UNIX - not in MSDOS */ +#define EIO (-1) /* UNIX - not in MSDOS */ +#define ENXIO (-1) /* UNIX - not in MSDOS */ +#define ECHILD (-1) /* UNIX - not in MSDOS */ +#define EAGAIN (-1) /* UNIX - not in MSDOS */ +#define ENOTBLK (-1) /* UNIX - not in MSDOS */ +#define EBUSY (-1) /* UNIX - not in MSDOS */ +#define ENFILE (-1) /* UNIX - not in MSDOS */ +#define ENOTTY (-1) /* UNIX - not in MSDOS */ +#define ETXTBSY (-1) /* UNIX - not in MSDOS */ +#define EFBIG (-1) /* UNIX - not in MSDOS */ +#define ESPIPE (-1) /* UNIX - not in MSDOS */ +#define EROFS (-1) /* UNIX - not in MSDOS */ +#define EPIPE (-1) /* UNIX - not in MSDOS */ +#define EUCLEAN (-1) /* UNIX - not in MSDOS */ + +extern int _doserrno; /* global DOS error variable */ +extern int errno; /* global error variable */ + +#endif diff --git a/code/SIBOSDK/include/evaldlg.g b/code/SIBOSDK/include/evaldlg.g new file mode 100644 index 0000000..4fb6ca4 --- /dev/null +++ b/code/SIBOSDK/include/evaldlg.g @@ -0,0 +1,30 @@ +/* Generated by Ctran from evaldlg.cl */ +#define EVALDLG_G +#ifndef DLGBOX_G +#include +#endif +#ifndef P_SYS_H +#include +#endif +#ifndef H_EVAL_H +#include +#endif +/* Class Numbers */ +#define C_EVALDLG 58 +/* Method Numbers */ +/* Constants for evaldlg */ +#define EVALDLG_CALCULATOR_EVALUATOR 0 +#define EVALDLG_GENERAL_EVALUATOR 1 +/* Property of evaldlg */ +typedef struct { +short int isEval; +EXTENDED_MEM_VALUES eMem; +} PRS_EVALDLG; +typedef struct pr_evaldlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_EVALDLG evaldlg; +} PR_EVALDLG; diff --git a/code/SIBOSDK/include/evaldlg.ing b/code/SIBOSDK/include/evaldlg.ing new file mode 100644 index 0000000..f61e3cc --- /dev/null +++ b/code/SIBOSDK/include/evaldlg.ing @@ -0,0 +1,29 @@ +; Generated by Ctran from evaldlg.cl +EVALDLG_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF P_SYS_INC + INCLUDE ..\inc\P_SYS.INC +ENDIF +IFNDEF H_EVAL_INC + INCLUDE ..\inc\H_EVAL.INC +ENDIF +; Class Numbers +C_EVALDLG equ 58 +; Method Numbers +; Constants for evaldlg +EVALDLG_CALCULATOR_EVALUATOR equ (0) +EVALDLG_GENERAL_EVALUATOR equ (1) +; Property of evaldlg +PRS_EVALDLG struc +EvaldlgIsEval dw ? +EvaldlgEMem EXTENDED_MEM_VALUES <> +PRS_EVALDLG ends +PR_EVALDLG struc +EvaldlgRoot PRS_ROOT <> +EvaldlgWin PRS_WIN <> +EvaldlgDlgchain PRS_DLGCHAIN <> +EvaldlgDlgbox PRS_DLGBOX <> +EvaldlgEvaldlg PRS_EVALDLG <> +PR_EVALDLG ends diff --git a/code/SIBOSDK/include/factive.g b/code/SIBOSDK/include/factive.g new file mode 100644 index 0000000..bf7c1bb --- /dev/null +++ b/code/SIBOSDK/include/factive.g @@ -0,0 +1,348 @@ +/* Generated by Ctran from factive.cat */ +#define FACTIVE_G +#ifndef APPMAN_G +#include +#endif +#ifndef P_FILE_H +#include +#endif +/* Class Numbers */ +#define C_FACTIVE 25 +#define C_FSCAN 26 +#define C_FNODE 27 +#define C_PNODE 28 +#define C_PSELVAR 29 +#define C_PSEL 30 +#define C_FCASY 31 +#define C_FCSYNC 32 +#define C_FMMK 33 +#define C_FMSRC 34 +#define C_FMTARG 35 +#define C_FMFMT 36 +#define C_FMSCAN 37 +#define C_FMAN 38 +#define C_LOCS 39 +/* Method Numbers */ +#define O_FMAN_DELETE 4 +#define O_FMAN_ERROR 17 +#define O_FS_MATCHNAME 7 +#define O_LS_MATCHNAME 1 +#define O_FS_DIRNAME 10 +#define O_PS_SET_PATH 16 +#define O_FMAN_NAME 10 +#define O_FMAN_FORMAT 9 +#define O_PS_SETTAG 20 +#define O_FMAN_ATTRIB 12 +#define O_FS_END_DIRLIST 12 +#define O_FC_REQUEST_COMP 9 +#define O_FMAN_FILEEXIST 16 +#define O_FN_LIST 7 +#define O_FMAN_RENAME 5 +#define O_FMAN_UPDATE 15 +#define O_FMAN_NEWNAME 14 +#define O_PS_SELECT_DIRENTRY 18 +#define O_FMAN_COMPLETE 13 +#define O_LS_SCAN 2 +#define O_PS_DRIVES 19 +#define O_FS_FSCAN 8 +#define O_FMAN_INFO 11 +#define O_PS_NEW_LIST 23 +#define O_FC_OPEN 8 +#define O_PS_SENSE_FILENAME 17 +#define O_PS_GETTAG 21 +#define O_FMAN_COPY 3 +#define O_PS_DESCEND_PATH 15 +#define O_FMAN_MAKE 6 +#define O_FMAN_CANCEL 2 +#define O_PS_ASCEND_PATH 14 +#define O_PS_ORDER 22 +#define O_FN_END_LIST 8 +#define O_FMAN_REMOVE 7 +#define O_FN_NODENAME 9 +#define O_FC_WRITE 7 +#define O_FS_FILENAME 11 +#define O_PS_GET_FILE 13 +#define O_LS_FILENAME 3 +#define O_FMAN_INIT 1 +#define O_FA_CLOSE 6 +#define O_FMAN_COPYDEV 8 +#define O_FS_FSCAN_END 9 +/* Property of factive */ +typedef struct { +unsigned char *owner; +} PRS_FACTIVE; +typedef struct pr_factive +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +} PR_FACTIVE; +/* Constants for fscan */ +#define FS_WRITABLE P_FAWRITE +#define FS_HIDDEN P_FAHIDDEN +#define FS_SYSTEM P_FASYSTEM +#define FS_DIRECTORIES P_FADIR +#define FS_MODIFIED P_FAMOD +#define FS_ALL_FILES P_FAREAD +#define FS_FILE_TYPE (FS_HIDDEN|FS_SYSTEM) +#define FS_INCLUDE_SUBDIRECTORIES 0x1000 +#define FS_INCLUDE 0x2000 +#define FS_END_DIRLIST 0x4000 +#define FS_PARSE_NAME 0x8000 +#define FS_MAX_DIRLEVELS 32 +/* Property of fscan */ +typedef struct { +unsigned short int flags; +unsigned short int index; +unsigned char *pname; +unsigned char *match; +unsigned char delim[2]; +P_INFO finfo; +P_FPARSE crk; +unsigned char *pcbarr[FS_MAX_DIRLEVELS]; +unsigned char name[P_FNAMESIZE]; +} PRS_FSCAN; +typedef struct pr_fscan +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FSCAN fscan; +} PR_FSCAN; +/* Constants for fnode */ +#define FNODE_NODE_ARRAY 0x01 +#define FNODE_DEVICE_ARRAY 0x02 +#define FNODE_LOCAL_ONLY 0x04 +/* Property of fnode */ +typedef struct { +unsigned short int flags; +unsigned char *pname; +unsigned char *oldname; +unsigned char *pcb; +} PRS_FNODE; +typedef struct pr_fnode +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FNODE fnode; +} PR_FNODE; +/* Property of pnode */ +typedef struct pr_pnode +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FNODE fnode; +} PR_PNODE; +/* Constants for pselvar */ +#define PSEL_FLAG_TAG 0x1 +#define PSEL_ORDER_NAME 0 +#define PSEL_ORDER_TIME 1 +#define PSEL_ORDER_DATE 2 +#define PSEL_ORDER_SIZE 3 +#define PSEL_ORDER_EXT 4 +/* Types for pselvar */ +typedef struct +{ +unsigned short int flags; +unsigned short int namlen; +P_INFO info; +unsigned char name[P_FNAMESIZE]; +} PSEL_REC; +/* Property of pselvar */ +typedef struct pr_pselvar +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VAFLAT vaflat; +} PR_PSELVAR; +/* Constants for psel */ +#define PSEL_RESET_DIR_ARRAY 0x01 +#define PSEL_RESET_FILE_ARRAY 0x02 +#define PSEL_RESET_FSPEC 0x04 +#define PSEL_DEVICE_ARRAY 0x10 +#define PSEL_DIR_ARRAY 0x20 +#define PSEL_FILE_ARRAY 0x40 +#define PSEL_DESCEND 0x80 +#define PSEL_ASCEND 0x100 +#define PSEL_SETPATH 0x200 +#define PSEL_INIT 0x400 +#define PSEL_SELDIR 0x800 +#define PSEL_ANOTHER_CMD 0x1000 +#define PSEL_GENERATE_DEF 0x2000 +#define PSEL_QUEUED_CMD 0x4000 +#define PSEL_CURRENTLY_BUSY (0x100|0x80|0x400|0x200|0x800) +#define PSEL_SET_TAG -1 +#define PSEL_CLEAR_TAG 0 +#define PSEL_TOGGLE_TAG 1 +/* Property of psel */ +typedef struct { +PR_PSELVAR *pfile; +PR_VASTR *pdir; +PR_PNODE *pnode; +unsigned short int dirent; +unsigned short int flags; +unsigned short int asccnt; +unsigned short int dirnum; +unsigned char *setpath; +short int builderr; +P_FPARSE fck; +char fspec[P_FNAMESIZE]; +} PRS_PSEL; +typedef struct pr_psel +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FSCAN fscan; +PRS_PSEL psel; +} PR_PSEL; +/* Constants for fcasy */ +#define FCOPY_DISP_SFTYPE 0x01 +#define FCOPY_DISP_SFSIZE 0x02 +#define FCOPY_DISP_SFDATE 0x04 +#define FCOPY_DISP_SFNAME 0x08 +#define FCOPY_DISP_RFTYPE 0x10 +#define FCOPY_DISP_RFSIZE 0x20 +#define FCOPY_DISP_RFDATE 0x40 +#define FCOPY_DISP_RFNAME 0x80 +#define FCOPY_DISP_BLKSIZ 0x100 +#define FCOPY_DISP_BLKNO 0x200 +#define FCOPY_DISP_PROTOCOL 0x400 +#define FCASY_READ_QUEUED 0x01 +#define FCASY_WRITE_QUEUED 0x02 +/* Types for fcasy */ +typedef struct +{ +unsigned short int flags; +unsigned short int protocol; +unsigned short int blksiz; +unsigned short int blkno; +unsigned short int sftype; +unsigned short int rftype; +unsigned long int sfsize; +unsigned long int rfsize; +unsigned long int sfdate; +unsigned long int rfdate; +unsigned char *sfname; +unsigned char *rfname; +} FCOPY_DISP; +/* Property of fcasy */ +typedef struct { +unsigned char *recvname; +unsigned short int flags; +} PRS_FCASY; +typedef struct pr_fcasy +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FCASY fcasy; +} PR_FCASY; +/* Property of fcsync */ +typedef struct pr_fcsync +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FCASY fcasy; +} PR_FCSYNC; +/* Property of fmmk */ +typedef struct pr_fmmk +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +} PR_FMMK; +/* Property of fmsrc */ +typedef struct pr_fmsrc +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FCASY fcasy; +} PR_FMSRC; +/* Property of fmtarg */ +typedef struct pr_fmtarg +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FCASY fcasy; +} PR_FMTARG; +/* Constants for fmfmt */ +#define FMFMT_NAME 0x01 +/* Property of fmfmt */ +typedef struct { +unsigned short int rdword; +unsigned short int rdlen; +unsigned short int flags; +} PRS_FMFMT; +typedef struct pr_fmfmt +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FMFMT fmfmt; +} PR_FMFMT; +/* Property of fmscan */ +typedef struct pr_fmscan +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FSCAN fscan; +} PR_FMSCAN; +/* Constants for fman */ +#define FMAN_READ_SIZE 0x800 +#define FMAN_COPYING 0 +#define FMAN_DELETE 1 +#define FMAN_RENAME 2 +#define FMAN_MAKE 3 +#define FMAN_REMOVE 4 +#define FMAN_FORMAT 5 +#define FMAN_NAME 6 +#define FMAN_ATTRIB 7 +/* Property of fman */ +typedef struct { +PR_FMSRC *srcfile; +PR_FMTARG *targfile; +PR_FMSCAN *fmscan; +PR_FMMK *fmmk; +PR_FMFMT *fmfmt; +unsigned short int action; +unsigned short int mode; +unsigned short int srclen; +FCOPY_DISP dispinfo; +unsigned char targname[P_FNAMESIZE]; +unsigned char wildsrcname[P_FNAMESIZE]; +unsigned char wildtargname[P_FNAMESIZE]; +unsigned char buf[FMAN_READ_SIZE]; +} PRS_FMAN; +typedef struct pr_fman +{ +PRS_ROOT root; +PRS_FMAN fman; +} PR_FMAN; +/* Constants for locs */ +#define LOCS_FLG_ROM 0x1000 +#define LOCS_FLG_LOC 0x2000 +#define LOCS_FLG_ROOT (0x4000|LOCS_FLG_LOC) +#define LOCS_FLG_ROOT_ONLY 0x4000 +/* Property of locs */ +typedef struct { +unsigned short int flags; +unsigned char *pcb; +unsigned char *pname; +unsigned char *match; +P_INFO info; +unsigned char name[P_FNAMESIZE]; +unsigned char wildname[P_FNAMESIZE]; +} PRS_LOCS; +typedef struct pr_locs +{ +PRS_ROOT root; +PRS_LOCS locs; +} PR_LOCS; diff --git a/code/SIBOSDK/include/factive.ing b/code/SIBOSDK/include/factive.ing new file mode 100644 index 0000000..4dfcac2 --- /dev/null +++ b/code/SIBOSDK/include/factive.ing @@ -0,0 +1,331 @@ +; Generated by Ctran from factive.cat +FACTIVE_ING equ 1 +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +; Class Numbers +C_FACTIVE equ 25 +C_FSCAN equ 26 +C_FNODE equ 27 +C_PNODE equ 28 +C_PSELVAR equ 29 +C_PSEL equ 30 +C_FCASY equ 31 +C_FCSYNC equ 32 +C_FMMK equ 33 +C_FMSRC equ 34 +C_FMTARG equ 35 +C_FMFMT equ 36 +C_FMSCAN equ 37 +C_FMAN equ 38 +C_LOCS equ 39 +; Method Numbers +O_FMAN_DELETE equ 4 +O_FMAN_ERROR equ 17 +O_FS_MATCHNAME equ 7 +O_LS_MATCHNAME equ 1 +O_FS_DIRNAME equ 10 +O_PS_SET_PATH equ 16 +O_FMAN_NAME equ 10 +O_FMAN_FORMAT equ 9 +O_PS_SETTAG equ 20 +O_FMAN_ATTRIB equ 12 +O_FS_END_DIRLIST equ 12 +O_FC_REQUEST_COMP equ 9 +O_FMAN_FILEEXIST equ 16 +O_FN_LIST equ 7 +O_FMAN_RENAME equ 5 +O_FMAN_UPDATE equ 15 +O_FMAN_NEWNAME equ 14 +O_PS_SELECT_DIRENTRY equ 18 +O_FMAN_COMPLETE equ 13 +O_LS_SCAN equ 2 +O_PS_DRIVES equ 19 +O_FS_FSCAN equ 8 +O_FMAN_INFO equ 11 +O_PS_NEW_LIST equ 23 +O_FC_OPEN equ 8 +O_PS_SENSE_FILENAME equ 17 +O_PS_GETTAG equ 21 +O_FMAN_COPY equ 3 +O_PS_DESCEND_PATH equ 15 +O_FMAN_MAKE equ 6 +O_FMAN_CANCEL equ 2 +O_PS_ASCEND_PATH equ 14 +O_PS_ORDER equ 22 +O_FN_END_LIST equ 8 +O_FMAN_REMOVE equ 7 +O_FN_NODENAME equ 9 +O_FC_WRITE equ 7 +O_FS_FILENAME equ 11 +O_PS_GET_FILE equ 13 +O_LS_FILENAME equ 3 +O_FMAN_INIT equ 1 +O_FA_CLOSE equ 6 +O_FMAN_COPYDEV equ 8 +O_FS_FSCAN_END equ 9 +; Property of factive +PRS_FACTIVE struc +FactiveOwner dw ? +PRS_FACTIVE ends +PR_FACTIVE struc +FactiveRoot PRS_ROOT <> +FactiveActive PRS_ACTIVE <> +FactiveFactive PRS_FACTIVE <> +PR_FACTIVE ends +; Constants for fscan +FS_WRITABLE equ (P_FAWRITE) +FS_HIDDEN equ (P_FAHIDDEN) +FS_SYSTEM equ (P_FASYSTEM) +FS_DIRECTORIES equ (P_FADIR) +FS_MODIFIED equ (P_FAMOD) +FS_ALL_FILES equ (P_FAREAD) +FS_FILE_TYPE equ (FS_HIDDEN or FS_SYSTEM) +FS_INCLUDE_SUBDIRECTORIES equ (01000h) +FS_INCLUDE equ (02000h) +FS_END_DIRLIST equ (04000h) +FS_PARSE_NAME equ (08000h) +FS_MAX_DIRLEVELS equ (32) +; Property of fscan +PRS_FSCAN struc +FscanFlags dw ? +FscanIndex dw ? +FscanPname dw ? +FscanMatch dw ? +FscanDelim db (1) * 2 dup (?) +FscanFinfo P_INFO <> +FscanCrk P_FPARSE <> +FscanPcbarr dw FS_MAX_DIRLEVELS dup (?) +FscanName db (1) * P_FNAMESIZE dup (?) +PRS_FSCAN ends +PR_FSCAN struc +FscanRoot PRS_ROOT <> +FscanActive PRS_ACTIVE <> +FscanFactive PRS_FACTIVE <> +FscanFscan PRS_FSCAN <> +PR_FSCAN ends +; Constants for fnode +FNODE_NODE_ARRAY equ (001h) +FNODE_DEVICE_ARRAY equ (002h) +FNODE_LOCAL_ONLY equ (004h) +; Property of fnode +PRS_FNODE struc +FnodeFlags dw ? +FnodePname dw ? +FnodeOldname dw ? +FnodePcb dw ? +PRS_FNODE ends +PR_FNODE struc +FnodeRoot PRS_ROOT <> +FnodeActive PRS_ACTIVE <> +FnodeFactive PRS_FACTIVE <> +FnodeFnode PRS_FNODE <> +PR_FNODE ends +; Property of pnode +PR_PNODE struc +PnodeRoot PRS_ROOT <> +PnodeActive PRS_ACTIVE <> +PnodeFactive PRS_FACTIVE <> +PnodeFnode PRS_FNODE <> +PR_PNODE ends +; Constants for pselvar +PSEL_FLAG_TAG equ (01h) +PSEL_ORDER_NAME equ (0) +PSEL_ORDER_TIME equ (1) +PSEL_ORDER_DATE equ (2) +PSEL_ORDER_SIZE equ (3) +PSEL_ORDER_EXT equ (4) +; Types for pselvar +PSEL_REC struc +PSEL_RECFlags dw ? +PSEL_RECNamlen dw ? +PSEL_RECInfo P_INFO <> +PSEL_RECName db (1) * P_FNAMESIZE dup (?) +PSEL_REC ends +; Property of pselvar +PR_PSELVAR struc +PselvarRoot PRS_ROOT <> +PselvarVaroot PRS_VAROOT <> +PselvarVafix PRS_VAFIX <> +PselvarVaflat PRS_VAFLAT <> +PR_PSELVAR ends +; Constants for psel +PSEL_RESET_DIR_ARRAY equ (001h) +PSEL_RESET_FILE_ARRAY equ (002h) +PSEL_RESET_FSPEC equ (004h) +PSEL_DEVICE_ARRAY equ (010h) +PSEL_DIR_ARRAY equ (020h) +PSEL_FILE_ARRAY equ (040h) +PSEL_DESCEND equ (080h) +PSEL_ASCEND equ (0100h) +PSEL_SETPATH equ (0200h) +PSEL_INIT equ (0400h) +PSEL_SELDIR equ (0800h) +PSEL_ANOTHER_CMD equ (01000h) +PSEL_GENERATE_DEF equ (02000h) +PSEL_QUEUED_CMD equ (04000h) +PSEL_CURRENTLY_BUSY equ (0100h or 080h or 0400h or 0200h or 0800h) +PSEL_SET_TAG equ (-1) +PSEL_CLEAR_TAG equ (0) +PSEL_TOGGLE_TAG equ (1) +; Property of psel +PRS_PSEL struc +PselPfile dw ? +PselPdir dw ? +PselPnode dw ? +PselDirent dw ? +PselFlags dw ? +PselAsccnt dw ? +PselDirnum dw ? +PselSetpath dw ? +PselBuilderr dw ? +PselFck P_FPARSE <> +PselFspec db (1) * P_FNAMESIZE dup (?) +PRS_PSEL ends +PR_PSEL struc +PselRoot PRS_ROOT <> +PselActive PRS_ACTIVE <> +PselFactive PRS_FACTIVE <> +PselFscan PRS_FSCAN <> +PselPsel PRS_PSEL <> +PR_PSEL ends +; Constants for fcasy +FCOPY_DISP_SFTYPE equ (001h) +FCOPY_DISP_SFSIZE equ (002h) +FCOPY_DISP_SFDATE equ (004h) +FCOPY_DISP_SFNAME equ (008h) +FCOPY_DISP_RFTYPE equ (010h) +FCOPY_DISP_RFSIZE equ (020h) +FCOPY_DISP_RFDATE equ (040h) +FCOPY_DISP_RFNAME equ (080h) +FCOPY_DISP_BLKSIZ equ (0100h) +FCOPY_DISP_BLKNO equ (0200h) +FCOPY_DISP_PROTOCOL equ (0400h) +FCASY_READ_QUEUED equ (001h) +FCASY_WRITE_QUEUED equ (002h) +; Types for fcasy +FCOPY_DISP struc +FCOPY_DISPFlags dw ? +FCOPY_DISPProtocol dw ? +FCOPY_DISPBlksiz dw ? +FCOPY_DISPBlkno dw ? +FCOPY_DISPSftype dw ? +FCOPY_DISPRftype dw ? +FCOPY_DISPSfsize dd ? +FCOPY_DISPRfsize dd ? +FCOPY_DISPSfdate dd ? +FCOPY_DISPRfdate dd ? +FCOPY_DISPSfname dw ? +FCOPY_DISPRfname dw ? +FCOPY_DISP ends +; Property of fcasy +PRS_FCASY struc +FcasyRecvname dw ? +FcasyFlags dw ? +PRS_FCASY ends +PR_FCASY struc +FcasyRoot PRS_ROOT <> +FcasyActive PRS_ACTIVE <> +FcasyFactive PRS_FACTIVE <> +FcasyFcasy PRS_FCASY <> +PR_FCASY ends +; Property of fcsync +PR_FCSYNC struc +FcsyncRoot PRS_ROOT <> +FcsyncActive PRS_ACTIVE <> +FcsyncFactive PRS_FACTIVE <> +FcsyncFcasy PRS_FCASY <> +PR_FCSYNC ends +; Property of fmmk +PR_FMMK struc +FmmkRoot PRS_ROOT <> +FmmkActive PRS_ACTIVE <> +FmmkFactive PRS_FACTIVE <> +PR_FMMK ends +; Property of fmsrc +PR_FMSRC struc +FmsrcRoot PRS_ROOT <> +FmsrcActive PRS_ACTIVE <> +FmsrcFactive PRS_FACTIVE <> +FmsrcFcasy PRS_FCASY <> +PR_FMSRC ends +; Property of fmtarg +PR_FMTARG struc +FmtargRoot PRS_ROOT <> +FmtargActive PRS_ACTIVE <> +FmtargFactive PRS_FACTIVE <> +FmtargFcasy PRS_FCASY <> +PR_FMTARG ends +; Constants for fmfmt +FMFMT_NAME equ (001h) +; Property of fmfmt +PRS_FMFMT struc +FmfmtRdword dw ? +FmfmtRdlen dw ? +FmfmtFlags dw ? +PRS_FMFMT ends +PR_FMFMT struc +FmfmtRoot PRS_ROOT <> +FmfmtActive PRS_ACTIVE <> +FmfmtFactive PRS_FACTIVE <> +FmfmtFmfmt PRS_FMFMT <> +PR_FMFMT ends +; Property of fmscan +PR_FMSCAN struc +FmscanRoot PRS_ROOT <> +FmscanActive PRS_ACTIVE <> +FmscanFactive PRS_FACTIVE <> +FmscanFscan PRS_FSCAN <> +PR_FMSCAN ends +; Constants for fman +FMAN_READ_SIZE equ (0800h) +FMAN_COPYING equ (0) +FMAN_DELETE equ (1) +FMAN_RENAME equ (2) +FMAN_MAKE equ (3) +FMAN_REMOVE equ (4) +FMAN_FORMAT equ (5) +FMAN_NAME equ (6) +FMAN_ATTRIB equ (7) +; Property of fman +PRS_FMAN struc +FmanSrcfile dw ? +FmanTargfile dw ? +FmanFmscan dw ? +FmanFmmk dw ? +FmanFmfmt dw ? +FmanAction dw ? +FmanMode dw ? +FmanSrclen dw ? +FmanDispinfo FCOPY_DISP <> +FmanTargname db (1) * P_FNAMESIZE dup (?) +FmanWildsrcname db (1) * P_FNAMESIZE dup (?) +FmanWildtargname db (1) * P_FNAMESIZE dup (?) +FmanBuf db (1) * FMAN_READ_SIZE dup (?) +PRS_FMAN ends +PR_FMAN struc +FmanRoot PRS_ROOT <> +FmanFman PRS_FMAN <> +PR_FMAN ends +; Constants for locs +LOCS_FLG_ROM equ (01000h) +LOCS_FLG_LOC equ (02000h) +LOCS_FLG_ROOT equ (04000h or LOCS_FLG_LOC) +LOCS_FLG_ROOT_ONLY equ (04000h) +; Property of locs +PRS_LOCS struc +LocsFlags dw ? +LocsPcb dw ? +LocsPname dw ? +LocsMatch dw ? +LocsInfo P_INFO <> +LocsName db (1) * P_FNAMESIZE dup (?) +LocsWildname db (1) * P_FNAMESIZE dup (?) +PRS_LOCS ends +PR_LOCS struc +LocsRoot PRS_ROOT <> +LocsLocs PRS_LOCS <> +PR_LOCS ends diff --git a/code/SIBOSDK/include/fcharge.h b/code/SIBOSDK/include/fcharge.h new file mode 100644 index 0000000..0099c96 --- /dev/null +++ b/code/SIBOSDK/include/fcharge.h @@ -0,0 +1,32 @@ +#define P_FCHG_UNKNOWN 0 +#define P_FCHG_NOTCHARGING 1 +#define P_FCHG_FASTCHARGING 2 +#define P_FCHG_TOPPINGOFF 3 +#define P_FCHG_TRICKLE 4 + +#define P_FCHG_DEFAULTCC 0x0000 +#define P_FCHG_CC100mA 0x1000 +#define P_FCHG_CC200mA 0x2000 +#define P_FCHG_CC350mA 0x3000 +#define P_FCHG_CC500mA 0x4000 +#define P_FCHG_CC650mA 0x5000 +#define P_FCHG_CC800mA 0x8000 +#define P_FCHG_CC1000mA 0xa000 +#define P_FCHG_CC1200mA 0xc000 +#define P_FCHG_CC1400mA 0xe000 + +#define P_FCHG_CTIME1C 2 +#define P_FCHG_CTIME2C 6 +#define P_FCHG_CTIMEC2 4 +#define P_FCHG_CTIMEC4 0 + +#define P_FCHG_SETCHARGEMODE 0 +#define P_FCHG_READCHARGEMODE 1 +#define P_FCHG_READSTATUS 2 +#define P_FCHG_CLOSE 3 +#define P_FCHG_CANCEL 4 +#define P_FCHG_FASTCHARGE1 5 +#define P_FCHG_FASTCHARGE2 6 +#define P_FCHG_DISCHARGE 7 +#define P_FCHG_ASYNCHREAD 8 +#define P_FCHG_RESETBOTH 9 diff --git a/code/SIBOSDK/include/fcntl.h b/code/SIBOSDK/include/fcntl.h new file mode 100644 index 0000000..608a2d1 --- /dev/null +++ b/code/SIBOSDK/include/fcntl.h @@ -0,0 +1,50 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* fcntl.h - definitions for opening files. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _FCNTL_INC_ +#define _FCNTL_INC_ + +extern unsigned _fmode; + +/* Flag values for open */ + +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 + +#define O_CREAT 0x0100 /* create and open file */ +#define O_TRUNC 0x0200 /* open with truncation */ +#define O_EXCL 0x0400 /* exclusive open */ + +#define _O_EOF 0x0200 /* set when text file hits ^Z */ + +/* A file in append mode may be written to only at its end. */ + +#define O_APPEND 0x0800 /* to end of file */ + +/* File mode special bits. User may only read these bits */ + +#define O_CHANGED 0x1000 /* File has been written */ +#define O_DEVICE 0x2000 /* user read only flag */ +#define O_TEXT 0x4000 /* CR-LF translation */ +#define O_BINARY 0x8000 /* no translation */ + +/* DOS 3.x file sharing options */ + +#define SH_NOINHERIT 0x80 +#define SH_COMPAT 0x00 +#define SH_DENYRW 0x10 +#define SH_DENYWR 0x20 +#define SH_DENYRD 0x30 +#define SH_DENYNO 0x40 + +#define SH_DENYNONE SH_DENYNO /* MS documentation uses both */ +#endif diff --git a/code/SIBOSDK/include/filelist.g b/code/SIBOSDK/include/filelist.g new file mode 100644 index 0000000..007d810 --- /dev/null +++ b/code/SIBOSDK/include/filelist.g @@ -0,0 +1,100 @@ +/* Generated by Ctran from filelist.cl */ +#define FILELIST_G +#ifndef FACTIVE_G +#include +#endif +#ifndef H_FILE_H +#include +#endif +#ifndef LISTBOX_G +#include +#endif +#ifndef TIME_G +#include +#endif +/* Class Numbers */ +#define C_NONODE 39 +#define C_HPSEL 40 +#define C_FILELIST 41 +/* Method Numbers */ +#define O_FL_LOCCHG 23 +#define O_FL_LIST_COMPLETE 22 +/* Property of nonode */ +typedef struct pr_nonode +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FNODE fnode; +} PR_NONODE; +/* Property of hpsel */ +typedef struct { +PR_ROOT *owner; +} PRS_HPSEL; +typedef struct pr_hpsel +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_FACTIVE factive; +PRS_FSCAN fscan; +PRS_PSEL psel; +PRS_HPSEL hpsel; +} PR_HPSEL; +/* Constants for filelist */ +#define PR_FILELIST_ISFILE 0x100 +#define PR_FILELIST_TAGS_CHANGED 0x0200 +#define PR_FILELIST_NOSCAN 0x0400 +#define PR_FILELIST_SCANNING 0x0800 +#define PR_FILELIST_LOCAL 0x1000 +#define PR_FILELIST_WILDCARDED 0x2000 +#define PR_FILELIST_SET_UNMARKED 0x4000 +#define IN_FILELIST_ALLOW_DIRS H_FILE_ALLOW_DIRS +#define IN_FILELIST_JUST_DIRS H_FILE_JUST_DIRS +#define IN_FILELIST_CAN_TAG H_FILE_CAN_TAG +#define IN_FILELIST_CAN_WILDCARD H_FILE_CAN_WILDCARD +#define IN_FILELIST_NO_FORCE_WILD 0x8000 +#define FILENAME_WIDTH 12 +#define FILESIZE_WIDTH 7 +#define FILETIME_WIDTH 7 +#define FILEDATE_WIDTH 9 +/* Types for filelist */ +typedef struct +{ +short int dtype; +void *vadev; +short int ascoff; +unsigned short int tagoff; +unsigned short int sizeoff; +unsigned short int timeoff; +unsigned short int dateoff; +unsigned short int dateendoff; +char asc[P_FNAMESIZE]; +} PR_FILELIST_X; +/* Property of filelist */ +typedef struct { +PR_HPSEL *hpsel; +PR_VASTR *contexts; +PR_TIME *date; +PR_VASTR *tags; +PR_VASTR **ptags; +PR_ROOT *next; +unsigned short int locmask; +unsigned short int flags; +short int parent; +short int thisdir; +P_FPARSE crk; +short int derr; +PR_FILELIST_X *x; +unsigned long int dfree; +char wild[P_FNAMESIZE]; +char subd[P_FNAMESIZE]; +char scr[P_FNAMESIZE]; +char targ[P_FNAMESIZE]; +} PRS_FILELIST; +typedef struct pr_filelist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LISTBOX listbox; +PRS_FILELIST filelist; +} PR_FILELIST; diff --git a/code/SIBOSDK/include/filelist.ing b/code/SIBOSDK/include/filelist.ing new file mode 100644 index 0000000..8dbd308 --- /dev/null +++ b/code/SIBOSDK/include/filelist.ing @@ -0,0 +1,96 @@ +; Generated by Ctran from filelist.cl +FILELIST_ING equ 1 +IFNDEF FACTIVE_ING + INCLUDE ..\inc\FACTIVE.ING +ENDIF +IFNDEF H_FILE_INC + INCLUDE ..\inc\H_FILE.INC +ENDIF +IFNDEF LISTBOX_ING + INCLUDE ..\inc\LISTBOX.ING +ENDIF +IFNDEF TIME_ING + INCLUDE ..\inc\TIME.ING +ENDIF +; Class Numbers +C_NONODE equ 39 +C_HPSEL equ 40 +C_FILELIST equ 41 +; Method Numbers +O_FL_LOCCHG equ 23 +O_FL_LIST_COMPLETE equ 22 +; Property of nonode +PR_NONODE struc +NonodeRoot PRS_ROOT <> +NonodeActive PRS_ACTIVE <> +NonodeFactive PRS_FACTIVE <> +NonodeFnode PRS_FNODE <> +PR_NONODE ends +; Property of hpsel +PRS_HPSEL struc +HpselOwner dw ? +PRS_HPSEL ends +PR_HPSEL struc +HpselRoot PRS_ROOT <> +HpselActive PRS_ACTIVE <> +HpselFactive PRS_FACTIVE <> +HpselFscan PRS_FSCAN <> +HpselPsel PRS_PSEL <> +HpselHpsel PRS_HPSEL <> +PR_HPSEL ends +; Constants for filelist +PR_FILELIST_ISFILE equ (0100h) +PR_FILELIST_TAGS_CHANGED equ (00200h) +PR_FILELIST_NOSCAN equ (00400h) +PR_FILELIST_SCANNING equ (00800h) +PR_FILELIST_LOCAL equ (01000h) +PR_FILELIST_WILDCARDED equ (02000h) +PR_FILELIST_SET_UNMARKED equ (04000h) +IN_FILELIST_ALLOW_DIRS equ (H_FILE_ALLOW_DIRS) +IN_FILELIST_JUST_DIRS equ (H_FILE_JUST_DIRS) +IN_FILELIST_CAN_TAG equ (H_FILE_CAN_TAG) +IN_FILELIST_CAN_WILDCARD equ (H_FILE_CAN_WILDCARD) +IN_FILELIST_NO_FORCE_WILD equ (08000h) +FILENAME_WIDTH equ (12) +FILESIZE_WIDTH equ (7) +FILETIME_WIDTH equ (7) +FILEDATE_WIDTH equ (9) +; Types for filelist +PR_FILELIST_X struc +PR_FILELIST_XDtype dw ? +PR_FILELIST_XVadev dw ? +PR_FILELIST_XAscoff dw ? +PR_FILELIST_XTagoff dw ? +PR_FILELIST_XSizeoff dw ? +PR_FILELIST_XTimeoff dw ? +PR_FILELIST_XDateoff dw ? +PR_FILELIST_XDateendoff dw ? +PR_FILELIST_XAsc db (1) * P_FNAMESIZE dup (?) +PR_FILELIST_X ends +; Property of filelist +PRS_FILELIST struc +FilelistHpsel dw ? +FilelistContexts dw ? +FilelistDate dw ? +FilelistTags dw ? +FilelistPtags dw ? +FilelistNext dw ? +FilelistLocmask dw ? +FilelistFlags dw ? +FilelistParent dw ? +FilelistThisdir dw ? +FilelistCrk P_FPARSE <> +FilelistDerr dw ? +FilelistX dw ? +FilelistDfree dd ? +FilelistWild db (1) * P_FNAMESIZE dup (?) +FilelistSubd db (1) * P_FNAMESIZE dup (?) +FilelistScr db (1) * P_FNAMESIZE dup (?) +FilelistTarg db (1) * P_FNAMESIZE dup (?) +PRS_FILELIST ends +PR_FILELIST struc +FilelistRoot PRS_ROOT <> +FilelistWin PRS_WIN <> +FilelistListbox PRS_LISTBOX <> +FilelistFilelist PRS_FILELIST <> +PR_FILELIST ends diff --git a/code/SIBOSDK/include/files.g b/code/SIBOSDK/include/files.g new file mode 100644 index 0000000..a16c769 --- /dev/null +++ b/code/SIBOSDK/include/files.g @@ -0,0 +1,127 @@ +/* Generated by Ctran from files.cl */ +#define FILES_G +#ifndef CHLIST_G +#include +#endif +#ifndef EDWIN_G +#include +#endif +#ifndef VARES_G +#include +#endif +#ifndef TIME_G +#include +#endif +#ifndef P_FILE_H +#include +#endif +#ifndef H_FILE_H +#include +#endif +/* Class Numbers */ +#define C_VADEV 42 +#define C_PACKSEL 43 +#define C_FNEDIT 44 +#define C_FNSELWN 45 +/* Method Numbers */ +#define O_FNS_INSERT_TAGS 19 +#define O_FNS_EXTRACT_TAGS 20 +#define O_FNS_VALIDATE_FLIST 22 +#define O_FNS_SUBSET 21 +/* Property of vadev */ +typedef struct { +char buf[20]; +} PRS_VADEV; +typedef struct pr_vadev +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VASTR vastr; +PRS_VADEV vadev; +} PR_VADEV; +/* Constants for packsel */ +#define PR_CHLIST_PACKSEL_DODINFO 0x8000 +/* Property of packsel */ +typedef struct { +PR_LODGER *filsel; +short int err; +} PRS_PACKSEL; +typedef struct pr_packsel +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_CHLIST chlist; +PRS_PACKSEL packsel; +} PR_PACKSEL; +/* Constants for fnedit */ +#define IN_FNEDIT_STANDARD H_FILE_STANDARD_INIT +#define IN_FNEDIT_ALLOW_DIRS H_FILE_ALLOW_DIRS +#define IN_FNEDIT_JUST_DIRS H_FILE_JUST_DIRS +#define IN_FNEDIT_FORCE_NXIST H_FILE_FORCE_NXIST +#define IN_FNEDIT_NO_AUTOQUERY H_FILE_NO_AUTOQUERY +#define IN_FNEDIT_ACCEPT_NULL H_FILE_ACCEPT_NULL +#define IN_FNEDIT_SET_DEFEXT H_FILE_SET_DEFEXT +#define IN_FNEDIT_CAN_WILDCARD H_FILE_CAN_WILDCARD +/* Types for fnedit */ +typedef struct +{ +unsigned char flags; +char fname[1]; +} IN_FNEDIT; +/* Property of fnedit */ +typedef struct { +PR_LISTBOX *pop; +PR_PACKSEL *pack; +unsigned short int flags; +char *defext; +char extbuf[6]; +char buf[P_FNAMESIZE]; +} PRS_FNEDIT; +typedef struct pr_fnedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_EDWIN edwin; +PRS_FNEDIT fnedit; +} PR_FNEDIT; +/* Constants for fnselwn */ +#define IN_FNSELWN_STANDARD H_FILE_STANDARD_INIT +#define IN_FNSELWN_SHOW_DIRS H_FILE_ALLOW_DIRS +#define IN_FNSELWN_HIDE_FILES H_FILE_JUST_DIRS +#define IN_FNSELWN_RESTRICT_LIST H_FILE_RESTRICT_LIST +#define IN_FNSELWN_CAN_TAG H_FILE_CAN_TAG +#define IN_FNSELWN_ACCEPT_NULL H_FILE_ACCEPT_NULL +#define IN_FNSELWN_SET_DEFEXT H_FILE_SET_DEFEXT +#define IN_FNSELWN_CAN_WILDCARD H_FILE_CAN_WILDCARD +#define PR_FNSELWN_TAGSHERE 0x100 +#define PR_FNSELWN_AT_ROOT 0x200 +#define PR_FNSELWN_WILDCARDED 0x400 +#define PR_FNSELWN_PRESERVE_TAGS 0x800 +#define PR_FNSELWN_ON_DIR 0x1000 +#define PR_FNSELWN_CHANGED_DIR 0x8000 +/* Types for fnselwn */ +typedef struct +{ +unsigned char flags; +char fname[1]; +} IN_FNSELWN; +/* Property of fnselwn */ +typedef struct { +PR_VASTR *tags; +PR_PACKSEL *pack; +unsigned short int flags; +char *defext; +char extbuf[6]; +P_FPARSE crk; +char buf[P_FNAMESIZE]; +} PRS_FNSELWN; +typedef struct pr_fnselwn +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_CHLIST chlist; +PRS_FNSELWN fnselwn; +} PR_FNSELWN; diff --git a/code/SIBOSDK/include/files.ing b/code/SIBOSDK/include/files.ing new file mode 100644 index 0000000..bc42583 --- /dev/null +++ b/code/SIBOSDK/include/files.ing @@ -0,0 +1,121 @@ +; Generated by Ctran from files.cl +FILES_ING equ 1 +IFNDEF CHLIST_ING + INCLUDE ..\inc\CHLIST.ING +ENDIF +IFNDEF EDWIN_ING + INCLUDE ..\inc\EDWIN.ING +ENDIF +IFNDEF VARES_ING + INCLUDE ..\inc\VARES.ING +ENDIF +IFNDEF TIME_ING + INCLUDE ..\inc\TIME.ING +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +IFNDEF H_FILE_INC + INCLUDE ..\inc\H_FILE.INC +ENDIF +; Class Numbers +C_VADEV equ 42 +C_PACKSEL equ 43 +C_FNEDIT equ 44 +C_FNSELWN equ 45 +; Method Numbers +O_FNS_INSERT_TAGS equ 19 +O_FNS_EXTRACT_TAGS equ 20 +O_FNS_VALIDATE_FLIST equ 22 +O_FNS_SUBSET equ 21 +; Property of vadev +PRS_VADEV struc +VadevBuf db (1) * 20 dup (?) +PRS_VADEV ends +PR_VADEV struc +VadevRoot PRS_ROOT <> +VadevVaroot PRS_VAROOT <> +VadevVastr PRS_VASTR <> +VadevVadev PRS_VADEV <> +PR_VADEV ends +; Constants for packsel +PR_CHLIST_PACKSEL_DODINFO equ (08000h) +; Property of packsel +PRS_PACKSEL struc +PackselFilsel dw ? +PackselErr dw ? +PRS_PACKSEL ends +PR_PACKSEL struc +PackselRoot PRS_ROOT <> +PackselWin PRS_WIN <> +PackselLodger PRS_LODGER <> +PackselChlist PRS_CHLIST <> +PackselPacksel PRS_PACKSEL <> +PR_PACKSEL ends +; Constants for fnedit +IN_FNEDIT_STANDARD equ (H_FILE_STANDARD_INIT) +IN_FNEDIT_ALLOW_DIRS equ (H_FILE_ALLOW_DIRS) +IN_FNEDIT_JUST_DIRS equ (H_FILE_JUST_DIRS) +IN_FNEDIT_FORCE_NXIST equ (H_FILE_FORCE_NXIST) +IN_FNEDIT_NO_AUTOQUERY equ (H_FILE_NO_AUTOQUERY) +IN_FNEDIT_ACCEPT_NULL equ (H_FILE_ACCEPT_NULL) +IN_FNEDIT_SET_DEFEXT equ (H_FILE_SET_DEFEXT) +IN_FNEDIT_CAN_WILDCARD equ (H_FILE_CAN_WILDCARD) +; Types for fnedit +IN_FNEDIT struc +IN_FNEDITFlags db ? +IN_FNEDITFname db (1) * 1 dup (?) +IN_FNEDIT ends +; Property of fnedit +PRS_FNEDIT struc +FneditPop dw ? +FneditPack dw ? +FneditFlags dw ? +FneditDefext dw ? +FneditExtbuf db (1) * 6 dup (?) +FneditBuf db (1) * P_FNAMESIZE dup (?) +PRS_FNEDIT ends +PR_FNEDIT struc +FneditRoot PRS_ROOT <> +FneditWin PRS_WIN <> +FneditLodger PRS_LODGER <> +FneditEdwin PRS_EDWIN <> +FneditFnedit PRS_FNEDIT <> +PR_FNEDIT ends +; Constants for fnselwn +IN_FNSELWN_STANDARD equ (H_FILE_STANDARD_INIT) +IN_FNSELWN_SHOW_DIRS equ (H_FILE_ALLOW_DIRS) +IN_FNSELWN_HIDE_FILES equ (H_FILE_JUST_DIRS) +IN_FNSELWN_RESTRICT_LIST equ (H_FILE_RESTRICT_LIST) +IN_FNSELWN_CAN_TAG equ (H_FILE_CAN_TAG) +IN_FNSELWN_ACCEPT_NULL equ (H_FILE_ACCEPT_NULL) +IN_FNSELWN_SET_DEFEXT equ (H_FILE_SET_DEFEXT) +IN_FNSELWN_CAN_WILDCARD equ (H_FILE_CAN_WILDCARD) +PR_FNSELWN_TAGSHERE equ (0100h) +PR_FNSELWN_AT_ROOT equ (0200h) +PR_FNSELWN_WILDCARDED equ (0400h) +PR_FNSELWN_PRESERVE_TAGS equ (0800h) +PR_FNSELWN_ON_DIR equ (01000h) +PR_FNSELWN_CHANGED_DIR equ (08000h) +; Types for fnselwn +IN_FNSELWN struc +IN_FNSELWNFlags db ? +IN_FNSELWNFname db (1) * 1 dup (?) +IN_FNSELWN ends +; Property of fnselwn +PRS_FNSELWN struc +FnselwnTags dw ? +FnselwnPack dw ? +FnselwnFlags dw ? +FnselwnDefext dw ? +FnselwnExtbuf db (1) * 6 dup (?) +FnselwnCrk P_FPARSE <> +FnselwnBuf db (1) * P_FNAMESIZE dup (?) +PRS_FNSELWN ends +PR_FNSELWN struc +FnselwnRoot PRS_ROOT <> +FnselwnWin PRS_WIN <> +FnselwnLodger PRS_LODGER <> +FnselwnChlist PRS_CHLIST <> +FnselwnFnselwn PRS_FNSELWN <> +PR_FNSELWN ends diff --git a/code/SIBOSDK/include/float.h b/code/SIBOSDK/include/float.h new file mode 100644 index 0000000..f1cd1ef --- /dev/null +++ b/code/SIBOSDK/include/float.h @@ -0,0 +1,114 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* float.h - Implementation specific macros for floating point. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _FLOAT_INC_ +#define _FLOAT_INC_ + +#define DBL_DIG 15 /* number of decimal digits of precision */ +#define DBL_MANT_DIG 53 /* number of bits in mantissa */ +#define DBL_MAX_10_EXP 308 /* maximum decimal exponent */ +#define DBL_MAX_EXP 1024 /* maximum binary exponent */ +#define DBL_MIN_10_EXP -307 /* minimum decimal exponent */ +#define DBL_MIN_EXP -1021 /* minimum binary exponent */ +#define DBL_RADIX 2 /* exponent radix */ +#define DBL_ROUNDS 1 /* addition rounding */ +#define DBL_EPSILON 2.2204460492503131e-016 /* 1.0+DBL_EPSILON != 1.0 */ +#define DBL_MAX 1.7976931348623151e+308 /* maximum value */ +#define DBL_MIN 2.2250738585072014e-308 /* minimum positive value */ + +#define FLT_DIG 6 /* number of decimal digits of precision */ +#define FLT_GUARD 0 +#define FLT_MANT_DIG 24 /* number of bits in mantissa */ +#define FLT_MAX_10_EXP 38 /* maximum decimal exponent */ +#define FLT_MAX_EXP 128 /* maximum binary exponent */ +#define FLT_MIN_10_EXP -37 /* minimum decimal exponent */ +#define FLT_MIN_EXP -125 /* minimum binary exponent */ +#define FLT_NORMALIZE 0 +#define FLT_RADIX 2 /* exponent radix */ +#define FLT_ROUNDS 1 /* addition rounding chops */ +#define FLT_EPSILON 1.192092896e-07 /* smallest such that 1.0+FLT_EPSILON != 1.0 */ +#define FLT_MAX 3.402823466e+38 /* maximum value */ +#define FLT_MIN 1.175494351e-38 /* minimum positive value */ + +#define LDBL_DIG 19 /* number of decimal digits of precision */ +#define LDBL_EPSILON 5.4210108624275221706e-20 /* smallest such that 1.0+LDBL_EPSILON != 1.0 */ +#define LDBL_MANT_DIG 64 /* number of bits in mantissa */ +#define LDBL_MAX 1.189731495357231765e+4932L /* maximum value */ +#define LDBL_MAX_10_EXP 4932 /* maximum decimal exponent */ +#define LDBL_MAX_EXP 16384 /* maximum binary exponent */ +#define LDBL_MIN 3.3621031431120935063e-4932L /* minimum positive value */ +#define LDBL_MIN_10_EXP (-4931) /* minimum deimal exponent */ +#define LDBL_MIN_EXP (-16381) /* minimum binary exponent */ +#define LDBL_RADIX 2 /* exponent radix */ +#define LDBL_ROUNDS DBL_ROUNDS /* addition rounding */ + +/* X087 math control information */ + +/* Control Word Mask and bit definitions */ + +#define MCW_EM 0x003f /* interrupt Exception Masks */ +#define EM_INVALID 0x0001 /* invalid */ +#define EM_DENORMAL 0x0002 /* denormal */ +#define EM_ZERODIVIDE 0x0004 /* zero divide */ +#define EM_OVERFLOW 0x0008 /* overflow */ +#define EM_UNDERFLOW 0x0010 /* underflow */ +#define EM_INEXACT 0x0020 /* inexact */ + +#define MCW_IC 0x1000 /* Infinity Control */ +#define IC_AFFINE 0x1000 /* affine */ +#define IC_PROJECTIVE 0x0000 /* projective */ + +#define MCW_RC 0x0c00 /* Rounding Control */ +#define RC_CHOP 0x0c00 /* chop */ +#define RC_UP 0x0800 /* up */ +#define RC_DOWN 0x0400 /* down */ +#define RC_NEAR 0x0000 /* near */ + +#define MCW_PC 0x0300 /* Precision Control */ +#define PC_24 0x0000 /* 24 bits */ +#define PC_53 0x0200 /* 53 bits */ +#define PC_64 0x0300 /* 64 bits */ + +/* Initial Control Word value */ + +#define CW_DEFAULT ( IC_AFFINE + RC_NEAR + PC_64 + EM_DENORMAL + EM_UNDERFLOW + EM_INEXACT ) + +/* user Status Word bit definitions */ + +#define SW_INVALID 0x0001 /* invalid */ +#define SW_DENORMAL 0x0002 /* denormal */ +#define SW_ZERODIVIDE 0x0004 /* zero divide */ +#define SW_OVERFLOW 0x0008 /* overflow */ +#define SW_UNDERFLOW 0x0010 /* underflow */ +#define SW_INEXACT 0x0020 /* precision inexact */ + +/* Floating point error signals */ + +#define FPE_INVALID 0x81 +#define FPE_DENORMAL 0x82 +#define FPE_ZERODIVIDE 0x83 +#define FPE_OVERFLOW 0x84 +#define FPE_UNDERFLOW 0x85 +#define FPE_INEXACT 0x86 + +/* X087 control function prototypes */ + +#ifdef __cplusplus +extern "C" { +#endif +extern unsigned int _clear87(void); +extern unsigned int _control87(unsigned int _new, unsigned int _mask); +extern void _fpreset(void); +extern unsigned int _status87(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/fltedit.g b/code/SIBOSDK/include/fltedit.g new file mode 100644 index 0000000..8b37978 --- /dev/null +++ b/code/SIBOSDK/include/fltedit.g @@ -0,0 +1,45 @@ +/* Generated by Ctran from fltedit.cl */ +#define FLTEDIT_G +#ifndef EDWIN_G +#include +#endif +/* Class Numbers */ +#define C_FLTEDIT 46 +/* Method Numbers */ +/* Constants for fltedit */ +#define FLTEDIT_MAX_CHAR 20 +#define SE_FLTEDIT_CURRENT 0x01 +#define SE_FLTEDIT_HIGH 0x02 +#define SE_FLTEDIT_LOW 0x04 +/* Types for fltedit */ +typedef struct +{ +double current; +double low; +double high; +unsigned char vulen; +unsigned char format; +} IN_FLTEDIT; +typedef struct +{ +double current; +double low; +double high; +short int set_flags; +} SE_FLTEDIT; +/* Property of fltedit */ +typedef struct { +double current; +double low; +double high; +unsigned char point; +unsigned char format; +} PRS_FLTEDIT; +typedef struct pr_fltedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_EDWIN edwin; +PRS_FLTEDIT fltedit; +} PR_FLTEDIT; diff --git a/code/SIBOSDK/include/fltedit.ing b/code/SIBOSDK/include/fltedit.ing new file mode 100644 index 0000000..db1e45b --- /dev/null +++ b/code/SIBOSDK/include/fltedit.ing @@ -0,0 +1,42 @@ +; Generated by Ctran from fltedit.cl +FLTEDIT_ING equ 1 +IFNDEF EDWIN_ING + INCLUDE ..\inc\EDWIN.ING +ENDIF +; Class Numbers +C_FLTEDIT equ 46 +; Method Numbers +; Constants for fltedit +FLTEDIT_MAX_CHAR equ (20) +SE_FLTEDIT_CURRENT equ (001h) +SE_FLTEDIT_HIGH equ (002h) +SE_FLTEDIT_LOW equ (004h) +; Types for fltedit +IN_FLTEDIT struc +IN_FLTEDITCurrent db 8 dup (?) +IN_FLTEDITLow db 8 dup (?) +IN_FLTEDITHigh db 8 dup (?) +IN_FLTEDITVulen db ? +IN_FLTEDITFormat db ? +IN_FLTEDIT ends +SE_FLTEDIT struc +SE_FLTEDITCurrent db 8 dup (?) +SE_FLTEDITLow db 8 dup (?) +SE_FLTEDITHigh db 8 dup (?) +SE_FLTEDITSet_flags dw ? +SE_FLTEDIT ends +; Property of fltedit +PRS_FLTEDIT struc +FlteditCurrent db 8 dup (?) +FlteditLow db 8 dup (?) +FlteditHigh db 8 dup (?) +FlteditPoint db ? +FlteditFormat db ? +PRS_FLTEDIT ends +PR_FLTEDIT struc +FlteditRoot PRS_ROOT <> +FlteditWin PRS_WIN <> +FlteditLodger PRS_LODGER <> +FlteditEdwin PRS_EDWIN <> +FlteditFltedit PRS_FLTEDIT <> +PR_FLTEDIT ends diff --git a/code/SIBOSDK/include/fontdlg.g b/code/SIBOSDK/include/fontdlg.g new file mode 100644 index 0000000..f20e590 --- /dev/null +++ b/code/SIBOSDK/include/fontdlg.g @@ -0,0 +1,34 @@ +/* Generated by Ctran from fontdlg.cl */ +#define FONTDLG_G +#ifndef DLGBOX_G +#include +#endif +#ifndef SCRLAY_G +#include +#endif +/* Class Numbers */ +#define C_FONTSEL 64 +/* Method Numbers */ +/* Types for fontsel */ +typedef struct +{ +void *wdr; +SCRLAY_FONT *pf; +unsigned short int ret; +} FONTSEL_DATA; +/* Property of fontsel */ +typedef struct { +PR_ROOT *names; +PR_ROOT *sizes; +void *wdr; +SCRLAY_FONT *pf; +SCRLAY_FONT f; +} PRS_FONTSEL; +typedef struct pr_fontsel +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_FONTSEL fontsel; +} PR_FONTSEL; diff --git a/code/SIBOSDK/include/fontdlg.ing b/code/SIBOSDK/include/fontdlg.ing new file mode 100644 index 0000000..0cdb4b4 --- /dev/null +++ b/code/SIBOSDK/include/fontdlg.ing @@ -0,0 +1,32 @@ +; Generated by Ctran from fontdlg.cl +FONTDLG_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +; Class Numbers +C_FONTSEL equ 64 +; Method Numbers +; Types for fontsel +FONTSEL_DATA struc +FONTSEL_DATAWdr dw ? +FONTSEL_DATAPf dw ? +FONTSEL_DATARet dw ? +FONTSEL_DATA ends +; Property of fontsel +PRS_FONTSEL struc +FontselNames dw ? +FontselSizes dw ? +FontselWdr dw ? +FontselPf dw ? +FontselF SCRLAY_FONT <> +PRS_FONTSEL ends +PR_FONTSEL struc +FontselRoot PRS_ROOT <> +FontselWin PRS_WIN <> +FontselDlgchain PRS_DLGCHAIN <> +FontselDlgbox PRS_DLGBOX <> +FontselFontsel PRS_FONTSEL <> +PR_FONTSEL ends diff --git a/code/SIBOSDK/include/fonts.h b/code/SIBOSDK/include/fonts.h new file mode 100644 index 0000000..364adb0 --- /dev/null +++ b/code/SIBOSDK/include/fonts.h @@ -0,0 +1,105 @@ +/* + File: FONTS.H + Copyright (C) Psion PLC 1993 + Started by : DavidW + Started in: April 1993 (derived from earlier contents of Hwim.cat) + + The fonts listed in sxwim.rom (and in egclient.par), in order: + + S3.FON 6000,1,2,3 (SYS$NORM,SYS$BOLD,SYS$DIGT,*) + SA13S.FON 6004,5,6,7 (SA13SN,SA13SNM,SA13SB,*) + SA13R.FON 6008,9,a (SA13RN,SA13RB,*) + SA16RN.FON 600b + SA16SN.FON 600c + SA11S.FON 600d,e,f (SA11SN,SA11SB,*) + SA11R.FON 6010,11,12 (SA11RN,SA11RB,*) + SA08S.FON 6013,14,15 (SA08SN,SA08SB,*) + SA08RND4.FON 6016 + SA08RBD4.FON 6017 + SA37SND.FON 6018 + SA08SN5.FON 6019 + SA07RBA.FON 601a + SA05RND.FON 601b + AGN8SYM.FON 601c + AGN13SYM.FON 601d + SA08RNM8.FON 601e + SA06RNM6.FON 601f + SPR05RN4.FON 6020 + SA15SND.FON 6021 + SA11SYM.FON 6022 + WORLD.FON 6023 + + The numerical contents of sys$wsrv.fsu (defines the 4000 numbered fonts): + + 0,1,2, Series3 fonts + 1e, 8x8 mono + 3,12,a,b, 4 Roman fonts: 8/11/13/16 + 15,f,7,c, 4 Swiss fonts: 8/11/13/16 + 1f 6x6 mono + + "Server fonts" in egclient.par (and in xhhenv.ini) (all are 6000 numbers): + 7 S3b system font + 4 S3b notifer/alert message font ("internal font") + 13 (d) status window diamond bar text font + 13 (d) status window diamond bar symbol font + 24 (18) "medium 2" digital clock font + 13 (d) "medium 2" date font + 4 button text in notifiers and alerts + 33 (21) small digital clock font +*/ + +/* +Series 3 fonts +*/ +#define FONT_ID_S3 WS_FONT_BASE +#define FONT_ID_S3BOLD (WS_FONT_BASE+0x1) +#define FONT_ID_S3DIGITS (WS_FONT_BASE+0x2) + +/* +Series 3B supported fonts +*/ +#define FONT_ID_MONO_8x8 (WS_FONT_BASE+0x3) +#define FONT_ID_ROMAN_8 (WS_FONT_BASE+0x4) +#define FONT_ID_ROMAN_11 (WS_FONT_BASE+0x5) +#define FONT_ID_ROMAN_13 (WS_FONT_BASE+0x6) +#define FONT_ID_ROMAN_16 (WS_FONT_BASE+0x7) +#define FONT_ID_SWISS_8 (WS_FONT_BASE+0x8) +#define FONT_ID_SWISS_11 (WS_FONT_BASE+0x9) +#define FONT_ID_SWISS_13 (WS_FONT_BASE+0xa) +#define FONT_ID_SWISS_16 (WS_FONT_BASE+0xb) +#define FONT_ID_MONO_6x6 (WS_FONT_BASE+0xc) + +/* +Series 3B specialised fonts, not necessarily supported on future machines +*/ +#define FONT_ID_DIGITS_8x4 (WS_FONT_BASE2+0x16) +#define FONT_ID_DIGITS_8x4B (WS_FONT_BASE2+0x17) +#define FONT_ID_CLOCK_37 (WS_FONT_BASE2+0x18) +#define FONT_ID_SWISS_8_THIN (WS_FONT_BASE2+0x19) +#define FONT_ID_ALPHA_UC_7B (WS_FONT_BASE2+0x1a) +#define FONT_ID_DIGITS_5x4 (WS_FONT_BASE2+0x1b) +#define FONT_ID_AGN_SYM_8 (WS_FONT_BASE2+0x1c) +#define FONT_ID_AGN_SYM_13 (WS_FONT_BASE2+0x1d) +#define FONT_ID_SPR_5x4 (WS_FONT_BASE2+0x20) +#define FONT_ID_CLOCK_15 (WS_FONT_BASE2+0x21) + +/* +Vine and s3d fonts +*/ +#define FONT_ID_SA_11_SYM (WS_FONT_BASE2+0x22) +#define FONT_ID_WORLD (WS_FONT_BASE2+0x23) + +/* +Font ids that are component parts of configured groups +*/ +#define FONT_ID_13_S (WS_FONT_BASE2+0x4) +#define FONT_ID_13M_S (WS_FONT_BASE2+0x5) +#define FONT_ID_13B_S (WS_FONT_BASE2+0x6) +#define FONT_ID_13_R (WS_FONT_BASE2+0x8) +#define FONT_ID_13B_R (WS_FONT_BASE2+0x9) +#define FONT_ID_11_S (WS_FONT_BASE2+0xd) +#define FONT_ID_11B_S (WS_FONT_BASE2+0xe) +#define FONT_ID_11_R (WS_FONT_BASE2+0x10) +#define FONT_ID_11B_R (WS_FONT_BASE2+0x11) +#define FONT_ID_8_S (WS_FONT_BASE2+0x13) +#define FONT_ID_8B_S (WS_FONT_BASE2+0x14) diff --git a/code/SIBOSDK/include/form.ext b/code/SIBOSDK/include/form.ext new file mode 100644 index 0000000..16ab7c3 --- /dev/null +++ b/code/SIBOSDK/include/form.ext @@ -0,0 +1,188 @@ +Generated by Ctran from form.cat +LIBRARY form +CLASS scrlay root +{ +DECLARE sl_init +DECLARE sl_set +DECLARE sl_sense +DECLARE sl_line_ends +DECLARE sl_pos_to_xl +DECLARE sl_xl_to_pos +DECLARE sl_begin_read +DECLARE sl_read +DECLARE sl_format_line +DECLARE sl_scroll +DECLARE sl_view +DECLARE sl_discard_layout +DECLARE sl_set_lines +DECLARE sl_para_changed +DECLARE sl_rescale +HAS_METHOD +HAS_PROPERTY +} +CLASS prnlay scrlay +{ +DECLARE sl_print_read +DECLARE sl_print_pos +HAS_METHOD +HAS_PROPERTY +} +CLASS wrap active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS scrimg root +{ +DECLARE si_init +DECLARE si_set +DECLARE si_sense +DECLARE si_emphasize +DECLARE si_get_select +DECLARE si_pan +DECLARE si_scroll +DECLARE si_view +DECLARE si_move_cursor +DECLARE si_redraw +DECLARE si_doc_changed +DECLARE si_doc_reset +DECLARE si_para_changed +DECLARE si_style_changed +DECLARE si_delprep +DECLARE si_fwd_change +HAS_METHOD +HAS_PROPERTY +} +CLASS epfdoc epflat +{ +DECLARE epfdoc_para_start +DECLARE epfdoc_sense_chars +HAS_METHOD +} +CLASS epdoc eproot +{ +DECLARE epdoc_para_start +DECLARE epdoc_sense_chars +DECLARE epdoc_set_pages +DECLARE epdoc_enq_page +DECLARE epdoc_goto_page +DECLARE epdoc_set_filter +DECLARE epdoc_pos_filter +HAS_METHOD +HAS_PROPERTY +} +CLASS wdr root +{ +DECLARE wdr_init +DECLARE wdr_count_models +DECLARE wdr_sense_model_name +DECLARE wdr_set_model +DECLARE wdr_sense_model +DECLARE wdr_typeface +DECLARE wdr_search_typeface +DECLARE wdr_font_height +DECLARE wdr_search_height +DECLARE wdr_get_width_table +DECLARE wdr_sense_width +DECLARE wdr_twips_to_xy +DECLARE wdr_open_print +DECLARE wdr_load_record +HAS_METHOD +HAS_PROPERTY +} +CLASS pdr root +{ +DECLARE pdr_init +DECLARE pdr_print +DECLARE pdr_add_command +DECLARE pdr_destroy +DECLARE pdr_start +DECLARE pdr_end +DECLARE pdr_page +DECLARE pdr_text +DECLARE pdr_line +DECLARE pdr_right +DECLARE pdr_font +DECLARE pdr_style +HAS_METHOD +HAS_PROPERTY +} +CLASS pages active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS printer root +{ +DECLARE pr_init +DECLARE pr_store_srchar +DECLARE pr_store_file +DECLARE pr_set_port_type +DECLARE pr_set_model +DECLARE pr_port_data +DECLARE pr_sense_port +DECLARE pr_sense_model +DECLARE pr_get_params +DECLARE pr_set_hd +DECLARE pr_get_hd +DECLARE pr_open_wdr +DECLARE pr_close_wdr +DECLARE pr_open_port +DECLARE pr_print +DECLARE pr_paginate +DECLARE pr_preview_start +DECLARE pr_preview +DECLARE pr_preview_end +DECLARE pr_preview_data +HAS_METHOD +HAS_PROPERTY +} +CLASS prvpdr pdr +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS calimg root +{ +DECLARE ci_init +DECLARE ci_set_title +DECLARE ci_emphasise +DECLARE ci_move_cursor +DECLARE ci_goto_date +DECLARE ci_adjust_date +DECLARE ci_redraw +DECLARE ci_sense +DECLARE ci_view +DECLARE ci_pos_mxy +DECLARE ci_today_changed +HAS_METHOD +HAS_PROPERTY +} +CLASS ptroot root +{ +DECLARE pt_init +DECLARE pt_reset +DECLARE pt_append +DECLARE pt_put_lintab +DECLARE pt_pbuf +DECLARE pt_add_phrase +DECLARE pt_wrap +DECLARE pt_display_line +DECLARE pt_set_fonts +DECLARE pt_mod_by_num +DECLARE pt_mod_by_attrib +DECLARE pt_find +DECLARE pt_inquire +HAS_METHOD +HAS_PROPERTY +} +CLASS ptseg ptroot +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS ptflat ptroot +{ +HAS_METHOD +HAS_PROPERTY +} diff --git a/code/SIBOSDK/include/form.g b/code/SIBOSDK/include/form.g new file mode 100644 index 0000000..83be76f --- /dev/null +++ b/code/SIBOSDK/include/form.g @@ -0,0 +1,12 @@ +/* Generated by Ctran from form.cat */ +#define FORM_G +#ifndef P_STD_H +#include +#endif +#ifndef P_OBJECT_H +#include +#endif +/* Category Numbers */ +/* EPOC */ +#define CAT_FORM_FORM 0 +#define CAT_FORM_OLIB 1 diff --git a/code/SIBOSDK/include/form.ing b/code/SIBOSDK/include/form.ing new file mode 100644 index 0000000..d4faa2d --- /dev/null +++ b/code/SIBOSDK/include/form.ing @@ -0,0 +1,11 @@ +; Generated by Ctran from form.cat +FORM_ING equ 1 +IFNDEF P_STD_INC + INCLUDE ..\inc\P_STD.INC +ENDIF +IFNDEF P_OBJECT_INC + INCLUDE ..\inc\P_OBJECT.INC +ENDIF +; Category Numbers +CAT_FORM_FORM equ 0 +CAT_FORM_OLIB equ 1 diff --git a/code/SIBOSDK/include/form.lis b/code/SIBOSDK/include/form.lis new file mode 100644 index 0000000..5ab59e1 --- /dev/null +++ b/code/SIBOSDK/include/form.lis @@ -0,0 +1,69 @@ +Generated by Ctran from form.cat + +LIBRARY form + +********** form ********** + +********** scrlay ********** +scrlay + Derived from root + Subclassed by prnlay + Referenced by scrimg +prnlay + Derived from scrlay,root + Referenced by pages + +********** scrimg ********** +wrap + Derived from active,root + Referenced by scrimg +scrimg + Derived from root + References wrap,scrlay + +********** epdoc ********** +epfdoc + Derived from epflat,eproot,root + Referenced by pages +epdoc + Derived from eproot,root + References sgbuf,vaflat,vaflat + +********** prdrv ********** +wdr + Derived from root + References rscfile + Referenced by printer +pdr + Derived from root + Subclassed by prvpdr + Referenced by pages + +********** pages ********** +pages + Derived from active,root + References vaflat,vaseg,epfdoc,prnlay,pdr + +********** printer ********** +printer + Derived from root + References wdr + +********** prvpdr ********** +prvpdr + Derived from pdr,root + References root + +********** calimg ********** +calimg + Derived from root + +********** polytext ********** +ptroot + Derived from root + Subclassed by ptflat,ptseg +ptseg + Derived from ptroot,root + References vaxvar +ptflat + Derived from ptroot,root diff --git a/code/SIBOSDK/include/fstream.hpp b/code/SIBOSDK/include/fstream.hpp new file mode 100644 index 0000000..6f56cd1 --- /dev/null +++ b/code/SIBOSDK/include/fstream.hpp @@ -0,0 +1,135 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* FSTREAM.HPP - header file for file stream input and output. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef __FSTREAM_INC_ +#define __FSTREAM_INC_ + +#include + +class filebuf : public streambuf { + +public: + static const int openprot; + + filebuf(); + filebuf(int); + filebuf(int _f, char*, int); + ~filebuf(); + + int is_open(); + int fd(); + + filebuf* open(const char*, int, int = filebuf::openprot); + + filebuf* close(); + filebuf* attach(int); + virtual int overflow(int = EOF); + virtual int underflow(); + virtual int sync(); + virtual streampos seekoff(streamoff, ios::seek_dir, int); + virtual streambuf* setbuf(char*, int); + +protected: + + int last_op(); + int xfd; + int mode; + short opened; + streampos last_seek; + char* in_start; + char lahead[2]; +}; + +inline int filebuf::is_open() { return opened; } +inline int filebuf::fd() { return xfd; } + +class fstreambase : virtual public ios { + +public: + + fstreambase(); + fstreambase(const char*, int, int = filebuf::openprot); + fstreambase(int); + fstreambase(int _f, char*, int); + ~fstreambase(); + + void open(const char*, int, int = filebuf::openprot); + void attach(int); + void close(); + void setbuf(char*, int); + filebuf* rdbuf(); + +private: + + filebuf buf; + +}; + +inline filebuf* fstreambase::rdbuf() { return &buf; } + + +class ifstream : public fstreambase, public istream { + +public: + ifstream(); + ifstream(const char*, int = ios::in, int = filebuf::openprot); + ifstream(int); + ifstream(int _f, char*, int); + ~ifstream(); + + filebuf* rdbuf(); + void open(const char*, int = ios::in, int = filebuf::openprot); + +}; + +inline filebuf* ifstream::rdbuf() { return fstreambase::rdbuf(); } +inline void ifstream::open(const char* name, int m, int prot) { + fstreambase::open(name, m | ios::in, prot); } + + +class ofstream : public fstreambase, public ostream { + +public: + ofstream(); + ofstream(const char*, int = ios::out, int = filebuf::openprot); + ofstream(int); + ofstream(int _f, char*, int); + ~ofstream(); + + filebuf* rdbuf(); + void open(const char*, int = ios::out, int = filebuf::openprot); + +}; + +inline filebuf* ofstream::rdbuf() { return fstreambase::rdbuf(); } +inline void ofstream::open(const char* name, int m, int prot) { + fstreambase::open(name, m | ios::out, prot); } + + +class fstream : public fstreambase, public iostream { + +public: + fstream(); + fstream(const char*, int, int = filebuf::openprot); + fstream(int); + fstream(int _f, char*, int); + ~fstream(); + + filebuf* rdbuf(); + void open(const char *, int, int = filebuf::openprot); + +}; + +inline filebuf* fstream::rdbuf() { return fstreambase::rdbuf(); } +inline void fstream::open(const char* name, int m, int prot) { + fstreambase::open(name, m, prot); } + +#endif \ No newline at end of file diff --git a/code/SIBOSDK/include/gate.g b/code/SIBOSDK/include/gate.g new file mode 100644 index 0000000..6819f9b --- /dev/null +++ b/code/SIBOSDK/include/gate.g @@ -0,0 +1,122 @@ +/* Generated by Ctran from gate.cl */ +#define GATE_G +#ifndef OLIB_G +#include +#endif +/* Class Numbers */ +#define C_GATE 0 +/* Method Numbers */ +#define O_GT_XW_ENABLE 20 +#define O_GT_DIAL_RUN 8 +#define O_GT_MENU_CLOSE 5 +#define O_GT_BUTTON_ADD 17 +#define O_GT_DIAL_ADD 7 +#define O_GT_CHOICE_CLOSE 15 +#define O_GT_MENU_RUN 4 +#define O_GT_MENU_ADD 3 +#define O_GT_WDR_PRINT_SETUP 25 +#define O_GT_DIAL_SOPEN 28 +#define O_GT_CHOICE_ADD 14 +#define O_GT_LAST_KEY 23 +#define O_GT_CARD_OPEN 10 +#define O_GT_INIT 1 +#define O_GT_SET_RSCFILE 27 +#define O_GT_DIAL_POSITION 19 +#define O_GT_CARD_CLOSE 12 +#define O_GT_BUTTON_OPEN 16 +#define O_GT_DIAL_OPEN 6 +#define O_GT_RETURN_SIGNALS 21 +#define O_GT_DO_HELP 26 +#define O_GT_CARD_ADD 11 +#define O_GT_MENU_OPEN 2 +#define O_GT_WDR_PRINT 24 +#define O_GT_CHECK_ATS_ON 22 +#define O_GT_BUTTON_CLOSE 18 +#define O_GT_DIAL_CLOSE 9 +#define O_GT_CHOICE_OPEN 13 +/* Constants for gate */ +#define PR_XWSERV_SHUTDOWN 0x01 +#define PR_XWSERV_QUERY_ALERT 0x02 +#define PR_XWSERV_S3FS 0x04 +#define PR_XWSERV_FROM_OVAL 0x08 +#define PVV_TEXT_MAX_LEN 50 +#define OPRINTER_DO_PREVIEW 1 +#define OPRINTER_PRINT_AFTER 2 +/* Types for gate */ +typedef struct +{ +short int class; +void *data; +} DITEM_LIST; +typedef struct +{ +unsigned short int xwim; +unsigned short int nmenus; +void **menus; +unsigned short int ulines[16]; +unsigned short int count; +DITEM_LIST dialret[9]; +unsigned short int nrec; +void *orec; +unsigned short int preview; +} PURE_GATE; +typedef struct +{ +unsigned char Mode; +unsigned char Flags; +} PVV_DISPLAY; +typedef struct +{ +unsigned short int fht; +unsigned short int fds; +unsigned short int fas; +unsigned short int fnw; +unsigned short int fmw; +unsigned short int cht; +unsigned short int mbht; +unsigned short int bfid; +unsigned short int bulyo; +unsigned short int bulht; +unsigned short int ninlb; +unsigned short int ssww; +unsigned short int bsww; +unsigned short int hllg; +unsigned short int samo; +unsigned short int damo; +} X_CONSTANTS; +typedef struct +{ +unsigned short int fht; +unsigned short int fds; +unsigned short int fas; +unsigned short int fnw; +unsigned short int fmw; +unsigned short int cht; +unsigned short int bulyo; +unsigned short int bulht; +unsigned short int ninlb; +} DLG_X_CONSTANTS; +/* Property of gate */ +typedef struct { +void *waotstat; +void *concb; +int xadd; +unsigned short int flags; +unsigned short int dialres; +X_CONSTANTS x; +void *getkeys; +unsigned short int lastkey; +unsigned short int lastmods; +unsigned short int atpid; +unsigned short int atson; +void *today_hook; +char shift_txt[10]; +PVV_DISPLAY prevdisp; +DLG_X_CONSTANTS dx; +PURE_GATE g; +} PRS_GATE; +typedef struct pr_gate +{ +PRS_ROOT root; +PRS_GATE gate; +} PR_GATE; diff --git a/code/SIBOSDK/include/gate.ing b/code/SIBOSDK/include/gate.ing new file mode 100644 index 0000000..eb2dbe3 --- /dev/null +++ b/code/SIBOSDK/include/gate.ing @@ -0,0 +1,116 @@ +; Generated by Ctran from gate.cl +GATE_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +; Class Numbers +C_GATE equ 0 +; Method Numbers +O_GT_XW_ENABLE equ 20 +O_GT_DIAL_RUN equ 8 +O_GT_MENU_CLOSE equ 5 +O_GT_BUTTON_ADD equ 17 +O_GT_DIAL_ADD equ 7 +O_GT_CHOICE_CLOSE equ 15 +O_GT_MENU_RUN equ 4 +O_GT_MENU_ADD equ 3 +O_GT_WDR_PRINT_SETUP equ 25 +O_GT_DIAL_SOPEN equ 28 +O_GT_CHOICE_ADD equ 14 +O_GT_LAST_KEY equ 23 +O_GT_CARD_OPEN equ 10 +O_GT_INIT equ 1 +O_GT_SET_RSCFILE equ 27 +O_GT_DIAL_POSITION equ 19 +O_GT_CARD_CLOSE equ 12 +O_GT_BUTTON_OPEN equ 16 +O_GT_DIAL_OPEN equ 6 +O_GT_RETURN_SIGNALS equ 21 +O_GT_DO_HELP equ 26 +O_GT_CARD_ADD equ 11 +O_GT_MENU_OPEN equ 2 +O_GT_WDR_PRINT equ 24 +O_GT_CHECK_ATS_ON equ 22 +O_GT_BUTTON_CLOSE equ 18 +O_GT_DIAL_CLOSE equ 9 +O_GT_CHOICE_OPEN equ 13 +; Constants for gate +PR_XWSERV_SHUTDOWN equ (001h) +PR_XWSERV_QUERY_ALERT equ (002h) +PR_XWSERV_S3FS equ (004h) +PR_XWSERV_FROM_OVAL equ (008h) +PVV_TEXT_MAX_LEN equ (50) +OPRINTER_DO_PREVIEW equ (1) +OPRINTER_PRINT_AFTER equ (2) +; Types for gate +DITEM_LIST struc +DITEM_LISTClass dw ? +DITEM_LISTData dw ? +DITEM_LIST ends +PURE_GATE struc +PURE_GATEXwim dw ? +PURE_GATENmenus dw ? +PURE_GATEMenus dw ? +PURE_GATEUlines db (2) * 16 dup (?) +PURE_GATECount dw ? +PURE_GATEDialret db (size DITEM_LIST)* 9 dup (?) +PURE_GATENrec dw ? +PURE_GATEOrec dw ? +PURE_GATEPreview dw ? +PURE_GATE ends +PVV_DISPLAY struc +PVV_DISPLAYMode db ? +PVV_DISPLAYFlags db ? +PVV_DISPLAY ends +X_CONSTANTS struc +X_CONSTANTSFht dw ? +X_CONSTANTSFds dw ? +X_CONSTANTSFas dw ? +X_CONSTANTSFnw dw ? +X_CONSTANTSFmw dw ? +X_CONSTANTSCht dw ? +X_CONSTANTSMbht dw ? +X_CONSTANTSBfid dw ? +X_CONSTANTSBulyo dw ? +X_CONSTANTSBulht dw ? +X_CONSTANTSNinlb dw ? +X_CONSTANTSSsww dw ? +X_CONSTANTSBsww dw ? +X_CONSTANTSHllg dw ? +X_CONSTANTSSamo dw ? +X_CONSTANTSDamo dw ? +X_CONSTANTS ends +DLG_X_CONSTANTS struc +DLG_X_CONSTANTSFht dw ? +DLG_X_CONSTANTSFds dw ? +DLG_X_CONSTANTSFas dw ? +DLG_X_CONSTANTSFnw dw ? +DLG_X_CONSTANTSFmw dw ? +DLG_X_CONSTANTSCht dw ? +DLG_X_CONSTANTSBulyo dw ? +DLG_X_CONSTANTSBulht dw ? +DLG_X_CONSTANTSNinlb dw ? +DLG_X_CONSTANTS ends +; Property of gate +PRS_GATE struc +GateWaotstat dw ? +GateConcb dw ? +GateXadd dw ? +GateFlags dw ? +GateDialres dw ? +GateX X_CONSTANTS <> +GateGetkeys dw ? +GateLastkey dw ? +GateLastmods dw ? +GateAtpid dw ? +GateAtson dw ? +GateToday_hook dw ? +GateShift_txt db (1) * 10 dup (?) +GatePrevdisp PVV_DISPLAY <> +GateDx DLG_X_CONSTANTS <> +GateG PURE_GATE <> +PRS_GATE ends +PR_GATE struc +GateRoot PRS_ROOT <> +GateGate PRS_GATE <> +PR_GATE ends diff --git a/code/SIBOSDK/include/gauge.g b/code/SIBOSDK/include/gauge.g new file mode 100644 index 0000000..8d25c52 --- /dev/null +++ b/code/SIBOSDK/include/gauge.g @@ -0,0 +1,30 @@ +/* Generated by Ctran from gauge.cl */ +#define GAUGE_G +#ifndef LODGER_G +#include +#endif +/* Class Numbers */ +#define C_GAUGE 24 +/* Method Numbers */ +/* Constants for gauge */ +#define GAUGE_WHITE 1 +#define GAUGE_GREY 2 +#define GAUGE_BLACK 3 +/* Types for gauge */ +typedef struct +{ +unsigned short int size[4]; +unsigned char colour[4]; +} SE_GAUGE; +/* Property of gauge */ +typedef struct { +unsigned short int size[4]; +unsigned char colour[4]; +} PRS_GAUGE; +typedef struct pr_gauge +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_GAUGE gauge; +} PR_GAUGE; diff --git a/code/SIBOSDK/include/gauge.ing b/code/SIBOSDK/include/gauge.ing new file mode 100644 index 0000000..30a7ab4 --- /dev/null +++ b/code/SIBOSDK/include/gauge.ing @@ -0,0 +1,28 @@ +; Generated by Ctran from gauge.cl +GAUGE_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +; Class Numbers +C_GAUGE equ 24 +; Method Numbers +; Constants for gauge +GAUGE_WHITE equ (1) +GAUGE_GREY equ (2) +GAUGE_BLACK equ (3) +; Types for gauge +SE_GAUGE struc +SE_GAUGESize db (2) * 4 dup (?) +SE_GAUGEColour db (1) * 4 dup (?) +SE_GAUGE ends +; Property of gauge +PRS_GAUGE struc +GaugeSize db (2) * 4 dup (?) +GaugeColour db (1) * 4 dup (?) +PRS_GAUGE ends +PR_GAUGE struc +GaugeRoot PRS_ROOT <> +GaugeWin PRS_WIN <> +GaugeLodger PRS_LODGER <> +GaugeGauge PRS_GAUGE <> +PR_GAUGE ends diff --git a/code/SIBOSDK/include/generic.hpp b/code/SIBOSDK/include/generic.hpp new file mode 100644 index 0000000..abea23c --- /dev/null +++ b/code/SIBOSDK/include/generic.hpp @@ -0,0 +1,47 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* GENERIC.HPP - header file for creating generic classes. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _GENERIC_INC_ +#define _GENERIC_INC_ + +#define _PASTE2(x, y) _PASTE2_x(x, y) +#define _PASTE2_x(x, y) x##y +#define _PASTE3(x, y, z) _PASTE3_x(x, y, z) +#define _PASTE3_x(x, y, z) x##y##z +#define _PASTE4(w, x, y, z) _PASTE4_x(w, x, y, z) +#define _PASTE4_x(w, x, y, z) w##x##y##z + +#define _ALT_PASTE2(x, y) _ALT_PASTE2_x(x, y) +#define _ALT_PASTE2_x(x, y) x##y +#define _ALT_PASTE3(x, y, z) _ALT_PASTE3_x(x, y, z) +#define _ALT_PASTE3_x(x, y, z) x##y##z +#define _ALT_PASTE4(w, x, y, z) _ALT_PASTE4_x(w, x, y, z) +#define _ALT_PASTE4_x(w, x, y, z) w##x##y##z + +// macros for the declaration and implementation of classes +#define declare(x, y) _PASTE2(x, declare)(y) +#define implement(x, y) _PASTE2(x, implement)(y) +#define declare2(x, y, z) _PASTE2(x, declare2)(y, z) +#define implement2(x, y, z) _PASTE2(x, implement2)(y, z) + +// macros for the declaration of error-handling functions + +extern genericerror(int, char*); +typedef int (*GPT)(int, char*); +#define set_handler(generic, type, x) _PASTE4(set_, type, generic, _handler)(x) +#define errorhandler(generic, type) _PASTE3(type, generic, handler) +#define callerror(generic, type, x, y) (*errorhandler(generic, type))(x, y) + +#define name2(x, y) _ALT_PASTE2_x(x, y) +#define name3(x, y, z) _ALT_PASTE3_x(x, y, z) +#define name4(w, x, y, z) _ALT_PASTE4_x(w, x, y, z) + +#endif diff --git a/code/SIBOSDK/include/gridwin.g b/code/SIBOSDK/include/gridwin.g new file mode 100644 index 0000000..f4c3260 --- /dev/null +++ b/code/SIBOSDK/include/gridwin.g @@ -0,0 +1,80 @@ +/* Generated by Ctran from gridwin.cl */ +#define GRIDWIN_G +#ifndef BWIN_G +#include +#endif +/* Class Numbers */ +#define C_GRIDWIN 20 +/* Method Numbers */ +#define O_GW_GET_CURRENT 19 +#define O_GW_SET_ROW_HEIGHT 18 +#define O_GW_HIGHLIGHT 21 +#define O_GW_SET_COL_WIDTH 17 +#define O_GW_DRAW_CELLS 15 +#define O_GW_MOVE_TO 16 +#define O_GW_ZOOM 20 +#define O_GW_GET_DATA 22 +#define O_GW_GET_CELL_RECT 14 +/* Constants for gridwin */ +#define PR_GRIDWIN_MIN_COL_WIDTH 4 +#define PR_GRIDWIN_CELL_HGAP 2 +#define PR_GRIDWIN_CELL_LGAP 2 +#define PR_GRIDWIN_BORDER_WIDTH 1 +#define PR_GRIDWIN_SCROLL_SMALL 6 +#define PR_GRIDWIN_SCROLL_LARGE 9 +#define PR_GRIDWIN_SCROLL_ARROW 15 +#define PR_GRIDWIN_PLOT_X 0 +#define PR_GRIDWIN_PLOT_Y 2 +#define PR_GRIDWIN_ALLOC_THRESH 16 +#define PR_GRIDWIN_COMPLETE_ONLY 0x01 +#define PR_GRIDWIN_GRIDLINES 0x02 +#define PR_GRIDWIN_FREE_SIZES 0x04 +#define PR_GRIDWIN_GRID_SIZE 0x01 +#define PR_GRIDWIN_LOCK 0x02 +#define PR_GRIDWIN_SIZES 0x04 +#define PR_GRIDWIN_FLAGS 0x08 +#define PR_GRIDWIN_XPLANE 0x10 +#define PR_GRIDWIN_YPLANE 0x20 +#define PR_GRIDWIN_ZOOMBASE 0x40 +#define PR_GRIDWIN_SCROLL 0x80 +/* Types for gridwin */ +typedef struct +{ +int locked; +int anchor; +int current; +int visible; +unsigned char clipped; +unsigned char full; +int total; +int *psize; +int defsize; +int numspec; +int scroll; +int gutter; +int max; +int plot; +unsigned short int flags; +void *ptr; +} GRID_PLANE; +typedef struct +{ +GRID_PLANE xplane; +GRID_PLANE yplane; +int zoombase; +int zoom; +unsigned short int flags; +} IN_GRIDWIN; +/* Property of gridwin */ +typedef struct { +IN_GRIDWIN params; +P_EXTENT wextent; +unsigned short int fascent; +unsigned char fstyle; +} PRS_GRIDWIN; +typedef struct pr_gridwin +{ +PRS_ROOT root; +PRS_WIN win; +PRS_GRIDWIN gridwin; +} PR_GRIDWIN; diff --git a/code/SIBOSDK/include/gridwin.ing b/code/SIBOSDK/include/gridwin.ing new file mode 100644 index 0000000..e525d64 --- /dev/null +++ b/code/SIBOSDK/include/gridwin.ing @@ -0,0 +1,77 @@ +; Generated by Ctran from gridwin.cl +GRIDWIN_ING equ 1 +IFNDEF BWIN_ING + INCLUDE ..\inc\BWIN.ING +ENDIF +; Class Numbers +C_GRIDWIN equ 20 +; Method Numbers +O_GW_GET_CURRENT equ 19 +O_GW_SET_ROW_HEIGHT equ 18 +O_GW_HIGHLIGHT equ 21 +O_GW_SET_COL_WIDTH equ 17 +O_GW_DRAW_CELLS equ 15 +O_GW_MOVE_TO equ 16 +O_GW_ZOOM equ 20 +O_GW_GET_DATA equ 22 +O_GW_GET_CELL_RECT equ 14 +; Constants for gridwin +PR_GRIDWIN_MIN_COL_WIDTH equ (4) +PR_GRIDWIN_CELL_HGAP equ (2) +PR_GRIDWIN_CELL_LGAP equ (2) +PR_GRIDWIN_BORDER_WIDTH equ (1) +PR_GRIDWIN_SCROLL_SMALL equ (6) +PR_GRIDWIN_SCROLL_LARGE equ (9) +PR_GRIDWIN_SCROLL_ARROW equ (15) +PR_GRIDWIN_PLOT_X equ (0) +PR_GRIDWIN_PLOT_Y equ (2) +PR_GRIDWIN_ALLOC_THRESH equ (16) +PR_GRIDWIN_COMPLETE_ONLY equ (001h) +PR_GRIDWIN_GRIDLINES equ (002h) +PR_GRIDWIN_FREE_SIZES equ (004h) +PR_GRIDWIN_GRID_SIZE equ (001h) +PR_GRIDWIN_LOCK equ (002h) +PR_GRIDWIN_SIZES equ (004h) +PR_GRIDWIN_FLAGS equ (008h) +PR_GRIDWIN_XPLANE equ (010h) +PR_GRIDWIN_YPLANE equ (020h) +PR_GRIDWIN_ZOOMBASE equ (040h) +PR_GRIDWIN_SCROLL equ (080h) +; Types for gridwin +GRID_PLANE struc +GRID_PLANELocked dw ? +GRID_PLANEAnchor dw ? +GRID_PLANECurrent dw ? +GRID_PLANEVisible dw ? +GRID_PLANEClipped db ? +GRID_PLANEFull db ? +GRID_PLANETotal dw ? +GRID_PLANEPsize dw ? +GRID_PLANEDefsize dw ? +GRID_PLANENumspec dw ? +GRID_PLANEScroll dw ? +GRID_PLANEGutter dw ? +GRID_PLANEMax dw ? +GRID_PLANEPlot dw ? +GRID_PLANEFlags dw ? +GRID_PLANEPtr dw ? +GRID_PLANE ends +IN_GRIDWIN struc +IN_GRIDWINXplane GRID_PLANE <> +IN_GRIDWINYplane GRID_PLANE <> +IN_GRIDWINZoombase dw ? +IN_GRIDWINZoom dw ? +IN_GRIDWINFlags dw ? +IN_GRIDWIN ends +; Property of gridwin +PRS_GRIDWIN struc +GridwinParams IN_GRIDWIN <> +GridwinWextent P_EXTENT <> +GridwinFascent dw ? +GridwinFstyle db ? +PRS_GRIDWIN ends +PR_GRIDWIN struc +GridwinRoot PRS_ROOT <> +GridwinWin PRS_WIN <> +GridwinGridwin PRS_GRIDWIN <> +PR_GRIDWIN ends diff --git a/code/SIBOSDK/include/h_eval.h b/code/SIBOSDK/include/h_eval.h new file mode 100644 index 0000000..fb288c0 --- /dev/null +++ b/code/SIBOSDK/include/h_eval.h @@ -0,0 +1,39 @@ +/* HEADER - H_EVAL.H +Epoc/Os structures and constants. +Copyright (c) Psion PLC 1991. + + VER DATE BY DESCRIPTION +----- -------- ---- ----------- +1.00F 12/03/91 PST Final release +*/ + +#define EVAL_DEFAULT_PLACES 2 +#define EVAL_DEFAULT_FMT_TYPE P_DTOB_FIXED +#define CALC_MAX_PLACES 12 +#define CALC_DEFAULT_PLACES CALC_MAX_PLACES +#define CALC_DEFAULT_FMT_TYPE P_DTOB_GENERAL +#define MAX_MEMORIES 10 + +typedef struct + { + UBYTE evalFormat; /* Dtob format code for all except calc */ + UBYTE evalDPlaces; /* Decimal places for all except calc */ + UBYTE calcFormat; /* Dtob format code */ + UBYTE calcDPlaces; /* Decimal places, if relevant */ + DOUBLE values[MAX_MEMORIES]; + } MEM_VALUES; + +typedef struct + { + UBYTE nameLbc; + UBYTE name[3]; + UBYTE valueLbc; + MEM_VALUES value; + } MEM_ENV; + +typedef struct + { + UBYTE evalDegrees; + UBYTE calcDegrees; + MEM_VALUES memVal; + } EXTENDED_MEM_VALUES; diff --git a/code/SIBOSDK/include/h_eval.inc b/code/SIBOSDK/include/h_eval.inc new file mode 100644 index 0000000..4470134 --- /dev/null +++ b/code/SIBOSDK/include/h_eval.inc @@ -0,0 +1,43 @@ + .xlist +; Include file - H_EVAL.INC +; Epoc/Os OPL runtime include file +; Copyright (c) Psion PLC 1988. +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 1.00A 04/06/91 HP First release +; +H_EVAL_INC equ 1 + .xlist +; +EVAL_DEFAULT_PLACES equ 2 +EVAL_DEFAULT_FMT_TYPE equ DtobTypeFixed +CALC_MAX_PLACES equ 12 +CALC_DEFAULT_PLACES equ CALC_MAX_PLACES +CALC_DEFAULT_FMT_TYPE equ DtobTypeGeneral +MAX_MEMORIES equ 10 +; +MEM_VALUES struc +memValuesEvalFormat db ? +memValuesEvalDPlaces db ? +memValuesCalcFormat db ? +memValuesCalcDPlaces db ? +memValuesMemories dq MAX_MEMORIES dup (?) +MEM_VALUES ends +; +; Memory environment variable structure (name M$V) +; +MEM_ENV struc +memEnvNameLbc db ? +memEnvName db 3 dup (?) +memEnvValueLbc db ? +memEnvValue MEM_VALUES <> +MEM_ENV ends +; +sizeMemName = memEnvValueLbc-memEnvName ; M$V +; +EXTENDED_MEM_VALUES struc +exMemValuesEvalDegrees db ? +exMemValuesCalcDegrees db ? +exMemValuesMemValues MEM_VALUES <> +EXTENDED_MEM_VALUES ends + diff --git a/code/SIBOSDK/include/h_file.h b/code/SIBOSDK/include/h_file.h new file mode 100644 index 0000000..a900311 --- /dev/null +++ b/code/SIBOSDK/include/h_file.h @@ -0,0 +1,25 @@ +/* +HEADER - H_FILE.H +*/ + +#define H_FILE_H + +#define H_FILE_ALLOW_DIRS 0x02 +#define H_FILE_JUST_DIRS 0x04 +#define H_FILE_FORCE_NXIST 0x08 +#define H_FILE_NO_AUTOQUERY 0x10 +#define H_FILE_ACCEPT_NULL 0x20 +#define H_FILE_SET_DEFEXT 0x40 +#define H_FILE_CAN_WILDCARD 0x80 + +#define H_FILE_STANDARD_INIT 0x01 +#define H_FILE_RESTRICT_LIST H_FILE_FORCE_NXIST +#define H_FILE_CAN_TAG H_FILE_NO_AUTOQUERY + +#define H_FILE_HWIF_MASK 0xfe +#define H_FILE_PICK_SELECTOR 0 +#define H_FILE_NEW_EDITOR 0x01 + +#define H_FILE_IS_DIR 0x01 +#define H_FILE_AT_ROOT 0x02 +#define H_FILE_IS_ROOT 0x03 diff --git a/code/SIBOSDK/include/h_file.inc b/code/SIBOSDK/include/h_file.inc new file mode 100644 index 0000000..377eb3c --- /dev/null +++ b/code/SIBOSDK/include/h_file.inc @@ -0,0 +1,29 @@ + .xlist +; Include file - H_FILE.INC +; Flags for Hwif file selector and editor +; Copyright (c) Psion PLC 1988. +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 28/08/91 HP First release +; +H_FILE_INC equ 1 +; +H_FILE_ALLOW_DIRS equ 02h +H_FILE_JUST_DIRS equ 04h +H_FILE_FORCE_NXIST equ 08h +H_FILE_NO_AUTOQUERY equ 10h +H_FILE_ACCEPT_NULL equ 20h +H_FILE_SET_DEFEXT equ 40h +H_FILE_CAN_WILDCARD equ 80h + +H_FILE_STANDARD_INIT equ 01h +H_FILE_RESTRICT_LIST equ H_FILE_FORCE_NXIST +H_FILE_CAN_TAG equ H_FILE_NO_AUTOQUERY + +H_FILE_HWIF_MASK equ 0feh +H_FILE_PICK_SELECTOR equ 0h +H_FILE_NEW_EDITOR equ 01h + +H_FILE_IS_DIR equ 01h +H_FILE_AT_ROOT equ 02h +H_FILE_IS_ROOT equ 03h diff --git a/code/SIBOSDK/include/hactive.g b/code/SIBOSDK/include/hactive.g new file mode 100644 index 0000000..93bb036 --- /dev/null +++ b/code/SIBOSDK/include/hactive.g @@ -0,0 +1,53 @@ +/* Generated by Ctran from hactive.cl */ +#define HACTIVE_G +#ifndef APPMAN_G +#include +#endif +/* Class Numbers */ +#define C_SHUTTER 49 +#define C_WAOTSTAT 50 +#define C_HAIDLE 51 +#define C_DIALAO 52 +/* Method Numbers */ +#define O_HAI_KEY 6 +/* Constants for shutter */ +#define SHUTTER_BUFFER_LEN 128 +#define SHUTTER_COUNT_MAX 32 +/* Property of shutter */ +typedef struct { +short int count; +unsigned char buf[128]; +} PRS_SHUTTER; +typedef struct pr_shutter +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_SHUTTER shutter; +} PR_SHUTTER; +/* Property of waotstat */ +typedef struct { +unsigned short int count; +} PRS_WAOTSTAT; +typedef struct pr_waotstat +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_WAOTSTAT waotstat; +} PR_WAOTSTAT; +/* Property of haidle */ +typedef struct { +void *rbuf; +} PRS_HAIDLE; +typedef struct pr_haidle +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_HAIDLE haidle; +} PR_HAIDLE; +/* Property of dialao */ +typedef struct pr_dialao +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_HAIDLE haidle; +} PR_DIALAO; diff --git a/code/SIBOSDK/include/hactive.ing b/code/SIBOSDK/include/hactive.ing new file mode 100644 index 0000000..6cf1fac --- /dev/null +++ b/code/SIBOSDK/include/hactive.ing @@ -0,0 +1,49 @@ +; Generated by Ctran from hactive.cl +HACTIVE_ING equ 1 +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +; Class Numbers +C_SHUTTER equ 49 +C_WAOTSTAT equ 50 +C_HAIDLE equ 51 +C_DIALAO equ 52 +; Method Numbers +O_HAI_KEY equ 6 +; Constants for shutter +SHUTTER_BUFFER_LEN equ (128) +SHUTTER_COUNT_MAX equ (32) +; Property of shutter +PRS_SHUTTER struc +ShutterCount dw ? +ShutterBuf db (1) * 128 dup (?) +PRS_SHUTTER ends +PR_SHUTTER struc +ShutterRoot PRS_ROOT <> +ShutterActive PRS_ACTIVE <> +ShutterShutter PRS_SHUTTER <> +PR_SHUTTER ends +; Property of waotstat +PRS_WAOTSTAT struc +WaotstatCount dw ? +PRS_WAOTSTAT ends +PR_WAOTSTAT struc +WaotstatRoot PRS_ROOT <> +WaotstatActive PRS_ACTIVE <> +WaotstatWaotstat PRS_WAOTSTAT <> +PR_WAOTSTAT ends +; Property of haidle +PRS_HAIDLE struc +HaidleRbuf dw ? +PRS_HAIDLE ends +PR_HAIDLE struc +HaidleRoot PRS_ROOT <> +HaidleActive PRS_ACTIVE <> +HaidleHaidle PRS_HAIDLE <> +PR_HAIDLE ends +; Property of dialao +PR_DIALAO struc +DialaoRoot PRS_ROOT <> +DialaoActive PRS_ACTIVE <> +DialaoHaidle PRS_HAIDLE <> +PR_DIALAO ends diff --git a/code/SIBOSDK/include/hasrv.h b/code/SIBOSDK/include/hasrv.h new file mode 100644 index 0000000..41c6627 --- /dev/null +++ b/code/SIBOSDK/include/hasrv.h @@ -0,0 +1,39 @@ +/* INCLUDE - HASRV.H +Consumer Handheld alarm server constants. +Copyright (c) Psion PLC 1991 - 1996. + +*/ +#define HASRV_H +#ifndef P_FILE_H +#include +#endif + +#define TypeTimedAlarm 1 /* Timed diary type alarm */ +#define TypeUnTimedAlarm 2 /* Untimed diary type alarm */ +#define OldMaxAlarmText 65 /* S3 Maximum size of alarm text including zts */ +#define MaxAlarmText 161 /* Maximum size of alarm text including zts */ + +/* ALM: i/o functions as well as P_FCLOSE and P_FCANCEL */ +#define A_FUNTIMED P_FREAD +#define A_FTIMED P_FWRITE +#define A_FUNTIMED_X P_FSEEK +#define A_FTIMED_X P_FSETEOF + +#define TIME_TO_ALERT 0 /* First time is when to raise the alert */ +#define TIME_EVENT_DUE 1 /* Second time is when the actual event is due */ + +typedef struct + { + UBYTE len; + TEXT name[8]; + UBYTE zero_term; + } SE_SND; + +typedef struct + { + ULONG absTime; /* Alarm time in seconds */ + ULONG dueTime; /* Actual time alarm is due for */ + SE_SND sound; /* The sound to play */ + } AXDATA; + + diff --git a/code/SIBOSDK/include/help.g b/code/SIBOSDK/include/help.g new file mode 100644 index 0000000..b2ad184 --- /dev/null +++ b/code/SIBOSDK/include/help.g @@ -0,0 +1,43 @@ +/* Generated by Ctran from help.cl */ +#define HELP_G +#ifndef DLGBOX_G +#include +#endif +#ifndef LISTBOX_G +#include +#endif +/* Class Numbers */ +#define C_HELPLIST 47 +#define C_HELPDLG 48 +/* Method Numbers */ +/* Types for helplist */ +typedef struct +{ +unsigned short int topic_id; +char topic[1]; +} HELP_RSC; +/* Property of helplist */ +typedef struct { +PR_VASTR *list; +PR_VAFLAT *ids; +unsigned short int firsttop; +char title[50]; +} PRS_HELPLIST; +typedef struct pr_helplist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LISTBOX listbox; +PRS_HELPLIST helplist; +} PR_HELPLIST; +/* Property of helpdlg */ +typedef struct { +PR_HELPLIST *listbox; +} PRS_HELPDLG; +typedef struct pr_helpdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_HELPDLG helpdlg; +} PR_HELPDLG; diff --git a/code/SIBOSDK/include/help.ing b/code/SIBOSDK/include/help.ing new file mode 100644 index 0000000..f7c3a94 --- /dev/null +++ b/code/SIBOSDK/include/help.ing @@ -0,0 +1,40 @@ +; Generated by Ctran from help.cl +HELP_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF LISTBOX_ING + INCLUDE ..\inc\LISTBOX.ING +ENDIF +; Class Numbers +C_HELPLIST equ 47 +C_HELPDLG equ 48 +; Method Numbers +; Types for helplist +HELP_RSC struc +HELP_RSCTopic_id dw ? +HELP_RSCTopic db (1) * 1 dup (?) +HELP_RSC ends +; Property of helplist +PRS_HELPLIST struc +HelplistList dw ? +HelplistIds dw ? +HelplistFirsttop dw ? +HelplistTitle db (1) * 50 dup (?) +PRS_HELPLIST ends +PR_HELPLIST struc +HelplistRoot PRS_ROOT <> +HelplistWin PRS_WIN <> +HelplistListbox PRS_LISTBOX <> +HelplistHelplist PRS_HELPLIST <> +PR_HELPLIST ends +; Property of helpdlg +PRS_HELPDLG struc +HelpdlgListbox dw ? +PRS_HELPDLG ends +PR_HELPDLG struc +HelpdlgRoot PRS_ROOT <> +HelpdlgWin PRS_WIN <> +HelpdlgDlgchain PRS_DLGCHAIN <> +HelpdlgHelpdlg PRS_HELPDLG <> +PR_HELPDLG ends diff --git a/code/SIBOSDK/include/htime.g b/code/SIBOSDK/include/htime.g new file mode 100644 index 0000000..8379cc4 --- /dev/null +++ b/code/SIBOSDK/include/htime.g @@ -0,0 +1,29 @@ +/* Generated by Ctran from htime.cl */ +#define HTIME_G +#ifndef TIME_G +#include +#endif +/* Class Numbers */ +#define C_HTIME 11 +/* Method Numbers */ +#define O_TO_SET_ABBREVIATIONS 10 +/* Constants for htime */ +#define PR_TIME_ABBREVIATE 0x1000 +#define PR_TIME_FORCE_UPDATE_FORMAT 0x2000 +#define HTIME_FIRST_DAY 29219L +#define HTIME_LAST_DAY 54786L +#define HTIME_FIRST_SEC 0L +#define HTIME_LAST_SEC 86399L +#define HTIME_FIRST_MIN 0L +#define HTIME_LAST_MIN 86340L +/* Property of htime */ +typedef struct { +unsigned char tDay; +unsigned char tMonth; +} PRS_HTIME; +typedef struct pr_htime +{ +PRS_ROOT root; +PRS_TIME time; +PRS_HTIME htime; +} PR_HTIME; diff --git a/code/SIBOSDK/include/htime.ing b/code/SIBOSDK/include/htime.ing new file mode 100644 index 0000000..6f3803e --- /dev/null +++ b/code/SIBOSDK/include/htime.ing @@ -0,0 +1,28 @@ +; Generated by Ctran from htime.cl +HTIME_ING equ 1 +IFNDEF TIME_ING + INCLUDE ..\inc\TIME.ING +ENDIF +; Class Numbers +C_HTIME equ 11 +; Method Numbers +O_TO_SET_ABBREVIATIONS equ 10 +; Constants for htime +PR_TIME_ABBREVIATE equ (01000h) +PR_TIME_FORCE_UPDATE_FORMAT equ (02000h) +HTIME_FIRST_DAY equ (29219L) +HTIME_LAST_DAY equ (54786L) +HTIME_FIRST_SEC equ (0L) +HTIME_LAST_SEC equ (86399L) +HTIME_FIRST_MIN equ (0L) +HTIME_LAST_MIN equ (86340L) +; Property of htime +PRS_HTIME struc +HtimeTDay db ? +HtimeTMonth db ? +PRS_HTIME ends +PR_HTIME struc +HtimeRoot PRS_ROOT <> +HtimeTime PRS_TIME <> +HtimeHtime PRS_HTIME <> +PR_HTIME ends diff --git a/code/SIBOSDK/include/hwif.h b/code/SIBOSDK/include/hwif.h new file mode 100644 index 0000000..5dd66fe --- /dev/null +++ b/code/SIBOSDK/include/hwif.h @@ -0,0 +1,341 @@ +/* HEADER - HWIF.H +Copyright (C) Psion PLC 1992 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.20F 08/11/92 DWW New version for Developers Conference +2.00F 01/12/93 DWW Version 2 C SDK +*/ +#define HWIF_H +#ifndef P_GRAF_H +#include +#endif +#ifndef WLIB_H +#include +#endif +#ifdef STDEPOC_H +# ifndef P_CONS_H +# include +# endif +#else +# ifndef EPOCCONS_H +# include +# endif +#endif + +typedef struct + { + char *title; + unsigned short int nlines; + } H_MENU_DATA; +#define H_DIALOG_TEXT 0 +#define H_DIALOG_CHOICE 1 +#define H_DIALOG_NUMBER 2 +#define H_DIALOG_FLOAT 3 +#define H_DIALOG_TIME 4 +#define H_DIALOG_DATE 5 +#define H_DIALOG_EDIT 6 +#define H_DIALOG_SEDIT 7 +#define H_DIALOG_XINPUT 8 +#define H_DIALOG_FSEL 9 +#define H_DIALOG_BUTTONS 10 +typedef struct + { + char *str; + unsigned short int type; + } H_DI_TEXT; +#define H_DTEXT_ALIGN_LEFT 0 +#define H_DTEXT_ALIGN_RIGHT 1 +#define H_DTEXT_ALIGN_CENTRE 2 +#define H_DTEXT_BOLD 0x100 +#define H_DTEXT_UNDERLINE 0x200 +#define H_DTEXT_SELECTABLE 0x400 +typedef struct + { + union + { + unsigned short int *sel; + unsigned short int count; + } u; + void *menu; + } H_DI_CHOICE; +typedef struct + { + long int *value; + long int low; + long int high; + } H_DI_NUMBER; +typedef struct + { + double *value; + double low; + double high; + } H_DI_FLOAT; +typedef struct + { + unsigned long int *value; + unsigned long int low; + unsigned long int high; + unsigned short int type; + } H_DI_TIME; +#define H_DTIME_SHOW_SECONDS 1 +#define H_DTIME_DURATION 2 +typedef struct + { + unsigned long int *value; + unsigned long int low; + unsigned long int high; + } H_DI_DATE; +#define H_LAST_DAY 93501l +#define H_FIRST_SYS_DAY 25567l +#define H_LAST_SYS_DAY 75276l +typedef struct + { + char *str; + unsigned short int len; + } H_DI_EDIT; +typedef struct + { + char *str; + unsigned short int len; + unsigned short int width; + } H_DI_SEDIT; +typedef struct + { + char *str; + } H_DI_XINPUT; +typedef struct + { + char *fname; + unsigned short int flags; + } H_DI_FSEL; +typedef struct + { + char *str; + short int accel; + } H_CARD; +typedef struct + { + char *str; + } H_CHOICE; +typedef struct + { + char *str; + unsigned short int keycode; + } H_BUTTON; +#define W_EVENT_KEY (CONS_SPECIAL_EVENT*256) +#define H_FILE_ALLOW_DIRS 0x02 +#define H_FILE_JUST_DIRS 0x04 +#define H_FILE_FORCE_NXIST 0x08 +#define H_FILE_NO_AUTOQUERY 0x10 +#define H_FILE_ACCEPT_NULL 0x20 +#define H_FILE_SET_DEFEXT 0x40 +#define H_FILE_CAN_WILDCARD 0x80 +#define H_FILE_RESTRICT_LIST H_FILE_FORCE_NXIST +#define H_FILE_PICK_SELECTOR 0 +#define H_FILE_NEW_EDITOR 0x01 +#define H_PRINT_PAGE 0x01 +#define H_PRINT_LINE 0x02 +#define H_PRINT_RIGHT 0x04 +#define H_PRINT_TEXT 0x10 +#define H_PRINT_KEEP 0x8000 +#define H_PRINT_STY_UNDERLINE 0x01 +#define H_PRINT_STY_BOLD 0x02 +#define H_PRINT_STY_ITALIC 0x04 +#define H_PRINT_STY_SUPER 0x08 +#define H_PRINT_STY_SUB 0x10 +typedef struct + { + short int flags; + short int typf; + short int fheight; + short int style; + short int down; + short int indent; + short int height; + short int right; + char *buf; + unsigned short int blen; + } H_PRINT; +#define H_TIME_SET_SDATE 0 +#define H_TIME_SET_DATE 1 +#define H_TIME_SET_DAYSEC 2 +#define H_TIME_SET_NOW 3 +#define H_TIME_SENSE_BOTH 3 +#define H_TIME_SENSE_DATE 4 +#define H_TIME_SENSE_TIME 5 +#define H_TIME_FORMAT_NO_DAY 0x0004 +#define H_TIME_FORMAT_NO_MONTH 0x0008 +#define H_TIME_FORMAT_NO_YEAR 0x0010 +#define H_TIME_FORMAT_MONTH_NAME 0x0020 +#define H_TIME_FORMAT_SUFFIX 0x0040 +#define H_TIME_FORMAT_DAY_NAME 0x0080 +#define H_TIME_FORMAT_NO_CENTURY 0x0100 +#define H_TIME_FORMAT_NO_SECONDS 0x0200 +#define H_ALARM_TIMED 2 +#define H_ALARM_UNTIMED 1 +typedef struct + { + unsigned short int maxchars; + unsigned short int vulen; + unsigned short int vislines; + P_POINT pos; + unsigned short int win; + unsigned short int font; + unsigned short int style; + unsigned short int lead_tot; + unsigned short int lead_top; + } H_EDIT_BOX; +typedef struct + { + unsigned short int pos; + short int line; + short int x; + } H_SCRLAY_PLX; +#define H_EDIT_BOX_CLIPBOARD 0x0040 +#define H_EDIT_BOX_LEFT_CURSOR 0x0200 +#define H_EDIT_BOX_FONT 0x1000 +#define H_EDIT_BOX_LEADING 0x2000 +#define H_EDIT_BOX_VISLINES 0x4000 +#define HEB_FIND_BACKWARDS 0x01 +#define HEB_FIND_CASESENS 0x02 +#define H_DTEDIT_DDMMYYYY 0x0000 +#define H_DTEDIT_HHMMSS 0x1100 +#define H_DTEDIT_HHMM 0x0100 +#define H_DTEDIT_HHMMSS_D 0x1300 +#define H_DTEDIT_HHMM_D 0x0300 +#define H_DTEDIT_SET_VALUE 0x0001 +#define H_DTEDIT_SET_LOW 0x0002 +#define H_DTEDIT_SET_HIGH 0x0004 +typedef struct + { + unsigned short int flags; + long int value; + long int low; + long int high; + P_POINT pos; + unsigned short int win; + unsigned short int width; + unsigned short int emph; + } H_DTEDIT; +typedef struct + { + unsigned short int flags; + long int value; + long int low; + long int high; + } H_SE_DTEDIT; +#ifdef __cplusplus +extern "C" { +#endif +extern int hIFInit(void *); +extern int hMenuOpen(void); +extern int hMenuAdd(char *,void *); +extern int hMenuRun(void); +extern void hMenuClose(void); +extern int hDlgOpen(char *); +extern int hDlgAdd(unsigned short int,char *,void *); +extern int hDlgRun(void); +extern void hDlgClose(void); +extern int hDlgPosition(int x,int y); +extern void *hCardOpen(void); +extern int hCardAdd(void *,int,int,char *); +extern void hCardClose(void *); +extern void *hChoiceOpen(void); +extern int hChoiceAdd(void *,int,char *); +extern void hChoiceClose(void *); +extern void *hButtonOpen(void); +extern int hButtonAdd(void *,int,int,char *); +extern void hButtonClose(void *); +extern void hEnsurePath(char *fname); +extern void hSetUpStatusNames(char *pb); +extern int hCrackCommandLine(void); +extern int hIsDbfCompressible(void *dH); +extern int hDTMFString(char *zts); +extern unsigned int hLastSystemKey(unsigned int *pmodifiers); +extern void uCommonInit(void); +extern void uEnableGrey(void); +extern void uGetKey(WMSG_KEY *pkey); +extern void uGetKeyA(short int *pstat,WMSG_KEY *pkey); +extern void uCancelGetKeyA(void); +extern int uKeyPressOutstanding(void); +extern void uEscape(unsigned short int flag); +extern unsigned int uFindMainWid(void); +extern void uForceToFront(void); +extern void uErrorString(char *message); +extern int uErrorValue(int ret); +extern void *uCheckHandle(void *handle); +extern void uZTStoBCS(char *bcs,char *zts); +extern int uOpenDialog(char *title); +extern int uAddDialogItem(int type,char *prompt,void *data); +extern int uRunDialog(void); +extern int cdecl uAddButtonList(char *but,int code,...); +extern int uBeginDCL(H_DI_CHOICE *pch); +extern int uGrowDCL(H_DI_CHOICE *pch,char *choice); +extern int uAddDCL(char *prompt,unsigned short int *nsel,H_DI_CHOICE *pch); +extern int cdecl uAddChoiceList(char *prompt,unsigned short int *nsel,char *choice,...); +extern int cdecl uDialogMenu(char *title,char *pb,...); +extern void cdecl uDisplayText(char *pb,...); +extern int uPresentMenus(void); +extern void uAddGreyUline(unsigned char,unsigned short int *plines); +extern void uSetDialogUline(int pos,int on); +extern int uLocateCommand(int accel); +extern void hPrintSetupDialog(void); +extern void hPrint(int printline(H_PRINT *)); +extern void hPrinterSetupDialog(void); +extern void hPrintSetSI(unsigned int subsqind); +extern int hPrintSensePageWidth(void); +extern int hPrintSenseBufWidth(char *buf,int blen); +extern void hHelpSubSystem(int startid,int indexid); +extern void *hTTOpen(void); +extern int hTTSetTime(void *handle,int type,void *data); +extern int hTTSenseString(void *handle,int type,char *buf); +extern void hTTSetFormat(void *handle,int values); +extern void hTTSetAbbreviations(void *handle,int dayabb,int monabb); +extern void hTTClose(void *handle); +extern int hEBHandleKey(void *ebH,int keycode,int modifier); +extern int hEBCompleteFormat(void *ebH); +extern char *hEBSenseText(void *ebH); +extern int hEBSetText(void *ebH,char *pb,int blen); +extern void hEBEmphasise(void *ebH,int flag); +extern int hEBSetSelect(void *ebH,int aoff,int coff); +extern int hEBSenseSelect(void *ebH,unsigned short int *top); +extern int hEBSetClipText(void *ebH,char *pb,int blen); +extern char *hEBSenseClipText(void *ebH); +extern int hEBEvaluate(void *ebH); +extern int hEBSetMargin(void *ebH,unsigned int right); +extern unsigned int hEBSenseMargin(void *ebH); +extern int hEBChangeWidth(void *ebH,int width); +extern void hEBSetCWidth(void *ebH,int cwidth); +extern int hEBInsert(void *ebH,char *pb,int blen); +extern int hEBReplace(void *ebH,char *replace,int backwards); +extern int hEBCopy(void *ebH); +extern int hEBPaste(void *ebH); +extern int hEBFind(void *ebH,char *str,int flags); +extern int hEBSenseChanged(void *ebH); +extern void hEBClearChanged(void *ebH); +extern int hEBShowSymbols(void *ebH,int flag); +extern void *hEBOpen(int flags,H_EDIT_BOX *heb); +extern void hEBClose(void *ebH); +extern void *hEBSenseDoc(void *ebH); +extern int hEDCapacity(void *doc,unsigned int maxlen); +extern int hEDInsert(void *doc,unsigned int pos,void *buf,unsigned int len); +extern int hEBDocChanged(void *ebH); +extern int hEBPosToXL(void *ebH,H_SCRLAY_PLX *plx); +extern void hDeclareAppRcb(void *rcb); +extern void *hInitAppRcb(void); +extern int hSetSystemResLang(int lang); +extern void hRequestReplacePack(void *rcb,char *fname); +extern void *hDTOpen(H_DTEDIT *dte); +extern void hDTClose(void *dte); +extern void hDTSet(void *dte,H_SE_DTEDIT *sdte); +extern void hDTSense(void *dte,H_SE_DTEDIT *sdte); +extern int hDTSelfCheck(void *dte); +extern int hDTHandleKey(void *dte,int keycode,int modifier); +extern void hDTEmphasise(void *dte,int flag); +extern void hSetVarrayInChlist(int index,int nsel,void *varray); +extern void hOODialog(int catHandle,int classno,int resid,void *rbuf); +extern int hLoadOwnDyl(int index); +#ifdef __cplusplus +} +#endif + diff --git a/code/SIBOSDK/include/hwim.ext b/code/SIBOSDK/include/hwim.ext new file mode 100644 index 0000000..9ce47cf --- /dev/null +++ b/code/SIBOSDK/include/hwim.ext @@ -0,0 +1,577 @@ +Generated by Ctran from hwim.cat +LIBRARY hwim +CLASS gate root +{ +DECLARE gt_init +DECLARE gt_menu_open +DECLARE gt_menu_add +DECLARE gt_menu_run +DECLARE gt_menu_close +DECLARE gt_dial_open +DECLARE gt_dial_add +DECLARE gt_dial_run +DECLARE gt_dial_close +DECLARE gt_card_open +DECLARE gt_card_add +DECLARE gt_card_close +DECLARE gt_choice_open +DECLARE gt_choice_add +DECLARE gt_choice_close +DECLARE gt_button_open +DECLARE gt_button_add +DECLARE gt_button_close +DECLARE gt_dial_position +DECLARE gt_xw_enable +DECLARE gt_return_signals +DECLARE gt_check_ats_on +DECLARE gt_last_key +DECLARE gt_wdr_print +DECLARE gt_wdr_print_setup +DECLARE gt_do_help +DECLARE gt_set_rscfile +DECLARE gt_dial_sopen +HAS_METHOD +HAS_PROPERTY +} +CLASS win root +{ +DECLARE wn_redraw +DECLARE wn_dodraw +DECLARE wn_connect +DECLARE wn_position +DECLARE wn_calc_position +DECLARE wn_key +DECLARE wn_visible +DECLARE wn_emphasise +DECLARE wn_sense_help +DECLARE wn_set +DECLARE wn_sense +DECLARE wn_draw +DECLARE wn_init +HAS_METHOD +HAS_PROPERTY +} +CLASS bwin win +{ +HAS_METHOD +} +CLASS lodger win +{ +DECLARE lg_set_id_pos +DECLARE lg_draw +DECLARE lg_self_check +DECLARE lg_sense_width +DECLARE lg_update +HAS_METHOD +HAS_PROPERTY +} +CLASS textwin lodger +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS matcher root +{ +DECLARE im_init +DECLARE im_set_buf +DECLARE im_sense_buf +DECLARE im_set_val +DECLARE im_sense_val +DECLARE im_try_match +DECLARE im_transition +DECLARE im_key +HAS_METHOD +HAS_PROPERTY +} +CLASS vmatcher matcher +{ +DECLARE im_set_range +HAS_METHOD +HAS_PROPERTY +} +CLASS listbox bwin +{ +DECLARE lb_draw_item +DECLARE lb_draw_emphasis +DECLARE lb_size_window +DECLARE lb_item_width +DECLARE lb_take_focus +DECLARE lb_inquire_focus +DECLARE lb_inquire_item +DECLARE lb_inquire_last +HAS_METHOD +HAS_PROPERTY +} +CLASS pulldown listbox +{ +HAS_METHOD +} +CLASS menutab bwin +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS menubar bwin +{ +DECLARE mb_add_menu +HAS_METHOD +HAS_PROPERTY +} +CLASS htime time +{ +DECLARE to_set_abbreviations +HAS_METHOD +HAS_PROPERTY +} +CLASS dlgchain bwin +{ +HAS_PROPERTY +} +CLASS dlgbox dlgchain +{ +DECLARE dl_item_lock +DECLARE dl_item_dim +DECLARE dl_set_item_flags +DECLARE dl_clr_item_flags +DECLARE dl_set_prompt +DECLARE dl_take_focus +DECLARE dl_handle_to_index +DECLARE dl_index_to_handle +DECLARE dl_item_replace +DECLARE dl_item_append +DECLARE dl_init +DECLARE dl_dimmed_message +DECLARE dl_item_add +DECLARE dl_set_size +DECLARE dl_inq_minsize +DECLARE dl_dyn_init +DECLARE dl_key +DECLARE dl_changed +DECLARE dl_focus +DECLARE dl_launch_sub +DECLARE dl_item_new +HAS_METHOD +HAS_PROPERTY +} +CLASS errordlg dlgbox +{ +HAS_METHOD +} +CLASS querydlg dlgbox +{ +HAS_METHOD +} +CLASS flistdlg dlgbox +{ +HAS_METHOD +} +CLASS comman root +{ +DECLARE com_init +DECLARE com_statwin +DECLARE com_accl_check +DECLARE com_menu +DECLARE com_mode_change +DECLARE com_file_change +DECLARE com_exit +HAS_METHOD +} +CLASS wserv active +{ +DECLARE ws_do_dial +DECLARE ws_add_dial +DECLARE ws_remove_dial +DECLARE ws_sense_accel +DECLARE ws_change_cliwin +DECLARE ws_cancel +DECLARE ws_wrap_para +DECLARE ws_error_dialog +DECLARE ws_query_dialog +DECLARE ws_do_help +DECLARE ws_do_submenu +DECLARE ws_set_menubar +DECLARE ws_reset_menubar +DECLARE ws_load_chlist_res +DECLARE ws_append_country +DECLARE ws_free_dial +DECLARE ws_smart_dial +DECLARE ws_dial_env +DECLARE ws_lock +DECLARE ws_format_dialog +DECLARE ws_evaluate +DECLARE ws_eval_env +DECLARE ws_sense_pdev_text +DECLARE ws_edit_pdev_setup +DECLARE ws_edit_print_context +DECLARE ws_ens_print_context +DECLARE ws_add_filelist +DECLARE ws_remove_filelist +DECLARE ws_anim_tick +DECLARE ws_switch_files +DECLARE ws_alert +DECLARE ws_unknown_wm +DECLARE ws_foreground +DECLARE ws_background +DECLARE ws_dyn_init +DECLARE ws_process_key +DECLARE ws_date_changed +DECLARE ws_launch_dyl +DECLARE ws_define_fnbar +DECLARE ws_hook_today_changed +DECLARE ws_get_alloc_info +DECLARE ws_get_print_context +DECLARE ws_self_check +DECLARE ws_hide_app +DECLARE ws_attach_app +DECLARE ws_file_info_print +DECLARE ws_run_memo +DECLARE ws_do_remote_dial +DECLARE ws_user_abandoned +HAS_METHOD +HAS_PROPERTY +} +CLASS hwimman appman +{ +DECLARE am_new_filename +DECLARE am_yield +DECLARE am_ensure_ipcs +HAS_METHOD +HAS_PROPERTY +} +CLASS vares varoot +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS chlist lodger +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS smaclist lodger +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS aclist smaclist +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS gauge lodger +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS donewn gauge +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS xedit lodger +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS mfne lodger +{ +DECLARE mf_range_beep +HAS_METHOD +HAS_PROPERTY +} +CLASS lncedit mfne +{ +HAS_METHOD +} +CLASS ncedit lncedit +{ +HAS_METHOD +} +CLASS wncedit lncedit +{ +HAS_METHOD +} +CLASS dtedit mfne +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS rgedit mfne +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS lledit mfne +{ +HAS_METHOD +} +CLASS edwin lodger +{ +DECLARE ew_sense_size +DECLARE ew_set_size +DECLARE ew_set +DECLARE ew_sense +DECLARE ew_insert +DECLARE ew_snuggle_insert +DECLARE ew_set_font +DECLARE ew_leave +DECLARE ew_find +DECLARE ew_replace +DECLARE ew_evaluate +DECLARE ew_replace_clip +DECLARE ew_paste_clip +DECLARE ew_bring_in +DECLARE ew_ep_insert +DECLARE ew_return_key +DECLARE ew_tab_key +DECLARE ew_init_style +DECLARE ew_readonly +HAS_METHOD +HAS_PROPERTY +} +CLASS punctued edwin +{ +HAS_METHOD +} +CLASS ewlinksv root +{ +DECLARE ewls_init +DECLARE ewls_extract +HAS_METHOD +HAS_PROPERTY +} +CLASS wmatcher matcher +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS wldselwn lodger +{ +DECLARE wld_restrict +HAS_METHOD +HAS_PROPERTY +} +CLASS nonode pnode +{ +HAS_METHOD +} +CLASS hpsel psel +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS filelist listbox +{ +DECLARE fl_list_complete +DECLARE fl_locchg +HAS_METHOD +HAS_PROPERTY +} +CLASS vadev vastr +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS packsel chlist +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS fnedit edwin +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS fnselwn chlist +{ +DECLARE fns_insert_tags +DECLARE fns_extract_tags +DECLARE fns_subset +DECLARE fns_validate_flist +HAS_METHOD +HAS_PROPERTY +} +CLASS fltedit edwin +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS helplist listbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS helpdlg dlgchain +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS shutter active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS waotstat active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS haidle aidle +{ +DECLARE hai_key +HAS_METHOD +HAS_PROPERTY +} +CLASS dialao haidle +{ +HAS_METHOD +} +CLASS progtran server +{ +DECLARE pt_start +DECLARE pt_getline +DECLARE pt_complete +HAS_METHOD +HAS_PROPERTY +} +CLASS progexec active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS progfind locs +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS setportdlg dlgbox +{ +HAS_METHOD +} +CLASS sethshkdlg dlgbox +{ +HAS_METHOD +} +CLASS evaldlg dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS dialdlg dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS freedial lodger +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS fdialdlg dialdlg +{ +HAS_METHOD +} +CLASS cntrydlg dlgbox +{ +HAS_METHOD +} +CLASS sdialdlg dialdlg +{ +HAS_METHOD +} +CLASS fontsel dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS pdevdlg dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS prnctrl dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS pagectrl dlgbox +{ +HAS_METHOD +} +CLASS margins dlgbox +{ +HAS_METHOD +} +CLASS headfoot dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS prnmodel dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS pagesize dlgbox +{ +HAS_METHOD +} +CLASS printing dlgbox +{ +DECLARE printing_set_title +DECLARE printing_do_print +DECLARE printing_done +HAS_METHOD +HAS_PROPERTY +} +CLASS pmodlocs locs +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS lprinter root +{ +DECLARE lpr_init +DECLARE lpr_read +DECLARE lpr_sense_buf_width +DECLARE lpr_sense_text +HAS_METHOD +HAS_PROPERTY +} +CLASS sndlist chlist +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS sndlocs locs +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS fsoundao haidle +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS vanumber varoot +{ +DECLARE van_set_max +HAS_METHOD +HAS_PROPERTY +} +CLASS nchlist chlist +{ +HAS_METHOD +} +CLASS prnprev dlgbox +{ +HAS_METHOD +} +CLASS xpulldwn pulldown +{ +HAS_METHOD +} +CLASS vilastmoddlg dlgbox +{ +HAS_METHOD +} diff --git a/code/SIBOSDK/include/hwim.g b/code/SIBOSDK/include/hwim.g new file mode 100644 index 0000000..eef9c98 --- /dev/null +++ b/code/SIBOSDK/include/hwim.g @@ -0,0 +1,11 @@ +/* Generated by Ctran from hwim.cat */ +#define HWIM_G +#ifndef OLIB_G +#include +#endif +/* Category Numbers */ +/* EPOC */ +#define CAT_HWIM_HWIM 0 +#define CAT_HWIM_OLIB 1 +#define CAT_HWIM_OPL 2 +#define CAT_HWIM_FORM 3 diff --git a/code/SIBOSDK/include/hwim.h b/code/SIBOSDK/include/hwim.h new file mode 100644 index 0000000..c075a6a --- /dev/null +++ b/code/SIBOSDK/include/hwim.h @@ -0,0 +1,89 @@ +/* HEADER - HWIM.H +Hwim utilities constants, structures and function prototypes +Copyright (c) Psion PLC 1991 - 1996. +*/ + +#define HWIM_H + +#define PTR_CALL call(reg_param =>(bx,ax,cx,dx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) + +#ifndef HWIMMAN_G +#include /* for the definition of DL_DATA */ +#endif + +GLREF_C INT CDECL hConfirm(INT rid,...); +GLREF_C INT CDECL h2LineConfirm(INT secondrid,INT rid,...); +GLREF_C INT CDECL hErrorDialog(INT err,INT rid,...); +GLREF_C VOID CDECL hInfoPrint(INT rid,...); +GLREF_C VOID CDECL hBusyPrint(INT delay,INT rid,...); +GLREF_C TEXT * CDECL hAtos(TEXT *buf,INT frid,...); +#pragma save,call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hDestroy(VOID *hand); +#pragma call(reg_param =>(bx,ax,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C INT hLaunchDial(P_CATID cat,INT class,DL_DATA *data); +#pragma call(reg_param =>(dx,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C INT hLoadResBuf(INT id,VOID *pb); +GLREF_C INT hLoadResource(INT id,VOID *ppdata); +#pragma call(reg_param =>(cx,dx,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C INT hAtob(TEXT *pb,INT rid,INT *pargs); +#pragma call(reg_param =>(bx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hErrs(TEXT *buf,INT err); +#pragma call(reg_param =>(ax),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hInfoPrintErr(INT err); +#pragma call(reg_param =>(dx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C TEXT *hLoadChlistResBuf(INT rid,INT choice,TEXT *buf); +#pragma call(reg_param =>(cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hWservComSend(INT comid); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hInitVis(VOID *win); +GLREF_C VOID hAppendEllipsis(TEXT *buf); +GLREF_C VOID hSetGStyle(UINT style); +GLREF_C VOID hEnsurePath(TEXT *filename); +#pragma call(reg_param =>(),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hBeep(VOID); +#pragma call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hSetGTmode(UINT tmode); +#pragma call(reg_param =>(cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hSetGFont(UINT fid); +GLREF_C INT hGetSWid(TEXT *pzts); +#pragma call(reg_param =>(cx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +GLREF_C INT hGetBWid(TEXT *pb,INT blen); +GLREF_C INT hGetBBWid(TEXT *pb,INT blen); +#pragma call(reg_param =>(bx,ax),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +GLREF_C VOID hTwipsToBuf(TEXT *pbuf,UINT val); +GLREF_C UINT hDoubleToTwips(DOUBLE *val); +GLREF_C VOID hTwipsToDouble(DOUBLE *dd,UINT value); +#pragma call(reg_param =>(dx,ax),reg_saved =>(si,di,EPOC_SAVE)) +GLREF_C VOID hDlgSet(UBYTE index,VOID *set); +GLREF_C VOID hDlgSense(UBYTE index,VOID *sense); +#pragma call(reg_param =>(dx,ax),reg_saved =>(si,di,EPOC_SAVE)) +GLREF_C VOID hDlgSetPrompt(UBYTE index,TEXT *pmt); +GLREF_C VOID hDlgSetText(UBYTE index,TEXT *buf); +GLREF_C VOID hDlgSetEdwin(UBYTE index,TEXT *buf); +GLREF_C VOID hDlgSetChlist(UBYTE index,INT nsel); +GLREF_C VOID hDlgSetChlistOn(UBYTE index); +GLREF_C VOID hDlgSetNcedit(UBYTE index,UINT value); +GLREF_C VOID hDlgSetLledit(UBYTE index,INT value); +GLREF_C VOID hDlgSetPtedit(UBYTE index,UBYTE ch); +GLREF_C VOID hDlgSetFledit(UBYTE index,DOUBLE *value); +GLREF_C VOID hDlgSetTwips(UBYTE index,UINT value); +GLREF_C VOID hDlgSenseRgedit(UBYTE index,UWORD *values); +GLREF_C VOID hDlgSenseFledit(UBYTE index,DOUBLE *value); +GLREF_C VOID hDlgItemDim(UBYTE index,INT flag); +GLREF_C VOID hDlgItemLock(UBYTE index,INT flag); +#pragma call(reg_param =>(dx,ax,bx),reg_saved =>(si,di,EPOC_SAVE)) +GLREF_C VOID hDlgSetDtedit(UBYTE index,ULONG value); +GLREF_C VOID hDlgSetRgedit(UBYTE index,UINT value1,UINT value2); +#pragma call(reg_param =>(dx),reg_saved =>(si,di,EPOC_SAVE)) +GLREF_C VOID hDlgSetTitleByRid(INT rid); +GLREF_C TEXT *hDlgSenseEdwin(UBYTE index); +GLREF_C INT hDlgSenseChlist(UBYTE index); +GLREF_C UINT hDlgSenseNcedit(UBYTE index); +GLREF_C INT hDlgSenseLledit(UBYTE index); +GLREF_C INT hDlgSensePtedit(UBYTE index); +GLREF_C UINT hDlgSenseTwips(UBYTE index); +GLREF_C ULONG hDlgSenseDtedit(UBYTE index); +GLREF_C VOID hDlgTakeFocus(UBYTE index); +#pragma METHOD_CALL +GLREF_C VOID hDlgInit(VOID *dlg,HD_DLGBOX_RSC *head,VOID *rbuf); +#pragma restore diff --git a/code/SIBOSDK/include/hwim.ing b/code/SIBOSDK/include/hwim.ing new file mode 100644 index 0000000..bac2b35 --- /dev/null +++ b/code/SIBOSDK/include/hwim.ing @@ -0,0 +1,13 @@ +; Generated by Ctran from hwim.cat +HWIM_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF NOSEND_INC + INCLUDE ..\inc\NOSEND.INC +ENDIF +; Category Numbers +CAT_HWIM_HWIM equ 0 +CAT_HWIM_OLIB equ 1 +CAT_HWIM_OPL equ 2 +CAT_HWIM_FORM equ 3 diff --git a/code/SIBOSDK/include/hwim.rg b/code/SIBOSDK/include/hwim.rg new file mode 100644 index 0000000..6c4b273 --- /dev/null +++ b/code/SIBOSDK/include/hwim.rg @@ -0,0 +1,115 @@ +#define O_PVC_PREVIEW_PRINT 8 +#define O_PVC_PREVIEW_MARGINS 9 +#define O_PVC_PREVIEW_OPTIONS 10 +#define O_PVC_PREVIEW_JUMP 11 +#define O_PVC_PREVIEW_EXIT 12 +#define BREAK_LINE_FOLLOWS 0x80 +#define C_ACLIST 23 +#define C_CHLIST 21 +#define C_DONEWN 25 +#define C_DTEDIT 31 +#define C_EDWIN 34 +#define C_FLTEDIT 46 +#define C_FNEDIT 44 +#define C_FNSELWN 45 +#define C_FREEDIAL 60 +#define C_GAUGE 24 +#define C_LLEDIT 33 +#define C_LNCEDIT 28 +#define C_NCEDIT 29 +#define C_PUNCTUED 35 +#define C_RGEDIT 32 +#define C_TEXTWIN 4 +#define C_WLDSELWN 38 +#define C_WNCEDIT 30 +#define C_XEDIT 26 +#define C_SMACLIST 22 +#define C_SNDLIST 75 +#define C_NCHLIST 79 +#define DLGBOX_NOTIFY_ENTER 0x0001 +#define DLGBOX_NOTIFY_ESCAPE 0x0002 +#define DLGBOX_RBUF_FILLED 0x0004 +#define DLGBOX_ACTION_LIST 0x0008 +#define DLGBOX_SMALL_FONT 0x0010 +#define DLGBOX_NO_WAIT 0x0020 +#define DLGBOX_NOTIFY_ALL_ACT 0x0040 +#define DLGBOX_REPORT_ACT_HORIZ 0x0080 +#define DLGBOX_APPEND_UNITS_TITLE 0x0100 +#define DLGBOX_SMALL_ACTION_LIST 0x0200 +#define DLGBOX_NO_SHADOW 0x0400 +#define DLGBOX_NO_DDP 0x0800 +#define PR_WIN_FORCE_TOP 0x8000 +#define PR_WIN_FORCE_BOTTOM 0x4000 +#define PR_WIN_FORCE_LEFT 0x2000 +#define PR_WIN_FORCE_RIGHT 0x1000 +#define DLGBOX_ITEM_NOTIFY_FOCUS 0x0080 +#define DLGBOX_ITEM_NOTIFY_CHANGED 0x0001 +#define DLGBOX_ITEM_UNDERLINED 0x0004 +#define DLGBOX_ITEM_DIMMED 0x0002 +#define DLGBOX_ITEM_CENTRE 0x0010 +#define DLGBOX_ITEM_DEAD 0x0020 +#define DLGBOX_ITEM_APPL_CAT 0x0008 +#define DLGBOX_ITEM_NEEDS_PACK 0x0100 +#define DLGBOX_ITEM_LOCKED 0x0200 +#define IN_TEXTWIN_AL_LEFT 0x00 +#define IN_TEXTWIN_AL_CENTRE 0x02 +#define IN_TEXTWIN_AL_RIGHT 0x01 +#define IN_TEXTWIN_BOLD 0x04 +#define IN_TEXTWIN_POPOUT 0x40 +#define IN_CHLIST_INCREMENTAL 0x01 +#define HTIME_FIRST_DAY 29219L +#define HTIME_LAST_DAY 54786L +#define HTIME_FIRST_SEC 0L +#define HTIME_LAST_SEC 86399L +#define HTIME_FIRST_MIN 0L +#define HTIME_LAST_MIN 86340L +#define IN_DTEDIT_INIT (0x01 |0x02 |0x04 ) +#define IN_DTEDIT_DDMMYYYY (0x0000 ) +#define IN_DTEDIT_HHMMSS (0x0100 |0x1000 ) +#define IN_DTEDIT_HHMM (0x0100 ) +#define IN_DTEDIT_HHMMSS_D (0x0100 |0x0200 |0x1000 ) +#define IN_DTEDIT_HHMM_D (0x0100 |0x0200 ) +#define IN_DTEDIT_HHMMSS_ND (0x0100 |(0x0200 |0x2000 ) |0x1000 ) +#define IN_DTEDIT_HHMM_ND (0x0100 |(0x0200 |0x2000 ) ) +#define IN_LLEDIT_LATITUDE 0 +#define IN_LLEDIT_LONGITUDE 1 +#define IN_WLDSELWN_CITY 0 +#define IN_WLDSELWN_COUNTRY 0x01 +#define IN_WLDSELWN_SECOND_PARTNER 0x10 +#define IN_WLDSELWN_FIRST_PARTNER 0x02 +#define IN_WLDSELWN_SETHOME 0x20 +#define IN_WLDSELWN_SETDFLT 0x40 +#define IN_EDWIN_VULEN_CHARACTERS 0x0080 +#define IN_EDWIN_VULEN_PIXELS (0x0080 |0x0100 ) +#define IN_EDWIN_NO_AUTOSELECT 0x0010 +#define IN_EDWIN_AUTO_CUR_END (0x0008 |0x0010 ) +#define IN_EDWIN_ACCEPT_TABS 0x0002 +#define IN_EDWIN_DIALLABLE 0x0001 +#define IN_FNSELWN_STANDARD 0x01 +#define IN_FNSELWN_SHOW_DIRS 0x02 +#define IN_FNSELWN_HIDE_FILES 0x04 +#define IN_FNSELWN_RESTRICT_LIST 0x08 +#define IN_FNSELWN_CAN_TAG 0x10 +#define IN_FNSELWN_ACCEPT_NULL 0x20 +#define IN_FNSELWN_SET_DEFEXT 0x40 +#define IN_FNSELWN_CAN_WILDCARD 0x80 +#define IN_FNEDIT_STANDARD 0x01 +#define IN_FNEDIT_ALLOW_DIRS 0x02 +#define IN_FNEDIT_JUST_DIRS 0x04 +#define IN_FNEDIT_FORCE_NXIST 0x08 +#define IN_FNEDIT_NO_AUTOQUERY 0x10 +#define IN_FNEDIT_ACCEPT_NULL 0x20 +#define IN_FNEDIT_SET_DEFEXT 0x40 +#define IN_FNEDIT_CAN_WILDCARD 0x80 +#define WR_MAX_DIAL_STRING 24 +#define P_FNAMESIZE 128 +#define W_KEY_RETURN 13 +#define W_KEY_ESCAPE 27 +#define W_KEY_TAB 9 +#define W_KEY_DELETE_LEFT 8 +#define W_KEY_UP 0x0100 +#define W_KEY_DOWN 0x0101 +#define W_KEY_RIGHT 0x0102 +#define W_KEY_LEFT 0x0103 +#define W_KEY_SPACE 32 +#define W_KEY_MENU 0x0122 diff --git a/code/SIBOSDK/include/hwim.rh b/code/SIBOSDK/include/hwim.rh new file mode 100644 index 0000000..14058c8 --- /dev/null +++ b/code/SIBOSDK/include/hwim.rh @@ -0,0 +1,207 @@ +/* +HWIM.RH - Resource file common header +Started by Carol, December 1990 +*/ + +STRUCT STRING + { + TEXT str; /* zero terminated text string */ + } + +STRUCT STRING_ARRAY + { + STRUCT strlst[]; + } + +STRUCT STRING_ARRAY_SMALL + { + LEN BYTE STRUCT strlst[]; + } + +/* +Accelerators, Menu bars and menus +*/ + +STRUCT WSERV_INFO + { + BYTE menu=0; /* which menu to start with */ + BYTE mnitem=0; /* which item to start with in that menu */ + LINK menbar_id; /* resource id of menu bar */ + BYTE first_com; /* method number of first command */ + LEN BYTE BYTE accel[]; /* acc key only */ + } + +STRUCT MENU_ITEM + BYTE { + BYTE com_id; /* method in command manager */ + TEXT mn_item; /* menu item text */ + } + +STRUCT MENU + { + LEN BYTE STRUCT items[]; /* menu items only */ + } + +STRUCT MENU_BAR_ITEM + { + LINK menu_id; /* resource id of associated menu */ + TEXT mb_item; /* menu header */ + } + +STRUCT MENU_BAR + { + LEN BYTE STRUCT items[]; /* menu bar item only */ + } + +/* +Dialog boxes +*/ + +STRUCT CHLIST + { + LINK rid=0; + BYTE nsel=0; + BYTE flags=0; + } + +STRUCT TXTMESS + { + WORD flags=0; + TEXT str=""; + } + +STRUCT EDWIN /* edit box */ + { + WORD vulen; /* ignored unless either _VULEN_ flag set */ + WORD flags=0; + WORD maxlen; + TEXT str=""; + } + +STRUCT PUSH_BUT + BYTE { + WORD keycode; + TEXT str; /* text associated with button */ + } + +STRUCT ACLIST_ARRAY + { + LEN BYTE STRUCT button[]; /* array of push_buttons */ + } + +STRUCT ACLIST /* Initialising struct for action list */ + { + LINK rid; + } + +STRUCT CHOICE_ITEM /* choice list item */ + BYTE { + TEXT str=""; /* identification text */ + } + +STRUCT LNCEDIT /* long number edit box */ + { + LONG current = 0; + LONG low = 0; /* lowest allowed value */ + LONG high = 10000000; /* highest allowed value */ + } + +STRUCT NCEDIT /* numeric control edit box (unsigned words) */ + { + WORD current = 0; + WORD low = 0; /* lowest allowed value */ + WORD high = 65535; /* highest allowed value */ + } + +STRUCT WNCEDIT /* numeric control edit box (signed words) */ + { + WORD current = 0; + WORD low = -32768; /* lowest allowed value */ + WORD high = 32767; /* highest allowed value */ + } + +STRUCT FLTEDIT /* floating point edit box */ + { + DOUBLE current=0.0; + DOUBLE low =-9.9999999999e99; /* lower bound */ + DOUBLE high =9.9999999999e99; /* upper bound */ + BYTE vulen=5; /* width of editor in characters */ + BYTE ndec=0; /* P_DTOB_GENERAL */ + } + +STRUCT DTEDIT /* combined date/time editor */ + { + WORD flags; + LONG current; + LONG low; /* lowest allowed value */ + LONG high; /* highest allowed value */ + } + +STRUCT RGEDIT /* range editor */ + { + WORD low=1; /* lowest allowed value */ + WORD value_1=1; /* lower value of range */ + WORD value_2=9999; /* higher value of range */ + WORD high=9999; /* highest allowed value */ + } + +STRUCT LLEDIT /* lat long editor */ + { + WORD flags; /* Latitude or longitude */ + WORD value=0; /* The default value */ + } + +STRUCT WLDSELWN + { + WORD flags; + } + +STRUCT FNEDIT /* filename editor */ + { + BYTE flags=0; + TEXT fname=""; + } + +STRUCT FNSELWN /* filename selector */ + { + BYTE flags=0; + TEXT fname=""; + } + +STRUCT CONTROL + LEN { + WORD flags=0; + BYTE class; /* class of control */ + TEXT prompt=""; /* Prompt for item */ + STRUCT info; /* eg CHLIST, TXTMESS, EDWIN, or NCEDIT */ + } + +STRUCT DIALOG + { + WORD flags=0; + TEXT title=""; + LEN BYTE STRUCT controls[]; /* CONTROL only */ + } + +STRUCT TOPIC_ARRAY + { + LEN BYTE LINK id_lst[]; /* ids of topics or related topics */ + } + +STRUCT HELP_ARRAY + { + LINK topic_id=0; /* id of array of related topics */ + TEXT topic; + LEN BYTE STRUCT strlst[]; + } + +STRUCT PAGE_SIZE + { + WORD width; + WORD length; + } + +STRUCT PAGE_SIZE_ARRAY + { + LEN WORD STRUCT page_size[]; + } diff --git a/code/SIBOSDK/include/hwimman.g b/code/SIBOSDK/include/hwimman.g new file mode 100644 index 0000000..64aa0a7 --- /dev/null +++ b/code/SIBOSDK/include/hwimman.g @@ -0,0 +1,236 @@ +/* Generated by Ctran from hwimman.cl */ +#define HWIMMAN_G +#ifndef PULLDOWN_G +#include +#endif +#ifndef APPMAN_G +#include +#endif +#ifndef DLGBOX_G +#include +#endif +#ifndef COMMAN_G +#include +#endif +#ifndef MENUBAR_G +#include +#endif +/* Class Numbers */ +#define C_WSERV 18 +#define C_HWIMMAN 19 +/* Method Numbers */ +#define O_WS_SMART_DIAL 22 +#define O_AM_YIELD 16 +#define O_WS_GET_ALLOC_INFO 46 +#define O_WS_SELF_CHECK 48 +#define O_WS_BACKGROUND 39 +#define O_WS_REMOVE_DIAL 8 +#define O_WS_LOAD_CHLIST_RES 19 +#define O_WS_SET_MENUBAR 17 +#define O_WS_UNKNOWN_WM 37 +#define O_WS_GET_PRINT_CONTEXT 47 +#define O_WS_DIAL_ENV 23 +#define O_WS_DO_REMOTE_DIAL 53 +#define O_WS_REMOVE_FILELIST 33 +#define O_WS_ANIM_TICK 34 +#define O_WS_ERROR_DIALOG 13 +#define O_WS_SWITCH_FILES 35 +#define O_WS_FILE_INFO_PRINT 51 +#define O_WS_HIDE_APP 49 +#define O_WS_PROCESS_KEY 41 +#define O_WS_CHANGE_CLIWIN 10 +#define O_WS_ADD_DIAL 7 +#define O_WS_WRAP_PARA 12 +#define O_AM_ENSURE_IPCS 17 +#define O_WS_DYN_INIT 40 +#define O_WS_SENSE_PDEV_TEXT 28 +#define O_WS_EVAL_ENV 27 +#define O_WS_DO_SUBMENU 16 +#define O_WS_HOOK_TODAY_CHANGED 45 +#define O_WS_ENS_PRINT_CONTEXT 31 +#define O_WS_LOCK 24 +#define O_WS_APPEND_COUNTRY 20 +#define O_WS_LAUNCH_DYL 43 +#define O_WS_FOREGROUND 38 +#define O_WS_RUN_MEMO 52 +#define O_WS_ALERT 36 +#define O_WS_DO_HELP 15 +#define O_WS_DO_DIAL 6 +#define O_WS_ATTACH_APP 50 +#define O_WS_EDIT_PRINT_CONTEXT 30 +#define O_WS_ADD_FILELIST 32 +#define O_WS_CANCEL 11 +#define O_WS_SENSE_ACCEL 9 +#define O_WS_FORMAT_DIALOG 25 +#define O_WS_QUERY_DIALOG 14 +#define O_WS_DATE_CHANGED 42 +#define O_WS_FREE_DIAL 21 +#define O_WS_USER_ABANDONED 54 +#define O_AM_NEW_FILENAME 15 +#define O_WS_RESET_MENUBAR 18 +#define O_WS_DEFINE_FNBAR 44 +#define O_WS_EVALUATE 26 +#define O_WS_EDIT_PDEV_SETUP 29 +/* Constants for wserv */ +#define PR_WSERV_CONNECT_AT_BACK W_CONNECT_AT_BACK +#define PR_WSERV_FOREGROUND 0x02 +#define PR_WSERV_CLIWIN_KEY 0x04 +#define PR_WSERV_CANCELLING 0x08 +#define PR_WSERV_BASIC_HELP 0x10 +#define PR_WSERV_FREEFORM_DIALLING 0x20 +#define PR_WSERV_INSERT_MODE 0x40 +#define PR_WSERV_INSERT_PENDING 0x80 +#define PR_WSERV_OWN_DEFAULT_FONT 0x100 +#define PR_WSERV_RECEIVED_KEY 0x200 +#define PR_WSERV_HIDDEN 0x400 +#define PR_WSERV_METRIC 0x800 +#define PR_WSERV_FULLSCREEN 0x1000 +#define PR_WSERV_CANCELLING_DIALOG 0x2000 +#define PR_WSERV_FROM_HWIF 0x4000 +#define PR_WSERV_OWNPRIO 0x8000 +#define PR_WSERV_HELP_INDEX 0x01 +#define WSERV_DTOB_HEX 3 +#define DEGREES_MODE 0x80 +#define DTOB_MAX_WIDTH 20 +#define WS_EVAL_ENV_SET 0 +#define WS_EVAL_ENV_GET 1 +#define WS_DIAL_ENV_SET 0 +#define WS_DIAL_ENV_GET 1 +#define PDEV_TEXT_MAX_LEN 14 +#define WS_LOCCHG_LOW 0x0100 +#define WS_LOCCHG_HIGH 0x4000 +#define WS_EM_STYLES 0x01 +#define WS_EM_PRINT_CONTEXT 0x02 +#define WS_EM_REUSE_BODY_BUFFER 0x04 +#define WS_EM_REUSE_STYLES_BUFFER 0x08 +#define WS_EM_CALLBACK 0x40 +#define MEMO_NO_CHANGE 0 +#define MEMO_NULL_LENGTH 1 +#define MEMO_STANDARD_CHANGE 2 +/* Types for wserv */ +typedef struct +{ +int com_cat; +unsigned short int com_class; +} IN_WSERV; +typedef struct +{ +unsigned char menu; +unsigned char mnitem; +unsigned short int menubar_id; +unsigned char first_com; +unsigned char count; +unsigned char accel[1]; +} WSERV_INFO; +typedef struct +{ +unsigned short int id; +void *rbuf; +PR_DLGBOX **pdlg; +} DL_DATA; +typedef struct +{ +char *dupnp; +char hidden[6]; +} WS_HIDE_APP_DATA; +typedef struct +{ +unsigned short int margin; +unsigned short int fmargin; +short int font; +unsigned short int style; +short int nlines; +unsigned char *ptable; +} WRAP_DATA; +typedef struct +{ +unsigned short int ncells; +unsigned short int nbytes; +} WS_ALLOC_INFO; +typedef struct +{ +void *next; +void *object; +unsigned short int message; +} WS_TODAY_HOOK; +typedef struct +{ +unsigned short int len; +void *p; +} MEMO_DATA_PART; +typedef struct +{ +MEMO_DATA_PART body; +MEMO_DATA_PART styles; +MEMO_DATA_PART title; +} MEMO_DATA; +typedef struct +{ +void *owner; +unsigned short int method; +} MEMO_CALLBACK; +/* Property of wserv */ +typedef struct { +WS_EVENT_X ws; +PR_COMMAN *com; +PR_DLGCHAIN *dial; +PR_MENUBAR *bar; +PR_WIN *cli; +WSERV_INFO *info; +WSERV_INFO *oldinfo; +PR_WIN *filter; +int filmethod; +unsigned short int flags; +unsigned short int help_index_id; +unsigned short int help; +unsigned char lock; +unsigned char subdial; +char sc[10]; +unsigned short int locmask; +PR_ROOT *filelist; +PR_ROOT *anim; +PR_ROOT *printer; +} PRS_WSERV; +typedef struct pr_wserv +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_WSERV wserv; +} PR_WSERV; +/* Constants for hwimman */ +#define H_COMMAND_DEFAULT_FILE 'D' +#define H_COMMAND_OPEN_FILE 'O' +#define H_COMMAND_CREATE_FILE 'C' +#define H_COMMAND_EXIT 'X' +#define H_COMMAND_TRANSLATE_FILE 'T' +#define H_COMMAND_RUN_FILE 'R' +#define H_COMMAND_LAUNCH_DYL 'L' +#define H_COMMAND_BYPASS 'Z' +#define FLG_APPMAN_FULLSCREEN 0x1000 +#define FLG_APPMAN_LINKING 0x2000 +#define FLG_APPMAN_FROM_HWIF 0x4000 +#define FLG_APPMAN_OWNPRIO 0x8000 +#define FLG_APPMAN_S3FS 0x0100 +#define FLG_APPMAN_WSERV_MASK (PR_WSERV_FROM_HWIF|PR_WSERV_OWNPRIO|PR_WSERV_FULLSCREEN) +#define RUN_ACTIVE_CLEANUP_NONOTIFY -1 +/* Types for hwimman */ +typedef struct +{ +unsigned short int flags; +int wserv_cat; +unsigned short int wserv_class; +} IN_HWIMMAN; +/* Property of hwimman */ +typedef struct { +unsigned char contig; +unsigned char command; +char *defext; +char *aliasinfo; +PR_AIDLE *yield; +} PRS_HWIMMAN; +typedef struct pr_hwimman +{ +PRS_ROOT root; +PRS_APPMAN appman; +PRS_HWIMMAN hwimman; +} PR_HWIMMAN; diff --git a/code/SIBOSDK/include/hwimman.ing b/code/SIBOSDK/include/hwimman.ing new file mode 100644 index 0000000..16df6d8 --- /dev/null +++ b/code/SIBOSDK/include/hwimman.ing @@ -0,0 +1,223 @@ +; Generated by Ctran from hwimman.cl +HWIMMAN_ING equ 1 +IFNDEF PULLDOWN_ING + INCLUDE ..\inc\PULLDOWN.ING +ENDIF +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF COMMAN_ING + INCLUDE ..\inc\COMMAN.ING +ENDIF +IFNDEF MENUBAR_ING + INCLUDE ..\inc\MENUBAR.ING +ENDIF +; Class Numbers +C_WSERV equ 18 +C_HWIMMAN equ 19 +; Method Numbers +O_WS_SMART_DIAL equ 22 +O_AM_YIELD equ 16 +O_WS_GET_ALLOC_INFO equ 46 +O_WS_SELF_CHECK equ 48 +O_WS_BACKGROUND equ 39 +O_WS_REMOVE_DIAL equ 8 +O_WS_LOAD_CHLIST_RES equ 19 +O_WS_SET_MENUBAR equ 17 +O_WS_UNKNOWN_WM equ 37 +O_WS_GET_PRINT_CONTEXT equ 47 +O_WS_DIAL_ENV equ 23 +O_WS_DO_REMOTE_DIAL equ 53 +O_WS_REMOVE_FILELIST equ 33 +O_WS_ANIM_TICK equ 34 +O_WS_ERROR_DIALOG equ 13 +O_WS_SWITCH_FILES equ 35 +O_WS_FILE_INFO_PRINT equ 51 +O_WS_HIDE_APP equ 49 +O_WS_PROCESS_KEY equ 41 +O_WS_CHANGE_CLIWIN equ 10 +O_WS_ADD_DIAL equ 7 +O_WS_WRAP_PARA equ 12 +O_AM_ENSURE_IPCS equ 17 +O_WS_DYN_INIT equ 40 +O_WS_SENSE_PDEV_TEXT equ 28 +O_WS_EVAL_ENV equ 27 +O_WS_DO_SUBMENU equ 16 +O_WS_HOOK_TODAY_CHANGED equ 45 +O_WS_ENS_PRINT_CONTEXT equ 31 +O_WS_LOCK equ 24 +O_WS_APPEND_COUNTRY equ 20 +O_WS_LAUNCH_DYL equ 43 +O_WS_FOREGROUND equ 38 +O_WS_RUN_MEMO equ 52 +O_WS_ALERT equ 36 +O_WS_DO_HELP equ 15 +O_WS_DO_DIAL equ 6 +O_WS_ATTACH_APP equ 50 +O_WS_EDIT_PRINT_CONTEXT equ 30 +O_WS_ADD_FILELIST equ 32 +O_WS_CANCEL equ 11 +O_WS_SENSE_ACCEL equ 9 +O_WS_FORMAT_DIALOG equ 25 +O_WS_QUERY_DIALOG equ 14 +O_WS_DATE_CHANGED equ 42 +O_WS_FREE_DIAL equ 21 +O_WS_USER_ABANDONED equ 54 +O_AM_NEW_FILENAME equ 15 +O_WS_RESET_MENUBAR equ 18 +O_WS_DEFINE_FNBAR equ 44 +O_WS_EVALUATE equ 26 +O_WS_EDIT_PDEV_SETUP equ 29 +; Constants for wserv +PR_WSERV_CONNECT_AT_BACK equ (W_CONNECT_AT_BACK) +PR_WSERV_FOREGROUND equ (002h) +PR_WSERV_CLIWIN_KEY equ (004h) +PR_WSERV_CANCELLING equ (008h) +PR_WSERV_BASIC_HELP equ (010h) +PR_WSERV_FREEFORM_DIALLING equ (020h) +PR_WSERV_INSERT_MODE equ (040h) +PR_WSERV_INSERT_PENDING equ (080h) +PR_WSERV_OWN_DEFAULT_FONT equ (0100h) +PR_WSERV_RECEIVED_KEY equ (0200h) +PR_WSERV_HIDDEN equ (0400h) +PR_WSERV_METRIC equ (0800h) +PR_WSERV_FULLSCREEN equ (01000h) +PR_WSERV_CANCELLING_DIALOG equ (02000h) +PR_WSERV_FROM_HWIF equ (04000h) +PR_WSERV_OWNPRIO equ (08000h) +PR_WSERV_HELP_INDEX equ (001h) +WSERV_DTOB_HEX equ (3) +DEGREES_MODE equ (080h) +DTOB_MAX_WIDTH equ (20) +WS_EVAL_ENV_SET equ (0) +WS_EVAL_ENV_GET equ (1) +WS_DIAL_ENV_SET equ (0) +WS_DIAL_ENV_GET equ (1) +PDEV_TEXT_MAX_LEN equ (14) +WS_LOCCHG_LOW equ (00100h) +WS_LOCCHG_HIGH equ (04000h) +WS_EM_STYLES equ (001h) +WS_EM_PRINT_CONTEXT equ (002h) +WS_EM_REUSE_BODY_BUFFER equ (004h) +WS_EM_REUSE_STYLES_BUFFER equ (008h) +WS_EM_CALLBACK equ (040h) +MEMO_NO_CHANGE equ (0) +MEMO_NULL_LENGTH equ (1) +MEMO_STANDARD_CHANGE equ (2) +; Types for wserv +IN_WSERV struc +IN_WSERVCom_cat dw ? +IN_WSERVCom_class dw ? +IN_WSERV ends +WSERV_INFO struc +WSERV_INFOMenu db ? +WSERV_INFOMnitem db ? +WSERV_INFOMenubar_id dw ? +WSERV_INFOFirst_com db ? +WSERV_INFOCount db ? +WSERV_INFOAccel db (1) * 1 dup (?) +WSERV_INFO ends +DL_DATA struc +DL_DATAId dw ? +DL_DATARbuf dw ? +DL_DATAPdlg dw ? +DL_DATA ends +WS_HIDE_APP_DATA struc +WS_HIDE_APP_DATADupnp dw ? +WS_HIDE_APP_DATAHidden db (1) * 6 dup (?) +WS_HIDE_APP_DATA ends +WRAP_DATA struc +WRAP_DATAMargin dw ? +WRAP_DATAFmargin dw ? +WRAP_DATAFont dw ? +WRAP_DATAStyle dw ? +WRAP_DATANlines dw ? +WRAP_DATAPtable dw ? +WRAP_DATA ends +WS_ALLOC_INFO struc +WS_ALLOC_INFONcells dw ? +WS_ALLOC_INFONbytes dw ? +WS_ALLOC_INFO ends +WS_TODAY_HOOK struc +WS_TODAY_HOOKNext dw ? +WS_TODAY_HOOKObject dw ? +WS_TODAY_HOOKMessage dw ? +WS_TODAY_HOOK ends +MEMO_DATA_PART struc +MEMO_DATA_PARTLen dw ? +MEMO_DATA_PARTP dw ? +MEMO_DATA_PART ends +MEMO_DATA struc +MEMO_DATABody MEMO_DATA_PART <> +MEMO_DATAStyles MEMO_DATA_PART <> +MEMO_DATATitle MEMO_DATA_PART <> +MEMO_DATA ends +MEMO_CALLBACK struc +MEMO_CALLBACKOwner dw ? +MEMO_CALLBACKMethod dw ? +MEMO_CALLBACK ends +; Property of wserv +PRS_WSERV struc +WservWs WS_EVENT_X <> +WservCom dw ? +WservDial dw ? +WservBar dw ? +WservCli dw ? +WservInfo dw ? +WservOldinfo dw ? +WservFilter dw ? +WservFilmethod dw ? +WservFlags dw ? +WservHelp_index_id dw ? +WservHelp dw ? +WservLock db ? +WservSubdial db ? +WservSc db (1) * 10 dup (?) +WservLocmask dw ? +WservFilelist dw ? +WservAnim dw ? +WservPrinter dw ? +PRS_WSERV ends +PR_WSERV struc +WservRoot PRS_ROOT <> +WservActive PRS_ACTIVE <> +WservWserv PRS_WSERV <> +PR_WSERV ends +; Constants for hwimman +H_COMMAND_DEFAULT_FILE equ ('D') +H_COMMAND_OPEN_FILE equ ('O') +H_COMMAND_CREATE_FILE equ ('C') +H_COMMAND_EXIT equ ('X') +H_COMMAND_TRANSLATE_FILE equ ('T') +H_COMMAND_RUN_FILE equ ('R') +H_COMMAND_LAUNCH_DYL equ ('L') +H_COMMAND_BYPASS equ ('Z') +FLG_APPMAN_FULLSCREEN equ (01000h) +FLG_APPMAN_LINKING equ (02000h) +FLG_APPMAN_FROM_HWIF equ (04000h) +FLG_APPMAN_OWNPRIO equ (08000h) +FLG_APPMAN_S3FS equ (00100h) +FLG_APPMAN_WSERV_MASK equ (PR_WSERV_FROM_HWIF or PR_WSERV_OWNPRIO or PR_WSERV_FULLSCREEN) +RUN_ACTIVE_CLEANUP_NONOTIFY equ (-1) +; Types for hwimman +IN_HWIMMAN struc +IN_HWIMMANFlags dw ? +IN_HWIMMANWserv_cat dw ? +IN_HWIMMANWserv_class dw ? +IN_HWIMMAN ends +; Property of hwimman +PRS_HWIMMAN struc +HwimmanContig db ? +HwimmanCommand db ? +HwimmanDefext dw ? +HwimmanAliasinfo dw ? +HwimmanYield dw ? +PRS_HWIMMAN ends +PR_HWIMMAN struc +HwimmanRoot PRS_ROOT <> +HwimmanAppman PRS_APPMAN <> +HwimmanHwimman PRS_HWIMMAN <> +PR_HWIMMAN ends diff --git a/code/SIBOSDK/include/io.h b/code/SIBOSDK/include/io.h new file mode 100644 index 0000000..2187c69 --- /dev/null +++ b/code/SIBOSDK/include/io.h @@ -0,0 +1,72 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* io.h - Definitions for low level I/O functions. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _IO_INC_ +#define _IO_INC_ + +struct ftime { + unsigned ft_tsec : 5; /* Two second interval */ + unsigned ft_min : 6; /* Minutes */ + unsigned ft_hour : 5; /* Hours */ + unsigned ft_day : 5; /* Days */ + unsigned ft_month : 4; /* Months */ + unsigned ft_year : 7; /* Year */ +}; + +#define HANDLE_MAX 20U +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +extern unsigned _openfd[HANDLE_MAX]; + +#ifdef __cplusplus +extern "C" { +#endif +extern int access(const char *_path, int _access); +extern int chmod(const char *_path, int _mode); +extern int _chmod(const char *_path, int _func, int _mode); +extern int chsize(int _handle, long _size); +extern int close(int _handle); +extern int _close(int _handle); +extern int creat(const char *_path, int _access); +extern int _creat(const char *_path, int _permission); +extern int _creat_trunc(const char *_path, int _permission); +extern int creatnew(const char *_path, int _premission); +extern int _creat_new(const char *_path, int _permission); +extern int creattemp(const char *_path, int _permission); +extern int _creat_temp(char *_path, int _permission); +extern int dup(int _handle); +extern int dup2(int _oldhandle, int _newhandle); +extern int eof(int _handle); +extern int _dup(int _handle); +extern int _dup2(int _oldhandle, int _newhandle); +extern int _eof(int _handle); +extern long filelength(int _handle); +extern int _filedrive(int _handle); +extern int getftime(int _handle, struct ftime *_ftimep); +extern int isatty(int _handle); +extern long lseek(int _handle, long _offset, int _fromwhere); +extern int open(const char *_path, int _access,... /*unsigned mode*/); +extern int _open(const char *_path, int _oflags); +extern int read(int _handle, void *_buf, unsigned _num); +extern int _read(int _handle, void *_buf, unsigned _num); +extern int setmode(int _handle, unsigned _mode); +extern int sopen(const char *_path, int _access, int _shflag, ... /*unsigned mode*/); +extern long tell(int _handle); +extern unsigned umask(unsigned _cmask); +extern int unlink(const char *_path); +extern int write(int _handle, void *_buf, unsigned _num); +extern int _write(int _handle, const void *_buf, unsigned _num); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/iomanip.hpp b/code/SIBOSDK/include/iomanip.hpp new file mode 100644 index 0000000..95ffff4 --- /dev/null +++ b/code/SIBOSDK/include/iomanip.hpp @@ -0,0 +1,113 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* IOMANIP.HPP - header file for pasting I/O manipulators. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef __IOMANIP_INC_ +#define __IOMANIP_INC_ + +#include +#include + +#define SMANIP(type) _PASTE2(smanip_, type) +#define SAPP(type) _PASTE2(sapply_, type) +#define IMANIP(type) _PASTE2(imanip_, type) +#define OMANIP(type) _PASTE2(omanip_, type) +#define IOMANIP(type) _PASTE2(iomanip_, type) +#define IAPP(type) _PASTE2(iapply_, type) +#define OAPP(type) _PASTE2(oapply_, type) +#define IOAPP(type) _PASTE2(ioapply_, type) + +#define IOMANIPdeclare(type) \ +class SMANIP(type) { \ + ios& (*_fn)(ios&, type); \ + type _ag; \ +public: \ + SMANIP(type)(ios& (*_f)(ios&, type), type _a) : _fn(_f), _ag(_a) { } \ + friend istream& operator>>(istream& _s, const SMANIP(type)& _f) { \ + (*_f._fn)(_s, _f._ag); return _s; } \ + friend ostream& operator<<(ostream& _s, const SMANIP(type)& _f) { \ + (*_f._fn)(_s, _f._ag); return _s; } \ +}; \ +class SAPP(type) { \ + ios& (*_fn)(ios&, type); \ +public: \ + SAPP(type)(ios& (*_f)(ios&, type)) : _fn(_f) { } \ + SMANIP(type) operator()(type _z) { return SMANIP(type)(_fn, _z); } \ +}; \ +class IMANIP(type) { \ + istream& (*_fn)(istream&, type); \ + type _ag; \ +public: \ + IMANIP(type)(istream& (*_f)(istream&, type), type _z ) : \ + _fn(_f), _ag(_z) { } \ + friend istream& operator>>(istream& _s, const IMANIP(type)& _f) { \ + return(*_f._fn)(_s, _f._ag); } \ +}; \ +class IAPP(type) { \ + istream& (*_fn)(istream&, type); \ +public: \ + IAPP(type)(istream& (*_f)(istream&, type)) : _fn(_f) { } \ + IMANIP(type) operator()(type _z) { \ + return IMANIP(type)(_fn, _z); } \ +}; \ +class OMANIP(type) { \ + ostream& (*_fn)(ostream&, type); \ + type _ag; \ +public: \ + OMANIP(type)(ostream& (*_f)(ostream&, type), type _z ) : \ + _fn(_f), _ag(_z) { } \ + friend ostream& operator<<(ostream& _s, const OMANIP(type)& _f) { \ + return(*_f._fn)(_s, _f._ag); } \ +}; \ +class OAPP(type) { \ + ostream& (*_fn)(ostream&, type); \ +public: \ + OAPP(type)(ostream& (*_f)(ostream&, type)) : _fn(_f) { } \ + OMANIP(type) operator()(type _z) { return OMANIP(type)(_fn, _z); } \ +}; \ +class IOMANIP(type) { \ + iostream& (*_fn)(iostream&, type); \ + type _ag; \ +public: \ + IOMANIP(type)(iostream& (*_f)(iostream&, type), type _z ) : \ + _fn(_f), _ag(_z) { } \ + friend istream& operator>>(iostream& _s, const IOMANIP(type)& _f) { \ + return(*_f._fn)(_s, _f._ag); } \ + friend ostream& operator<<(iostream& _s, const IOMANIP(type)& _f) { \ + return(*_f._fn)(_s, _f._ag); } \ +}; \ +class IOAPP(type) { \ + iostream& (*_fn)(iostream&, type); \ +public: \ + IOAPP(type)(iostream& (*_f)(iostream&, type)) : _fn(_f) { } \ + IOMANIP(type) operator()(type _z) { return IOMANIP(type)(_fn, _z); } \ +} + + +//CEP 6/7/91 +#pragma save,warn(wpnu=>off) +IOMANIPdeclare(int); +IOMANIPdeclare(long); +#pragma restore + +smanip_int setbase(int _b); + +smanip_long resetiosflags(long _b); + +smanip_long setiosflags(long _b); + +smanip_int setfill(int _f); + +smanip_int setprecision(int _n); + +smanip_int setw(int _n); + +#endif + \ No newline at end of file diff --git a/code/SIBOSDK/include/iostream.hpp b/code/SIBOSDK/include/iostream.hpp new file mode 100644 index 0000000..0448aa1 --- /dev/null +++ b/code/SIBOSDK/include/iostream.hpp @@ -0,0 +1,700 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* IOSTREAM.HPP - header file for stream input and output. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _IOSTREAM_INC_ +#define _IOSTREAM_INC_ + +#include + +#ifdef EOF +#if EOF != -1 +#undef EOF +#define EOF (-1) +#endif +#else +#define EOF (-1) +#endif + +#define zapeof(c) ((c)&0xFF) + +typedef long streampos; +typedef long streamoff; + +class streambuf; +class ostream; + +class ios { + +public: + enum io_state { + goodbit = 0x00, + eofbit = 0x01, + failbit = 0x02, + badbit = 0x04, + hardfail = 0x80 + }; + + enum open_mode { + in = 0x01, + out = 0x02, + ate = 0x04, + app = 0x08, + trunc = 0x10, + nocreate = 0x20, + noreplace = 0x40, + binary = 0x80 + }; + + enum seek_dir { + beg=0, + cur=1, + end=2 + }; + + enum { + skipws = 0x0001, + left = 0x0002, + right = 0x0004, + internal = 0x0008, + dec = 0x0010, + oct = 0x0020, + hex = 0x0040, + showbase = 0x0080, + showpoint = 0x0100, + uppercase = 0x0200, + showpos = 0x0400, + scientific = 0x0800, + fixed = 0x1000, + unitbuf = 0x2000, + stdio = 0x4000 + }; + + static const long basefield; + static const long adjustfield; + static const long floatfield; + + ios(streambuf* _buffer); + virtual ~ios(); + + long flags(); + long flags(long _fl); + long setf(long _setbits, long _fld); + long setf(long _fld); + long unsetf(long _fld); + + int width(); + int width(int _w); + + char fill(); + char fill(char _f); + + int precision(); + int precision(int _p); + + ostream* tie(); + ostream* tie(ostream* _ost); + + int rdstate(); + int eof(); + int fail(); + int bad(); + int good(); + void clear(int = 0); + operator void* (); + int operator! (); + streambuf* rdbuf(); + + static long bitalloc(); + static int xalloc(); + long& iword(int); + void*& pword(int); + + static void sync_with_stdio(); + + int skip(int); + +protected: + + enum { + translate = 0x080, + skipping = 0x100, + tied = 0x200 + }; + + streambuf *_bp; + ostream* x_tie; + int state; + int ispecial; + int ospecial; + long x_flags; + int x_precision; + int x_width; + int x_fill; + int isfx_special; + int osfx_special; + int delbuf; + int assign_private; + + ios(); + void init(streambuf* _buffer); + void setstate(int); + static void (*stdioflush)(); + +private: + + union ios_user_union { + long x; + void *p; + }; + + static long nextbit; + static int usercount; + union ios_user_union *userwords; + int nwords; + void uresize(int); + + ios(ios&); // not implemented + void operator= (ios&); // not implemented +}; + +#ifdef _SMALL_INLINE +inline streambuf* ios::rdbuf() { return _bp;} +inline ostream* ios::tie() { return x_tie;} +inline char ios::fill() { return x_fill; } +inline int ios::precision() { return x_precision; } +inline int ios::rdstate() { return state; } +inline int ios::eof() { return (state&eofbit); } +inline int ios::fail() { return (state&(failbit|badbit|hardfail)); } +inline int ios::bad() { return (state&(badbit|hardfail)); } +inline int ios::good() { return (state == 0); } +inline long ios::flags() { return x_flags; } +inline int ios::width() { return x_width; } +inline int ios::width(int _w) { int _temp = x_width; + x_width = _w; + return _temp; } +inline char ios::fill(char _w) { char _temp = x_fill; + x_fill = _w; + return _temp; } +inline int ios::precision(int _w) { int _temp = x_precision; + x_precision = _w; + return _temp; } + +inline ios::operator void* () {return (fail()|eof()) ? 0 : this; } +inline ios::operator! () {return (fail()|eof()); } +#endif + + +class streambuf { + +public: + + streambuf(); + streambuf(char * _buf, int _size); + virtual ~streambuf(); + + virtual streambuf* setbuf(char * _buf, int _size); + virtual streambuf* setbuf(char * _buf, int , int); + + int sgetc(); + int snextc(); + int sbumpc(); + void stossc(); + int sgetn(char *_s, int _num); + virtual int do_sgetn(char *_s, int _num); + virtual int underflow(); + int sputbackc(char _c); + virtual int pbackfail(int); + int in_avail(); + + int sputc(int _c); + virtual int do_sputn(const char *_s, int _num); + int sputn(const char *_s, int _num); + virtual int overflow(int _c = EOF); + int out_waiting(); + + virtual streampos seekoff(streamoff, ios::seek_dir, int = (ios::in | ios::out)); + virtual streampos seekpos(streamoff, int = (ios::in | ios::out)); + virtual int sync(); + int dbp(); + +protected: + + char *base(); + char *ebuf(); + int blen(); + char *pbase(); + char *pptr(); + char *epptr(); + char *eback(); + char *gptr(); + char *egptr(); + void setp(char *, char *); + void setg(char *, char *, char *); + void pbump(int); + void gbump(int); + void setb(char *, char *, int = 0); + void unbuffered(int); + int unbuffered(); + int allocate(); + virtual int doallocate(); + +private: + short _alloc; + short _unbuf; + char *_base; + char *_ebuf; + char *_pbase; + char *_pptr; + char *_epptr; + char *_eback; + char *_gptr; + char *_egptr; + + streambuf(streambuf&); + void operator= (streambuf&); + + int do_snextc(); +}; +#ifdef _SMALL_INLINE +inline char * streambuf::base() { return _base; } +inline char * streambuf::pbase() { return _pbase; } +inline char * streambuf::pptr() { return _pptr; } +inline char * streambuf::epptr() { return _epptr; } +inline char * streambuf::gptr() { return _gptr; } +inline char * streambuf::egptr() { return _egptr; } +inline char * streambuf::eback() { return _eback; } +inline char * streambuf::ebuf() { return _ebuf; } + +inline int streambuf::unbuffered() { return _unbuf; } +inline int streambuf::blen() { return (int) (_ebuf - _base); } + +inline void streambuf::pbump(int _n) { _pptr += _n; } +inline void streambuf::gbump(int _n) { _gptr += _n; } +inline void streambuf::unbuffered(int _ub) { _unbuf = (_ub != 0); } +inline int streambuf::in_avail() { return (_egptr > _gptr) ? + (int)(_egptr - _gptr): 0; } +inline int streambuf::out_waiting() { return _pptr ? + (int)(_pptr - _pbase): 0; } +inline int streambuf::allocate() { return((_base || _unbuf) ? 0 : doallocate()); } + +inline int streambuf::sgetc() { return ((_gptr >= _egptr) ? underflow() : + (unsigned char) *_gptr); } + +inline int streambuf::snextc() { return ((++_gptr >= _egptr) ? + do_snextc() : + (unsigned char) *_gptr); } + +inline int streambuf::sbumpc() { return ((_gptr >= _egptr) + && (underflow() == EOF) ? + EOF : + (unsigned char) *_gptr++); } +inline void streambuf::stossc() { if (_gptr >= _egptr) + underflow(); + else + ++_gptr; } + +inline int streambuf::sputbackc(char _c) { return (_gptr > _eback) ? + *--_gptr = _c : + pbackfail(_c) ; } + +inline int streambuf::sputc(int _c) { return (_pptr >= _epptr) ? + overflow(_c) : + (*_pptr++=_c, _c); } + +#ifdef _BIG_INLINE +inline int streambuf::sputn(const char *_s, int _n) { + if(_n <= (_epptr - _pptr)) { + memcpy(_pptr, _s, _n); + pbump(_n); + return _n; + } + return do_sputn(_s, _n); } + +inline int streambuf::sgetn(char *_s, int _n) { + if(_n <= (_egptr - _gptr)) { + memcpy(_s, _gptr, _n); + gbump(_n); + return _n; + } + return do_sgetn(_s, _n); } + +#endif +#endif +class istream : virtual public ios { + +public: + + istream(streambuf*); + istream(streambuf*, int _sk, ostream* _t=NULL); + istream(int _sz, char *, int _sk=1); + istream(int _fd, int _sk=1, ostream* _t=NULL); + virtual ~istream(); + + int ipfx(int = 0); + int ipfx0(); + int ipfx1(); + void isfx() {} + + istream& seekg(streampos); + istream& seekg(streamoff, ios::seek_dir); + streampos tellg(); + + int sync(); + + istream& get( signed char*, int, char = '\n'); + istream& get(unsigned char*, int, char = '\n'); + istream& get( char*, int, char = '\n'); + istream& read( signed char*, int); + istream& read(unsigned char*, int); + istream& read( char*, int); + istream& getline( signed char*, int, char = '\n'); + istream& getline(unsigned char*, int, char = '\n'); + istream& getline( char*, int, char = '\n'); + + istream& get(streambuf&, char = '\n'); + istream& get( signed char&); + istream& get(unsigned char&); + istream& get( char&); + int get(); + + int peek(); + int gcount(); + istream& putback(char); + istream& ignore(int = 1, int = EOF); + + istream& operator>> (istream& (*_f)(istream&)); + istream& operator>> (ios& (*_f)(ios&)); + istream& operator>> ( signed char*); + istream& operator>> (unsigned char*); + istream& operator>> ( char*); + istream& operator>> ( signed char&); + istream& operator>> (unsigned char&); + istream& operator>> ( char&); + istream& operator>> (short&); + istream& operator>> (int&); + istream& operator>> (long&); + istream& operator>> (unsigned short&); + istream& operator>> (unsigned int&); + istream& operator>> (unsigned long&); + istream& operator>> (float&); + istream& operator>> (double&); + istream& operator>> (long double&); + + istream& operator>> (streambuf*); + +protected: + + istream(); + int do_ipfx(int); + void eatwhite(); + +private: + + int _gcount; + int do_get(); +}; + +#ifdef _SMALL_INLINE +inline int istream::gcount() { return _gcount; } + +inline int istream::ipfx(int _need) { if( _need ? (ispecial&~skipping) : + ispecial) + return do_ipfx(_need); + return 1; } + +inline int istream::ipfx0() { return ispecial ? do_ipfx(0) : 1; } + +inline int istream::ipfx1() { return (ispecial&~skipping) ? do_ipfx(1) : 1; } + +inline istream& istream::operator>>(unsigned char& _c) { + if(ipfx0()) { + if(_bp->in_avail()) + _c = _bp->sbumpc(); + else + _c = do_get(); + } + return *this; } + +inline istream& istream::operator>>(signed char& _c) { + if(ipfx0()) { + if(_bp->in_avail()) + _c = _bp->sbumpc(); + else + _c = do_get(); + } + return *this; } + +inline istream& istream::operator>>( char& _c) { + if(ipfx0()) { + if(_bp->in_avail()) + _c = _bp->sbumpc(); + else + _c = do_get(); + } + return *this; } + +inline istream& istream::operator>>(unsigned char* _s) { + return *this>>(signed char *) _s; } + +inline istream& istream::operator>>( char* _s) { + return *this>>(signed char *) _s; } + +inline istream& istream::get(unsigned char* _s, int _l, char _t) { + return get((signed char *)_s, _l, _t); } + +inline istream& istream::get( char* _s, int _l, char _t) { + return get((signed char *)_s, _l, _t); } + +#ifdef _BIG_INLINE_ +inline istream& istream::get(unsigned char& _c) { + if( ipfx1() ) { + if( _bp->in_avail() ) { + _gcount = 1; + _c = _bp->sbumpc(); + } + else + _c = do_get(); + } + return *this; } + +inline istream& istream::get(signed char& _c) { + if( ipfx1() ) { + if( _bp->in_avail()) { + _gcount = 1; + _c = _bp->sbumpc(); + } + else + _c = do_get(); + } + return *this; } + + +inline istream& istream::get( char& _c) { + if( ipfx1() ) { + if( _bp->in_avail()) { + _gcount = 1; + _c = _bp->sbumpc(); + } + else + _c = do_get(); + } + return *this; } + +inline int istream::get() { + if( ipfx1() ) { + int _c = _bp->sbumpc(); + if( _c == EOF ) + setstate(eofbit); + else _gcount = 1; + return _c; + } + return EOF; } + +#endif + +inline istream& istream::read(unsigned char* _s, int _l) { + return read((signed char *)_s, _l); } + +inline istream& istream::read( char* _s, int _l) { + return read((signed char *)_s, _l); } + +inline istream& istream::getline(unsigned char* _s, int _l, char _t) { + return getline((signed char *)_s, _l, _t); } + +inline istream& istream::getline( char* _s, int _l, char _t) { + return getline((signed char *)_s, _l, _t); } + +inline int istream::sync() { return _bp->sync(); } + +inline istream& istream::operator>> (istream& (*_f)(istream&)) { + return (*_f)(*this); } + +inline int istream::peek() { return ipfx1() ? _bp->sgetc() : EOF; } + +#endif + +class ostream : virtual public ios { + +public: + + + ostream(streambuf *); + ~ostream(); + + ostream(int _fd); + ostream(int _sz, char *); + + int opfx(); + void osfx(); + ostream& flush(); + + ostream& seekp(streampos); + ostream& seekp(streamoff, ios::seek_dir); + streampos tellp(); + + ostream& put(char); + ostream& write(const char*, int); + ostream& write(const signed char*, int); + ostream& write(const unsigned char*, int); + + ostream& operator<<( signed char); + ostream& operator<<(unsigned char); + ostream& operator<<( char); + ostream& operator<<( signed short); + ostream& operator<<(unsigned short); + ostream& operator<<( signed int); + ostream& operator<<(unsigned int); + ostream& operator<<( signed long); + ostream& operator<<(unsigned long); + ostream& operator<<(float); + ostream& operator<<(double); + ostream& operator<<(long double); + ostream& operator<<(const char *); + ostream& operator<<(const signed char *); + ostream& operator<<(const unsigned char *); + ostream& operator<<(void *); + + ostream& operator<<(streambuf*); + ostream& operator<<(ostream& (*_f)(ostream&)); + ostream& operator<<(ios& (*_f)(ios&)); + +protected: + + ostream(); + int do_opfx(); + int do_osfx(); + +private: + + void outlong(unsigned long, int); + void outstr(const char *); +}; + +#ifdef _SMALL_INLINE +inline int ostream::opfx() { return ospecial ? do_opfx() : 1; } + +inline void ostream::osfx() { if((x_flags&(stdio|unitbuf)) || (ospecial)) do_osfx(); } + +inline ostream& ostream::operator<<(unsigned char _c) { + return *this <<(signed char ) _c; } + +inline ostream& ostream::operator<<( char _c) { + return *this <<(signed char ) _c; } + +inline ostream& ostream::operator<<(short _i) { return *this<<(long)_i; } + +inline ostream& ostream::operator<<(unsigned short _i) { + return *this<<(unsigned long)_i; } + +inline ostream& ostream::operator<<(int _i) { return *this<<(long)_i; } + +inline ostream& ostream::operator<<(unsigned int _i) { + return *this<<(unsigned long)_i; } + +inline ostream& ostream::operator<<(float _f) { + return *this<<(long double)_f; } + +inline ostream& ostream::operator<<(double _f) { + return *this<<(long double)_f; } + +inline ostream& ostream::operator<<(ostream& (*_f)(ostream&)) { + return (*_f)(*this); } + +inline ostream& ostream::write(const signed char *_s, int _n) { + return write((const char *)_s, _n); } + +inline ostream& ostream::write(const unsigned char *_s, int _n) { + return write((const char *)_s, _n); } + +inline ostream& ostream::put(char _c) { + if(_bp->sputc(_c) == EOF) + setstate(badbit); + return *this; } + +inline ostream& ostream::operator<<(const signed char *_s) { + return *this<<(const char *) _s; } + +inline ostream& ostream::operator<<(const unsigned char *_s) { + return *this<<(const char *) _s; } +#endif + +class iostream : public istream , public ostream { + +public: + + iostream(streambuf*); + virtual ~iostream(); + +protected: + iostream(); + +}; + + +class istream_withassign : public istream { + +public: + + istream_withassign(); + virtual ~istream_withassign(); + + istream_withassign& operator= (istream&); + istream_withassign& operator= (streambuf*); + +private: + + unsigned assign_const; +}; + +class ostream_withassign : public ostream { + +public: + + ostream_withassign(); + virtual ~ostream_withassign(); + + ostream_withassign& operator= (ostream&); + ostream_withassign& operator= (streambuf*); + +private: + + unsigned assign_const; +}; + +class iostream_withassign : public iostream { + +public: + + iostream_withassign(); + virtual ~iostream_withassign(); + + iostream_withassign& operator= (ios&); + iostream_withassign& operator= (streambuf*); + +private: + + unsigned assign_const; +}; + +extern istream_withassign cin; +extern ostream_withassign cout; +extern ostream_withassign cerr; +extern ostream_withassign clog; + +ostream& endl(ostream&); +ostream& ends(ostream&); +ostream& flush(ostream&); +istream& ws(istream&); +ios& dec(ios&); +ios& hex(ios&); +ios& oct(ios&); +#endif + diff --git a/code/SIBOSDK/include/ipc.g b/code/SIBOSDK/include/ipc.g new file mode 100644 index 0000000..cfd8f1b --- /dev/null +++ b/code/SIBOSDK/include/ipc.g @@ -0,0 +1,266 @@ +/* Generated by Ctran from ipc.cat */ +#define IPC_G +#ifndef APPMAN_G +#include +#endif +#ifndef P_FILE_H +#include +#endif +/* Class Numbers */ +#define C_SERVER 16 +#define C_LINKSV 17 +#define C_LINKCL 18 +#define C_TOPLIP 19 +#define C_EXOPL 20 +#define C_CMAP 21 +#define C_VOICE 22 +#define C_NOTIFY 23 +#define C_CONSOL 24 +/* Method Numbers */ +#define O_CM_AUTOWRAP 9 +#define O_NO_DRAW 7 +#define O_CO_DRAW 6 +#define O_CO_KEY 4 +#define O_CM_INSERT 2 +#define O_SV_INIT 2 +#define O_LC_START 1 +#define O_CM_ATTRIB 12 +#define O_CO_EDIT 10 +#define O_CM_RECT 3 +#define O_TIP_COMPLETE 6 +#define O_CM_SENSE_SIZE 7 +#define O_CO_SIZE 8 +#define O_CM_ENQ_DRAW 4 +#define O_CO_ESC 9 +#define O_SV_RUN 3 +#define O_CM_SENSE_CPOS 5 +#define O_CM_SCROLL 11 +#define O_CO_EXTRA 5 +#define O_TIP_GETLINE 5 +#define O_TIP_START 4 +#define O_LS_GET_DATA 5 +#define O_CM_SET_CPOS 6 +#define O_CO_CURSOR 7 +#define O_LC_GET_DATA 2 +#define O_LC_STOP 3 +#define O_CM_POINT_ROW 8 +#define O_LS_SET_FORMAT 4 +#define O_CM_SCROLLOCK 10 +#define O_CM_INIT 1 +#define O_SV_ABRUN 1 +/* Property of server */ +typedef struct { +P_QUE q; +unsigned short int t1; +unsigned short int t2; +unsigned short int cid; +} PRS_SERVER; +typedef struct pr_server +{ +PRS_ROOT root; +PRS_SERVER server; +} PR_SERVER; +/* Constants for linksv */ +#define TY_LINKSV_STEP 0x21 +#define TY_LINKSV_DEATH 0x22 +#define DF_LINK_NATIVE 0 +#define DF_LINK_TEXT 1 +#define DF_LINK_TABTEXT 2 +#define DF_LINK_VOICE 3 +#define DF_LINK_PARAS 4 +#define DF_LINK_SPR 5 +#define DF_LINK_WRD 6 +#define DF_LINK_AGD 7 +/* Property of linksv */ +typedef struct { +unsigned char *buf; +unsigned short int len; +} PRS_LINKSV; +typedef struct pr_linksv +{ +PRS_ROOT root; +PRS_SERVER server; +PRS_LINKSV linksv; +} PR_LINKSV; +/* Property of linkcl */ +typedef struct { +unsigned short int pid; +} PRS_LINKCL; +typedef struct pr_linkcl +{ +PRS_ROOT root; +PRS_LINKCL linkcl; +} PR_LINKCL; +/* Constants for toplip */ +#define TY_TOPLIP_LINE 0x10 +#define TY_TOPLIP_DEATH 0x11 +/* Types for toplip */ +typedef struct +{ +short int stat; +unsigned short int mode; +unsigned short int line; +unsigned short int offset; +} PR_TOPLIP_STATUS; +typedef struct +{ +unsigned short int pid; +char *bofs; +PR_TOPLIP_STATUS *sofs; +} PR_TOPLIP_SOURCE; +/* Property of toplip */ +typedef struct { +PR_TOPLIP_STATUS st; +char buf[256]; +} PRS_TOPLIP; +typedef struct pr_toplip +{ +PRS_ROOT root; +PRS_SERVER server; +PRS_TOPLIP toplip; +} PR_TOPLIP; +/* Constants for exopl */ +#define EXOPL_ISEXP 0x01 +#define EXOPL_SIGNAL 0x02 +#define EXOPL_NTFY 0x04 +/* Types for exopl */ +typedef struct +{ +double value; +short int error; +unsigned short int line; +unsigned short int offset; +char src[P_FNAMESIZE]; +} EXOPL_RESBUF; +typedef struct +{ +unsigned short int flags; +short int cid; +unsigned char *qofs; +unsigned short int qlen; +EXOPL_RESBUF *rofs; +} EXOPL_PAR; +/* Property of exopl */ +typedef struct { +EXOPL_RESBUF result; +} PRS_EXOPL; +typedef struct pr_exopl +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_EXOPL exopl; +} PR_EXOPL; +/* Constants for cmap */ +#define DR_CMAP_END 0 +#define DR_CMAP_TEXT 1 +#define DR_CMAP_SPACES 2 +#define DR_CMAP_SCROLL 3 +#define OP_CMAP_CLEAR 1 +#define OP_CMAP_INVALID 2 +/* Types for cmap */ +typedef struct +{ +unsigned short int len; +unsigned char *buf; +unsigned char row; +unsigned char col; +} PR_CMAP_DRAW; +/* Property of cmap */ +typedef struct { +unsigned char *base; +unsigned short int toprow; +unsigned short int width; +unsigned short int height; +unsigned short int row; +unsigned short int col; +short int scroll; +unsigned char wrap; +unsigned char slock; +} PRS_CMAP; +typedef struct pr_cmap +{ +PRS_ROOT root; +PRS_CMAP cmap; +} PR_CMAP; +/* Constants for voice */ +#define TY_VOICE_PLAY 0 +#define TY_VOICE_EDIT 1 +#define TY_VOICE_CANCEL 2 +/* Types for voice */ +typedef struct +{ +short int *pstat; +unsigned char *buf; +unsigned short int len; +unsigned short int maxlen; +} RQ_VOICE_MSG; +/* Property of voice */ +typedef struct { +PR_ROOT *owner; +unsigned short int method; +} PRS_VOICE; +typedef struct pr_voice +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_VOICE voice; +} PR_VOICE; +/* Constants for notify */ +#define NOTIFY_MESS_TYPE 0 +#define NOTIFY_MESS_ARGS 5 +#define NOTIFY_MESS_SIZE 64 +/* Property of notify */ +typedef struct { +unsigned char err0text[NOTIFY_MESS_SIZE]; +unsigned char err1text[NOTIFY_MESS_SIZE]; +unsigned char but0text[NOTIFY_MESS_SIZE]; +unsigned char but1text[NOTIFY_MESS_SIZE]; +unsigned char but2text[NOTIFY_MESS_SIZE]; +unsigned char pname[NOTIFY_MESS_SIZE]; +} PRS_NOTIFY; +typedef struct pr_notify +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_IPCS ipcs; +PRS_NOTIFY notify; +} PR_NOTIFY; +/* Constants for consol */ +#define CONSOL_MESS_READ 0 +#define CONSOL_MESS_WRITE 1 +#define CONSOL_MESS_CLOSE 2 +#define CONSOL_MESS_SET 3 +#define CONSOL_MESS_SENSE 4 +#define CONSOL_MESS_TEST 5 +#define CONSOL_MESS_FLUSH 6 +#define CONSOL_MESS_CANCEL 7 +#define CONSOL_MESS_EDIT 8 +#define CONSOL_MESS_SPARE1 9 +#define CONSOL_MESS_SPARE2 10 +#define CONSOL_MESS_SPARE3 11 +#define CONSOL_MESS_SPARE4 12 +#define CONSOL_MESS_DIED 13 +#define CONSOL_KEY_TYPE_AHEAD 32 +#define CONSOL_MAX_STRING 255 +/* Types for consol */ +typedef struct +{ +unsigned short int keycode; +unsigned char modifiers; +unsigned char count; +} PR_CONSOL_WMSG_KEY; +/* Property of consol */ +typedef struct { +PR_CMAP *cmap; +unsigned short int rcomp; +unsigned char *rmess; +PR_CONSOL_WMSG_KEY *head; +PR_CONSOL_WMSG_KEY *tail; +PR_CONSOL_WMSG_KEY list[CONSOL_KEY_TYPE_AHEAD]; +} PRS_CONSOL; +typedef struct pr_consol +{ +PRS_ROOT root; +PRS_SERVER server; +PRS_CONSOL consol; +} PR_CONSOL; diff --git a/code/SIBOSDK/include/ipc.ing b/code/SIBOSDK/include/ipc.ing new file mode 100644 index 0000000..cd3c934 --- /dev/null +++ b/code/SIBOSDK/include/ipc.ing @@ -0,0 +1,250 @@ +; Generated by Ctran from ipc.cat +IPC_ING equ 1 +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +; Class Numbers +C_SERVER equ 16 +C_LINKSV equ 17 +C_LINKCL equ 18 +C_TOPLIP equ 19 +C_EXOPL equ 20 +C_CMAP equ 21 +C_VOICE equ 22 +C_NOTIFY equ 23 +C_CONSOL equ 24 +; Method Numbers +O_CM_AUTOWRAP equ 9 +O_NO_DRAW equ 7 +O_CO_DRAW equ 6 +O_CO_KEY equ 4 +O_CM_INSERT equ 2 +O_SV_INIT equ 2 +O_LC_START equ 1 +O_CM_ATTRIB equ 12 +O_CO_EDIT equ 10 +O_CM_RECT equ 3 +O_TIP_COMPLETE equ 6 +O_CM_SENSE_SIZE equ 7 +O_CO_SIZE equ 8 +O_CM_ENQ_DRAW equ 4 +O_CO_ESC equ 9 +O_SV_RUN equ 3 +O_CM_SENSE_CPOS equ 5 +O_CM_SCROLL equ 11 +O_CO_EXTRA equ 5 +O_TIP_GETLINE equ 5 +O_TIP_START equ 4 +O_LS_GET_DATA equ 5 +O_CM_SET_CPOS equ 6 +O_CO_CURSOR equ 7 +O_LC_GET_DATA equ 2 +O_LC_STOP equ 3 +O_CM_POINT_ROW equ 8 +O_LS_SET_FORMAT equ 4 +O_CM_SCROLLOCK equ 10 +O_CM_INIT equ 1 +O_SV_ABRUN equ 1 +; Property of server +PRS_SERVER struc +ServerQ P_QUE <> +ServerT1 dw ? +ServerT2 dw ? +ServerCid dw ? +PRS_SERVER ends +PR_SERVER struc +ServerRoot PRS_ROOT <> +ServerServer PRS_SERVER <> +PR_SERVER ends +; Constants for linksv +TY_LINKSV_STEP equ (021h) +TY_LINKSV_DEATH equ (022h) +DF_LINK_NATIVE equ (0) +DF_LINK_TEXT equ (1) +DF_LINK_TABTEXT equ (2) +DF_LINK_VOICE equ (3) +DF_LINK_PARAS equ (4) +DF_LINK_SPR equ (5) +DF_LINK_WRD equ (6) +DF_LINK_AGD equ (7) +; Property of linksv +PRS_LINKSV struc +LinksvBuf dw ? +LinksvLen dw ? +PRS_LINKSV ends +PR_LINKSV struc +LinksvRoot PRS_ROOT <> +LinksvServer PRS_SERVER <> +LinksvLinksv PRS_LINKSV <> +PR_LINKSV ends +; Property of linkcl +PRS_LINKCL struc +LinkclPid dw ? +PRS_LINKCL ends +PR_LINKCL struc +LinkclRoot PRS_ROOT <> +LinkclLinkcl PRS_LINKCL <> +PR_LINKCL ends +; Constants for toplip +TY_TOPLIP_LINE equ (010h) +TY_TOPLIP_DEATH equ (011h) +; Types for toplip +PR_TOPLIP_STATUS struc +PR_TOPLIP_STATUSStat dw ? +PR_TOPLIP_STATUSMode dw ? +PR_TOPLIP_STATUSLine dw ? +PR_TOPLIP_STATUSOffset dw ? +PR_TOPLIP_STATUS ends +PR_TOPLIP_SOURCE struc +PR_TOPLIP_SOURCEPid dw ? +PR_TOPLIP_SOURCEBofs dw ? +PR_TOPLIP_SOURCESofs dw ? +PR_TOPLIP_SOURCE ends +; Property of toplip +PRS_TOPLIP struc +ToplipSt PR_TOPLIP_STATUS <> +ToplipBuf db (1) * 256 dup (?) +PRS_TOPLIP ends +PR_TOPLIP struc +ToplipRoot PRS_ROOT <> +ToplipServer PRS_SERVER <> +ToplipToplip PRS_TOPLIP <> +PR_TOPLIP ends +; Constants for exopl +EXOPL_ISEXP equ (001h) +EXOPL_SIGNAL equ (002h) +EXOPL_NTFY equ (004h) +; Types for exopl +EXOPL_RESBUF struc +EXOPL_RESBUFValue db 8 dup (?) +EXOPL_RESBUFError dw ? +EXOPL_RESBUFLine dw ? +EXOPL_RESBUFOffset dw ? +EXOPL_RESBUFSrc db (1) * P_FNAMESIZE dup (?) +EXOPL_RESBUF ends +EXOPL_PAR struc +EXOPL_PARFlags dw ? +EXOPL_PARCid dw ? +EXOPL_PARQofs dw ? +EXOPL_PARQlen dw ? +EXOPL_PARRofs dw ? +EXOPL_PAR ends +; Property of exopl +PRS_EXOPL struc +ExoplResult EXOPL_RESBUF <> +PRS_EXOPL ends +PR_EXOPL struc +ExoplRoot PRS_ROOT <> +ExoplActive PRS_ACTIVE <> +ExoplExopl PRS_EXOPL <> +PR_EXOPL ends +; Constants for cmap +DR_CMAP_END equ (0) +DR_CMAP_TEXT equ (1) +DR_CMAP_SPACES equ (2) +DR_CMAP_SCROLL equ (3) +OP_CMAP_CLEAR equ (1) +OP_CMAP_INVALID equ (2) +; Types for cmap +PR_CMAP_DRAW struc +PR_CMAP_DRAWLen dw ? +PR_CMAP_DRAWBuf dw ? +PR_CMAP_DRAWRow db ? +PR_CMAP_DRAWCol db ? +PR_CMAP_DRAW ends +; Property of cmap +PRS_CMAP struc +CmapBase dw ? +CmapToprow dw ? +CmapWidth dw ? +CmapHeight dw ? +CmapRow dw ? +CmapCol dw ? +CmapScroll dw ? +CmapWrap db ? +CmapSlock db ? +PRS_CMAP ends +PR_CMAP struc +CmapRoot PRS_ROOT <> +CmapCmap PRS_CMAP <> +PR_CMAP ends +; Constants for voice +TY_VOICE_PLAY equ (0) +TY_VOICE_EDIT equ (1) +TY_VOICE_CANCEL equ (2) +; Types for voice +RQ_VOICE_MSG struc +RQ_VOICE_MSGPstat dw ? +RQ_VOICE_MSGBuf dw ? +RQ_VOICE_MSGLen dw ? +RQ_VOICE_MSGMaxlen dw ? +RQ_VOICE_MSG ends +; Property of voice +PRS_VOICE struc +VoiceOwner dw ? +VoiceMethod dw ? +PRS_VOICE ends +PR_VOICE struc +VoiceRoot PRS_ROOT <> +VoiceActive PRS_ACTIVE <> +VoiceVoice PRS_VOICE <> +PR_VOICE ends +; Constants for notify +NOTIFY_MESS_TYPE equ (0) +NOTIFY_MESS_ARGS equ (5) +NOTIFY_MESS_SIZE equ (64) +; Property of notify +PRS_NOTIFY struc +NotifyErr0text db (1) * NOTIFY_MESS_SIZE dup (?) +NotifyErr1text db (1) * NOTIFY_MESS_SIZE dup (?) +NotifyBut0text db (1) * NOTIFY_MESS_SIZE dup (?) +NotifyBut1text db (1) * NOTIFY_MESS_SIZE dup (?) +NotifyBut2text db (1) * NOTIFY_MESS_SIZE dup (?) +NotifyPname db (1) * NOTIFY_MESS_SIZE dup (?) +PRS_NOTIFY ends +PR_NOTIFY struc +NotifyRoot PRS_ROOT <> +NotifyActive PRS_ACTIVE <> +NotifyIpcs PRS_IPCS <> +NotifyNotify PRS_NOTIFY <> +PR_NOTIFY ends +; Constants for consol +CONSOL_MESS_READ equ (0) +CONSOL_MESS_WRITE equ (1) +CONSOL_MESS_CLOSE equ (2) +CONSOL_MESS_SET equ (3) +CONSOL_MESS_SENSE equ (4) +CONSOL_MESS_TEST equ (5) +CONSOL_MESS_FLUSH equ (6) +CONSOL_MESS_CANCEL equ (7) +CONSOL_MESS_EDIT equ (8) +CONSOL_MESS_SPARE1 equ (9) +CONSOL_MESS_SPARE2 equ (10) +CONSOL_MESS_SPARE3 equ (11) +CONSOL_MESS_SPARE4 equ (12) +CONSOL_MESS_DIED equ (13) +CONSOL_KEY_TYPE_AHEAD equ (32) +CONSOL_MAX_STRING equ (255) +; Types for consol +PR_CONSOL_WMSG_KEY struc +PR_CONSOL_WMSG_KEYKeycode dw ? +PR_CONSOL_WMSG_KEYModifiers db ? +PR_CONSOL_WMSG_KEYCount db ? +PR_CONSOL_WMSG_KEY ends +; Property of consol +PRS_CONSOL struc +ConsolCmap dw ? +ConsolRcomp dw ? +ConsolRmess dw ? +ConsolHead dw ? +ConsolTail dw ? +ConsolList db (size PR_CONSOL_WMSG_KEY)* CONSOL_KEY_TYPE_AHEAD dup (?) +PRS_CONSOL ends +PR_CONSOL struc +ConsolRoot PRS_ROOT <> +ConsolServer PRS_SERVER <> +ConsolConsol PRS_CONSOL <> +PR_CONSOL ends diff --git a/code/SIBOSDK/include/isam.g b/code/SIBOSDK/include/isam.g new file mode 100644 index 0000000..e26638a --- /dev/null +++ b/code/SIBOSDK/include/isam.g @@ -0,0 +1,360 @@ +/* Generated by version 3.20 of Ctran from isam.cat */ +/* Thursday 05-03-1992 19:38:37 */ +#define ISAM_G +#ifndef P_STD_H +#include +#endif +#ifndef P_OBJECT_H +#include +#endif +#ifndef P_DBF_H +#include +#endif +#ifndef P_MATH_H +#include +#endif +/* Category Numbers */ +#ifndef EPOC +GLREF_D P_CLASS *ct_isam[]; +#endif /* EPOC */ +#ifdef EPOC +#define CAT_ISAM_ISAM 0 +#else +#define CAT_ISAM_ISAM (&ct_isam[0]) +#endif +/* Class Numbers */ +#define C_ISROOT 0 +#define C_IXREC 1 +#define C_ISAMAN 2 +#define C_BTDBF 3 +#define C_DADBF 4 +#define C_IXBTREE 5 +#define C_BLOCKER 6 +/* Method Numbers */ +#define O_IX_NEXT 13 +#define O_DA_READ 6 +#define O_IS_IERASE 27 +#define O_DA_SIZE 10 +#define O_IS_GET_FIELD 13 +#define O_IS_GET_KEYDEF 11 +#define O_IX_INSERT 6 +#define O_IS_ILAST 35 +#define O_IX_ERASEALL 9 +#define O_BL_INIT 1 +#define O_IX_GET_KEYDEF 20 +#define O_BL_ALLOC 8 +#define O_IS_DFLUSH 3 +#define O_IS_IQADD 26 +#define O_DA_ERASE 5 +#define O_IX_FLUSH 12 +#define O_IS_ICLOSE 18 +#define O_IS_IFLUSH 19 +#define O_BL_FREEALL 10 +#define O_DA_INIT 1 +#define O_IX_SET_NMATCH 3 +#define O_IS_UPDATE 39 +#define O_IS_ADD 37 +#define O_IX_UPDATE 10 +#define O_IS_DNEXT 6 +#define O_BL_DELETE 5 +#define O_BL_WRITE_HEADER 14 +#define O_IS_SET_DFORMAT 16 +#define O_IX_BACK 14 +#define O_IX_LAST 16 +#define O_IS_PUT_FIELD 12 +#define O_IS_DOPEN 2 +#define O_IS_INEXT 32 +#define O_DA_APPEND 4 +#define O_IS_IOPEN 17 +#define O_DA_NEXT 9 +#define O_IS_DSIZE 4 +#define O_IS_GET_TYPE 14 +#define O_IS_SET_FIELDDEF 8 +#define O_IX_DUP 2 +#define O_IX_OPEN 5 +#define O_IX_FIND 11 +#define O_IS_ISIZE 30 +#define O_BL_READ_HEADER 13 +#define O_BL_FREE 9 +#define O_IX_FIRST 15 +#define O_IX_COUNT 18 +#define O_IS_IDUP 21 +#define O_IX_FILTER 1 +#define O_IS_IFLAGS 22 +#define O_BL_FLUSH 4 +#define O_IS_ICOUNT 29 +#define O_BL_UPDATE 12 +#define O_DA_FLUSH 3 +#define O_IS_ICURRENT 36 +#define O_IS_IFIND 31 +#define O_IX_SIZE 19 +#define O_IX_CURRENT 17 +#define O_IS_DFIRST 5 +#define O_IS_GET_FIELDDEF 9 +#define O_IS_IADD 25 +#define O_BL_OPEN 2 +#define O_IS_ERASE 38 +#define O_DBF_HEADER 11 +#define O_IS_IFILTER 20 +#define O_IS_IFIRST 34 +#define O_BL_COUNT 7 +#define O_IS_INIT 1 +#define O_IX_ERASE 8 +#define O_IS_SET_KEYDEF 10 +#define O_BL_CLOSE 3 +#define O_IX_QINSERT 7 +#define O_IS_IERASEALL 28 +#define O_IS_IBUILD 23 +#define O_IX_INIT 4 +#define O_IS_SET_RADIX 15 +#define O_IS_IBACK 33 +#define O_BL_NFILES 6 +#define O_IS_DESTROY 0 +#define O_DA_OPEN 2 +#define O_IS_GET_RBUF 7 +#define O_DA_GET_SEQ 7 +#define O_DA_FIRST 8 +#define O_IS_IQBUILD 24 +#define O_IX_FLAGS 21 +#define O_BL_READ 11 +/* Property of isroot */ +typedef struct { +P_OBJECT pc; +} PRS_ISROOT; +typedef struct pr_isroot +{ +PRS_ISROOT isroot; +} PR_ISROOT; +/* Property of darec */ +typedef struct pr_darec +{ +PRS_ISROOT isroot; +} PR_DAREC; +/* Property of ixrec */ +typedef struct { +VOID *filterObj; +WORD filterMeth; +VOID *dupObj; +WORD dupMeth; +WORD nMatch; +} PRS_IXREC; +typedef struct pr_ixrec +{ +PRS_ISROOT isroot; +PRS_IXREC ixrec; +} PR_IXREC; +/* Constants for isaman */ +#define ISAM_MAX_INDEXES 8 +#define ISAM_MAX_KEY_LENGTH 64 +#define ISAM_MAX_DEFINED_FIELDS 32 +#define ISAM_MAX_KEYFIELDS 8 +#define ISAM_MAX_KEYDEF_LENGTH 66 +#define ISAM_MAX_FIELD_LENGTH 256 +#define ISAM_MAX_SEG_BLOCKS 1024 +#define ISAM_MIN_RECORD_BUFFER 512 +#define ISAM_MAX_RECORD_BUFFER 16384 +#define ISAM_MAX_RECORD_FIELDS 4094 +#define ISAM_RECORD_LENGTH_MASK 0xfff +#define ISAM_BLOCK_SIZE 512 +#define ISAM_BLOCK_SHIFTS 9 +#define ISAM_FIELDTYPE_WORD 0 +#define ISAM_FIELDTYPE_UWORD 0x80 +#define ISAM_FIELDTYPE_LONG 1 +#define ISAM_FIELDTYPE_ULONG 0x81 +#define ISAM_FIELDTYPE_DOUBLE 2 +#define ISAM_FIELDTYPE_STRING 3 +#define ISAM_FIELDTYPE_BYTE 4 +#define ISAM_FIELDTYPE_UBYTE 0x84 +#define ISAM_FIELDTYPE_LIMIT 4 +#define ISAM_CONVERT_NOFOLD 0 +#define ISAM_CONVERT_FOLD 1 +#define ISAM_CONVERT_UPPER 2 +#define ISAM_CONVERT_LOWER 3 +#define ISAM_FIELDFLAG_ASCEND 0 +#define ISAM_FIELDFLAG_DESCEND 1 +#define ISAM_FLAG_ALLOWDUP 1 +#define ISAM_FLAG_MANUAL 2 +#define ISAM_FLAG_MINIMIZE 4 +#define ISAM_DEFAULT_FIELD_COUNT 32 +#define ISAM_DEFAULT_FIELD_TYPE ISAM_FIELDTYPE_STRING +#define ISAM_DEFAULT_KEY_FIELD_COUNT 1 +#define ISAM_DEFAULT_KEY_STRING_LENGTH 8 +#define ISAM_DEFAULT_RADIX 10 +#define ISAM_DEFAULT_DTOB_WIDTH 20 +#define ISAM_DEFAULT_DTOB_POINT '.' +#define ISAM_PANIC_CALL 160 +#define ISAM_PANIC_PARAM 161 +/* Types for isaman */ +typedef struct +{ +WORD nFields; +UBYTE type[ISAM_MAX_DEFINED_FIELDS]; +} ISAM_FIELDDEF; +typedef struct +{ +WORD field; +UBYTE type; +UBYTE flags; +UBYTE offset; +UBYTE len; +WORD convert; +} ISAM_KEY_FIELD; +typedef struct +{ +WORD nKeyFields; +ISAM_KEY_FIELD keyField[ISAM_MAX_KEYFIELDS]; +} ISAM_KEYDEF; +/* Property of isaman */ +typedef struct { +PR_DAREC *daRec; +PR_IXREC *ixRec[ISAM_MAX_INDEXES]; +WORD ixCat; +WORD ixClass; +WORD iBufBlocks; +LONG ref; +WORD radix; +P_DTOB dFormat; +WORD rBufSize; +UBYTE *rBuf; +ISAM_FIELDDEF fieldInfo; +ISAM_KEYDEF keyDef; +UBYTE zeroBuf[sizeof(DOUBLE)]; +UBYTE tempField[ISAM_MAX_FIELD_LENGTH]; +} PRS_ISAMAN; +typedef struct pr_isaman +{ +PRS_ISROOT isroot; +PRS_ISAMAN isaman; +} PR_ISAMAN; +/* Property of btdbf */ +typedef struct pr_btdbf +{ +PRS_ISROOT isroot; +PRS_ISAMAN isaman; +} PR_BTDBF; +/* Property of dadbf */ +typedef struct { +VOID *pfcb; +UBYTE *buffer; +WORD maxBufSize; +WORD currentBufSize; +WORD nextOffset; +UWORD recordType; +LONG dataStart; +LONG bufFilePos; +LONG ref; +DbfHeader header; +} PRS_DADBF; +typedef struct pr_dadbf +{ +PRS_ISROOT isroot; +PRS_DADBF dadbf; +} PR_DADBF; +/* Constants for ixbtree */ +#define BT_SIG_LENGTH 16 +#define BT_INDEXFILE_VERSION 0x100F +#define BT_INDEXFILE_TYPE1 1 +#define BT_MAX_LEVELS 10 +/* Types for ixbtree */ +typedef struct +{ +UBYTE signature[BT_SIG_LENGTH]; +UWORD version; +WORD type; +LONG count; +UWORD rootBlock; +WORD flags; +WORD keyLen; +WORD entryLen; +WORD maxEntries; +UBYTE keyDef[ISAM_MAX_KEYDEF_LENGTH]; +} IXBTREE_FILE_HEADER; +typedef struct +{ +UWORD child; +LONG ref; +UBYTE key[ISAM_MAX_KEY_LENGTH]; +} IXBTREE_ENTRY; +typedef struct +{ +WORD nEntries; +UBYTE entry[2]; +} IXBTREE_BLOCK; +typedef struct +{ +UWORD blockNum; +WORD entryNum; +} IXBTREE_STACK; +/* Property of ixbtree */ +typedef struct { +WORD fileId; +WORD level; +UWORD blockNum; +WORD entryNum; +LONG ref; +IXBTREE_BLOCK *pB; +IXBTREE_STACK stack[BT_MAX_LEVELS]; +IXBTREE_FILE_HEADER head; +} PRS_IXBTREE; +typedef struct pr_ixbtree +{ +PRS_ISROOT isroot; +PRS_IXREC ixrec; +PRS_IXBTREE ixbtree; +} PR_IXBTREE; +/* Constants for blocker */ +#define BL_BLOCK_SIZE 512 +#define BL_BLOCK_SHIFTS 9 +#define BL_SEG_BLOCKS 20 +#define BL_DS_BLOCKS 4 +#define BL_BLOCK_GRANULARITY 4 +#define BL_MAX_FILES 32 +#define BL_SIG_LENGTH 16 +#define BL_FILE_VERSION 0x100F +#define BL_LIST_SIZE 6 +/* Types for blocker */ +typedef struct +{ +WORD dirty; +UWORD totalBlocks; +UWORD ffBlock; +} BLOCKER_INFO; +typedef struct +{ +UBYTE signature[BL_SIG_LENGTH]; +UWORD version; +BLOCKER_INFO info; +UBYTE spare[8]; +} BLOCKER_FILE_HEADER; +typedef struct +{ +VOID *chan; +UWORD actualBlocks; +BLOCKER_INFO info; +} BLOCKER_FCB; +typedef struct +{ +WORD lru; +WORD fileId; +UWORD block; +UBYTE data[BL_BLOCK_SIZE]; +} BLOCKER_DS_BUF; +/* Property of blocker */ +typedef struct { +UWORD *pBlock; +UBYTE *pFileId; +UBYTE *pDirty; +WORD *pLru; +HANDLE segHandle; +WORD maxBlocks; +WORD nFiles; +WORD currBuf; +BLOCKER_FCB fileCB[BL_MAX_FILES]; +BLOCKER_DS_BUF dsBuf[BL_DS_BLOCKS]; +UBYTE temp[BL_BLOCK_SIZE]; +} PRS_BLOCKER; +typedef struct pr_blocker +{ +PRS_ISROOT isroot; +PRS_BLOCKER blocker; +} PR_BLOCKER; diff --git a/code/SIBOSDK/include/limits.h b/code/SIBOSDK/include/limits.h new file mode 100644 index 0000000..15ed55b --- /dev/null +++ b/code/SIBOSDK/include/limits.h @@ -0,0 +1,36 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* limits.h - Value ranges for common data types. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _LIMITS_INC_ +#define _LIMITS_INC_ + +#define CHAR_BIT 8 +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MIN 0 +#define CHAR_MAX 255 +#else +#define CHAR_MIN (-128) +#define CHAR_MAX 127 +#endif +#define MB_LEN_MAX 1 +#define SCHAR_MAX 127 +#define SCHAR_MIN (-128) +#define UCHAR_MAX 255 +#define SHRT_MAX 32767 +#define SHRT_MIN (-32767-1) +#define USHRT_MAX 65535U +#define INT_MAX 32767 +#define INT_MIN (-32767-1) +#define UINT_MAX 0xFFFFU +#define LONG_MAX 2147483647L +#define LONG_MIN (-2147483647L-1) +#define ULONG_MAX 4294967295UL +#endif diff --git a/code/SIBOSDK/include/link_def.h b/code/SIBOSDK/include/link_def.h new file mode 100644 index 0000000..bec1723 --- /dev/null +++ b/code/SIBOSDK/include/link_def.h @@ -0,0 +1,8 @@ +/* +LINK_DEF.H - Link process message types +*/ + +#define LNKMSG_NONCP 2 /* if NCP dies this msg sent */ +#define LNKMSG_TERMINATE 3 /* Terminate everything */ +#define LNKMSG_LOADREMOTE 4 /* Load a remote process */ +#define LNKMSG_CONFIG 5 /* Re-configure serial channel */ diff --git a/code/SIBOSDK/include/listbox.g b/code/SIBOSDK/include/listbox.g new file mode 100644 index 0000000..541aa6c --- /dev/null +++ b/code/SIBOSDK/include/listbox.g @@ -0,0 +1,95 @@ +/* Generated by Ctran from listbox.cl */ +#define LISTBOX_G +#ifndef WIN_G +#include +#endif +#ifndef BWIN_G +#include +#endif +#ifndef MATCHER_G +#include +#endif +/* Class Numbers */ +#define C_LISTBOX 7 +/* Method Numbers */ +#define O_LB_DRAW_ITEM 14 +#define O_LB_DRAW_EMPHASIS 15 +#define O_LB_ITEM_WIDTH 17 +#define O_LB_INQUIRE_FOCUS 19 +#define O_LB_INQUIRE_LAST 21 +#define O_LB_INQUIRE_ITEM 20 +#define O_LB_SIZE_WINDOW 16 +#define O_LB_TAKE_FOCUS 18 +/* Constants for listbox */ +#define IN_LISTBOX_MATCHER 0x0001 +#define IN_LISTBOX_KEEP_ARRAY 0x0002 +#define IN_LISTBOX_TEXT_OFFSET 0x0004 +#define IN_LISTBOX_CUR_SET 0x0008 +#define IN_LISTBOX_FIRST_SET 0x0010 +#define IN_LISTBOX_LAST_SET 0x0020 +#define IN_LISTBOX_POS_ALIGN_X 0x0040 +#define IN_LISTBOX_POS_ALIGN_Y 0x0080 +#define IN_LISTBOX_MIN_WIDTH 0x0100 +#define IN_LISTBOX_AUTO_SIZE 0x0200 +#define IN_LISTBOX_FORCE_WIDE 0x0400 +#define IN_LISTBOX_WRAP_ROUND 0x0800 +#define IN_LISTBOX_FIXED_WIDTH 0x8000 +#define PR_LISTBOX_KEEP_ARRAY IN_LISTBOX_KEEP_ARRAY +#define PR_LISTBOX_FORCE_WIDE IN_LISTBOX_FORCE_WIDE +#define PR_LISTBOX_WRAP_ROUND IN_LISTBOX_WRAP_ROUND +#define PR_LISTBOX_UNSTABLE 0x1000 +#define PR_LISTBOX_BOLD_CURSOR 0x2000 +#define PR_LISTBOX_PLAQUE 0x4000 +#define PR_LISTBOX_FIXED_WIDTH IN_LISTBOX_FIXED_WIDTH +#define PR_LISTBOX_SMALL_FONT PR_WIN_FORCE_RIGHT +#define LISTBOX_TOP_EDGE (BWIN_CUSHION_Y+2) +#define LISTBOX_BOTTOM_EDGE (LISTBOX_TOP_EDGE+BWIN_SHADOW_1_HEIGHT) +#define LISTBOX_LEFT_EDGE (BWIN_CUSHION_X+2) +#define LISTBOX_RIGHT_EDGE (LISTBOX_LEFT_EDGE+BWIN_SHADOW_1_WIDTH) +#define XLISTBOX_TOP_EDGE (LISTBOX_TOP_EDGE+6) +#define XLISTBOX_BOTTOM_EDGE (LISTBOX_BOTTOM_EDGE+5) +#define XLISTBOX_LEFT_EDGE (LISTBOX_LEFT_EDGE+6) +#define XLISTBOX_RIGHT_EDGE (LISTBOX_RIGHT_EDGE+5) +#define VXLISTBOX_TOP_EDGE (LISTBOX_TOP_EDGE+4) +#define VXLISTBOX_BOTTOM_EDGE (LISTBOX_BOTTOM_EDGE+3) +#define VXLISTBOX_LEFT_EDGE (LISTBOX_LEFT_EDGE+4) +#define VXLISTBOX_RIGHT_EDGE (LISTBOX_RIGHT_EDGE+3) +#define LISTBOX_OBLOID_INDENT 2 +#define LISTBOX_TITLELINE_HEIGHT 3 +#define LISTBOX_SCROLL_GUTTER 7 +#define LISTBOX_SCROLL_OFFSET 1 +/* Types for listbox */ +typedef struct +{ +unsigned short int flags; +PR_VAROOT *array; +unsigned short int offset; +short int current; +unsigned short int top; +unsigned short int first; +unsigned short int last; +P_POINT pos; +unsigned short int minwid; +} IN_LISTBOX; +/* Property of listbox */ +typedef struct { +PR_VMATCHER *match; +PR_VAROOT *va; +unsigned short int flags; +short int width; +unsigned short int matchlen; +unsigned short int curoff; +unsigned short int offset; +short int current; +short int top; +short int first; +short int last; +short int vastart; +short int matchstart; +} PRS_LISTBOX; +typedef struct pr_listbox +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LISTBOX listbox; +} PR_LISTBOX; diff --git a/code/SIBOSDK/include/listbox.ing b/code/SIBOSDK/include/listbox.ing new file mode 100644 index 0000000..b62c9d5 --- /dev/null +++ b/code/SIBOSDK/include/listbox.ing @@ -0,0 +1,93 @@ +; Generated by Ctran from listbox.cl +LISTBOX_ING equ 1 +IFNDEF WIN_ING + INCLUDE ..\inc\WIN.ING +ENDIF +IFNDEF BWIN_ING + INCLUDE ..\inc\BWIN.ING +ENDIF +IFNDEF MATCHER_ING + INCLUDE ..\inc\MATCHER.ING +ENDIF +; Class Numbers +C_LISTBOX equ 7 +; Method Numbers +O_LB_DRAW_ITEM equ 14 +O_LB_DRAW_EMPHASIS equ 15 +O_LB_ITEM_WIDTH equ 17 +O_LB_INQUIRE_FOCUS equ 19 +O_LB_INQUIRE_LAST equ 21 +O_LB_INQUIRE_ITEM equ 20 +O_LB_SIZE_WINDOW equ 16 +O_LB_TAKE_FOCUS equ 18 +; Constants for listbox +IN_LISTBOX_MATCHER equ (00001h) +IN_LISTBOX_KEEP_ARRAY equ (00002h) +IN_LISTBOX_TEXT_OFFSET equ (00004h) +IN_LISTBOX_CUR_SET equ (00008h) +IN_LISTBOX_FIRST_SET equ (00010h) +IN_LISTBOX_LAST_SET equ (00020h) +IN_LISTBOX_POS_ALIGN_X equ (00040h) +IN_LISTBOX_POS_ALIGN_Y equ (00080h) +IN_LISTBOX_MIN_WIDTH equ (00100h) +IN_LISTBOX_AUTO_SIZE equ (00200h) +IN_LISTBOX_FORCE_WIDE equ (00400h) +IN_LISTBOX_WRAP_ROUND equ (00800h) +IN_LISTBOX_FIXED_WIDTH equ (08000h) +PR_LISTBOX_KEEP_ARRAY equ (IN_LISTBOX_KEEP_ARRAY) +PR_LISTBOX_FORCE_WIDE equ (IN_LISTBOX_FORCE_WIDE) +PR_LISTBOX_WRAP_ROUND equ (IN_LISTBOX_WRAP_ROUND) +PR_LISTBOX_UNSTABLE equ (01000h) +PR_LISTBOX_BOLD_CURSOR equ (02000h) +PR_LISTBOX_PLAQUE equ (04000h) +PR_LISTBOX_FIXED_WIDTH equ (IN_LISTBOX_FIXED_WIDTH) +PR_LISTBOX_SMALL_FONT equ (PR_WIN_FORCE_RIGHT) +LISTBOX_TOP_EDGE equ (BWIN_CUSHION_Y+2) +LISTBOX_BOTTOM_EDGE equ (LISTBOX_TOP_EDGE+BWIN_SHADOW_1_HEIGHT) +LISTBOX_LEFT_EDGE equ (BWIN_CUSHION_X+2) +LISTBOX_RIGHT_EDGE equ (LISTBOX_LEFT_EDGE+BWIN_SHADOW_1_WIDTH) +XLISTBOX_TOP_EDGE equ (LISTBOX_TOP_EDGE+6) +XLISTBOX_BOTTOM_EDGE equ (LISTBOX_BOTTOM_EDGE+5) +XLISTBOX_LEFT_EDGE equ (LISTBOX_LEFT_EDGE+6) +XLISTBOX_RIGHT_EDGE equ (LISTBOX_RIGHT_EDGE+5) +VXLISTBOX_TOP_EDGE equ (LISTBOX_TOP_EDGE+4) +VXLISTBOX_BOTTOM_EDGE equ (LISTBOX_BOTTOM_EDGE+3) +VXLISTBOX_LEFT_EDGE equ (LISTBOX_LEFT_EDGE+4) +VXLISTBOX_RIGHT_EDGE equ (LISTBOX_RIGHT_EDGE+3) +LISTBOX_OBLOID_INDENT equ (2) +LISTBOX_TITLELINE_HEIGHT equ (3) +LISTBOX_SCROLL_GUTTER equ (7) +LISTBOX_SCROLL_OFFSET equ (1) +; Types for listbox +IN_LISTBOX struc +IN_LISTBOXFlags dw ? +IN_LISTBOXArray dw ? +IN_LISTBOXOffset dw ? +IN_LISTBOXCurrent dw ? +IN_LISTBOXTop dw ? +IN_LISTBOXFirst dw ? +IN_LISTBOXLast dw ? +IN_LISTBOXPos P_POINT <> +IN_LISTBOXMinwid dw ? +IN_LISTBOX ends +; Property of listbox +PRS_LISTBOX struc +ListboxMatch dw ? +ListboxVa dw ? +ListboxFlags dw ? +ListboxWidth dw ? +ListboxMatchlen dw ? +ListboxCuroff dw ? +ListboxOffset dw ? +ListboxCurrent dw ? +ListboxTop dw ? +ListboxFirst dw ? +ListboxLast dw ? +ListboxVastart dw ? +ListboxMatchstart dw ? +PRS_LISTBOX ends +PR_LISTBOX struc +ListboxRoot PRS_ROOT <> +ListboxWin PRS_WIN <> +ListboxListbox PRS_LISTBOX <> +PR_LISTBOX ends diff --git a/code/SIBOSDK/include/lledit.g b/code/SIBOSDK/include/lledit.g new file mode 100644 index 0000000..3296a4d --- /dev/null +++ b/code/SIBOSDK/include/lledit.g @@ -0,0 +1,32 @@ +/* Generated by Ctran from lledit.cl */ +#define LLEDIT_G +#ifndef LODGER_G +#include +#endif +#ifndef MFNE_G +#include +#endif +/* Class Numbers */ +#define C_LLEDIT 33 +/* Method Numbers */ +/* Constants for lledit */ +#define IN_LLEDIT_LATITUDE 0 +#define IN_LLEDIT_LONGITUDE 1 +/* Types for lledit */ +typedef struct +{ +short int flags; +short int value; +} IN_LLEDIT; +typedef struct +{ +short int value; +} SE_LLEDIT; +/* Property of lledit */ +typedef struct pr_lledit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +} PR_LLEDIT; diff --git a/code/SIBOSDK/include/lledit.ing b/code/SIBOSDK/include/lledit.ing new file mode 100644 index 0000000..cf74c03 --- /dev/null +++ b/code/SIBOSDK/include/lledit.ing @@ -0,0 +1,29 @@ +; Generated by Ctran from lledit.cl +LLEDIT_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF MFNE_ING + INCLUDE ..\inc\MFNE.ING +ENDIF +; Class Numbers +C_LLEDIT equ 33 +; Method Numbers +; Constants for lledit +IN_LLEDIT_LATITUDE equ (0) +IN_LLEDIT_LONGITUDE equ (1) +; Types for lledit +IN_LLEDIT struc +IN_LLEDITFlags dw ? +IN_LLEDITValue dw ? +IN_LLEDIT ends +SE_LLEDIT struc +SE_LLEDITValue dw ? +SE_LLEDIT ends +; Property of lledit +PR_LLEDIT struc +LleditRoot PRS_ROOT <> +LleditWin PRS_WIN <> +LleditLodger PRS_LODGER <> +LleditMfne PRS_MFNE <> +PR_LLEDIT ends diff --git a/code/SIBOSDK/include/locale.h b/code/SIBOSDK/include/locale.h new file mode 100644 index 0000000..f2bc361 --- /dev/null +++ b/code/SIBOSDK/include/locale.h @@ -0,0 +1,55 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* locale.h - locale definitions and prototypes. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _LOCALE_INC_ +#define _LOCALE_INC_ + +#ifndef NULL +#define NULL 0 +#endif + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_NUMERIC 3 +#define LC_TIME 4 +#define LC_MONETARY 5 + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +#ifdef __cplusplus +extern "C" { +#endif +extern struct lconv * localeconv(void); +extern char * setlocale(int _category, const char *_locale); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/lodger.g b/code/SIBOSDK/include/lodger.g new file mode 100644 index 0000000..c03ff92 --- /dev/null +++ b/code/SIBOSDK/include/lodger.g @@ -0,0 +1,30 @@ +/* Generated by Ctran from lodger.cl */ +#define LODGER_G +#ifndef WIN_G +#include +#endif +/* Class Numbers */ +#define C_LODGER 3 +/* Method Numbers */ +#define O_LG_SET_ID_POS 14 +#define O_LG_UPDATE 18 +#define O_LG_SENSE_WIDTH 17 +#define O_LG_SELF_CHECK 16 +#define O_LG_DRAW 15 +/* Constants for lodger */ +#define LG_CHECK_OK 1 +#define LG_CHECK_FAILED 0 +#define LG_CHECK_FAILED_CHANGED (-1) +#define LG_CHECK_OK_CHANGED (-2) +/* Property of lodger */ +typedef struct { +P_POINT offset; +unsigned short int width; +PR_WIN *landlord; +} PRS_LODGER; +typedef struct pr_lodger +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +} PR_LODGER; diff --git a/code/SIBOSDK/include/lodger.ing b/code/SIBOSDK/include/lodger.ing new file mode 100644 index 0000000..55f0f6b --- /dev/null +++ b/code/SIBOSDK/include/lodger.ing @@ -0,0 +1,29 @@ +; Generated by Ctran from lodger.cl +LODGER_ING equ 1 +IFNDEF WIN_ING + INCLUDE ..\inc\WIN.ING +ENDIF +; Class Numbers +C_LODGER equ 3 +; Method Numbers +O_LG_SET_ID_POS equ 14 +O_LG_UPDATE equ 18 +O_LG_SENSE_WIDTH equ 17 +O_LG_SELF_CHECK equ 16 +O_LG_DRAW equ 15 +; Constants for lodger +LG_CHECK_OK equ (1) +LG_CHECK_FAILED equ (0) +LG_CHECK_FAILED_CHANGED equ (-1) +LG_CHECK_OK_CHANGED equ (-2) +; Property of lodger +PRS_LODGER struc +LodgerOffset P_POINT <> +LodgerWidth dw ? +LodgerLandlord dw ? +PRS_LODGER ends +PR_LODGER struc +LodgerRoot PRS_ROOT <> +LodgerWin PRS_WIN <> +LodgerLodger PRS_LODGER <> +PR_LODGER ends diff --git a/code/SIBOSDK/include/lprinter.g b/code/SIBOSDK/include/lprinter.g new file mode 100644 index 0000000..ae89a6c --- /dev/null +++ b/code/SIBOSDK/include/lprinter.g @@ -0,0 +1,31 @@ +/* Generated by Ctran from lprinter.cl */ +#define LPRINTER_G +#ifndef SCRLAY_G +#include +#endif +#ifndef PRDRV_G +#include +#endif +/* Class Numbers */ +#define C_LPRINTER 74 +/* Method Numbers */ +#define O_LPR_SENSE_TEXT 4 +#define O_LPR_INIT 1 +#define O_LPR_READ 2 +#define O_LPR_SENSE_BUF_WIDTH 3 +/* Property of lprinter */ +typedef struct { +void *pages; +void *wdr; +SCRLAY_FONT f; +WDR_PRINT defer; +unsigned char *wtab; +unsigned short int lheight; +unsigned short int width; +unsigned short int subsqind; +} PRS_LPRINTER; +typedef struct pr_lprinter +{ +PRS_ROOT root; +PRS_LPRINTER lprinter; +} PR_LPRINTER; diff --git a/code/SIBOSDK/include/lprinter.ing b/code/SIBOSDK/include/lprinter.ing new file mode 100644 index 0000000..09dd331 --- /dev/null +++ b/code/SIBOSDK/include/lprinter.ing @@ -0,0 +1,30 @@ +; Generated by Ctran from lprinter.cl +LPRINTER_ING equ 1 +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +IFNDEF PRDRV_ING + INCLUDE ..\inc\PRDRV.ING +ENDIF +; Class Numbers +C_LPRINTER equ 74 +; Method Numbers +O_LPR_SENSE_TEXT equ 4 +O_LPR_INIT equ 1 +O_LPR_READ equ 2 +O_LPR_SENSE_BUF_WIDTH equ 3 +; Property of lprinter +PRS_LPRINTER struc +LprinterPages dw ? +LprinterWdr dw ? +LprinterF SCRLAY_FONT <> +LprinterDefer WDR_PRINT <> +LprinterWtab dw ? +LprinterLheight dw ? +LprinterWidth dw ? +LprinterSubsqind dw ? +PRS_LPRINTER ends +PR_LPRINTER struc +LprinterRoot PRS_ROOT <> +LprinterLprinter PRS_LPRINTER <> +PR_LPRINTER ends diff --git a/code/SIBOSDK/include/malloc.h b/code/SIBOSDK/include/malloc.h new file mode 100644 index 0000000..8c3da28 --- /dev/null +++ b/code/SIBOSDK/include/malloc.h @@ -0,0 +1,2 @@ +#include + \ No newline at end of file diff --git a/code/SIBOSDK/include/matcher.g b/code/SIBOSDK/include/matcher.g new file mode 100644 index 0000000..e119a7b --- /dev/null +++ b/code/SIBOSDK/include/matcher.g @@ -0,0 +1,46 @@ +/* Generated by Ctran from matcher.cl */ +#define MATCHER_G +#ifndef VARRAY_G +#include +#endif +/* Class Numbers */ +#define C_MATCHER 5 +#define C_VMATCHER 6 +/* Method Numbers */ +#define O_IM_TRY_MATCH 6 +#define O_IM_SET_BUF 2 +#define O_IM_TRANSITION 7 +#define O_IM_SET_VAL 4 +#define O_IM_INIT 1 +#define O_IM_SENSE_BUF 3 +#define O_IM_SET_RANGE 9 +#define O_IM_SENSE_VAL 5 +#define O_IM_KEY 8 +/* Constants for matcher */ +#define IM_NEW_LEN 1 +#define IM_NEW_DISPLAY 2 +#define IM_NO_CHANGE 3 +/* Property of matcher */ +typedef struct { +char *ptyped; +unsigned char *plen; +} PRS_MATCHER; +typedef struct pr_matcher +{ +PRS_ROOT root; +PRS_MATCHER matcher; +} PR_MATCHER; +/* Property of vmatcher */ +typedef struct { +PR_VAROOT *va; +unsigned short int index; +unsigned short int first; +unsigned short int last; +unsigned short int txtoff; +} PRS_VMATCHER; +typedef struct pr_vmatcher +{ +PRS_ROOT root; +PRS_MATCHER matcher; +PRS_VMATCHER vmatcher; +} PR_VMATCHER; diff --git a/code/SIBOSDK/include/matcher.ing b/code/SIBOSDK/include/matcher.ing new file mode 100644 index 0000000..3f9bd02 --- /dev/null +++ b/code/SIBOSDK/include/matcher.ing @@ -0,0 +1,44 @@ +; Generated by Ctran from matcher.cl +MATCHER_ING equ 1 +IFNDEF VARRAY_ING + INCLUDE ..\inc\VARRAY.ING +ENDIF +; Class Numbers +C_MATCHER equ 5 +C_VMATCHER equ 6 +; Method Numbers +O_IM_TRY_MATCH equ 6 +O_IM_SET_BUF equ 2 +O_IM_TRANSITION equ 7 +O_IM_SET_VAL equ 4 +O_IM_INIT equ 1 +O_IM_SENSE_BUF equ 3 +O_IM_SET_RANGE equ 9 +O_IM_SENSE_VAL equ 5 +O_IM_KEY equ 8 +; Constants for matcher +IM_NEW_LEN equ (1) +IM_NEW_DISPLAY equ (2) +IM_NO_CHANGE equ (3) +; Property of matcher +PRS_MATCHER struc +MatcherPtyped dw ? +MatcherPlen dw ? +PRS_MATCHER ends +PR_MATCHER struc +MatcherRoot PRS_ROOT <> +MatcherMatcher PRS_MATCHER <> +PR_MATCHER ends +; Property of vmatcher +PRS_VMATCHER struc +VmatcherVa dw ? +VmatcherIndex dw ? +VmatcherFirst dw ? +VmatcherLast dw ? +VmatcherTxtoff dw ? +PRS_VMATCHER ends +PR_VMATCHER struc +VmatcherRoot PRS_ROOT <> +VmatcherMatcher PRS_MATCHER <> +VmatcherVmatcher PRS_VMATCHER <> +PR_VMATCHER ends diff --git a/code/SIBOSDK/include/matchwin.g b/code/SIBOSDK/include/matchwin.g new file mode 100644 index 0000000..b54bb71 --- /dev/null +++ b/code/SIBOSDK/include/matchwin.g @@ -0,0 +1,42 @@ +/* Generated by Ctran from matchwin.cl */ +#define MATCHWIN_G +#ifndef MATCHER_G +#include +#endif +#ifndef GRIDWIN_G +#include +#endif +/* Class Numbers */ +#define C_MATCHWIN 21 +/* Method Numbers */ +#define O_MW_STOP_MATCH 24 +#define O_MW_HIT_MAXLEN 25 +#define O_MW_START_MATCH 23 +/* Constants for matchwin */ +#define PR_MATCHWIN_UNSET (-1) +/* Types for matchwin */ +typedef struct +{ +PR_VAROOT *array; +unsigned int maxlen; +unsigned short int txtoff; +unsigned int minrec; +unsigned int maxrec; +int offset; +unsigned int column; +int position; +} IN_MATCHWIN; +/* Property of matchwin */ +typedef struct { +PR_VMATCHER *matcher; +IN_MATCHWIN params; +unsigned char matchlen; +unsigned char filler; +} PRS_MATCHWIN; +typedef struct pr_matchwin +{ +PRS_ROOT root; +PRS_WIN win; +PRS_GRIDWIN gridwin; +PRS_MATCHWIN matchwin; +} PR_MATCHWIN; diff --git a/code/SIBOSDK/include/matchwin.ing b/code/SIBOSDK/include/matchwin.ing new file mode 100644 index 0000000..224c8c0 --- /dev/null +++ b/code/SIBOSDK/include/matchwin.ing @@ -0,0 +1,40 @@ +; Generated by Ctran from matchwin.cl +MATCHWIN_ING equ 1 +IFNDEF MATCHER_ING + INCLUDE ..\inc\MATCHER.ING +ENDIF +IFNDEF GRIDWIN_ING + INCLUDE ..\inc\GRIDWIN.ING +ENDIF +; Class Numbers +C_MATCHWIN equ 21 +; Method Numbers +O_MW_STOP_MATCH equ 24 +O_MW_HIT_MAXLEN equ 25 +O_MW_START_MATCH equ 23 +; Constants for matchwin +PR_MATCHWIN_UNSET equ (-1) +; Types for matchwin +IN_MATCHWIN struc +IN_MATCHWINArray dw ? +IN_MATCHWINMaxlen dw ? +IN_MATCHWINTxtoff dw ? +IN_MATCHWINMinrec dw ? +IN_MATCHWINMaxrec dw ? +IN_MATCHWINOffset dw ? +IN_MATCHWINColumn dw ? +IN_MATCHWINPosition dw ? +IN_MATCHWIN ends +; Property of matchwin +PRS_MATCHWIN struc +MatchwinMatcher dw ? +MatchwinParams IN_MATCHWIN <> +MatchwinMatchlen db ? +MatchwinFiller db ? +PRS_MATCHWIN ends +PR_MATCHWIN struc +MatchwinRoot PRS_ROOT <> +MatchwinWin PRS_WIN <> +MatchwinGridwin PRS_GRIDWIN <> +MatchwinMatchwin PRS_MATCHWIN <> +PR_MATCHWIN ends diff --git a/code/SIBOSDK/include/math.h b/code/SIBOSDK/include/math.h new file mode 100644 index 0000000..e75d7fa --- /dev/null +++ b/code/SIBOSDK/include/math.h @@ -0,0 +1,159 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* math.h - floating point definitions and prototypes. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _MATH_INC_ +#define _MATH_INC_ + +#ifndef _ERRNOM_INC_ +#define _ERRNOM_INC_ + +extern int _doserrno; /* global DOS error variable */ +extern int errno; /* global error variable */ +#endif + +#define EDOM (-2) /* Math argument */ +#define ERANGE (-7) /* Result too large */ + + +#define DOMAIN 1 /* parameter not in valid domain */ +#define SING 2 /* function is incalculable at this place */ +#define OVERFLOW 3 /* result exceeds representable range */ +#define UNDERFLOW 4 /* result too close to zero to be represented */ +#define TLOSS 5 /* total loss of precision (eg. Sine (2**65)) */ +#define PLOSS 6 /* partial precision loss */ + +#define HUGE_VAL HUGE +#define LHUGE_VAL LHUGE + +extern double HUGE; +extern double LHUGE; + +#ifdef __cplusplus +extern "C" { +#endif +extern int abs(int _x); +extern double acos(double _x); +extern double asin(double _x); +extern double atan(double _x); +extern double atan2(double _y, double _x); +extern double atof(const char *_s); +extern double ceil(double _x); +extern double cos(double _x); +extern double cosh(double _x); +extern double exp(double _x); +extern double fabs(double _x); +extern double floor(double _x); +extern double fmod(double _x, double _y); +extern double frexp(double _x, int *_exp); +extern long labs(long _x); +extern double ldexp(double _x, int _exp); +extern double log(double _x); +extern double log10(double _x); +extern double modf(double _x, double *_ipart); +extern double poly(double _x, int _degree, double _coeffs[]); +extern double pow(double _x, double _y); +extern double sin(double _x); +extern double sinh(double _x); +extern double sqrt(double _x); +extern double strtod(const char *_s, char **_eptr); +extern double tan(double _x); +extern double tanh(double _x); + +extern long double acosl(long double _x); +extern long double asinl(long double _x); +extern long double atanl(long double _x); +extern long double atan2l(long double _y, long double _x); +extern long double atofl(const char *_s); +extern long double ceill(long double _x); +extern long double cosl(long double _x); +extern long double coshl(long double _x); +extern long double expl(long double _x); +extern long double fabsl(long double _x); +extern long double floorl(long double _x); +extern long double fmodl(long double _x, long double _y); +extern long double frexpl(long double _x, int *_exp); +extern long double ldexpl(long double _x, int _exp); +extern long double logl(long double _x); +extern long double log10l(long double _x); +extern long double modfl(long double _x, long double *_ipart); +extern long double polyl(long double _x, int _degree, long double _coeffs[]); +extern long double powl(long double _x, long double _y); +extern long double sinl(long double _x); +extern long double sinhl(long double _x); +extern long double sqrtl(long double _x); +extern long double strtodl(const char *_s, char **_eptr); +extern long double tanl(long double _x); +extern long double tanhl(long double _x); +#ifdef __cplusplus +} +#endif + +struct exception { + int type; + char *name; + double arg1, + arg2, + retval; +}; + +extern int (* matherr)(struct exception *_x); +#ifdef __cplusplus +extern "C" { +#endif +extern double hypot(double _x, double _y); +extern long double hypotl(long double _x, long double _y); +extern double pow10(int _p); +extern void _fpreset(void); +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +struct _complex { /* as used by cabs function */ + double x, + y; +}; + +struct _complexl { /* as used by cabsl function */ + long double x, + y; +}; +#else +struct complex { /* as used by cabs function */ + double x, + y; +}; + +struct complexl { /* as used by cabsl function */ + long double x, + y; +}; +#endif + +#define cabs(z) (hypot ((z).x, (z).y)) +#define cabsl(z) (hypotl((z).x, (z).y)) + +/* Constants rounded for 18 decimals. */ +#define MA_E 2.71828182845904524 +#define MA_LOG2E 1.44269504088896341 +#define MA_LOG10E 0.434294481903251828 +#define MA_LN2 0.693147180559945309 +#define MA_LN10 2.30258509299404568 +#define MA_PI 3.14159265358979324 +#define MA_PI_2 1.57079632679489662 +#define MA_PI_4 0.785398163397448310 +#define MA_1_PI 0.318309886183790672 +#define MA_2_PI 0.636619772367581343 +#define MA_1_SQRTPI 0.564189583547756287 +#define MA_2_SQRTPI 1.12837916709551257 +#define MA_SQRT2 1.41421356237309505 +#define MA_SQRT_2 0.707106781186547524 +#endif diff --git a/code/SIBOSDK/include/mem.h b/code/SIBOSDK/include/mem.h new file mode 100644 index 0000000..135c6e3 --- /dev/null +++ b/code/SIBOSDK/include/mem.h @@ -0,0 +1,42 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* mem.h - memory manipulation definitions and function prototypes. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _MEM_INC_ +#define _MEM_INC_ + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern int memcmp(const void *_s1, const void *_s2, size_t _num); +extern void * memcpy(void *_dest, const void *_source, size_t _num); +extern void * memset(void *_s, int _c, size_t _num); +extern void * memccpy(void *_dest, const void *_source, int _c, size_t _num); +extern void * memchr(const void *_s, int _c, size_t _num); +extern int memicmp(const void *_s1, const void *_s2, size_t _num); +extern void * memmove(void *_dest, const void *_source, size_t _num); +extern void movmem(void *src, void *_dest, unsigned _length); +extern void setmem(void *_dest, unsigned _length, char _value); +extern void * memwmove(void *_dest, const void *_source, size_t _num); +extern void * memwset(void *_s, int _c, size_t _num); +extern void * memwcpy(void *_dest, const void *_source, size_t _num); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/memory.h b/code/SIBOSDK/include/memory.h new file mode 100644 index 0000000..19bc761 --- /dev/null +++ b/code/SIBOSDK/include/memory.h @@ -0,0 +1,2 @@ +#include + \ No newline at end of file diff --git a/code/SIBOSDK/include/menubar.g b/code/SIBOSDK/include/menubar.g new file mode 100644 index 0000000..b05892c --- /dev/null +++ b/code/SIBOSDK/include/menubar.g @@ -0,0 +1,59 @@ +/* Generated by Ctran from menubar.cl */ +#define MENUBAR_G +#ifndef BWIN_G +#include +#endif +#ifndef PULLDOWN_G +#include +#endif +/* Class Numbers */ +#define C_MENUTAB 9 +#define C_MENUBAR 10 +/* Method Numbers */ +#define O_MB_ADD_MENU 14 +/* Property of menutab */ +typedef struct { +char *txt; +unsigned short int xoff; +} PRS_MENUTAB; +typedef struct pr_menutab +{ +PRS_ROOT root; +PRS_WIN win; +PRS_MENUTAB menutab; +} PR_MENUTAB; +/* Constants for menubar */ +#define MENUBAR_LEFT_SHOULD 4 +#define MENUBAR_RIGHT_SHOULD 4 +#define MENUBAR_MAX_MENU 15 +#define MENUBAR_MIN_GAP 3 +#define MENUBAR_MAX_GAP 10 +#define MENUBAR_3b_TAIL_WIDTH 18 +#define MENUBAR_FLG_PREBUILT 0x80 +/* Types for menubar */ +typedef struct +{ +unsigned short int menu_id; +char mb_txt[1]; +} MENUBAR_ITEM; +typedef struct +{ +unsigned char count; +} MENUBAR; +/* Property of menubar */ +typedef struct { +PR_MENUTAB *tab; +PR_PULLDOWN *menu; +MENUBAR *mb; +unsigned char num; +unsigned char xoff; +unsigned char toff; +unsigned char asc; +unsigned short int pos[MENUBAR_MAX_MENU+1]; +} PRS_MENUBAR; +typedef struct pr_menubar +{ +PRS_ROOT root; +PRS_WIN win; +PRS_MENUBAR menubar; +} PR_MENUBAR; diff --git a/code/SIBOSDK/include/menubar.ing b/code/SIBOSDK/include/menubar.ing new file mode 100644 index 0000000..672d26e --- /dev/null +++ b/code/SIBOSDK/include/menubar.ing @@ -0,0 +1,55 @@ +; Generated by Ctran from menubar.cl +MENUBAR_ING equ 1 +IFNDEF BWIN_ING + INCLUDE ..\inc\BWIN.ING +ENDIF +IFNDEF PULLDOWN_ING + INCLUDE ..\inc\PULLDOWN.ING +ENDIF +; Class Numbers +C_MENUTAB equ 9 +C_MENUBAR equ 10 +; Method Numbers +O_MB_ADD_MENU equ 14 +; Property of menutab +PRS_MENUTAB struc +MenutabTxt dw ? +MenutabXoff dw ? +PRS_MENUTAB ends +PR_MENUTAB struc +MenutabRoot PRS_ROOT <> +MenutabWin PRS_WIN <> +MenutabMenutab PRS_MENUTAB <> +PR_MENUTAB ends +; Constants for menubar +MENUBAR_LEFT_SHOULD equ (4) +MENUBAR_RIGHT_SHOULD equ (4) +MENUBAR_MAX_MENU equ (15) +MENUBAR_MIN_GAP equ (3) +MENUBAR_MAX_GAP equ (10) +MENUBAR_3b_TAIL_WIDTH equ (18) +MENUBAR_FLG_PREBUILT equ (080h) +; Types for menubar +MENUBAR_ITEM struc +MENUBAR_ITEMMenu_id dw ? +MENUBAR_ITEMMb_txt db (1) * 1 dup (?) +MENUBAR_ITEM ends +MENUBAR struc +MENUBARCount db ? +MENUBAR ends +; Property of menubar +PRS_MENUBAR struc +MenubarTab dw ? +MenubarMenu dw ? +MenubarMb dw ? +MenubarNum db ? +MenubarXoff db ? +MenubarToff db ? +MenubarAsc db ? +MenubarPos db (2) * MENUBAR_MAX_MENU+1 dup (?) +PRS_MENUBAR ends +PR_MENUBAR struc +MenubarRoot PRS_ROOT <> +MenubarWin PRS_WIN <> +MenubarMenubar PRS_MENUBAR <> +PR_MENUBAR ends diff --git a/code/SIBOSDK/include/mfne.g b/code/SIBOSDK/include/mfne.g new file mode 100644 index 0000000..e1c138c --- /dev/null +++ b/code/SIBOSDK/include/mfne.g @@ -0,0 +1,56 @@ +/* Generated by Ctran from mfne.cl */ +#define MFNE_G +#ifndef LODGER_G +#include +#endif +/* Class Numbers */ +#define C_MFNE 27 +/* Method Numbers */ +#define O_MF_RANGE_BEEP 19 +/* Constants for mfne */ +#define MFNE_MAX_FIELDS 4 +#define MFNE_MAX_WIDTH 10 +#define MFNE_MAX_TRAILER 3 +#define MFNE_LOWER 0 +#define MFNE_UPPER 1 +#define MFNE_CURSOR_WIDTH 3 +#define MFNE_SIGNED 0x01 +#define MFNE_LEFT_ALIGN 0x02 +#define MFNE_SUPPRESS_LEADING 0x04 +#define MFNE_SUPPRESS_SEPARATOR 0x08 +#define MFNE_TRAILER 0x10 +#define MFNE_SETS_NEXT 0x20 +#define MFNE_SETS_PREV 0x40 +#define MFNE_AUTO_SIZE 0x80 +#define MFNE_EMPHASISED_KLUDGE 0x20 +/* Types for mfne */ +typedef struct +{ +short int flags; +long int value; +unsigned char width; +unsigned char hWidth; +unsigned char hPos; +unsigned char separator; +long int limits[2]; +} MFNE_FIELD; +/* Property of mfne */ +typedef struct { +short int selected; +short int cField; +short int nField; +short int totWidth; +short int cPos; +short int changed; +char eStr[MFNE_MAX_WIDTH+2]; +char dStr[MFNE_MAX_FIELDS*(MFNE_MAX_WIDTH+1)+MFNE_MAX_TRAILER+2]; +char trail[2][MFNE_MAX_TRAILER+1]; +MFNE_FIELD f[MFNE_MAX_FIELDS]; +} PRS_MFNE; +typedef struct pr_mfne +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +} PR_MFNE; diff --git a/code/SIBOSDK/include/mfne.ing b/code/SIBOSDK/include/mfne.ing new file mode 100644 index 0000000..df0f37b --- /dev/null +++ b/code/SIBOSDK/include/mfne.ing @@ -0,0 +1,54 @@ +; Generated by Ctran from mfne.cl +MFNE_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +; Class Numbers +C_MFNE equ 27 +; Method Numbers +O_MF_RANGE_BEEP equ 19 +; Constants for mfne +MFNE_MAX_FIELDS equ (4) +MFNE_MAX_WIDTH equ (10) +MFNE_MAX_TRAILER equ (3) +MFNE_LOWER equ (0) +MFNE_UPPER equ (1) +MFNE_CURSOR_WIDTH equ (3) +MFNE_SIGNED equ (001h) +MFNE_LEFT_ALIGN equ (002h) +MFNE_SUPPRESS_LEADING equ (004h) +MFNE_SUPPRESS_SEPARATOR equ (008h) +MFNE_TRAILER equ (010h) +MFNE_SETS_NEXT equ (020h) +MFNE_SETS_PREV equ (040h) +MFNE_AUTO_SIZE equ (080h) +MFNE_EMPHASISED_KLUDGE equ (020h) +; Types for mfne +MFNE_FIELD struc +MFNE_FIELDFlags dw ? +MFNE_FIELDValue dd ? +MFNE_FIELDWidth db ? +MFNE_FIELDHWidth db ? +MFNE_FIELDHPos db ? +MFNE_FIELDSeparator db ? +MFNE_FIELDLimits db (4) * 2 dup (?) +MFNE_FIELD ends +; Property of mfne +PRS_MFNE struc +MfneSelected dw ? +MfneCField dw ? +MfneNField dw ? +MfneTotWidth dw ? +MfneCPos dw ? +MfneChanged dw ? +MfneEStr db (1) * MFNE_MAX_WIDTH+2 dup (?) +MfneDStr db (1) * MFNE_MAX_FIELDS*(MFNE_MAX_WIDTH+1)+MFNE_MAX_TRAILER+2 dup (?) +MfneTrail db (1) * 2 dup (?) +MfneF db (size MFNE_FIELD)* MFNE_MAX_FIELDS dup (?) +PRS_MFNE ends +PR_MFNE struc +MfneRoot PRS_ROOT <> +MfneWin PRS_WIN <> +MfneLodger PRS_LODGER <> +MfneMfne PRS_MFNE <> +PR_MFNE ends diff --git a/code/SIBOSDK/include/mux.h b/code/SIBOSDK/include/mux.h new file mode 100644 index 0000000..05f5353 --- /dev/null +++ b/code/SIBOSDK/include/mux.h @@ -0,0 +1,159 @@ +/* +MUX.H Defines for the Psion IRDA IRMUX implementation +Written by Jason J Robinson 1st November 1996 +PSION PLC 1995/96 +*/ + +/* Irmux user port defines */ +/* User can choose ports in range 1-126 */ +/* Port zero is always the IAS */ +/* Port number 128 is reserved for ports awaiting connection */ + +#define MaxPortNumber 126 +#define MUX_NOTCONNECTED 128 + +/* Irmux state machine states */ + +#define LM_SNIFF 0 +#define LM_DISCOVER 1 +#define LM_RESOLVEADDR 2 +#define LM_READY 3 +#define LM_READYPEND 4 +#define LM_EXCLUSIVEPEND 5 +#define LM_EXCLUSIVE 6 +#define LM_ROLEEXCHANGE 7 + +/* Client services */ +/* IPC call message numbers */ + +#define LM_Logon 1 +#define LM_Logoff 2 +#define LM_EmergencyLogoff 3 + +/* Irmux connectionless services */ +/* IPC call message numbers */ + +#define LM_CLReadRequest 4 +#define LM_CLWriteRequest 5 +#define LM_DiscoverDevicesRequest 6 +#define LM_SniffRequest 7 +#define LM_WaitForConnection 8 +#define LM_ConnectRequest 9 +#define LM_RegisterPort 10 +#define LM_UnRegisterPort 11 + +/* Irmux connection based services */ +/* IPC call message numbers */ + +#define LM_DisconnectRequest 20 +#define LM_StatusRequest 21 +#define LM_AccessModeRequest 22 +#define LM_IdleRequest 23 +#define LM_ReadRequest 24 +#define LM_WriteRequest 25 +#define LM_UReadRequest 26 +#define LM_UWriteRequest 27 +#define LM_SetHandshakingLevel 28 + +/* IAS services */ +/* Not implemented in current stack versions */ + +#define LM_GetValueByClass 32 +#define LM_GetInfoBaseDetails 33 +#define LM_GetObjects 34 +#define LM_GetValue 35 +#define LM_GetObjectInfo 36 +#define LM_GetAttributeNames 37 + +/* IPC call message numbers */ +/* Constants */ + +#define FirstConnectionBasedFunction LM_DisconnectRequest +#define MaxMessageNumber 38 + +/* IPC call message parameters and modes */ +/* Exclusive mode */ + +#define LM_ExclusiveMode 1 +#define LM_MultiplexMode 0 + +/* Connection mode */ + +#define MUX_PRIMARY 1 +#define MUX_SECONDARY 2 + +/* Mux level frame fromats */ +/* Control frame codes */ + +#define MUX_CONTROL_FRAME 0x80 +#define MUX_DISCONNECT_OPCODE 0x02 +#define MUX_CONNECT_OPCODE 0x01 +#define MUX_CONNECTCONFIRM_OPCODE 0x81 +#define MUX_ACCESS_OPCODE 0x03 +#define MUX_ACCESSCONFIRM_OPCODE 0x83 + +#define MUX_MODE_NOT_EXCLUSIVE 0x00 +#define MUX_MODE_EXCLUSIVE 0x01 + +#define CompleteRequest p_mfree + +/* Function returns */ + +#define OKAY 0 +#define MUX_DISCOVERY_COMPLETE 0 +#define MUX_CACHE_USED 1 + +/* Function error returns */ + +#define E_MUX_USERDISCONNECT -1 +#define E_MUX_LOGOFFDISCONNECT -2 +#define E_MUX_REMOTEDISCONNECT -3 +#define E_MUX_TIMEOUTDISCONNECT -4 +#define E_MUX_EXCLUSIVE -5 +#define E_MUX_BUSY -6 +#define E_MUX_LAP -7 +#define E_MUX_INUSE -8 +#define E_MUX_NOCONNECTION -9 +#define E_MUX_TIMEOUT -10 +#define E_MUX_ABORT -11 +#define E_MUX_LOGON -12 +#define E_GEN_BATIRDA -26 + +/* Irmux disconnect reasons */ +/* Errors returned in disconnect frames */ + +#define MUX_DISCONNECT_USER 0x01 +#define MUX_DISCONNECT_REASON_VAGUE 0x05 +#define MUX_DISCONNECT_NOT_CONNECTED_REASON 0x06 +#define MUX_DISCONNECT_NO_CLIENT 0x08 + +#define AccessModeTimeout 2000 +#define ConnectFrameTimeout 2000 + +#define DisconnectRequestLength 4 +#define ConnectRequestLength 64 +#define MuxConnectInfoLength 60 +#define ExclusiveRequestLength 5 +#define EndExclusiveRequestLength 5 +#define ConnectConfirmLength 64 +#define ExclusiveReplyLength 5 + +#define MuxMaxResetCountMinusOne 4 + +/* IRMUX panic numbers */ + +#define MUX_PANIC_NOTDISCOVERY 180 +#define PANIC_MUX_RESOLVE 181 +#define PANIC_MUX_STATUSINDICATION 182 +#define MUX_PANIC_NOFUNCTION 184 +#define PANIC_MUX_CONNECTCONFIRM 185 +#define PANIC_MUX_DISCONNECTINDICATION 186 +#define PANIC_MUX_DATAINDICATION 187 +#define PANIC_MUX_RESETCONFIRM 188 +#define PANIC_MUX_RESETINDICATION 190 +#define MUX_PANIC_LOSTLAPCONNECTION 191 +#define MUX_PANIC_MEMORY 196 + +#define IASLast 0x80 +#define IASAck 0x40 +#define IASGetValueByClass 0x04 diff --git a/code/SIBOSDK/include/ncedit.g b/code/SIBOSDK/include/ncedit.g new file mode 100644 index 0000000..f2eff60 --- /dev/null +++ b/code/SIBOSDK/include/ncedit.g @@ -0,0 +1,91 @@ +/* Generated by Ctran from ncedit.cl */ +#define NCEDIT_G +#ifndef LODGER_G +#include +#endif +#ifndef MFNE_G +#include +#endif +/* Class Numbers */ +#define C_LNCEDIT 28 +#define C_NCEDIT 29 +#define C_WNCEDIT 30 +/* Method Numbers */ +/* Constants for lncedit */ +#define SE_LNCEDIT_VALUE 0x01 +#define SE_LNCEDIT_LOW 0x02 +#define SE_LNCEDIT_HIGH 0x04 +/* Types for lncedit */ +typedef struct +{ +long int value; +long int low; +long int high; +} IN_LNCEDIT; +typedef struct +{ +long int value; +long int low; +long int high; +unsigned short int flags; +} SE_LNCEDIT; +/* Property of lncedit */ +typedef struct pr_lncedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +} PR_LNCEDIT; +/* Constants for ncedit */ +#define SE_NCEDIT_VALUE 0x01 +#define SE_NCEDIT_LOW 0x02 +#define SE_NCEDIT_HIGH 0x04 +/* Types for ncedit */ +typedef struct +{ +unsigned short int value; +unsigned short int low; +unsigned short int high; +} IN_NCEDIT; +typedef struct +{ +unsigned short int value; +unsigned short int low; +unsigned short int high; +unsigned short int flags; +} SE_NCEDIT; +/* Property of ncedit */ +typedef struct pr_ncedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +} PR_NCEDIT; +/* Constants for wncedit */ +#define SE_WNCEDIT_VALUE 0x01 +#define SE_WNCEDIT_LOW 0x02 +#define SE_WNCEDIT_HIGH 0x04 +/* Types for wncedit */ +typedef struct +{ +short int value; +short int low; +short int high; +} IN_WNCEDIT; +typedef struct +{ +short int value; +short int low; +short int high; +short int flags; +} SE_WNCEDIT; +/* Property of wncedit */ +typedef struct pr_wncedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +} PR_WNCEDIT; diff --git a/code/SIBOSDK/include/ncedit.ing b/code/SIBOSDK/include/ncedit.ing new file mode 100644 index 0000000..2997cb8 --- /dev/null +++ b/code/SIBOSDK/include/ncedit.ing @@ -0,0 +1,82 @@ +; Generated by Ctran from ncedit.cl +NCEDIT_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF MFNE_ING + INCLUDE ..\inc\MFNE.ING +ENDIF +; Class Numbers +C_LNCEDIT equ 28 +C_NCEDIT equ 29 +C_WNCEDIT equ 30 +; Method Numbers +; Constants for lncedit +SE_LNCEDIT_VALUE equ (001h) +SE_LNCEDIT_LOW equ (002h) +SE_LNCEDIT_HIGH equ (004h) +; Types for lncedit +IN_LNCEDIT struc +IN_LNCEDITValue dd ? +IN_LNCEDITLow dd ? +IN_LNCEDITHigh dd ? +IN_LNCEDIT ends +SE_LNCEDIT struc +SE_LNCEDITValue dd ? +SE_LNCEDITLow dd ? +SE_LNCEDITHigh dd ? +SE_LNCEDITFlags dw ? +SE_LNCEDIT ends +; Property of lncedit +PR_LNCEDIT struc +LnceditRoot PRS_ROOT <> +LnceditWin PRS_WIN <> +LnceditLodger PRS_LODGER <> +LnceditMfne PRS_MFNE <> +PR_LNCEDIT ends +; Constants for ncedit +SE_NCEDIT_VALUE equ (001h) +SE_NCEDIT_LOW equ (002h) +SE_NCEDIT_HIGH equ (004h) +; Types for ncedit +IN_NCEDIT struc +IN_NCEDITValue dw ? +IN_NCEDITLow dw ? +IN_NCEDITHigh dw ? +IN_NCEDIT ends +SE_NCEDIT struc +SE_NCEDITValue dw ? +SE_NCEDITLow dw ? +SE_NCEDITHigh dw ? +SE_NCEDITFlags dw ? +SE_NCEDIT ends +; Property of ncedit +PR_NCEDIT struc +NceditRoot PRS_ROOT <> +NceditWin PRS_WIN <> +NceditLodger PRS_LODGER <> +NceditMfne PRS_MFNE <> +PR_NCEDIT ends +; Constants for wncedit +SE_WNCEDIT_VALUE equ (001h) +SE_WNCEDIT_LOW equ (002h) +SE_WNCEDIT_HIGH equ (004h) +; Types for wncedit +IN_WNCEDIT struc +IN_WNCEDITValue dw ? +IN_WNCEDITLow dw ? +IN_WNCEDITHigh dw ? +IN_WNCEDIT ends +SE_WNCEDIT struc +SE_WNCEDITValue dw ? +SE_WNCEDITLow dw ? +SE_WNCEDITHigh dw ? +SE_WNCEDITFlags dw ? +SE_WNCEDIT ends +; Property of wncedit +PR_WNCEDIT struc +WnceditRoot PRS_ROOT <> +WnceditWin PRS_WIN <> +WnceditLodger PRS_LODGER <> +WnceditMfne PRS_MFNE <> +PR_WNCEDIT ends diff --git a/code/SIBOSDK/include/nchlist.g b/code/SIBOSDK/include/nchlist.g new file mode 100644 index 0000000..a1375c6 --- /dev/null +++ b/code/SIBOSDK/include/nchlist.g @@ -0,0 +1,28 @@ +/* Generated by Ctran from nchlist.cl */ +#define NCHLIST_G +#ifndef CHLIST_G +#include +#endif +/* Class Numbers */ +#define C_VANUMBER 78 +#define C_NCHLIST 79 +/* Method Numbers */ +#define O_VAN_SET_MAX 24 +/* Property of vanumber */ +typedef struct { +char data[8]; +} PRS_VANUMBER; +typedef struct pr_vanumber +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VANUMBER vanumber; +} PR_VANUMBER; +/* Property of nchlist */ +typedef struct pr_nchlist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_CHLIST chlist; +} PR_NCHLIST; diff --git a/code/SIBOSDK/include/nchlist.ing b/code/SIBOSDK/include/nchlist.ing new file mode 100644 index 0000000..27009a2 --- /dev/null +++ b/code/SIBOSDK/include/nchlist.ing @@ -0,0 +1,26 @@ +; Generated by Ctran from nchlist.cl +NCHLIST_ING equ 1 +IFNDEF CHLIST_ING + INCLUDE ..\inc\CHLIST.ING +ENDIF +; Class Numbers +C_VANUMBER equ 78 +C_NCHLIST equ 79 +; Method Numbers +O_VAN_SET_MAX equ 24 +; Property of vanumber +PRS_VANUMBER struc +VanumberData db (1) * 8 dup (?) +PRS_VANUMBER ends +PR_VANUMBER struc +VanumberRoot PRS_ROOT <> +VanumberVaroot PRS_VAROOT <> +VanumberVanumber PRS_VANUMBER <> +PR_VANUMBER ends +; Property of nchlist +PR_NCHLIST struc +NchlistRoot PRS_ROOT <> +NchlistWin PRS_WIN <> +NchlistLodger PRS_LODGER <> +NchlistChlist PRS_CHLIST <> +PR_NCHLIST ends diff --git a/code/SIBOSDK/include/new.hpp b/code/SIBOSDK/include/new.hpp new file mode 100644 index 0000000..3fef8d0 --- /dev/null +++ b/code/SIBOSDK/include/new.hpp @@ -0,0 +1,21 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* NEW.H - header file for C++ memory allocation operators. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _NEW_INC_ +#define _NEW_INC_ + +#include + +extern void (* set_new_handler(void(*)()))(); + +void * operator new(size_t _size, void *_place); + +#endif diff --git a/code/SIBOSDK/include/nosend.h b/code/SIBOSDK/include/nosend.h new file mode 100644 index 0000000..59cc7d8 --- /dev/null +++ b/code/SIBOSDK/include/nosend.h @@ -0,0 +1,8 @@ +#define p_send() THIS_WILL_NOT_COMPILE +#define p_supersend() THIS_WILL_NOT_COMPILE +#define p_entersend() THIS_WILL_NOT_COMPILE +#define f_send() THIS_WILL_NOT_COMPILE +#define p_enter() THIS_WILL_NOT_COMPILE +#define p_ioa() THIS_WILL_NOT_COMPILE +#define p_iow() THIS_WILL_NOT_COMPILE +#define p_ioc() THIS_WILL_NOT_COMPILE diff --git a/code/SIBOSDK/include/nosend.inc b/code/SIBOSDK/include/nosend.inc new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/code/SIBOSDK/include/nosend.inc @@ -0,0 +1 @@ + diff --git a/code/SIBOSDK/include/olib.ext b/code/SIBOSDK/include/olib.ext new file mode 100644 index 0000000..0d75de0 --- /dev/null +++ b/code/SIBOSDK/include/olib.ext @@ -0,0 +1,481 @@ +Generated by Ctran from olib.cat +LIBRARY olib +CLASS root +{ +DECLARE destroy +HAS_METHOD +HAS_PROPERTY +} +CLASS varoot root +{ +DECLARE va_count +DECLARE va_delete +DECLARE va_sort +DECLARE va_key +DECLARE va_findisq +DECLARE va_insertisq +DECLARE va_append +DECLARE va_insert +DECLARE va_search +DECLARE va_compare +DECLARE va_reset +DECLARE va_test +DECLARE va_replace +DECLARE va_copy +DECLARE va_reclen +DECLARE va_swap +DECLARE va_init +DECLARE va_deletem +DECLARE va_insertm +DECLARE va_prec +DECLARE va_pbuf +DECLARE va_capacity +DECLARE va_compress +HAS_METHOD +HAS_PROPERTY +} +CLASS vafix varoot +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS vaflat vafix +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS sgbuf root +{ +DECLARE sb_init +DECLARE sb_point +DECLARE sb_insert +DECLARE sb_delete +DECLARE sb_extract +DECLARE sb_compress +DECLARE sb_count +DECLARE sb_backpoint +DECLARE sb_allocseg +HAS_METHOD +HAS_PROPERTY +} +CLASS vaseg vafix +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS vastr varoot +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS vaxvar vaflat +{ +HAS_METHOD +} +CLASS vaxvars vaseg +{ +HAS_METHOD +} +CLASS cleanup vaflat +{ +DECLARE cl_init +DECLARE cl_add +DECLARE cl_remove +DECLARE cl_clean_item +DECLARE cl_clean_level +DECLARE cl_set_level +HAS_METHOD +HAS_PROPERTY +} +CLASS active root +{ +DECLARE ao_init +DECLARE ao_cancel +DECLARE ao_abrun +DECLARE ao_queue +DECLARE ao_run +HAS_METHOD +HAS_PROPERTY +} +CLASS aidle active +{ +HAS_METHOD +} +CLASS rscfile root +{ +DECLARE rs_init +DECLARE rs_read +DECLARE rs_read_buf +HAS_METHOD +HAS_PROPERTY +} +CLASS system root +{ +DECLARE sy_init +DECLARE sy_icon_pos +DECLARE sy_link_server +DECLARE sy_link_paste +DECLARE sy_exec_open +HAS_METHOD +HAS_PROPERTY +} +CLASS ipcs active +{ +DECLARE ip_add_server +HAS_METHOD +HAS_PROPERTY +} +CLASS appman root +{ +DECLARE am_init +DECLARE am_start +DECLARE am_stop +DECLARE am_add_task +DECLARE am_wait +DECLARE am_load_resource +DECLARE am_load_res_buf +DECLARE am_rscname +DECLARE am_notify +DECLARE am_notifyerr +DECLARE am_clean_up +DECLARE am_onlyone +DECLARE am_findimg +DECLARE am_change_pri +HAS_METHOD +HAS_PROPERTY +} +CLASS server root +{ +DECLARE sv_abrun +DECLARE sv_init +DECLARE sv_run +HAS_METHOD +HAS_PROPERTY +} +CLASS linksv server +{ +DECLARE ls_set_format +DECLARE ls_get_data +HAS_METHOD +HAS_PROPERTY +} +CLASS linkcl root +{ +DECLARE lc_start +DECLARE lc_get_data +DECLARE lc_stop +HAS_METHOD +HAS_PROPERTY +} +CLASS toplip server +{ +DECLARE tip_start +DECLARE tip_getline +DECLARE tip_complete +HAS_METHOD +HAS_PROPERTY +} +CLASS exopl active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS cmap root +{ +DECLARE cm_init +DECLARE cm_insert +DECLARE cm_rect +DECLARE cm_enq_draw +DECLARE cm_sense_cpos +DECLARE cm_set_cpos +DECLARE cm_sense_size +DECLARE cm_point_row +DECLARE cm_autowrap +DECLARE cm_scrollock +DECLARE cm_scroll +DECLARE cm_attrib +HAS_METHOD +HAS_PROPERTY +} +CLASS voice active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS notify ipcs +{ +DECLARE no_draw +HAS_METHOD +HAS_PROPERTY +} +CLASS consol server +{ +DECLARE co_key +DECLARE co_extra +DECLARE co_draw +DECLARE co_cursor +DECLARE co_size +DECLARE co_esc +DECLARE co_edit +HAS_METHOD +HAS_PROPERTY +} +CLASS factive active +{ +DECLARE fa_close +HAS_METHOD +HAS_PROPERTY +} +CLASS fscan factive +{ +DECLARE fs_matchname +DECLARE fs_fscan +DECLARE fs_fscan_end +DECLARE fs_dirname +DECLARE fs_filename +DECLARE fs_end_dirlist +HAS_METHOD +HAS_PROPERTY +} +CLASS fnode factive +{ +DECLARE fn_list +DECLARE fn_end_list +DECLARE fn_nodename +HAS_METHOD +HAS_PROPERTY +} +CLASS pnode fnode +{ +HAS_METHOD +} +CLASS pselvar vaxvar +{ +HAS_METHOD +} +CLASS psel fscan +{ +DECLARE ps_get_file +DECLARE ps_ascend_path +DECLARE ps_descend_path +DECLARE ps_set_path +DECLARE ps_sense_filename +DECLARE ps_select_direntry +DECLARE ps_drives +DECLARE ps_settag +DECLARE ps_gettag +DECLARE ps_order +DECLARE ps_new_list +HAS_METHOD +HAS_PROPERTY +} +CLASS fcasy factive +{ +DECLARE fc_write +DECLARE fc_open +DECLARE fc_request_comp +HAS_METHOD +HAS_PROPERTY +} +CLASS fcsync fcasy +{ +HAS_METHOD +} +CLASS fmmk factive +{ +HAS_METHOD +} +CLASS fmsrc fcasy +{ +HAS_METHOD +} +CLASS fmtarg fcasy +{ +HAS_METHOD +} +CLASS fmfmt factive +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS fmscan fscan +{ +HAS_METHOD +} +CLASS fman root +{ +DECLARE fman_init +DECLARE fman_cancel +DECLARE fman_copy +DECLARE fman_delete +DECLARE fman_rename +DECLARE fman_make +DECLARE fman_remove +DECLARE fman_copydev +DECLARE fman_format +DECLARE fman_name +DECLARE fman_info +DECLARE fman_attrib +DECLARE fman_complete +DECLARE fman_newname +DECLARE fman_update +DECLARE fman_fileexist +DECLARE fman_error +HAS_METHOD +HAS_PROPERTY +} +CLASS locs root +{ +DECLARE ls_matchname +DECLARE ls_scan +DECLARE ls_filename +HAS_METHOD +HAS_PROPERTY +} +CLASS time root +{ +DECLARE to_set +DECLARE to_sense +DECLARE to_add_years +DECLARE to_add_months +DECLARE to_add_days +DECLARE to_add_secs +DECLARE to_set_format +DECLARE to_sense_format +DECLARE to_get_sysdat +HAS_METHOD +HAS_PROPERTY +} +CLASS timer active +{ +DECLARE tm_qabsolute +HAS_METHOD +} +CLASS buzsnd timer +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS alarr vaxvar +{ +DECLARE va_confirm +DECLARE va_cancel +HAS_METHOD +HAS_PROPERTY +} +CLASS animator timer +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS bfile root +{ +DECLARE fi_close +DECLARE fi_read +DECLARE fl_set_buf_len +DECLARE fl_sense_data +DECLARE fi_open +DECLARE fl_rewind +HAS_METHOD +HAS_PROPERTY +} +CLASS tlvfile bfile +{ +DECLARE fl_write_rec +DECLARE fl_delrec +DECLARE fl_count +DECLARE fl_read_by_type +DECLARE fl_set_rec +DECLARE fl_sense_rec +DECLARE fl_replace +HAS_METHOD +HAS_PROPERTY +} +CLASS tlvdata root +{ +DECLARE td_open +DECLARE td_save +DECLARE td_changed +DECLARE td_load_item +DECLARE td_save_item +DECLARE td_reset +DECLARE td_set_file +DECLARE td_set_item +DECLARE td_sense_item +HAS_METHOD +HAS_PROPERTY +} +CLASS serfile tlvdata +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS print active +{ +DECLARE pr_get_data +HAS_METHOD +HAS_PROPERTY +} +CLASS serial active +{ +DECLARE sr_write +DECLARE sr_test +DECLARE sr_set +DECLARE sr_sense +DECLARE sr_flush +DECLARE sr_control +DECLARE sr_enquire +DECLARE sr_grab +HAS_METHOD +HAS_PROPERTY +} +CLASS eproot root +{ +DECLARE ep_set_text +DECLARE ep_scan_word +DECLARE ep_word_count +DECLARE ep_scan_para +DECLARE ep_para_count +DECLARE ep_scan_block +DECLARE ep_add_para +DECLARE ep_copy_indent +DECLARE ep_copy_to_front +DECLARE ep_copy_to_back +DECLARE ep_paste +DECLARE ep_mod_chars +DECLARE ep_sense_text +DECLARE ep_capacity +DECLARE ep_compress +DECLARE ep_init +DECLARE ep_sense_len +DECLARE ep_sense_chars +DECLARE ep_back_chars +DECLARE ep_insert +DECLARE ep_delete +DECLARE ep_extract +DECLARE ep_clear +HAS_METHOD +HAS_PROPERTY +} +CLASS epflat eproot +{ +DECLARE ef_granularity +DECLARE ef_sense_buf +HAS_METHOD +HAS_PROPERTY +} +CLASS epseg eproot +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS vtab vaflat +{ +DECLARE vt_gaptonext +DECLARE vt_set_colwid +DECLARE vt_setintv +DECLARE vt_set +DECLARE vt_strip +HAS_METHOD +HAS_PROPERTY +} diff --git a/code/SIBOSDK/include/olib.g b/code/SIBOSDK/include/olib.g new file mode 100644 index 0000000..9add02a --- /dev/null +++ b/code/SIBOSDK/include/olib.g @@ -0,0 +1,23 @@ +/* Generated by Ctran from olib.cat */ +#define OLIB_G +#ifndef P_STD_H +#include +#endif +#ifndef P_OBJECT_H +#include +#endif +/* Category Numbers */ +/* EPOC */ +#define CAT_OLIB_OLIB 0 +/* Class Numbers */ +#define C_ROOT 0 +/* Method Numbers */ +#define O_DESTROY 0 +/* Property of root */ +typedef struct { +P_OBJECT pc; +} PRS_ROOT; +typedef struct pr_root +{ +PRS_ROOT root; +} PR_ROOT; diff --git a/code/SIBOSDK/include/olib.h b/code/SIBOSDK/include/olib.h new file mode 100644 index 0000000..fd6c0c9 --- /dev/null +++ b/code/SIBOSDK/include/olib.h @@ -0,0 +1,17 @@ +/* HEADER - OLIB.H +OLIB standard header +Copyright (c) Psion PLC 1991 - 1996. +*/ +#ifndef OLIB_H +#define OLIB_H + +GLREF_C INT cl_add(INT,VOID *); +GLREF_C INT cl_add_alloc(VOID *); +GLREF_C INT cl_add_iochan(VOID *); +GLREF_C INT cl_add_object(VOID *); +GLREF_C INT cl_add_shared(VOID *); +GLREF_C INT cl_add_dyl(HANDLE); +GLREF_C VOID cl_clean_item(INT); +GLREF_C VOID cl_remove(INT); + +#endif // OLIB_H diff --git a/code/SIBOSDK/include/olib.ing b/code/SIBOSDK/include/olib.ing new file mode 100644 index 0000000..e58e6be --- /dev/null +++ b/code/SIBOSDK/include/olib.ing @@ -0,0 +1,21 @@ +; Generated by Ctran from olib.cat +OLIB_ING equ 1 +IFNDEF P_STD_INC + INCLUDE ..\inc\P_STD.INC +ENDIF +IFNDEF P_OBJECT_INC + INCLUDE ..\inc\P_OBJECT.INC +ENDIF +; Category Numbers +CAT_OLIB_OLIB equ 0 +; Class Numbers +C_ROOT equ 0 +; Method Numbers +O_DESTROY equ 0 +; Property of root +PRS_ROOT struc +RootPc P_OBJECT <> +PRS_ROOT ends +PR_ROOT struc +RootRoot PRS_ROOT <> +PR_ROOT ends diff --git a/code/SIBOSDK/include/olib.lis b/code/SIBOSDK/include/olib.lis new file mode 100644 index 0000000..c635b42 --- /dev/null +++ b/code/SIBOSDK/include/olib.lis @@ -0,0 +1,171 @@ +Generated by Ctran from olib.cat + +LIBRARY olib + +********** olib ********** +root + +********** varray ********** +varoot + Derived from root + Subclassed by vastr,vafix +vafix + Derived from varoot,root + Subclassed by vaseg,vaflat +vaflat + Derived from vafix,varoot,root + Subclassed by vaxvar,vtab,cleanup +sgbuf + Derived from root + Referenced by vaseg,epseg +vaseg + Derived from vafix,varoot,root + References sgbuf + Subclassed by vaxvars +vastr + Derived from varoot,root + Referenced by psel +vaxvar + Derived from vaflat,vafix,varoot,root + Subclassed by alarr,pselvar +vaxvars + Derived from vaseg,vafix,varoot,root + +********** appman ********** +cleanup + Derived from vaflat,vafix,varoot,root + Referenced by appman +active + Derived from root + Subclassed by print,aidle,ipcs,timer,exopl,factive,voice,serial +aidle + Derived from active,root +rscfile + Derived from root + Referenced by appman +system + Derived from root + Referenced by appman +ipcs + Derived from active,root + Subclassed by notify + Referenced by appman +appman + Derived from root + References cleanup,system,rscfile,rscfile,ipcs + +********** ipc ********** +server + Derived from root + Subclassed by consol,toplip,linksv +linksv + Derived from server,root +linkcl + Derived from root +toplip + Derived from server,root +exopl + Derived from active,root +cmap + Derived from root + Referenced by consol +voice + Derived from active,root + References root +notify + Derived from ipcs,active,root +consol + Derived from server,root + References cmap + +********** factive ********** +factive + Derived from active,root + Subclassed by fcasy,fmfmt,fscan,fmmk,fnode +fscan + Derived from factive,active,root + Subclassed by fmscan,psel +fnode + Derived from factive,active,root + Subclassed by pnode +pnode + Derived from fnode,factive,active,root + Referenced by psel +pselvar + Derived from vaxvar,vaflat,vafix,varoot,root + Referenced by psel +psel + Derived from fscan,factive,active,root + References pselvar,vastr,pnode +fcasy + Derived from factive,active,root + Subclassed by fmsrc,fmtarg,fcsync +fcsync + Derived from fcasy,factive,active,root +fmmk + Derived from factive,active,root + Referenced by fman +fmsrc + Derived from fcasy,factive,active,root + Referenced by fman +fmtarg + Derived from fcasy,factive,active,root + Referenced by fman +fmfmt + Derived from factive,active,root + Referenced by fman +fmscan + Derived from fscan,factive,active,root + Referenced by fman +fman + Derived from root + References fmsrc,fmtarg,fmscan,fmmk,fmfmt +locs + Derived from root + +********** time ********** +time + Derived from root + +********** timer ********** +timer + Derived from active,root + Subclassed by animator,buzsnd +buzsnd + Derived from timer,active,root + References root +alarr + Derived from vaxvar,vaflat,vafix,varoot,root +animator + Derived from timer,active,root + References root + +********** tlvfile ********** +bfile + Derived from root + Subclassed by tlvfile +tlvfile + Derived from bfile,root + Referenced by tlvdata +tlvdata + Derived from root + References tlvfile + Subclassed by serfile +serfile + Derived from tlvdata,root +print + Derived from active,root +serial + Derived from active,root + +********** edit ********** +eproot + Derived from root + Subclassed by epseg,epflat +epflat + Derived from eproot,root +epseg + Derived from eproot,root + References sgbuf +vtab + Derived from vaflat,vafix,varoot,root diff --git a/code/SIBOSDK/include/oprinter.g b/code/SIBOSDK/include/oprinter.g new file mode 100644 index 0000000..2471948 --- /dev/null +++ b/code/SIBOSDK/include/oprinter.g @@ -0,0 +1,44 @@ +/* Generated by Ctran from oprinter.cl */ +#define OPRINTER_G +#ifndef XPRINTER_G +#include +#endif +#ifndef HELP_G +#include +#endif +/* Class Numbers */ +#define C_OPRINTER 15 +#define C_OHELPDLG 16 +/* Method Numbers */ +#define O_LPR_PRINT_COMMAND 5 +/* Types for oprinter */ +typedef struct +{ +short int style; +unsigned short int blen; +char *buf; +} OPRINT_REC; +/* Property of oprinter */ +typedef struct { +unsigned short int nrecs; +OPRINT_REC *first; +unsigned short int index; +OPRINT_REC *current; +short int comman_changed; +void *old_comman; +} PRS_OPRINTER; +typedef struct pr_oprinter +{ +PRS_ROOT root; +PRS_LPRINTER lprinter; +PRS_XPRINTER xprinter; +PRS_OPRINTER oprinter; +} PR_OPRINTER; +/* Property of ohelpdlg */ +typedef struct pr_ohelpdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_HELPDLG helpdlg; +} PR_OHELPDLG; diff --git a/code/SIBOSDK/include/oprinter.ing b/code/SIBOSDK/include/oprinter.ing new file mode 100644 index 0000000..c7445ef --- /dev/null +++ b/code/SIBOSDK/include/oprinter.ing @@ -0,0 +1,41 @@ +; Generated by Ctran from oprinter.cl +OPRINTER_ING equ 1 +IFNDEF XPRINTER_ING + INCLUDE ..\inc\XPRINTER.ING +ENDIF +IFNDEF HELP_ING + INCLUDE ..\inc\HELP.ING +ENDIF +; Class Numbers +C_OPRINTER equ 15 +C_OHELPDLG equ 16 +; Method Numbers +O_LPR_PRINT_COMMAND equ 5 +; Types for oprinter +OPRINT_REC struc +OPRINT_RECStyle dw ? +OPRINT_RECBlen dw ? +OPRINT_RECBuf dw ? +OPRINT_REC ends +; Property of oprinter +PRS_OPRINTER struc +OprinterNrecs dw ? +OprinterFirst dw ? +OprinterIndex dw ? +OprinterCurrent dw ? +OprinterComman_changed dw ? +OprinterOld_comman dw ? +PRS_OPRINTER ends +PR_OPRINTER struc +OprinterRoot PRS_ROOT <> +OprinterLprinter PRS_LPRINTER <> +OprinterXprinter PRS_XPRINTER <> +OprinterOprinter PRS_OPRINTER <> +PR_OPRINTER ends +; Property of ohelpdlg +PR_OHELPDLG struc +OhelpdlgRoot PRS_ROOT <> +OhelpdlgWin PRS_WIN <> +OhelpdlgDlgchain PRS_DLGCHAIN <> +OhelpdlgHelpdlg PRS_HELPDLG <> +PR_OHELPDLG ends diff --git a/code/SIBOSDK/include/p_8086.h b/code/SIBOSDK/include/p_8086.h new file mode 100644 index 0000000..8abd69d --- /dev/null +++ b/code/SIBOSDK/include/p_8086.h @@ -0,0 +1,53 @@ +/* HEADER - P_8086.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_8086_H +#define P_8086_H + +#include + +#define AX x.ax +#define BX x.bx +#define CX x.cx +#define DX x.dx +#define SI x.si +#define DI x.di +#define ES x.es +#define DS x.ds +#define AL h.al +#define AH h.ah +#define BL h.bl +#define BH h.bh +#define CL h.cl +#define CH h.ch +#define DL h.dl +#define DH h.dh +#define CF 0x0001 +#define PF 0x0004 +#define AF 0x0010 +#define ZF 0x0040 +#define SF 0x0080 +#define TF 0x0100 +#define IF 0x0200 +#define DF 0x0400 +#define OF 0x0800 +typedef struct +{ +short int ax,bx,cx,dx,si,di,es,ds; +} XREG; +typedef struct +{ +char al,ah,bl,bh,cl,ch,dl,dh; +} HREG; +typedef union +{ +XREG x; +HREG h; +} REGS; + +#endif // P_8086_H diff --git a/code/SIBOSDK/include/p_assert.h b/code/SIBOSDK/include/p_assert.h new file mode 100644 index 0000000..4e48d55 --- /dev/null +++ b/code/SIBOSDK/include/p_assert.h @@ -0,0 +1,27 @@ +/* HEADER - P_ASSERT.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_ASSERT_H +#define P_ASSERT_H + +#include + +#ifdef ASSERTIONS +#ifdef __cplusplus +extern "C" { +#endif +extern void p_assert(char *pAssert,char *pFile,int lineNo); +#ifdef __cplusplus +} +#endif +#define __ASSERT(p) ((p) ? ((void)0) : p_assert(#p,__FILE__,__LINE__)) +#else +#define __ASSERT(ignore) ((void)0) +#endif + +#endif // P_ASSERT_H diff --git a/code/SIBOSDK/include/p_config.h b/code/SIBOSDK/include/p_config.h new file mode 100644 index 0000000..dc6f700 --- /dev/null +++ b/code/SIBOSDK/include/p_config.h @@ -0,0 +1,92 @@ +/* HEADER - P_CONFIG.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_CONFIG_H +#define P_CONFIG_H + +#include + +#define E_DATE_USA 0 /* MM/DD/YY */ +#define E_DATE_EUROPE 1 /* DD/MM/YY */ +#define E_DATE_JAPAN 2 /* YY/MM/DD */ +#define E_CURRENCY_BEFORE 0 +#define E_CURRENCY_AFTER 1 +#define E_NOSPACE_BETWEEN 1 +#define E_SPACE_BETWEEN 0 +#define E_TIME_12 0 +#define E_TIME_24 1 +#define E_ANALOGUE_CLOCK 0 +#define E_DIGITAL_CLOCK 1 +#define E_DST_HOME 1 +#define E_DST_EUROPEAN 2 +#define E_DST_NORTHERN 4 +#define E_DST_SOUTHERN 8 +#define E_IMPERIAL 0 +#define E_METRIC 1 +#define P_LANGUAGE_TST 0 /* Test language */ +#define P_LANGUAGE_ENG 1 /* English */ +#define P_LANGUAGE_FRN 2 /* French */ +#define P_LANGUAGE_GRM 3 /* German */ +#define P_LANGUAGE_SPA 4 /* Spanish */ +#define P_LANGUAGE_ITA 5 /* Italian */ +#define P_LANGUAGE_SWE 6 /* Swedish */ +#define P_LANGUAGE_DAN 7 /* Danish */ +#define P_LANGUAGE_NOR 8 /* Norwegian */ +#define P_LANGUAGE_FIN 9 /* Finnish */ +#define P_LANGUAGE_USA 10 /* American */ +#define P_LANGUAGE_SWF 11 /* Swiss french */ +#define P_LANGUAGE_SWG 12 /* Swiss german */ +#define P_LANGUAGE_POR 13 /* Portuguese */ +#define P_LANGUAGE_TUR 14 /* Turkish */ +#define P_LANGUAGE_ICE 15 /* Icelandic */ +#define P_LANGUAGE_RUS 16 /* Russian */ +#define P_LANGUAGE_HUN 17 /* Hungarian */ +#define P_LANGUAGE_DUT 18 /* Dutch */ +#define P_LANGUAGE_FLE 19 /* Belgian Flemish */ +#define P_LANGUAGE_OZZ 20 /* Australian */ +#define P_LANGUAGE_NZL 21 /* New Zealand */ +#define P_LANGUAGE_OST 22 /* Austrian */ +#define P_LANGUAGE_BEF 23 /* Belgian french */ +#define P_MAX_LANGUAGES 24 +typedef struct +{ +unsigned short int countryCode; +short int gmtOffset; /* In minutes */ +unsigned char dateType; +unsigned char timeType; +unsigned char currencySymbolPosition; +unsigned char currencySpaceRequired; +unsigned char currencyDecimalPlaces; +unsigned char currencyNegativeInBrackets; +unsigned char currencyTriadsAllowed; +unsigned char thousandsSeparator; +unsigned char decimalSeparator; +unsigned char dateSeparator; +unsigned char timeSeparator; +unsigned char currencySymbol[9]; +unsigned char startOfWeek; +unsigned char summerTime; +unsigned char clockType; +unsigned char dayAbbreviation; +unsigned char monthAbbreviation; +unsigned char workDays; +unsigned char units; +unsigned char spare[9]; +} E_CONFIG; +#pragma save,call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +#ifdef __cplusplus +extern "C" { +#endif +extern void p_setctd(const E_CONFIG *); +extern void p_getctd(E_CONFIG *); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_CONFIG_H diff --git a/code/SIBOSDK/include/p_cons.h b/code/SIBOSDK/include/p_cons.h new file mode 100644 index 0000000..992b196 --- /dev/null +++ b/code/SIBOSDK/include/p_cons.h @@ -0,0 +1,99 @@ +/* HEADER - P_CONS.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_CONS_H +#define P_CONS_H + +#include + +#ifndef P_GRAF_H +#include +#endif +typedef struct +{ +unsigned int window_handle; +unsigned int font_handle; +unsigned int line_height; +unsigned int char_width; +} CONSOLE_INFO; +typedef struct +{ +unsigned short int code; +unsigned char modifier_mask; +unsigned char dont_care_mask; +} CONSOLE_CAPTURE_KEY; +typedef struct +{ +unsigned short int id; +unsigned short int style; +} P_SCR_SET_FONT; +typedef struct +{ +P_EXTENT extent; +P_SCR_SET_FONT font; +} P_SCR_SET_FONT_EXT; +#ifndef _P_CON_KBREC +#define _P_CON_KBREC +typedef struct +{ +unsigned short int keycode; +unsigned char modifiers; +unsigned char count; +} P_CON_KBREC; +#endif +#define P_MAXEDITSTR 256 +#ifndef _P_CEDIT +#define _P_CEDIT +typedef struct +{ +unsigned char cursorpos; +unsigned char trap; +unsigned char string[P_MAXEDITSTR]; +} P_CEDIT; +#endif +#define CONS_SPECIAL_EVENT 0x4 +#define CONS_EVENT_FOREGROUND ((CONS_SPECIAL_EVENT*256)+1) +#define CONS_EVENT_BACKGROUND ((CONS_SPECIAL_EVENT*256)+2) +#define CONS_EVENT_ON_OFF ((CONS_SPECIAL_EVENT*256)+3) +#define CONS_EVENT_COMMAND ((CONS_SPECIAL_EVENT*256)+4) +#define CONS_EVENT_DATE_CHANGED ((CONS_SPECIAL_EVENT*256)+5) +#define CONS_EVENT_OTHER ((CONS_SPECIAL_EVENT*256)+255) +#define P_SCR_NORMAL 0 +#define P_SCR_BOLD 0x01 +#define P_SCR_REVERSE 0x02 +#define P_SCR_UNDLINE 0x04 +#define P_SCR_BLINK 0x08 +#define P_SCR_ITALIC 0x10 +#define P_SCR_ATTRB 0 +#define P_SCR_SCROLL 1 +#define P_SCR_CLR 2 +#define P_SCR_POSA 3 +#define P_SCR_POSR 4 +#define P_SCR_WSET 5 +#define P_SCR_SLOCK 6 +#define P_SCR_WLOCK 7 +#define P_SCR_NEL 8 +#define P_SCR_CURSOR 9 +#define P_SCR_ESCAPE 10 +#define P_SCR_FLUSH 11 +#define P_SCR_CSET 12 +#define P_SCR_CAPTURE_KEY 13 +#define P_SCR_CANCEL_CAPTURE_KEY 14 +#define P_SCR_CLIENT_FOREGROUND 15 +#define P_SCR_LAST_LINE_WRAP 16 +#define P_SCR_FONT 17 +#define P_SCR_DISABLE_READS 18 +#define P_SCR_SET_PRIORITY_CONTROL 19 +#define P_SCR_COMPATIBILITY 20 +#define P_SCR_GREY 21 +#define P_SCR_FONT_EXT 22 +#define P_FWFLUSH P_FRSUPER +#define P_EVENT_READ P_FSTOP +#define P_EVENT_TEST P_FSTART + +#endif // P_CONS_H diff --git a/code/SIBOSDK/include/p_crc.h b/code/SIBOSDK/include/p_crc.h new file mode 100644 index 0000000..4a045bb --- /dev/null +++ b/code/SIBOSDK/include/p_crc.h @@ -0,0 +1,37 @@ +/* HEADER - P_CRC.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_CRC_H +#define P_CRC_H + +#include + +typedef struct + { + unsigned char lo; /* CRC low byte*/ + unsigned char hi; /* CRC high byte*/ + } CRC; + +/* CRC as hi lo bytes or a word */ +typedef union + { + unsigned short int uw; + CRC hilo; + } P_CRC; + +#pragma save,call(reg_param =>(di,si,cx),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +#ifdef __cplusplus +extern "C" { +#endif +extern void p_crc(unsigned short int *,const unsigned char *,unsigned int); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_CRC_H diff --git a/code/SIBOSDK/include/p_crypt.h b/code/SIBOSDK/include/p_crypt.h new file mode 100644 index 0000000..6697a48 --- /dev/null +++ b/code/SIBOSDK/include/p_crypt.h @@ -0,0 +1,22 @@ +/* HEADER - P_CRYPT.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_CRYPT_H +#define P_CRYPT_H + +#include + +#define P_MAX_PASS_LEN 16 /* maximum password length */ +typedef struct +{ +unsigned char len; /* length of mask */ +unsigned char pos; /* current position in mask */ +unsigned char msk[P_MAX_PASS_LEN]; /* the mask */ +} P_MASK; + +#endif // P_CRYPT_H diff --git a/code/SIBOSDK/include/p_date.h b/code/SIBOSDK/include/p_date.h new file mode 100644 index 0000000..5a87335 --- /dev/null +++ b/code/SIBOSDK/include/p_date.h @@ -0,0 +1,54 @@ +/* HEADER - P_DATE.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_DATE_H +#define P_DATE_H + +#include + +#define P_NSECDAY 86400l /* number of seconds in a day */ +/* +Convert day since 1900 to day in week, Monday=0 +*/ +#define P_WEEK(d) ((INT)((d)%7)) /* JAN 1 1900 was a Monday */ +typedef struct + { + unsigned long int day; /* day number since 1900, up to 2155, 0 to approx 93000 */ + unsigned long int sec; /* seconds in day, 0 to 86399 */ + } P_DAYSEC; +typedef struct + { + unsigned char year; /* Year - 1900 */ + unsigned char month; /* Month number in year, 0 to 11 */ + unsigned char day; /* Day number in month, 0 to 30 */ + unsigned char hour; /* Hour in day, 0 to 23 */ + unsigned char minute; /* Minute in hour, 0 to 59 */ + unsigned char second; /* Second in minute, 0 to 59 */ + unsigned short int yrday; /* day in year */ + } P_DATE; +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_param =>(si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_dstodt(const P_DAYSEC *,P_DATE *); +extern int p_dttods(const P_DATE *,P_DAYSEC *); +#pragma call(reg_param =>(si,di),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern int p_dstost(const P_DAYSEC *,unsigned long int *); +#pragma call(reg_param =>(bx,di),reg_saved =>(bx,si,di,EPOC_SAVE)) +extern void p_sttods(const unsigned long int *,P_DAYSEC *); +#pragma call(reg_param =>(di,si,bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_dt2str(char *str,const char *fmt,const P_DATE *dt); +extern int p_ds2str(char *str,const char *fmt,const P_DAYSEC *ds); +extern int p_now2str(char *str,const char *fmt); +extern int p_st2str(char *str,const char *fmt,const unsigned long int *st); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_DATE_H diff --git a/code/SIBOSDK/include/p_dbf.h b/code/SIBOSDK/include/p_dbf.h new file mode 100644 index 0000000..859f76f --- /dev/null +++ b/code/SIBOSDK/include/p_dbf.h @@ -0,0 +1,112 @@ +/* HEADER - P_DBF.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +1.11F 31/08/23 AB #ifndef fix +*/ +#ifndef P_DBF_H +#define P_DBF_H + +#include + +#define DbfMaxRecords 0xfffe /* 0-fffd,1-fffe for OPL with ffff at eof */ +#define DbfRecordTypeMask 0xf000 /* Top nibble of header word */ +#define DbfRecordLengthMask 0x0fff /* Bottom 12 bits of header word */ +#define DbfFieldTypeWord 0 +#define DbfFieldTypeLong 1 +#define DbfFieldTypeDouble 2 +#define DbfFieldTypeString 3 +#define DbfFindAllStrings -1 /* for nStrings parameter to DbfFindRead */ +#define DbfFindBackwards 0x0000 +#define DbfFindForwards 0x0100 +#define DbfFindLast 0x0200 +#define DbfFindFirst 0x0300 +#define DbfFindCaseIndependent 0x0000 +#define DbfFindCaseDependent 0x1000 +#define DbfCopyFromHandle 0 +#define DbfCopyToHandle 1 +#define DbfStateCopyAbort -2 /* for DbfCopyFile only */ +#define DbfStateOpenNoIndex -2 /* for DbfOpen only */ +#define DbfStateDisabled -1 +#define DbfStateStart 0 +#define DbfStateScanBuffer 1 +#define DbfStateGetBuffer 2 +#define DbfStateFinished 3 +#define DbfHeaderNameSize 16 +#define DbfHeaderLength 22 /* Length of header without F.I.R */ +#define DbfMaxFirLength 32 /* 32 bytes */ +#define DbfMinBufferSize 512 /* Minimum buffer size */ +#define DbfMaxBufferSize 16384 /* Maximum buffer size */ +#define DbfMaxRecordLength 4094 /* Maximum record length,not inc. header */ +#define DbfRecordTypeFir 2 /* Record type for Field Information Record */ +#define DbfRecordTypeDesc 3 /* Record type for 'descriptive' record */ +#define DbfRecordTypeAll 15 /* Record type to match all records (except erased) */ +typedef struct +{ +unsigned char fileType[DbfHeaderNameSize]; /* Name of the file type */ +unsigned short int createVersion; /* software version used to create file */ +unsigned short int dataStart; /* Offset in file for start of data */ +unsigned short int needVersion; /* minimum software version needed to handle this file */ +unsigned short int firHeader; +unsigned char fir[DbfMaxFirLength]; +} DbfHeader; +typedef struct +{ +unsigned short int header; /* Record header word */ +unsigned char data[2]; /* Data follows... */ +} DbfRecord; +typedef struct +{ +void **pFcb; /* the address of the fcb */ +char *fName; /* the file name */ +unsigned int mode; /* the mode */ +DbfHeader *pHead; /* the address of the header */ +} DbfOpenArgs; +#ifdef __cplusplus +extern "C" { +#endif +#pragma save, call(reg_param=>(bx,dx),reg_saved=>(cx,si,di,EPOC_SAVE)) +extern int DbfFileSize(void *pHandle,unsigned long int *pos); +#pragma call(reg_param=>(di,bx,si,dx,cx,ax),reg_saved=>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int DbfQuickOpen(int *pState,DbfOpenArgs *pArgs,unsigned char *buffer,unsigned int length,unsigned int type); +extern int DbfCopyFile(unsigned int *state,void *sHandle,const char *targetName,unsigned int targetMode,unsigned int type,int dir); +extern int DbfEraseRead(int *state,void *pHandle,unsigned short int *pOffset); +extern int DbfCompress(unsigned int *state,void *pHandle); +#pragma call(reg_param=>(di,bx,si,cx,dx,ax),reg_saved=>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int DbfFindRead(unsigned int *state,void *pHandle,const void *buffer,unsigned int length,unsigned int findMode,unsigned int nStrings,unsigned short int *pOffset); +#pragma call(reg_param=>(di,bx,cx),reg_saved=>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int DbfUpdate(int *state,void *pHandle,unsigned int length); +#pragma call(reg_param=>(bx,cx,si),reg_saved=>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int DbfAbsRead(void *pHandle,unsigned int record,unsigned short int *pOffset); +extern int DbfAppend(void *pHandle,unsigned int length); +extern int DbfFlush(void *pHandle); +extern int DbfClose(void *pHandle); +extern unsigned int DbfDescRecordRead(void *pHandle); +extern int DbfDescRecordWrite(void *pHandle,unsigned int length); +#pragma call(reg_param=>(bx,cx,si,di),reg_saved=>(bx,cx,si,di,EPOC_SAVE)) +extern int DbfAbsReadSense(void *pHandle,unsigned int record,unsigned short int *pOffset,unsigned long int *pPos); +#pragma call(reg_param=>(bx,si),reg_saved=>(cx,dx,di,EPOC_SAVE)) +extern int DbfNextRead(void *pHandle,unsigned short int *pOffset); +extern int DbfBackRead(void *pHandle,unsigned short int *pOffset); +extern int DbfFirstRead(void *pHandle,unsigned short int *pOffset); +extern int DbfLastRead(void *pHandle,unsigned short int *pOffset); +#pragma call(reg_param=>(ax,bx,si,cx),reg_saved=>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int DbfExtHeaderRead(unsigned int x,void *pHandle,void *buffer,unsigned int len); +extern int DbfExtHeaderWrite(unsigned int x,void *pHandle,const void *buffer,unsigned int len); +#pragma call(reg_param=>(bx,si),reg_saved=>(bx,cx,dx,si,di,EPOC_SAVE),inline=>on) +static unsigned int DbfVersion(void)={0xb4,0x0a,0xcd,0xd8}; +static void DbfTrash(void *pHandle)={0xb4,0x03,0xcd,0xd8}; +static unsigned int DbfSense(void *pHandle)={0xb4,0x15,0xcd,0xd8}; +static unsigned int DbfCount(void *pHandle)={0xb4,0x16,0xcd,0xd8}; +static int DbfCopyDown(void *pHandle,unsigned int offset)={0xb4,0x04,0xcd,0xd8}; +#pragma restore +extern int cdecl DbfFindReadField(unsigned int *state,void *pHandle,const void *buffer,unsigned int length,unsigned int findMode,unsigned int nStrings,unsigned short int *pOffset,unsigned int startStr); +extern int cdecl DbfOpen(int *state,void **pHandle,const char *name,unsigned int mode, + DbfHeader *header,unsigned char *buffer,unsigned int length,unsigned int type); +#ifdef __cplusplus +} +#endif + +#endif // P_DBF_H diff --git a/code/SIBOSDK/include/p_file.h b/code/SIBOSDK/include/p_file.h new file mode 100644 index 0000000..a308583 --- /dev/null +++ b/code/SIBOSDK/include/p_file.h @@ -0,0 +1,298 @@ +/* HEADER - P_FILE.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_FILE_H +#define P_FILE_H + +#include + +#define P_MAXDEVNAME 4 +typedef void (*P_DEVICE)(void); +typedef struct /* IO request packet */ +{ +short int *pstat; /* where to write completion status */ +unsigned char *a1; /* first parameter */ +unsigned char *a2; /* second parameter */ +} P_RQPKT; +/* all I/O control blocks must start with this header */ +typedef struct p_icb /* I/O control block header */ +{ +struct p_icb *picb; /* ptr to current ICB in chain */ +int (*vec)(); /* strategy entry point */ +} P_ICB; +/* IO request - as passed to strategy functions */ +typedef struct +{ +unsigned int func; /* function number */ +P_RQPKT r; /* request packet */ +} P_IRQ; +/* Wait Handler defines */ +#define P_SIGNAL_UNUSED 0 /* signal not used by waithandler */ +#define P_SIGNAL_ENABLE 1 /* signal used by handler,I/O's still pending */ +#define P_SIGNAL_DISABLE 2 /* signal used by handler,no I/O's pending */ +/* open service mode flags */ +#define P_FOPEN 0x0000 /* Open i/o service */ +#define P_FCREATE 0x0001 /* Create file */ +#define P_FREPLACE 0x0002 /* Replace file */ +#define P_FAPPEND 0x0003 /* Append records */ +#define P_FUNIQUE 0x0004 /* Unique file open */ +#define P_FSER_MASK 0x000f /* File service mask */ +#define P_FSTREAM 0x0000 /* Stream access to a binary file */ +#define P_FSTREAM_TEXT 0x0010 /* Stream access to a text file */ +#define P_FTEXT 0x0020 /* Record access to a text file */ +#define P_FDIR 0x0030 /* Record access to a directory file */ +#define P_FFORMAT 0x0040 /* Format a device */ +#define P_FDEVICE 0x0050 /* Record access to device name list */ +#define P_FNODE 0x0060 /* Record access to node name list */ +#define P_FMT_MASK 0x00f0 /* File format mask */ +#define P_FUPDATE 0x0100 /* Read and write access */ +#define P_FRANDOM 0x0200 /* Random access */ +#define P_FSHARE 0x0400 /* File can be shared */ +#define P_FACC_MASK 0x0f00 /* mask for access types */ +#define P_FLOWDENSITY 0x1000 +/* p_io/p_iow function constants */ +/* Generic I/O functions */ +#define P_FPANIC 0 /* Panic the device */ +#define P_FREAD 1 /* Read */ +#define P_FWRITE 2 /* Write */ +#define P_FCLOSE 3 /* Close */ +#define P_FCANCEL 4 /* Cancel io */ +#define P_FATTACH 5 /* attach this pseudo device */ +#define P_FDETACH 6 /* detach this pseudo device */ +#define P_FSET 7 /* set channel characteristics */ +#define P_FSENSE 8 /* sense channel characteristics */ +#define P_FFLUSH 9 /* Flush buffers */ +/* Now follows the device specific functions */ +/* Timer device driver */ +#define P_FRELATIVE P_FREAD /* Relative timer */ +#define P_FABSOLUTE P_FWRITE /* Absolute timer */ +/* Files */ +#define P_FSEEK 10 /* Seek */ +#define P_FSETEOF 11 /* Set end of file */ +/* Data Link I/O + wserv */ +#define P_FCONNECT 10 /* Queue a link connect request */ +#define P_FDISCONNECT 11 /* Disconnect the link */ +/* wserv functions */ +#define P_FWRITE_REPLY 12 /* P_FWRITE + read a reply from the server */ +/* Serial/llmac */ +#define P_FTEST 10 /* return no. of bytes in serial receieve buffer */ +#define P_FCTRL 11 /* serial port control lines */ +#define P_FINQ 12 /* inquire of device capabilities */ +#define P_FRSUPER 13 /* read a supervisory frame (p_llmac) */ +#define P_FSTOP 14 /* stop LLMAC mode */ +#define P_FSTART 15 /* start LLMAC mode */ +/* Serial LDD to Serial PDD I/O defines */ +#define P_FENABLE 16 /* Enable transmit interrupts */ +#define P_FSETINT 17 /* set the serial Interrupt code ptrs */ +/* modem functions */ +#define P_FMINIT 16 /* modem initialization function */ +#define P_FMDIAL 17 /* modem dial function */ +#define P_FMWAITCALL 18 /* wait for an incoming call */ +#define P_FMSENSE 19 /* Sense Modem characteristics */ +#define P_FMSET 20 /* Set Modem characteristics */ +#define P_FMCANCEL 21 /* Cancel outstanding mode request */ +#define P_FMWRITE 22 /* Write a configuration string to modem with timeout */ +/* p_seek() mode constants */ +#define P_FABS 1 /* Position absolute in the file */ +#define P_FEND 2 /* Position relative from the end of file */ +#define P_FCUR 3 /* Position relative to the current pos */ +#define P_FRSENSE 4 /* Sense the record position */ +#define P_FRSET 5 /* Set the record position */ +#define P_FREWIND 6 /* Rewind a text file */ + +/* IRDA Defines */ +#define P_FIRDISCONNECT 4 /* Disconnect from remote machine */ +#define P_FIRAWAITCONNECT 5 /* Wait for a connection from a remote machine */ +#define P_FIRDISCOVER 6 /* Discover remote machines */ +#define P_FIRSELECT 7 /* Select a remote machine */ +#define P_FIRMAKECONNECT 8 /* Make a connection to a remote machine */ + +/* file errors */ +#define ExistsErr (-32) +#define NotExistsErr (-33) +#define WriteErr (-34) +#define ReadErr (-35) +#define EofErr (-36) +#define FullErr (-37) +#define NameErr (-38) +#define AccessErr (-39) +#define LockedErr (-40) +#define DeviceErr (-41) +#define DirErr (-42) +#define RecordErr (-43) +#define ReadOnlyErr (-44) +#define IoInvalidErr (-45) +#define PendingErr (-46) +#define VolumeErr (-47) +#define CancelErr (-48) +#define IoAllocErr (-10) /* E_GEN_NOMEMORY */ +#define DisconnectErr (-50) +#define ConnectErr (-51) +#define ReTransmitErr (-52) +#define LineErr (-53) +#define InActivityErr (-54) +#define ParityErr (-55) +#define FrameErr (-56) +#define OverrunErr (-57) +#define ModemConnectErr (-58) +#define ModemBusyErr (-59) +#define ModemNoAnswerErr (-60) +#define ModemBlacklistErr (-61) +#define NotReadyErr (-62) +#define UnknownErr (-63) +#define DirFullErr (-64) +#define WriteProtectErr (-65) +#define CorruptMediaErr (-66) +#define AbortErr (-67) +#define EraseErr (-68) +#define InvalidFileErr (-69) +#define E_FILE_EXIST ExistsErr /* File already exists */ +#define E_FILE_NXIST NotExistsErr /* File does not exist */ +#define E_FILE_WRITE WriteErr /* Write to file failed */ +#define E_FILE_READ ReadErr /* Read from file failed */ +#define E_FILE_EOF EofErr /* Read past end of file */ +#define E_FILE_FULL FullErr /* Disk/serial read buffer full */ +#define E_FILE_NAME NameErr /* Invalid file name */ +#define E_FILE_ACCESS AccessErr /* Access denied */ +#define E_FILE_LOCKED LockedErr /* Record or file locked */ +#define E_FILE_DEVICE DeviceErr /* Device does not exist */ +#define E_FILE_DIR DirErr /* Directory does not exist */ +#define E_FILE_RECORD RecordErr /* Record too large */ +#define E_FILE_RDONLY ReadOnlyErr /* File has read only access */ +#define E_FILE_INV IoInvalidErr /* Invalid I/O operation */ +#define E_FILE_PENDING PendingErr /* I/O pending (not yet completed) */ +#define E_FILE_VOLUME VolumeErr /* Invalid volume */ +#define E_FILE_CANCEL CancelErr /* Async operation was cancelled */ +#define E_FILE_ALLOC IoAllocErr /* No memory for control block */ +#define E_FILE_DISC DisconnectErr /* link is disconnected */ +#define E_FILE_CONNECT ConnectErr /* link already connected */ +#define E_FILE_RETRAN ReTransmitErr /* Retransmission threshold exceeded */ +#define E_FILE_LINE LineErr /* Physical link failure */ +#define E_FILE_INACT InActivityErr /* Inactivity timer expired */ +#define E_FILE_PARITY ParityErr /* Serial parity error */ +#define E_FILE_FRAME FrameErr /* Serial framing error */ +#define E_FILE_OVERRUN OverrunErr /* Serial overrun error */ +#define E_MDM_CONFAIL ModemConnectErr /* modem can't connect to remote modem */ +#define E_MDM_BUSY ModemBusyErr /* remote number busy */ +#define E_MDM_NOANS ModemNoAnswerErr /* there was no answer */ +#define E_MDM_BLACKLIST ModemBlacklistErr /* number blacklisted by the modem*/ +#define E_FILE_NOTREADY NotReadyErr /* Drive not ready error */ +#define E_FILE_UNKNOWN UnknownErr /* Unknown media in drive */ +#define E_FILE_DIRFULL DirFullErr /* Root dir full error */ +#define E_FILE_PROTECT WriteProtectErr /* Device write protect */ +#define E_FILE_CORRUPT CorruptMediaErr /* Media is corrupt */ +#define E_FILE_ABORT AbortErr /* User aborted operation error */ +#define E_FILE_ERASE EraseErr /* Failed to Erase Flash pack */ +#define E_FILE_INVALID InvalidFileErr /* Invalid file for DBF system */ +/* defines for changing directories */ +#define P_CD_ROOT 0 /* goto root directory */ +#define P_CD_PARENT 1 /* goto parent directory */ +#define P_CD_SUBDIR 2 /* goto subdirectory */ +/* masks for status flag of P_INFO */ +#define P_FAWRITE 0x01 /* can the file be written to? */ +#define P_FAHIDDEN 0x02 /* set if file is hidden */ +#define P_FASYSTEM 0x04 /* set if file is a system file */ +#define P_FAVOLUME 0x08 /* set if the name is a volume name */ +#define P_FADIR 0x10 /* set if file is a directory file */ +#define P_FAMOD 0x20 /* has the file been modified? */ +#define P_FAREAD 0x100 /* can the file be read? */ +#define P_FAEXEC 0x200 /* is the file executable? */ +#define P_FASTREAM 0x400 /* is the file a byte stream file? */ +#define P_FATEXT 0x800 /* is it a text file? */ +/* File system File information - p_finfo() */ +typedef struct { +unsigned short int version; /* for future expansion */ +unsigned short int status; /* status bits */ +unsigned long int size; /* size of the file */ +unsigned long int modst; /* system time of last modification */ +unsigned char spare[4]; /* spare bytes for future expansion */ +} P_INFO; +#define P_VOLUMENAME 32 +#define P_FMEDIA_UNKNOWN 0 +#define P_FMEDIA_FLOPPY 1 +#define P_FMEDIA_HARDDISK 2 +#define P_FMEDIA_FLASH 3 +#define P_FMEDIA_RAM 4 +#define P_FMEDIA_ROM 5 +#define P_FMEDIA_WRITEPROTECTED 6 +#define P_FMEDIA_COMPRESSIBLE 0x8000 /* Worth compressing deleted records */ +#define P_FMEDIA_DYNAMIC 0x4000 /* Media size is dynamic */ +#define P_FMEDIA_INTERNAL 0x2000 /* Media is internal */ +#define P_FMEDIA_DUAL_DENSITY 0x1000 +#define P_FMEDIA_FORMATTABLE 0x800 +/* File System Device information - p_dinfo() */ +typedef struct { +unsigned short int version; /* for future expansion */ +unsigned short int mediatype; /* what type of device is this */ +unsigned short int removable; /* is device removable or not */ +unsigned long int size; /* size of the device */ +unsigned long int free; /* amount of device still free */ +char name[P_VOLUMENAME]; /* the volume name of the device */ +short int batterystate; /* Device battery status */ +unsigned char spare[16]; /* spare bytes for future expansion */ +} P_DINFO; +#define P_FSYSTYPE_FLAT 0 +#define P_FSYSTYPE_HIER 1 +/* File System Node information - p_ninfo() */ +typedef struct { +unsigned short int version; /* for future expansion */ +unsigned short int type; /* file system type (flat/hierarchical...) */ +unsigned short int formattable; /* TRUE if node supports format cmds else FALSE */ +unsigned char spare[26]; /* spare bytes for future expansion */ +} P_NINFO; +/* Flag defines for p_fparse */ +#define P_PWILD_ANY 0x01 /* contains one or more wildcards */ +#define P_PWILD_NAME 0x02 /* the name field contains wildcards */ +#define P_PWILD_EXT 0x04 /* the extension contains wildcards */ +/* Full file system parse - p_fparse() */ +#define P_FSYSNAMESIZE 5 +typedef struct { +unsigned char system; /* file system name length */ +unsigned char device; /* device name length */ +unsigned char path; /* path name length */ +unsigned char name; /* name length */ +unsigned char ext; /* extension length */ +unsigned char flags; /* information on the presence of wildcards */ +} P_FPARSE; +#define P_FBLKSHIFT 9 /* Block shift factor */ +#define P_FBLKSIZE 0x200 /* Block size */ +#define P_FMAXRSIZE 0x100 /* Maximum text record size */ +#define P_FMAXSSIZE 0x4000 /* Maximum stream read/write length */ +#define P_FSIZRPOS sizeof(long int) /* array size for storing r/w position */ +#define P_MAXDEV 128 /* Maximum device name size */ +#define P_MAXPATH 128 /* Maximum path size */ +#define P_MAXNAME 128 /* Maximum name size */ +#define P_MAXEXTN 128 /* Maximum extension size */ +#define P_FNAMESIZE 128 /* Maximum file name size */ +/* BINARY FILE SIGNATURE FOR APPLICATION FILES */ +typedef struct +{ +char app_id[3]; /* application id */ +unsigned char chk_sum; /* application id checksum */ +unsigned char file_vn; /* file version number */ +unsigned char app_vn; /* application version number */ +} P_FSIG; +#ifdef __cplusplus +extern "C" { +#endif +extern void cdecl p_inst(P_DEVICE *,...); +#pragma save,call(reg_param =>(bx,cx,di,si,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_fparse(const char *,const char *,char *,P_FPARSE *); +extern int f_fparse(const char *,const char *,char *,P_FPARSE *); +extern int p_fparseasync(const char *,const char *,char *,P_FPARSE *,short int *); +extern int p_finfo(const char *,P_INFO *); +extern int p_finfoasync(const char *,P_INFO *,short int *); +extern int p_ninfo(const char *,P_NINFO *); +extern int p_ninfoasync(const char *,P_NINFO *,short int *); +extern int p_dinfo(const char *,P_DINFO *); +extern int p_dinfoasync(const char *,P_DINFO *,short int *); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_FILE_H diff --git a/code/SIBOSDK/include/p_frame.h b/code/SIBOSDK/include/p_frame.h new file mode 100644 index 0000000..fa053b0 --- /dev/null +++ b/code/SIBOSDK/include/p_frame.h @@ -0,0 +1,37 @@ +/* HEADER - P_FRAME.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_FRAME_H +#define P_FRAME_H + +#include +#include +#include + +typedef struct +{ +/* Transmit stuff */ +P_CRC tcrc; /* the CRC for the transmitted data */ +unsigned char *pbuf; /* where to extract next byte from transmit buffer */ +unsigned char *pend; /* ptr to end of data in transmit buffer */ +unsigned char tcntl; /* the control byte to transmit */ +unsigned char tstat; /* current transmit frame state */ +/* receive stuff */ +unsigned short int rlen; /* current received frame length */ +unsigned char rstat; /* current receive frame state */ +unsigned char rtyp; /* current receive frame type */ +unsigned char rseq; /* current receive frame sequence */ +unsigned char rfull; /* TRUE if a complete data frame is in buffer */ +P_CRC rcrc; /* the CRC for the received data */ +P_FRAME dfrm; /* the internal data frame */ +short int numfrm; /* number of frames currently in supervisory Q */ +P_FRAME *prfin; /* entry pt to supervisory frame Q */ +P_FRAME *prfout; /* removal pt of supervisory frame Q */ +P_FRAME rfrm[MAXFRM]; /* supervisory frame Q */ +} P_FRMCB; + +#endif // P_FRAME_H \ No newline at end of file diff --git a/code/SIBOSDK/include/p_gen.h b/code/SIBOSDK/include/p_gen.h new file mode 100644 index 0000000..13e770e --- /dev/null +++ b/code/SIBOSDK/include/p_gen.h @@ -0,0 +1,68 @@ +/* HEADER - P_GEN.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_GEN_H +#define P_GEN_H + +#include + +/* general errors */ +#define NoErr 0 /* no error !! */ +#define FailErr (-1) /* Failure */ +#define ArgumentErr (-2) /* Invalid arguments */ +#define OsErr (-3) /* Operating system error */ +#define NotSupportedErr (-4) /* Not supported function */ +#define UnderflowErr (-5) /* Underflow */ +#define OverflowErr (-6) /* Overflow */ +#define E_GEN_FAIL FailErr +#define E_GEN_ARG ArgumentErr +#define E_GEN_OS OsErr +#define E_GEN_NSUP NotSupportedErr +#define E_GEN_UNDER UnderflowErr +#define E_GEN_OVER OverflowErr +#define RangeErr (-7) /* Argument range */ +#define DivideByZeroErr (-8) /* Divide by zero */ +#define InUseErr (-9) /* Resource in use */ +#define NoMemoryErr (-10) /* No memory left */ +#define NoSegmentsErr (-11) /* No segments left */ +#define NoSemaphoreErr (-12) /* No semaphores left */ +#define NoProcessErr (-13) /* No processes left */ +#define AlreadyOpenErr (-14) /* Resource already open */ +#define NotOpenErr (-15) /* Resource not open */ +#define ImageErr (-16) /* Invalid image file */ +#define NoReceiverErr (-17) /* No message receiver */ +#define NoDevicesErr (-18) /* No devices left */ +#define NoFileSystemErr (-19) /* No file system left */ +#define FailedToStartErr (-20) /* Failed to start application */ +#define FontNotLoadedErr (-21) +#define TooWideErr (-22) +#define TooManyItemsErr (-23) +#define BatLowSoundErr (-24) +#define BatLowFlashErr (-25) +#define E_GEN_RANGE RangeErr +#define E_GEN_DIVIDE DivideByZeroErr +#define E_GEN_INUSE InUseErr +#define E_GEN_NOMEMORY NoMemoryErr +#define E_GEN_NOSEGMENTS NoSegmentsErr +#define E_GEN_NOSEM NoSemaphoreErr +#define E_GEN_NOPROC NoProcessErr +#define E_GEN_OPEN AlreadyOpenErr +#define E_GEN_NOTOPEN NotOpenErr +#define E_GEN_IMAGE ImageErr +#define E_GEN_RECEIVER NoReceiverErr +#define E_GEN_DEVICE NoDevicesErr +#define E_GEN_FSYS NoFileSystemErr +#define E_GEN_START FailedToStartErr +#define E_GEN_NOFONT FontNotLoadedErr +#define E_GEN_TOOWIDE TooWideErr +#define E_GEN_TOOMANY TooManyItemsErr +#define E_GEN_BATSOUND BatLowSoundErr +#define E_GEN_BATFLASH BatLowFlashErr +#define E_KILLEXIT 0 /* Died by being killed */ +#define E_PANICEXIT 1 /* Died by a panic */ + +#endif // P_GEN_H \ No newline at end of file diff --git a/code/SIBOSDK/include/p_graf.h b/code/SIBOSDK/include/p_graf.h new file mode 100644 index 0000000..f1a7dd1 --- /dev/null +++ b/code/SIBOSDK/include/p_graf.h @@ -0,0 +1,62 @@ +/* HEADER - P_GRAF.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_GRAF_H +#define P_GRAF_H + +#include + +typedef struct +{ +short int x; /* Horizontal coordinate */ +short int y; /* Vertical coordinate */ +} P_POINT; +typedef struct +{ +P_POINT tl; /* Top left point */ +P_POINT br; /* Bottom right point */ +} P_RECT; +typedef struct +{ +P_RECT r; /* Rectangle */ +P_POINT p; /* Point */ +} P_RECTP; +typedef struct +{ +P_POINT tl; /* Top left point */ +unsigned short int width; /* Width */ +unsigned short int height; /* Height */ +} P_EXTENT; +typedef struct +{ +unsigned short int *addr; /* address of 2-dimensional bit array */ +P_RECT area; /* area bounding the picture within bit array */ +unsigned short int bytewid; /* number of bytes in a row */ +} P_BITMAP; +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_param =>(si,di),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +extern void p_absrec(const P_RECT *,P_RECT *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_emprec(const P_RECT *); +#pragma call(reg_param =>(bx,ax,di),reg_saved =>(ax,bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_insrec(P_RECT *,int,int); +#pragma call(reg_param =>(si,bx,di),reg_saved =>(EPOC_SAVE)) +extern int p_intrec(const P_RECT *,const P_RECT *,P_RECT *); +#pragma call(reg_param =>(bx,ax,dx),reg_saved =>(ax,bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_offrec(P_RECT *,int,int); +#pragma call(reg_param =>(di,bx),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +extern int p_pinrec(const P_POINT *,const P_RECT *); +#pragma call(reg_param =>(si,bx,di),reg_saved =>(bx,EPOC_SAVE)) +extern void p_unirec(const P_RECT *,const P_RECT *,P_RECT *); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_GRAF_H diff --git a/code/SIBOSDK/include/p_just.h b/code/SIBOSDK/include/p_just.h new file mode 100644 index 0000000..8c2631a --- /dev/null +++ b/code/SIBOSDK/include/p_just.h @@ -0,0 +1,18 @@ +/* HEADER - P_JUST.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_JUST_H +#define P_JUST_H + +#include + +/* parameters to p_jtob */ +#define P_JLEFT 0 +#define P_JRIGHT 1 +#define P_JCENTRE 2 + +#endif // P_JUST_H diff --git a/code/SIBOSDK/include/p_keyb.h b/code/SIBOSDK/include/p_keyb.h new file mode 100644 index 0000000..d0baaa1 --- /dev/null +++ b/code/SIBOSDK/include/p_keyb.h @@ -0,0 +1,23 @@ +/* HEADER - P_KEYB.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_KEYB_H +#define P_KEYB_H + +#include + +#ifndef _P_CON_KBREC +#define _P_CON_KBREC +typedef struct +{ +unsigned short int keycode; /* Code for the key pressed */ +unsigned char modifiers; /* A bit set for each modifier key held down */ +unsigned char count; +} P_CON_KBREC; +#endif + +#endif // P_KEYB_H diff --git a/code/SIBOSDK/include/p_link.h b/code/SIBOSDK/include/p_link.h new file mode 100644 index 0000000..84a9ca3 --- /dev/null +++ b/code/SIBOSDK/include/p_link.h @@ -0,0 +1,43 @@ +/* HEADER - P_LINK.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_LINK_H +#define P_LINK_H + +#include +#include +#include + +/* P_FCONNECT service connection modes */ +#define P_LINK_ACCP 0 /* want link as acceptor */ +#define P_LINK_INIT 1 /* want link as initiator */ +/* Link layer states */ +#define P_LINK_IDLE 0 /* no connection - idle */ +#define P_LINK_IDLE_LR 1 /* no connection - awaiting LR */ +#define P_LINK_DATA_IDLE 2 /* connected - idle */ +#define P_LINK_DATA_LA 3 /* connected - awaiting LA */ +#define P_LINK_IDLE_LA 4 /* not connected - awaiting LA (or LT) to LR */ +/* State and event log record */ +typedef struct +{ +unsigned char state; +unsigned char event; +} P_LLLOG; +#define P_LINK_NLOG 32 /* Max number of debug events,states we record */ +#define P_LINK_LOG_MASK 0xC0 +#define P_LINK_LOG_PANIC 0xC0 /* panic number */ +#define P_LINK_LOG_MAC 0x00 /* MAC request or timer */ +#define P_LINK_LOG_REQ 0x80 /* User request */ +#define P_LINK_LOG_COMP 0x40 /* User completion */ +typedef struct +{ +P_LLMAC mac; /* LLMAC characteristics */ +unsigned short int br_cnt; /* count of broken frames */ +unsigned short int rx_cnt; /* re-transmission count */ +} P_LLDATA; + +#endif // P_LINK_H diff --git a/code/SIBOSDK/include/p_llmac.h b/code/SIBOSDK/include/p_llmac.h new file mode 100644 index 0000000..53d8073 --- /dev/null +++ b/code/SIBOSDK/include/p_llmac.h @@ -0,0 +1,37 @@ +/* HEADER - P_LLMAC.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_LLMAC_H +#define P_LLMAC_H + +#include + +#define P_MAXILEN 300 /* maximum length of information field */ +#define MAXFRM 4 /* maximum number of frames in supervisory Q */ +#define SERNOCHAR (-1) /* no character to transmit */ +/* Frame type codes */ +#define LA_LPDU 0 /* The Link Acknowledge PDU */ +#define LD_LPDU 1 /* The Link disconnect PDU */ +#define LR_LPDU 2 /* The Link Request PDU*/ +#define LT_LPDU 3 /* The Link Data PDU */ +#define P_FRM_BROKEN 4 /* A broken frame */ +typedef struct +{ +unsigned char type; /* frame type or P_FRM_BROKEN for a broken frame */ +unsigned char seq; /* frame sequence */ +short int len; /* length of information field */ +unsigned char *pbuf; /* data buffer (INFO) */ +} P_FRAME; +/* LLMAC layer characteristics */ +typedef struct +{ +unsigned short int ilen; /* maximum information field length */ +unsigned short int speed; /* nominal speed in characters per second */ +unsigned short int rtint; /* suggested retransmission interval */ +} P_LLMAC; + +#endif // P_LLMAC_H diff --git a/code/SIBOSDK/include/p_math.h b/code/SIBOSDK/include/p_math.h new file mode 100644 index 0000000..dce34e4 --- /dev/null +++ b/code/SIBOSDK/include/p_math.h @@ -0,0 +1,103 @@ +/* HEADER - P_MATH.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_MATH_H +#define P_MATH_H + +#include + +#define ABS(x) ((x)<0 ? -(x) : (x)) +#define MAX(a,b) ((a)>(b) ? (a) : (b)) +#define MIN(a,b) ((a)<(b) ? (a) : (b)) +#define P_FLT_MAXEXP 1023 /* maximum magnitude of float exponent */ +#define P_FLT_MANT 53 /* number of bits in mantissa (binary precission) */ +#define P_FLT_PREC 15 /* approximate precision in decimal digits */ +/* Cracked form of double float */ +typedef struct +{ +short int sign; /* P_FLT_ZERO,P_FLT_POS or P_FLT_NEG */ +short int exp; /* signed binary exponent */ +unsigned long int mant[2]; /* mantissa (least significant integer first) */ +} P_CRKFLT; +/* values for sign above */ +#define P_FLT_ZERO 0 /* value is zero */ +#define P_FLT_POS 1 /* value is positive */ +#define P_FLT_NEG 2 /* value is negative */ +/* format specification for p_dtob() */ +typedef struct +{ +unsigned char type; /* conversion type */ +unsigned char width; /* width of representation in characters */ +unsigned char ndec; /* number of decimal places */ +char point; /* decimal point character */ +char triad; /* triad separator character */ +unsigned char trilen; /* threshold for triad character use */ +} P_DTOB; +/* values for type in the above */ +#define P_DTOB_FIXED 0 /* fixed number of decimap points */ +#define P_DTOB_EXPONENT 1 /* exponent notation */ +#define P_DTOB_GENERAL 2 /* general format */ +/* Struct for p_poly() */ +typedef struct +{ +unsigned short int num; /* number of coefficients */ +double c[1]; /* coefficient table */ +} P_POLY; +/* DOUBLE constants */ +#define SQHF .70710678118654752440 /* Square root of a half */ +#define RLN2 1.4426950408889634 /* Reciprocal of ln 2 */ +#define RLN10 0.4342944819032518 /* Reciprocal of ln 10 */ +#define RLG2 0.3010299956639812 /* Reciprocal of log 2 */ +#define PI 3.1415926535897932 /* Pi */ +#define RPI 0.3183098861837907 /* Reciprocal of Pi */ +#define PIB2 1.5707963267948966 /* pi/2 */ +#define DRPI 0.6366197723675813 /* 2/pi */ +#define SQT3 1.7320508075688773 /* Square root of three */ +#define MSQ3 0.2679491924311227 /* 2 minus square root of three */ +#define RADTODEG 57.29577951308232 /* 1 radian in degrees (180/pi) */ +#define DEGTORAD 0.017453292519943296 /* 1 degree in radians */ +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_param =>(si,di,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_stod(char **,double *,int); +#pragma call(reg_param =>(di,si,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_dtob(char *,const double *,P_DTOB *); +extern int p_acos(double *,const double *); +extern int p_asin(double *,const double *); +extern int p_atan(double *,const double *); +extern int p_cos(double *,const double *); +extern int p_exp(double *,const double *); +extern int p_ln(double *,const double *); +extern int p_log(double *,const double *); +extern int p_mod(double *,const double *,const double *); +extern int p_pow(double *,const double *,const double *); +extern int p_sin(double *,const double *); +extern int p_sqrt(double *,const double *); +extern int p_tan(double *,const double *); +extern int p_int(double *,const double *); +extern int p_inti(short int *,const double *); +extern int p_fadd(double *,const double *); +extern int p_fsub(double *,const double *); +extern int p_fmul(double *,const double *); +extern int p_fdiv(double *,const double *); +extern int p_fcmp(double *,const double *); +extern void p_frand(double *,double *); +extern int p_fld(double *,const double *); +extern void p_itof(double *,const short int *); +extern int p_fneg(double *); +#pragma call(reg_param =>(di,si,dx),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern int p_intl(long int *,const double *); +extern void p_longtof(double *,const long int *); +#pragma call(reg_param =>(di,si,dx),reg_saved =>(si,EPOC_SAVE)) +extern double p_rand(unsigned long int *); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_MATH_H diff --git a/code/SIBOSDK/include/p_modem.h b/code/SIBOSDK/include/p_modem.h new file mode 100644 index 0000000..fc03e59 --- /dev/null +++ b/code/SIBOSDK/include/p_modem.h @@ -0,0 +1,32 @@ +/* HEADER - P_MODEM.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_MODEM_H +#define P_MODEM_H + +#include + +/* what options are selected */ +#define P_MDM_TONE 0x01 /* as opposed to PULSE dialling (default) */ +#define P_MDM_BELL 0x02 /* as opposed to CCITT (default) */ +#define P_MDM_NO_MODULATION 0x04 /* as opposed to CCITT or BELL */ +#define P_MDM_CONSTANT_SPEED 0x08 /* modem has constant speed interface */ +/* Error correction types */ +#define P_MDM_ERRCORRECT_NONE 0 /* NO error correction */ +#define P_MDM_ERRCORRECT 1 /* some form of error correction (ARQ)*/ +#define P_MDM_ERRCORRECT_MNP 2 /* MNP error correction being used */ +#define P_MDM_ERRCORRECT_V42 3 /* V42 error correction being used */ +typedef struct + { + unsigned short int supported; /* what baud rates are supported by modem */ + unsigned short int options; /* flags which options are selected */ + unsigned short int baudrate; /* baud rate currently running at/to run at */ + unsigned char chand; /* connected handshaking */ + unsigned char ichand; /* incoming call handshaking */ + } P_MDMCHR; + +#endif // P_MODEM_H diff --git a/code/SIBOSDK/include/p_ncp.h b/code/SIBOSDK/include/p_ncp.h new file mode 100644 index 0000000..e07c0ec --- /dev/null +++ b/code/SIBOSDK/include/p_ncp.h @@ -0,0 +1,131 @@ +/* HEADER - P_NCP.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_NCP_H +#define P_NCP_H + +#include + +#define NCLINK_VERSION_NUMBER 3 +#define NCLINK_MINOR_VERNO 1 +typedef struct +{ +unsigned char *pcb; /* Handle to call */ +int handler; /* Handler handler */ +unsigned char *(*Install)(); /* Install server */ +void (*Remove)(); /* Remove the server */ +int (*WaitHandler)(); /* Wait handler function to call */ +unsigned char name[16]; /* name of the server */ +} P_NCP; +/* Informational data obtained by supervisory reads */ +#define PHYS_LINK_FAILED 0 /* Link layer has failed*/ +#define PHYS_CONNECT_FAILED 1 /* Waiting for connection failed */ +#define PHYS_CHARS_FAILED 2 /* Setting serial characteristics failed */ +#define PHYS_INIT_FAILED 3 /* Initialization of modem failed */ +#define PHYS_DIAL_FAILED 4 /* Dialling phone number failed */ +#define PHYS_MDMCONFIG_FAILED 5 /* additional modem config failed */ +#define PHYS_PHYS_LINK_ESTABLISHED 6 /* A physical link established */ +#define PHYS_WAITING_FOR_CALL 7 /* Physical layer waiting for call */ +#define PHYS_DIALLING_NUMBER 8 /* Physical layer dialling */ +#define PHYS_CONFIGURING_MODEM 9 /* configuring modem */ +#define PHYS_NCP_LINK_ESTAB_OK 10 /* Ncp link established OK */ +#define PHYS_NCP_LINK_ESTAB_NEW_NCP 11 /* Talking to different Ncp */ +#define PHYS_NCP_LINK_ESTAB_INVALID_VER 12 /* Remote NCP is V1.0 !!*/ +#define PHYS_NCP_LINK_END 13 /* remote NCP is terminating */ +#define PHYS_SERCONFIG_FAILED 14 /* serial port not there */ +/* type of message to add to the queue */ +#define NCONT_MSG_SEND 0 /* controller */ +#define NUSER_MSG_SEND 1 /* users */ +#define NEXPEDIATED_MSG_SEND 2 /* expediated */ +/***************************************************************************/ +/* NUCB flags defines */ +#define NUFLAG_WRITE_HELD 0x01 +#define NUFLAG_WRITE_OUTSTANDING 0x02 +#define NUFLAG_CONNECT_REQUEST 0x08 +#define NUFLAG_DISCONNECTED 0x10 +#define NUFLAG_ALLOCATED 0x20 +#define NUFLAG_CHANNEL_CLOSED 0x40 +#define NUFLAG_DISCONNECT_REQUEST 0x80 +#define NUFLAG_TEMPDISC 0x100 +#define NUFLAG_NO_CONNECTION (NUFLAG_TEMPDISC|NUFLAG_DISCONNECTED) +#define NC_VERSION_NUMBER 2 /* were version 2 */ +#define NC_MAX_USERCB 8 /* Max number of connected users */ +#define NC_MSG_SIZE 8 /* Max inter controller msg size */ +typedef struct nudata /* Network user data control block */ +{ +struct nudata *pnudata; /* next control blk in list */ +unsigned short int reclen; /* amount in buffer */ +unsigned char recbuf[1]; /* expands as required (for C offset) */ +} NUDATA; +typedef struct /* Network User control block */ +{ +P_ICB icb; /* I/O control block */ +unsigned short int flags; /* controlling flags */ +P_RQPKT read; /* read request block */ +P_RQPKT write; /* write request block */ +P_RQPKT super; /* supervisory read request blk */ +P_NCP *pncp; /* open channel control blk ptr */ +unsigned char localchanid; /* local channel id number */ +unsigned char remotechanid; /* remote channel id number */ +unsigned char *pncb; /* Network handle */ +unsigned char *handler; /* Network client wait handler handle */ +NUDATA *pnudata; /* Network users queued data */ +unsigned short int nclen; /* amount in the Network Controller msg buffer */ +unsigned char ncbuf[NC_MSG_SIZE]; /* message buffer */ +unsigned short int recvbytes; /* Number of bytes received (>1K) */ +unsigned short int xmitbytes; /* Number of bytes xmitted (>1K) */ +unsigned long int recvK; /* Number of K received */ +unsigned long int xmitK; /* Number of K transmitted */ +} NUCB; +/*************************************************************************/ +/* Inter controller message types */ +#define NCON_MSG_DATA_XOFF 1 +#define NCON_MSG_DATA_XON 2 +#define NCON_MSG_CONNECT_TO_SERVER 3 +#define NCON_MSG_CONNECT_RESPONSE 4 +#define NCON_MSG_CHANNEL_CLOSED 5 +#define NCON_MSG_NCP_INFO 6 /* MUST BE 6 for older versions*/ +#define NCON_MSG_CHANNEL_DISCONNECT 7 +#define NCON_MSG_NCP_END 8 +/* Inter Network user message types */ +#define NU_MSG_WRITECOMPLETE 1 +#define NU_MSG_WRITEPARTIAL 2 +#define NC_LINK_ACTIVE 0x01 +#define NC_READ_QUEUED 0x02 +#define NC_WRITE_QUEUED 0x04 +#define NC_TERMINATING 0x08 +#define NC_OWNER_CLOSE_REQUEST 0x10 +#define CONNECT_STATE_0 0 +#define CONNECT_STATE_1 1 +#define CONNECT_STATE_2 2 +typedef struct +{ +unsigned short int flags; /* Controlling flags */ +short int ctrlmsgqueue; /* Network users have controller messages queued */ +short int ctrllastxmit; /* Network users last transmitted a ctrl msg */ +short int usermsgqueue; /* Network users have queued write requests */ +short int userlastxmit; /* Network users last transmitted a user msg */ +unsigned short int maxfrmsize; /* maximum frame we can transmit/receive */ +short int wstat; /* Write completion status */ +short int rstat; /* Read completion status */ +unsigned short int wlen; /* Write length */ +unsigned short int rlen; /* Read length */ +unsigned char *handler; /* Network controller wait handler handle */ +unsigned char *plcb; /* link layer that were using */ +unsigned short int connected; /* connected state */ +unsigned short int remotencpver; /* the remote NCP version number */ +unsigned long int startdate; /* NCP start up date (logon id) */ +unsigned long int remotestartdate; /* the remote NCP logon id */ +unsigned short int expediatedlen; /* amount in expediated buf to transmit */ +unsigned char expediatedbuf[NC_MSG_SIZE]; +NUCB *lastnucb; /* last network user to do a write */ +unsigned char rbuf[P_MAXILEN]; /* read buffer */ +unsigned char wbuf[P_MAXILEN]; /* write buffer */ +NUCB usertable[NC_MAX_USERCB]; +} NCB; + +#endif // P_NCP_H diff --git a/code/SIBOSDK/include/p_nmsys.h b/code/SIBOSDK/include/p_nmsys.h new file mode 100644 index 0000000..aad40e6 --- /dev/null +++ b/code/SIBOSDK/include/p_nmsys.h @@ -0,0 +1,23 @@ +/* HEADER - P_NMSYS.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_NMSYS_H +#define P_NMSYS_H + +#include + +#define P_SYSNAME_FIL 0 +#define P_SYSNAME_TIM 1 +#define P_SYSNAME_TTY 2 +#define P_SYSNAME_HMD 3 +#define P_SYSNAME_MAS 4 +#define P_SYSNAME_LLC 5 +#define P_SYSNAME_NLC 6 +#define P_SYSNAME_XMD 7 +#define P_SYSNAME_NCP 8 + +#endif // P_NMSYS_H diff --git a/code/SIBOSDK/include/p_object.h b/code/SIBOSDK/include/p_object.h new file mode 100644 index 0000000..40ab808 --- /dev/null +++ b/code/SIBOSDK/include/p_object.h @@ -0,0 +1,104 @@ +/* HEADER - P_OBJECT.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_OBJECT_H +#define P_OBJECT_H + +#include + +#define METHOD +typedef struct p_class +{ +unsigned short int cat; /* category id */ +struct p_class *super; /* superclass class */ +unsigned short int len; /* length of instance */ +unsigned char base; /* base function number */ +unsigned char sig_6b; /* signature - should be 0x6b */ +unsigned char num; /* number of entries in vector table */ +unsigned char ncomp; /* number of component objects */ +} P_CLASS; +typedef struct +{ +int hcat; +int hclass; +} P_OBJECT; +typedef int P_CATID; /* category identifier */ +typedef struct +{ +P_CATID cat; /* category identifier */ +unsigned short int xclass; /* class number */ +} P_CLASSID; +#define METHOD_CALL call(reg_param =>(bx,dx,si,di),reg_saved =>(ds,st1,st2)) +#define p_send3(o,m,p1) _p_send3(o,m,(void *)(p1)) +#define p_send4(o,m,p1,p2) _p_send4(o,m,(void *)(p1),(void *)(p2)) +#define p_send5(o,m,p1,p2,p3) _p_send5(o,m,(void *)(p1),(void *)(p2),(void *)(p3)) +#define f_send3(o,m,p1) _f_send3(o,m,(void *)(p1)) +#define f_send4(o,m,p1,p2) _f_send4(o,m,(void *)(p1),(void *)(p2)) +#define f_send5(o,m,p1,p2,p3) _f_send5(o,m,(void *)(p1),(void *)(p2),(void *)(p3)) +#define p_entersend3(o,m,p1) _p_entersend3(o,m,(void *)(p1)) +#define p_entersend4(o,m,p1,p2) _p_entersend4(o,m,(void *)(p1),(void *)(p2)) +#define p_entersend5(o,m,p1,p2,p3) _p_entersend5(o,m,(void *)(p1),(void *)(p2),(void *)(p3)) +#define p_supersend3(o,m,p1) _p_supersend3(o,m,(void *)(p1)) +#define p_supersend4(o,m,p1,p2) _p_supersend4(o,m,(void *)(p1),(void *)(p2)) +#define p_supersend5(o,m,p1,p2,p3) _p_supersend5(o,m,(void *)(p1),(void *)(p2),(void *)(p3)) +#ifdef __cplusplus +extern "C" { +#endif +extern int cdecl p_send(void *,unsigned char,...); +extern int cdecl f_send(void *,unsigned char,...); +extern int cdecl p_qsend(void *,unsigned char,...); +extern void * cdecl f_newsend(int,int,unsigned char,...); +extern void * cdecl f_newlibhsend(int,int,unsigned char,...); +extern int cdecl p_entersend(void *,unsigned char,...); +extern int cdecl p_supersend(void *,unsigned char,...); +extern int cdecl p_exactsend(int,int,void *,unsigned char,...); +#pragma save,call(reg_param =>(bx,cx,dx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int f_send2(void *,unsigned char); +extern int _f_send3(void *,unsigned char,void *); +extern int _f_send4(void *,unsigned char,void *,void *); +extern int _f_send5(void *,unsigned char,void *,void *,void *); +#pragma call(reg_param =>(bx,cx,dx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE),inline =>on) +static int p_send2(void *,unsigned char) = {0xcd,0xcf}; +static int _p_send3(void *,unsigned char,void *) = {0xcd,0xcf}; +static int _p_send4(void *,unsigned char,void *,void *) = {0xcd,0xcf}; +static int _p_send5(void *,unsigned char,void *,void *,void *) = {0xcd,0xcf}; +static int p_entersend2(void *,unsigned char) = {0xcd,0xd9}; +static int _p_entersend3(void *,unsigned char,void *) = {0xcd,0xd9}; +static int _p_entersend4(void *,unsigned char,void *,void *) = {0xcd,0xd9}; +static int _p_entersend5(void *,unsigned char,void *,void *,void *) = {0xcd,0xd9}; +static int p_supersend2(void *,unsigned char) = {0xcd,0xd0}; +static int _p_supersend3(void *,unsigned char,void *) = {0xcd,0xd0}; +static int _p_supersend4(void *,unsigned char,void *,void *) = {0xcd,0xd0}; +static int _p_supersend5(void *,unsigned char,void *,void *,void *) = {0xcd,0xd0}; +#pragma restore +#pragma save,call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void *p_new(int,int); +extern void *f_new(int,int); +extern int p_getlibh(int); +extern void *p_newlibh(int,int); +extern void *f_newlibh(int,int); +#pragma call(reg_param =>(bx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_findlib(const char *,int *); +#pragma call(reg_param =>(bx,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_linklib(int); +extern int p_loadlib(const char *,int *,int); +extern int p_unloadlib(int); +#pragma call(reg_param =>(bx,ax,si,cx),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +extern int p_loadfilelib(void *,int,int *,int); +#pragma call(reg_param =>(si,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_openlib(void **,const char *); +#pragma call(reg_param =>(bx,cx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_reclass(int,int,void *); +extern void p_reclassbyhandle(int,int,void *); +#pragma call(reg_param =>(bx,di,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_cpycat(int,void *,void *,unsigned int); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_OBJECT_H diff --git a/code/SIBOSDK/include/p_par.h b/code/SIBOSDK/include/p_par.h new file mode 100644 index 0000000..cf133e3 --- /dev/null +++ b/code/SIBOSDK/include/p_par.h @@ -0,0 +1,22 @@ +/* HEADER - P_PAR.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 22/10/93 SLT First relase +*/ +#ifndef P_PAR_H +#define P_PAR_H + +#include + +#define S_BUSY 0x10 +#define S_ACK 0x20 +#define S_ERROR 0x40 +#define S_PE 0x80 +#define S_SPARE 0x08 +#define S_STROBE 0x10 +#define S_INIT 0x20 +#define S_AUTOFD 0x40 +#define S_SELECT 0x80 + +#endif // P_PAR_H diff --git a/code/SIBOSDK/include/p_prdrv.h b/code/SIBOSDK/include/p_prdrv.h new file mode 100644 index 0000000..dd404d9 --- /dev/null +++ b/code/SIBOSDK/include/p_prdrv.h @@ -0,0 +1,58 @@ +/* HEADER - P_PRDRV.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_PRDRV_H +#define P_PRDRV_H + +#include + +typedef struct + { + unsigned char topmarg; /* Number of lines in page's top margin */ + unsigned char bodylen; /* Total number of lines to print on the page */ + unsigned char lftmarg; /* Spaces in page's left margin */ + unsigned char bodywid; /* Total number of characters to print on each line */ + } P_LAYOUT_DATA; +typedef struct + { + unsigned char escapon; /* Escape processing enabled/disbaled */ + unsigned char escchar; /* Escape character */ + } P_ESCAPE_DATA; +#define P_PRNFLG_ESCAPE 1 /* Set if escape processing is enabled */ +#define P_PRNFLG_LAYOUT 2 /* Set if layout processing is enabled */ +#define P_PRNTYP_PAR 0 /* Parallel port type */ +#define P_PRNTYP_SER 1 /* Serial port type */ +#define P_PRNTYP_FIL 2 /* File port type */ +typedef struct + { + unsigned char port_type; /* P_PRNTYP_XXX */ + unsigned char nstack; /* number of devices in stack */ + unsigned char flags; /* P_PRNFLG_XXX bits */ + unsigned char escchar; /* Escape character */ + P_LAYOUT_DATA ld; /* Page layout */ + } P_PRN_INTF; +typedef struct + { + P_PRN_INTF *pintf; /* Interfacing information */ + char *label; /* user label */ + char *pname; /* port name */ + unsigned char *psetbuf; /* port setup data */ + char *driver; /* name of .prd file or NULL for no driver */ + } P_PRN_CRK; +#ifdef __cplusplus +extern "C" { +#endif +extern int p_prnset(int,void *,int); +extern int p_prnget(int,void *); +extern int p_prncur(int); +extern int p_prnbld(void *,P_PRN_CRK *); +extern void p_prncrk(void *,P_PRN_CRK *); +#ifdef __cplusplus +} +#endif + +#endif // P_PRDRV_H diff --git a/code/SIBOSDK/include/p_que.h b/code/SIBOSDK/include/p_que.h new file mode 100644 index 0000000..ec911db --- /dev/null +++ b/code/SIBOSDK/include/p_que.h @@ -0,0 +1,39 @@ +/* HEADER - P_QUE.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_QUE_H +#define P_QUE_H + +#include + +#define P_ISEMPTYQ(q) ((q)==(q)->next) +#define P_INITQ(q) (q)->next=(q)->prev=(q) +#define P_DECLAREQ(q) P_QUE q = {&q,&q} +typedef struct p_que +{ +struct p_que *next; /* Next entry */ +struct p_que *prev; /* Previous entry */ +} P_QUE; +typedef struct +{ +P_QUE q; /* Que entry control */ +long int key; /* Delta key value */ +} P_DELTA; +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_param =>(si,di),reg_saved =>(ax,cx,dx,si,di,EPOC_SAVE)) +extern void p_enque(P_QUE *,P_QUE *); +extern void p_deque(P_QUE *); +#pragma restore +P_DELTA *p_enqued(P_QUE *,P_DELTA *,long int); +P_DELTA *p_dequed(P_QUE *,P_DELTA *); +#ifdef __cplusplus +} +#endif + +#endif // P_QUE_H diff --git a/code/SIBOSDK/include/p_screen.h b/code/SIBOSDK/include/p_screen.h new file mode 100644 index 0000000..95902ab --- /dev/null +++ b/code/SIBOSDK/include/p_screen.h @@ -0,0 +1,69 @@ +/* HEADER - P_SCREEN.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_SCREEN_H +#define P_SCREEN_H + +#include +#include + +#define P_SCR_ATTRB 0 +#define P_SCR_SCROLL 1 +#define P_SCR_CLR 2 +#define P_SCR_POSA 3 +#define P_SCR_POSR 4 +#define P_SCR_WSET 5 +#define P_SCR_SLOCK 6 +#define P_SCR_WLOCK 7 +#define P_SCR_NEL 8 +#define P_SCR_CURSOR 9 +#define P_SCR_ESCAPE 10 +#define P_SCR_FLUSH 11 +#define P_SCR_CSET 12 +#define P_SCR_NORMAL 0 +#define P_SCR_BOLD 0x01 +#define P_SCR_REVERSE 0x02 +#define P_SCR_UNDLINE 0x04 +#define P_SCR_BLINK 0x08 +#define P_MAXEDITSTR 256 +#define P_FEDIT P_FCTRL /* invoke consol edit */ +#define P_FCONSP1 P_FINQ /* consol spare 1 */ +#define P_FCONSP2 P_FRSUPER /* consol spare 2 */ +#define P_FCONSP3 P_FSTOP /* consol spare 3 */ +#define P_FCONSP4 P_FSTART /* consol spare 4 */ +#define P_FWFLUSH P_FRSUPER +#define P_EVENT_READ P_FSTOP +#define P_EVENT_TEST P_FSTART +#ifndef _P_CEDIT +#define _P_CEDIT +typedef struct /* console driver line editor */ +{ +unsigned char cursorpos; /* initial cursor position */ +unsigned char trap; /* trap input errors or not */ +unsigned char string[P_MAXEDITSTR]; /* buffer to edit */ +} P_CEDIT; +#endif +typedef struct /* line editor control block */ +{ +unsigned char *le_scb; /* screen control block */ +P_RECT le_win; /* window dimensions (relative) */ +char *le_buf; /* edit buffer */ +unsigned char le_len; /* length of edit text */ +unsigned char le_max; /* max length of edit text */ +unsigned char le_pos; /* position of cursor in buffer */ +unsigned char spare; /* keep struct word aligned */ +} P_LECB; +#define P_LE_LEFT 0 +#define P_LE_RIGHT 1 +#define P_LE_UP 2 +#define P_LE_DOWN 3 +#define P_LE_START 4 +#define P_LE_END 5 +#define P_LE_DELETE 6 +#define P_LE_CLR 7 + +#endif // P_SCREEN_H diff --git a/code/SIBOSDK/include/p_serial.h b/code/SIBOSDK/include/p_serial.h new file mode 100644 index 0000000..494e671 --- /dev/null +++ b/code/SIBOSDK/include/p_serial.h @@ -0,0 +1,111 @@ +/* HEADER - P_SERIAL.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_SERIAL_H +#define P_SERIAL_H +#include +#include + +/* Serial port characteristics */ +typedef struct +{ +unsigned char tbaud; /* transmit Baud rate selector */ +unsigned char rbaud; /* receive Baud rate selector */ +unsigned char frame; /* number of data,parity and stop bits */ +unsigned char parity; /* parity selector */ +unsigned char hand; /* handshake flags */ +unsigned char xon; /* XON character */ +unsigned char xoff; /* XOFF character */ +unsigned char flags; /* ignore parity errors/dont drive DTR changing chars */ +unsigned long int tmask; /* terminator mask */ +} P_SRCHAR; +/* Baud rates */ +#define P_BAUD_50 0x01 +#define P_BAUD_75 0x02 +#define P_BAUD_110 0x03 +#define P_BAUD_134 0x04 +#define P_BAUD_150 0x05 +#define P_BAUD_300 0x06 +#define P_BAUD_600 0x07 +#define P_BAUD_1200 0x08 +#define P_BAUD_1800 0x09 +#define P_BAUD_2000 0x0A +#define P_BAUD_2400 0x0B +#define P_BAUD_3600 0x0C +#define P_BAUD_4800 0x0D +#define P_BAUD_7200 0x0E +#define P_BAUD_9600 0x0F +#define P_BAUD_19200 0x10 +#define P_BAUD_38400 0x11 +#define P_BAUD_56000 0x12 +#define P_BAUD_115000 0x13 +/* allocation of frame bits */ +#define P_DATA_FRM 0x0f /* number of data bits mask */ +#define P_DATA_5 0 /* 5 data bits */ +#define P_DATA_6 1 /* 6 data bits */ +#define P_DATA_7 2 /* 7 data bits */ +#define P_DATA_8 3 /* 8 data bits */ +#define P_TWOSTOP 0x10 /* 2 stop bits if set,1 if clear */ +#define P_PARITY 0x20 /* 1 parity bit if set,0 if clear */ +/* parity - ignored unless P_PARITY is set */ +#define P_PAR_EVEN 1 /* even parity */ +#define P_PAR_ODD 2 /* odd parity */ +#define P_PAR_MARK 3 /* mark parity */ +#define P_PAR_SPACE 4 /* space parity */ +/* handshaking control */ +#define P_OBEY_XOFF 0x01 /* respond to received XOFF (and XON) if set */ +#define P_SEND_XOFF 0x02 /* send XOFF/XON to control receive buffer if set */ +#define P_IGN_CTS 0x04 /* ignore the state of CTS if set */ +#define P_OBEY_DSR 0x08 /* obey the state of DSR if set */ +#define P_FAIL_DSR 0x10 /* fail if DSR goes OFF if set */ +#define P_OBEY_DCD 0x20 /* obey the state of DCD if set */ +#define P_FAIL_DCD 0x40 /* fail if DCD goes OFF if set */ +/* flags control */ +#define P_IGNORE_PARITY 0x01 /* ignore parity errors */ +/* For P_FCTRL function */ +#define P_SRCTRL_CTS 0x01 +#define P_SRCTRL_DSR 0x02 +#define P_SRCTRL_DCD 0x04 +#define P_SRCTRL_RTS 0x08 +#define P_SRCTRL_DTR 0x10 +#define P_SRDTR_ON 1 /* to set DTR to MARK */ +#define P_SRDTR_OFF 2 /* to set DTR to SPACE */ +/* Bit masks for P_FINQ function */ +#define P_SRINQ_50 0x0001 +#define P_SRINQ_75 0x0002 +#define P_SRINQ_110 0x0004 +#define P_SRINQ_134 0x0008 +#define P_SRINQ_150 0x0010 +#define P_SRINQ_300 0x0020 +#define P_SRINQ_600 0x0040 +#define P_SRINQ_1200 0x0080 +#define P_SRINQ_1800 0x0100 +#define P_SRINQ_2000 0x0200 +#define P_SRINQ_2400 0x0400 +#define P_SRINQ_3600 0x0800 +#define P_SRINQ_4800 0x1000 +#define P_SRINQ_7200 0x2000 +#define P_SRINQ_9600 0x4000 +#define P_SRINQ_19200 0x8000 +/* second baud rate word */ +#define P_SRINQ_38400 0x0001 +#define P_SRINQ_56000 0x0002 +/* 2nd set of info */ +#define P_SRINQ_DATA5 0x0001 /* supports 5 data bits */ +#define P_SRINQ_DATA6 0x0002 /* supports 6 data bits */ +#define P_SRINQ_DATA7 0x0004 /* supports 7 data bits */ +#define P_SRINQ_DATA8 0x0008 /* supports 8 data bits */ +#define P_SRINQ_STOP2 0x0010 /* supports 2 stop bits (as well as 1) */ +#define P_SRINQ_PAREVEN 0x0020 /* supports even parity */ +#define P_SRINQ_PARODD 0x0040 /* supports odd parity */ +#define P_SRINQ_PARMARK 0x0080 /* supports mark parity */ +#define P_SRINQ_PARSPACE 0x0100 /* supports space parity */ +#define P_SRINQ_SETDTR 0x0200 /* can set DTR */ +#define P_SRINQ_SPLIT 0x400 /* supports split Baud rates */ +#define P_SRINQ_XONXOFF 0x800 /* Supports soft xon/xoff characters */ + +#endif // P_SERIAL_H diff --git a/code/SIBOSDK/include/p_std.h b/code/SIBOSDK/include/p_std.h new file mode 100644 index 0000000..e17618e --- /dev/null +++ b/code/SIBOSDK/include/p_std.h @@ -0,0 +1,350 @@ +/* HEADER - P_STD.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_STD_H +#define P_STD_H + +#include + +#define GLREF_D extern +#define GLDEF_D +#define LOCAL_D static +#define GLREF_C extern +#define LOCAL_C static +#define GLDEF_C +#define CDECL cdecl +#define FOREVER for(;;) +#define TRUE 1 +#define FALSE 0 +#define NULL 0 +#define NULL_D ((VOID *)0) +#define NULL_C ((INT (*)(VOID))0) +#define VOID void +#define FAST register +#define CONST const +#define CLIB_CONST CONST +typedef int INT,HANDLE; +typedef unsigned int UINT; +typedef signed char BYTE; +typedef unsigned char UBYTE; +typedef char TEXT; +typedef short int WORD; +typedef unsigned short int UWORD; +typedef long int LONG; +typedef unsigned long int ULONG; +typedef double DOUBLE; +typedef float FLOAT; +typedef union + { + BYTE *b; UBYTE *ub; INT *i; UINT *ui; WORD *w; + UWORD *uw; LONG *l; ULONG *ul; UBYTE **a; TEXT *t; + } UPTR; +#ifdef __cplusplus +extern "C" { +#endif +#define ENTER_CALL call(reg_param =>(bx,cx,dx,si,di),reg_saved =>(ds,st1,st2)) +#define p_enter1(f) _p_enter1((void *)(f)) +#define p_enter2(f,p1) _p_enter2((void *)(f),(void *)(p1)) +#define p_enter3(f,p1,p2) _p_enter3((void *)(f),(void *)(p1),(void *)(p2)) +#define p_enter4(f,p1,p2,p3) _p_enter4((void *)(f),(void *)(p1),(void *)(p2),(void *)(p3)) +#define p_enter5(f,p1,p2,p3,p4) _p_enter5((void *)(f),(void *)(p1),(void *)(p2),(void *)(p3),(void *)(p4)) +#define p_enter6(f,p1,p2,p3,p4,p5) _p_enter6((void *)(f),(void *)(p1),(void *)(p2),(void *)(p3),(void *)(p4),(void *)(p5)) +extern int cdecl p_ioa(void *,int,short int *,...); +extern void cdecl p_ioc(void *,int,short int *,...); +extern int cdecl p_iow(void *,int,...); +extern int cdecl p_enter(void *,...); +#pragma save,call(reg_param =>(ax,bx,cx,dx,si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE),inline =>on) +static int _p_enter1(void *) = {0xcd,0xd2}; +static int _p_enter2(void *,void *) = {0xcd,0xd2}; +static int _p_enter3(void *,void *,void *) = {0xcd,0xd2}; +static int _p_enter4(void *,void *,void *,void *) = {0xcd,0xd2}; +static int _p_enter5(void *,void *,void *,void *,void *) = {0xcd,0xd2}; +static int _p_enter6(void *,void *,void *,void *,void *,void *) = {0xcd,0xd2}; +#pragma call(reg_param =>(bx,ax,di,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE),inline=>off) +extern int p_ioa3(void *,unsigned char,short int *); +extern int p_ioa4(void *,unsigned char,short int *,void *); +extern int p_ioa5(void *,unsigned char,short int *,void *,void *); +extern void p_ioc3(void *,unsigned char,short int *); +extern void p_ioc4(void *,unsigned char,short int *,void *); +extern void p_ioc5(void *,unsigned char,short int *,void *,void *); +#pragma call(reg_param =>(bx,ax,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_iow2(void *,unsigned char); +extern int p_iow3(void *,unsigned char,void *); +extern int p_iow4(void *,unsigned char,void *,void *); +#pragma restore +extern void p_abort(void); +extern void cdecl p_atos(char *,const char *,...); +extern int cdecl p_getflg(char *,char *,...); +extern char * cdecl p_scatm(char *,...); +extern char * cdecl p_scpym(char *,...); +extern int cdecl p_stoa(char **,const char *,...); +#pragma save,call(reg_param =>(cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void *f_alloc(unsigned int); +#pragma restore +extern int f_leave(int); +#pragma save,call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_sound(unsigned int,unsigned int); +extern void *f_realloc(void *,unsigned int); +#pragma call(reg_param =>(bx,dx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void *p_adjust(void *,unsigned int,int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_semcrt(int); +extern void p_semdel(int); +extern unsigned int p_alen(const void *); +extern int p_setpth(const char *); +#pragma restore +extern void p_allchk(int); +#pragma save,call(reg_param =>(cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void *p_alloc(unsigned int); +#pragma call(reg_param =>(di),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern unsigned int p_allspc(void **); +#pragma restore +extern void p_allwalk(void (*)(void *,int,unsigned int),void *); +#pragma save,call(reg_param =>(di,si,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_atob(char *,const char *,void *); +#pragma call(reg_param =>(si,cx,di,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_bcmp(const void *,int,const void *,int); +extern int p_bcmpi(const char *,int,const char *,int); +#pragma call(reg_param =>(di,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern unsigned char *p_bcpy(void *,const void *,unsigned int); +#pragma call(reg_param =>(di,cx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern unsigned char *p_bfil(void *,unsigned int,int); +#pragma call(reg_param =>(si,cx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_bloc(const void *,int,int); +extern int p_bloci(const char *,int,int); +#pragma call(reg_param =>(si,cx,di,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_bmatch(const char *,int,const char *,int); +extern int p_bmatchi(const char *,int,const char *,int); +#pragma restore +extern unsigned char *p_brep(void *,int,const void *,int); +extern int p_bsrch(int,int (*)(int,void *),int *,void *); +#pragma save,call(reg_param =>(si,cx,di,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_bsub(const void *,int,const void *,int); +extern int p_bsubi(const char *,int,const char *,int); +#pragma call(reg_param =>(di,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_bswap(void *,void *,int); +#pragma call(reg_param =>(di,si,cx),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +extern void p_ccpy(void *,void *,unsigned int); +#pragma call(reg_param =>(bx,cx,di,si,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_chdir(const char *,char *,int,const char *); +extern int p_chdirasync(const char *,char *,int,const char *,short int *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_close(void *); +#pragma call(reg_param =>(),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE),reg_return =>(ax,bx)) +extern unsigned long int p_date(void); +#pragma restore +extern void p_dummy(void); +extern void p_decrypt(void *,void *,int); +extern int p_defdev(char *,int); +extern int p_defdir(char *,int); +#pragma save,call(reg_param =>(di,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_delenv(const char *); +extern int p_delenviron(const char *,int); +#pragma call(reg_param =>(bx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_delete(const char *); +extern int p_deleteasync(const char *,short int *); +extern int p_setpthasync(const char *,short int *); +extern int p_testpthasync(const char *,short int *); +#pragma restore +extern void p_dummy(void); +extern void p_encrypt(void *,void *,int); +#pragma save,call(reg_param =>(bx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_nmday(char *,int); +extern void p_nmmon(char *,int); +extern void p_getampmtext(char *,int); +extern void p_errs(char *,int); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_testpth(const char *); +extern int p_getpth(char *); +extern void p_getsuffixes(char *); +extern void p_exit(int); +extern void p_signal(int); +#pragma call(reg_param =>(bx,cx,di,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_fdate(const char *,unsigned long int); +extern int p_fdateasync(const char *,unsigned long int,short int *); +#pragma call(reg_param =>(di,dx,si,cx),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern int p_findenviron(const char *,int,unsigned char *,int *); +#pragma call(reg_param =>(di,si,cx,dx),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern int p_fndenv(const char *,char *,char *,int *); +#pragma call(reg_param =>(bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_free(void *); +#pragma restore +extern void p_freemask(void *); +extern unsigned char *p_getcoml(void); +#pragma save,call(reg_param =>(di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_getenv(const char *,char *); +#pragma call(reg_param =>(di,dx,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_getenviron(const char *,int,void *); +#pragma call(reg_param =>(di,bx,dx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_gltob(char *,unsigned long int,int); +#pragma call(reg_param =>(di,bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_gtob(char *,unsigned int,int); +#pragma restore +extern void p_hdel(void *,char *); +extern unsigned char *p_hfind(void *,char *); +extern int p_hfins(void *,char *,char **); +extern void p_hfree(void *); +extern int p_hinit(void **,int,unsigned int ,int); +extern int p_hins(void *,char *); +extern int p_hvisit(void *,int (*)(char *)); +#pragma save,call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_iosignal(void); +extern void p_iowait(void); +extern void p_ioyield(void); +extern int p_isalnum(int); +extern int p_isalpha(int); +extern int p_iscntrl(int); +extern int p_isdigit(int); +extern int p_isgraph(int); +extern int p_islower(int); +extern int p_isprint(int); +extern int p_ispunct(int); +extern int p_isspace(int); +extern int p_isupper(int); +extern int p_isxdigit(int); +#pragma call(reg_param =>(di,bx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_itob(char *,int); +#pragma call(reg_param =>(di,bx,si,cx,dx,ax),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +extern char *p_jtob(char *,int,char *,int,int,int); +#pragma call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_leave(int); +#pragma call(reg_param =>(di,bx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_ltob(char *,long int); +#pragma call(reg_param =>(bx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_mkdir(const char *); +extern int p_mkdirasync(const char *,short int *); +#pragma call(reg_param =>(di,bx,cx),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +extern int p_open(void **,const char *,unsigned int); +extern int f_open(void **,const char *,unsigned int); +#pragma call(reg_param =>(di,bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_opent(void **,const char *,unsigned int); +#pragma call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_panic(int); +#pragma restore +extern int p_qsort(int,int (*)(int,int,void *),void (*)(int,int,void *),void *); +#pragma save,call(reg_param =>(bx),reg_saved =>(cx,dx,si,di,EPOC_SAVE),reg_return =>(ax,bx)) +extern unsigned long int p_randl(unsigned long int *); +#pragma restore +#pragma save,call(reg_param =>(bx,cx,dx),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +extern int p_read(void *,void *,unsigned int); +extern int f_read(void *,void *,unsigned int); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void *p_realloc(void *,unsigned int); +#pragma call(reg_param =>(bx,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_rename(const char *,const char *); +extern int p_renameasync(const char *,const char *,short int *); +#pragma call(reg_param =>(di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern char *p_scat(char *,const char *); +#pragma call(reg_param =>(si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_scmp(const char *,const char *); +extern int p_scmpi(const char *,const char *); +extern void p_sconf(char *); +#pragma call(reg_param =>(di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern char *p_scpy(char *,const char *); +extern char *p_scpyf(char *,const char *); +#pragma call(reg_param =>(bx,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_seek(void *,int,long int *); +extern int f_seek(void *,int,long int *); +#pragma call(reg_param =>(di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_setenv(const char *,const char *); +#pragma call(reg_param =>(di,dx,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_setenviron(const char *,int,const void *,int); +#pragma restore +extern int p_setmask(void **,char *); +#pragma save,call(reg_param =>(bx,di,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sfstat(const char *,unsigned int,unsigned int); +extern int p_sfstatasync(const char *,unsigned int,unsigned int,short int *); +#pragma call(reg_param =>(si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_scap(char *); +extern char *p_skipch(const char *); +extern char *p_skipwh(const char *); +#pragma call(reg_param =>(dx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sleepa(unsigned long int); +extern int p_sleep(unsigned long int); +extern int p_wkday(unsigned long int); +#pragma call(reg_param =>(di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern unsigned int p_slen(const char *); +#pragma restore +extern void p_slfclose(void *); +extern int p_slfind(void *,char *,int); +extern int p_slfopen(void **,char *,int); +#pragma save,call(reg_param =>(si,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sloc(const char *,int); +extern int p_sloci(const char *,int); +extern int p_slocr(const char *,int); +extern int p_slocri(const char *,int); +#pragma call(reg_param =>(si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_smatch(const char *,const char *); +extern int p_smatchi(const char *,const char *); +#pragma restore +extern char *p_srep(char *,int,const char *); +#pragma save,call(reg_param =>(si,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_ssub(const char *,const char *); +extern int p_ssubi(const char *,const char *); +#pragma call(reg_param =>(bx,di,cx),reg_saved =>(bx,cx,dx,di,EPOC_SAVE)) +extern int p_stog(char **,unsigned short int *,int); +#pragma call(reg_param =>(dx,di,cx),reg_saved =>(cx,dx,EPOC_SAVE)) +extern int p_stogl(char **,unsigned long int *,int); +#pragma call(reg_param =>(bx,di),reg_saved =>(bx,cx,dx,di,EPOC_SAVE)) +extern int p_stoi(char **,short int *); +#pragma call(reg_param =>(dx,di),reg_saved =>(cx,dx,EPOC_SAVE)) +extern int p_stol(char **,long int *); +#pragma restore +extern int p_strm(void *,int,long int,void *,int); +extern int p_strmf(void *); +extern void p_strmi(void *,int,int (*)(void *,int,void *,int,int),int,void *); +#pragma save,call(reg_param =>(cx,bx),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +extern int p_svecadd(void *,void *); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_sveccall(int,int); +extern void p_svecrem(int); +#pragma call(reg_param =>(ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_tofold(int); +extern int p_tolower(int); +extern int p_toupper(int); +#pragma restore +extern int p_vradd(void *,void *); +extern int p_vrcnt(void *); +extern int p_vrdel(void *,int); +extern int p_vrfnd(void *,int (*)(void *,void *),void *,short int *); +extern void p_vrfree(void *); +extern void *p_vrinit(unsigned int,unsigned int); +extern int p_vrins(void *,void *,int); +extern int p_vrisq(void *,int (*)(void *,void *),void *,short int *,void *); +extern void *p_vrpnt(void *,int); +extern void p_vrset(void *,int); +extern void p_vrzero(void *); +#pragma save,call(reg_param =>(di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void p_waitstat(short int *); +#pragma call(reg_param =>(dx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_weekno(unsigned long int); +#pragma call(reg_param =>(bx,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_write(void *,void *,unsigned int); +extern int f_write(void *,void *,unsigned int); +#pragma call(reg_param =>(bx,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sgadjust(int,int); +extern int p_sgclose(int); +#pragma call(reg_param =>(bx,di,dx,si,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sgcopyfr(int,long int,void *,unsigned int); +extern int p_sgcopyto(int,long int,void *,unsigned int); +#pragma call(reg_param =>(bx,cx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sgcreate(const char *,int,int); +extern int p_sgdelete(const char *); +#pragma call(reg_param =>(bx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int p_sgfind(int,const char *,char *); +extern unsigned int p_sgfree(void); +extern void p_sglock(int); +extern void p_sgunlock(int); +extern int p_sgopen(const char *); +extern unsigned int p_sgramdisk(void); +extern unsigned int p_sgsize(int); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // P_STD_H \ No newline at end of file diff --git a/code/SIBOSDK/include/p_strm.h b/code/SIBOSDK/include/p_strm.h new file mode 100644 index 0000000..07a9e85 --- /dev/null +++ b/code/SIBOSDK/include/p_strm.h @@ -0,0 +1,27 @@ +/* HEADER - P_STRM.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_STRM_H +#define P_STRM_H + +#include + +#define STRM_READ 0 +#define STRM_WRITE 1 +typedef struct +{ +unsigned int bsiz; /* block size in bytes */ +unsigned int dirty; /* TRUE if active block is dirty */ +unsigned int blk; /* block number currently in buf */ +unsigned int ffblk; /* first free block */ +int (*iovec)(void *,int,void *,int,int); /* block io function */ +void *pcb; /* parameter to block io function */ +unsigned char buf[2]; /* buffer */ +} STRMCB; +#define STRMCBL (sizeof(STRMCB)-2) + +#endif // P_STRM_H diff --git a/code/SIBOSDK/include/p_sys.h b/code/SIBOSDK/include/p_sys.h new file mode 100644 index 0000000..8af7bae --- /dev/null +++ b/code/SIBOSDK/include/p_sys.h @@ -0,0 +1,39 @@ +/* HEADER - P_SYS.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_SYS_H +#define P_SYS_H + +#include + +#define P_ENVMAX 256 /* Max size of an environment string */ +#define P_CMDMAX 258 /* Max buffer size for the input command line */ +#define P_MAXSYSIO 258 /* Max buffer size for p_gets() and p_puts() */ +/* For returning strings from p_getflg */ +typedef struct + { + unsigned short int argc; /* no. of argumets returned */ + unsigned short int argm; /* capacity of address table */ + char **argp; /* address of address table */ + } P_GETFLG; +#ifdef __cplusplus +extern "C" { +#endif +extern void cdecl p_printf(const char *,...); +extern void cdecl p_print(const char *,...); +extern void p_getdat(char *); +extern int p_getch(void); +extern int p_getl(const char *,char *,int); +extern int p_gets(char *); +extern void p_putch(int); +extern void p_puts(const char *); +extern void t_panic(const char *); +#ifdef __cplusplus +} +#endif + +#endif // P_SYS_H diff --git a/code/SIBOSDK/include/p_xmodem.h b/code/SIBOSDK/include/p_xmodem.h new file mode 100644 index 0000000..edc4cce --- /dev/null +++ b/code/SIBOSDK/include/p_xmodem.h @@ -0,0 +1,47 @@ +/* HEADER - P_XMODEM.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef P_XMODEM_H +#define P_XMODEM_H + +#include + +/* P_FCONNECT service connection modes */ +#define P_XMDM_ACCP 0 /* want link as acceptor */ +#define P_XMDM_INIT 1 /* want link as initiator */ +/* Xmodem/Ymodem link connection types */ +#define P_XMDM_CRCORCHECKSUM 0 +#define P_XMDM_CRCMODE 1 +#define P_XMDM_CHECKSUMMODE 2 +#define P_YMODEM_MODE 3 +#define P_YMODEM_G_MODE 4 +#define P_XMDM_ONE_K 0x8000 +/* Xmodem/Ymodem supported flags */ +#define P_FXMDM_SENSE 0xff /* I/O function number */ +#define P_XSUP_XMODEM 0x01 /* original Xmodem checksum */ +#define P_XSUP_XMODEM_CRC 0x02 /* Xmodem with CRC */ +#define P_XSUP_ONE_K_OPTION 0x04 /* 1k frames */ +#define P_XSUP_YMODEM 0x08 /* Ymodem */ +#define P_XSUP_YMODEM_G 0x10 /* Ymodem-G */ +/* Connection states. */ +#define P_XMDM_IDLE 0 /* idle state (no connection) */ +#define P_XMDM_CONNECT_RECEIVE 1 /* receive connection state */ +#define P_XMDM_CONNECT_TRANSMIT 2 /* transmit connection state */ +#define P_XMDM_DATA_RECEIVE 3 /* recieve data state */ +#define P_XMDM_DATA_TRANSMIT 4 /* transmit data state */ +#define P_XMDM_NLOG 32 /* Max number of debug events,states we record */ +#define P_XMDM_LOG_PANIC 0xC0 /* panic number */ +#define P_XMDM_LOG_COMP 0x40 /* user completion */ +#define P_XMDM_LOG_REQ 0x80 /* user request */ +/* State and event log record */ +typedef struct + { + unsigned char state; + unsigned char event; + } P_XMLOG; + +#endif // P_XMODEM_H diff --git a/code/SIBOSDK/include/p_zmodem.h b/code/SIBOSDK/include/p_zmodem.h new file mode 100644 index 0000000..cd865ec --- /dev/null +++ b/code/SIBOSDK/include/p_zmodem.h @@ -0,0 +1,66 @@ +/* +P_ZMODEM.H - Header file for Zmodem protocol + +Written by John, August 1995 +*/ +#ifndef P_ZMODEM_H +#define P_ZMODEM_H + +/* ZDLE sequences */ +#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */ +#define ZCRCG 'i' /* CRC next, frame continues nonstop */ +#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */ +#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */ +#define ZRUB0 'l' /* Translate to rubout 0177 */ +#define ZRUB1 'm' /* Translate to rubout 0377 */ + +/* Zmodem frame byte defines */ +#define ZPAD 0x2A +#define ZDLE 0x18 +#define ZBIN 0x41 +#define ZHEX 0x42 +#define ZBIN_32 0x43 +#define CAN 0x18 /* Makes the ZDLE choice the worst possible */ + +/* P_FCONNECT service connection modes */ +#define P_ZMDM_RECV 0 /* want link as acceptor/receiver of files */ +#define P_ZMDM_SEND 1 /* want link as initiator/sendor of files */ + +#define P_ZMDM_NLOG 32 /* Max number of debug events,states we record */ +/* Event types */ +#define P_ZMDM_LOG_PANIC 0xC0 /* panic number */ +#define P_ZMDM_LOG_COMP 0x40 /* user completion */ +#define P_ZMDM_LOG_REQ 0x80 /* user request */ + +/* State and event log record */ +typedef struct + { + UBYTE state; + UBYTE event; + } P_ZMLOG; + +#define P_ZM_MAX_BUF 1030 + +/* Frame types that we received */ +#define P_ZM_FRAME_TYPE_RQ_INIT 0 +#define P_ZM_FRAME_TYPE_R_INIT 1 +#define P_ZM_FRAME_TYPE_S_INIT 2 +#define P_ZM_FRAME_TYPE_ACK 3 +#define P_ZM_FRAME_TYPE_FILE 4 +#define P_ZM_FRAME_TYPE_SKIP 5 +#define P_ZM_FRAME_TYPE_NAK 6 +#define P_ZM_FRAME_TYPE_ABORT 7 +#define P_ZM_FRAME_TYPE_FINISH 8 +#define P_ZM_FRAME_TYPE_R_POS 9 +#define P_ZM_FRAME_TYPE_DATA 10 +#define P_ZM_FRAME_TYPE_EOF 11 +#define P_ZM_FRAME_TYPE_FILE_ERR 12 +#define P_ZM_FRAME_TYPE_CRC 13 +#define P_ZM_FRAME_TYPE_CHALLENGE 14 +#define P_ZM_FRAME_TYPE_COMPLETE 15 +#define PSEUDO_IMPLEMENTATION_SPECIFIC_FRAME 16 +#define P_ZM_FRAME_TYPE_FREE_SIZE 17 +#define P_ZM_FRAME_TYPE_COMMAND 18 +#define P_ZM_FRAME_TYPE_STD_ERR 19 + +#endif // P_ZMODEM_H diff --git a/code/SIBOSDK/include/pages.g b/code/SIBOSDK/include/pages.g new file mode 100644 index 0000000..e6f57ab --- /dev/null +++ b/code/SIBOSDK/include/pages.g @@ -0,0 +1,148 @@ +/* Generated by Ctran from pages.cat */ +#define PAGES_G +#ifndef VARRAY_G +#include +#endif +#ifndef APPMAN_G +#include +#endif +#ifndef EPDOC_G +#include +#endif +#ifndef SCRLAY_G +#include +#endif +#ifndef TIME_G +#include +#endif +#ifndef PRDRV_G +#include +#endif +/* Class Numbers */ +#define C_PAGES 8 +/* Method Numbers */ +/* Constants for pages */ +#define PAGES_DONE_PAGE 0 +#define PAGES_DONE_DOC 1 +#define PAGES_DONE_END 2 +#define PAGES_DONE_ERROR 3 +#define PAGES_DOC_NEW_PAGE 0x01 +#define PAGES_DOC_RESET_PAGE_NUM 0x02 +#define PAGES_FLAGS_PRINTING 0x01 +#define PAGES_FLAGS_NOTFIRST 0x02 +#define PAGES_FLAGS_ZERODOWN 0x04 +#define PAGES_REGION_BODY 0 +#define PAGES_REGION_TOP 1 +#define PAGES_REGION_BOTTOM 2 +#define PAGES_REGION_LAST_BOTTOM 3 +#define PAGES_REGION_END 4 +#define PAGES_REGION_VERY_END 5 +#define PAGES_REGION_DOC_END 6 +#define PAGES_PAGENUM_ARABIC 0 +#define PAGES_PAGENUM_ROMAN_U 1 +#define PAGES_PAGENUM_ROMAN_L 2 +#define PAGES_HEADER_2_COLUMNS SCRLAY_ALIGN_JUSTIFY+1 +#define PAGES_HEADER_3_COLUMNS SCRLAY_ALIGN_JUSTIFY+2 +/* Types for pages */ +typedef struct +{ +unsigned short int x; +unsigned short int y; +} UPOINT; +typedef struct +{ +UPOINT tl; +unsigned short int width; +unsigned short int height; +} UEXTENT; +typedef struct +{ +short int event; +unsigned short int page; +PR_VAFLAT *pages; +} PAGES_DONE; +typedef struct +{ +SCRLAY_FONT f; +unsigned char align; +unsigned char first_page; +} PAGES_HEADER; +typedef struct +{ +unsigned short int width; +unsigned short int height; +UEXTENT body; +unsigned short int hdtop; +unsigned short int hdbot; +} PAGES_PAGE; +typedef struct +{ +short int offset; +short int last; +short int style; +} PAGES_PAGENUM; +typedef struct +{ +PAGES_PAGE pg; +short int pdrflags; +short int docflags; +unsigned short int pgbeg; +unsigned short int pgend; +PAGES_HEADER top; +PAGES_HEADER bot; +PAGES_PAGENUM pgnum; +} PAGES_PARAMS; +typedef struct +{ +void *hread; +short int mread; +void *hdone; +short int mdone; +} PAGES_CALLS; +typedef struct +{ +PR_WDR *wdr; +PAGES_CALLS c; +char *fname; +char *toptxt; +char *bottxt; +} PAGES_INIT; +/* Property of pages */ +typedef struct { +PR_VAFLAT *pagarr; +PR_VASEG *todo; +PR_EPFDOC *ephead; +PR_PRNLAY *prhead; +PR_PDR *pdr; +PAGES_INIT in; +PAGES_PARAMS par; +short int last_pos; +unsigned short int flags; +short int pheight; +short int brk_height; +short int brk_above; +unsigned short int brk_pos; +short int y; +short int nrec; +unsigned short int page; +unsigned char reset_page; +unsigned char newdoc; +unsigned char started; +unsigned char newpage; +short int region; +short int holding; +unsigned short int pos; +WDR_PRINT pr; +SCRLAY_TABS tabs; +SCRLAY_SPACING spacing; +SCRLAY_MARGINS margins; +char time[LN_TIME_DATE_STR]; +char date[LN_TIME_TIME_STR-2]; +unsigned short int ioclen; +} PRS_PAGES; +typedef struct pr_pages +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_PAGES pages; +} PR_PAGES; diff --git a/code/SIBOSDK/include/pages.ing b/code/SIBOSDK/include/pages.ing new file mode 100644 index 0000000..e1b76f7 --- /dev/null +++ b/code/SIBOSDK/include/pages.ing @@ -0,0 +1,138 @@ +; Generated by Ctran from pages.cl +PAGES_ING equ 1 +IFNDEF VARRAY_ING + INCLUDE ..\inc\VARRAY.ING +ENDIF +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF EPDOC_ING + INCLUDE ..\inc\EPDOC.ING +ENDIF +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +IFNDEF TIME_ING + INCLUDE ..\inc\TIME.ING +ENDIF +IFNDEF PRDRV_ING + INCLUDE ..\inc\PRDRV.ING +ENDIF +; Class Numbers +C_PAGES equ 8 +; Method Numbers +; Constants for pages +PAGES_DONE_PAGE equ (0) +PAGES_DONE_DOC equ (1) +PAGES_DONE_END equ (2) +PAGES_DONE_ERROR equ (3) +PAGES_DOC_NEW_PAGE equ (001h) +PAGES_DOC_RESET_PAGE_NUM equ (002h) +PAGES_FLAGS_PRINTING equ (001h) +PAGES_FLAGS_NOTFIRST equ (002h) +PAGES_FLAGS_ZERODOWN equ (004h) +PAGES_REGION_BODY equ (0) +PAGES_REGION_TOP equ (1) +PAGES_REGION_BOTTOM equ (2) +PAGES_REGION_LAST_BOTTOM equ (3) +PAGES_REGION_END equ (4) +PAGES_REGION_VERY_END equ (5) +PAGES_REGION_DOC_END equ (6) +PAGES_PAGENUM_ARABIC equ (0) +PAGES_PAGENUM_ROMAN_U equ (1) +PAGES_PAGENUM_ROMAN_L equ (2) +PAGES_HEADER_2_COLUMNS equ (SCRLAY_ALIGN_JUSTIFY+1) +PAGES_HEADER_3_COLUMNS equ (SCRLAY_ALIGN_JUSTIFY+2) +; Types for pages +UPOINT struc +UPOINTX dw ? +UPOINTY dw ? +UPOINT ends +UEXTENT struc +UEXTENTTl UPOINT <> +UEXTENTWidth dw ? +UEXTENTHeight dw ? +UEXTENT ends +PAGES_DONE struc +PAGES_DONEEvent dw ? +PAGES_DONEPage dw ? +PAGES_DONEPages dw ? +PAGES_DONE ends +PAGES_HEADER struc +PAGES_HEADERF SCRLAY_FONT <> +PAGES_HEADERAlign db ? +PAGES_HEADERFirst_page db ? +PAGES_HEADER ends +PAGES_PAGE struc +PAGES_PAGEWidth dw ? +PAGES_PAGEHeight dw ? +PAGES_PAGEBody UEXTENT <> +PAGES_PAGEHdtop dw ? +PAGES_PAGEHdbot dw ? +PAGES_PAGE ends +PAGES_PAGENUM struc +PAGES_PAGENUMOffset dw ? +PAGES_PAGENUMLast dw ? +PAGES_PAGENUMStyle dw ? +PAGES_PAGENUM ends +PAGES_PARAMS struc +PAGES_PARAMSPg PAGES_PAGE <> +PAGES_PARAMSPdrflags dw ? +PAGES_PARAMSDocflags dw ? +PAGES_PARAMSPgbeg dw ? +PAGES_PARAMSPgend dw ? +PAGES_PARAMSTop PAGES_HEADER <> +PAGES_PARAMSBot PAGES_HEADER <> +PAGES_PARAMSPgnum PAGES_PAGENUM <> +PAGES_PARAMS ends +PAGES_CALLS struc +PAGES_CALLSHread dw ? +PAGES_CALLSMread dw ? +PAGES_CALLSHdone dw ? +PAGES_CALLSMdone dw ? +PAGES_CALLS ends +PAGES_INIT struc +PAGES_INITWdr dw ? +PAGES_INITC PAGES_CALLS <> +PAGES_INITFname dw ? +PAGES_INITToptxt dw ? +PAGES_INITBottxt dw ? +PAGES_INIT ends +; Property of pages +PRS_PAGES struc +PagesPagarr dw ? +PagesTodo dw ? +PagesEphead dw ? +PagesPrhead dw ? +PagesPdr dw ? +PagesIn PAGES_INIT <> +PagesPar PAGES_PARAMS <> +PagesLast_pos dw ? +PagesFlags dw ? +PagesPheight dw ? +PagesBrk_height dw ? +PagesBrk_above dw ? +PagesBrk_pos dw ? +PagesY dw ? +PagesNrec dw ? +PagesPage dw ? +PagesReset_page db ? +PagesNewdoc db ? +PagesStarted db ? +PagesNewpage db ? +PagesRegion dw ? +PagesHolding dw ? +PagesPos dw ? +PagesPr WDR_PRINT <> +PagesTabs SCRLAY_TABS <> +PagesSpacing SCRLAY_SPACING <> +PagesMargins SCRLAY_MARGINS <> +PagesTime db (1) * LN_TIME_TIME_STR dup (?) +PagesDate db (1) * LN_TIME_DATE_STR-2 dup (?) +PagesIoclen dw ? +PRS_PAGES ends +PR_PAGES struc +PagesRoot PRS_ROOT <> +PagesActive PRS_ACTIVE <> +PagesPages PRS_PAGES <> +PR_PAGES ends diff --git a/code/SIBOSDK/include/pagesize.h b/code/SIBOSDK/include/pagesize.h new file mode 100644 index 0000000..48fb29f --- /dev/null +++ b/code/SIBOSDK/include/pagesize.h @@ -0,0 +1,20 @@ +/* +PAGESIZE.H +*/ +#define PAGE_WIDTH_A4 11906 /* 210mm */ +#define PAGE_LENGTH_A4 16838 /* 297mm */ +#define PAGE_WIDTH_LEGAL 12240 /* 8.5in */ +#define PAGE_LENGTH_LEGAL 20160 /* 14in */ +#define PAGE_WIDTH_EXECUTIVE 10440 /* 7.25in */ +#define PAGE_LENGTH_EXECUTIVE 15120 /* 10.5in */ +#define PAGE_WIDTH_LETTER 12240 /* 8.5in */ +#define PAGE_LENGTH_LETTER 15840 /* 11in */ +#define PAGE_WIDTH_COM_10 5940 /* 4.125in */ +#define PAGE_LENGTH_COM_10 13680 /* 9.5in */ +#define PAGE_WIDTH_MONARCH 5580 /* 3.825in */ +#define PAGE_LENGTH_MONARCH 10800 /* 7.5in */ +#define PAGE_WIDTH_DL 6236 /* 110mm */ +#define PAGE_LENGTH_DL 12472 /* 220mm */ +#define PAGE_WIDTH_C5 9184 /* 162mm */ +#define PAGE_LENGTH_C5 12983 /* 229mm */ + diff --git a/code/SIBOSDK/include/plib.h b/code/SIBOSDK/include/plib.h new file mode 100644 index 0000000..1a133ac --- /dev/null +++ b/code/SIBOSDK/include/plib.h @@ -0,0 +1,23 @@ +/* HEADER - PLIB.H +Copyright (C) Psion PLC 1991-92 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 07/07/92 NSM Second release +*/ +#ifndef PLIB_H +#define PLIB_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // PLIB_H \ No newline at end of file diff --git a/code/SIBOSDK/include/pmodlocs.g b/code/SIBOSDK/include/pmodlocs.g new file mode 100644 index 0000000..529b1f3 --- /dev/null +++ b/code/SIBOSDK/include/pmodlocs.g @@ -0,0 +1,21 @@ +/* Generated by Ctran from pmodlocs.cl */ +#define PMODLOCS_G +#ifndef FACTIVE_G +#include +#endif +#ifndef PRNTDLGS_G +#include +#endif +/* Class Numbers */ +#define C_PMODLOCS 73 +/* Method Numbers */ +/* Property of pmodlocs */ +typedef struct { +PR_PRNMODEL *dl; +} PRS_PMODLOCS; +typedef struct pr_pmodlocs +{ +PRS_ROOT root; +PRS_LOCS locs; +PRS_PMODLOCS pmodlocs; +} PR_PMODLOCS; diff --git a/code/SIBOSDK/include/pmodlocs.ing b/code/SIBOSDK/include/pmodlocs.ing new file mode 100644 index 0000000..e5eae88 --- /dev/null +++ b/code/SIBOSDK/include/pmodlocs.ing @@ -0,0 +1,20 @@ +; Generated by Ctran from pmodlocs.cl +PMODLOCS_ING equ 1 +IFNDEF FACTIVE_ING + INCLUDE ..\inc\FACTIVE.ING +ENDIF +IFNDEF PRNTDLGS_ING + INCLUDE ..\inc\PRNTDLGS.ING +ENDIF +; Class Numbers +C_PMODLOCS equ 73 +; Method Numbers +; Property of pmodlocs +PRS_PMODLOCS struc +PmodlocsDl dw ? +PRS_PMODLOCS ends +PR_PMODLOCS struc +PmodlocsRoot PRS_ROOT <> +PmodlocsLocs PRS_LOCS <> +PmodlocsPmodlocs PRS_PMODLOCS <> +PR_PMODLOCS ends diff --git a/code/SIBOSDK/include/polytext.g b/code/SIBOSDK/include/polytext.g new file mode 100644 index 0000000..c37f441 --- /dev/null +++ b/code/SIBOSDK/include/polytext.g @@ -0,0 +1,107 @@ +/* Generated by Ctran from polytext.cat */ +#define POLYTEXT_G +#ifndef P_STD_H +#include +#endif +#ifndef P_OBJECT_H +#include +#endif +#ifndef VARRAY_G +#include +#endif +/* Class Numbers */ +#define C_PTROOT 12 +#define C_PTSEG 13 +#define C_PTFLAT 14 +/* Method Numbers */ +#define O_PT_RESET 2 +#define O_PT_MOD_BY_ATTRIB 11 +#define O_PT_ADD_PHRASE 6 +#define O_PT_DISPLAY_LINE 8 +#define O_PT_INIT 1 +#define O_PT_PUT_LINTAB 4 +#define O_PT_INQUIRE 13 +#define O_PT_WRAP 7 +#define O_PT_MOD_BY_NUM 10 +#define O_PT_PBUF 5 +#define O_PT_FIND 12 +#define O_PT_APPEND 3 +#define O_PT_SET_FONTS 9 +/* Constants for ptroot */ +#define PT_FIND_DEFAULT 0x0000 +#define PT_FIND_BACKWARDS 0x0001 +#define PT_FIND_CAN_STAY 0x0002 +#define PT_STY_DEFAULT 0x00 +#define PT_STY_BREAK_AT_START 0x01 +#define PT_STY_BREAK_AT_END 0x02 +#define PT_STY_OSTRIKE_XLEFT 0x20 +#define PT_STY_OSTRIKE_XRIGHT 0x40 +#define PT_STY_OVERSTRIKE 0x80 +#define PT_MAX_PHRASE_LEN 236 +#define PT_DESCR_MOD_FONT 0x0001 +#define PT_DESCR_MOD_WS_STYLE 0x0002 +#define PT_DESCR_MOD_PT_STYLE 0x0004 +#define PT_DESCR_MOD_ATTRIB 0x0008 +#define PT_DESCR_MOD_TLEN 0x0010 +/* Types for ptroot */ +typedef struct +{ +unsigned short int font_id; +unsigned char attrib; +} PT_FONT_SPEC; +typedef struct +{ +int line; +int offset; +int width; +} PT_PHRASE_INFO; +typedef struct +{ +unsigned short int font_id; +unsigned char ws_style; +unsigned char pt_style; +unsigned char attrib; +unsigned char tlen; +} PT_PHRASE_DESCR; +typedef struct +{ +PT_PHRASE_DESCR descr; +char txt[1]; +} PT_PHRASE; +/* Property of ptroot */ +typedef struct { +unsigned int nphrases; +unsigned int nchars; +unsigned int nlines; +unsigned int wwidth; +unsigned int lmargin; +unsigned int ascent; +} PRS_PTROOT; +typedef struct pr_ptroot +{ +PRS_ROOT root; +PRS_PTROOT ptroot; +} PR_PTROOT; +/* Property of ptseg */ +typedef struct { +PR_VAXVAR *phrases; +} PRS_PTSEG; +typedef struct pr_ptseg +{ +PRS_ROOT root; +PRS_PTROOT ptroot; +PRS_PTSEG ptseg; +} PR_PTSEG; +/* Property of ptflat */ +typedef struct { +unsigned char *buffer; +unsigned short int bufsize; +unsigned short int granularity; +unsigned short int nextoff; +} PRS_PTFLAT; +typedef struct pr_ptflat +{ +PRS_ROOT root; +PRS_PTROOT ptroot; +PRS_PTFLAT ptflat; +} PR_PTFLAT; diff --git a/code/SIBOSDK/include/polytext.ing b/code/SIBOSDK/include/polytext.ing new file mode 100644 index 0000000..f0b652b --- /dev/null +++ b/code/SIBOSDK/include/polytext.ing @@ -0,0 +1,100 @@ +; Generated by Ctran from polytext.cl +POLYTEXT_ING equ 1 +IFNDEF P_STD_INC + INCLUDE ..\inc\P_STD.INC +ENDIF +IFNDEF P_OBJECT_INC + INCLUDE ..\inc\P_OBJECT.INC +ENDIF +IFNDEF VARRAY_ING + INCLUDE ..\inc\VARRAY.ING +ENDIF +; Class Numbers +C_PTROOT equ 12 +C_PTSEG equ 13 +C_PTFLAT equ 14 +; Method Numbers +O_PT_RESET equ 2 +O_PT_MOD_BY_ATTRIB equ 11 +O_PT_ADD_PHRASE equ 6 +O_PT_DISPLAY_LINE equ 8 +O_PT_INIT equ 1 +O_PT_PUT_LINTAB equ 4 +O_PT_INQUIRE equ 13 +O_PT_WRAP equ 7 +O_PT_MOD_BY_NUM equ 10 +O_PT_PBUF equ 5 +O_PT_FIND equ 12 +O_PT_APPEND equ 3 +O_PT_SET_FONTS equ 9 +; Constants for ptroot +PT_FIND_DEFAULT equ (00000h) +PT_FIND_BACKWARDS equ (00001h) +PT_FIND_CAN_STAY equ (00002h) +PT_STY_DEFAULT equ (000h) +PT_STY_BREAK_AT_START equ (001h) +PT_STY_BREAK_AT_END equ (002h) +PT_STY_OSTRIKE_XLEFT equ (020h) +PT_STY_OSTRIKE_XRIGHT equ (040h) +PT_STY_OVERSTRIKE equ (080h) +PT_MAX_PHRASE_LEN equ (236) +PT_DESCR_MOD_FONT equ (00001h) +PT_DESCR_MOD_WS_STYLE equ (00002h) +PT_DESCR_MOD_PT_STYLE equ (00004h) +PT_DESCR_MOD_ATTRIB equ (00008h) +PT_DESCR_MOD_TLEN equ (00010h) +; Types for ptroot +PT_FONT_SPEC struc +PT_FONT_SPECFont_id dw ? +PT_FONT_SPECAttrib db ? +PT_FONT_SPEC ends +PT_PHRASE_INFO struc +PT_PHRASE_INFOLine dw ? +PT_PHRASE_INFOOffset dw ? +PT_PHRASE_INFOWidth dw ? +PT_PHRASE_INFO ends +PT_PHRASE_DESCR struc +PT_PHRASE_DESCRFont_id dw ? +PT_PHRASE_DESCRWs_style db ? +PT_PHRASE_DESCRPt_style db ? +PT_PHRASE_DESCRAttrib db ? +PT_PHRASE_DESCRTlen db ? +PT_PHRASE_DESCR ends +PT_PHRASE struc +PT_PHRASEDescr PT_PHRASE_DESCR <> +PT_PHRASETxt db (1) * 1 dup (?) +PT_PHRASE ends +; Property of ptroot +PRS_PTROOT struc +PtrootNphrases dw ? +PtrootNchars dw ? +PtrootNlines dw ? +PtrootWwidth dw ? +PtrootLmargin dw ? +PtrootAscent dw ? +PRS_PTROOT ends +PR_PTROOT struc +PtrootRoot PRS_ROOT <> +PtrootPtroot PRS_PTROOT <> +PR_PTROOT ends +; Property of ptseg +PRS_PTSEG struc +PtsegPhrases dw ? +PRS_PTSEG ends +PR_PTSEG struc +PtsegRoot PRS_ROOT <> +PtsegPtroot PRS_PTROOT <> +PtsegPtseg PRS_PTSEG <> +PR_PTSEG ends +; Property of ptflat +PRS_PTFLAT struc +PtflatBuffer dw ? +PtflatBufsize dw ? +PtflatGranularity dw ? +PtflatNextoff dw ? +PRS_PTFLAT ends +PR_PTFLAT struc +PtflatRoot PRS_ROOT <> +PtflatPtroot PRS_PTROOT <> +PtflatPtflat PRS_PTFLAT <> +PR_PTFLAT ends diff --git a/code/SIBOSDK/include/prdrv.g b/code/SIBOSDK/include/prdrv.g new file mode 100644 index 0000000..e757ca3 --- /dev/null +++ b/code/SIBOSDK/include/prdrv.g @@ -0,0 +1,205 @@ +/* Generated by Ctran from prdrv.cat */ +#define PRDRV_G +#ifndef P_FILE_H +#include +#endif +#ifndef APPMAN_G +#include +#endif +/* Class Numbers */ +#define C_WDR 6 +#define C_PDR 7 +/* Method Numbers */ +#define O_WDR_SEARCH_TYPEFACE 7 +#define O_PDR_PAGE 7 +#define O_WDR_TYPEFACE 6 +#define O_PDR_STYLE 12 +#define O_PDR_PRINT 2 +#define O_WDR_TWIPS_TO_XY 12 +#define O_WDR_FONT_HEIGHT 8 +#define O_WDR_SENSE_MODEL 5 +#define O_WDR_SET_MODEL 4 +#define O_WDR_SENSE_WIDTH 11 +#define O_WDR_COUNT_MODELS 2 +#define O_PDR_END 6 +#define O_PDR_TEXT 8 +#define O_PDR_DESTROY 4 +#define O_PDR_START 5 +#define O_PDR_INIT 1 +#define O_WDR_INIT 1 +#define O_PDR_RIGHT 10 +#define O_PDR_ADD_COMMAND 3 +#define O_WDR_GET_WIDTH_TABLE 10 +#define O_WDR_OPEN_PRINT 13 +#define O_WDR_LOAD_RECORD 14 +#define O_WDR_SEARCH_HEIGHT 9 +#define O_PDR_FONT 11 +#define O_WDR_SENSE_MODEL_NAME 3 +#define O_PDR_LINE 9 +/* Constants for wdr */ +#define WDR_PRINT_PAGE 0x01 +#define WDR_PRINT_LINE 0x02 +#define WDR_PRINT_RIGHT 0x04 +#define WDR_PRINT_FONT 0x08 +#define WDR_PRINT_TEXT 0x10 +#define WDR_PRINT_START 0x20 +#define WDR_PRINT_END 0x40 +#define WDR_PRINT_IDLE 0x4000 +#define WDR_PRINT_KEEP 0x8000 +#define WDR_PDR_LANDSCAPE 0x01 +#define WDR_RSC_HEADER 1 +#define WDR_RSC_COMMANDS 2 +#define WDR_DYL_LOAD 0x01 +#define WDR_HP_PCL 0x02 +#define WDR_STYLE_NORMAL 0x0000 +#define WDR_STYLE_UNDERLINE 0x0001 +#define WDR_STYLE_BOLD 0x0002 +#define WDR_STYLE_ITALIC 0x0004 +#define WDR_STYLE_SUPER 0x0008 +#define WDR_STYLE_SUB 0x0010 +#define WDR_STYLE_MONOSPACE 0x8000 +#define WDR_STYLE_SANS_SERIF 0x4000 +#define WDR_TYPF_PROPORTIONAL 0x01 +#define WDR_TYPF_SCALED 0x02 +#define WDR_TYPF_SERIF 0x04 +#define WDR_MODEL_LANDSCAPE_AVAILABLE 1 +#define WDR_MODEL_MINX_IS_DOTS_PER_INCH 4 +#define WDR_SCALE_DEFAULT_HEIGHT 1000 +#define WDR_FONT_NAME_LEN 20 +#define PRINTER_NAME_LEN 24 +#define PRINT_TYPE_LEN 9 +#define PDR_FILE_LEN 9 +/* Types for wdr */ +typedef struct +{ +unsigned short int height; +unsigned short int height_max; +unsigned short int height_delta; +unsigned short int width_scale; +unsigned short int width_normal; +unsigned short int width_italic; +unsigned short int width_bold; +unsigned short int width_bold_italic; +unsigned short int command; +} WDR_FONT; +typedef struct +{ +char name[WDR_FONT_NAME_LEN]; +unsigned short int typeface; +unsigned short int type; +short int trans_rid; +unsigned short int num_heights; +WDR_FONT font[1]; +} WDR_TYPEFACE; +typedef struct +{ +unsigned short int minx; +unsigned short int miny; +unsigned short int skipx; +unsigned short int skipy; +unsigned short int flags; +unsigned short int num_typefaces; +WDR_TYPEFACE *typeface[1]; +} WDR_MODEL; +typedef struct +{ +unsigned short int rid; +char name[PRINTER_NAME_LEN]; +} WDR_MODEL_INDEX; +typedef struct +{ +char id[6]; +unsigned short int flags; +unsigned short int num_model; +WDR_MODEL_INDEX model[1]; +} WDR_HEADER; +typedef struct width_table +{ +struct width_table *next; +unsigned short int rid; +unsigned short int height; +unsigned char *table; +} WDR_WIDTH_TABLE; +typedef struct +{ +short int flags; +short int typf; +short int fheight; +short int style; +short int down; +short int indent; +short int height; +short int right; +char *buf; +unsigned short int blen; +} WDR_PRINT; +/* Property of wdr */ +typedef struct { +PR_RSCFILE *file; +WDR_HEADER *head; +WDR_MODEL *model; +WDR_WIDTH_TABLE *wid; +char wdrname[P_FNAMESIZE]; +} PRS_WDR; +typedef struct pr_wdr +{ +PRS_ROOT root; +PRS_WDR wdr; +} PR_WDR; +/* Constants for pdr */ +#define PDR_CMD_RESET 0 +#define PDR_CMD_FORM_LENGTH 1 +#define PDR_CMD_PREAMBLE 2 +#define PDR_CMD_POSTAMBLE 3 +#define PDR_CMD_UNDERLINE_ON 4 +#define PDR_CMD_UNDERLINE_OFF 5 +#define PDR_CMD_BOLD_ON 6 +#define PDR_CMD_BOLD_OFF 7 +#define PDR_CMD_ITALIC_ON 8 +#define PDR_CMD_ITALIC_OFF 9 +#define PDR_CMD_SUPERSCRIPT_ON 10 +#define PDR_CMD_SUPERSCRIPT_OFF 11 +#define PDR_CMD_SUBSCRIPT_ON 12 +#define PDR_CMD_SUBSCRIPT_OFF 13 +#define PDR_CMD_NEW_PAGE 14 +#define PDR_CMD_CARRIAGE_RETURN 15 +#define PDR_CMD_MOVE_DOWN 16 +#define PDR_CMD_MOVE_RIGHT_PREFIX 17 +#define PDR_CMD_MOVE_RIGHT 18 +#define PDR_CMD_MOVE_RIGHT_SUFFIX 19 +#define PDR_CMD_LANDSCAPE 20 +/* Types for pdr */ +typedef struct +{ +PR_WDR *wdr; +short int flags; +short int page_length; +int dyl; +WDR_HEADER *head; +WDR_MODEL *model; +} PDR_INIT; +typedef struct +{ +unsigned char *commands; +unsigned char *outbuf; +unsigned char *trans_res; +char **tix; +} PDR_ALLOC; +/* Property of pdr */ +typedef struct { +PDR_INIT par; +unsigned short int mode; +short int typfix; +short int fhix; +short int style; +short int lheight; +PDR_ALLOC a; +unsigned short int trans_rid; +short int outlen; +unsigned short int skipy; +} PRS_PDR; +typedef struct pr_pdr +{ +PRS_ROOT root; +PRS_PDR pdr; +} PR_PDR; diff --git a/code/SIBOSDK/include/prdrv.ing b/code/SIBOSDK/include/prdrv.ing new file mode 100644 index 0000000..cbb0c39 --- /dev/null +++ b/code/SIBOSDK/include/prdrv.ing @@ -0,0 +1,194 @@ +; Generated by Ctran from prdrv.cl +PRDRV_ING equ 1 +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +; Class Numbers +C_WDR equ 6 +C_PDR equ 7 +; Method Numbers +O_WDR_SEARCH_TYPEFACE equ 7 +O_PDR_PAGE equ 7 +O_WDR_TYPEFACE equ 6 +O_PDR_STYLE equ 12 +O_PDR_PRINT equ 2 +O_WDR_TWIPS_TO_XY equ 12 +O_WDR_FONT_HEIGHT equ 8 +O_WDR_SENSE_MODEL equ 5 +O_WDR_SET_MODEL equ 4 +O_WDR_SENSE_WIDTH equ 11 +O_WDR_COUNT_MODELS equ 2 +O_PDR_END equ 6 +O_PDR_TEXT equ 8 +O_PDR_DESTROY equ 4 +O_PDR_START equ 5 +O_PDR_INIT equ 1 +O_WDR_INIT equ 1 +O_PDR_RIGHT equ 10 +O_PDR_ADD_COMMAND equ 3 +O_WDR_GET_WIDTH_TABLE equ 10 +O_WDR_OPEN_PRINT equ 13 +O_WDR_LOAD_RECORD equ 14 +O_WDR_SEARCH_HEIGHT equ 9 +O_PDR_FONT equ 11 +O_WDR_SENSE_MODEL_NAME equ 3 +O_PDR_LINE equ 9 +; Constants for wdr +WDR_PRINT_PAGE equ (001h) +WDR_PRINT_LINE equ (002h) +WDR_PRINT_RIGHT equ (004h) +WDR_PRINT_FONT equ (008h) +WDR_PRINT_TEXT equ (010h) +WDR_PRINT_START equ (020h) +WDR_PRINT_END equ (040h) +WDR_PRINT_IDLE equ (04000h) +WDR_PRINT_KEEP equ (08000h) +WDR_PDR_LANDSCAPE equ (001h) +WDR_RSC_HEADER equ (1) +WDR_RSC_COMMANDS equ (2) +WDR_DYL_LOAD equ (001h) +WDR_HP_PCL equ (002h) +WDR_STYLE_NORMAL equ (00000h) +WDR_STYLE_UNDERLINE equ (00001h) +WDR_STYLE_BOLD equ (00002h) +WDR_STYLE_ITALIC equ (00004h) +WDR_STYLE_SUPER equ (00008h) +WDR_STYLE_SUB equ (00010h) +WDR_STYLE_MONOSPACE equ (08000h) +WDR_STYLE_SANS_SERIF equ (04000h) +WDR_TYPF_PROPORTIONAL equ (001h) +WDR_TYPF_SCALED equ (002h) +WDR_TYPF_SERIF equ (004h) +WDR_MODEL_LANDSCAPE_AVAILABLE equ (1) +WDR_MODEL_MINX_IS_DOTS_PER_INCH equ (4) +WDR_SCALE_DEFAULT_HEIGHT equ (1000) +WDR_FONT_NAME_LEN equ (20) +PRINTER_NAME_LEN equ (24) +PRINT_TYPE_LEN equ (9) +PDR_FILE_LEN equ (9) +; Types for wdr +WDR_FONT struc +WDR_FONTHeight dw ? +WDR_FONTHeight_max dw ? +WDR_FONTHeight_delta dw ? +WDR_FONTWidth_scale dw ? +WDR_FONTWidth_normal dw ? +WDR_FONTWidth_italic dw ? +WDR_FONTWidth_bold dw ? +WDR_FONTWidth_bold_italic dw ? +WDR_FONTCommand dw ? +WDR_FONT ends +WDR_TYPEFACE struc +WDR_TYPEFACEName db (1) * WDR_FONT_NAME_LEN dup (?) +WDR_TYPEFACETypeface dw ? +WDR_TYPEFACEType dw ? +WDR_TYPEFACETrans_rid dw ? +WDR_TYPEFACENum_heights dw ? +WDR_TYPEFACEFont db (size WDR_FONT)* 1 dup (?) +WDR_TYPEFACE ends +WDR_MODEL struc +WDR_MODELMinx dw ? +WDR_MODELMiny dw ? +WDR_MODELSkipx dw ? +WDR_MODELSkipy dw ? +WDR_MODELFlags dw ? +WDR_MODELNum_typefaces dw ? +WDR_MODELTypeface dw 1 dup (?) +WDR_MODEL ends +WDR_MODEL_INDEX struc +WDR_MODEL_INDEXRid dw ? +WDR_MODEL_INDEXName db (1) * PRINTER_NAME_LEN dup (?) +WDR_MODEL_INDEX ends +WDR_HEADER struc +WDR_HEADERId db (1) * 6 dup (?) +WDR_HEADERFlags dw ? +WDR_HEADERNum_model dw ? +WDR_HEADERModel db (size WDR_MODEL_INDEX)* 1 dup (?) +WDR_HEADER ends +WDR_WIDTH_TABLE struc +WDR_WIDTH_TABLENext dw ? +WDR_WIDTH_TABLERid dw ? +WDR_WIDTH_TABLEHeight dw ? +WDR_WIDTH_TABLETable dw ? +WDR_WIDTH_TABLE ends +WDR_PRINT struc +WDR_PRINTFlags dw ? +WDR_PRINTTypf dw ? +WDR_PRINTFheight dw ? +WDR_PRINTStyle dw ? +WDR_PRINTDown dw ? +WDR_PRINTIndent dw ? +WDR_PRINTHeight dw ? +WDR_PRINTRight dw ? +WDR_PRINTBuf dw ? +WDR_PRINTBlen dw ? +WDR_PRINT ends +; Property of wdr +PRS_WDR struc +WdrFile dw ? +WdrHead dw ? +WdrModel dw ? +WdrWid dw ? +WdrWdrname db (1) * P_FNAMESIZE dup (?) +PRS_WDR ends +PR_WDR struc +WdrRoot PRS_ROOT <> +WdrWdr PRS_WDR <> +PR_WDR ends +; Constants for pdr +PDR_CMD_RESET equ (0) +PDR_CMD_FORM_LENGTH equ (1) +PDR_CMD_PREAMBLE equ (2) +PDR_CMD_POSTAMBLE equ (3) +PDR_CMD_UNDERLINE_ON equ (4) +PDR_CMD_UNDERLINE_OFF equ (5) +PDR_CMD_BOLD_ON equ (6) +PDR_CMD_BOLD_OFF equ (7) +PDR_CMD_ITALIC_ON equ (8) +PDR_CMD_ITALIC_OFF equ (9) +PDR_CMD_SUPERSCRIPT_ON equ (10) +PDR_CMD_SUPERSCRIPT_OFF equ (11) +PDR_CMD_SUBSCRIPT_ON equ (12) +PDR_CMD_SUBSCRIPT_OFF equ (13) +PDR_CMD_NEW_PAGE equ (14) +PDR_CMD_CARRIAGE_RETURN equ (15) +PDR_CMD_MOVE_DOWN equ (16) +PDR_CMD_MOVE_RIGHT_PREFIX equ (17) +PDR_CMD_MOVE_RIGHT equ (18) +PDR_CMD_MOVE_RIGHT_SUFFIX equ (19) +PDR_CMD_LANDSCAPE equ (20) +; Types for pdr +PDR_INIT struc +PDR_INITWdr dw ? +PDR_INITFlags dw ? +PDR_INITPage_length dw ? +PDR_INITDyl dw ? +PDR_INITHead dw ? +PDR_INITModel dw ? +PDR_INIT ends +PDR_ALLOC struc +PDR_ALLOCCommands dw ? +PDR_ALLOCOutbuf dw ? +PDR_ALLOCTrans_res dw ? +PDR_ALLOCTix dw ? +PDR_ALLOC ends +; Property of pdr +PRS_PDR struc +PdrPar PDR_INIT <> +PdrMode dw ? +PdrTypfix dw ? +PdrFhix dw ? +PdrStyle dw ? +PdrLheight dw ? +PdrA PDR_ALLOC <> +PdrTrans_rid dw ? +PdrOutlen dw ? +PdrSkipy dw ? +PRS_PDR ends +PR_PDR struc +PdrRoot PRS_ROOT <> +PdrPdr PRS_PDR <> +PR_PDR ends diff --git a/code/SIBOSDK/include/prev.g b/code/SIBOSDK/include/prev.g new file mode 100644 index 0000000..2d63b5f --- /dev/null +++ b/code/SIBOSDK/include/prev.g @@ -0,0 +1,164 @@ +/* Generated by Ctran from prev.cl */ +#define PREV_G +#ifndef HWIMMAN_G +#include +#endif +#ifndef GATE_G +#include +#endif +#ifndef DLGBOX_G +#include +#endif +#ifndef PRVPDR_G +#include +#endif +#ifndef PAGES_G +#include +#endif +/* Class Numbers */ +#define C_PRVINFO 0 +#define C_PRVVIEW 1 +#define C_PRVPAGE 2 +#define C_PRVCOMM 3 +#define C_PRVJUMP_DLG 4 +#define C_PRVOPTIONS_DLG 5 +/* Method Numbers */ +#define O_PVV_NEW_PAGE 16 +#define O_PVV_PAGES_DONE 15 +#define O_PVC_PREVIEW_EXIT 12 +#define O_PVP_MARGINS 14 +#define O_PVV_MARGINS 17 +#define O_PVV_FALSE 19 +#define O_PVV_DONE 14 +#define O_PVC_PREVIEW_PRINT 8 +#define O_PVC_PREVIEW_OPTIONS 10 +#define O_PVC_PREVIEW_MARGINS 9 +#define O_PVV_INIT 18 +#define O_PVC_PREVIEW_JUMP 11 +/* Property of prvinfo */ +typedef struct { +int NoPages; +unsigned short int FontHeight; +unsigned short int FontAscent; +} PRS_PRVINFO; +typedef struct pr_prvinfo +{ +PRS_ROOT root; +PRS_WIN win; +PRS_PRVINFO prvinfo; +} PR_PRVINFO; +/* Constants for prvview */ +#define PVV_INTERPAGE_GAP 6 +#define PVV_TOP_GAP 4 +#define PVV_FOOTER_GAP 12 +#define PVV_PAGE_SHADOW 1 +#define PVV_SIDE_GAP 12 +#define PVV_PAGENO_DISP_GAP 60 +#define PVV_DISP_FACING 0 +#define PVV_DISP1 1 +#define PVV_DISP2 2 +#define PVV_DISP3 3 +#define PVV_DISP4 4 +#define PVV_MARGINS_ON 0x01 +#define PVV_PREVIEW_SET 0x80 +#define PVV_VIEW_MAX_PAGEVIEWS 4 +/* Types for prvview */ +typedef struct +{ +PAGES_CALLS Calls; +short int PrintMethod; +short int Spare1; +short int Spare2; +} IN_PRVVIEW; +typedef struct +{ +P_RECT Margins; +int HeadTop; +int HeadBot; +P_RECT Border; +P_RECT Footer; +} PVV_PAGE_DATA; +typedef struct +{ +PR_ROOT *pArray; +int NoPages; +int FirstPage; +int LastPage; +int PageOffset; +int PageNo; +PVV_DISPLAY Disp; +int UseGrey; +int LeftOffset; +int PageViewWidth; +PVV_PAGE_DATA Page; +unsigned char *pBitRow; +unsigned char *pLastRow; +BMP_RASTER_ROW_REC *pRowRec; +int PrvSegHandle; +PRV_BITMAP Bmp; +} PVV_PAGEVIEW_DATA; +/* Property of prvview */ +typedef struct { +PR_PAGES *pPages; +PR_PRVINFO *pPrvInfo; +PR_ROOT *pPageView[PVV_VIEW_MAX_PAGEVIEWS]; +WSERV_INFO *pOldMenu; +PR_COMMAN *pOldComman; +short int Started; +short int PrintMethod; +void *hdone; +short int mdone; +int NoPageViews; +int MaxNoPageViews; +P_RECT ScrollArea; +PVV_PAGEVIEW_DATA Pv; +} PRS_PRVVIEW; +typedef struct pr_prvview +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_PRVVIEW prvview; +} PR_PRVVIEW; +/* Types for prvpage */ +typedef struct +{ +PR_PRVVIEW *pPrvView; +int Pos; +unsigned short int wid; +} IN_PRVPAGE; +/* Property of prvpage */ +typedef struct { +IN_PRVPAGE init; +} PRS_PRVPAGE; +typedef struct pr_prvpage +{ +PRS_ROOT root; +PRS_WIN win; +PRS_PRVPAGE prvpage; +} PR_PRVPAGE; +/* Property of prvcomm */ +typedef struct { +PR_PRVVIEW *pPrvView; +} PRS_PRVCOMM; +typedef struct pr_prvcomm +{ +PRS_ROOT root; +PRS_PRVCOMM prvcomm; +} PR_PRVCOMM; +/* Property of prvjump_dlg */ +typedef struct pr_prvjump_dlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_PRVJUMP_DLG; +/* Property of prvoptions_dlg */ +typedef struct pr_prvoptions_dlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_PRVOPTIONS_DLG; diff --git a/code/SIBOSDK/include/prev.ing b/code/SIBOSDK/include/prev.ing new file mode 100644 index 0000000..67dd2c4 --- /dev/null +++ b/code/SIBOSDK/include/prev.ing @@ -0,0 +1,154 @@ +; Generated by Ctran from prev.cl +PREV_ING equ 1 +IFNDEF HWIMMAN_ING + INCLUDE ..\inc\HWIMMAN.ING +ENDIF +IFNDEF GATE_ING + INCLUDE ..\inc\GATE.ING +ENDIF +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF PRVPDR_ING + INCLUDE ..\inc\PRVPDR.ING +ENDIF +IFNDEF PAGES_ING + INCLUDE ..\inc\PAGES.ING +ENDIF +; Class Numbers +C_PRVINFO equ 0 +C_PRVVIEW equ 1 +C_PRVPAGE equ 2 +C_PRVCOMM equ 3 +C_PRVJUMP_DLG equ 4 +C_PRVOPTIONS_DLG equ 5 +; Method Numbers +O_PVV_NEW_PAGE equ 16 +O_PVV_PAGES_DONE equ 15 +O_PVC_PREVIEW_EXIT equ 12 +O_PVP_MARGINS equ 14 +O_PVV_MARGINS equ 17 +O_PVV_FALSE equ 19 +O_PVV_DONE equ 14 +O_PVC_PREVIEW_PRINT equ 8 +O_PVC_PREVIEW_OPTIONS equ 10 +O_PVC_PREVIEW_MARGINS equ 9 +O_PVV_INIT equ 18 +O_PVC_PREVIEW_JUMP equ 11 +; Property of prvinfo +PRS_PRVINFO struc +PrvinfoNoPages dw ? +PrvinfoFontHeight dw ? +PrvinfoFontAscent dw ? +PRS_PRVINFO ends +PR_PRVINFO struc +PrvinfoRoot PRS_ROOT <> +PrvinfoWin PRS_WIN <> +PrvinfoPrvinfo PRS_PRVINFO <> +PR_PRVINFO ends +; Constants for prvview +PVV_INTERPAGE_GAP equ (6) +PVV_TOP_GAP equ (4) +PVV_FOOTER_GAP equ (12) +PVV_PAGE_SHADOW equ (1) +PVV_SIDE_GAP equ (12) +PVV_PAGENO_DISP_GAP equ (60) +PVV_DISP_FACING equ (0) +PVV_DISP1 equ (1) +PVV_DISP2 equ (2) +PVV_DISP3 equ (3) +PVV_DISP4 equ (4) +PVV_MARGINS_ON equ (001h) +PVV_PREVIEW_SET equ (080h) +PVV_VIEW_MAX_PAGEVIEWS equ (4) +; Types for prvview +IN_PRVVIEW struc +IN_PRVVIEWCalls PAGES_CALLS <> +IN_PRVVIEWPrintMethod dw ? +IN_PRVVIEWSpare1 dw ? +IN_PRVVIEWSpare2 dw ? +IN_PRVVIEW ends +PVV_PAGE_DATA struc +PVV_PAGE_DATAMargins P_RECT <> +PVV_PAGE_DATAHeadTop dw ? +PVV_PAGE_DATAHeadBot dw ? +PVV_PAGE_DATABorder P_RECT <> +PVV_PAGE_DATAFooter P_RECT <> +PVV_PAGE_DATA ends +PVV_PAGEVIEW_DATA struc +PVV_PAGEVIEW_DATAPArray dw ? +PVV_PAGEVIEW_DATANoPages dw ? +PVV_PAGEVIEW_DATAFirstPage dw ? +PVV_PAGEVIEW_DATALastPage dw ? +PVV_PAGEVIEW_DATAPageOffset dw ? +PVV_PAGEVIEW_DATAPageNo dw ? +PVV_PAGEVIEW_DATADisp PVV_DISPLAY <> +PVV_PAGEVIEW_DATAUseGrey dw ? +PVV_PAGEVIEW_DATALeftOffset dw ? +PVV_PAGEVIEW_DATAPageViewWidth dw ? +PVV_PAGEVIEW_DATAPage PVV_PAGE_DATA <> +PVV_PAGEVIEW_DATAPBitRow dw ? +PVV_PAGEVIEW_DATAPLastRow dw ? +PVV_PAGEVIEW_DATAPRowRec dw ? +PVV_PAGEVIEW_DATAPrvSegHandle dw ? +PVV_PAGEVIEW_DATABmp PRV_BITMAP <> +PVV_PAGEVIEW_DATA ends +; Property of prvview +PRS_PRVVIEW struc +PrvviewPPages dw ? +PrvviewPPrvInfo dw ? +PrvviewPPageView dw PVV_VIEW_MAX_PAGEVIEWS dup (?) +PrvviewPOldMenu dw ? +PrvviewPOldComman dw ? +PrvviewStarted dw ? +PrvviewPrintMethod dw ? +PrvviewHdone dw ? +PrvviewMdone dw ? +PrvviewNoPageViews dw ? +PrvviewMaxNoPageViews dw ? +PrvviewScrollArea P_RECT <> +PrvviewPv PVV_PAGEVIEW_DATA <> +PRS_PRVVIEW ends +PR_PRVVIEW struc +PrvviewRoot PRS_ROOT <> +PrvviewWin PRS_WIN <> +PrvviewDlgchain PRS_DLGCHAIN <> +PrvviewPrvview PRS_PRVVIEW <> +PR_PRVVIEW ends +; Types for prvpage +IN_PRVPAGE struc +IN_PRVPAGEPPrvView dw ? +IN_PRVPAGEPos dw ? +IN_PRVPAGEWid dw ? +IN_PRVPAGE ends +; Property of prvpage +PRS_PRVPAGE struc +PrvpageInit IN_PRVPAGE <> +PRS_PRVPAGE ends +PR_PRVPAGE struc +PrvpageRoot PRS_ROOT <> +PrvpageWin PRS_WIN <> +PrvpagePrvpage PRS_PRVPAGE <> +PR_PRVPAGE ends +; Property of prvcomm +PRS_PRVCOMM struc +PrvcommPPrvView dw ? +PRS_PRVCOMM ends +PR_PRVCOMM struc +PrvcommRoot PRS_ROOT <> +PrvcommPrvcomm PRS_PRVCOMM <> +PR_PRVCOMM ends +; Property of prvjump_dlg +PR_PRVJUMP_DLG struc +Prvjump_dlgRoot PRS_ROOT <> +Prvjump_dlgWin PRS_WIN <> +Prvjump_dlgDlgchain PRS_DLGCHAIN <> +Prvjump_dlgDlgbox PRS_DLGBOX <> +PR_PRVJUMP_DLG ends +; Property of prvoptions_dlg +PR_PRVOPTIONS_DLG struc +Prvoptions_dlgRoot PRS_ROOT <> +Prvoptions_dlgWin PRS_WIN <> +Prvoptions_dlgDlgchain PRS_DLGCHAIN <> +Prvoptions_dlgDlgbox PRS_DLGBOX <> +PR_PRVOPTIONS_DLG ends diff --git a/code/SIBOSDK/include/printer.g b/code/SIBOSDK/include/printer.g new file mode 100644 index 0000000..6b34e76 --- /dev/null +++ b/code/SIBOSDK/include/printer.g @@ -0,0 +1,91 @@ +/* Generated by Ctran from printer.cat */ +#define PRINTER_G +#ifndef PAGES_G +#include +#endif +/* Class Numbers */ +#define C_PRINTER 9 +/* Method Numbers */ +#define O_PR_PREVIEW_START 17 +#define O_PR_PAGINATE 16 +#define O_PR_SENSE_PORT 7 +#define O_PR_OPEN_WDR 12 +#define O_PR_SET_PORT_TYPE 4 +#define O_PR_PREVIEW 18 +#define O_PR_SET_MODEL 5 +#define O_PR_CLOSE_WDR 13 +#define O_PR_SET_HD 10 +#define O_PR_PREVIEW_END 19 +#define O_PR_STORE_SRCHAR 2 +#define O_PR_GET_HD 11 +#define O_PR_SENSE_MODEL 8 +#define O_PR_PORT_DATA 6 +#define O_PR_GET_PARAMS 9 +#define O_PR_STORE_FILE 3 +#define O_PR_PREVIEW_DATA 20 +#define O_PR_PRINT 15 +#define O_PR_OPEN_PORT 14 +#define O_PR_INIT 1 +/* Constants for printer */ +#define PRINTER_PORT_PARALLEL 0 +#define PRINTER_PORT_SERIAL 1 +#define PRINTER_PORT_FILE 2 +#define PRINTER_PORT_FAX 3 +#define PRINTER_PORT_NOT_SET 255 +#define PRINTER_HDR_TOP 0 +#define PRINTER_HDR_BOT 1 +#define PRINTER_PAGINATE 0 +#define PRINTER_PRINTING 1 +#define PRINTER_PREVIEW 2 +#define PRV_SEG_GRANULARITY 16 +/* Types for printer */ +typedef struct +{ +char *model; +char *hdtxt[2]; +} PRINTER_ALLOC; +typedef struct +{ +SCRLAY_FONT f; +unsigned char size_choice; +unsigned char wo_control; +unsigned short int spare[2]; +} PRINTER_DATA; +typedef struct +{ +PAGES_PARAMS p; +PRINTER_DATA d; +} PRINTER_PARAMS; +typedef struct +{ +unsigned char *pSegName; +PR_ROOT *pArray; +UPOINT PrvSize; +unsigned short int BitWidth; +void *hPrvDone; +short int mPrvDone; +} PREVIEW_INIT; +typedef struct +{ +int SegHandle; +PR_ROOT *pArray; +UPOINT Size; +unsigned short int BitWidth; +void *hPrvDone; +short int mPrvDone; +} PREVIEW_DATA; +/* Property of printer */ +typedef struct { +PR_WDR *wdr; +PRINTER_ALLOC a; +short int port_type; +char deftoptxt[3]; +char defbottxt[3]; +PRINTER_PARAMS p; +PREVIEW_DATA prv; +} PRS_PRINTER; +typedef struct pr_printer +{ +PRS_ROOT root; +PRS_PRINTER printer; +} PR_PRINTER; diff --git a/code/SIBOSDK/include/printer.ing b/code/SIBOSDK/include/printer.ing new file mode 100644 index 0000000..a65d9e7 --- /dev/null +++ b/code/SIBOSDK/include/printer.ing @@ -0,0 +1,86 @@ +; Generated by Ctran from printer.cl +PRINTER_ING equ 1 +IFNDEF PAGES_ING + INCLUDE ..\inc\PAGES.ING +ENDIF +; Class Numbers +C_PRINTER equ 9 +; Method Numbers +O_PR_PREVIEW_START equ 17 +O_PR_PAGINATE equ 16 +O_PR_SENSE_PORT equ 7 +O_PR_OPEN_WDR equ 12 +O_PR_SET_PORT_TYPE equ 4 +O_PR_PREVIEW equ 18 +O_PR_SET_MODEL equ 5 +O_PR_CLOSE_WDR equ 13 +O_PR_SET_HD equ 10 +O_PR_PREVIEW_END equ 19 +O_PR_STORE_SRCHAR equ 2 +O_PR_GET_HD equ 11 +O_PR_SENSE_MODEL equ 8 +O_PR_PORT_DATA equ 6 +O_PR_GET_PARAMS equ 9 +O_PR_STORE_FILE equ 3 +O_PR_PREVIEW_DATA equ 20 +O_PR_PRINT equ 15 +O_PR_OPEN_PORT equ 14 +O_PR_INIT equ 1 +; Constants for printer +PRINTER_PORT_PARALLEL equ (0) +PRINTER_PORT_SERIAL equ (1) +PRINTER_PORT_FILE equ (2) +PRINTER_PORT_FAX equ (3) +PRINTER_PORT_IR equ (4) +PRINTER_PORT_NOT_SET equ (255) +PRINTER_HDR_TOP equ (0) +PRINTER_HDR_BOT equ (1) +PRINTER_PAGINATE equ (0) +PRINTER_PRINTING equ (1) +PRINTER_PREVIEW equ (2) +PRV_SEG_GRANULARITY equ (16) +; Types for printer +PRINTER_ALLOC struc +PRINTER_ALLOCModel dw ? +PRINTER_ALLOCHdtxt dw 2 dup (?) +PRINTER_ALLOC ends +PRINTER_DATA struc +PRINTER_DATAF SCRLAY_FONT <> +PRINTER_DATASize_choice db ? +PRINTER_DATAWo_control db ? +PRINTER_DATASpare db (2) * 2 dup (?) +PRINTER_DATA ends +PRINTER_PARAMS struc +PRINTER_PARAMSP PAGES_PARAMS <> +PRINTER_PARAMSD PRINTER_DATA <> +PRINTER_PARAMS ends +PREVIEW_INIT struc +PREVIEW_INITPSegName dw ? +PREVIEW_INITPArray dw ? +PREVIEW_INITPrvSize UPOINT <> +PREVIEW_INITBitWidth dw ? +PREVIEW_INITHPrvDone dw ? +PREVIEW_INITMPrvDone dw ? +PREVIEW_INIT ends +PREVIEW_DATA struc +PREVIEW_DATASegHandle dw ? +PREVIEW_DATAPArray dw ? +PREVIEW_DATASize UPOINT <> +PREVIEW_DATABitWidth dw ? +PREVIEW_DATAHPrvDone dw ? +PREVIEW_DATAMPrvDone dw ? +PREVIEW_DATA ends +; Property of printer +PRS_PRINTER struc +PrinterWdr dw ? +PrinterA PRINTER_ALLOC <> +PrinterPort_type dw ? +PrinterDeftoptxt db (1) * 3 dup (?) +PrinterDefbottxt db (1) * 3 dup (?) +PrinterP PRINTER_PARAMS <> +PrinterPrv PREVIEW_DATA <> +PRS_PRINTER ends +PR_PRINTER struc +PrinterRoot PRS_ROOT <> +PrinterPrinter PRS_PRINTER <> +PR_PRINTER ends diff --git a/code/SIBOSDK/include/printing.g b/code/SIBOSDK/include/printing.g new file mode 100644 index 0000000..8f69834 --- /dev/null +++ b/code/SIBOSDK/include/printing.g @@ -0,0 +1,34 @@ +/* Generated by Ctran from printing.cl */ +#define PRINTING_G +#ifndef DLGBOX_G +#include +#endif +#ifndef PAGES_G +#include +#endif +/* Class Numbers */ +#define C_PRINTING 72 +/* Method Numbers */ +#define O_PRINTING_SET_TITLE 35 +#define O_PRINTING_DO_PRINT 36 +#define O_PRINTING_DONE 37 +/* Constants for printing */ +#define PR_WIN_WILL_SKIP 0x4000 +/* Types for printing */ +typedef struct +{ +PAGES_CALLS calls; +void **ppages; +} RBUF_PRINTING; +/* Property of printing */ +typedef struct { +void *pages; +} PRS_PRINTING; +typedef struct pr_printing +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_PRINTING printing; +} PR_PRINTING; diff --git a/code/SIBOSDK/include/printing.ing b/code/SIBOSDK/include/printing.ing new file mode 100644 index 0000000..066b91c --- /dev/null +++ b/code/SIBOSDK/include/printing.ing @@ -0,0 +1,32 @@ +; Generated by Ctran from printing.cl +PRINTING_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF PAGES_ING + INCLUDE ..\inc\PAGES.ING +ENDIF +; Class Numbers +C_PRINTING equ 72 +; Method Numbers +O_PRINTING_SET_TITLE equ 35 +O_PRINTING_DO_PRINT equ 36 +O_PRINTING_DONE equ 37 +; Constants for printing +PR_WIN_WILL_SKIP equ (04000h) +; Types for printing +RBUF_PRINTING struc +RBUF_PRINTINGCalls PAGES_CALLS <> +RBUF_PRINTINGPpages dw ? +RBUF_PRINTING ends +; Property of printing +PRS_PRINTING struc +PrintingPages dw ? +PRS_PRINTING ends +PR_PRINTING struc +PrintingRoot PRS_ROOT <> +PrintingWin PRS_WIN <> +PrintingDlgchain PRS_DLGCHAIN <> +PrintingDlgbox PRS_DLGBOX <> +PrintingPrinting PRS_PRINTING <> +PR_PRINTING ends diff --git a/code/SIBOSDK/include/prnprev.g b/code/SIBOSDK/include/prnprev.g new file mode 100644 index 0000000..eac516c --- /dev/null +++ b/code/SIBOSDK/include/prnprev.g @@ -0,0 +1,16 @@ +/* Generated by Ctran from prnprev.cl */ +#define PRNPREV_G +#ifndef DLGBOX_G +#include +#endif +/* Class Numbers */ +#define C_PRNPREV 80 +/* Method Numbers */ +/* Property of prnprev */ +typedef struct pr_prnprev +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_PRNPREV; diff --git a/code/SIBOSDK/include/prnprev.ing b/code/SIBOSDK/include/prnprev.ing new file mode 100644 index 0000000..be984ed --- /dev/null +++ b/code/SIBOSDK/include/prnprev.ing @@ -0,0 +1,15 @@ +; Generated by Ctran from prnprev.cl +PRNPREV_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +; Class Numbers +C_PRNPREV equ 80 +; Method Numbers +; Property of prnprev +PR_PRNPREV struc +PrnprevRoot PRS_ROOT <> +PrnprevWin PRS_WIN <> +PrnprevDlgchain PRS_DLGCHAIN <> +PrnprevDlgbox PRS_DLGBOX <> +PR_PRNPREV ends diff --git a/code/SIBOSDK/include/prntdlgs.g b/code/SIBOSDK/include/prntdlgs.g new file mode 100644 index 0000000..815411a --- /dev/null +++ b/code/SIBOSDK/include/prntdlgs.g @@ -0,0 +1,123 @@ +/* Generated by Ctran from prntdlgs.cl */ +#define PRNTDLGS_G +#ifndef DLGBOX_G +#include +#endif +#ifndef GATE_G +#include +#endif +#ifndef SCRLAY_G +#include +#endif +#ifndef P_FILE_H +#include +#endif +#ifndef P_SERIAL_H +#include +#endif +/* Class Numbers */ +#define C_PDEVDLG 65 +#define C_PRNCTRL 66 +#define C_PAGECTRL 67 +#define C_MARGINS 68 +#define C_HEADFOOT 69 +#define C_PRNMODEL 70 +#define C_PAGESIZE 71 +/* Method Numbers */ +/* Property of pdevdlg */ +typedef struct { +PR_ROOT *printer; +P_SRCHAR srchar; +short int filechanged; +short int own_printer; +PVV_DISPLAY Disp; +} PRS_PDEVDLG; +typedef struct pr_pdevdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_PDEVDLG pdevdlg; +} PR_PDEVDLG; +/* Types for prnctrl */ +typedef struct +{ +unsigned short int tmarg; +unsigned short int lmarg; +unsigned short int rmarg; +unsigned short int bmarg; +} TMARG; +/* Property of prnctrl */ +typedef struct { +TMARG tm; +} PRS_PRNCTRL; +typedef struct pr_prnctrl +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_PRNCTRL prnctrl; +} PR_PRNCTRL; +/* Property of pagectrl */ +typedef struct pr_pagectrl +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_PAGECTRL; +/* Property of margins */ +typedef struct pr_margins +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_MARGINS; +/* Property of headfoot */ +typedef struct { +void *ph; +unsigned short int *offset; +} PRS_HEADFOOT; +typedef struct pr_headfoot +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_HEADFOOT headfoot; +} PR_HEADFOOT; +/* Types for prnmodel */ +typedef struct +{ +int path; +int index; +} MLIST_ITEM; +/* Property of prnmodel */ +typedef struct { +PR_VASTR *pm; +PR_VASTR *pf; +PR_VAFLAT *pi; +unsigned short int model; +short int nsel; +SCRLAY_FONT sf; +char wdrfile[P_FNAMESIZE]; +} PRS_PRNMODEL; +typedef struct pr_prnmodel +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_PRNMODEL prnmodel; +} PR_PRNMODEL; +/* Property of pagesize */ +typedef struct pr_pagesize +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_PAGESIZE; diff --git a/code/SIBOSDK/include/prntdlgs.ing b/code/SIBOSDK/include/prntdlgs.ing new file mode 100644 index 0000000..808accc --- /dev/null +++ b/code/SIBOSDK/include/prntdlgs.ing @@ -0,0 +1,114 @@ +; Generated by Ctran from prntdlgs.cl +PRNTDLGS_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF GATE_ING + INCLUDE ..\inc\GATE.ING +ENDIF +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +IFNDEF P_SERIAL_INC + INCLUDE ..\inc\P_SERIAL.INC +ENDIF +; Class Numbers +C_PDEVDLG equ 65 +C_PRNCTRL equ 66 +C_PAGECTRL equ 67 +C_MARGINS equ 68 +C_HEADFOOT equ 69 +C_PRNMODEL equ 70 +C_PAGESIZE equ 71 +; Method Numbers +; Property of pdevdlg +PRS_PDEVDLG struc +PdevdlgPrinter dw ? +PdevdlgSrchar P_SRCHAR <> +PdevdlgFilechanged dw ? +PdevdlgOwn_printer dw ? +PdevdlgDisp PVV_DISPLAY <> +PRS_PDEVDLG ends +PR_PDEVDLG struc +PdevdlgRoot PRS_ROOT <> +PdevdlgWin PRS_WIN <> +PdevdlgDlgchain PRS_DLGCHAIN <> +PdevdlgDlgbox PRS_DLGBOX <> +PdevdlgPdevdlg PRS_PDEVDLG <> +PR_PDEVDLG ends +; Types for prnctrl +TMARG struc +TMARGTmarg dw ? +TMARGLmarg dw ? +TMARGRmarg dw ? +TMARGBmarg dw ? +TMARG ends +; Property of prnctrl +PRS_PRNCTRL struc +PrnctrlTm TMARG <> +PRS_PRNCTRL ends +PR_PRNCTRL struc +PrnctrlRoot PRS_ROOT <> +PrnctrlWin PRS_WIN <> +PrnctrlDlgchain PRS_DLGCHAIN <> +PrnctrlDlgbox PRS_DLGBOX <> +PrnctrlPrnctrl PRS_PRNCTRL <> +PR_PRNCTRL ends +; Property of pagectrl +PR_PAGECTRL struc +PagectrlRoot PRS_ROOT <> +PagectrlWin PRS_WIN <> +PagectrlDlgchain PRS_DLGCHAIN <> +PagectrlDlgbox PRS_DLGBOX <> +PR_PAGECTRL ends +; Property of margins +PR_MARGINS struc +MarginsRoot PRS_ROOT <> +MarginsWin PRS_WIN <> +MarginsDlgchain PRS_DLGCHAIN <> +MarginsDlgbox PRS_DLGBOX <> +PR_MARGINS ends +; Property of headfoot +PRS_HEADFOOT struc +HeadfootPh dw ? +HeadfootOffset dw ? +PRS_HEADFOOT ends +PR_HEADFOOT struc +HeadfootRoot PRS_ROOT <> +HeadfootWin PRS_WIN <> +HeadfootDlgchain PRS_DLGCHAIN <> +HeadfootDlgbox PRS_DLGBOX <> +HeadfootHeadfoot PRS_HEADFOOT <> +PR_HEADFOOT ends +; Types for prnmodel +MLIST_ITEM struc +MLIST_ITEMPath dw ? +MLIST_ITEMIndex dw ? +MLIST_ITEM ends +; Property of prnmodel +PRS_PRNMODEL struc +PrnmodelPm dw ? +PrnmodelPf dw ? +PrnmodelPi dw ? +PrnmodelModel dw ? +PrnmodelNsel dw ? +PrnmodelSf SCRLAY_FONT <> +PrnmodelWdrfile db (1) * P_FNAMESIZE dup (?) +PRS_PRNMODEL ends +PR_PRNMODEL struc +PrnmodelRoot PRS_ROOT <> +PrnmodelWin PRS_WIN <> +PrnmodelDlgchain PRS_DLGCHAIN <> +PrnmodelDlgbox PRS_DLGBOX <> +PrnmodelPrnmodel PRS_PRNMODEL <> +PR_PRNMODEL ends +; Property of pagesize +PR_PAGESIZE struc +PagesizeRoot PRS_ROOT <> +PagesizeWin PRS_WIN <> +PagesizeDlgchain PRS_DLGCHAIN <> +PagesizeDlgbox PRS_DLGBOX <> +PR_PAGESIZE ends diff --git a/code/SIBOSDK/include/process.h b/code/SIBOSDK/include/process.h new file mode 100644 index 0000000..3d3f9d2 --- /dev/null +++ b/code/SIBOSDK/include/process.h @@ -0,0 +1,47 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* process.h - header for process control functions. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _PROCESS_INC_ +#define _PROCESS_INC_ + + +/* Modes available as first argument of the spawn? functions. */ + +#define P_WAIT 0 /* child runs separately, parent waits */ +#define P_NOWAIT 1 /* both concurrent */ +#define P_OVERLAY 2 /* parent dies, same as exec? */ + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort(void); +extern int atexit(void (* func)(void)); +extern void (* onexit(void (* func)(void)))(); + +extern int execl(const char *_path, char *_arg0, ...); +extern int execlp(const char *_path, char *_arg0, ...); +extern int execv(const char *_path, char *_argv[]); +extern int execvp(const char *_path, char *_argv[]); + +extern void exit(int _status); +extern void _exit(int _status); +extern unsigned getpid(void); + +extern int spawnl(int _mode, const char *_path, char *_arg0, ...); +extern int spawnlp(int _mode, const char *_path, char *_arg0, ...); +extern int spawnv(int _mode, const char *_path, char *_argv[]); +extern int spawnvp(int _mode, const char *_path, char *_argv[]); +extern int system(const char *_command); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/SIBOSDK/include/program.g b/code/SIBOSDK/include/program.g new file mode 100644 index 0000000..07d4768 --- /dev/null +++ b/code/SIBOSDK/include/program.g @@ -0,0 +1,65 @@ +/* Generated by Ctran from program.cl */ +#define PROGRAM_G +#ifndef P_STD_H +#include +#endif +#ifndef P_OBJECT_H +#include +#endif +#ifndef PROGRAM_H +#include +#endif +#ifndef OLIB_G +#include +#endif +#ifndef APPMAN_G +#include +#endif +#ifndef FACTIVE_G +#include +#endif +#ifndef IPC_G +#include +#endif +/* Class Numbers */ +#define C_PROGTRAN 53 +#define C_PROGEXEC 54 +#define C_PROGFIND 55 +/* Method Numbers */ +#define O_PT_START 4 +#define O_PT_COMPLETE 6 +#define O_PT_GETLINE 5 +/* Constants for progtran */ +#define PROGTRAN_PROG_TYPE_MASK 0x7fff +#define PROGTRAN_COMPATIBILITY_MODE 0x8000 +/* Property of progtran */ +typedef struct { +PROGTRAN_STATUS st; +char buf[256]; +} PRS_PROGTRAN; +typedef struct pr_progtran +{ +PRS_ROOT root; +PRS_SERVER server; +PRS_PROGTRAN progtran; +} PR_PROGTRAN; +/* Property of progexec */ +typedef struct { +PROGEXEC_RESBUF result; +} PRS_PROGEXEC; +typedef struct pr_progexec +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_PROGEXEC progexec; +} PR_PROGEXEC; +/* Property of progfind */ +typedef struct { +unsigned char *pbuf; +} PRS_PROGFIND; +typedef struct pr_progfind +{ +PRS_ROOT root; +PRS_LOCS locs; +PRS_PROGFIND progfind; +} PR_PROGFIND; diff --git a/code/SIBOSDK/include/program.h b/code/SIBOSDK/include/program.h new file mode 100644 index 0000000..08786cc --- /dev/null +++ b/code/SIBOSDK/include/program.h @@ -0,0 +1,59 @@ +/* HEADER - PROGRAM.H +PROGRAM header +Copyright (c) Psion PLC 1993. + + VER DATE BY DESCRIPTION +----- -------- ---- ----------- +1.00A 03/03/93 HP Initial release +*/ +#ifndef PROGRAM_H +#define PROGRAM_H + +#include +#include + +/* Constants for progexec */ +#define PROGEXEC_SIGNAL 0x01 /* signal on completion */ +#define PROGEXEC_NOTIFY 0x02 /* call notifier on error */ +#define H_COMMAND_TRANSLATE_FILE 'T' +#define H_COMMAND_RUN_FILE 'R' +#define H_COMMAND_XTRANSLATE_FILE 't' + +/* Constants for progtran */ +#define PT_PROGTRAN_LINE 0x10 /* get a line of source */ +#define PT_PROGTRAN_DEATH 0x11 /* Opl translator death */ + +/* Types for progtran */ +typedef struct + { + WORD stat; /* completion status */ + UWORD mode; /* translation mode */ + UWORD line; /* line number */ + UWORD offset; /* offset to syntax error */ + } PROGTRAN_STATUS; + +typedef struct + { + UWORD pid; /* process id of source */ + TEXT *buffer_offset; /* offset of buffer in source process */ + PROGTRAN_STATUS *status_offset; /* offset of status block in source */ + } PROGTRAN_SOURCE; + +/* Types for progexec */ +typedef struct + { /* receives data from sys$prg?.img on completion */ + WORD error; /* runtime error */ + UWORD line; /* line no of start of proc containing error */ + UWORD offset; /* Q code offset to runtime error */ + TEXT err[40]; /* runtime error string */ + TEXT src[P_FNAMESIZE]; /* to take source module name */ + } PROGEXEC_RESBUF; + +typedef struct + { /* used to pass parameters to sys$prg?.img in p_execc() */ + UWORD flags; /* mode information */ + UWORD pid; /* requestor process id */ + PROGEXEC_RESBUF *result_offset; /* result buffer offset */ + } PROGEXEC_PAR; + +#endif // PROGRAM_H \ No newline at end of file diff --git a/code/SIBOSDK/include/program.inc b/code/SIBOSDK/include/program.inc new file mode 100644 index 0000000..ffb607f --- /dev/null +++ b/code/SIBOSDK/include/program.inc @@ -0,0 +1,53 @@ + title PROGRAM + subttl Copyright (c) Psion PLC 1993 + name PROGRAM +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 00.1A 03/03/93 HP First release +; +PROGRAM_INC equ 1 + +IFNDEF P_STD_INC + INCLUDE ..\inc\P_STD.INC +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF + +; Constants for progexec +PROGEXEC_SIGNAL equ (001h) +PROGEXEC_NOTIFY equ (002h) +H_COMMAND_TRANSLATE_FILE equ ('T') +H_COMMAND_RUN_FILE equ ('R') + +; Constants for progtran +PT_PROGTRAN_LINE equ (010h) +PT_PROGTRAN_DEATH equ (011h) + +; Types for progtran +PROGTRAN_STATUS struc +PROGTRAN_STATUSStat dw ? +PROGTRAN_STATUSMode dw ? +PROGTRAN_STATUSLine dw ? +PROGTRAN_STATUSOffset dw ? +PROGTRAN_STATUS ends +; +PROGTRAN_SOURCE struc +PROGTRAN_SOURCEPid dw ? +PROGTRAN_SOURCEBuffer_offset dw ? +PROGTRAN_SOURCEStatus_offset dw ? +PROGTRAN_SOURCE ends +; +PROGEXEC_RESBUF struc +PROGEXEC_RESBUFError dw ? +PROGEXEC_RESBUFLine dw ? +PROGEXEC_RESBUFOffset dw ? +PROGEXEC_RESBUFErr db (1) * 40 dup (?) +PROGEXEC_RESBUFSrc db (1) * P_FNAMESIZE dup (?) +PROGEXEC_RESBUF ends +PROGEXEC_PAR struc +PROGEXEC_PARFlags dw ? +PROGEXEC_PARPid dw ? +PROGEXEC_PARResult_offset dw ? +PROGEXEC_PAR ends diff --git a/code/SIBOSDK/include/program.ing b/code/SIBOSDK/include/program.ing new file mode 100644 index 0000000..e0972bf --- /dev/null +++ b/code/SIBOSDK/include/program.ing @@ -0,0 +1,62 @@ +; Generated by Ctran from program.cl +PROGRAM_ING equ 1 +IFNDEF P_STD_INC + INCLUDE ..\inc\P_STD.INC +ENDIF +IFNDEF P_OBJECT_INC + INCLUDE ..\inc\P_OBJECT.INC +ENDIF +IFNDEF PROGRAM_INC + INCLUDE ..\inc\PROGRAM.INC +ENDIF +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF FACTIVE_ING + INCLUDE ..\inc\FACTIVE.ING +ENDIF +IFNDEF IPC_ING + INCLUDE ..\inc\IPC.ING +ENDIF +; Class Numbers +C_PROGTRAN equ 53 +C_PROGEXEC equ 54 +C_PROGFIND equ 55 +; Method Numbers +O_PT_START equ 4 +O_PT_COMPLETE equ 6 +O_PT_GETLINE equ 5 +; Constants for progtran +PROGTRAN_PROG_TYPE_MASK equ (07fffh) +PROGTRAN_COMPATIBILITY_MODE equ (08000h) +; Property of progtran +PRS_PROGTRAN struc +ProgtranSt PROGTRAN_STATUS <> +ProgtranBuf db (1) * 256 dup (?) +PRS_PROGTRAN ends +PR_PROGTRAN struc +ProgtranRoot PRS_ROOT <> +ProgtranServer PRS_SERVER <> +ProgtranProgtran PRS_PROGTRAN <> +PR_PROGTRAN ends +; Property of progexec +PRS_PROGEXEC struc +ProgexecResult PROGEXEC_RESBUF <> +PRS_PROGEXEC ends +PR_PROGEXEC struc +ProgexecRoot PRS_ROOT <> +ProgexecActive PRS_ACTIVE <> +ProgexecProgexec PRS_PROGEXEC <> +PR_PROGEXEC ends +; Property of progfind +PRS_PROGFIND struc +ProgfindPbuf dw ? +PRS_PROGFIND ends +PR_PROGFIND struc +ProgfindRoot PRS_ROOT <> +ProgfindLocs PRS_LOCS <> +ProgfindProgfind PRS_PROGFIND <> +PR_PROGFIND ends diff --git a/code/SIBOSDK/include/prvpdr.g b/code/SIBOSDK/include/prvpdr.g new file mode 100644 index 0000000..1a9d814 --- /dev/null +++ b/code/SIBOSDK/include/prvpdr.g @@ -0,0 +1,79 @@ +/* Generated by Ctran from prvpdr.cat */ +#define PRVPDR_G +#ifndef P_STD_H +#include +#endif +#ifndef P_OBJECT_H +#include +#endif +#ifndef P_FILE_H +#include +#endif +#ifndef P_GRAF_H +#include +#endif +#ifndef OLIB_G +#include +#endif +#ifndef PRINTER_G +#include +#endif +#ifndef PRDRV_G +#include +#endif +/* Class Numbers */ +#define C_PRVPDR 10 +/* Method Numbers */ +/* Types for prvpdr */ +typedef struct +{ +int Id; +int SegHandle; +UPOINT Size; +unsigned short int ByteWidth; +unsigned short int BitWidth; +} PRV_BITMAP; +typedef struct +{ +unsigned short int typeface; +unsigned short int height; +unsigned short int style; +} FONT_DESC; +typedef struct +{ +unsigned char Type; +unsigned char Length; +} BMP_RASTER_TL; +typedef struct +{ +BMP_RASTER_TL tl; +unsigned char Data[2]; +} BMP_RASTER_ROW_REC; +/* Property of prvpdr */ +typedef struct { +unsigned char *pChWidths; +unsigned short int SpaceWidth; +unsigned short int FontY; +unsigned short int TwipsRound; +unsigned short int PageHeight; +UPOINT Scale; +UPOINT Round; +UPOINT Pos; +void *hPrvDone; +short int mPrvDone; +PRV_BITMAP Bmp; +int SegHandle; +long int SegPos; +int SegHeight; +int SegSize; +PR_ROOT *pArray; +unsigned char *pBitRow; +unsigned char *pLastRow; +BMP_RASTER_ROW_REC *pRowRec; +} PRS_PRVPDR; +typedef struct pr_prvpdr +{ +PRS_ROOT root; +PRS_PDR pdr; +PRS_PRVPDR prvpdr; +} PR_PRVPDR; diff --git a/code/SIBOSDK/include/prvpdr.ing b/code/SIBOSDK/include/prvpdr.ing new file mode 100644 index 0000000..82f76ea --- /dev/null +++ b/code/SIBOSDK/include/prvpdr.ing @@ -0,0 +1,74 @@ +; Generated by Ctran from prvpdr.cl +PRVPDR_ING equ 1 +IFNDEF P_STD_INC + INCLUDE ..\inc\P_STD.INC +ENDIF +IFNDEF P_OBJECT_INC + INCLUDE ..\inc\P_OBJECT.INC +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +IFNDEF P_GRAF_INC + INCLUDE ..\inc\P_GRAF.INC +ENDIF +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF PRINTER_ING + INCLUDE ..\inc\PRINTER.ING +ENDIF +IFNDEF PRDRV_ING + INCLUDE ..\inc\PRDRV.ING +ENDIF +; Class Numbers +C_PRVPDR equ 10 +; Method Numbers +; Types for prvpdr +PRV_BITMAP struc +PRV_BITMAPId dw ? +PRV_BITMAPSegHandle dw ? +PRV_BITMAPSize UPOINT <> +PRV_BITMAPByteWidth dw ? +PRV_BITMAPBitWidth dw ? +PRV_BITMAP ends +FONT_DESC struc +FONT_DESCTypeface dw ? +FONT_DESCHeight dw ? +FONT_DESCStyle dw ? +FONT_DESC ends +BMP_RASTER_TL struc +BMP_RASTER_TLType db ? +BMP_RASTER_TLLength db ? +BMP_RASTER_TL ends +BMP_RASTER_ROW_REC struc +BMP_RASTER_ROW_RECTl BMP_RASTER_TL <> +BMP_RASTER_ROW_RECData db (1) * 2 dup (?) +BMP_RASTER_ROW_REC ends +; Property of prvpdr +PRS_PRVPDR struc +PrvpdrPChWidths dw ? +PrvpdrSpaceWidth dw ? +PrvpdrFontY dw ? +PrvpdrTwipsRound dw ? +PrvpdrPageHeight dw ? +PrvpdrScale UPOINT <> +PrvpdrRound UPOINT <> +PrvpdrPos UPOINT <> +PrvpdrHPrvDone dw ? +PrvpdrMPrvDone dw ? +PrvpdrBmp PRV_BITMAP <> +PrvpdrSegHandle dw ? +PrvpdrSegPos dd ? +PrvpdrSegHeight dw ? +PrvpdrSegSize dw ? +PrvpdrPArray dw ? +PrvpdrPBitRow dw ? +PrvpdrPLastRow dw ? +PrvpdrPRowRec dw ? +PRS_PRVPDR ends +PR_PRVPDR struc +PrvpdrRoot PRS_ROOT <> +PrvpdrPdr PRS_PDR <> +PrvpdrPrvpdr PRS_PRVPDR <> +PR_PRVPDR ends diff --git a/code/SIBOSDK/include/pulldown.g b/code/SIBOSDK/include/pulldown.g new file mode 100644 index 0000000..ec87d8b --- /dev/null +++ b/code/SIBOSDK/include/pulldown.g @@ -0,0 +1,21 @@ +/* Generated by Ctran from pulldown.cl */ +#define PULLDOWN_G +#ifndef LISTBOX_G +#include +#endif +/* Class Numbers */ +#define C_PULLDOWN 8 +/* Method Numbers */ +/* Types for pulldown */ +typedef struct +{ +unsigned char com_id; +char mn_txt[1]; +} MENU_ITEM; +/* Property of pulldown */ +typedef struct pr_pulldown +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LISTBOX listbox; +} PR_PULLDOWN; diff --git a/code/SIBOSDK/include/pulldown.ing b/code/SIBOSDK/include/pulldown.ing new file mode 100644 index 0000000..a958d56 --- /dev/null +++ b/code/SIBOSDK/include/pulldown.ing @@ -0,0 +1,19 @@ +; Generated by Ctran from pulldown.cl +PULLDOWN_ING equ 1 +IFNDEF LISTBOX_ING + INCLUDE ..\inc\LISTBOX.ING +ENDIF +; Class Numbers +C_PULLDOWN equ 8 +; Method Numbers +; Types for pulldown +MENU_ITEM struc +MENU_ITEMCom_id db ? +MENU_ITEMMn_txt db (1) * 1 dup (?) +MENU_ITEM ends +; Property of pulldown +PR_PULLDOWN struc +PulldownRoot PRS_ROOT <> +PulldownWin PRS_WIN <> +PulldownListbox PRS_LISTBOX <> +PR_PULLDOWN ends diff --git a/code/SIBOSDK/include/rgedit.g b/code/SIBOSDK/include/rgedit.g new file mode 100644 index 0000000..86d3358 --- /dev/null +++ b/code/SIBOSDK/include/rgedit.g @@ -0,0 +1,42 @@ +/* Generated by Ctran from rgedit.cl */ +#define RGEDIT_G +#ifndef LODGER_G +#include +#endif +#ifndef MFNE_G +#include +#endif +/* Class Numbers */ +#define C_RGEDIT 32 +/* Method Numbers */ +/* Constants for rgedit */ +#define SE_RGEDIT_LOW 0x01 +#define SE_RGEDIT_VALUE_1 0x02 +#define SE_RGEDIT_VALUE_2 0x04 +#define SE_RGEDIT_HIGH 0x08 +#define IX_RGEDIT_LOW 0 +#define IX_RGEDIT_VALUE_1 1 +#define IX_RGEDIT_VALUE_2 2 +#define IX_RGEDIT_HIGH 3 +/* Types for rgedit */ +typedef struct +{ +unsigned short int value[4]; +} IN_RGEDIT; +typedef struct +{ +unsigned short int value[4]; +unsigned short int flags; +} SE_RGEDIT; +/* Property of rgedit */ +typedef struct { +IN_RGEDIT in; +} PRS_RGEDIT; +typedef struct pr_rgedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_MFNE mfne; +PRS_RGEDIT rgedit; +} PR_RGEDIT; diff --git a/code/SIBOSDK/include/rgedit.ing b/code/SIBOSDK/include/rgedit.ing new file mode 100644 index 0000000..107ee99 --- /dev/null +++ b/code/SIBOSDK/include/rgedit.ing @@ -0,0 +1,39 @@ +; Generated by Ctran from rgedit.cl +RGEDIT_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF MFNE_ING + INCLUDE ..\inc\MFNE.ING +ENDIF +; Class Numbers +C_RGEDIT equ 32 +; Method Numbers +; Constants for rgedit +SE_RGEDIT_LOW equ (001h) +SE_RGEDIT_VALUE_1 equ (002h) +SE_RGEDIT_VALUE_2 equ (004h) +SE_RGEDIT_HIGH equ (008h) +IX_RGEDIT_LOW equ (0) +IX_RGEDIT_VALUE_1 equ (1) +IX_RGEDIT_VALUE_2 equ (2) +IX_RGEDIT_HIGH equ (3) +; Types for rgedit +IN_RGEDIT struc +IN_RGEDITValue db (2) * 4 dup (?) +IN_RGEDIT ends +SE_RGEDIT struc +SE_RGEDITValue db (2) * 4 dup (?) +SE_RGEDITFlags dw ? +SE_RGEDIT ends +; Property of rgedit +PRS_RGEDIT struc +RgeditIn IN_RGEDIT <> +PRS_RGEDIT ends +PR_RGEDIT struc +RgeditRoot PRS_ROOT <> +RgeditWin PRS_WIN <> +RgeditLodger PRS_LODGER <> +RgeditMfne PRS_MFNE <> +RgeditRgedit PRS_RGEDIT <> +PR_RGEDIT ends diff --git a/code/SIBOSDK/include/rscfile.xg b/code/SIBOSDK/include/rscfile.xg new file mode 100644 index 0000000..4d587ce --- /dev/null +++ b/code/SIBOSDK/include/rscfile.xg @@ -0,0 +1,11 @@ +/* HEADER - RSCFILE.XG +Copyright (C) Psion PLC 1992 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.10F 31/05/92 DWW First release +*/ + +#define C_RSCFILE 12 +#define O_RS_READ_BUF 3 +#define O_RS_READ 2 +#define O_RS_INIT 1 diff --git a/code/SIBOSDK/include/rtcheck.h b/code/SIBOSDK/include/rtcheck.h new file mode 100644 index 0000000..ba7d711 --- /dev/null +++ b/code/SIBOSDK/include/rtcheck.h @@ -0,0 +1,42 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* rtcheck.h - run time check error handler interface. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _RTCHECK_INC_ +#define _RTCHECK_INC_ + +/* Values for code parameter */ +#define _CNS_STACK 1 /* Stack overflow */ +#define _CNS_NILPTR 2 /* Nil Ptr dereference */ +#define _CNS_INDEX 3 /* Index out of range */ +#define _CNS_OVERFLOW 4 /* Integer overflow */ +#define _CNS_RANGE 5 /* Integer out of range */ +#define _CNS_RETURN 6 /* No return in function */ +#define _CNS_CASE 7 /* No matching case */ +#define _CNS_DIVZERO 8 /* Long integer divide by zero */ +#define _CNS_PVC 10 /* Pure virtual function called */ + +/* return values for handler */ +#define _CNS_CONTINUE 1 +#define _CNS_TERMINATE 0 + +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_param=>(), reg_saved=>(ax,bx,cx,dx,ds,si,di,st1,st2)) +#pragma name(prefix=>"CoreSig@") +extern unsigned char (* CnsHandler)(unsigned code, unsigned IP, unsigned CS); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/code/SIBOSDK/include/runmemo.g b/code/SIBOSDK/include/runmemo.g new file mode 100644 index 0000000..7aca242 --- /dev/null +++ b/code/SIBOSDK/include/runmemo.g @@ -0,0 +1,60 @@ +/* Generated by Ctran from runmemo.cl */ +#define RUNMEMO_G +#ifndef HWIMMAN_G +#include +#endif +#ifndef XACTIVE_G +#include +#endif +/* Class Numbers */ +#define C_RUNMEMO 11 +#define C_IPCSTAT 12 +/* Method Numbers */ +#define O_IPCS_SET_MESSAGE 6 +#define O_IPCS_KEY 8 +#define O_IPCS_WAIT 7 +/* Types for runmemo */ +typedef struct +{ +void *self; +short int *stat; +unsigned short int appid; +unsigned short int flags; +} MEMO_ENV; +typedef struct +{ +MEMO_ENV e; +MEMO_DATA t; +} MEMO_CL; +/* Property of runmemo */ +typedef struct { +PR_LOGONA *logona; +unsigned short int mempid; +unsigned char command_byte; +unsigned char alias_info; +MEMO_CL cl; +MEMO_DATA in; +MEMO_CALLBACK cb; +unsigned short int hidflag; +unsigned short int callback; +PR_ACTIVE *active; +WS_HIDE_APP_DATA hidden; +} PRS_RUNMEMO; +typedef struct pr_runmemo +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_RUNMEMO runmemo; +} PR_RUNMEMO; +/* Property of ipcstat */ +typedef struct { +int pid; +unsigned short int len; +unsigned char message[128]; +} PRS_IPCSTAT; +typedef struct pr_ipcstat +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_IPCSTAT ipcstat; +} PR_IPCSTAT; diff --git a/code/SIBOSDK/include/runmemo.ing b/code/SIBOSDK/include/runmemo.ing new file mode 100644 index 0000000..f8ffa57 --- /dev/null +++ b/code/SIBOSDK/include/runmemo.ing @@ -0,0 +1,56 @@ +; Generated by Ctran from runmemo.cl +RUNMEMO_ING equ 1 +IFNDEF HWIMMAN_ING + INCLUDE ..\inc\HWIMMAN.ING +ENDIF +IFNDEF XACTIVE_ING + INCLUDE ..\inc\XACTIVE.ING +ENDIF +; Class Numbers +C_RUNMEMO equ 11 +C_IPCSTAT equ 12 +; Method Numbers +O_IPCS_SET_MESSAGE equ 6 +O_IPCS_KEY equ 8 +O_IPCS_WAIT equ 7 +; Types for runmemo +MEMO_ENV struc +MEMO_ENVSelf dw ? +MEMO_ENVStat dw ? +MEMO_ENVAppid dw ? +MEMO_ENVFlags dw ? +MEMO_ENV ends +MEMO_CL struc +MEMO_CLE MEMO_ENV <> +MEMO_CLT MEMO_DATA <> +MEMO_CL ends +; Property of runmemo +PRS_RUNMEMO struc +RunmemoLogona dw ? +RunmemoMempid dw ? +RunmemoCommand_byte db ? +RunmemoAlias_info db ? +RunmemoCl MEMO_CL <> +RunmemoIn MEMO_DATA <> +RunmemoCb MEMO_CALLBACK <> +RunmemoHidflag dw ? +RunmemoCallback dw ? +RunmemoActive dw ? +RunmemoHidden WS_HIDE_APP_DATA <> +PRS_RUNMEMO ends +PR_RUNMEMO struc +RunmemoRoot PRS_ROOT <> +RunmemoActive PRS_ACTIVE <> +RunmemoRunmemo PRS_RUNMEMO <> +PR_RUNMEMO ends +; Property of ipcstat +PRS_IPCSTAT struc +IpcstatPid dw ? +IpcstatLen dw ? +IpcstatMessage db (1) * 128 dup (?) +PRS_IPCSTAT ends +PR_IPCSTAT struc +IpcstatRoot PRS_ROOT <> +IpcstatActive PRS_ACTIVE <> +IpcstatIpcstat PRS_IPCSTAT <> +PR_IPCSTAT ends diff --git a/code/SIBOSDK/include/s3_.rsg b/code/SIBOSDK/include/s3_.rsg new file mode 100644 index 0000000..501d3b0 --- /dev/null +++ b/code/SIBOSDK/include/s3_.rsg @@ -0,0 +1,127 @@ +#define SYS_SPECIAL_CHARACTERS 1 +#define SYS_STRING 2 +#define SYS_DIMMED_MSG 3 +#define SYS_LOCKED_MSG 4 +#define SYS_BUSY 5 +#define SYS_SCANNING 6 +#define SYS_PRINTING_TO 7 +#define SYS_PAGE_IS 8 +#define SYS_COPIED_PROMPT 9 +#define SYS_COPYING_PROMPT 10 +#define SYS_LOADING_PROMPT 11 +#define SYS_MERGING_PROMPT 12 +#define SYS_NOTHING_TO_BRING 13 +#define SYS_NOT_FOUND 14 +#define SYS_NOTHING_TO_FIND 15 +#define SYS_COMPRESS_PROMPT 16 +#define SYS_NOT_COMPRESSIBLE 17 +#define SYS_PASSWORD_INCORRECT 18 +#define SYS_PASSWORD_NOT_CONFIRMED 19 +#define SYS_RANGE_RESET 20 +#define SYS_INVALID_NUM 21 +#define SYS_INVALID_MARGINS 22 +#define SYS_INVALID_CHAR 23 +#define SYS_OUT_OF_RANGE 24 +#define SYS_EDIT_NCHARS 25 +#define SYS_POPOUT_HELP 26 +#define SYS_HELP_STRING 27 +#define SYS_REPLACE_DISK 28 +#define SYS_NAME 29 +#define SYS_PACK 30 +#define SYS_FILELIST_DISK 31 +#define SYS_FLIST_RESET 32 +#define SYS_DEVICE_MEMORY 33 +#define SYS_PATH_IS 34 +#define SYS_CHOOSE_DIRECTORY 35 +#define SYS_CHOOSE_FILENAME 36 +#define SYS_CHOOSE_NEW_DIRECTORY 37 +#define SYS_EXISTS_OVER 38 +#define SYS_MAX 39 +#define SYS_MIN 40 +#define SYS_DEC_PLACES 41 +#define SYS_SIG_DIGITS 42 +#define SYS_EVALDLG_TITLE 43 +#define SYS_NOTHING_TO_EVAL 44 +#define SYS_TOOLONG_TO_EVAL 45 +#define SYS_XONXOFF_STRING 46 +#define SYS_HEADER_STR 47 +#define SYS_FOOTER_STR 48 +#define SYS_CENTIMETRES 49 +#define SYS_INCHES 50 +#define SYS_DEV_NOTREADY 51 +#define SYS_DEV_CORRUPT 52 +#define SYS_DEV_UNKNOWN 53 +#define SYS_DEV_INFO 54 +#define SYS_MTYPE_UNKNOWN 55 +#define SYS_MTYPE_FLOPPY 56 +#define SYS_MTYPE_HARD 57 +#define SYS_MTYPE_FLASH 58 +#define SYS_MTYPE_RAM 59 +#define SYS_MTYPE_ROM 60 +#define SYS_MTYPE_PROTECTED 61 +#define SYS_FILES_TAGGED 62 +#define SYS_NO_FILES 63 +#define SYS_NO_DISK 64 +#define SYS_UNFORMATTED 65 +#define SYS_UNRECOGNISED 66 +#define SYS_SOUND_FAIL 67 +#define SYS_BUTTON_TEXT 68 +#define SYS_AC_NO_YES 69 +#define SYS_AC_CONTINUE 70 +#define SYS_AC_ABANDON 71 +#define SYS_APPEND_ACLIST 72 +#define SYS_SMART_DIAL_ACLIST 73 +#define SYS_FREEDIAL_ACLIST 74 +#define SYS_NO_YES 75 +#define SYS_OFFON_MENU 76 +#define SYS_PRINTER_UNITS_CHLIST 77 +#define SYS_PRINTER_DEVICE_CHLIST 78 +#define SYS_BAUD_RATE_CHLIST 79 +#define SYS_DATA_BITS_CHLIST 80 +#define SYS_STOP_BITS_CHLIST 81 +#define SYS_PARITY_CHLIST 82 +#define SYS_FORMAT_CHLIST 83 +#define SYS_RAD_DEG 84 +#define SYS_PAGE_DIMENSIONS 85 +#define SYS_PAGE_SIZE 86 +#define SYS_ORIENT 87 +#define SYS_PRN_POS 88 +#define SYS_HEADFOOT_ALIGN 89 +#define SYS_PGNO_CHOICE 90 +#define SYS_ERROR_DIALOG 91 +#define SYS_QUERY_DIALOG 92 +#define SYS_PRINTING_DIALOG 93 +#define SYS_SET_PORT_DIALOG 94 +#define SYS_SET_HSHK_DIALOG 95 +#define SYS_PRINTER_CONFIG_DIALOG 96 +#define SYS_EVAL_DIALOG 97 +#define SYS_COUNTRY_SELECTOR_DIALOG 98 +#define SYS_SMART_DIAL_ITEM 99 +#define SYS_SMART_DIAL_DIALOG 100 +#define SYS_FREEDIAL_DIALOG 101 +#define SYS_FLIST_DIALOG 102 +#define SYS_PRINT_CONTROL_DL 103 +#define SYS_PAGING_CONTROL_DL 104 +#define SYS_PRINTER_MODEL 105 +#define SYS_MARGINS_DL 106 +#define SYS_HEADFOOT_DL 107 +#define SYS_PAGESIZE_DL 108 +#define SYS_FONT_DL 109 +#define SYS_TXTMESS 110 +#define SYS_HELP_INDEX_DATA 111 +#define SYS_HELP_INDEX 112 +#define SYS_HELP_ON_HELP 113 +#define SYS_HELP_DIALOG 114 +#define SYS_HELP_STATWIN 115 +#define SYS_HELP_DIALLING 116 +#define SYS_HELP_FILSELS 117 +#define SYS_HELP_EDIT 118 +#define SYS_HELP_X_HELP 119 +#define SYS_HELP_FILES 120 +#define SYS_HELP_PRINT 121 +#define SYS_TIME_BASICS 122 +#define SYS_HELP_ON_OFF 123 +#define SYS_HELP_X_INDEX 124 +#define SYS_WDR_GENERAL 125 +#define SYS_DIAL_OUT 126 +#define SYS_SKIPPING_PAGE 127 diff --git a/code/SIBOSDK/include/s3_.rsi b/code/SIBOSDK/include/s3_.rsi new file mode 100644 index 0000000..122ef7d --- /dev/null +++ b/code/SIBOSDK/include/s3_.rsi @@ -0,0 +1,127 @@ +SYS_SPECIAL_CHARACTERS equ 1 +SYS_STRING equ 2 +SYS_DIMMED_MSG equ 3 +SYS_LOCKED_MSG equ 4 +SYS_BUSY equ 5 +SYS_SCANNING equ 6 +SYS_PRINTING_TO equ 7 +SYS_PAGE_IS equ 8 +SYS_COPIED_PROMPT equ 9 +SYS_COPYING_PROMPT equ 10 +SYS_LOADING_PROMPT equ 11 +SYS_MERGING_PROMPT equ 12 +SYS_NOTHING_TO_BRING equ 13 +SYS_NOT_FOUND equ 14 +SYS_NOTHING_TO_FIND equ 15 +SYS_COMPRESS_PROMPT equ 16 +SYS_NOT_COMPRESSIBLE equ 17 +SYS_PASSWORD_INCORRECT equ 18 +SYS_PASSWORD_NOT_CONFIRMED equ 19 +SYS_RANGE_RESET equ 20 +SYS_INVALID_NUM equ 21 +SYS_INVALID_MARGINS equ 22 +SYS_INVALID_CHAR equ 23 +SYS_OUT_OF_RANGE equ 24 +SYS_EDIT_NCHARS equ 25 +SYS_POPOUT_HELP equ 26 +SYS_HELP_STRING equ 27 +SYS_REPLACE_DISK equ 28 +SYS_NAME equ 29 +SYS_PACK equ 30 +SYS_FILELIST_DISK equ 31 +SYS_FLIST_RESET equ 32 +SYS_DEVICE_MEMORY equ 33 +SYS_PATH_IS equ 34 +SYS_CHOOSE_DIRECTORY equ 35 +SYS_CHOOSE_FILENAME equ 36 +SYS_CHOOSE_NEW_DIRECTORY equ 37 +SYS_EXISTS_OVER equ 38 +SYS_MAX equ 39 +SYS_MIN equ 40 +SYS_DEC_PLACES equ 41 +SYS_SIG_DIGITS equ 42 +SYS_EVALDLG_TITLE equ 43 +SYS_NOTHING_TO_EVAL equ 44 +SYS_TOOLONG_TO_EVAL equ 45 +SYS_XONXOFF_STRING equ 46 +SYS_HEADER_STR equ 47 +SYS_FOOTER_STR equ 48 +SYS_CENTIMETRES equ 49 +SYS_INCHES equ 50 +SYS_DEV_NOTREADY equ 51 +SYS_DEV_CORRUPT equ 52 +SYS_DEV_UNKNOWN equ 53 +SYS_DEV_INFO equ 54 +SYS_MTYPE_UNKNOWN equ 55 +SYS_MTYPE_FLOPPY equ 56 +SYS_MTYPE_HARD equ 57 +SYS_MTYPE_FLASH equ 58 +SYS_MTYPE_RAM equ 59 +SYS_MTYPE_ROM equ 60 +SYS_MTYPE_PROTECTED equ 61 +SYS_FILES_TAGGED equ 62 +SYS_NO_FILES equ 63 +SYS_NO_DISK equ 64 +SYS_UNFORMATTED equ 65 +SYS_UNRECOGNISED equ 66 +SYS_SOUND_FAIL equ 67 +SYS_BUTTON_TEXT equ 68 +SYS_AC_NO_YES equ 69 +SYS_AC_CONTINUE equ 70 +SYS_AC_ABANDON equ 71 +SYS_APPEND_ACLIST equ 72 +SYS_SMART_DIAL_ACLIST equ 73 +SYS_FREEDIAL_ACLIST equ 74 +SYS_NO_YES equ 75 +SYS_OFFON_MENU equ 76 +SYS_PRINTER_UNITS_CHLIST equ 77 +SYS_PRINTER_DEVICE_CHLIST equ 78 +SYS_BAUD_RATE_CHLIST equ 79 +SYS_DATA_BITS_CHLIST equ 80 +SYS_STOP_BITS_CHLIST equ 81 +SYS_PARITY_CHLIST equ 82 +SYS_FORMAT_CHLIST equ 83 +SYS_RAD_DEG equ 84 +SYS_PAGE_DIMENSIONS equ 85 +SYS_PAGE_SIZE equ 86 +SYS_ORIENT equ 87 +SYS_PRN_POS equ 88 +SYS_HEADFOOT_ALIGN equ 89 +SYS_PGNO_CHOICE equ 90 +SYS_ERROR_DIALOG equ 91 +SYS_QUERY_DIALOG equ 92 +SYS_PRINTING_DIALOG equ 93 +SYS_SET_PORT_DIALOG equ 94 +SYS_SET_HSHK_DIALOG equ 95 +SYS_PRINTER_CONFIG_DIALOG equ 96 +SYS_EVAL_DIALOG equ 97 +SYS_COUNTRY_SELECTOR_DIALOG equ 98 +SYS_SMART_DIAL_ITEM equ 99 +SYS_SMART_DIAL_DIALOG equ 100 +SYS_FREEDIAL_DIALOG equ 101 +SYS_FLIST_DIALOG equ 102 +SYS_PRINT_CONTROL_DL equ 103 +SYS_PAGING_CONTROL_DL equ 104 +SYS_PRINTER_MODEL equ 105 +SYS_MARGINS_DL equ 106 +SYS_HEADFOOT_DL equ 107 +SYS_PAGESIZE_DL equ 108 +SYS_FONT_DL equ 109 +SYS_TXTMESS equ 110 +SYS_HELP_INDEX_DATA equ 111 +SYS_HELP_INDEX equ 112 +SYS_HELP_ON_HELP equ 113 +SYS_HELP_DIALOG equ 114 +SYS_HELP_STATWIN equ 115 +SYS_HELP_DIALLING equ 116 +SYS_HELP_FILSELS equ 117 +SYS_HELP_EDIT equ 118 +SYS_HELP_X_HELP equ 119 +SYS_HELP_FILES equ 120 +SYS_HELP_PRINT equ 121 +SYS_TIME_BASICS equ 122 +SYS_HELP_ON_OFF equ 123 +SYS_HELP_X_INDEX equ 124 +SYS_WDR_GENERAL equ 125 +SYS_DIAL_OUT equ 126 +SYS_SKIPPING_PAGE equ 127 diff --git a/code/SIBOSDK/include/sa_.rsg b/code/SIBOSDK/include/sa_.rsg new file mode 100644 index 0000000..d705dc2 --- /dev/null +++ b/code/SIBOSDK/include/sa_.rsg @@ -0,0 +1,179 @@ +#define SYS_SPECIAL_CHARACTERS 1 +#define SYS_STRING 2 +#define SYS_DIMMED_MSG 3 +#define SYS_LOCKED_MSG 4 +#define SYS_BUSY 5 +#define SYS_SCANNING 6 +#define SYS_PRINTING_TO 7 +#define SYS_PAGE_IS 8 +#define SYS_COPIED_PROMPT 9 +#define SYS_COPYING_PROMPT 10 +#define SYS_LOADING_PROMPT 11 +#define SYS_MERGING_PROMPT 12 +#define SYS_NOTHING_TO_BRING 13 +#define SYS_NOT_FOUND 14 +#define SYS_NOTHING_TO_FIND 15 +#define SYS_COMPRESS_PROMPT 16 +#define SYS_NOT_COMPRESSIBLE 17 +#define SYS_PASSWORD_INCORRECT 18 +#define SYS_PASSWORD_NOT_CONFIRMED 19 +#define SYS_RANGE_RESET 20 +#define SYS_INVALID_NUM 21 +#define SYS_INVALID_MARGINS 22 +#define SYS_INVALID_CHAR 23 +#define SYS_OUT_OF_RANGE 24 +#define SYS_EDIT_NCHARS 25 +#define SYS_POPOUT_HELP 26 +#define SYS_HELP_STRING 27 +#define SYS_REPLACE_DISK 28 +#define SYS_NAME 29 +#define SYS_PACK 30 +#define SYS_FILELIST_DISK 31 +#define SYS_FLIST_RESET 32 +#define SYS_DEVICE_MEMORY 33 +#define SYS_PATH_IS 34 +#define SYS_CHOOSE_DIRECTORY 35 +#define SYS_CHOOSE_FILENAME 36 +#define SYS_CHOOSE_NEW_DIRECTORY 37 +#define SYS_EXISTS_OVER 38 +#define SYS_MAX 39 +#define SYS_MIN 40 +#define SYS_DEC_PLACES 41 +#define SYS_SIG_DIGITS 42 +#define SYS_EVALDLG_TITLE 43 +#define SYS_NOTHING_TO_EVAL 44 +#define SYS_TOOLONG_TO_EVAL 45 +#define SYS_XONXOFF_STRING 46 +#define SYS_HEADER_STR 47 +#define SYS_FOOTER_STR 48 +#define SYS_CENTIMETRES 49 +#define SYS_INCHES 50 +#define SYS_DEV_NOTREADY 51 +#define SYS_DEV_CORRUPT 52 +#define SYS_DEV_UNKNOWN 53 +#define SYS_DEV_INFO 54 +#define SYS_MTYPE_UNKNOWN 55 +#define SYS_MTYPE_FLOPPY 56 +#define SYS_MTYPE_HARD 57 +#define SYS_MTYPE_FLASH 58 +#define SYS_MTYPE_RAM 59 +#define SYS_MTYPE_ROM 60 +#define SYS_MTYPE_PROTECTED 61 +#define SYS_FILES_TAGGED 62 +#define SYS_NO_FILES 63 +#define SYS_NO_DISK 64 +#define SYS_UNFORMATTED 65 +#define SYS_UNRECOGNISED 66 +#define SYS_SOUND_FAIL 67 +#define SYS_BUTTON_TEXT 68 +#define SYS_AC_NO_YES 69 +#define SYS_AC_CONTINUE 70 +#define SYS_AC_ABANDON 71 +#define SYS_APPEND_ACLIST 72 +#define SYS_SMART_DIAL_ACLIST 73 +#define SYS_FREEDIAL_ACLIST 74 +#define SYS_NO_YES 75 +#define SYS_OFFON_MENU 76 +#define SYS_PRINTER_UNITS_CHLIST 77 +#define SYS_PRINTER_DEVICE_CHLIST 78 +#define SYS_BAUD_RATE_CHLIST 79 +#define SYS_DATA_BITS_CHLIST 80 +#define SYS_STOP_BITS_CHLIST 81 +#define SYS_PARITY_CHLIST 82 +#define SYS_FORMAT_CHLIST 83 +#define SYS_RAD_DEG 84 +#define SYS_PAGE_DIMENSIONS 85 +#define SYS_PAGE_SIZE 86 +#define SYS_ORIENT 87 +#define SYS_PRN_POS 88 +#define SYS_HEADFOOT_ALIGN 89 +#define SYS_PGNO_CHOICE 90 +#define SYS_ERROR_DIALOG 91 +#define SYS_QUERY_DIALOG 92 +#define SYS_PRINTING_DIALOG 93 +#define SYS_SET_PORT_DIALOG 94 +#define SYS_SET_HSHK_DIALOG 95 +#define SYS_PRINTER_CONFIG_DIALOG 96 +#define SYS_EVAL_DIALOG 97 +#define SYS_COUNTRY_SELECTOR_DIALOG 98 +#define SYS_SMART_DIAL_ITEM 99 +#define SYS_SMART_DIAL_DIALOG 100 +#define SYS_FREEDIAL_DIALOG 101 +#define SYS_FLIST_DIALOG 102 +#define SYS_PRINT_CONTROL_DL 103 +#define SYS_PAGING_CONTROL_DL 104 +#define SYS_PRINTER_MODEL 105 +#define SYS_MARGINS_DL 106 +#define SYS_HEADFOOT_DL 107 +#define SYS_PAGESIZE_DL 108 +#define SYS_FONT_DL 109 +#define SYS_TXTMESS 110 +#define SYS_HELP_INDEX_DATA 111 +#define SYS_HELP_INDEX 112 +#define SYS_HELP_ON_HELP 113 +#define SYS_HELP_DIALOG 114 +#define SYS_HELP_STATWIN 115 +#define SYS_HELP_DIALLING 116 +#define SYS_HELP_FILSELS 117 +#define SYS_HELP_EDIT 118 +#define SYS_HELP_X_HELP 119 +#define SYS_HELP_FILES 120 +#define SYS_HELP_PRINT 121 +#define SYS_TIME_BASICS 122 +#define SYS_HELP_ON_OFF 123 +#define SYS_HELP_X_INDEX 124 +#define SYS_WDR_GENERAL 125 +#define SYS_DIAL_OUT 126 +#define SYS_SKIPPING_PAGE 127 +#define SYS_DEBUGGING_NUM_CELLS 128 +#define SYS_CALENDAR 129 +#define SYS_PAGE 130 +#define SYS_PAGES 131 +#define SYS_PREVIEW_BUSY 132 +#define SYS_DISPLAY_MARGINS 133 +#define SYS_HIDE_MARGINS 134 +#define SYS_OPENING_PROMPT 135 +#define SYS_PRINT_PREVIEW 136 +#define SYS_PREVIEW_MARGINS_CHLIST 137 +#define SYS_PREVIEW_OPTIONS_CHLIST 138 +#define SYS_PREVIEW_OPTIONS_DIALOG 139 +#define SYS_PREVIEW_JUMP_DIALOG 140 +#define SYS_PREVIEW_ACC 141 +#define SYS_PREVIEW_MENUBAR 142 +#define SYS_PREVIEW_MENU 143 +#define SYS_PRINTER_DEVICES 144 +#define SYS_PRINT_CONTROL_DEVICE 145 +#define SYS_PRINT_PREVIEW_SETTINGS 146 +#define SYS_PREVIEW_SETTINGS_DL 147 +#define SYS_STANDARD_SOUNDS 148 +#define SYS_ALARM_STANDARD_NAME 149 +#define SYS_SILENT_ALARM 150 +#define SYS_SOUND_DISABLED 151 +#define SYS_WORD_ROM 152 +#define SYS_RESTART_FROM_SYS 153 +#define SRT_FILE_CREATED 154 +#define SRT_FILE_OPENED 155 +#define SRT_FILE_SAVED 156 +#define SRT_FILE_COMPRESSED 157 +#define SRT_FILE_MERGED 158 +#define SYS_SAVING_PROMPT 159 +#define SYS_RELOADING_PROMPT 160 +#define SYS_CONVERTING_PROMPT 161 +#define SYS_NOT_CHANGED 162 +#define SYS_CONFIRM_CONTINUE 163 +#define SYS_CONFIRM_CHANGE_LOSS 164 +#define SYS_LOSING_CHANGES 165 +#define SYS_NOTHING_TO_PRINT 166 +#define SYS_NOTHING_TO_INSERT 167 +#define SYS_NOTHING_TO_COPY 168 +#define SYS_REVERT_TO_SAVED 169 +#define SYS_SHIFT_KEY_NAME 170 +#define SRT_SPACE_ONLY 171 +#define SYS_CHANGE_PASSWORD 172 +#define SYS_SET_PASSWORD_DL 173 +#define SYS_GET_PASSWORD_DL 174 +#define SYS_HELP_EVALUATE 175 +#define SYS_HELP_MEMO 176 +#define SYS_HELP_IN_USE 177 +#define SYS_HELP_NO_SYS_MEM 178 +#define SYS_HELP_CALENDAR 179 diff --git a/code/SIBOSDK/include/sa_.rsi b/code/SIBOSDK/include/sa_.rsi new file mode 100644 index 0000000..dd04974 --- /dev/null +++ b/code/SIBOSDK/include/sa_.rsi @@ -0,0 +1,179 @@ +SYS_SPECIAL_CHARACTERS equ 1 +SYS_STRING equ 2 +SYS_DIMMED_MSG equ 3 +SYS_LOCKED_MSG equ 4 +SYS_BUSY equ 5 +SYS_SCANNING equ 6 +SYS_PRINTING_TO equ 7 +SYS_PAGE_IS equ 8 +SYS_COPIED_PROMPT equ 9 +SYS_COPYING_PROMPT equ 10 +SYS_LOADING_PROMPT equ 11 +SYS_MERGING_PROMPT equ 12 +SYS_NOTHING_TO_BRING equ 13 +SYS_NOT_FOUND equ 14 +SYS_NOTHING_TO_FIND equ 15 +SYS_COMPRESS_PROMPT equ 16 +SYS_NOT_COMPRESSIBLE equ 17 +SYS_PASSWORD_INCORRECT equ 18 +SYS_PASSWORD_NOT_CONFIRMED equ 19 +SYS_RANGE_RESET equ 20 +SYS_INVALID_NUM equ 21 +SYS_INVALID_MARGINS equ 22 +SYS_INVALID_CHAR equ 23 +SYS_OUT_OF_RANGE equ 24 +SYS_EDIT_NCHARS equ 25 +SYS_POPOUT_HELP equ 26 +SYS_HELP_STRING equ 27 +SYS_REPLACE_DISK equ 28 +SYS_NAME equ 29 +SYS_PACK equ 30 +SYS_FILELIST_DISK equ 31 +SYS_FLIST_RESET equ 32 +SYS_DEVICE_MEMORY equ 33 +SYS_PATH_IS equ 34 +SYS_CHOOSE_DIRECTORY equ 35 +SYS_CHOOSE_FILENAME equ 36 +SYS_CHOOSE_NEW_DIRECTORY equ 37 +SYS_EXISTS_OVER equ 38 +SYS_MAX equ 39 +SYS_MIN equ 40 +SYS_DEC_PLACES equ 41 +SYS_SIG_DIGITS equ 42 +SYS_EVALDLG_TITLE equ 43 +SYS_NOTHING_TO_EVAL equ 44 +SYS_TOOLONG_TO_EVAL equ 45 +SYS_XONXOFF_STRING equ 46 +SYS_HEADER_STR equ 47 +SYS_FOOTER_STR equ 48 +SYS_CENTIMETRES equ 49 +SYS_INCHES equ 50 +SYS_DEV_NOTREADY equ 51 +SYS_DEV_CORRUPT equ 52 +SYS_DEV_UNKNOWN equ 53 +SYS_DEV_INFO equ 54 +SYS_MTYPE_UNKNOWN equ 55 +SYS_MTYPE_FLOPPY equ 56 +SYS_MTYPE_HARD equ 57 +SYS_MTYPE_FLASH equ 58 +SYS_MTYPE_RAM equ 59 +SYS_MTYPE_ROM equ 60 +SYS_MTYPE_PROTECTED equ 61 +SYS_FILES_TAGGED equ 62 +SYS_NO_FILES equ 63 +SYS_NO_DISK equ 64 +SYS_UNFORMATTED equ 65 +SYS_UNRECOGNISED equ 66 +SYS_SOUND_FAIL equ 67 +SYS_BUTTON_TEXT equ 68 +SYS_AC_NO_YES equ 69 +SYS_AC_CONTINUE equ 70 +SYS_AC_ABANDON equ 71 +SYS_APPEND_ACLIST equ 72 +SYS_SMART_DIAL_ACLIST equ 73 +SYS_FREEDIAL_ACLIST equ 74 +SYS_NO_YES equ 75 +SYS_OFFON_MENU equ 76 +SYS_PRINTER_UNITS_CHLIST equ 77 +SYS_PRINTER_DEVICE_CHLIST equ 78 +SYS_BAUD_RATE_CHLIST equ 79 +SYS_DATA_BITS_CHLIST equ 80 +SYS_STOP_BITS_CHLIST equ 81 +SYS_PARITY_CHLIST equ 82 +SYS_FORMAT_CHLIST equ 83 +SYS_RAD_DEG equ 84 +SYS_PAGE_DIMENSIONS equ 85 +SYS_PAGE_SIZE equ 86 +SYS_ORIENT equ 87 +SYS_PRN_POS equ 88 +SYS_HEADFOOT_ALIGN equ 89 +SYS_PGNO_CHOICE equ 90 +SYS_ERROR_DIALOG equ 91 +SYS_QUERY_DIALOG equ 92 +SYS_PRINTING_DIALOG equ 93 +SYS_SET_PORT_DIALOG equ 94 +SYS_SET_HSHK_DIALOG equ 95 +SYS_PRINTER_CONFIG_DIALOG equ 96 +SYS_EVAL_DIALOG equ 97 +SYS_COUNTRY_SELECTOR_DIALOG equ 98 +SYS_SMART_DIAL_ITEM equ 99 +SYS_SMART_DIAL_DIALOG equ 100 +SYS_FREEDIAL_DIALOG equ 101 +SYS_FLIST_DIALOG equ 102 +SYS_PRINT_CONTROL_DL equ 103 +SYS_PAGING_CONTROL_DL equ 104 +SYS_PRINTER_MODEL equ 105 +SYS_MARGINS_DL equ 106 +SYS_HEADFOOT_DL equ 107 +SYS_PAGESIZE_DL equ 108 +SYS_FONT_DL equ 109 +SYS_TXTMESS equ 110 +SYS_HELP_INDEX_DATA equ 111 +SYS_HELP_INDEX equ 112 +SYS_HELP_ON_HELP equ 113 +SYS_HELP_DIALOG equ 114 +SYS_HELP_STATWIN equ 115 +SYS_HELP_DIALLING equ 116 +SYS_HELP_FILSELS equ 117 +SYS_HELP_EDIT equ 118 +SYS_HELP_X_HELP equ 119 +SYS_HELP_FILES equ 120 +SYS_HELP_PRINT equ 121 +SYS_TIME_BASICS equ 122 +SYS_HELP_ON_OFF equ 123 +SYS_HELP_X_INDEX equ 124 +SYS_WDR_GENERAL equ 125 +SYS_DIAL_OUT equ 126 +SYS_SKIPPING_PAGE equ 127 +SYS_DEBUGGING_NUM_CELLS equ 128 +SYS_CALENDAR equ 129 +SYS_PAGE equ 130 +SYS_PAGES equ 131 +SYS_PREVIEW_BUSY equ 132 +SYS_DISPLAY_MARGINS equ 133 +SYS_HIDE_MARGINS equ 134 +SYS_OPENING_PROMPT equ 135 +SYS_PRINT_PREVIEW equ 136 +SYS_PREVIEW_MARGINS_CHLIST equ 137 +SYS_PREVIEW_OPTIONS_CHLIST equ 138 +SYS_PREVIEW_OPTIONS_DIALOG equ 139 +SYS_PREVIEW_JUMP_DIALOG equ 140 +SYS_PREVIEW_ACC equ 141 +SYS_PREVIEW_MENUBAR equ 142 +SYS_PREVIEW_MENU equ 143 +SYS_PRINTER_DEVICES equ 144 +SYS_PRINT_CONTROL_DEVICE equ 145 +SYS_PRINT_PREVIEW_SETTINGS equ 146 +SYS_PREVIEW_SETTINGS_DL equ 147 +SYS_STANDARD_SOUNDS equ 148 +SYS_ALARM_STANDARD_NAME equ 149 +SYS_SILENT_ALARM equ 150 +SYS_SOUND_DISABLED equ 151 +SYS_WORD_ROM equ 152 +SYS_RESTART_FROM_SYS equ 153 +SRT_FILE_CREATED equ 154 +SRT_FILE_OPENED equ 155 +SRT_FILE_SAVED equ 156 +SRT_FILE_COMPRESSED equ 157 +SRT_FILE_MERGED equ 158 +SYS_SAVING_PROMPT equ 159 +SYS_RELOADING_PROMPT equ 160 +SYS_CONVERTING_PROMPT equ 161 +SYS_NOT_CHANGED equ 162 +SYS_CONFIRM_CONTINUE equ 163 +SYS_CONFIRM_CHANGE_LOSS equ 164 +SYS_LOSING_CHANGES equ 165 +SYS_NOTHING_TO_PRINT equ 166 +SYS_NOTHING_TO_INSERT equ 167 +SYS_NOTHING_TO_COPY equ 168 +SYS_REVERT_TO_SAVED equ 169 +SYS_SHIFT_KEY_NAME equ 170 +SRT_SPACE_ONLY equ 171 +SYS_CHANGE_PASSWORD equ 172 +SYS_SET_PASSWORD_DL equ 173 +SYS_GET_PASSWORD_DL equ 174 +SYS_HELP_EVALUATE equ 175 +SYS_HELP_MEMO equ 176 +SYS_HELP_IN_USE equ 177 +SYS_HELP_NO_SYS_MEM equ 178 +SYS_HELP_CALENDAR equ 179 diff --git a/code/SIBOSDK/include/sc_.rsg b/code/SIBOSDK/include/sc_.rsg new file mode 100644 index 0000000..cab4c50 --- /dev/null +++ b/code/SIBOSDK/include/sc_.rsg @@ -0,0 +1,191 @@ +#define SYS_SPECIAL_CHARACTERS 1 +#define SYS_STRING 2 +#define SYS_DIMMED_MSG 3 +#define SYS_LOCKED_MSG 4 +#define SYS_BUSY 5 +#define SYS_SCANNING 6 +#define SYS_PRINTING_TO 7 +#define SYS_PAGE_IS 8 +#define SYS_COPIED_PROMPT 9 +#define SYS_COPYING_PROMPT 10 +#define SYS_LOADING_PROMPT 11 +#define SYS_MERGING_PROMPT 12 +#define SYS_NOTHING_TO_BRING 13 +#define SYS_NOT_FOUND 14 +#define SYS_NOTHING_TO_FIND 15 +#define SYS_COMPRESS_PROMPT 16 +#define SYS_NOT_COMPRESSIBLE 17 +#define SYS_PASSWORD_INCORRECT 18 +#define SYS_PASSWORD_NOT_CONFIRMED 19 +#define SYS_RANGE_RESET 20 +#define SYS_INVALID_NUM 21 +#define SYS_INVALID_MARGINS 22 +#define SYS_INVALID_CHAR 23 +#define SYS_OUT_OF_RANGE 24 +#define SYS_EDIT_NCHARS 25 +#define SYS_POPOUT_HELP 26 +#define SYS_HELP_STRING 27 +#define SYS_REPLACE_DISK 28 +#define SYS_NAME 29 +#define SYS_PACK 30 +#define SYS_FILELIST_DISK 31 +#define SYS_FLIST_RESET 32 +#define SYS_DEVICE_MEMORY 33 +#define SYS_PATH_IS 34 +#define SYS_CHOOSE_DIRECTORY 35 +#define SYS_CHOOSE_FILENAME 36 +#define SYS_CHOOSE_NEW_DIRECTORY 37 +#define SYS_EXISTS_OVER 38 +#define SYS_MAX 39 +#define SYS_MIN 40 +#define SYS_DEC_PLACES 41 +#define SYS_SIG_DIGITS 42 +#define SYS_EVALDLG_TITLE 43 +#define SYS_NOTHING_TO_EVAL 44 +#define SYS_TOOLONG_TO_EVAL 45 +#define SYS_XONXOFF_STRING 46 +#define SYS_HEADER_STR 47 +#define SYS_FOOTER_STR 48 +#define SYS_CENTIMETRES 49 +#define SYS_INCHES 50 +#define SYS_DEV_NOTREADY 51 +#define SYS_DEV_CORRUPT 52 +#define SYS_DEV_UNKNOWN 53 +#define SYS_DEV_INFO 54 +#define SYS_MTYPE_UNKNOWN 55 +#define SYS_MTYPE_FLOPPY 56 +#define SYS_MTYPE_HARD 57 +#define SYS_MTYPE_FLASH 58 +#define SYS_MTYPE_RAM 59 +#define SYS_MTYPE_ROM 60 +#define SYS_MTYPE_PROTECTED 61 +#define SYS_FILES_TAGGED 62 +#define SYS_NO_FILES 63 +#define SYS_NO_DISK 64 +#define SYS_UNFORMATTED 65 +#define SYS_UNRECOGNISED 66 +#define SYS_SOUND_FAIL 67 +#define SYS_BUTTON_TEXT 68 +#define SYS_AC_NO_YES 69 +#define SYS_AC_CONTINUE 70 +#define SYS_AC_ABANDON 71 +#define SYS_APPEND_ACLIST 72 +#define SYS_SMART_DIAL_ACLIST 73 +#define SYS_FREEDIAL_ACLIST 74 +#define SYS_NO_YES 75 +#define SYS_OFFON_MENU 76 +#define SYS_PRINTER_UNITS_CHLIST 77 +#define SYS_PRINTER_DEVICE_CHLIST 78 +#define SYS_BAUD_RATE_CHLIST 79 +#define SYS_DATA_BITS_CHLIST 80 +#define SYS_STOP_BITS_CHLIST 81 +#define SYS_PARITY_CHLIST 82 +#define SYS_FORMAT_CHLIST 83 +#define SYS_RAD_DEG 84 +#define SYS_PAGE_DIMENSIONS 85 +#define SYS_PAGE_SIZE 86 +#define SYS_ORIENT 87 +#define SYS_PRN_POS 88 +#define SYS_HEADFOOT_ALIGN 89 +#define SYS_PGNO_CHOICE 90 +#define SYS_ERROR_DIALOG 91 +#define SYS_QUERY_DIALOG 92 +#define SYS_PRINTING_DIALOG 93 +#define SYS_SET_PORT_DIALOG 94 +#define SYS_SET_HSHK_DIALOG 95 +#define SYS_PRINTER_CONFIG_DIALOG 96 +#define SYS_EVAL_DIALOG 97 +#define SYS_COUNTRY_SELECTOR_DIALOG 98 +#define SYS_SMART_DIAL_ITEM 99 +#define SYS_SMART_DIAL_DIALOG 100 +#define SYS_FREEDIAL_DIALOG 101 +#define SYS_FLIST_DIALOG 102 +#define SYS_PRINT_CONTROL_DL 103 +#define SYS_PAGING_CONTROL_DL 104 +#define SYS_PRINTER_MODEL 105 +#define SYS_MARGINS_DL 106 +#define SYS_HEADFOOT_DL 107 +#define SYS_PAGESIZE_DL 108 +#define SYS_FONT_DL 109 +#define SYS_TXTMESS 110 +#define SYS_HELP_INDEX_DATA 111 +#define SYS_HELP_INDEX 112 +#define SYS_HELP_ON_HELP 113 +#define SYS_HELP_DIALOG 114 +#define SYS_HELP_STATWIN 115 +#define SYS_HELP_DIALLING 116 +#define SYS_HELP_FILSELS 117 +#define SYS_HELP_EDIT 118 +#define SYS_HELP_X_HELP 119 +#define SYS_HELP_FILES 120 +#define SYS_HELP_PRINT 121 +#define SYS_TIME_BASICS 122 +#define SYS_HELP_ON_OFF 123 +#define SYS_HELP_X_INDEX 124 +#define SYS_WDR_GENERAL 125 +#define SYS_DIAL_OUT 126 +#define SYS_SKIPPING_PAGE 127 +#define SYS_DEBUGGING_NUM_CELLS 128 +#define SYS_CALENDAR 129 +#define SYS_PAGE 130 +#define SYS_PAGES 131 +#define SYS_PREVIEW_BUSY 132 +#define SYS_DISPLAY_MARGINS 133 +#define SYS_HIDE_MARGINS 134 +#define SYS_OPENING_PROMPT 135 +#define SYS_PRINT_PREVIEW 136 +#define SYS_PREVIEW_MARGINS_CHLIST 137 +#define SYS_PREVIEW_OPTIONS_CHLIST 138 +#define SYS_PREVIEW_OPTIONS_DIALOG 139 +#define SYS_PREVIEW_JUMP_DIALOG 140 +#define SYS_PREVIEW_ACC 141 +#define SYS_PREVIEW_MENUBAR 142 +#define SYS_PREVIEW_MENU 143 +#define SYS_PRINTER_DEVICES 144 +#define SYS_PRINT_CONTROL_DEVICE 145 +#define SYS_PRINT_PREVIEW_SETTINGS 146 +#define SYS_PREVIEW_SETTINGS_DL 147 +#define SYS_STANDARD_SOUNDS 148 +#define SYS_ALARM_STANDARD_NAME 149 +#define SYS_SILENT_ALARM 150 +#define SYS_SOUND_DISABLED 151 +#define SYS_WORD_ROM 152 +#define SYS_RESTART_FROM_SYS 153 +#define SRT_FILE_CREATED 154 +#define SRT_FILE_OPENED 155 +#define SRT_FILE_SAVED 156 +#define SRT_FILE_COMPRESSED 157 +#define SRT_FILE_MERGED 158 +#define SYS_SAVING_PROMPT 159 +#define SYS_RELOADING_PROMPT 160 +#define SYS_CONVERTING_PROMPT 161 +#define SYS_NOT_CHANGED 162 +#define SYS_CONFIRM_CONTINUE 163 +#define SYS_CONFIRM_CHANGE_LOSS 164 +#define SYS_LOSING_CHANGES 165 +#define SYS_NOTHING_TO_PRINT 166 +#define SYS_NOTHING_TO_INSERT 167 +#define SYS_NOTHING_TO_COPY 168 +#define SYS_REVERT_TO_SAVED 169 +#define SYS_SHIFT_KEY_NAME 170 +#define SRT_SPACE_ONLY 171 +#define SYS_CHANGE_PASSWORD 172 +#define SYS_SET_PASSWORD_DL 173 +#define SYS_GET_PASSWORD_DL 174 +#define SYS_HELP_EVALUATE 175 +#define SYS_HELP_MEMO 176 +#define SYS_HELP_IN_USE 177 +#define SYS_HELP_NO_SYS_MEM 178 +#define SYS_HELP_CALENDAR 179 +#define SYS_S3C_PRINT_CONTROL_DL 180 +#define SYS_S3C_PAGE_SETUP 181 +#define SYS_HELP_BATTERY 182 +#define SYS_VINE_FILE_INFO_DL 183 +#define SYS_RUSSIAN_KEYS 184 +#define SYS_HELP_INFRARED 185 +#define SYS_HELP_APPNOTREADY 186 +#define SYS_IR_DISABLED 187 +#define SYS_IR_POWER_LEVEL 188 +#define SYS_PRINTER_IR 189 +#define SYS_BAUD_RATE_CHLIST_X 190 +#define SYS_BAUD_CONTROL_X 191 diff --git a/code/SIBOSDK/include/sc_.rsi b/code/SIBOSDK/include/sc_.rsi new file mode 100644 index 0000000..20c7b76 --- /dev/null +++ b/code/SIBOSDK/include/sc_.rsi @@ -0,0 +1,191 @@ +SYS_SPECIAL_CHARACTERS equ 1 +SYS_STRING equ 2 +SYS_DIMMED_MSG equ 3 +SYS_LOCKED_MSG equ 4 +SYS_BUSY equ 5 +SYS_SCANNING equ 6 +SYS_PRINTING_TO equ 7 +SYS_PAGE_IS equ 8 +SYS_COPIED_PROMPT equ 9 +SYS_COPYING_PROMPT equ 10 +SYS_LOADING_PROMPT equ 11 +SYS_MERGING_PROMPT equ 12 +SYS_NOTHING_TO_BRING equ 13 +SYS_NOT_FOUND equ 14 +SYS_NOTHING_TO_FIND equ 15 +SYS_COMPRESS_PROMPT equ 16 +SYS_NOT_COMPRESSIBLE equ 17 +SYS_PASSWORD_INCORRECT equ 18 +SYS_PASSWORD_NOT_CONFIRMED equ 19 +SYS_RANGE_RESET equ 20 +SYS_INVALID_NUM equ 21 +SYS_INVALID_MARGINS equ 22 +SYS_INVALID_CHAR equ 23 +SYS_OUT_OF_RANGE equ 24 +SYS_EDIT_NCHARS equ 25 +SYS_POPOUT_HELP equ 26 +SYS_HELP_STRING equ 27 +SYS_REPLACE_DISK equ 28 +SYS_NAME equ 29 +SYS_PACK equ 30 +SYS_FILELIST_DISK equ 31 +SYS_FLIST_RESET equ 32 +SYS_DEVICE_MEMORY equ 33 +SYS_PATH_IS equ 34 +SYS_CHOOSE_DIRECTORY equ 35 +SYS_CHOOSE_FILENAME equ 36 +SYS_CHOOSE_NEW_DIRECTORY equ 37 +SYS_EXISTS_OVER equ 38 +SYS_MAX equ 39 +SYS_MIN equ 40 +SYS_DEC_PLACES equ 41 +SYS_SIG_DIGITS equ 42 +SYS_EVALDLG_TITLE equ 43 +SYS_NOTHING_TO_EVAL equ 44 +SYS_TOOLONG_TO_EVAL equ 45 +SYS_XONXOFF_STRING equ 46 +SYS_HEADER_STR equ 47 +SYS_FOOTER_STR equ 48 +SYS_CENTIMETRES equ 49 +SYS_INCHES equ 50 +SYS_DEV_NOTREADY equ 51 +SYS_DEV_CORRUPT equ 52 +SYS_DEV_UNKNOWN equ 53 +SYS_DEV_INFO equ 54 +SYS_MTYPE_UNKNOWN equ 55 +SYS_MTYPE_FLOPPY equ 56 +SYS_MTYPE_HARD equ 57 +SYS_MTYPE_FLASH equ 58 +SYS_MTYPE_RAM equ 59 +SYS_MTYPE_ROM equ 60 +SYS_MTYPE_PROTECTED equ 61 +SYS_FILES_TAGGED equ 62 +SYS_NO_FILES equ 63 +SYS_NO_DISK equ 64 +SYS_UNFORMATTED equ 65 +SYS_UNRECOGNISED equ 66 +SYS_SOUND_FAIL equ 67 +SYS_BUTTON_TEXT equ 68 +SYS_AC_NO_YES equ 69 +SYS_AC_CONTINUE equ 70 +SYS_AC_ABANDON equ 71 +SYS_APPEND_ACLIST equ 72 +SYS_SMART_DIAL_ACLIST equ 73 +SYS_FREEDIAL_ACLIST equ 74 +SYS_NO_YES equ 75 +SYS_OFFON_MENU equ 76 +SYS_PRINTER_UNITS_CHLIST equ 77 +SYS_PRINTER_DEVICE_CHLIST equ 78 +SYS_BAUD_RATE_CHLIST equ 79 +SYS_DATA_BITS_CHLIST equ 80 +SYS_STOP_BITS_CHLIST equ 81 +SYS_PARITY_CHLIST equ 82 +SYS_FORMAT_CHLIST equ 83 +SYS_RAD_DEG equ 84 +SYS_PAGE_DIMENSIONS equ 85 +SYS_PAGE_SIZE equ 86 +SYS_ORIENT equ 87 +SYS_PRN_POS equ 88 +SYS_HEADFOOT_ALIGN equ 89 +SYS_PGNO_CHOICE equ 90 +SYS_ERROR_DIALOG equ 91 +SYS_QUERY_DIALOG equ 92 +SYS_PRINTING_DIALOG equ 93 +SYS_SET_PORT_DIALOG equ 94 +SYS_SET_HSHK_DIALOG equ 95 +SYS_PRINTER_CONFIG_DIALOG equ 96 +SYS_EVAL_DIALOG equ 97 +SYS_COUNTRY_SELECTOR_DIALOG equ 98 +SYS_SMART_DIAL_ITEM equ 99 +SYS_SMART_DIAL_DIALOG equ 100 +SYS_FREEDIAL_DIALOG equ 101 +SYS_FLIST_DIALOG equ 102 +SYS_PRINT_CONTROL_DL equ 103 +SYS_PAGING_CONTROL_DL equ 104 +SYS_PRINTER_MODEL equ 105 +SYS_MARGINS_DL equ 106 +SYS_HEADFOOT_DL equ 107 +SYS_PAGESIZE_DL equ 108 +SYS_FONT_DL equ 109 +SYS_TXTMESS equ 110 +SYS_HELP_INDEX_DATA equ 111 +SYS_HELP_INDEX equ 112 +SYS_HELP_ON_HELP equ 113 +SYS_HELP_DIALOG equ 114 +SYS_HELP_STATWIN equ 115 +SYS_HELP_DIALLING equ 116 +SYS_HELP_FILSELS equ 117 +SYS_HELP_EDIT equ 118 +SYS_HELP_X_HELP equ 119 +SYS_HELP_FILES equ 120 +SYS_HELP_PRINT equ 121 +SYS_TIME_BASICS equ 122 +SYS_HELP_ON_OFF equ 123 +SYS_HELP_X_INDEX equ 124 +SYS_WDR_GENERAL equ 125 +SYS_DIAL_OUT equ 126 +SYS_SKIPPING_PAGE equ 127 +SYS_DEBUGGING_NUM_CELLS equ 128 +SYS_CALENDAR equ 129 +SYS_PAGE equ 130 +SYS_PAGES equ 131 +SYS_PREVIEW_BUSY equ 132 +SYS_DISPLAY_MARGINS equ 133 +SYS_HIDE_MARGINS equ 134 +SYS_OPENING_PROMPT equ 135 +SYS_PRINT_PREVIEW equ 136 +SYS_PREVIEW_MARGINS_CHLIST equ 137 +SYS_PREVIEW_OPTIONS_CHLIST equ 138 +SYS_PREVIEW_OPTIONS_DIALOG equ 139 +SYS_PREVIEW_JUMP_DIALOG equ 140 +SYS_PREVIEW_ACC equ 141 +SYS_PREVIEW_MENUBAR equ 142 +SYS_PREVIEW_MENU equ 143 +SYS_PRINTER_DEVICES equ 144 +SYS_PRINT_CONTROL_DEVICE equ 145 +SYS_PRINT_PREVIEW_SETTINGS equ 146 +SYS_PREVIEW_SETTINGS_DL equ 147 +SYS_STANDARD_SOUNDS equ 148 +SYS_ALARM_STANDARD_NAME equ 149 +SYS_SILENT_ALARM equ 150 +SYS_SOUND_DISABLED equ 151 +SYS_WORD_ROM equ 152 +SYS_RESTART_FROM_SYS equ 153 +SRT_FILE_CREATED equ 154 +SRT_FILE_OPENED equ 155 +SRT_FILE_SAVED equ 156 +SRT_FILE_COMPRESSED equ 157 +SRT_FILE_MERGED equ 158 +SYS_SAVING_PROMPT equ 159 +SYS_RELOADING_PROMPT equ 160 +SYS_CONVERTING_PROMPT equ 161 +SYS_NOT_CHANGED equ 162 +SYS_CONFIRM_CONTINUE equ 163 +SYS_CONFIRM_CHANGE_LOSS equ 164 +SYS_LOSING_CHANGES equ 165 +SYS_NOTHING_TO_PRINT equ 166 +SYS_NOTHING_TO_INSERT equ 167 +SYS_NOTHING_TO_COPY equ 168 +SYS_REVERT_TO_SAVED equ 169 +SYS_SHIFT_KEY_NAME equ 170 +SRT_SPACE_ONLY equ 171 +SYS_CHANGE_PASSWORD equ 172 +SYS_SET_PASSWORD_DL equ 173 +SYS_GET_PASSWORD_DL equ 174 +SYS_HELP_EVALUATE equ 175 +SYS_HELP_MEMO equ 176 +SYS_HELP_IN_USE equ 177 +SYS_HELP_NO_SYS_MEM equ 178 +SYS_HELP_CALENDAR equ 179 +SYS_S3C_PRINT_CONTROL_DL equ 180 +SYS_S3C_PAGE_SETUP equ 181 +SYS_HELP_BATTERY equ 182 +SYS_VINE_FILE_INFO_DL equ 183 +SYS_RUSSIAN_KEYS equ 184 +SYS_HELP_INFRARED equ 185 +SYS_HELP_APPNOTREADY equ 186 +SYS_IR_DISABLED equ 187 +SYS_IR_POWER_LEVEL equ 188 +SYS_PRINTER_IR equ 189 +SYS_BAUD_RATE_CHLIST_X equ 190 +SYS_BAUD_CONTROL_X equ 191 diff --git a/code/SIBOSDK/include/scprndlg.g b/code/SIBOSDK/include/scprndlg.g new file mode 100644 index 0000000..74dd373 --- /dev/null +++ b/code/SIBOSDK/include/scprndlg.g @@ -0,0 +1,48 @@ +/* Generated by Ctran from scprndlg.cl */ +#define SCPRNDLG_G +#ifndef DLGBOX_G +#include +#endif +#ifndef GATE_G +#include +#endif +#ifndef SCRLAY_G +#include +#endif +#ifndef FONTDLG_G +#include +#endif +#ifndef PRNTDLGS_G +#include +#endif +#ifndef P_FILE_H +#include +#endif +#ifndef P_SERIAL_H +#include +#endif +/* Class Numbers */ +#define C_SCPRNCTL 18 +#define C_SCPGSETUP 19 +/* Method Numbers */ +/* Property of scprnctl */ +typedef struct { +PVV_DISPLAY Disp; +} PRS_SCPRNCTL; +typedef struct pr_scprnctl +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_SCPRNCTL scprnctl; +} PR_SCPRNCTL; +/* Property of scpgsetup */ +typedef struct pr_scpgsetup +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_PRNCTRL prnctrl; +} PR_SCPGSETUP; diff --git a/code/SIBOSDK/include/scprndlg.ing b/code/SIBOSDK/include/scprndlg.ing new file mode 100644 index 0000000..a34e620 --- /dev/null +++ b/code/SIBOSDK/include/scprndlg.ing @@ -0,0 +1,46 @@ +; Generated by Ctran from scprndlg.cl +SCPRNDLG_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF GATE_ING + INCLUDE ..\inc\GATE.ING +ENDIF +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +IFNDEF FONTDLG_ING + INCLUDE ..\inc\FONTDLG.ING +ENDIF +IFNDEF PRNTDLGS_ING + INCLUDE ..\inc\PRNTDLGS.ING +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +IFNDEF P_SERIAL_INC + INCLUDE ..\inc\P_SERIAL.INC +ENDIF +; Class Numbers +C_SCPRNCTL equ 18 +C_SCPGSETUP equ 19 +; Method Numbers +; Property of scprnctl +PRS_SCPRNCTL struc +ScprnctlDisp PVV_DISPLAY <> +PRS_SCPRNCTL ends +PR_SCPRNCTL struc +ScprnctlRoot PRS_ROOT <> +ScprnctlWin PRS_WIN <> +ScprnctlDlgchain PRS_DLGCHAIN <> +ScprnctlDlgbox PRS_DLGBOX <> +ScprnctlScprnctl PRS_SCPRNCTL <> +PR_SCPRNCTL ends +; Property of scpgsetup +PR_SCPGSETUP struc +ScpgsetupRoot PRS_ROOT <> +ScpgsetupWin PRS_WIN <> +ScpgsetupDlgchain PRS_DLGCHAIN <> +ScpgsetupDlgbox PRS_DLGBOX <> +ScpgsetupPrnctrl PRS_PRNCTRL <> +PR_SCPGSETUP ends diff --git a/code/SIBOSDK/include/scrimg.g b/code/SIBOSDK/include/scrimg.g new file mode 100644 index 0000000..e619e56 --- /dev/null +++ b/code/SIBOSDK/include/scrimg.g @@ -0,0 +1,111 @@ +/* Generated by Ctran from scrimg.cat */ +#define SCRIMG_G +#ifndef SCRLAY_G +#include +#endif +#ifndef APPMAN_G +#include +#endif +#ifndef WLIB_H +#include +#endif +/* Class Numbers */ +#define C_WRAP 2 +#define C_SCRIMG 3 +/* Method Numbers */ +#define O_SI_SENSE 3 +#define O_SI_FWD_CHANGE 16 +#define O_SI_STYLE_CHANGED 14 +#define O_SI_DOC_RESET 12 +#define O_SI_MOVE_CURSOR 9 +#define O_SI_DELPREP 15 +#define O_SI_GET_SELECT 5 +#define O_SI_REDRAW 10 +#define O_SI_EMPHASIZE 4 +#define O_SI_SCROLL 7 +#define O_SI_PAN 6 +#define O_SI_PARA_CHANGED 13 +#define O_SI_SET 2 +#define O_SI_DOC_CHANGED 11 +#define O_SI_INIT 1 +#define O_SI_VIEW 8 +/* Property of wrap */ +typedef struct { +void *scrimg; +} PRS_WRAP; +typedef struct pr_wrap +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_WRAP wrap; +} PR_WRAP; +/* Constants for scrimg */ +#define SCRIMG_LINEDN 0x00 +#define SCRIMG_LINEUP 0x01 +#define SCRIMG_PAGEDN 0x02 +#define SCRIMG_PAGEUP 0x03 +#define SCRIMG_LINBEG 0x04 +#define SCRIMG_LINEND 0x05 +#define SCRIMG_SETPOS 0x06 +#define SCRIMG_FORMAT_DELETE_LEFT 1 +#define SCRIMG_FORMAT_DELETE_RIGHT 2 +#define SCRIMG_FORMAT_TYPING 3 +#define SCRIMG_PAN_SETNOPAN 0 +#define SCRIMG_PAN_DELTA 1 +#define SCRIMG_PAN_ABS 2 +#define SCRIMG_STCHNG_DOC 0 +#define SCRIMG_STCHNG_PARA 1 +#define SCRIMG_STCHNG_LINE 2 +#define SCRIMG_FLAGS_PAGEBREAK 0x01 +#define SCRIMG_FLAGS_S3_COMPAT 0x02 +/* Types for scrimg */ +typedef struct +{ +unsigned short int wid; +P_POINT tl; +short int nlines; +unsigned char lheight; +unsigned char lascent; +short int width; +short int margin; +short int lcfont; +unsigned char cwidth; +unsigned char lcstyle; +unsigned char lccode; +unsigned char hscrlx; +unsigned char hscrlm; +unsigned char drawplabs; +} SCRIMG_WIN; +/* Property of scrimg */ +typedef struct { +PR_WRAP *wrap; +PR_SCRLAY *lay; +SCRIMG_WIN win; +SCRLAY_PLX anc; +SCRLAY_PLX crs; +SCRLAY_PLX oldcrs; +short int txwidth; +short int mrwidth; +short int xleft; +short int xright; +unsigned char lcwidth; +unsigned char lcline; +short int updownx; +unsigned char select; +unsigned char formatting; +unsigned char isredraw; +unsigned char GCcreated; +unsigned char emphasised; +unsigned char plabchange; +unsigned char nopan; +unsigned char flags; +short int lfmt; +short int lgood; +short int xo; +G_GC gc; +} PRS_SCRIMG; +typedef struct pr_scrimg +{ +PRS_ROOT root; +PRS_SCRIMG scrimg; +} PR_SCRIMG; diff --git a/code/SIBOSDK/include/scrimg.ing b/code/SIBOSDK/include/scrimg.ing new file mode 100644 index 0000000..a93aee8 --- /dev/null +++ b/code/SIBOSDK/include/scrimg.ing @@ -0,0 +1,108 @@ +; Generated by Ctran from scrimg.cl +SCRIMG_ING equ 1 +IFNDEF SCRLAY_ING + INCLUDE ..\inc\SCRLAY.ING +ENDIF +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF WLIB_INC + INCLUDE ..\inc\WLIB.INC +ENDIF +; Class Numbers +C_WRAP equ 2 +C_SCRIMG equ 3 +; Method Numbers +O_SI_SENSE equ 3 +O_SI_FWD_CHANGE equ 16 +O_SI_STYLE_CHANGED equ 14 +O_SI_DOC_RESET equ 12 +O_SI_MOVE_CURSOR equ 9 +O_SI_DELPREP equ 15 +O_SI_GET_SELECT equ 5 +O_SI_REDRAW equ 10 +O_SI_EMPHASIZE equ 4 +O_SI_SCROLL equ 7 +O_SI_PAN equ 6 +O_SI_PARA_CHANGED equ 13 +O_SI_SET equ 2 +O_SI_DOC_CHANGED equ 11 +O_SI_INIT equ 1 +O_SI_VIEW equ 8 +; Property of wrap +PRS_WRAP struc +WrapScrimg dw ? +PRS_WRAP ends +PR_WRAP struc +WrapRoot PRS_ROOT <> +WrapActive PRS_ACTIVE <> +WrapWrap PRS_WRAP <> +PR_WRAP ends +; Constants for scrimg +SCRIMG_LINEDN equ (000h) +SCRIMG_LINEUP equ (001h) +SCRIMG_PAGEDN equ (002h) +SCRIMG_PAGEUP equ (003h) +SCRIMG_LINBEG equ (004h) +SCRIMG_LINEND equ (005h) +SCRIMG_SETPOS equ (006h) +SCRIMG_FORMAT_DELETE_LEFT equ (1) +SCRIMG_FORMAT_DELETE_RIGHT equ (2) +SCRIMG_FORMAT_TYPING equ (3) +SCRIMG_PAN_SETNOPAN equ (0) +SCRIMG_PAN_DELTA equ (1) +SCRIMG_PAN_ABS equ (2) +SCRIMG_STCHNG_DOC equ (0) +SCRIMG_STCHNG_PARA equ (1) +SCRIMG_STCHNG_LINE equ (2) +SCRIMG_FLAGS_PAGEBREAK equ (001h) +SCRIMG_FLAGS_S3_COMPAT equ (002h) +; Types for scrimg +SCRIMG_WIN struc +SCRIMG_WINWid dw ? +SCRIMG_WINTl P_POINT <> +SCRIMG_WINNlines dw ? +SCRIMG_WINLheight db ? +SCRIMG_WINLascent db ? +SCRIMG_WINWidth dw ? +SCRIMG_WINMargin dw ? +SCRIMG_WINLcfont dw ? +SCRIMG_WINCwidth db ? +SCRIMG_WINLcstyle db ? +SCRIMG_WINLccode db ? +SCRIMG_WINHscrlx db ? +SCRIMG_WINHscrlm db ? +SCRIMG_WINDrawplabs db ? +SCRIMG_WIN ends +; Property of scrimg +PRS_SCRIMG struc +ScrimgWrap dw ? +ScrimgLay dw ? +ScrimgWin SCRIMG_WIN <> +ScrimgAnc SCRLAY_PLX <> +ScrimgCrs SCRLAY_PLX <> +ScrimgOldcrs SCRLAY_PLX <> +ScrimgTxwidth dw ? +ScrimgMrwidth dw ? +ScrimgXleft dw ? +ScrimgXright dw ? +ScrimgLcwidth db ? +ScrimgLcline db ? +ScrimgUpdownx dw ? +ScrimgSelect db ? +ScrimgFormatting db ? +ScrimgIsredraw db ? +ScrimgGCcreated db ? +ScrimgEmphasised db ? +ScrimgPlabchange db ? +ScrimgNopan db ? +ScrimgFlags db ? +ScrimgLfmt dw ? +ScrimgLgood dw ? +ScrimgXo dw ? +ScrimgGc G_GC <> +PRS_SCRIMG ends +PR_SCRIMG struc +ScrimgRoot PRS_ROOT <> +ScrimgScrimg PRS_SCRIMG <> +PR_SCRIMG ends diff --git a/code/SIBOSDK/include/scrlay.g b/code/SIBOSDK/include/scrlay.g new file mode 100644 index 0000000..5670dda --- /dev/null +++ b/code/SIBOSDK/include/scrlay.g @@ -0,0 +1,255 @@ +/* Generated by Ctran from scrlay.cat */ +#define SCRLAY_G +#ifndef OLIB_G +#include +#endif +#ifndef P_GRAF_H +#include +#endif +/* Class Numbers */ +#define C_SCRLAY 0 +#define C_PRNLAY 1 +/* Method Numbers */ +#define O_SL_FORMAT_LINE 9 +#define O_SL_POS_TO_XL 5 +#define O_SL_SCROLL 10 +#define O_SL_PARA_CHANGED 14 +#define O_SL_RESCALE 15 +#define O_SL_LINE_ENDS 4 +#define O_SL_SET 2 +#define O_SL_SET_LINES 13 +#define O_SL_INIT 1 +#define O_SL_PRINT_POS 17 +#define O_SL_VIEW 11 +#define O_SL_BEGIN_READ 7 +#define O_SL_SENSE 3 +#define O_SL_READ 8 +#define O_SL_PRINT_READ 16 +#define O_SL_XL_TO_POS 6 +#define O_SL_DISCARD_LAYOUT 12 +/* Constants for scrlay */ +#define SCRLAY_SYM_HARD_HYPHEN 7 +#define SCRLAY_SYM_SOFT_HYPHEN 14 +#define SCRLAY_SYM_HARD_SPACE 15 +#define SCRLAY_SYM_SHOW_SPACE 8 +#define SCRLAY_SHOW_TABS 0x01 +#define SCRLAY_SHOW_SPACES 0x02 +#define SCRLAY_SHOW_CRS 0x04 +#define SCRLAY_SHOW_HYPHENS 0x08 +#define SCRLAY_SHOW_LFS 0x10 +#define SCRLAY_WIDOW_ORPHAN 0x20 +#define SCRLAY_ALIGN_LEFT 0 +#define SCRLAY_ALIGN_RIGHT 1 +#define SCRLAY_ALIGN_CENTRE 2 +#define SCRLAY_ALIGN_JUSTIFY 3 +#define SCRLAY_REPEAT_TAB 3 +#define SCRLAY_NTABS_MAX 8 +#define SCRLAY_SCAN_POS 0 +#define SCRLAY_SCAN_XY 1 +#define SCRLAY_SCAN_LINE 2 +#define SCRLAY_SPACING_KEEP_NEXT 0x01 +#define SCRLAY_SPACING_KEEP_TOGETHER 0x02 +#define SCRLAY_SPACING_NEW_PAGE 0x04 +#define SCRLAY_TBOX_TAB 0x8000 +#define SCRLAY_TBOX_TAB_USED 0x4000 +#define SCRLAY_TBOX_TAB_LEFT 0x2000 +#define SCRLAY_TBOX_NO_STYLE 0x1000 +#define SCRLAY_TBOX_MASK_LEN 0xff +/* Types for scrlay */ +typedef struct +{ +unsigned short int x; +unsigned short int type; +} SCRLAY_TABSTOP; +typedef struct +{ +unsigned short int ntab; +SCRLAY_TABSTOP tab[SCRLAY_NTABS_MAX]; +} SCRLAY_TABS; +typedef struct +{ +unsigned short int left; +unsigned short int right; +unsigned short int indent; +unsigned short int align; +} SCRLAY_MARGINS; +typedef struct +{ +unsigned short int line; +unsigned short int above; +unsigned short int below; +unsigned short int flags; +} SCRLAY_SPACING; +typedef struct +{ +unsigned short int fid; +unsigned short int style; +unsigned short int height; +} SCRLAY_FONT; +typedef struct +{ +unsigned short int pos; +short int printer; +char *buf; +short int blen; +} SCRLAY_SENSECHARS; +typedef struct +{ +SCRLAY_MARGINS *margins; +SCRLAY_TABS *tabs; +SCRLAY_SPACING *spacing; +} SCRLAY_PDATA; +typedef struct +{ +SCRLAY_FONT font; +unsigned short int align; +char *buf; +short int blen; +} SCRLAY_PLABEL; +typedef struct +{ +unsigned short int len; +void *content; +short int sensechars; +short int sensepdata; +short int senseplabel; +short int toparst; +short int enqpage; +} SCRLAY_DOC; +typedef struct que_tbox +{ +struct scrlay_tbox *next; +struct scrlay_tbox *prev; +} QUE_TBOX; +typedef struct scrlay_tbox +{ +QUE_TBOX hd; +short int width; +unsigned short int tlen; +} SCRLAY_TBOX; +typedef struct que_line +{ +struct scrlay_line *next; +struct scrlay_line *prev; +} QUE_LINE; +typedef struct scrlay_line +{ +QUE_LINE hd; +QUE_TBOX tboxs; +short int indent; +unsigned short int len; +unsigned char islast; +unsigned char new_page; +} SCRLAY_LINE; +typedef struct que_para +{ +struct scrlay_para *next; +struct scrlay_para *prev; +} QUE_PARA; +typedef struct scrlay_para +{ +QUE_PARA hd; +QUE_LINE lines; +} SCRLAY_PARA; +typedef struct +{ +unsigned short int pos; +short int line; +short int x; +} SCRLAY_PLX; +typedef struct +{ +short int scan; +SCRLAY_PLX test; +SCRLAY_PLX pbeg; +SCRLAY_PLX lbeg; +SCRLAY_PLX tbeg; +SCRLAY_TBOX *pt; +SCRLAY_LINE *pl; +SCRLAY_PARA *pp; +} SCRLAY_SCAN; +typedef struct +{ +SCRLAY_PLABEL *label; +SCRLAY_FONT f; +unsigned short int width; +unsigned short int indent; +unsigned char blen; +unsigned char isfirst; +unsigned char islast; +unsigned char new_page; +} SCRLAY_READ; +typedef struct +{ +SCRLAY_PARA *pp; +SCRLAY_LINE *pl; +SCRLAY_TBOX *pt; +unsigned short int pos; +} SCRLAY_RD; +typedef struct +{ +SCRLAY_PARA *pp; +unsigned short int pos; +short int line; +unsigned short int pend; +short int lend; +} SCRLAY_FMT; +typedef struct +{ +unsigned char options; +unsigned char printer; +SCRLAY_PDATA pd; +SCRLAY_FONT *font; +unsigned char *fwtab; +unsigned short int scrpwidth; +SCRLAY_FONT *sfont; +} SCRLAY_STYLE; +/* Property of scrlay */ +typedef struct { +QUE_PARA paras; +SCRLAY_PLX first; +unsigned char nomemory; +unsigned char adjust; +SCRLAY_SCAN *scan; +SCRLAY_RD rd; +SCRLAY_FMT fmt; +SCRLAY_DOC doc; +short int slines; +short int spadjust; +SCRLAY_STYLE st; +} PRS_SCRLAY; +typedef struct pr_scrlay +{ +PRS_ROOT root; +PRS_SCRLAY scrlay; +} PR_SCRLAY; +/* Types for prnlay */ +typedef struct +{ +SCRLAY_PLABEL s; +unsigned char *wid; +unsigned short int margin; +unsigned short int gutter; +} PRNLAY_PLABEL; +/* Property of prnlay */ +typedef struct { +short int tbxlen; +short int senselen; +char *sensebuf; +unsigned short int pos; +short int line; +short int nlines; +short int below; +short int excess; +short int ngaps; +short int ngap; +short int used; +SCRLAY_TBOX *ptab; +short int plabel; +} PRS_PRNLAY; +typedef struct pr_prnlay +{ +PRS_ROOT root; +PRS_SCRLAY scrlay; +PRS_PRNLAY prnlay; +} PR_PRNLAY; diff --git a/code/SIBOSDK/include/scrlay.ing b/code/SIBOSDK/include/scrlay.ing new file mode 100644 index 0000000..e7a724d --- /dev/null +++ b/code/SIBOSDK/include/scrlay.ing @@ -0,0 +1,231 @@ +; Generated by Ctran from scrlay.cl +SCRLAY_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF P_GRAF_INC + INCLUDE ..\inc\P_GRAF.INC +ENDIF +; Class Numbers +C_SCRLAY equ 0 +C_PRNLAY equ 1 +; Method Numbers +O_SL_FORMAT_LINE equ 9 +O_SL_POS_TO_XL equ 5 +O_SL_SCROLL equ 10 +O_SL_PARA_CHANGED equ 14 +O_SL_RESCALE equ 15 +O_SL_LINE_ENDS equ 4 +O_SL_SET equ 2 +O_SL_SET_LINES equ 13 +O_SL_INIT equ 1 +O_SL_PRINT_POS equ 17 +O_SL_VIEW equ 11 +O_SL_BEGIN_READ equ 7 +O_SL_SENSE equ 3 +O_SL_READ equ 8 +O_SL_PRINT_READ equ 16 +O_SL_XL_TO_POS equ 6 +O_SL_DISCARD_LAYOUT equ 12 +; Constants for scrlay +SCRLAY_SYM_HARD_HYPHEN equ (7) +SCRLAY_SYM_SOFT_HYPHEN equ (14) +SCRLAY_SYM_HARD_SPACE equ (15) +SCRLAY_SYM_SHOW_SPACE equ (8) +SCRLAY_SHOW_TABS equ (001h) +SCRLAY_SHOW_SPACES equ (002h) +SCRLAY_SHOW_CRS equ (004h) +SCRLAY_SHOW_HYPHENS equ (008h) +SCRLAY_SHOW_LFS equ (010h) +SCRLAY_WIDOW_ORPHAN equ (020h) +SCRLAY_ALIGN_LEFT equ (0) +SCRLAY_ALIGN_RIGHT equ (1) +SCRLAY_ALIGN_CENTRE equ (2) +SCRLAY_ALIGN_JUSTIFY equ (3) +SCRLAY_REPEAT_TAB equ (3) +SCRLAY_NTABS_MAX equ (8) +SCRLAY_SCAN_POS equ (0) +SCRLAY_SCAN_XY equ (1) +SCRLAY_SCAN_LINE equ (2) +SCRLAY_SPACING_KEEP_NEXT equ (001h) +SCRLAY_SPACING_KEEP_TOGETHER equ (002h) +SCRLAY_SPACING_NEW_PAGE equ (004h) +SCRLAY_TBOX_TAB equ (08000h) +SCRLAY_TBOX_TAB_USED equ (04000h) +SCRLAY_TBOX_TAB_LEFT equ (02000h) +SCRLAY_TBOX_NO_STYLE equ (01000h) +SCRLAY_TBOX_MASK_LEN equ (0ffh) +; Types for scrlay +SCRLAY_TABSTOP struc +SCRLAY_TABSTOPX dw ? +SCRLAY_TABSTOPType dw ? +SCRLAY_TABSTOP ends +SCRLAY_TABS struc +SCRLAY_TABSNtab dw ? +SCRLAY_TABSTab db (size SCRLAY_TABSTOP)* SCRLAY_NTABS_MAX dup (?) +SCRLAY_TABS ends +SCRLAY_MARGINS struc +SCRLAY_MARGINSLeft dw ? +SCRLAY_MARGINSRight dw ? +SCRLAY_MARGINSIndent dw ? +SCRLAY_MARGINSAlign dw ? +SCRLAY_MARGINS ends +SCRLAY_SPACING struc +SCRLAY_SPACINGLine dw ? +SCRLAY_SPACINGAbove dw ? +SCRLAY_SPACINGBelow dw ? +SCRLAY_SPACINGFlags dw ? +SCRLAY_SPACING ends +SCRLAY_FONT struc +SCRLAY_FONTFid dw ? +SCRLAY_FONTStyle dw ? +SCRLAY_FONTHeight dw ? +SCRLAY_FONT ends +SCRLAY_SENSECHARS struc +SCRLAY_SENSECHARSPos dw ? +SCRLAY_SENSECHARSPrinter dw ? +SCRLAY_SENSECHARSBuf dw ? +SCRLAY_SENSECHARSBlen dw ? +SCRLAY_SENSECHARS ends +SCRLAY_PDATA struc +SCRLAY_PDATAMargins dw ? +SCRLAY_PDATATabs dw ? +SCRLAY_PDATASpacing dw ? +SCRLAY_PDATA ends +SCRLAY_PLABEL struc +SCRLAY_PLABELFont SCRLAY_FONT <> +SCRLAY_PLABELAlign dw ? +SCRLAY_PLABELBuf dw ? +SCRLAY_PLABELBlen dw ? +SCRLAY_PLABEL ends +SCRLAY_DOC struc +SCRLAY_DOCLen dw ? +SCRLAY_DOCContent dw ? +SCRLAY_DOCSensechars dw ? +SCRLAY_DOCSensepdata dw ? +SCRLAY_DOCSenseplabel dw ? +SCRLAY_DOCToparst dw ? +SCRLAY_DOCEnqpage dw ? +SCRLAY_DOC ends +QUE_TBOX struc +QUE_TBOXNext dw ? +QUE_TBOXPrev dw ? +QUE_TBOX ends +SCRLAY_TBOX struc +SCRLAY_TBOXHd QUE_TBOX <> +SCRLAY_TBOXWidth dw ? +SCRLAY_TBOXTlen dw ? +SCRLAY_TBOX ends +QUE_LINE struc +QUE_LINENext dw ? +QUE_LINEPrev dw ? +QUE_LINE ends +SCRLAY_LINE struc +SCRLAY_LINEHd QUE_LINE <> +SCRLAY_LINETboxs QUE_TBOX <> +SCRLAY_LINEIndent dw ? +SCRLAY_LINELen dw ? +SCRLAY_LINEIslast db ? +SCRLAY_LINENew_page db ? +SCRLAY_LINE ends +QUE_PARA struc +QUE_PARANext dw ? +QUE_PARAPrev dw ? +QUE_PARA ends +SCRLAY_PARA struc +SCRLAY_PARAHd QUE_PARA <> +SCRLAY_PARALines QUE_LINE <> +SCRLAY_PARA ends +SCRLAY_PLX struc +SCRLAY_PLXPos dw ? +SCRLAY_PLXLine dw ? +SCRLAY_PLXX dw ? +SCRLAY_PLX ends +SCRLAY_SCAN struc +SCRLAY_SCANScan dw ? +SCRLAY_SCANTest SCRLAY_PLX <> +SCRLAY_SCANPbeg SCRLAY_PLX <> +SCRLAY_SCANLbeg SCRLAY_PLX <> +SCRLAY_SCANTbeg SCRLAY_PLX <> +SCRLAY_SCANPt dw ? +SCRLAY_SCANPl dw ? +SCRLAY_SCANPp dw ? +SCRLAY_SCAN ends +SCRLAY_READ struc +SCRLAY_READLabel dw ? +SCRLAY_READF SCRLAY_FONT <> +SCRLAY_READWidth dw ? +SCRLAY_READIndent dw ? +SCRLAY_READBlen db ? +SCRLAY_READIsfirst db ? +SCRLAY_READIslast db ? +SCRLAY_READNew_page db ? +SCRLAY_READ ends +SCRLAY_RD struc +SCRLAY_RDPp dw ? +SCRLAY_RDPl dw ? +SCRLAY_RDPt dw ? +SCRLAY_RDPos dw ? +SCRLAY_RD ends +SCRLAY_FMT struc +SCRLAY_FMTPp dw ? +SCRLAY_FMTPos dw ? +SCRLAY_FMTLine dw ? +SCRLAY_FMTPend dw ? +SCRLAY_FMTLend dw ? +SCRLAY_FMT ends +SCRLAY_STYLE struc +SCRLAY_STYLEOptions db ? +SCRLAY_STYLEPrinter db ? +SCRLAY_STYLEPd SCRLAY_PDATA <> +SCRLAY_STYLEFont dw ? +SCRLAY_STYLEFwtab dw ? +SCRLAY_STYLEScrpwidth dw ? +SCRLAY_STYLESfont dw ? +SCRLAY_STYLE ends +; Property of scrlay +PRS_SCRLAY struc +ScrlayParas QUE_PARA <> +ScrlayFirst SCRLAY_PLX <> +ScrlayNomemory db ? +ScrlayAdjust db ? +ScrlayScan dw ? +ScrlayRd SCRLAY_RD <> +ScrlayFmt SCRLAY_FMT <> +ScrlayDoc SCRLAY_DOC <> +ScrlaySlines dw ? +ScrlaySpadjust dw ? +ScrlaySt SCRLAY_STYLE <> +PRS_SCRLAY ends +PR_SCRLAY struc +ScrlayRoot PRS_ROOT <> +ScrlayScrlay PRS_SCRLAY <> +PR_SCRLAY ends +; Types for prnlay +PRNLAY_PLABEL struc +PRNLAY_PLABELS SCRLAY_PLABEL <> +PRNLAY_PLABELWid dw ? +PRNLAY_PLABELMargin dw ? +PRNLAY_PLABELGutter dw ? +PRNLAY_PLABEL ends +; Property of prnlay +PRS_PRNLAY struc +PrnlayTbxlen dw ? +PrnlaySenselen dw ? +PrnlaySensebuf dw ? +PrnlayPos dw ? +PrnlayLine dw ? +PrnlayNlines dw ? +PrnlayBelow dw ? +PrnlayExcess dw ? +PrnlayNgaps dw ? +PrnlayNgap dw ? +PrnlayUsed dw ? +PrnlayPtab dw ? +PrnlayPlabel dw ? +PRS_PRNLAY ends +PR_PRNLAY struc +PrnlayRoot PRS_ROOT <> +PrnlayScrlay PRS_SCRLAY <> +PrnlayPrnlay PRS_PRNLAY <> +PR_PRNLAY ends diff --git a/code/SIBOSDK/include/search.h b/code/SIBOSDK/include/search.h new file mode 100644 index 0000000..84b1fcd --- /dev/null +++ b/code/SIBOSDK/include/search.h @@ -0,0 +1,42 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* search.h - search and sort function prototypes. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _SEARCH_INC_ +#define _SEARCH_INC_ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern void * bsearch(const void *_key, const void *_base, + size_t _num, size_t _width, + int ( *_compare)(const void *_e1, const void *_e2)); +extern void qsort(void *_base, size_t _num, size_t _width, + int ( *_compare)(const void *_e1, const void *_e2)); +extern char * lfind(const char *_key, const char *_base, + unsigned *_num, unsigned _width, + int ( *_compare)(const void *_e1, const void *_e2)); +extern char * lsearch(const char *_key, char *_base, + unsigned *_num, unsigned _width, + int ( *_compare)(const void *_e1, const void *_e2)); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/serdlgs.g b/code/SIBOSDK/include/serdlgs.g new file mode 100644 index 0000000..d756419 --- /dev/null +++ b/code/SIBOSDK/include/serdlgs.g @@ -0,0 +1,28 @@ +/* Generated by Ctran from serdlgs.cl */ +#define SERDLGS_G +#ifndef DLGBOX_G +#include +#endif +#ifndef P_SERIAL_H +#include +#endif +/* Class Numbers */ +#define C_SETPORTDLG 56 +#define C_SETHSHKDLG 57 +/* Method Numbers */ +/* Property of setportdlg */ +typedef struct pr_setportdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_SETPORTDLG; +/* Property of sethshkdlg */ +typedef struct pr_sethshkdlg +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +} PR_SETHSHKDLG; diff --git a/code/SIBOSDK/include/serdlgs.ing b/code/SIBOSDK/include/serdlgs.ing new file mode 100644 index 0000000..78fe3e2 --- /dev/null +++ b/code/SIBOSDK/include/serdlgs.ing @@ -0,0 +1,26 @@ +; Generated by Ctran from serdlgs.cl +SERDLGS_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF P_SERIAL_INC + INCLUDE ..\inc\P_SERIAL.INC +ENDIF +; Class Numbers +C_SETPORTDLG equ 56 +C_SETHSHKDLG equ 57 +; Method Numbers +; Property of setportdlg +PR_SETPORTDLG struc +SetportdlgRoot PRS_ROOT <> +SetportdlgWin PRS_WIN <> +SetportdlgDlgchain PRS_DLGCHAIN <> +SetportdlgDlgbox PRS_DLGBOX <> +PR_SETPORTDLG ends +; Property of sethshkdlg +PR_SETHSHKDLG struc +SethshkdlgRoot PRS_ROOT <> +SethshkdlgWin PRS_WIN <> +SethshkdlgDlgchain PRS_DLGCHAIN <> +SethshkdlgDlgbox PRS_DLGBOX <> +PR_SETHSHKDLG ends diff --git a/code/SIBOSDK/include/setjmp.h b/code/SIBOSDK/include/setjmp.h new file mode 100644 index 0000000..459db94 --- /dev/null +++ b/code/SIBOSDK/include/setjmp.h @@ -0,0 +1,46 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* setjmp.h - typedef and function prototypes for setjmp and longjmp. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _SETJMP_INC_ +#define _SETJMP_INC_ + +#ifndef _JMPTYPE_DEF +#define _JMPTYPE_DEF + +typedef struct { + unsigned j_flag; + unsigned j_ip; + unsigned j_sp; + unsigned j_bp; + unsigned j_si; + unsigned j_di; + unsigned j_dx; + unsigned j_cx; + unsigned j_bx; + unsigned j_classHandle; + unsigned j_classPtr; + unsigned j_enterFrame; + unsigned j_osFrame; + char j_st[2][10]; +} jmp_buf[1]; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#pragma save,call(reg_saved=>(ax,bx,cx,dx,ds,es,si,di,st0,st1,st2,st3,st4,st5,st6)) +extern void longjmp(jmp_buf _env, int _val); +#pragma restore +extern int setjmp(jmp_buf _env); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/share.h b/code/SIBOSDK/include/share.h new file mode 100644 index 0000000..1fc6f67 --- /dev/null +++ b/code/SIBOSDK/include/share.h @@ -0,0 +1,25 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* share.h - header file for file sharing used with sopen. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _SHARE_INC_ +#define _SHARE_INC_ + +#define SH_NOINHERIT 0x80 +#define SH_COMPAT 0x00 +#define SH_DENYRW 0x10 +#define SH_DENYWR 0x20 +#define SH_DENYRD 0x30 +#define SH_DENYNO 0x40 + +#define SH_ALL 0xF0 + +#define SH_DENYNONE SH_DENYNO /* MS documentation uses both */ +#endif diff --git a/code/SIBOSDK/include/signal.h b/code/SIBOSDK/include/signal.h new file mode 100644 index 0000000..cb03a22 --- /dev/null +++ b/code/SIBOSDK/include/signal.h @@ -0,0 +1,51 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* signal.h - software signalling definitions and prototypes. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _SIGNAL_INC_ +#define _SIGNAL_INC_ + +typedef int sig_atomic_t; +#define NSIG 23 /* maximum signal number + 1 */ + +/* signal types */ +#define SIGINT 2 /* interrupt - corresponds to DOS 3.x int 23H */ +#define SIGILL 4 /* illegal opcode */ +#define SIGFPE 8 /* floating point error */ +#define SIGSEGV 11 /* segment violation */ +#define SIGTERM 15 /* Software termination signal from kill */ +#define SIGUSR1 16 /* User defined signal 1 */ +#define SIGUSR2 17 /* User defined signal 2 */ +#define SIGUSR3 20 /* User defined signal 3 */ +#define SIGABRT 22 /* abnormal termination triggered by abort call */ + +/* signal action codes */ + +#define SIG_DFL (void (*)(int))0L /* default signal action */ +#define SIG_IGN (void (*)(int))1L /* ignore */ +#define SIG_SGE (void (*)(int))3L /* signal gets error */ +#define SIG_ACK (void (*)(int))4L /* error if handler not setup */ + +/* signal error value (returned by signal call on error) */ + +#define SIG_ERR (void (*)(int)) 0xFFFFL /* signal error value */ + +/* function prototypes */ + +#ifdef __cplusplus +extern "C" { +#endif +extern void ( * signal(int _sig, void (*_func)(int _signum)))(int _signum); +extern int raise(int _sig); +#ifdef __cplusplus +} +#endif +#endif + diff --git a/code/SIBOSDK/include/sndlist.g b/code/SIBOSDK/include/sndlist.g new file mode 100644 index 0000000..4eef6fe --- /dev/null +++ b/code/SIBOSDK/include/sndlist.g @@ -0,0 +1,53 @@ +/* Generated by Ctran from sndlist.cl */ +#define SNDLIST_G +#ifndef FACTIVE_G +#include +#endif +#ifndef CHLIST_G +#include +#endif +#ifndef HACTIVE_G +#include +#endif +/* Class Numbers */ +#define C_SNDLIST 75 +#define C_SNDLOCS 76 +#define C_FSOUNDAO 77 +/* Method Numbers */ +/* Constants for sndlist */ +#define SNDLIST_TWOTONE_SOUNDS 2 +#define SNDLIST_TWOTONE_SOUNDS_VINE 6 +/* Property of sndlist */ +typedef struct { +unsigned short int rom_count; +char rom_name_fmt[12]; +} PRS_SNDLIST; +typedef struct pr_sndlist +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_CHLIST chlist; +PRS_SNDLIST sndlist; +} PR_SNDLIST; +/* Property of sndlocs */ +typedef struct { +PR_VARES *data; +} PRS_SNDLOCS; +typedef struct pr_sndlocs +{ +PRS_ROOT root; +PRS_LOCS locs; +PRS_SNDLOCS sndlocs; +} PR_SNDLOCS; +/* Property of fsoundao */ +typedef struct { +void *snd; +} PRS_FSOUNDAO; +typedef struct pr_fsoundao +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_HAIDLE haidle; +PRS_FSOUNDAO fsoundao; +} PR_FSOUNDAO; diff --git a/code/SIBOSDK/include/sndlist.ing b/code/SIBOSDK/include/sndlist.ing new file mode 100644 index 0000000..44ceaa1 --- /dev/null +++ b/code/SIBOSDK/include/sndlist.ing @@ -0,0 +1,50 @@ +; Generated by Ctran from sndlist.cl +SNDLIST_ING equ 1 +IFNDEF FACTIVE_ING + INCLUDE ..\inc\FACTIVE.ING +ENDIF +IFNDEF CHLIST_ING + INCLUDE ..\inc\CHLIST.ING +ENDIF +IFNDEF HACTIVE_ING + INCLUDE ..\inc\HACTIVE.ING +ENDIF +; Class Numbers +C_SNDLIST equ 75 +C_SNDLOCS equ 76 +C_FSOUNDAO equ 77 +; Method Numbers +; Constants for sndlist +SNDLIST_TWOTONE_SOUNDS equ (2) +SNDLIST_TWOTONE_SOUNDS_VINE equ (6) +; Property of sndlist +PRS_SNDLIST struc +SndlistRom_count dw ? +SndlistRom_name_fmt db (1) * 12 dup (?) +PRS_SNDLIST ends +PR_SNDLIST struc +SndlistRoot PRS_ROOT <> +SndlistWin PRS_WIN <> +SndlistLodger PRS_LODGER <> +SndlistChlist PRS_CHLIST <> +SndlistSndlist PRS_SNDLIST <> +PR_SNDLIST ends +; Property of sndlocs +PRS_SNDLOCS struc +SndlocsData dw ? +PRS_SNDLOCS ends +PR_SNDLOCS struc +SndlocsRoot PRS_ROOT <> +SndlocsLocs PRS_LOCS <> +SndlocsSndlocs PRS_SNDLOCS <> +PR_SNDLOCS ends +; Property of fsoundao +PRS_FSOUNDAO struc +FsoundaoSnd dw ? +PRS_FSOUNDAO ends +PR_FSOUNDAO struc +FsoundaoRoot PRS_ROOT <> +FsoundaoActive PRS_ACTIVE <> +FsoundaoHaidle PRS_HAIDLE <> +FsoundaoFsoundao PRS_FSOUNDAO <> +PR_FSOUNDAO ends diff --git a/code/SIBOSDK/include/ss_.rsg b/code/SIBOSDK/include/ss_.rsg new file mode 100644 index 0000000..cab4c50 --- /dev/null +++ b/code/SIBOSDK/include/ss_.rsg @@ -0,0 +1,191 @@ +#define SYS_SPECIAL_CHARACTERS 1 +#define SYS_STRING 2 +#define SYS_DIMMED_MSG 3 +#define SYS_LOCKED_MSG 4 +#define SYS_BUSY 5 +#define SYS_SCANNING 6 +#define SYS_PRINTING_TO 7 +#define SYS_PAGE_IS 8 +#define SYS_COPIED_PROMPT 9 +#define SYS_COPYING_PROMPT 10 +#define SYS_LOADING_PROMPT 11 +#define SYS_MERGING_PROMPT 12 +#define SYS_NOTHING_TO_BRING 13 +#define SYS_NOT_FOUND 14 +#define SYS_NOTHING_TO_FIND 15 +#define SYS_COMPRESS_PROMPT 16 +#define SYS_NOT_COMPRESSIBLE 17 +#define SYS_PASSWORD_INCORRECT 18 +#define SYS_PASSWORD_NOT_CONFIRMED 19 +#define SYS_RANGE_RESET 20 +#define SYS_INVALID_NUM 21 +#define SYS_INVALID_MARGINS 22 +#define SYS_INVALID_CHAR 23 +#define SYS_OUT_OF_RANGE 24 +#define SYS_EDIT_NCHARS 25 +#define SYS_POPOUT_HELP 26 +#define SYS_HELP_STRING 27 +#define SYS_REPLACE_DISK 28 +#define SYS_NAME 29 +#define SYS_PACK 30 +#define SYS_FILELIST_DISK 31 +#define SYS_FLIST_RESET 32 +#define SYS_DEVICE_MEMORY 33 +#define SYS_PATH_IS 34 +#define SYS_CHOOSE_DIRECTORY 35 +#define SYS_CHOOSE_FILENAME 36 +#define SYS_CHOOSE_NEW_DIRECTORY 37 +#define SYS_EXISTS_OVER 38 +#define SYS_MAX 39 +#define SYS_MIN 40 +#define SYS_DEC_PLACES 41 +#define SYS_SIG_DIGITS 42 +#define SYS_EVALDLG_TITLE 43 +#define SYS_NOTHING_TO_EVAL 44 +#define SYS_TOOLONG_TO_EVAL 45 +#define SYS_XONXOFF_STRING 46 +#define SYS_HEADER_STR 47 +#define SYS_FOOTER_STR 48 +#define SYS_CENTIMETRES 49 +#define SYS_INCHES 50 +#define SYS_DEV_NOTREADY 51 +#define SYS_DEV_CORRUPT 52 +#define SYS_DEV_UNKNOWN 53 +#define SYS_DEV_INFO 54 +#define SYS_MTYPE_UNKNOWN 55 +#define SYS_MTYPE_FLOPPY 56 +#define SYS_MTYPE_HARD 57 +#define SYS_MTYPE_FLASH 58 +#define SYS_MTYPE_RAM 59 +#define SYS_MTYPE_ROM 60 +#define SYS_MTYPE_PROTECTED 61 +#define SYS_FILES_TAGGED 62 +#define SYS_NO_FILES 63 +#define SYS_NO_DISK 64 +#define SYS_UNFORMATTED 65 +#define SYS_UNRECOGNISED 66 +#define SYS_SOUND_FAIL 67 +#define SYS_BUTTON_TEXT 68 +#define SYS_AC_NO_YES 69 +#define SYS_AC_CONTINUE 70 +#define SYS_AC_ABANDON 71 +#define SYS_APPEND_ACLIST 72 +#define SYS_SMART_DIAL_ACLIST 73 +#define SYS_FREEDIAL_ACLIST 74 +#define SYS_NO_YES 75 +#define SYS_OFFON_MENU 76 +#define SYS_PRINTER_UNITS_CHLIST 77 +#define SYS_PRINTER_DEVICE_CHLIST 78 +#define SYS_BAUD_RATE_CHLIST 79 +#define SYS_DATA_BITS_CHLIST 80 +#define SYS_STOP_BITS_CHLIST 81 +#define SYS_PARITY_CHLIST 82 +#define SYS_FORMAT_CHLIST 83 +#define SYS_RAD_DEG 84 +#define SYS_PAGE_DIMENSIONS 85 +#define SYS_PAGE_SIZE 86 +#define SYS_ORIENT 87 +#define SYS_PRN_POS 88 +#define SYS_HEADFOOT_ALIGN 89 +#define SYS_PGNO_CHOICE 90 +#define SYS_ERROR_DIALOG 91 +#define SYS_QUERY_DIALOG 92 +#define SYS_PRINTING_DIALOG 93 +#define SYS_SET_PORT_DIALOG 94 +#define SYS_SET_HSHK_DIALOG 95 +#define SYS_PRINTER_CONFIG_DIALOG 96 +#define SYS_EVAL_DIALOG 97 +#define SYS_COUNTRY_SELECTOR_DIALOG 98 +#define SYS_SMART_DIAL_ITEM 99 +#define SYS_SMART_DIAL_DIALOG 100 +#define SYS_FREEDIAL_DIALOG 101 +#define SYS_FLIST_DIALOG 102 +#define SYS_PRINT_CONTROL_DL 103 +#define SYS_PAGING_CONTROL_DL 104 +#define SYS_PRINTER_MODEL 105 +#define SYS_MARGINS_DL 106 +#define SYS_HEADFOOT_DL 107 +#define SYS_PAGESIZE_DL 108 +#define SYS_FONT_DL 109 +#define SYS_TXTMESS 110 +#define SYS_HELP_INDEX_DATA 111 +#define SYS_HELP_INDEX 112 +#define SYS_HELP_ON_HELP 113 +#define SYS_HELP_DIALOG 114 +#define SYS_HELP_STATWIN 115 +#define SYS_HELP_DIALLING 116 +#define SYS_HELP_FILSELS 117 +#define SYS_HELP_EDIT 118 +#define SYS_HELP_X_HELP 119 +#define SYS_HELP_FILES 120 +#define SYS_HELP_PRINT 121 +#define SYS_TIME_BASICS 122 +#define SYS_HELP_ON_OFF 123 +#define SYS_HELP_X_INDEX 124 +#define SYS_WDR_GENERAL 125 +#define SYS_DIAL_OUT 126 +#define SYS_SKIPPING_PAGE 127 +#define SYS_DEBUGGING_NUM_CELLS 128 +#define SYS_CALENDAR 129 +#define SYS_PAGE 130 +#define SYS_PAGES 131 +#define SYS_PREVIEW_BUSY 132 +#define SYS_DISPLAY_MARGINS 133 +#define SYS_HIDE_MARGINS 134 +#define SYS_OPENING_PROMPT 135 +#define SYS_PRINT_PREVIEW 136 +#define SYS_PREVIEW_MARGINS_CHLIST 137 +#define SYS_PREVIEW_OPTIONS_CHLIST 138 +#define SYS_PREVIEW_OPTIONS_DIALOG 139 +#define SYS_PREVIEW_JUMP_DIALOG 140 +#define SYS_PREVIEW_ACC 141 +#define SYS_PREVIEW_MENUBAR 142 +#define SYS_PREVIEW_MENU 143 +#define SYS_PRINTER_DEVICES 144 +#define SYS_PRINT_CONTROL_DEVICE 145 +#define SYS_PRINT_PREVIEW_SETTINGS 146 +#define SYS_PREVIEW_SETTINGS_DL 147 +#define SYS_STANDARD_SOUNDS 148 +#define SYS_ALARM_STANDARD_NAME 149 +#define SYS_SILENT_ALARM 150 +#define SYS_SOUND_DISABLED 151 +#define SYS_WORD_ROM 152 +#define SYS_RESTART_FROM_SYS 153 +#define SRT_FILE_CREATED 154 +#define SRT_FILE_OPENED 155 +#define SRT_FILE_SAVED 156 +#define SRT_FILE_COMPRESSED 157 +#define SRT_FILE_MERGED 158 +#define SYS_SAVING_PROMPT 159 +#define SYS_RELOADING_PROMPT 160 +#define SYS_CONVERTING_PROMPT 161 +#define SYS_NOT_CHANGED 162 +#define SYS_CONFIRM_CONTINUE 163 +#define SYS_CONFIRM_CHANGE_LOSS 164 +#define SYS_LOSING_CHANGES 165 +#define SYS_NOTHING_TO_PRINT 166 +#define SYS_NOTHING_TO_INSERT 167 +#define SYS_NOTHING_TO_COPY 168 +#define SYS_REVERT_TO_SAVED 169 +#define SYS_SHIFT_KEY_NAME 170 +#define SRT_SPACE_ONLY 171 +#define SYS_CHANGE_PASSWORD 172 +#define SYS_SET_PASSWORD_DL 173 +#define SYS_GET_PASSWORD_DL 174 +#define SYS_HELP_EVALUATE 175 +#define SYS_HELP_MEMO 176 +#define SYS_HELP_IN_USE 177 +#define SYS_HELP_NO_SYS_MEM 178 +#define SYS_HELP_CALENDAR 179 +#define SYS_S3C_PRINT_CONTROL_DL 180 +#define SYS_S3C_PAGE_SETUP 181 +#define SYS_HELP_BATTERY 182 +#define SYS_VINE_FILE_INFO_DL 183 +#define SYS_RUSSIAN_KEYS 184 +#define SYS_HELP_INFRARED 185 +#define SYS_HELP_APPNOTREADY 186 +#define SYS_IR_DISABLED 187 +#define SYS_IR_POWER_LEVEL 188 +#define SYS_PRINTER_IR 189 +#define SYS_BAUD_RATE_CHLIST_X 190 +#define SYS_BAUD_CONTROL_X 191 diff --git a/code/SIBOSDK/include/ss_.rsi b/code/SIBOSDK/include/ss_.rsi new file mode 100644 index 0000000..20c7b76 --- /dev/null +++ b/code/SIBOSDK/include/ss_.rsi @@ -0,0 +1,191 @@ +SYS_SPECIAL_CHARACTERS equ 1 +SYS_STRING equ 2 +SYS_DIMMED_MSG equ 3 +SYS_LOCKED_MSG equ 4 +SYS_BUSY equ 5 +SYS_SCANNING equ 6 +SYS_PRINTING_TO equ 7 +SYS_PAGE_IS equ 8 +SYS_COPIED_PROMPT equ 9 +SYS_COPYING_PROMPT equ 10 +SYS_LOADING_PROMPT equ 11 +SYS_MERGING_PROMPT equ 12 +SYS_NOTHING_TO_BRING equ 13 +SYS_NOT_FOUND equ 14 +SYS_NOTHING_TO_FIND equ 15 +SYS_COMPRESS_PROMPT equ 16 +SYS_NOT_COMPRESSIBLE equ 17 +SYS_PASSWORD_INCORRECT equ 18 +SYS_PASSWORD_NOT_CONFIRMED equ 19 +SYS_RANGE_RESET equ 20 +SYS_INVALID_NUM equ 21 +SYS_INVALID_MARGINS equ 22 +SYS_INVALID_CHAR equ 23 +SYS_OUT_OF_RANGE equ 24 +SYS_EDIT_NCHARS equ 25 +SYS_POPOUT_HELP equ 26 +SYS_HELP_STRING equ 27 +SYS_REPLACE_DISK equ 28 +SYS_NAME equ 29 +SYS_PACK equ 30 +SYS_FILELIST_DISK equ 31 +SYS_FLIST_RESET equ 32 +SYS_DEVICE_MEMORY equ 33 +SYS_PATH_IS equ 34 +SYS_CHOOSE_DIRECTORY equ 35 +SYS_CHOOSE_FILENAME equ 36 +SYS_CHOOSE_NEW_DIRECTORY equ 37 +SYS_EXISTS_OVER equ 38 +SYS_MAX equ 39 +SYS_MIN equ 40 +SYS_DEC_PLACES equ 41 +SYS_SIG_DIGITS equ 42 +SYS_EVALDLG_TITLE equ 43 +SYS_NOTHING_TO_EVAL equ 44 +SYS_TOOLONG_TO_EVAL equ 45 +SYS_XONXOFF_STRING equ 46 +SYS_HEADER_STR equ 47 +SYS_FOOTER_STR equ 48 +SYS_CENTIMETRES equ 49 +SYS_INCHES equ 50 +SYS_DEV_NOTREADY equ 51 +SYS_DEV_CORRUPT equ 52 +SYS_DEV_UNKNOWN equ 53 +SYS_DEV_INFO equ 54 +SYS_MTYPE_UNKNOWN equ 55 +SYS_MTYPE_FLOPPY equ 56 +SYS_MTYPE_HARD equ 57 +SYS_MTYPE_FLASH equ 58 +SYS_MTYPE_RAM equ 59 +SYS_MTYPE_ROM equ 60 +SYS_MTYPE_PROTECTED equ 61 +SYS_FILES_TAGGED equ 62 +SYS_NO_FILES equ 63 +SYS_NO_DISK equ 64 +SYS_UNFORMATTED equ 65 +SYS_UNRECOGNISED equ 66 +SYS_SOUND_FAIL equ 67 +SYS_BUTTON_TEXT equ 68 +SYS_AC_NO_YES equ 69 +SYS_AC_CONTINUE equ 70 +SYS_AC_ABANDON equ 71 +SYS_APPEND_ACLIST equ 72 +SYS_SMART_DIAL_ACLIST equ 73 +SYS_FREEDIAL_ACLIST equ 74 +SYS_NO_YES equ 75 +SYS_OFFON_MENU equ 76 +SYS_PRINTER_UNITS_CHLIST equ 77 +SYS_PRINTER_DEVICE_CHLIST equ 78 +SYS_BAUD_RATE_CHLIST equ 79 +SYS_DATA_BITS_CHLIST equ 80 +SYS_STOP_BITS_CHLIST equ 81 +SYS_PARITY_CHLIST equ 82 +SYS_FORMAT_CHLIST equ 83 +SYS_RAD_DEG equ 84 +SYS_PAGE_DIMENSIONS equ 85 +SYS_PAGE_SIZE equ 86 +SYS_ORIENT equ 87 +SYS_PRN_POS equ 88 +SYS_HEADFOOT_ALIGN equ 89 +SYS_PGNO_CHOICE equ 90 +SYS_ERROR_DIALOG equ 91 +SYS_QUERY_DIALOG equ 92 +SYS_PRINTING_DIALOG equ 93 +SYS_SET_PORT_DIALOG equ 94 +SYS_SET_HSHK_DIALOG equ 95 +SYS_PRINTER_CONFIG_DIALOG equ 96 +SYS_EVAL_DIALOG equ 97 +SYS_COUNTRY_SELECTOR_DIALOG equ 98 +SYS_SMART_DIAL_ITEM equ 99 +SYS_SMART_DIAL_DIALOG equ 100 +SYS_FREEDIAL_DIALOG equ 101 +SYS_FLIST_DIALOG equ 102 +SYS_PRINT_CONTROL_DL equ 103 +SYS_PAGING_CONTROL_DL equ 104 +SYS_PRINTER_MODEL equ 105 +SYS_MARGINS_DL equ 106 +SYS_HEADFOOT_DL equ 107 +SYS_PAGESIZE_DL equ 108 +SYS_FONT_DL equ 109 +SYS_TXTMESS equ 110 +SYS_HELP_INDEX_DATA equ 111 +SYS_HELP_INDEX equ 112 +SYS_HELP_ON_HELP equ 113 +SYS_HELP_DIALOG equ 114 +SYS_HELP_STATWIN equ 115 +SYS_HELP_DIALLING equ 116 +SYS_HELP_FILSELS equ 117 +SYS_HELP_EDIT equ 118 +SYS_HELP_X_HELP equ 119 +SYS_HELP_FILES equ 120 +SYS_HELP_PRINT equ 121 +SYS_TIME_BASICS equ 122 +SYS_HELP_ON_OFF equ 123 +SYS_HELP_X_INDEX equ 124 +SYS_WDR_GENERAL equ 125 +SYS_DIAL_OUT equ 126 +SYS_SKIPPING_PAGE equ 127 +SYS_DEBUGGING_NUM_CELLS equ 128 +SYS_CALENDAR equ 129 +SYS_PAGE equ 130 +SYS_PAGES equ 131 +SYS_PREVIEW_BUSY equ 132 +SYS_DISPLAY_MARGINS equ 133 +SYS_HIDE_MARGINS equ 134 +SYS_OPENING_PROMPT equ 135 +SYS_PRINT_PREVIEW equ 136 +SYS_PREVIEW_MARGINS_CHLIST equ 137 +SYS_PREVIEW_OPTIONS_CHLIST equ 138 +SYS_PREVIEW_OPTIONS_DIALOG equ 139 +SYS_PREVIEW_JUMP_DIALOG equ 140 +SYS_PREVIEW_ACC equ 141 +SYS_PREVIEW_MENUBAR equ 142 +SYS_PREVIEW_MENU equ 143 +SYS_PRINTER_DEVICES equ 144 +SYS_PRINT_CONTROL_DEVICE equ 145 +SYS_PRINT_PREVIEW_SETTINGS equ 146 +SYS_PREVIEW_SETTINGS_DL equ 147 +SYS_STANDARD_SOUNDS equ 148 +SYS_ALARM_STANDARD_NAME equ 149 +SYS_SILENT_ALARM equ 150 +SYS_SOUND_DISABLED equ 151 +SYS_WORD_ROM equ 152 +SYS_RESTART_FROM_SYS equ 153 +SRT_FILE_CREATED equ 154 +SRT_FILE_OPENED equ 155 +SRT_FILE_SAVED equ 156 +SRT_FILE_COMPRESSED equ 157 +SRT_FILE_MERGED equ 158 +SYS_SAVING_PROMPT equ 159 +SYS_RELOADING_PROMPT equ 160 +SYS_CONVERTING_PROMPT equ 161 +SYS_NOT_CHANGED equ 162 +SYS_CONFIRM_CONTINUE equ 163 +SYS_CONFIRM_CHANGE_LOSS equ 164 +SYS_LOSING_CHANGES equ 165 +SYS_NOTHING_TO_PRINT equ 166 +SYS_NOTHING_TO_INSERT equ 167 +SYS_NOTHING_TO_COPY equ 168 +SYS_REVERT_TO_SAVED equ 169 +SYS_SHIFT_KEY_NAME equ 170 +SRT_SPACE_ONLY equ 171 +SYS_CHANGE_PASSWORD equ 172 +SYS_SET_PASSWORD_DL equ 173 +SYS_GET_PASSWORD_DL equ 174 +SYS_HELP_EVALUATE equ 175 +SYS_HELP_MEMO equ 176 +SYS_HELP_IN_USE equ 177 +SYS_HELP_NO_SYS_MEM equ 178 +SYS_HELP_CALENDAR equ 179 +SYS_S3C_PRINT_CONTROL_DL equ 180 +SYS_S3C_PAGE_SETUP equ 181 +SYS_HELP_BATTERY equ 182 +SYS_VINE_FILE_INFO_DL equ 183 +SYS_RUSSIAN_KEYS equ 184 +SYS_HELP_INFRARED equ 185 +SYS_HELP_APPNOTREADY equ 186 +SYS_IR_DISABLED equ 187 +SYS_IR_POWER_LEVEL equ 188 +SYS_PRINTER_IR equ 189 +SYS_BAUD_RATE_CHLIST_X equ 190 +SYS_BAUD_CONTROL_X equ 191 diff --git a/code/SIBOSDK/include/stat.h b/code/SIBOSDK/include/stat.h new file mode 100644 index 0000000..61a663c --- /dev/null +++ b/code/SIBOSDK/include/stat.h @@ -0,0 +1,50 @@ +/* Release 3.00 */ + +/*----------------------------------------------------------------------------* +* * +* stat.h - Definitions used for file status functions * +* * +* Copyright (c) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*-----------------------------------------------------------------------------*/ +#include + +#ifndef _STAT_INC_ +#define _STAT_INC_ + +#ifndef _STAT_H +#define _STAT_H + +#define S_IFMT 0170000 /* file type mask */ +#define S_IFDIR 0x4000 /* directory */ +#define S_IFCHR 0x2000 /* character device */ +#define S_IFREG 0x8000 /* regular file */ +#define S_IREAD 0x0100 /* owner may read */ +#define S_IWRITE 0x0080 /* owner may write */ +#define S_IEXEC 0x0040 /* owner may execute */ + +struct stat { + short st_dev; + short st_ino; + short st_mode; + short st_nlink; + int st_uid; + int st_gid; + short st_rdev; + long st_size; + long st_atime; + long st_mtime; + long st_ctime; +}; + +#ifdef __cplusplus +extern "C" { +#endif +extern int fstat (int _handle, struct stat *_statbuf); +extern int stat (const char *_path, struct stat *_statbuf); +#ifdef __cplusplus +} +#endif +#endif +#endif + diff --git a/code/SIBOSDK/include/stdarg.h b/code/SIBOSDK/include/stdarg.h new file mode 100644 index 0000000..a3d4f63 --- /dev/null +++ b/code/SIBOSDK/include/stdarg.h @@ -0,0 +1,24 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* stdarg.h - defines for ANSI macros for varaible argument functions * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STDARG_INC_ +#define _STDARG_INC_ + +#ifndef NULL +#define NULL 0 +#endif + +typedef char *va_list; + +#define va_start(ap, plist) ap = (va_list)&plist + sizeof(plist) +#define va_arg(ap, t) (*(t*)((ap += sizeof(t)+(sizeof(t)&1))-(sizeof(t)+(sizeof(t)&1)))) +#define va_end(ap) ap = NULL +#endif diff --git a/code/SIBOSDK/include/stddef.h b/code/SIBOSDK/include/stddef.h new file mode 100644 index 0000000..c4d428f --- /dev/null +++ b/code/SIBOSDK/include/stddef.h @@ -0,0 +1,40 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* stddef.h - definitions of common types. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STDDEF_INC_ +#define _STDDEF_INC_ + +#ifndef _PTRDIFF_T + #define _PTRDIFF_T + typedef int ptrdiff_t; +#endif + +#ifndef _SIZE_T + #define _SIZE_T + typedef unsigned size_t; +#endif + + +#ifndef _WCHAR_T + #define _WCHAR_T + typedef unsigned char wchar_t; +#endif + +#ifndef _OFFSETOF_M + #define _OFFSETOF_M + #define offsetof(st, member) (size_t)(&((st*)0)->member) +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#endif diff --git a/code/SIBOSDK/include/stdepoc.h b/code/SIBOSDK/include/stdepoc.h new file mode 100644 index 0000000..dab52e1 --- /dev/null +++ b/code/SIBOSDK/include/stdepoc.h @@ -0,0 +1,20 @@ +/* HEADER - STDEPOC.H +Epoc/Os standard C calling convention, structures and constants. +Copyright (c) Psion PLC 1991. + + VER DATE BY DESCRIPTION +----- -------- ---- ----------- +1.00F 26/04/91 NSM Final release +*/ +#ifndef STDEPOC_H +#define STDEPOC_H +#pragma call(reg_saved=>(ax,bx,cx,dx,di,si,ds,st1,st2),\ + reg_param=>(ax,bx,cx,dx,st0,st6,st5,st4,st3),\ + reg_return=>(ax,dx,st0),standard_float=>off,\ + opt_var_arg=>on,c_conv=>off) +#pragma call(seg_name =>null) +#pragma data(ss_in_dgroup =>on,seg_name =>null) +#pragma warn(wall=>on,wpnu=>off,wovr=>off) +#define EPOC_SAVE ds,st1,st2 +#endif + diff --git a/code/SIBOSDK/include/stdio.h b/code/SIBOSDK/include/stdio.h new file mode 100644 index 0000000..9e38a15 --- /dev/null +++ b/code/SIBOSDK/include/stdio.h @@ -0,0 +1,182 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* stdio.h - header file for stream input and output. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STDIO_INC_ +#define _STDIO_INC_ + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef _STDARG_INC_ +#include +#endif + +#ifndef _ERRNOS_INC_ +#define _ERRNOS_INC_ +extern int _doserrno; /* global DOS error variable */ +extern int errno; /* global error variable */ +#endif + +/* Number of files that can be open simultaneously */ + +#define OPEN_MAX 20 /* Total of 20 open files */ +#define SYS_OPEN 20 + +/* define file control block */ + +#ifndef _IOB +#define _IOB +typedef struct _iobuf { + char *_ptr; /* current char pointer */ + short _cnt; /* buffer free space */ + short _size; /* buffer size */ + char *_base; /* buffer address */ + int _flag; /* file attrib flag */ + int _file; /* file handle */ + int _pback; /* ungot char if no buffer */ +} FILE; +extern FILE _iob[OPEN_MAX]; +#endif + +/* Buffer type to be used as 3rd argument for "setvbuf" function */ + +#define _IOFBF 0 +#define _IOLBF 1 +#define _IONBF 2 + +/* End-of-file constant definition */ + +#define EOF (-1) + +/* Standard I/O predefined streams */ + +#define stdin (&_iob[0]) +#define stdout (&_iob[1]) +#define stderr (&_iob[2]) + +/* flags bit definitions */ + +#define _F_RDWR 0x0003 /* Read/write */ +#define _F_READ 0x0001 /* Read only file */ +#define _F_WRIT 0x0002 /* Write only file */ +#define _F_UBUF 0x0004 /* User allocated buffer */ +#define _F_APP 0x0008 /* Append data */ +#define _F_ERR 0x0010 /* Error */ +#define _F_EOF 0x0020 /* EOF */ +#define _F_BIN 0x0040 /* Binary file */ +#define _F_IN 0x0080 /* Data is incoming */ +#define _F_OUT 0x0100 /* Data is outgoing */ +#define _F_DEV 0x0200 /* File is terminal */ +#define _F_RST 0x0400 /* Newly opened stream */ +#define _F_LBUF 0x0800 /* line buffered stream */ +#define _F_CTZ 0x1000 + +/* Default buffer size use by "setbuf" function */ + +#define BUFSIZ 512 /* Buffer size for stdio */ + +/* Constants to be used as 3rd argument for "fseek" function */ + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#ifndef _FPOS_T_DEF +#define _FPOS_T_DEF +typedef long fpos_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern void clearerr(FILE *_st); +extern int fclose(FILE *_st); +extern int fflush(FILE *_st); +extern int fgetc(FILE *_st); +extern char * fgets(char *s, int _n, FILE *_st); +extern FILE * fopen(const char *_path, const char *_mode); +extern int fprintf(FILE *_st, const char *_format, ...); +extern int fputc(int _c, FILE *_st); +extern int fputs(const char *_s, FILE *_st); +extern size_t fread(void *_ptr, size_t _size, size_t _n, FILE *_st); +extern FILE * freopen(const char *_path, const char *_mode,FILE *_oldfile); +extern int fscanf(FILE *_st, const char *_format, ...); +extern int fseek(FILE *_st, long _offset, int _whence); +extern long ftell(FILE *_st); +extern size_t fwrite(const void *_ptr, size_t _size, size_t _n,FILE *_st); +extern char * gets(char *_s); +extern void perror(const char *_s); +extern int printf(const char *_format, ...); +extern int puts(const char *_s); +extern int rename(const char *_oldname, const char *_newname); +extern void rewind(FILE *_st); +extern int rmtmp(void); +extern int scanf(const char *_format, ...); +extern void setbuf(FILE *_st, char *_buf); +extern int setvbuf(FILE *_st, char *_buf, int _type, size_t _size); +extern int sprintf(char *_s, const char *_format, ...); +extern int sscanf(const char *_s, const char *_format, ...); +extern char * strerror(int _errnum); +extern FILE * tmpfile(void); +extern int ungetc(int _c, FILE *_st); +extern int vfprintf(FILE *_st, const char *_format, va_list _argptr); +extern int vfscanf(FILE *_st, const char *_format, va_list _argptr); +extern int vprintf(const char *_format, va_list _argptr); +extern int vscanf(const char *_format, va_list _argptr); +extern int vsprintf(char *_s, const char *_format, va_list _argptr); +extern int vsscanf(const char *_s, const char *_format, va_list _argptr); +extern int fcloseall(void); +extern FILE * fdopen(int _handle, char *_type); +extern int fgetchar(void); +extern int fgetpos(FILE *_st, fpos_t *_fp); +extern int fsetpos(FILE *_st, const fpos_t *_fp); +extern int flushall(void); +extern int fputchar(int _c); +extern int getw(FILE *_st); +extern int putw(int _w, FILE *_st); +extern char * _strerror(const char *_s); +extern int unlink(const char *_path); + +/* common functions normally implemented as macros */ + +extern int putchar(int _c); +extern int getchar(void); +extern int putc(int _c, FILE *_st); +extern int getc(FILE *_st); +extern int remove(const char *_path); +extern int fileno(FILE *_st); +extern int feof(FILE *_st); +extern int ferror(FILE *_st); +#ifdef __cplusplus +} +#endif + +#ifndef __STDC__ +#ifndef _IO_MTF +#define ferror(f) ((f)->_flag & _F_ERR) +#define feof(f) ((f)->_flag & _F_EOF) +#define fileno(f) ((f)->_file) +#define remove(path) unlink(path) +#define getc(f) fgetc(f) +#define putc(c,f) fputc(c,f) +#define getchar() fgetc(stdin) +#define putchar(c) fputc((c), stdout) +#endif +#endif + +#endif + diff --git a/code/SIBOSDK/include/stdiostr.hpp b/code/SIBOSDK/include/stdiostr.hpp new file mode 100644 index 0000000..c2e07c5 --- /dev/null +++ b/code/SIBOSDK/include/stdiostr.hpp @@ -0,0 +1,61 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* STDIOSTR.HPP - header file for stdio stream input and output. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STDIOSTR_INC_ +#define _STDIOSTR_INC_ + + +#include +#include + +class stdiobuf : public streambuf { + +public: + stdiobuf(FILE *); + ~stdiobuf(); + + FILE *stdiofile(); + virtual int overflow(int = EOF); + virtual int pbackfail(int); + virtual int sync(); + virtual streampos seekoff(streamoff, ios::seek_dir, int); + virtual int underflow(); + +private: + + FILE *sio; + long last_seek; + int gs; + char lahead[2]; + int last_op(); +}; + +inline FILE* stdiobuf::stdiofile() { return sio; } + +class stdiostream : public ios { + +public: + + stdiostream(FILE *); + ~stdiostream(); + + stdiobuf* rdbuf(); + +private: + + stdiobuf buf; + +}; + +inline stdiobuf* stdiostream::rdbuf() { return &buf; } + +#endif + diff --git a/code/SIBOSDK/include/stdlib.h b/code/SIBOSDK/include/stdlib.h new file mode 100644 index 0000000..8d65fe1 --- /dev/null +++ b/code/SIBOSDK/include/stdlib.h @@ -0,0 +1,150 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* stdlib.h - definitions for common variables, types and functions. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STDLIB_INC_ +#define _STDLIB_INC_ + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef _WCHAR_T +#define _WCHAR_T +typedef unsigned char wchar_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#define MB_CUR_MAX 1 + +#ifndef _LDIV_T +#define _LDIV_T +typedef struct { + long quot; + long rem; +} ldiv_t; +#endif + +#ifndef _DIV_T +#define _DIV_T +typedef struct { + int quot; + int rem; +} div_t; +#endif + +#ifndef _ERRNOL_INC_ +#define _ERRNOL_INC_ +extern int _doserrno; /* global DOS error variable */ +extern int errno; /* global error variable */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort(void); +extern int abs(int _num); +extern int atexit(void (*_func)(void)); +extern double atof(const char *_nptr); +extern long double atofl(const char *_nptr); +extern int atoi(const char *_nptr); +extern long atol(const char *_nptr); +extern unsigned long atoul(const char *_nptr); +extern void * bsearch(const void *_key, const void *_base, + size_t _nmemb, size_t _size, + int ( *_compare)(const void *_e1, const void *_e2)); +extern void * calloc(size_t _num, size_t _size); +extern void delay(int _tm); +extern div_t div(int _numer, int _denom); +extern char * ecvt(double _value, int _digits, int *_dec, int *_sign); +extern void _exit(int _status); +extern void exit(int _code); +extern char * fcvt(double _value, int _digits, int *_dec, int *_sign); +extern void free(void *_block); +extern char * gcvt(double _value, int _ndec, char *_buf); +extern char * gcvtl(long double _value, int _ndec, char *_buf); +extern char * getenv(const char *_name); +extern char * itoa(int _value, char *_string, int _radix); +extern long labs(long _j); +extern ldiv_t ldiv(long _numer, long _denom); +extern char * lfind(const char *_key, const char *_base, + unsigned *_num, unsigned _width, + int ( *_compare)(const void *_e1, const void *_e2)); +extern unsigned long _lrotl(unsigned long _val, int _count); +extern unsigned long _lrotr(unsigned long _val, int _count); +extern char * lsearch(const char *_key, char *_base, + unsigned *_num, unsigned _width, + int ( *_compare)(const void *_e1, const void *_e2)); +extern char * ltoa(long _value, char *_s, int _radix); +extern void _makepath(char *_path, const char *_drive, const char *_dir, + const char *_name, const char *_ext); +extern void * malloc(size_t _size); +extern int mblen(const char *_s, size_t _n); +extern size_t mbstowcs(wchar_t *_pwcs, const char *_s, size_t _n); +extern int mbtowc(wchar_t *_pwc, const char *_s, size_t _n); +extern void (* onexit(void ( *_func)(void)))(); +extern int putenv(const char *_name); +extern void qsort(void *_base, size_t _nmemb, size_t _size, + int (*_compare)(const void *_e1, const void *_e2)); +extern int rand(void); +extern void randomize(void); +extern void * realloc(void *_block, size_t _size); +extern unsigned _rotl(unsigned _value, int _count); +extern unsigned _rotr(unsigned _value, int _count); + +extern void _searchenv(const char *_name, const char *_env, char *_path); +extern void _splitpath(const char *_path, char *_drive, char *_dir, + char *_name, char *_ext); +extern void srand(unsigned _seed); +extern double strtod(const char *_s, char **_endptr); +extern long strtol(const char *_s, char **_endptr, int _base); +extern unsigned long strtoul(const char *_s, char **_endptr, int _base); +extern void swab(const char *_from, char *_to, int _num); +extern int system(const char *_string); +extern char * ultoa(unsigned long _value, char *_s, int _radix); +extern int wctomb(char *_s, wchar_t _wchar); +extern size_t wcstombs(char *_s, const wchar_t *_pwcs, size_t _n); +#ifdef __cplusplus +} +#endif + + +/* Variables */ + +extern unsigned int _fmode; +extern char * sys_errlist[38]; +extern int sys_nerr; + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 0xFF + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define random(num) (rand() % (num)) +#define RAND_MAX 32767 + + +#define _MAX_PATH 144 /* maximum length of full pathname */ +#define _MAX_DRIVE 4 /* maximum length of drive component */ +#define _MAX_DIR 130 /* maximum length of path component */ +#define _MAX_FNAME 9 /* maximum length of file name component */ +#define _MAX_EXT 5 /* maximum length of extension component */ + +#endif diff --git a/code/SIBOSDK/include/stream.hpp b/code/SIBOSDK/include/stream.hpp new file mode 100644 index 0000000..2ee5bf2 --- /dev/null +++ b/code/SIBOSDK/include/stream.hpp @@ -0,0 +1,245 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* STREAM.HPP - header file for AT&T v1.2 stream input and output. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef __STREAM_INC_ +#define __STREAM_INC_ + +#include + +#pragma save +#pragma name(prefix=>"__o__") + +struct whitespace { + char x; +}; + +extern struct whitespace WS; + +class istream; +class ostream; + +class streambuf { + +friend istream; +friend ostream; + +protected: + + FILE *file; + char *base; + char *pptr; + char *gptr; + char *eptr; + int didalloc; + + virtual int overflow(int = EOF ); + virtual int underflow(); + + int allocate(); + streambuf * setbuf(char *, int , unsigned = 0); + + virtual void terminate(); + +public: + streambuf() { file=0; didalloc=0; base=pptr=gptr=eptr=NULL; } + streambuf(char *buf, int len) { file=0; didalloc=0; setbuf(buf, len); } + virtual ~streambuf(); + + virtual int snextc(); + virtual int sputc(int); + virtual void sputbackc(char); + +}; + +enum open_mode { + input, + output, + append +}; + +class filebuf : public streambuf { + +private: + + int fd; + int isopen; + +protected: + + void terminate(); + +public: + + filebuf() { isopen=0; fd=0; } + filebuf(FILE *); + filebuf(int); + filebuf(int, char *, int); + ~filebuf() { close(); } + + filebuf* open(char *, int); + int close(); + int snextc() { return ::fgetc(file); } + int sputc(int _c) { return ::fputc(_c, file); } + void sputbackc(char _c) { (void) :: ungetc(_c, file); } +}; + +char *dec(long, int = 0); +char *hex(long, int = 0); +char *oct(long, int = 0); +char *chr(int, int = 0); +char *str(const char *, int = 0); +char *form(char *, ...); + +enum stream_state { + _good=0, + _eof=1, + _fail=2, + _bad=4 +}; + +class ostream { + +friend istream; + +private: + + streambuf* stream; + char mystream; + char state; + +public: + + ostream(streambuf *); + ostream(int); + ostream(int, char *); + ~ostream() { (void) flush(); if(mystream) delete stream; } + + operator void*() { return (state == _good) ? this : NULL; } + int operator !() { return (state != _good); } + + ostream& operator <<(int); + ostream& operator <<(long); + ostream& operator <<(unsigned int _U) { return *this << ((long) _U); } + ostream& operator <<(unsigned long); + ostream& operator <<(const char *); + ostream& operator <<(double); + ostream& operator <<(long double); + + ostream& put(char _c) { if(stream->sputc(_c) == EOF) + state = _fail; + return *this; } + + ostream& flush(); + + int rdstate() { return state; } + void clear(int _s = _good) { state = _s; } + int bad() { return (state & _bad); } + int fail() { return (state & _fail); } + int eof() { return (state & _eof); } + int good() { return (state == _good); } + +}; + +class istream { + +friend void eatwhite(istream& _s) {_s >> WS; } + +private: + ostream* tied_to; + streambuf* stream; + char skipping; + char mystream; + int state; + + long getlong(int); + long double getreal(); + +public: + istream(streambuf*, int = 1, ostream* = NULL); + istream(int, char*, int = 1); + istream(int, int = 1, ostream* = NULL); + ~istream() { if(mystream) delete stream; } + + operator void*() { return (state == _good) ? this : NULL; } + int operator !() { return (state != _good); } + + istream& operator >> (signed char& _c) { unsigned char _x; + *this >> _x; + if(state == _good) + _c=(signed char) _x; + return *this; } + + istream& operator >> ( char& _c) { unsigned char _x; + *this >> _x; + if(state == _good) + _c=(char) _x; + return *this; } + + istream& operator >> (short& _s){ short _x= (short) getlong(0); + if(state == _good) + _s=_x; + return *this; } + + istream& operator >> (int& _i) { int _x= (int) getlong(0); + if(state == _good) + _i=_x; + return *this; } + + istream& operator >> (long& _l){ long _x= getlong(0); + if(state == _good) + _l=_x; + return *this; } + + + istream& operator >> (unsigned char& _c); + + istream& operator >> (unsigned short& _s){ unsigned short _x= (unsigned short) getlong(0); + if(state == _good) + _s=_x; + return *this; } + + istream& operator >> (unsigned int& _i){ unsigned int _x= (unsigned int) getlong(0); + if(state == _good) + _i=_x; + return *this; } + + istream& operator >> (unsigned long& _l){ unsigned long _x= (unsigned long) getlong(0); + if(state == _good) + _l=_x; + return *this; } + + istream& operator >>(float&); + istream& operator >>(double&); + istream& operator >>(long double&); + istream& operator >>(char *); + istream& operator >>(whitespace&); + istream& get(char&); + istream& get(char*, int, int = '\n'); + + int skip(int _s) { short _t = skipping; skipping = _s; return _t; } + ostream * tie( ostream *_to ) { ostream *_t = tied_to; tied_to = _to; return _t; } + void putback(char _c) { stream->sputbackc(_c); }; + int rdstate() { return state; } + void clear(int _s = _good) { state = _s; } + int bad() { return (state & _bad); } + int fail() { return (state & _fail); } + int eof() { return (state & _eof); } + int good() { return (state == _good); } + +}; + +extern istream cin; +extern ostream cout; +extern ostream cerr; + +#pragma restore + +#endif diff --git a/code/SIBOSDK/include/string.h b/code/SIBOSDK/include/string.h new file mode 100644 index 0000000..f8e0ecf --- /dev/null +++ b/code/SIBOSDK/include/string.h @@ -0,0 +1,74 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* string.h - Definitions for string and memory functions. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STRING_INC_ +#define _STRING_INC_ + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern int memcmp(const void *_s1, const void *_s2, size_t _n); +extern void * memcpy(void *_dest, const void *_source, size_t _n); +extern void * memset(void *_s, int _c, size_t _n); +extern char * strcat(char *_dest, const char *_source); +extern int strcmp(const char *_s1, const char *_s2); +extern char * strcpy(char *_dest, const char *_source); +extern size_t strlen(const char *_s); +extern char * strset(char *_s, int _ch); +extern void * memccpy(void *_dest, const void *_source, int _c, size_t _n); +extern void * memchr(const void *_s, int _c, size_t _n); +extern int memicmp(const void *_s1, const void *_s2, size_t _n); +extern void * memmove(void *_dest, const void *_source, size_t _n); +extern void movmem(void *_src, void *_dest, unsigned length); +extern void setmem(void *_dest, unsigned length, char val); +extern void * memwcpy(void *_dest, const void *_source, size_t _n); +extern void * memwmove(void *_dest, const void *_source, size_t _n); +extern void * memwset(void *_s, int _c, size_t _n); +extern char * stpcpy(char *_dest, const char *_source); +extern char * strchr(const char *_s, int _c); +extern int strcoll(const char *_s1, const char *_s2); +extern size_t strxfrm(char *_s1, const char *_s2, size_t _n); +extern size_t strcspn(const char *_s1, const char *_s2); +extern char * strdup(const char *_s); +extern char * strerror(int _errnum); +extern int stricmp(const char *_s1, const char *_s2); +extern char * strlwr(char *_s); +extern char * strncat(char *_dest, const char *_source, size_t _n); +extern int strncmp(const char *_s1, const char *_s2, size_t _n); +extern char * strncpy(char *_dest, const char *_source, size_t _n); +extern int strnicmp(const char *_s1, const char *_s2, size_t _n); +extern char * strnset(char *_s, int _ch, size_t _n); +extern char * strpbrk(const char *_s1, const char *_s2); +extern char * strrchr(const char *_s, int _c); +extern char * strrev(char *_s); +extern size_t strspn(const char *_s1, const char *_s2); +extern char * strstr(const char *_s1, const char *_s2); +extern char * strtok(char *_s1, const char *_s2); +extern char * strupr(char *_s); +extern char * _strerror (const char *_s); +#ifdef __cplusplus +} +#endif + +/* compatibility with other compilers */ +#define strcmpi(s1,s2) stricmp(s1,s2) +#define strncmpi(s1,s2,n) strnicmp(s1,s2,n) + +#endif diff --git a/code/SIBOSDK/include/strstrea.hpp b/code/SIBOSDK/include/strstrea.hpp new file mode 100644 index 0000000..8a1a782 --- /dev/null +++ b/code/SIBOSDK/include/strstrea.hpp @@ -0,0 +1,108 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* STRSTREA.HPP - header file for string stream input and output. * +* * +* COPYRIGHT (C) 1990..1992 Clarion Software Corporation * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _STRSTREAM_INC_ +#define _STRSTREAM_INC_ + +#include + +class strstreambuf : public streambuf { + +public: + strstreambuf(); + strstreambuf(int _n); + strstreambuf(void * (*a)(long), void (*f)(void*)); + strstreambuf(char *_s, int , char *_start=NULL); + ~strstreambuf(); + + void freeze(int = 1); + char *str(); + virtual int doallocate(); + virtual int overflow(int); + virtual int underflow(); + virtual streambuf *setbuf(char *, int); + virtual streampos seekoff(streamoff, ios::seek_dir, int); + +private: + + enum { + dynamic = 1, + frozen = 2, + unlimited = 4 }; + + void * (*allocf)(long); + void (*freef)(void *); + void init(char *, int, char *); + short flags; + int next_alloc; +}; + +class strstreambase : public virtual ios { + +public: + + strstreambuf* rdbuf(); + +protected: + + strstreambase(char *, int, char *); + strstreambase(); + ~strstreambase(); + +private: + + strstreambuf buf; + +}; + +inline strstreambuf* strstreambase::rdbuf() { return &this->buf; } + +class istrstream : public strstreambase, public istream { + +public: + + istrstream(char *); + istrstream(char *, int); + ~istrstream(); +}; + +class ostrstream : public strstreambase, public ostream { + +public: + + ostrstream(); + ostrstream(char *, int, int); + ~ostrstream(); + + char *str(); + int pcount(); + +}; + +inline char *ostrstream::str() { return strstreambase::rdbuf()->str(); } +inline int ostrstream::pcount() { return strstreambase::rdbuf()->out_waiting(); } + +class strstream : public strstreambase, public iostream { + +public: + + strstream(); + strstream(char *, int _sz, int _m); + ~strstream(); + + char *str(); + +}; + +inline char *strstream::str() { return strstreambase::rdbuf()->str(); } + +#endif + diff --git a/code/SIBOSDK/include/sw_.rsg b/code/SIBOSDK/include/sw_.rsg new file mode 100644 index 0000000..2ce8a68 --- /dev/null +++ b/code/SIBOSDK/include/sw_.rsg @@ -0,0 +1,182 @@ +#define SYS_SPECIAL_CHARACTERS 1 +#define SYS_STRING 2 +#define SYS_DIMMED_MSG 3 +#define SYS_LOCKED_MSG 4 +#define SYS_BUSY 5 +#define SYS_SCANNING 6 +#define SYS_PRINTING_TO 7 +#define SYS_PAGE_IS 8 +#define SYS_COPIED_PROMPT 9 +#define SYS_COPYING_PROMPT 10 +#define SYS_LOADING_PROMPT 11 +#define SYS_MERGING_PROMPT 12 +#define SYS_NOTHING_TO_BRING 13 +#define SYS_NOT_FOUND 14 +#define SYS_NOTHING_TO_FIND 15 +#define SYS_COMPRESS_PROMPT 16 +#define SYS_NOT_COMPRESSIBLE 17 +#define SYS_PASSWORD_INCORRECT 18 +#define SYS_PASSWORD_NOT_CONFIRMED 19 +#define SYS_RANGE_RESET 20 +#define SYS_INVALID_NUM 21 +#define SYS_INVALID_MARGINS 22 +#define SYS_INVALID_CHAR 23 +#define SYS_OUT_OF_RANGE 24 +#define SYS_EDIT_NCHARS 25 +#define SYS_POPOUT_HELP 26 +#define SYS_HELP_STRING 27 +#define SYS_REPLACE_DISK 28 +#define SYS_NAME 29 +#define SYS_PACK 30 +#define SYS_FILELIST_DISK 31 +#define SYS_FLIST_RESET 32 +#define SYS_DEVICE_MEMORY 33 +#define SYS_PATH_IS 34 +#define SYS_CHOOSE_DIRECTORY 35 +#define SYS_CHOOSE_FILENAME 36 +#define SYS_CHOOSE_NEW_DIRECTORY 37 +#define SYS_EXISTS_OVER 38 +#define SYS_MAX 39 +#define SYS_MIN 40 +#define SYS_DEC_PLACES 41 +#define SYS_SIG_DIGITS 42 +#define SYS_EVALDLG_TITLE 43 +#define SYS_NOTHING_TO_EVAL 44 +#define SYS_TOOLONG_TO_EVAL 45 +#define SYS_XONXOFF_STRING 46 +#define SYS_HEADER_STR 47 +#define SYS_FOOTER_STR 48 +#define SYS_CENTIMETRES 49 +#define SYS_INCHES 50 +#define SYS_DEV_NOTREADY 51 +#define SYS_DEV_CORRUPT 52 +#define SYS_DEV_UNKNOWN 53 +#define SYS_DEV_INFO 54 +#define SYS_MTYPE_UNKNOWN 55 +#define SYS_MTYPE_FLOPPY 56 +#define SYS_MTYPE_HARD 57 +#define SYS_MTYPE_FLASH 58 +#define SYS_MTYPE_RAM 59 +#define SYS_MTYPE_ROM 60 +#define SYS_MTYPE_PROTECTED 61 +#define SYS_FILES_TAGGED 62 +#define SYS_NO_FILES 63 +#define SYS_NO_DISK 64 +#define SYS_UNFORMATTED 65 +#define SYS_UNRECOGNISED 66 +#define SYS_SOUND_FAIL 67 +#define SYS_BUTTON_TEXT 68 +#define SYS_AC_NO_YES 69 +#define SYS_AC_CONTINUE 70 +#define SYS_AC_ABANDON 71 +#define SYS_APPEND_ACLIST 72 +#define SYS_SMART_DIAL_ACLIST 73 +#define SYS_FREEDIAL_ACLIST 74 +#define SYS_NO_YES 75 +#define SYS_OFFON_MENU 76 +#define SYS_PRINTER_UNITS_CHLIST 77 +#define SYS_PRINTER_DEVICE_CHLIST 78 +#define SYS_BAUD_RATE_CHLIST 79 +#define SYS_DATA_BITS_CHLIST 80 +#define SYS_STOP_BITS_CHLIST 81 +#define SYS_PARITY_CHLIST 82 +#define SYS_FORMAT_CHLIST 83 +#define SYS_RAD_DEG 84 +#define SYS_PAGE_DIMENSIONS 85 +#define SYS_PAGE_SIZE 86 +#define SYS_ORIENT 87 +#define SYS_PRN_POS 88 +#define SYS_HEADFOOT_ALIGN 89 +#define SYS_PGNO_CHOICE 90 +#define SYS_ERROR_DIALOG 91 +#define SYS_QUERY_DIALOG 92 +#define SYS_PRINTING_DIALOG 93 +#define SYS_SET_PORT_DIALOG 94 +#define SYS_SET_HSHK_DIALOG 95 +#define SYS_PRINTER_CONFIG_DIALOG 96 +#define SYS_EVAL_DIALOG 97 +#define SYS_COUNTRY_SELECTOR_DIALOG 98 +#define SYS_SMART_DIAL_ITEM 99 +#define SYS_SMART_DIAL_DIALOG 100 +#define SYS_FREEDIAL_DIALOG 101 +#define SYS_FLIST_DIALOG 102 +#define SYS_PRINT_CONTROL_DL 103 +#define SYS_PAGING_CONTROL_DL 104 +#define SYS_PRINTER_MODEL 105 +#define SYS_MARGINS_DL 106 +#define SYS_HEADFOOT_DL 107 +#define SYS_PAGESIZE_DL 108 +#define SYS_FONT_DL 109 +#define SYS_TXTMESS 110 +#define SYS_HELP_INDEX_DATA 111 +#define SYS_HELP_INDEX 112 +#define SYS_HELP_ON_HELP 113 +#define SYS_HELP_DIALOG 114 +#define SYS_HELP_STATWIN 115 +#define SYS_HELP_DIALLING 116 +#define SYS_HELP_FILSELS 117 +#define SYS_HELP_EDIT 118 +#define SYS_HELP_X_HELP 119 +#define SYS_HELP_FILES 120 +#define SYS_HELP_PRINT 121 +#define SYS_TIME_BASICS 122 +#define SYS_HELP_ON_OFF 123 +#define SYS_HELP_X_INDEX 124 +#define SYS_WDR_GENERAL 125 +#define SYS_DIAL_OUT 126 +#define SYS_SKIPPING_PAGE 127 +#define SYS_DEBUGGING_NUM_CELLS 128 +#define SYS_CALENDAR 129 +#define SYS_PAGE 130 +#define SYS_PAGES 131 +#define SYS_PREVIEW_BUSY 132 +#define SYS_DISPLAY_MARGINS 133 +#define SYS_HIDE_MARGINS 134 +#define SYS_OPENING_PROMPT 135 +#define SYS_PRINT_PREVIEW 136 +#define SYS_PREVIEW_MARGINS_CHLIST 137 +#define SYS_PREVIEW_OPTIONS_CHLIST 138 +#define SYS_PREVIEW_OPTIONS_DIALOG 139 +#define SYS_PREVIEW_JUMP_DIALOG 140 +#define SYS_PREVIEW_ACC 141 +#define SYS_PREVIEW_MENUBAR 142 +#define SYS_PREVIEW_MENU 143 +#define SYS_PRINTER_DEVICES 144 +#define SYS_PRINT_CONTROL_DEVICE 145 +#define SYS_PRINT_PREVIEW_SETTINGS 146 +#define SYS_PREVIEW_SETTINGS_DL 147 +#define SYS_STANDARD_SOUNDS 148 +#define SYS_ALARM_STANDARD_NAME 149 +#define SYS_SILENT_ALARM 150 +#define SYS_SOUND_DISABLED 151 +#define SYS_WORD_ROM 152 +#define SYS_RESTART_FROM_SYS 153 +#define SRT_FILE_CREATED 154 +#define SRT_FILE_OPENED 155 +#define SRT_FILE_SAVED 156 +#define SRT_FILE_COMPRESSED 157 +#define SRT_FILE_MERGED 158 +#define SYS_SAVING_PROMPT 159 +#define SYS_RELOADING_PROMPT 160 +#define SYS_CONVERTING_PROMPT 161 +#define SYS_NOT_CHANGED 162 +#define SYS_CONFIRM_CONTINUE 163 +#define SYS_CONFIRM_CHANGE_LOSS 164 +#define SYS_LOSING_CHANGES 165 +#define SYS_NOTHING_TO_PRINT 166 +#define SYS_NOTHING_TO_INSERT 167 +#define SYS_NOTHING_TO_COPY 168 +#define SYS_REVERT_TO_SAVED 169 +#define SYS_SHIFT_KEY_NAME 170 +#define SRT_SPACE_ONLY 171 +#define SYS_CHANGE_PASSWORD 172 +#define SYS_SET_PASSWORD_DL 173 +#define SYS_GET_PASSWORD_DL 174 +#define SYS_HELP_EVALUATE 175 +#define SYS_HELP_MEMO 176 +#define SYS_HELP_IN_USE 177 +#define SYS_HELP_NO_SYS_MEM 178 +#define SYS_HELP_CALENDAR 179 +#define SYS_S3C_PRINT_CONTROL_DL 180 +#define SYS_S3C_PAGE_SETUP 181 +#define SYS_HELP_BATTERY 182 diff --git a/code/SIBOSDK/include/sw_.rsi b/code/SIBOSDK/include/sw_.rsi new file mode 100644 index 0000000..d93cae1 --- /dev/null +++ b/code/SIBOSDK/include/sw_.rsi @@ -0,0 +1,182 @@ +SYS_SPECIAL_CHARACTERS equ 1 +SYS_STRING equ 2 +SYS_DIMMED_MSG equ 3 +SYS_LOCKED_MSG equ 4 +SYS_BUSY equ 5 +SYS_SCANNING equ 6 +SYS_PRINTING_TO equ 7 +SYS_PAGE_IS equ 8 +SYS_COPIED_PROMPT equ 9 +SYS_COPYING_PROMPT equ 10 +SYS_LOADING_PROMPT equ 11 +SYS_MERGING_PROMPT equ 12 +SYS_NOTHING_TO_BRING equ 13 +SYS_NOT_FOUND equ 14 +SYS_NOTHING_TO_FIND equ 15 +SYS_COMPRESS_PROMPT equ 16 +SYS_NOT_COMPRESSIBLE equ 17 +SYS_PASSWORD_INCORRECT equ 18 +SYS_PASSWORD_NOT_CONFIRMED equ 19 +SYS_RANGE_RESET equ 20 +SYS_INVALID_NUM equ 21 +SYS_INVALID_MARGINS equ 22 +SYS_INVALID_CHAR equ 23 +SYS_OUT_OF_RANGE equ 24 +SYS_EDIT_NCHARS equ 25 +SYS_POPOUT_HELP equ 26 +SYS_HELP_STRING equ 27 +SYS_REPLACE_DISK equ 28 +SYS_NAME equ 29 +SYS_PACK equ 30 +SYS_FILELIST_DISK equ 31 +SYS_FLIST_RESET equ 32 +SYS_DEVICE_MEMORY equ 33 +SYS_PATH_IS equ 34 +SYS_CHOOSE_DIRECTORY equ 35 +SYS_CHOOSE_FILENAME equ 36 +SYS_CHOOSE_NEW_DIRECTORY equ 37 +SYS_EXISTS_OVER equ 38 +SYS_MAX equ 39 +SYS_MIN equ 40 +SYS_DEC_PLACES equ 41 +SYS_SIG_DIGITS equ 42 +SYS_EVALDLG_TITLE equ 43 +SYS_NOTHING_TO_EVAL equ 44 +SYS_TOOLONG_TO_EVAL equ 45 +SYS_XONXOFF_STRING equ 46 +SYS_HEADER_STR equ 47 +SYS_FOOTER_STR equ 48 +SYS_CENTIMETRES equ 49 +SYS_INCHES equ 50 +SYS_DEV_NOTREADY equ 51 +SYS_DEV_CORRUPT equ 52 +SYS_DEV_UNKNOWN equ 53 +SYS_DEV_INFO equ 54 +SYS_MTYPE_UNKNOWN equ 55 +SYS_MTYPE_FLOPPY equ 56 +SYS_MTYPE_HARD equ 57 +SYS_MTYPE_FLASH equ 58 +SYS_MTYPE_RAM equ 59 +SYS_MTYPE_ROM equ 60 +SYS_MTYPE_PROTECTED equ 61 +SYS_FILES_TAGGED equ 62 +SYS_NO_FILES equ 63 +SYS_NO_DISK equ 64 +SYS_UNFORMATTED equ 65 +SYS_UNRECOGNISED equ 66 +SYS_SOUND_FAIL equ 67 +SYS_BUTTON_TEXT equ 68 +SYS_AC_NO_YES equ 69 +SYS_AC_CONTINUE equ 70 +SYS_AC_ABANDON equ 71 +SYS_APPEND_ACLIST equ 72 +SYS_SMART_DIAL_ACLIST equ 73 +SYS_FREEDIAL_ACLIST equ 74 +SYS_NO_YES equ 75 +SYS_OFFON_MENU equ 76 +SYS_PRINTER_UNITS_CHLIST equ 77 +SYS_PRINTER_DEVICE_CHLIST equ 78 +SYS_BAUD_RATE_CHLIST equ 79 +SYS_DATA_BITS_CHLIST equ 80 +SYS_STOP_BITS_CHLIST equ 81 +SYS_PARITY_CHLIST equ 82 +SYS_FORMAT_CHLIST equ 83 +SYS_RAD_DEG equ 84 +SYS_PAGE_DIMENSIONS equ 85 +SYS_PAGE_SIZE equ 86 +SYS_ORIENT equ 87 +SYS_PRN_POS equ 88 +SYS_HEADFOOT_ALIGN equ 89 +SYS_PGNO_CHOICE equ 90 +SYS_ERROR_DIALOG equ 91 +SYS_QUERY_DIALOG equ 92 +SYS_PRINTING_DIALOG equ 93 +SYS_SET_PORT_DIALOG equ 94 +SYS_SET_HSHK_DIALOG equ 95 +SYS_PRINTER_CONFIG_DIALOG equ 96 +SYS_EVAL_DIALOG equ 97 +SYS_COUNTRY_SELECTOR_DIALOG equ 98 +SYS_SMART_DIAL_ITEM equ 99 +SYS_SMART_DIAL_DIALOG equ 100 +SYS_FREEDIAL_DIALOG equ 101 +SYS_FLIST_DIALOG equ 102 +SYS_PRINT_CONTROL_DL equ 103 +SYS_PAGING_CONTROL_DL equ 104 +SYS_PRINTER_MODEL equ 105 +SYS_MARGINS_DL equ 106 +SYS_HEADFOOT_DL equ 107 +SYS_PAGESIZE_DL equ 108 +SYS_FONT_DL equ 109 +SYS_TXTMESS equ 110 +SYS_HELP_INDEX_DATA equ 111 +SYS_HELP_INDEX equ 112 +SYS_HELP_ON_HELP equ 113 +SYS_HELP_DIALOG equ 114 +SYS_HELP_STATWIN equ 115 +SYS_HELP_DIALLING equ 116 +SYS_HELP_FILSELS equ 117 +SYS_HELP_EDIT equ 118 +SYS_HELP_X_HELP equ 119 +SYS_HELP_FILES equ 120 +SYS_HELP_PRINT equ 121 +SYS_TIME_BASICS equ 122 +SYS_HELP_ON_OFF equ 123 +SYS_HELP_X_INDEX equ 124 +SYS_WDR_GENERAL equ 125 +SYS_DIAL_OUT equ 126 +SYS_SKIPPING_PAGE equ 127 +SYS_DEBUGGING_NUM_CELLS equ 128 +SYS_CALENDAR equ 129 +SYS_PAGE equ 130 +SYS_PAGES equ 131 +SYS_PREVIEW_BUSY equ 132 +SYS_DISPLAY_MARGINS equ 133 +SYS_HIDE_MARGINS equ 134 +SYS_OPENING_PROMPT equ 135 +SYS_PRINT_PREVIEW equ 136 +SYS_PREVIEW_MARGINS_CHLIST equ 137 +SYS_PREVIEW_OPTIONS_CHLIST equ 138 +SYS_PREVIEW_OPTIONS_DIALOG equ 139 +SYS_PREVIEW_JUMP_DIALOG equ 140 +SYS_PREVIEW_ACC equ 141 +SYS_PREVIEW_MENUBAR equ 142 +SYS_PREVIEW_MENU equ 143 +SYS_PRINTER_DEVICES equ 144 +SYS_PRINT_CONTROL_DEVICE equ 145 +SYS_PRINT_PREVIEW_SETTINGS equ 146 +SYS_PREVIEW_SETTINGS_DL equ 147 +SYS_STANDARD_SOUNDS equ 148 +SYS_ALARM_STANDARD_NAME equ 149 +SYS_SILENT_ALARM equ 150 +SYS_SOUND_DISABLED equ 151 +SYS_WORD_ROM equ 152 +SYS_RESTART_FROM_SYS equ 153 +SRT_FILE_CREATED equ 154 +SRT_FILE_OPENED equ 155 +SRT_FILE_SAVED equ 156 +SRT_FILE_COMPRESSED equ 157 +SRT_FILE_MERGED equ 158 +SYS_SAVING_PROMPT equ 159 +SYS_RELOADING_PROMPT equ 160 +SYS_CONVERTING_PROMPT equ 161 +SYS_NOT_CHANGED equ 162 +SYS_CONFIRM_CONTINUE equ 163 +SYS_CONFIRM_CHANGE_LOSS equ 164 +SYS_LOSING_CHANGES equ 165 +SYS_NOTHING_TO_PRINT equ 166 +SYS_NOTHING_TO_INSERT equ 167 +SYS_NOTHING_TO_COPY equ 168 +SYS_REVERT_TO_SAVED equ 169 +SYS_SHIFT_KEY_NAME equ 170 +SRT_SPACE_ONLY equ 171 +SYS_CHANGE_PASSWORD equ 172 +SYS_SET_PASSWORD_DL equ 173 +SYS_GET_PASSWORD_DL equ 174 +SYS_HELP_EVALUATE equ 175 +SYS_HELP_MEMO equ 176 +SYS_HELP_IN_USE equ 177 +SYS_HELP_NO_SYS_MEM equ 178 +SYS_HELP_CALENDAR equ 179 +SYS_S3C_PRINT_CONTROL_DL equ 180 +SYS_S3C_PAGE_SETUP equ 181 +SYS_HELP_BATTERY equ 182 diff --git a/code/SIBOSDK/include/symbols.h b/code/SIBOSDK/include/symbols.h new file mode 100644 index 0000000..c919390 --- /dev/null +++ b/code/SIBOSDK/include/symbols.h @@ -0,0 +1,99 @@ +/* + File: SYMBOLS.H + Copyright (C) Psion PLC 1993 + Started by : DavidW +*/ + +/* Names of the pictures in the symbols font */ + +#define WS_SYMBOL_SHOW_CR 0 + +#define WS_SYMBOL_ELLIPSIS 1 +/* #define WS_WIDTH_ELLIPSIS 6 */ + +#define WS_SYMBOL_PSION 2 + +#define WS_SYMBOL_POWERX 3 + +#define WS_SYMBOL_DIAMOND 4 +#define WS_SYMBOL_NOTE_ICON 4 + +#define WS_SYMBOL_PHONE 5 + +#define WS_SYMBOL_PADLOCK 6 + +#define WS_SYMBOL_HARD_HYPHEN 7 + +#define WS_SYMBOL_SHOW_SPACE 8 + +#define WS_SYMBOL_SHOW_TAB 9 + +#define WS_SYMBOL_LINE_BREAK 10 + +#define WS_SYMBOL_SHIFTED 11 +#define WS_SYMBOL_SQROOT 11 + +#define WS_SYMBOL_TICK 12 + +#define WS_SYMBOL_DOWN_ARROWHEAD 13 + +#define WS_SYMBOL_SOFT_HYPHEN 14 + +#define WS_SYMBOL_HARD_SPACE 15 + +#define WS_SYMBOL_RIGHT_ARROWHEAD 16 + +#define WS_SYMBOL_LEFT_ARROWHEAD 17 + +#define WS_SYMBOL_WHITE_BOX 18 + +#define WS_SYMBOL_PASS_UNDERLINE 19 + +#define WS_SYMBOL_GREY_BOX 20 + +#define WS_SYMBOL_IR_SEND 21 + +#define WS_SYMBOL_BLACK_BOX 22 + +#define WS_SYMBOL_IR_RECEIVE 23 + +#define WS_SYMBOL_UP_KEY 24 + +#define WS_SYMBOL_DOWN_KEY 25 + +#define WS_SYMBOL_RIGHT_KEY 26 + +#define WS_SYMBOL_LEFT_KEY 27 + +#define WS_SYMBOL_MARGIN_CURSOR 28 + +#define WS_SYMBOL_BELL 29 + +#define WS_SYMBOL_UP_ARROWHEAD 30 + +#define WS_SYMBOL_NS 31 + +#define WS_SYMBOL_POWER2 253 + +#define WS_SYMBOL_BULLET 254 + +/* Positioning of special characters in the special array */ + +#define H_SC_TPLUS 0 /* T is for Tag */ +#define H_SC_TMINUS 1 +#define H_SC_TSTAR 2 +#define H_SC_TSLASH 3 + +#define H_SC_ILESS 4 /* I is for Incrementer */ +#define H_SC_ICOMMA 5 +#define H_SC_IMORE 6 +#define H_SC_IDOT 7 + +#define H_SC_HFANCY 8 /* H is for Hyphen */ + +#define H_SC_LLN 9 /* LL is for LatLong editor */ +#define H_SC_LLS 10 +#define H_SC_LLW 11 +#define H_SC_LLE 12 +#define H_SC_DEGREE 13 /* Degree symbol */ +#define H_SC_BULLET 14 /* bullet used in helplist */ diff --git a/code/SIBOSDK/include/symbols.inc b/code/SIBOSDK/include/symbols.inc new file mode 100644 index 0000000..40d09f3 --- /dev/null +++ b/code/SIBOSDK/include/symbols.inc @@ -0,0 +1,124 @@ +; Names and widths of the pictures in the symbols font + +WS_SYMBOL_SHOW_CR equ 0 +WS_WIDTH_SHOW_CR equ 6 + +WS_SYMBOL_ELLIPSIS equ 1 +WS_WIDTH_ELLIPSIS equ 6 + +WS_SYMBOL_PSION equ 2 +WS_WIDTH_PSION equ 5 + +WS_SYMBOL_POWERX equ 3 +WS_WIDTH_POWERX equ 5 + +WS_SYMBOL_NOTE_ICON equ 4 +WS_WIDTH_NOTE_ICON equ 6 + +WS_SYMBOL_PHONE equ 5 +WS_WIDTH_PHONE equ 6 + +WS_SYMBOL_PADLOCK equ 6 +WS_WIDTH_PADLOCK equ 6 + +WS_SYMBOL_HARD_HYPHEN equ 7 +WS_WIDTH_HARD_HYPHEN equ 6 + +WS_SYMBOL_SHOW_SPACE equ 8 +WS_WIDTH_SHOW_SPACE equ 3 + +WS_SYMBOL_SHOW_TAB equ 9 +WS_WIDTH_SHOW_TAB equ 6 + +WS_SYMBOL_LINE_BREAK equ 10 +WS_WIDTH_LINE_BREAK equ 6 + +WS_SYMBOL_SQROOT equ 11 +WS_WIDTH_SQROOT equ 6 + +WS_SYMBOL_TICK equ 12 +WS_WIDTH_TICK equ 8 + +WS_SYMBOL_DOWN_ARROWHEAD equ 13 +WS_WIDTH_DOWN_ARROWHEAD equ 7 + +WS_SYMBOL_SOFT_HYPHEN equ 14 +WS_WIDTH_SOFT_HYPHEN equ 6 + +WS_SYMBOL_HARD_SPACE equ 15 +WS_WIDTH_HARD_SPACE equ 3 + +WS_SYMBOL_RIGHT_ARROWHEAD equ 16 +WS_WIDTH_RIGHT_ARROWHEAD equ 5 + +WS_SYMBOL_LEFT_ARROWHEAD equ 17 +WS_WIDTH_LEFT_ARROWHEAD equ 5 + +WS_SYMBOL_WHITE_BOX1 equ 18 +WS_WIDTH_WHITE_BOX1 equ 6 + +WS_SYMBOL_WHITE_BOX2 equ 19 +WS_WIDTH_WHITE_BOX2 equ 5 + +WS_SYMBOL_GREY_BOX1 equ 20 +WS_WIDTH_GREY_BOX1 equ 6 + +WS_SYMBOL_GREY_BOX2 equ 21 +WS_WIDTH_GREY_BOX2 equ 5 + +WS_SYMBOL_BLACK_BOX1 equ 22 +WS_WIDTH_BLACK_BOX1 equ 6 + +WS_SYMBOL_BLACK_BOX2 equ 23 +WS_WIDTH_BLACK_BOX2 equ 5 + +WS_SYMBOL_UP_KEY equ 24 +WS_WIDTH_UP_KEY equ 6 + +WS_SYMBOL_DOWN_KEY equ 25 +WS_WIDTH_DOWN_KEY equ 6 + +WS_SYMBOL_RIGHT_KEY equ 26 +WS_WIDTH_RIGHT_KEY equ 8 + +WS_SYMBOL_LEFT_KEY equ 27 +WS_WIDTH_LEFT_KEY equ 8 + +WS_SYMBOL_MARGIN_CURSOR equ 28 +WS_WIDTH_MARGIN_CURSOR equ 5 + +WS_SYMBOL_BELL equ 29 +WS_WIDTH_BELL equ 6 + +WS_SYMBOL_UP_ARROWHEAD equ 30 +WS_WIDTH_UP_ARROWHEAD equ 7 + +WS_SYMBOL_NS equ 31 +WS_WIDTH_NS equ 6 + +WS_SYMBOL_POWER2 equ 253 +WS_WIDTH_POWER2 equ 4 + +WS_SYMBOL_BULLET equ 254 +WS_WIDTH_BULLET equ 5 + +; Positioning of special characters in the special array + +H_SC_TPLUS equ 0 ; T is for Tag */ +H_SC_TMINUS equ 1 +H_SC_TSTAR equ 2 +H_SC_TSLASH equ 3 + +H_SC_ILESS equ 4 ; I is for Incrementer +H_SC_ICOMMA equ 5 +H_SC_IMORE equ 6 +H_SC_IDOT equ 7 + +H_SC_HFANCY equ 8 ; H is for Hyphen + +H_SC_LLN equ 9 ; The following are North, South, West, East +H_SC_LLS equ 10 +H_SC_LLW equ 11 +H_SC_LLE equ 12 +H_SC_DEGREE equ 13 ; As used in LatLong editor +H_SC_BULLET equ 14 ; As used in help list diff --git a/code/SIBOSDK/include/sys$ncp.h b/code/SIBOSDK/include/sys$ncp.h new file mode 100644 index 0000000..c303108 --- /dev/null +++ b/code/SIBOSDK/include/sys$ncp.h @@ -0,0 +1,75 @@ +/* +SYS$NCP.H - Header file for NCP defines +*/ + +#define NCLINK_VERSION_NUMBER 3 +#define NCLINK_MINOR_VERNO 1 + +/* Informational data obtained by supervisory reads */ +#define PHYS_LINK_FAILED 0 /* Link layer has failed*/ +#define PHYS_CONNECT_FAILED 1 /* Waiting for connection failed */ +#define PHYS_CHARS_FAILED 2 /* Setting serial characteristics failed */ +#define PHYS_INIT_FAILED 3 /* Initialization of modem failed */ +#define PHYS_DIAL_FAILED 4 /* Dialling phone number failed */ +#define PHYS_MDMCONFIG_FAILED 5 /* additional modem config failed */ +#define PHYS_PHYS_LINK_ESTABLISHED 6 /* A physical link established */ +#define PHYS_WAITING_FOR_CALL 7 /* Physical layer waiting for call */ +#define PHYS_DIALLING_NUMBER 8 /* Physical layer dialling */ +#define PHYS_CONFIGURING_MODEM 9 /* configuring modem */ +#define PHYS_NCP_LINK_ESTAB_OK 10 /* Ncp link established OK */ +#define PHYS_NCP_LINK_ESTAB_NEW_NCP 11 /* Talking to different Ncp */ +#define PHYS_NCP_LINK_ESTAB_INVALID_VER 12 /* Remote NCP is V1.0 !!*/ +#define PHYS_NCP_LINK_END 13 /* remote NCP is terminating */ +#define PHYS_SERCONFIG_FAILED 14 /* serial port not there */ + +#define MAX_DVR_NAME 10 /* Max device driver name size (incl zero term) */ +#define MAX_PHONE_NO 40 /* Max phone number length */ +#define MAX_MODEM_CMD 40 /* Max extra modem config */ + +/* Control functions to perform */ +#define NCLINK_CTRL_RETRY 0 +#define NCLINK_CTRL_EXIT 1 +#define NCLINK_CTRL_NEWNCP_OK 2 +#define NCLINK_CTRL_NEW_CONFIG 3 + +typedef struct + { + P_SRCHAR sch; + P_MDMCHR mch; + UWORD errcorrect; /* what sort of error correction modem using */ + UWORD connectbaud; /* baud rate at which connected */ + UBYTE serdvr[MAX_DVR_NAME]; + UBYTE mdmdvr[MAX_DVR_NAME]; + UBYTE masdvr[MAX_DVR_NAME]; + UBYTE lnkdvr[MAX_DVR_NAME]; + UBYTE phoneno[MAX_PHONE_NO]; + UBYTE mdmconf[MAX_MODEM_CMD]; + } DVRS; + +typedef struct + { + UWORD vers; /* Remote NCP sofware version */ + ULONG id; /* Remote NCP id */ + } REM_NCP; + +typedef union + { + REM_NCP remncp; /* Remote NCP info */ + DVRS dvrs; /* Driver names, phone number */ + } PHY_INFO; + +typedef struct /* Physical layer status information */ + { + UWORD cmdtype; /* Info type */ + WORD errno; /* Error number if applicable to type */ + PHY_INFO p; /* Physical layer info */ + } NCLINK_INFO; + +typedef struct /* Network sense data struct */ + { + UWORD chanused; /* True if channel being used else False */ + ULONG xmitK; /* number K bytes transmitted */ + ULONG recvK; /* number K bytes received */ + UBYTE procname[E_MAX_NAME+2]; /* Process name that owns channel */ + } NCLINK_SREC; + diff --git a/code/SIBOSDK/include/textwin.g b/code/SIBOSDK/include/textwin.g new file mode 100644 index 0000000..86f90be --- /dev/null +++ b/code/SIBOSDK/include/textwin.g @@ -0,0 +1,54 @@ +/* Generated by Ctran from textwin.cl */ +#define TEXTWIN_G +#ifndef LODGER_G +#include +#endif +#ifndef EDIT_G +#include +#endif +/* Class Numbers */ +#define C_TEXTWIN 4 +/* Method Numbers */ +/* Constants for textwin */ +#define PR_TEXTWIN_AL_LEFT 0x00 +#define PR_TEXTWIN_AL_RIGHT 0x01 +#define PR_TEXTWIN_AL_CENTRE 0x02 +#define PR_TEXTWIN_BOLD 0x04 +#define PR_TEXTWIN_BULLET 0x20 +#define PR_TEXTWIN_POPOUT 0x40 +#define PR_TEXTWIN_FLASHING 0x80 +#define IN_TEXTWIN_AL_LEFT PR_TEXTWIN_AL_LEFT +#define IN_TEXTWIN_AL_RIGHT PR_TEXTWIN_AL_RIGHT +#define IN_TEXTWIN_AL_CENTRE PR_TEXTWIN_AL_CENTRE +#define IN_TEXTWIN_BOLD PR_TEXTWIN_BOLD +#define IN_TEXTWIN_BULLET PR_TEXTWIN_BULLET +#define IN_TEXTWIN_POPOUT PR_TEXTWIN_POPOUT +#define SE_TEXTWIN_ALIGN (PR_TEXTWIN_AL_RIGHT|PR_TEXTWIN_AL_CENTRE) +#define SE_TEXTWIN_BOLD PR_TEXTWIN_BOLD +#define SE_TEXTWIN_TEXT 0x08 +#define SE_TEXTWIN_BULLET PR_TEXTWIN_BULLET +/* Types for textwin */ +typedef struct +{ +unsigned short int state; +char label[1]; +}IN_TEXTWIN; +typedef struct +{ +int flags; +unsigned short int state; +char *buf; +unsigned short int len; +}SE_TEXTWIN; +/* Property of textwin */ +typedef struct { +PR_EPFLAT *label; +unsigned short int state; +} PRS_TEXTWIN; +typedef struct pr_textwin +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_TEXTWIN textwin; +} PR_TEXTWIN; diff --git a/code/SIBOSDK/include/textwin.ing b/code/SIBOSDK/include/textwin.ing new file mode 100644 index 0000000..3ecefa1 --- /dev/null +++ b/code/SIBOSDK/include/textwin.ing @@ -0,0 +1,51 @@ +; Generated by Ctran from textwin.cl +TEXTWIN_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +IFNDEF EDIT_ING + INCLUDE ..\inc\EDIT.ING +ENDIF +; Class Numbers +C_TEXTWIN equ 4 +; Method Numbers +; Constants for textwin +PR_TEXTWIN_AL_LEFT equ (000h) +PR_TEXTWIN_AL_RIGHT equ (001h) +PR_TEXTWIN_AL_CENTRE equ (002h) +PR_TEXTWIN_BOLD equ (004h) +PR_TEXTWIN_BULLET equ (020h) +PR_TEXTWIN_POPOUT equ (040h) +PR_TEXTWIN_FLASHING equ (080h) +IN_TEXTWIN_AL_LEFT equ (PR_TEXTWIN_AL_LEFT) +IN_TEXTWIN_AL_RIGHT equ (PR_TEXTWIN_AL_RIGHT) +IN_TEXTWIN_AL_CENTRE equ (PR_TEXTWIN_AL_CENTRE) +IN_TEXTWIN_BOLD equ (PR_TEXTWIN_BOLD) +IN_TEXTWIN_BULLET equ (PR_TEXTWIN_BULLET) +IN_TEXTWIN_POPOUT equ (PR_TEXTWIN_POPOUT) +SE_TEXTWIN_ALIGN equ (PR_TEXTWIN_AL_RIGHT or PR_TEXTWIN_AL_CENTRE) +SE_TEXTWIN_BOLD equ (PR_TEXTWIN_BOLD) +SE_TEXTWIN_TEXT equ (008h) +SE_TEXTWIN_BULLET equ (PR_TEXTWIN_BULLET) +; Types for textwin +IN_TEXTWIN struc +IN_TEXTWINState dw ? +IN_TEXTWINLabel db (1) * 1 dup (?) +IN_TEXTWIN ends +SE_TEXTWIN struc +SE_TEXTWINFlags dw ? +SE_TEXTWINState dw ? +SE_TEXTWINBuf dw ? +SE_TEXTWINLen dw ? +SE_TEXTWIN ends +; Property of textwin +PRS_TEXTWIN struc +TextwinLabel dw ? +TextwinState dw ? +PRS_TEXTWIN ends +PR_TEXTWIN struc +TextwinRoot PRS_ROOT <> +TextwinWin PRS_WIN <> +TextwinLodger PRS_LODGER <> +TextwinTextwin PRS_TEXTWIN <> +PR_TEXTWIN ends diff --git a/code/SIBOSDK/include/time.g b/code/SIBOSDK/include/time.g new file mode 100644 index 0000000..e4d6f71 --- /dev/null +++ b/code/SIBOSDK/include/time.g @@ -0,0 +1,93 @@ +/* Generated by Ctran from time.cat */ +#define TIME_G +#ifndef OLIB_G +#include +#endif +#ifndef P_DATE_H +#include +#endif +/* Class Numbers */ +#define C_TIME 40 +/* Method Numbers */ +#define O_TO_ADD_SECS 6 +#define O_TO_ADD_MONTHS 4 +#define O_TO_GET_SYSDAT 9 +#define O_TO_ADD_YEARS 3 +#define O_TO_SENSE 2 +#define O_TO_SENSE_FORMAT 8 +#define O_TO_SET 1 +#define O_TO_SET_FORMAT 7 +#define O_TO_ADD_DAYS 5 +/* Constants for time */ +#define SET_TIME_SECONDS 0 +#define SET_TIME_DATE 1 +#define SET_TIME_DAYSEC 2 +#define SET_TIME_NOW 3 +#define SET_TIME_DATESTR 4 +#define SET_TIME_TIMESTR 5 +#define SENSE_TIME_SECONDS 0 +#define SENSE_TIME_DATE 1 +#define SENSE_TIME_DAYSEC 2 +#define SENSE_TIME_STRING 3 +#define SENSE_TIME_DATESTR 4 +#define SENSE_TIME_TIMESTR 5 +#define SENSE_TIME_FIELDS 0x8000 +#define FLD_TIME_DAY 0 +#define FLD_TIME_MONTH 1 +#define FLD_TIME_YEAR 2 +#define FLD_TIME_HOUR 3 +#define FLD_TIME_MINUTE 4 +#define FLD_TIME_SECOND 5 +#define FLD_TIME_DAYNAME 6 +#define PR_TIME_DDMMYY 0x0000 +#define PR_TIME_MMDDYY 0x0001 +#define PR_TIME_YYMMDD 0x0002 +#define PR_TIME_DATE_ORDER 0x0003 +#define PR_TIME_NO_DAY 0x0004 +#define PR_TIME_NO_MONTH 0x0008 +#define PR_TIME_NO_YEAR 0x0010 +#define PR_TIME_MONTH_NAME 0x0020 +#define PR_TIME_SUFFIX_NAME 0x0040 +#define PR_TIME_DAY_NAME 0x0080 +#define PR_TIME_NO_CENTURY 0x0100 +#define PR_TIME_NO_SECS 0x0200 +#define PR_TIME_AMPM 0x0400 +#define TY_TIME_DAY 0 +#define TY_TIME_MONTH 1 +#define TY_TIME_SUFFIX 2 +#define TY_TIME_AMPM 3 +#define TY_TIME_FORMAT 4 +#define LN_TIME_DAY_NAME 14 +#define LN_TIME_MONTH_NAME 14 +#define LN_TIME_DATE_STR 48 +#define LN_TIME_TIME_STR 12 +/* Types for time */ +typedef struct +{ +unsigned short int flags; +unsigned char dsep; +unsigned char tsep; +} SE_TIME_FORMAT; +typedef struct +{ +unsigned short int fld; +char *buf; +unsigned short int len; +} SE_TIME_FIELD; +typedef union +{ +char *t; +unsigned long int *l; +P_DAYSEC *ds; +P_DATE *dt; +} PT_TIME_DATA; +/* Property of time */ +typedef struct { +P_DAYSEC ds; +SE_TIME_FORMAT f; +} PRS_TIME; +typedef struct pr_time +{ +PRS_ROOT root; +PRS_TIME time; +} PR_TIME; diff --git a/code/SIBOSDK/include/time.h b/code/SIBOSDK/include/time.h new file mode 100644 index 0000000..bd9d00a --- /dev/null +++ b/code/SIBOSDK/include/time.h @@ -0,0 +1,107 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* time.h - structure and function definitions for time. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _TIME_INC_ +#define _TIME_INC_ + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +#ifndef _TIME_DEF +#define _TIME_DEF +typedef long time_t; +#endif +typedef long clock_t; +#define CLK_TCK 100 +#define CLOCKS_PER_SEC 100 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef _TM_DEF +#define _TM_DEF +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; +#endif + +#ifndef _TMT_DEF +#define _TMT_DEF +struct date { + int da_year; + unsigned char da_day; + unsigned char da_mon; +}; + +struct time { + unsigned char ti_hour; + unsigned char ti_min; + unsigned char ti_sec; + unsigned char ti_hund; +}; +#endif + +#ifndef _UTMT_DEF +#define _UTMT_DEF +struct utm { int u_sec; + int u_min; + int u_hour; + int u_day; + int u_mon; + int u_year; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern char * asctime(const struct tm *_tblock); +extern char * ctime(const time_t *_timer); +extern clock_t clock(void); +extern double difftime(time_t _time2, time_t _time1); +extern struct tm * gmtime(const time_t *_timer); +extern struct tm * localtime(const time_t *_timer); +extern time_t mktime(struct tm *_timeptr); +extern size_t strftime(char *_s, size_t _maxsize, const char *_format, + const struct tm *_timeptr); +extern time_t time(time_t *_timer); +extern int stime(time_t *_tp); +extern void tzset(void); +extern void settime(const struct time *_tptr); +extern void gettime(struct time *_tptr); +extern void setdate(const struct date *_dptr); +extern void getdate(struct date *_dptr); +extern char * _strdate(char *_dt); +extern char * _strtime(char *_tm); +extern int utime(char *_path, struct utm *_time); +extern time_t get_utime(int _handle); +extern int _filetime(int _handle, struct utm *_ubuf); +#ifdef __cplusplus +} +#endif + +extern time_t timezone; +extern int daylight; +#endif diff --git a/code/SIBOSDK/include/time.ing b/code/SIBOSDK/include/time.ing new file mode 100644 index 0000000..96d55b8 --- /dev/null +++ b/code/SIBOSDK/include/time.ing @@ -0,0 +1,89 @@ +; Generated by Ctran from time.cat +TIME_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF P_DATE_INC + INCLUDE ..\inc\P_DATE.INC +ENDIF +; Class Numbers +C_TIME equ 40 +; Method Numbers +O_TO_ADD_SECS equ 6 +O_TO_ADD_MONTHS equ 4 +O_TO_GET_SYSDAT equ 9 +O_TO_ADD_YEARS equ 3 +O_TO_SENSE equ 2 +O_TO_SENSE_FORMAT equ 8 +O_TO_SET equ 1 +O_TO_SET_FORMAT equ 7 +O_TO_ADD_DAYS equ 5 +; Constants for time +SET_TIME_SECONDS equ (0) +SET_TIME_DATE equ (1) +SET_TIME_DAYSEC equ (2) +SET_TIME_NOW equ (3) +SET_TIME_DATESTR equ (4) +SET_TIME_TIMESTR equ (5) +SENSE_TIME_SECONDS equ (0) +SENSE_TIME_DATE equ (1) +SENSE_TIME_DAYSEC equ (2) +SENSE_TIME_STRING equ (3) +SENSE_TIME_DATESTR equ (4) +SENSE_TIME_TIMESTR equ (5) +SENSE_TIME_FIELDS equ (08000h) +FLD_TIME_DAY equ (0) +FLD_TIME_MONTH equ (1) +FLD_TIME_YEAR equ (2) +FLD_TIME_HOUR equ (3) +FLD_TIME_MINUTE equ (4) +FLD_TIME_SECOND equ (5) +FLD_TIME_DAYNAME equ (6) +PR_TIME_DDMMYY equ (00000h) +PR_TIME_MMDDYY equ (00001h) +PR_TIME_YYMMDD equ (00002h) +PR_TIME_DATE_ORDER equ (00003h) +PR_TIME_NO_DAY equ (00004h) +PR_TIME_NO_MONTH equ (00008h) +PR_TIME_NO_YEAR equ (00010h) +PR_TIME_MONTH_NAME equ (00020h) +PR_TIME_SUFFIX_NAME equ (00040h) +PR_TIME_DAY_NAME equ (00080h) +PR_TIME_NO_CENTURY equ (00100h) +PR_TIME_NO_SECS equ (00200h) +PR_TIME_AMPM equ (00400h) +TY_TIME_DAY equ (0) +TY_TIME_MONTH equ (1) +TY_TIME_SUFFIX equ (2) +TY_TIME_AMPM equ (3) +TY_TIME_FORMAT equ (4) +LN_TIME_DAY_NAME equ (14) +LN_TIME_MONTH_NAME equ (14) +LN_TIME_DATE_STR equ (48) +LN_TIME_TIME_STR equ (12) +; Types for time +SE_TIME_FORMAT struc +SE_TIME_FORMATFlags dw ? +SE_TIME_FORMATDsep db ? +SE_TIME_FORMATTsep db ? +SE_TIME_FORMAT ends +SE_TIME_FIELD struc +SE_TIME_FIELDFld dw ? +SE_TIME_FIELDBuf dw ? +SE_TIME_FIELDLen dw ? +SE_TIME_FIELD ends +PT_TIME_DATA union +PT_TIME_DATAT dw ? +PT_TIME_DATAL dw ? +PT_TIME_DATADs dw ? +PT_TIME_DATADt dw ? +PT_TIME_DATA ends +; Property of time +PRS_TIME struc +TimeDs P_DAYSEC <> +TimeF SE_TIME_FORMAT <> +PRS_TIME ends +PR_TIME struc +TimeRoot PRS_ROOT <> +TimeTime PRS_TIME <> +PR_TIME ends diff --git a/code/SIBOSDK/include/timeb.h b/code/SIBOSDK/include/timeb.h new file mode 100644 index 0000000..35d071b --- /dev/null +++ b/code/SIBOSDK/include/timeb.h @@ -0,0 +1,36 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* timeb.h - header file for ftime. * +* * +* COPYRIGHT (C) 1989, 1990 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _TIMEB_INC_ +#define _TIMEB_INC_ + +#ifndef _TIME_DEF +#define _TIME_DEF +typedef long time_t; +#endif + +/* structure returned by ftime */ + +struct timeb { + time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +#ifdef __cplusplus +extern "C" { +#endif +extern void ftime(struct timeb *); +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/SIBOSDK/include/timer.g b/code/SIBOSDK/include/timer.g new file mode 100644 index 0000000..40521db --- /dev/null +++ b/code/SIBOSDK/include/timer.g @@ -0,0 +1,70 @@ +/* Generated by Ctran from timer.cat */ +#define TIMER_G +#ifndef APPMAN_G +#include +#endif +/* Class Numbers */ +#define C_TIMER 41 +#define C_BUZSND 42 +#define C_ALARR 43 +#define C_ANIMATOR 44 +/* Method Numbers */ +#define O_VA_CANCEL 25 +#define O_VA_CONFIRM 24 +#define O_TM_QABSOLUTE 6 +/* Property of timer */ +typedef struct pr_timer +{ +PRS_ROOT root; +PRS_ACTIVE active; +} PR_TIMER; +/* Property of buzsnd */ +typedef struct { +unsigned char *snd; +unsigned short int sndrep; +unsigned short int sndnum; +unsigned short int snddelay; +unsigned short int sndvolume; +PR_ROOT *h_done; +unsigned short int m_done; +} PRS_BUZSND; +typedef struct pr_buzsnd +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_BUZSND buzsnd; +} PR_BUZSND; +/* Constants for alarr */ +#define ALARR_GRAN 8 +/* Property of alarr */ +typedef struct { +RC_VAXVAR rec; +} PRS_ALARR; +typedef struct pr_alarr +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VAFLAT vaflat; +PRS_ALARR alarr; +} PR_ALARR; +/* Types for animator */ +typedef struct +{ +PR_ROOT *own; +int message; +int interval; +int first; +} IN_ANIMATOR; +/* Property of animator */ +typedef struct { +PR_ROOT *own; +int message; +int interval; +} PRS_ANIMATOR; +typedef struct pr_animator +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_ANIMATOR animator; +} PR_ANIMATOR; diff --git a/code/SIBOSDK/include/timer.ing b/code/SIBOSDK/include/timer.ing new file mode 100644 index 0000000..958fd26 --- /dev/null +++ b/code/SIBOSDK/include/timer.ing @@ -0,0 +1,65 @@ +; Generated by Ctran from timer.cat +TIMER_ING equ 1 +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +; Class Numbers +C_TIMER equ 41 +C_BUZSND equ 42 +C_ALARR equ 43 +C_ANIMATOR equ 44 +; Method Numbers +O_VA_CANCEL equ 25 +O_VA_CONFIRM equ 24 +O_TM_QABSOLUTE equ 6 +; Property of timer +PR_TIMER struc +TimerRoot PRS_ROOT <> +TimerActive PRS_ACTIVE <> +PR_TIMER ends +; Property of buzsnd +PRS_BUZSND struc +BuzsndSnd dw ? +BuzsndSndrep dw ? +BuzsndSndnum dw ? +BuzsndSnddelay dw ? +BuzsndSndvolume dw ? +BuzsndH_done dw ? +BuzsndM_done dw ? +PRS_BUZSND ends +PR_BUZSND struc +BuzsndRoot PRS_ROOT <> +BuzsndActive PRS_ACTIVE <> +BuzsndBuzsnd PRS_BUZSND <> +PR_BUZSND ends +; Constants for alarr +ALARR_GRAN equ (8) +; Property of alarr +PRS_ALARR struc +AlarrRec RC_VAXVAR <> +PRS_ALARR ends +PR_ALARR struc +AlarrRoot PRS_ROOT <> +AlarrVaroot PRS_VAROOT <> +AlarrVafix PRS_VAFIX <> +AlarrVaflat PRS_VAFLAT <> +AlarrAlarr PRS_ALARR <> +PR_ALARR ends +; Types for animator +IN_ANIMATOR struc +IN_ANIMATOROwn dw ? +IN_ANIMATORMessage dw ? +IN_ANIMATORInterval dw ? +IN_ANIMATORFirst dw ? +IN_ANIMATOR ends +; Property of animator +PRS_ANIMATOR struc +AnimatorOwn dw ? +AnimatorMessage dw ? +AnimatorInterval dw ? +PRS_ANIMATOR ends +PR_ANIMATOR struc +AnimatorRoot PRS_ROOT <> +AnimatorActive PRS_ACTIVE <> +AnimatorAnimator PRS_ANIMATOR <> +PR_ANIMATOR ends diff --git a/code/SIBOSDK/include/tlvfile.g b/code/SIBOSDK/include/tlvfile.g new file mode 100644 index 0000000..716f9e3 --- /dev/null +++ b/code/SIBOSDK/include/tlvfile.g @@ -0,0 +1,238 @@ +/* Generated by Ctran from tlvfile.cat */ +#define TLVFILE_G +#ifndef APPMAN_G +#include +#endif +#ifndef P_FILE_H +#include +#endif +#ifndef P_SERIAL_H +#include +#endif +#ifndef P_MODEM_H +#include +#endif +/* Class Numbers */ +#define C_BFILE 45 +#define C_TLVFILE 46 +#define C_TLVDATA 47 +#define C_SERFILE 48 +#define C_PRINT 49 +#define C_SERIAL 50 +/* Method Numbers */ +#define O_TD_SAVE_ITEM 5 +#define O_TD_SENSE_ITEM 9 +#define O_FL_SET_BUF_LEN 3 +#define O_FL_SENSE_REC 12 +#define O_FL_REPLACE 13 +#define O_FL_DELREC 8 +#define O_TD_SET_ITEM 8 +#define O_TD_SAVE 2 +#define O_TD_OPEN 1 +#define O_FI_OPEN 5 +#define O_FL_SET_REC 11 +#define O_FL_WRITE_REC 7 +#define O_SR_FLUSH 10 +#define O_TD_LOAD_ITEM 4 +#define O_FI_CLOSE 1 +#define O_TD_SET_FILE 7 +#define O_TD_CHANGED 3 +#define O_FI_READ 2 +#define O_FL_SENSE_DATA 4 +#define O_FL_REWIND 6 +#define O_SR_CONTROL 11 +#define O_FL_COUNT 9 +#define O_SR_SENSE 9 +#define O_SR_ENQUIRE 12 +#define O_TD_RESET 6 +#define O_SR_GRAB 13 +#define O_PR_GET_DATA 6 +#define O_FL_READ_BY_TYPE 10 +#define O_SR_TEST 7 +#define O_SR_SET 8 +#define O_SR_WRITE 6 +/* Constants for bfile */ +#define OP_BFILE_ID_SIZE 16 +/* Types for bfile */ +typedef struct +{ +char fid[OP_BFILE_ID_SIZE]; +unsigned short int vers; +unsigned short int offset; +unsigned short int rtvers; +} OP_BFILE_FSIG; +/* Property of bfile */ +typedef struct { +unsigned char *pcb; +unsigned char *rbuf; +unsigned short int rlen; +unsigned short int offset; +} PRS_BFILE; +typedef struct pr_bfile +{ +PRS_ROOT root; +PRS_BFILE bfile; +} PR_BFILE; +/* Constants for tlvfile */ +#define TLV_TYPE_UNKNOWN 0x10 +#define TLV_TYPE_INVALID 0x0f +#define TLV_TYPE_DELETED 0x00 +#define TLV_TYPE_NORMAL 0x01 +#define TLV_TYPE_FIELDS 0x02 +#define TLV_TYPE_SHIFT 12 +#define TLV_TYPE_MASK 0xf000 +/* Types for tlvfile */ +typedef struct +{ +OP_BFILE_FSIG fsig; +unsigned short int types; +} OP_TLVFILE; +typedef struct +{ +unsigned char *buf; +unsigned int len; +int type; +} OP_TLV_REC; +/* Property of tlvfile */ +typedef struct { +unsigned short int typmask; +unsigned short int hdlen; +unsigned short int hdtype; +unsigned long int pos; +unsigned long int fpos; +} PRS_TLVFILE; +typedef struct pr_tlvfile +{ +PRS_ROOT root; +PRS_BFILE bfile; +PRS_TLVFILE tlvfile; +} PR_TLVFILE; +/* Types for tlvdata */ +typedef struct +{ +OP_TLVFILE tlvfile; +char ext[6]; +} PR_TLVDATA_CHARS; +/* Property of tlvdata */ +typedef struct { +PR_TLVFILE *tlv; +unsigned short int cl_tlv; +unsigned short int changed; +short int index; +short int tmask; +char name[P_FNAMESIZE]; +} PRS_TLVDATA; +typedef struct pr_tlvdata +{ +PRS_ROOT root; +PRS_TLVDATA tlvdata; +} PR_TLVDATA; +/* Constants for serfile */ +#define TE_MASK_SERIAL 0x0001 +#define TE_MASK_MODEM 0x0002 +#define TE_MASK_FILE 0x0004 +#define TY_SERFILE_SERIAL 1 +#define OBSOLETE_SERFILE_MODEM 2 +#define TY_SERFILE_FILE 3 +#define TY_SERFILE_NEW_MODEM 4 +#define TY_SERFILE_SERDVR 5 +#define TY_SERFILE_LNKDVR 6 +#define TE_XMDM_NONE 3 +#define TE_DIAL_PULSE 1 +#define TE_DIAL_TONE 2 +#define TE_MODEM_300 0x01 +#define TE_MODEM_1200 0x02 +#define TE_MODEM_2400 0x03 +#define TE_MODEM_4800 0x04 +#define TE_MODEM_9600 0x05 +#define TE_MODEM_19200 0x06 +#define MAX_DEVICE_NAME 10 +#define MAX_MODEM_CMD 40 +/* Types for serfile */ +typedef struct +{ +P_SRCHAR ch; +char port[P_MAXDEVNAME+2]; +} PF_SERIAL; +typedef struct +{ +P_MDMCHR mch; +unsigned char phone[25]; +unsigned char auto_dial; +unsigned char mdmdvr[MAX_DEVICE_NAME]; +unsigned char mdmcmd[MAX_MODEM_CMD]; +unsigned char spare[16]; +} PF_MODEM; +typedef struct +{ +unsigned short int protocol; +} PF_FILE; +typedef struct +{ +P_SRCHAR ch; +unsigned char serdvr[MAX_DEVICE_NAME]; +unsigned char spare[16]; +} PF_SERDVR; +typedef struct +{ +unsigned char masdvr[MAX_DEVICE_NAME]; +unsigned char lnkdvr[MAX_DEVICE_NAME]; +unsigned char spare[16]; +} PF_LNKDVR; +/* Property of serfile */ +typedef struct { +PF_SERIAL serial; +PF_MODEM modem; +PF_FILE file; +PF_LNKDVR lnkdvr; +PF_SERDVR serdvr; +} PRS_SERFILE; +typedef struct pr_serfile +{ +PRS_ROOT root; +PRS_TLVDATA tlvdata; +PRS_SERFILE serfile; +} PR_SERFILE; +/* Constants for print */ +#define PRINT_DATA 0x0 +#define PRINT_LINE 0x1 +#define PRINT_FINISH 0x8 +/* Types for print */ +typedef struct +{ +unsigned char *buf; +unsigned short int len; +unsigned short int status; +} PRINT_STATE; +/* Property of print */ +typedef struct { +PRINT_STATE state; +unsigned char crlf[2]; +} PRS_PRINT; +typedef struct pr_print +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_PRINT print; +} PR_PRINT; +/* Constants for serial */ +#define READ_QUEUED 0x01 +#define WRITE_QUEUED 0x02 +/* Property of serial */ +typedef struct { +unsigned short int flags; +short int rstat; +short int wstat; +unsigned short int rlen; +unsigned char *rbuf; +unsigned short int wlen; +unsigned char *wbuf; +unsigned short int rsize; +unsigned short int wsize; +} PRS_SERIAL; +typedef struct pr_serial +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_SERIAL serial; +} PR_SERIAL; diff --git a/code/SIBOSDK/include/tlvfile.ing b/code/SIBOSDK/include/tlvfile.ing new file mode 100644 index 0000000..2f2d5c8 --- /dev/null +++ b/code/SIBOSDK/include/tlvfile.ing @@ -0,0 +1,222 @@ +; Generated by Ctran from tlvfile.cat +TLVFILE_ING equ 1 +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +IFNDEF P_FILE_INC + INCLUDE ..\inc\P_FILE.INC +ENDIF +IFNDEF P_SERIAL_INC + INCLUDE ..\inc\P_SERIAL.INC +ENDIF +IFNDEF P_MODEM_INC + INCLUDE ..\inc\P_MODEM.INC +ENDIF +; Class Numbers +C_BFILE equ 45 +C_TLVFILE equ 46 +C_TLVDATA equ 47 +C_SERFILE equ 48 +C_PRINT equ 49 +C_SERIAL equ 50 +; Method Numbers +O_TD_SAVE_ITEM equ 5 +O_TD_SENSE_ITEM equ 9 +O_FL_SET_BUF_LEN equ 3 +O_FL_SENSE_REC equ 12 +O_FL_REPLACE equ 13 +O_FL_DELREC equ 8 +O_TD_SET_ITEM equ 8 +O_TD_SAVE equ 2 +O_TD_OPEN equ 1 +O_FI_OPEN equ 5 +O_FL_SET_REC equ 11 +O_FL_WRITE_REC equ 7 +O_SR_FLUSH equ 10 +O_TD_LOAD_ITEM equ 4 +O_FI_CLOSE equ 1 +O_TD_SET_FILE equ 7 +O_TD_CHANGED equ 3 +O_FI_READ equ 2 +O_FL_SENSE_DATA equ 4 +O_FL_REWIND equ 6 +O_SR_CONTROL equ 11 +O_FL_COUNT equ 9 +O_SR_SENSE equ 9 +O_SR_ENQUIRE equ 12 +O_TD_RESET equ 6 +O_SR_GRAB equ 13 +O_PR_GET_DATA equ 6 +O_FL_READ_BY_TYPE equ 10 +O_SR_TEST equ 7 +O_SR_SET equ 8 +O_SR_WRITE equ 6 +; Constants for bfile +OP_BFILE_ID_SIZE equ (16) +; Types for bfile +OP_BFILE_FSIG struc +OP_BFILE_FSIGFid db (1) * OP_BFILE_ID_SIZE dup (?) +OP_BFILE_FSIGVers dw ? +OP_BFILE_FSIGOffset dw ? +OP_BFILE_FSIGRtvers dw ? +OP_BFILE_FSIG ends +; Property of bfile +PRS_BFILE struc +BfilePcb dw ? +BfileRbuf dw ? +BfileRlen dw ? +BfileOffset dw ? +PRS_BFILE ends +PR_BFILE struc +BfileRoot PRS_ROOT <> +BfileBfile PRS_BFILE <> +PR_BFILE ends +; Constants for tlvfile +TLV_TYPE_UNKNOWN equ (010h) +TLV_TYPE_INVALID equ (00fh) +TLV_TYPE_DELETED equ (000h) +TLV_TYPE_NORMAL equ (001h) +TLV_TYPE_FIELDS equ (002h) +TLV_TYPE_SHIFT equ (12) +TLV_TYPE_MASK equ (0f000h) +; Types for tlvfile +OP_TLVFILE struc +OP_TLVFILEFsig OP_BFILE_FSIG <> +OP_TLVFILETypes dw ? +OP_TLVFILE ends +OP_TLV_REC struc +OP_TLV_RECBuf dw ? +OP_TLV_RECLen dw ? +OP_TLV_RECType dw ? +OP_TLV_REC ends +; Property of tlvfile +PRS_TLVFILE struc +TlvfileTypmask dw ? +TlvfileHdlen dw ? +TlvfileHdtype dw ? +TlvfilePos dd ? +TlvfileFpos dd ? +PRS_TLVFILE ends +PR_TLVFILE struc +TlvfileRoot PRS_ROOT <> +TlvfileBfile PRS_BFILE <> +TlvfileTlvfile PRS_TLVFILE <> +PR_TLVFILE ends +; Types for tlvdata +PR_TLVDATA_CHARS struc +PR_TLVDATA_CHARSTlvfile OP_TLVFILE <> +PR_TLVDATA_CHARSExt db (1) * 6 dup (?) +PR_TLVDATA_CHARS ends +; Property of tlvdata +PRS_TLVDATA struc +TlvdataTlv dw ? +TlvdataCl_tlv dw ? +TlvdataChanged dw ? +TlvdataIndex dw ? +TlvdataTmask dw ? +TlvdataName db (1) * P_FNAMESIZE dup (?) +PRS_TLVDATA ends +PR_TLVDATA struc +TlvdataRoot PRS_ROOT <> +TlvdataTlvdata PRS_TLVDATA <> +PR_TLVDATA ends +; Constants for serfile +TE_MASK_SERIAL equ (00001h) +TE_MASK_MODEM equ (00002h) +TE_MASK_FILE equ (00004h) +TY_SERFILE_SERIAL equ (1) +OBSOLETE_SERFILE_MODEM equ (2) +TY_SERFILE_FILE equ (3) +TY_SERFILE_NEW_MODEM equ (4) +TY_SERFILE_SERDVR equ (5) +TY_SERFILE_LNKDVR equ (6) +TE_XMDM_NONE equ (3) +TE_DIAL_PULSE equ (1) +TE_DIAL_TONE equ (2) +TE_MODEM_300 equ (001h) +TE_MODEM_1200 equ (002h) +TE_MODEM_2400 equ (003h) +TE_MODEM_4800 equ (004h) +TE_MODEM_9600 equ (005h) +TE_MODEM_19200 equ (006h) +MAX_DEVICE_NAME equ (10) +MAX_MODEM_CMD equ (40) +; Types for serfile +PF_SERIAL struc +PF_SERIALCh P_SRCHAR <> +PF_SERIALPort db (1) * P_MAXDEVNAME+2 dup (?) +PF_SERIAL ends +PF_MODEM struc +PF_MODEMMch P_MDMCHR <> +PF_MODEMPhone db (1) * 25 dup (?) +PF_MODEMAuto_dial db ? +PF_MODEMMdmdvr db (1) * MAX_DEVICE_NAME dup (?) +PF_MODEMMdmcmd db (1) * MAX_MODEM_CMD dup (?) +PF_MODEMSpare db (1) * 16 dup (?) +PF_MODEM ends +PF_FILE struc +PF_FILEProtocol dw ? +PF_FILE ends +PF_SERDVR struc +PF_SERDVRCh P_SRCHAR <> +PF_SERDVRSerdvr db (1) * MAX_DEVICE_NAME dup (?) +PF_SERDVRSpare db (1) * 16 dup (?) +PF_SERDVR ends +PF_LNKDVR struc +PF_LNKDVRMasdvr db (1) * MAX_DEVICE_NAME dup (?) +PF_LNKDVRLnkdvr db (1) * MAX_DEVICE_NAME dup (?) +PF_LNKDVRSpare db (1) * 16 dup (?) +PF_LNKDVR ends +; Property of serfile +PRS_SERFILE struc +SerfileSerial PF_SERIAL <> +SerfileModem PF_MODEM <> +SerfileFile PF_FILE <> +SerfileLnkdvr PF_LNKDVR <> +SerfileSerdvr PF_SERDVR <> +PRS_SERFILE ends +PR_SERFILE struc +SerfileRoot PRS_ROOT <> +SerfileTlvdata PRS_TLVDATA <> +SerfileSerfile PRS_SERFILE <> +PR_SERFILE ends +; Constants for print +PRINT_DATA equ (00h) +PRINT_LINE equ (01h) +PRINT_FINISH equ (08h) +; Types for print +PRINT_STATE struc +PRINT_STATEBuf dw ? +PRINT_STATELen dw ? +PRINT_STATEStatus dw ? +PRINT_STATE ends +; Property of print +PRS_PRINT struc +PrintState PRINT_STATE <> +PrintCrlf db (1) * 2 dup (?) +PRS_PRINT ends +PR_PRINT struc +PrintRoot PRS_ROOT <> +PrintActive PRS_ACTIVE <> +PrintPrint PRS_PRINT <> +PR_PRINT ends +; Constants for serial +READ_QUEUED equ (001h) +WRITE_QUEUED equ (002h) +; Property of serial +PRS_SERIAL struc +SerialFlags dw ? +SerialRstat dw ? +SerialWstat dw ? +SerialRlen dw ? +SerialRbuf dw ? +SerialWlen dw ? +SerialWbuf dw ? +SerialRsize dw ? +SerialWsize dw ? +PRS_SERIAL ends +PR_SERIAL struc +SerialRoot PRS_ROOT <> +SerialActive PRS_ACTIVE <> +SerialSerial PRS_SERIAL <> +PR_SERIAL ends diff --git a/code/SIBOSDK/include/types.h b/code/SIBOSDK/include/types.h new file mode 100644 index 0000000..f0f6685 --- /dev/null +++ b/code/SIBOSDK/include/types.h @@ -0,0 +1,31 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* types.h - common types * +* * +* COPYRIGHT (C) 1988 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _INO_DEF +typedef unsigned short ino_t; /* i-node number */ +#define _INO_DEF +#endif + +#ifndef _TIME_DEF +typedef long time_t; +#define _TIME_DEF +#endif + +#ifndef _DEV_DEF +typedef short dev_t; /* device code */ +#define _DEV_DEF +#endif + +#ifndef _OFF_DEF +typedef long off_t; /* file offset value */ +#define _OFF_DEF +#endif + diff --git a/code/SIBOSDK/include/values.h b/code/SIBOSDK/include/values.h new file mode 100644 index 0000000..9b1cc5e --- /dev/null +++ b/code/SIBOSDK/include/values.h @@ -0,0 +1,38 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* values.h - Value ranges for common data types. * +* * +* COPYRIGHT (C) 1988 Jensen and Partners. All Rights Reserved. * +* * +*--------------------------------------------------------------------------*/ +#include + +#ifndef _VALUES_INC_ +#define _VALUES_INC_ + +#define MAXCHAR 127 +#define MINCHAR -128 +#define MAXUCHAR 255 +#define MINUCHAR 0 +#define MAXSHORT 32767 +#define MINSHORT ((-32767)-1) +#define MAXINT 32767 +#define MININT ((-32767)-1) +#define MAXUINT 65535U +#define MINUINT 0 +#define MAXLONG 2147483647L +#define MINLONG ((-2147483647L)-1) +#define MAXULONG 4294967295UL +#define MINULONG 0 +#define DMAXEXP 308 +#define FMAXEXP 38 +#define DMINEXP -307 +#define FMINEXP -37 +#define MAXDOUBLE 1.797693e+308 +#define MAXFLOAT 3.402823e+38 +#define MINDOUBLE 2.225074e-308 +#define MINFLOAT 1.175494e-38 + +#endif diff --git a/code/SIBOSDK/include/vares.g b/code/SIBOSDK/include/vares.g new file mode 100644 index 0000000..31cc67b --- /dev/null +++ b/code/SIBOSDK/include/vares.g @@ -0,0 +1,18 @@ +/* Generated by Ctran from vares.cl */ +#define VARES_G +#ifndef VARRAY_G +#include +#endif +/* Class Numbers */ +#define C_VARES 20 +/* Method Numbers */ +/* Property of vares */ +typedef struct { +unsigned char *data; +} PRS_VARES; +typedef struct pr_vares +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VARES vares; +} PR_VARES; diff --git a/code/SIBOSDK/include/vares.ing b/code/SIBOSDK/include/vares.ing new file mode 100644 index 0000000..b7c4c0c --- /dev/null +++ b/code/SIBOSDK/include/vares.ing @@ -0,0 +1,17 @@ +; Generated by Ctran from vares.cl +VARES_ING equ 1 +IFNDEF VARRAY_ING + INCLUDE ..\inc\VARRAY.ING +ENDIF +; Class Numbers +C_VARES equ 20 +; Method Numbers +; Property of vares +PRS_VARES struc +VaresData dw ? +PRS_VARES ends +PR_VARES struc +VaresRoot PRS_ROOT <> +VaresVaroot PRS_VAROOT <> +VaresVares PRS_VARES <> +PR_VARES ends diff --git a/code/SIBOSDK/include/varray.g b/code/SIBOSDK/include/varray.g new file mode 100644 index 0000000..42ce9f5 --- /dev/null +++ b/code/SIBOSDK/include/varray.g @@ -0,0 +1,166 @@ +/* Generated by Ctran from varray.cat */ +#define VARRAY_G +#ifndef OLIB_G +#include +#endif +#ifndef P_QUE_H +#include +#endif +/* Class Numbers */ +#define C_VAROOT 1 +#define C_VAFIX 2 +#define C_VAFLAT 3 +#define C_SGBUF 4 +#define C_VASEG 5 +#define C_VASTR 6 +#define C_VAXVAR 7 +#define C_VAXVARS 8 +/* Method Numbers */ +#define O_VA_COPY 14 +#define O_SB_INIT 1 +#define O_VA_FINDISQ 5 +#define O_VA_TEST 12 +#define O_SB_DELETE 4 +#define O_VA_INIT 17 +#define O_VA_REPLACE 13 +#define O_SB_INSERT 3 +#define O_VA_RECLEN 15 +#define O_VA_APPEND 7 +#define O_VA_RESET 11 +#define O_VA_DELETE 2 +#define O_VA_INSERT 8 +#define O_SB_POINT 2 +#define O_VA_DELETEM 18 +#define O_SB_COMPRESS 6 +#define O_VA_SORT 3 +#define O_VA_PBUF 21 +#define O_VA_INSERTM 19 +#define O_VA_PREC 20 +#define O_SB_COUNT 7 +#define O_VA_COMPARE 10 +#define O_SB_ALLOCSEG 9 +#define O_VA_INSERTISQ 6 +#define O_VA_COMPRESS 23 +#define O_VA_KEY 4 +#define O_SB_BACKPOINT 8 +#define O_VA_SWAP 16 +#define O_VA_COUNT 1 +#define O_VA_CAPACITY 22 +#define O_VA_SEARCH 9 +#define O_SB_EXTRACT 5 +/* Constants for varoot */ +#define VA_ROOT_DUPLICATE 1 +#define VA_ROOT_FLG_FOLD 0x01 +#define VA_ROOT_FLG_DESC 0x02 +/* Types for varoot */ +typedef struct +{ +unsigned char ofs; +unsigned char len; +unsigned char fold; +unsigned char desc; +} PR_VAROOT_KEY; +/* Property of varoot */ +typedef struct { +unsigned short int nrec; +PR_VAROOT_KEY key; +} PRS_VAROOT; +typedef struct pr_varoot +{ +PRS_ROOT root; +PRS_VAROOT varoot; +} PR_VAROOT; +/* Property of vafix */ +typedef struct { +unsigned short int rlen; +} PRS_VAFIX; +typedef struct pr_vafix +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +} PR_VAFIX; +/* Property of vaflat */ +typedef struct { +unsigned short int gran; +unsigned short int nspc; +unsigned char *base; +} PRS_VAFLAT; +typedef struct pr_vaflat +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VAFLAT vaflat; +} PR_VAFLAT; +/* Types for sgbuf */ +typedef struct +{ +P_QUE q; +unsigned short int len; +} PR_SGBUF_HD; +typedef struct +{ +PR_SGBUF_HD *seg; +unsigned short int base; +unsigned short int ofs; +} PR_SGBUF_SBO; +/* Property of sgbuf */ +typedef struct { +PR_SGBUF_HD hd; +unsigned short int nbytes; +PR_SGBUF_SBO cur; +} PRS_SGBUF; +typedef struct pr_sgbuf +{ +PRS_ROOT root; +PRS_SGBUF sgbuf; +} PR_SGBUF; +/* Property of vaseg */ +typedef struct { +PR_SGBUF *buf; +} PRS_VASEG; +typedef struct pr_vaseg +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VASEG vaseg; +} PR_VASEG; +/* Property of vastr */ +typedef struct { +unsigned short int size; +unsigned short int gran; +unsigned char *base; +unsigned short int len; +unsigned short int num; +unsigned char *pnum; +} PRS_VASTR; +typedef struct pr_vastr +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VASTR vastr; +} PR_VASTR; +/* Types for vaxvar */ +typedef struct +{ +unsigned short int len; +unsigned char *buf; +} RC_VAXVAR; +/* Property of vaxvar */ +typedef struct pr_vaxvar +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VAFLAT vaflat; +} PR_VAXVAR; +/* Property of vaxvars */ +typedef struct pr_vaxvars +{ +PRS_ROOT root; +PRS_VAROOT varoot; +PRS_VAFIX vafix; +PRS_VASEG vaseg; +} PR_VAXVARS; diff --git a/code/SIBOSDK/include/varray.ing b/code/SIBOSDK/include/varray.ing new file mode 100644 index 0000000..ba932b7 --- /dev/null +++ b/code/SIBOSDK/include/varray.ing @@ -0,0 +1,154 @@ +; Generated by Ctran from varray.cat +VARRAY_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF P_QUE_INC + INCLUDE ..\inc\P_QUE.INC +ENDIF +; Class Numbers +C_VAROOT equ 1 +C_VAFIX equ 2 +C_VAFLAT equ 3 +C_SGBUF equ 4 +C_VASEG equ 5 +C_VASTR equ 6 +C_VAXVAR equ 7 +C_VAXVARS equ 8 +; Method Numbers +O_VA_COPY equ 14 +O_SB_INIT equ 1 +O_VA_FINDISQ equ 5 +O_VA_TEST equ 12 +O_SB_DELETE equ 4 +O_VA_INIT equ 17 +O_VA_REPLACE equ 13 +O_SB_INSERT equ 3 +O_VA_RECLEN equ 15 +O_VA_APPEND equ 7 +O_VA_RESET equ 11 +O_VA_DELETE equ 2 +O_VA_INSERT equ 8 +O_SB_POINT equ 2 +O_VA_DELETEM equ 18 +O_SB_COMPRESS equ 6 +O_VA_SORT equ 3 +O_VA_PBUF equ 21 +O_VA_INSERTM equ 19 +O_VA_PREC equ 20 +O_SB_COUNT equ 7 +O_VA_COMPARE equ 10 +O_SB_ALLOCSEG equ 9 +O_VA_INSERTISQ equ 6 +O_VA_COMPRESS equ 23 +O_VA_KEY equ 4 +O_SB_BACKPOINT equ 8 +O_VA_SWAP equ 16 +O_VA_COUNT equ 1 +O_VA_CAPACITY equ 22 +O_VA_SEARCH equ 9 +O_SB_EXTRACT equ 5 +; Constants for varoot +VA_ROOT_DUPLICATE equ (1) +VA_ROOT_FLG_FOLD equ (001h) +VA_ROOT_FLG_DESC equ (002h) +; Types for varoot +PR_VAROOT_KEY struc +PR_VAROOT_KEYOfs db ? +PR_VAROOT_KEYLen db ? +PR_VAROOT_KEYFold db ? +PR_VAROOT_KEYDesc db ? +PR_VAROOT_KEY ends +; Property of varoot +PRS_VAROOT struc +VarootNrec dw ? +VarootKey PR_VAROOT_KEY <> +PRS_VAROOT ends +PR_VAROOT struc +VarootRoot PRS_ROOT <> +VarootVaroot PRS_VAROOT <> +PR_VAROOT ends +; Property of vafix +PRS_VAFIX struc +VafixRlen dw ? +PRS_VAFIX ends +PR_VAFIX struc +VafixRoot PRS_ROOT <> +VafixVaroot PRS_VAROOT <> +VafixVafix PRS_VAFIX <> +PR_VAFIX ends +; Property of vaflat +PRS_VAFLAT struc +VaflatGran dw ? +VaflatNspc dw ? +VaflatBase dw ? +PRS_VAFLAT ends +PR_VAFLAT struc +VaflatRoot PRS_ROOT <> +VaflatVaroot PRS_VAROOT <> +VaflatVafix PRS_VAFIX <> +VaflatVaflat PRS_VAFLAT <> +PR_VAFLAT ends +; Types for sgbuf +PR_SGBUF_HD struc +PR_SGBUF_HDQ P_QUE <> +PR_SGBUF_HDLen dw ? +PR_SGBUF_HD ends +PR_SGBUF_SBO struc +PR_SGBUF_SBOSeg dw ? +PR_SGBUF_SBOBase dw ? +PR_SGBUF_SBOOfs dw ? +PR_SGBUF_SBO ends +; Property of sgbuf +PRS_SGBUF struc +SgbufHd PR_SGBUF_HD <> +SgbufNbytes dw ? +SgbufCur PR_SGBUF_SBO <> +PRS_SGBUF ends +PR_SGBUF struc +SgbufRoot PRS_ROOT <> +SgbufSgbuf PRS_SGBUF <> +PR_SGBUF ends +; Property of vaseg +PRS_VASEG struc +VasegBuf dw ? +PRS_VASEG ends +PR_VASEG struc +VasegRoot PRS_ROOT <> +VasegVaroot PRS_VAROOT <> +VasegVafix PRS_VAFIX <> +VasegVaseg PRS_VASEG <> +PR_VASEG ends +; Property of vastr +PRS_VASTR struc +VastrSize dw ? +VastrGran dw ? +VastrBase dw ? +VastrLen dw ? +VastrNum dw ? +VastrPnum dw ? +PRS_VASTR ends +PR_VASTR struc +VastrRoot PRS_ROOT <> +VastrVaroot PRS_VAROOT <> +VastrVastr PRS_VASTR <> +PR_VASTR ends +; Types for vaxvar +RC_VAXVAR struc +RC_VAXVARLen dw ? +RC_VAXVARBuf dw ? +RC_VAXVAR ends +; Property of vaxvar +PR_VAXVAR struc +VaxvarRoot PRS_ROOT <> +VaxvarVaroot PRS_VAROOT <> +VaxvarVafix PRS_VAFIX <> +VaxvarVaflat PRS_VAFLAT <> +PR_VAXVAR ends +; Property of vaxvars +PR_VAXVARS struc +VaxvarsRoot PRS_ROOT <> +VaxvarsVaroot PRS_VAROOT <> +VaxvarsVafix PRS_VAFIX <> +VaxvarsVaseg PRS_VASEG <> +PR_VAXVARS ends diff --git a/code/SIBOSDK/include/win.g b/code/SIBOSDK/include/win.g new file mode 100644 index 0000000..1e06d40 --- /dev/null +++ b/code/SIBOSDK/include/win.g @@ -0,0 +1,67 @@ +/* Generated by Ctran from win.cl */ +#define WIN_G +#ifndef OLIB_G +#include +#endif +#ifndef WLIB_H +#include +#endif +/* Class Numbers */ +#define C_WIN 1 +/* Method Numbers */ +#define O_WN_INIT 13 +#define O_WN_VISIBLE 7 +#define O_WN_SENSE 11 +#define O_WN_POSITION 4 +#define O_WN_KEY 6 +#define O_WN_DODRAW 2 +#define O_WN_CALC_POSITION 5 +#define O_WN_CONNECT 3 +#define O_WN_REDRAW 1 +#define O_WN_EMPHASISE 8 +#define O_WN_SENSE_HELP 9 +#define O_WN_SET 10 +#define O_WN_DRAW 12 +/* Constants for win */ +#define CURSOR_WIDTH 2 +#define CURSOR_COLWID 2 +#define SYSTEM_FONT_COLWID 2 +#define W_KEY_SPACE 32 +#define PR_BWIN_CUSHION 0x1 +#define PR_BWIN_CORNER_4 0x2 +#define PR_BWIN_SHADOW_1 0x4 +#define PR_BWIN_SHADOW_2 0x8 +#define PR_WIN_EMPHASISED 0x10 +#define PR_BWIN_OPEN 0x20 +#define PR_BWIN_CORNER_1 0x40 +#define PR_WIN_IS_DLCTRL 0x80 +#define PR_WIN_IS_OVCTRL 0x100 +#define PR_WIN_INITIALISED 0x800 +#define PR_WIN_FORCE_RIGHT 0x1000 +#define PR_WIN_FORCE_LEFT 0x2000 +#define PR_WIN_FORCE_BOTTOM 0x4000 +#define PR_WIN_FORCE_TOP 0x8000 +#define PR_WIN_FORCE_FLAGS 0xf000 +#define WIN_3dBORDER PR_WIN_FORCE_RIGHT +#define WIN_FROM_ATS PR_WIN_FORCE_LEFT +#define IN_WIN_EMPHASISED (PR_WIN_EMPHASISED) +#define WV_INVISIBLE 0 +#define WV_VISIBLE 1 +#define WV_INITINVIS 2 +#define WV_INITVIS 3 +#define WN_KEY_NO_CHANGE 0 +#define WN_KEY_CHANGED 3 +#define WN_KEY_CHANGED_DEFER 7 +#define WN_KEY_CANCELLED (-1) +#define WN_KEY_ABSORB_ON (-2) +#define ERROR_RID_OFFSET 512 +/* Property of win */ +typedef struct { +unsigned short int id; +unsigned short int flags; +} PRS_WIN; +typedef struct pr_win +{ +PRS_ROOT root; +PRS_WIN win; +} PR_WIN; diff --git a/code/SIBOSDK/include/win.ing b/code/SIBOSDK/include/win.ing new file mode 100644 index 0000000..7a284f8 --- /dev/null +++ b/code/SIBOSDK/include/win.ing @@ -0,0 +1,66 @@ +; Generated by Ctran from win.cl +WIN_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +IFNDEF WLIB_INC + INCLUDE ..\inc\WLIB.INC +ENDIF +; Class Numbers +C_WIN equ 1 +; Method Numbers +O_WN_INIT equ 13 +O_WN_VISIBLE equ 7 +O_WN_SENSE equ 11 +O_WN_POSITION equ 4 +O_WN_KEY equ 6 +O_WN_DODRAW equ 2 +O_WN_CALC_POSITION equ 5 +O_WN_CONNECT equ 3 +O_WN_REDRAW equ 1 +O_WN_EMPHASISE equ 8 +O_WN_SENSE_HELP equ 9 +O_WN_SET equ 10 +O_WN_DRAW equ 12 +; Constants for win +CURSOR_WIDTH equ (2) +CURSOR_COLWID equ (2) +SYSTEM_FONT_COLWID equ (2) +W_KEY_SPACE equ (32) +PR_BWIN_CUSHION equ (01h) +PR_BWIN_CORNER_4 equ (02h) +PR_BWIN_SHADOW_1 equ (04h) +PR_BWIN_SHADOW_2 equ (08h) +PR_WIN_EMPHASISED equ (010h) +PR_BWIN_OPEN equ (020h) +PR_BWIN_CORNER_1 equ (040h) +PR_WIN_IS_DLCTRL equ (080h) +PR_WIN_IS_OVCTRL equ (0100h) +PR_WIN_INITIALISED equ (0800h) +PR_WIN_FORCE_RIGHT equ (01000h) +PR_WIN_FORCE_LEFT equ (02000h) +PR_WIN_FORCE_BOTTOM equ (04000h) +PR_WIN_FORCE_TOP equ (08000h) +PR_WIN_FORCE_FLAGS equ (0f000h) +WIN_3dBORDER equ (PR_WIN_FORCE_RIGHT) +WIN_FROM_ATS equ (PR_WIN_FORCE_LEFT) +IN_WIN_EMPHASISED equ (PR_WIN_EMPHASISED) +WV_INVISIBLE equ (0) +WV_VISIBLE equ (1) +WV_INITINVIS equ (2) +WV_INITVIS equ (3) +WN_KEY_NO_CHANGE equ (0) +WN_KEY_CHANGED equ (3) +WN_KEY_CHANGED_DEFER equ (7) +WN_KEY_CANCELLED equ (-1) +WN_KEY_ABSORB_ON equ (-2) +ERROR_RID_OFFSET equ (512) +; Property of win +PRS_WIN struc +WinId dw ? +WinFlags dw ? +PRS_WIN ends +PR_WIN struc +WinRoot PRS_ROOT <> +WinWin PRS_WIN <> +PR_WIN ends diff --git a/code/SIBOSDK/include/window.h b/code/SIBOSDK/include/window.h new file mode 100644 index 0000000..8f5f128 --- /dev/null +++ b/code/SIBOSDK/include/window.h @@ -0,0 +1,34 @@ +/* Release 3.00 */ +/*-------------------------------------------------------------------------* +* * +* window.h - definitions for window module types and functions. * +* * +* COPYRIGHT (C) 1989..1991 Jensen and Partners. All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#ifndef _WINDOWS +#ifndef _TSWIN_INC_ +#define _TSWIN_INC_ + +#define TRUE 1 +#define FALSE 0 + +#ifdef __cplusplus +extern "C" { +#endif +extern void gotoxy(int x, int y); +extern int wherex(void); +extern int wherey(void); +extern void clrscr(void); +extern void cursoron(void); +extern void cursoroff(void); +extern void insline(void); +extern void delline(void); +extern void clreol(void); +extern void setwrap(int on); +#ifdef __cplusplus +} +#endif +#endif +#endif diff --git a/code/SIBOSDK/include/wldselwn.g b/code/SIBOSDK/include/wldselwn.g new file mode 100644 index 0000000..b42b67a --- /dev/null +++ b/code/SIBOSDK/include/wldselwn.g @@ -0,0 +1,68 @@ +/* Generated by Ctran from wldselwn.cl */ +#define WLDSELWN_G +#ifndef MATCHER_G +#include +#endif +#ifndef WR_IO_H +#include +#endif +/* Class Numbers */ +#define C_WMATCHER 37 +#define C_WLDSELWN 38 +/* Method Numbers */ +#define O_WLD_RESTRICT 19 +/* Constants for wmatcher */ +#define GEOG_MAX_NAME 22 +#define PR_WMATCHER_INDETERMINATE 0x02 +/* Property of wmatcher */ +typedef struct { +void *wfcb; +unsigned char iscountry; +unsigned char tleng; +char tbuf[GEOG_MAX_NAME]; +WR_FIND_RES res; +short int resco; +} PRS_WMATCHER; +typedef struct pr_wmatcher +{ +PRS_ROOT root; +PRS_MATCHER matcher; +PRS_WMATCHER wmatcher; +} PR_WMATCHER; +/* Constants for wldselwn */ +#define PR_WLDSELWN_COUNTRY 0x01 +#define PR_WLDSELWN_FIRST_PARTNER 0x02 +#define PR_WLDSELWN_NOT_IN_DIALOG 0x04 +#define PR_WLDSELWN_RESTRICTED 0x08 +#define IN_WLDSELWN_CITY 0 +#define IN_WLDSELWN_COUNTRY PR_WLDSELWN_COUNTRY +#define IN_WLDSELWN_FIRST_PARTNER PR_WLDSELWN_FIRST_PARTNER +#define IN_WLDSELWN_NOT_IN_DIALOG PR_WLDSELWN_NOT_IN_DIALOG +#define IN_WLDSELWN_SECOND_PARTNER 0x10 +#define IN_WLDSELWN_SETHOME 0x20 +#define IN_WLDSELWN_SETDFLT 0x40 +/* Types for wldselwn */ +typedef struct +{ +unsigned short int flags; +PR_WIN *other; +} IN_WLDSELWN; +typedef struct +{ +void *wfcb; +WR_EXTRA_DATA data; +} SENSE_WLDSELWN; +/* Property of wldselwn */ +typedef struct { +PR_WMATCHER *mat; +unsigned char *tleng; +unsigned short int flags; +PR_WIN *other; +} PRS_WLDSELWN; +typedef struct pr_wldselwn +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_WLDSELWN wldselwn; +} PR_WLDSELWN; diff --git a/code/SIBOSDK/include/wldselwn.ing b/code/SIBOSDK/include/wldselwn.ing new file mode 100644 index 0000000..7d7ba3e --- /dev/null +++ b/code/SIBOSDK/include/wldselwn.ing @@ -0,0 +1,64 @@ +; Generated by Ctran from wldselwn.cl +WLDSELWN_ING equ 1 +IFNDEF MATCHER_ING + INCLUDE ..\inc\MATCHER.ING +ENDIF +IFNDEF WR_IO_INC + INCLUDE ..\inc\WR_IO.INC +ENDIF +; Class Numbers +C_WMATCHER equ 37 +C_WLDSELWN equ 38 +; Method Numbers +O_WLD_RESTRICT equ 19 +; Constants for wmatcher +GEOG_MAX_NAME equ (22) +PR_WMATCHER_INDETERMINATE equ (002h) +; Property of wmatcher +PRS_WMATCHER struc +WmatcherWfcb dw ? +WmatcherIscountry db ? +WmatcherTleng db ? +WmatcherTbuf db (1) * GEOG_MAX_NAME dup (?) +WmatcherRes WR_FIND_RES <> +WmatcherResco dw ? +PRS_WMATCHER ends +PR_WMATCHER struc +WmatcherRoot PRS_ROOT <> +WmatcherMatcher PRS_MATCHER <> +WmatcherWmatcher PRS_WMATCHER <> +PR_WMATCHER ends +; Constants for wldselwn +PR_WLDSELWN_COUNTRY equ (001h) +PR_WLDSELWN_FIRST_PARTNER equ (002h) +PR_WLDSELWN_NOT_IN_DIALOG equ (004h) +PR_WLDSELWN_RESTRICTED equ (008h) +IN_WLDSELWN_CITY equ (0) +IN_WLDSELWN_COUNTRY equ (PR_WLDSELWN_COUNTRY) +IN_WLDSELWN_FIRST_PARTNER equ (PR_WLDSELWN_FIRST_PARTNER) +IN_WLDSELWN_NOT_IN_DIALOG equ (PR_WLDSELWN_NOT_IN_DIALOG) +IN_WLDSELWN_SECOND_PARTNER equ (010h) +IN_WLDSELWN_SETHOME equ (020h) +IN_WLDSELWN_SETDFLT equ (040h) +; Types for wldselwn +IN_WLDSELWN struc +IN_WLDSELWNFlags dw ? +IN_WLDSELWNOther dw ? +IN_WLDSELWN ends +SENSE_WLDSELWN struc +SENSE_WLDSELWNWfcb dw ? +SENSE_WLDSELWNData WR_EXTRA_DATA <> +SENSE_WLDSELWN ends +; Property of wldselwn +PRS_WLDSELWN struc +WldselwnMat dw ? +WldselwnTleng dw ? +WldselwnFlags dw ? +WldselwnOther dw ? +PRS_WLDSELWN ends +PR_WLDSELWN struc +WldselwnRoot PRS_ROOT <> +WldselwnWin PRS_WIN <> +WldselwnLodger PRS_LODGER <> +WldselwnWldselwn PRS_WLDSELWN <> +PR_WLDSELWN ends diff --git a/code/SIBOSDK/include/wlib.h b/code/SIBOSDK/include/wlib.h new file mode 100644 index 0000000..4557916 --- /dev/null +++ b/code/SIBOSDK/include/wlib.h @@ -0,0 +1,827 @@ +/* HEADER - WLIB.H +Copyright (C) Psion PLC 1991 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +1.10F 22/10/93 SLT Second relase +*/ +#ifndef WLIB_H +#define WLIB_H + +#include +#include +#include +#include +#include +#include + +#define G_GC_MASK_GMODE 0x2 +#define G_GC_MASK_TEXTMODE 0x4 +#define G_GC_MASK_STYLE 0x8 +#define G_GC_MASK_FONT 0x10 +#define G_GC_MASK_GREY 0x20 +#define G_GC_MASK_DOUBLE 0x40 + +#define G_GC_FLAG_GREY_PLANE 0x1 +#define G_GC_FLAG_BOTH_PLANES 0x2 +#define G_GC_FLAG_DOUBLE 0x4 + +#define G_TEXT_ALIGN_RIGHT 1 +#define G_TEXT_ALIGN_LEFT 2 +#define G_TEXT_ALIGN_CENTRE 4 +#define G_FONT_FLAG_ASCII 0x01 +#define G_FONT_FLAG_CP850 0x02 +#define G_FONT_FLAG_BOLD 0x04 +#define G_FONT_FLAG_ITALIC 0x08 +#define G_FONT_FLAG_SERIF 0x10 +#define G_FONT_FLAG_MONO 0x20 +#define G_FONT_FLAG_HANG 0x40 /* Has over/under hang table */ +#define G_FONT_SPECIAL_1 0x8000 /* Font is stored in Special format 1 */ +#define G_TRMODE_SET 0 +#define G_TRMODE_CLR 1 +#define G_TRMODE_INV 2 +#define MAX_GMODE 2 /* max trmode allowed in the gmode of a gc */ +#define G_TRMODE_REPL 4 +#define MAX_BLITMODE 5 /* .. .. in a blit-type command */ +#define MAX_TEXTMODE 5 /* .. .. in the textmode of a gc */ +#define G_STY_NORMAL 0 +#define G_STY_BOLD 0x01 +#define G_STY_UNDERLINE 0x02 +#define G_STY_INVERSE 0x04 +#define G_STY_DOUBLE 0x08 +#define G_STY_MONO 0x10 +#define G_STY_ITALIC 0x20 +#define G_STY_SUBSCRIPT2 0x40 +#define G_STY_SUPERSCRIPT2 0x80 +#define G_STY_SUBSCRIPT 0x100 +#define G_STY_SUPERSCRIPT 0x200 +#define G_XP_INV_BLOCK 0x01 +#define G_XP_INV_OBLOID 0x02 +#define G_XP_UND_BLOCK 0x04 +#define G_XP_REDUCED 0x08 +#define W_BORD_CORNER_2 0x00 +#define W_BORD_CUSHION 0x01 +#define W_BORD_CORNER_4 0x02 +#define W_BORD_SHADOW_S 0x04 +#define W_BORD_SHADOW_D 0x08 +#define W_BORD_SHADOW_ON 0x10 +#define W_BORD_OPEN 0x20 +#define W_BORD_CORNER_1 0x40 +#define W_BORD_TOP_OFF 0x80 +#define W_BORD_BOT_OFF 0x100 +#define W_BORD_TOP_ON 0x200 +#define W_BORD_BOT_ON 0x400 +#define X_BORD_SHADOW_BOX 0x8000 +#define W_BORDER_TYPE_0 0 +#define W_BORDER_TYPE_1 1 +#define X_BORDER_TYPE_MAX 1 +#define G_DRAW_OBJECT_TYPE_0 0 +#define X_DRAW_OBJECT_TYPE_MAX 0 +#define G_APPEND 0x01 +#define G_DISPLAY 0x02 +#define W_CTBY_S3 0x0001 +#define X_CTBY_SCR_SIZE 0x0002 +#define W_CTBY_S3_SCR (X_CTBY_S3|X_CTBY_SCR_SIZE) +#define W_SUPPORT_GREY 0x01 +#define W_SUPPORT_CTBY_S3 0x02 +typedef struct + { + unsigned int flags; + unsigned int fillers[15]; + } W_SUPPORT_INFO; +#define WS_MAX_CLIENTS 21 /* Includes rubber band client */ +#define FONT_NAME_LEN 16 +#define FONT_MAX_HEADER_LEN 128 +typedef struct + { + unsigned short int low_ch; /* lowest code in font */ + unsigned short int high_ch; /* highest code in font */ + unsigned short int height; /* height of font */ + unsigned short int descent; /* height of bottom part of character */ + unsigned short int ascent; /* height of top part of character */ + unsigned short int numeric_width; /* Width of numeric character */ + unsigned short int max_width; /* The width of the widest character in the font */ + unsigned short int flags; + char name[FONT_NAME_LEN]; + } G_FONT_INFO; +#define WS_FONT_SYSTEM 0x4099 +#define WS_DEFAULT_ICON (WS_BITMAP_BASE+8) +typedef struct + { + unsigned short int keycode; /* Code for the key pressed */ + unsigned char modifiers; /* A bit set for each modifier key held down */ + unsigned char count; + } WMSG_KEY; +typedef struct + { + unsigned short int unused; + unsigned char modifiers; /* A bit set for each modifier key held down */ + unsigned char filler; + } WMSG_CAPS; +typedef struct + { + unsigned char event; + unsigned char state; + P_POINT pos; + } WMSG_MOUSE; +typedef struct + { + unsigned short int state; + P_EXTENT extent; + } WMSG_RUBBER; +typedef union + { + unsigned short int uword; + unsigned char *dpoint; /* Data pointer */ + P_RECT rect; + WMSG_KEY key; + WMSG_MOUSE mouse; + WMSG_RUBBER rubber; + WMSG_CAPS caps; + } WS_EVENT_UNION; +typedef struct + { + unsigned short int handle; /* Destination handle */ + unsigned short int time; + WS_EVENT_UNION u; + } WS_EVENT_X; +typedef struct + { + short int type; /* E_FILE_PENDING,or -ve error,or +ve good event type */ + WS_EVENT_X x; + } WS_EVENT; +typedef struct /* The WS_EV struct runs in parallel to the WS_EVENT struct */ + { /* but is in a simplified form without the WS_EVENT_X */ + /* sub structure */ + short int type; + unsigned short int handle; + unsigned short int time; + WS_EVENT_UNION p; + } WS_EV; +#define MAX_CLIENT_TO_WSERV_BUFFER 300 +#define MAX_WSERV_TO_CLIENT_BUFFER 300 +#define W_INFO_MSG_MAX_LEN 64 +#define W_BUSY_MSG_MAX_LEN 20 +#define W_DRAW_BUTTON_MAX_LEN 64 +#define W_ALERT_TEXT_MAX_LEN 80 +#define W_PASSWORD_ALERT_TEXT_MAX_LEN 128 +#define W_BUTTON_TYPE_1 0 +#define W_BUTTON_TYPE_2 1 +typedef struct + { + unsigned char gmode; /* transfer mode */ + unsigned char textmode; /* transfer mode for writing text */ + unsigned char style; /* style of text : bold,underline etc. */ + unsigned char flags; + unsigned short int font; /* handle of curr font in use */ + } G_GC; +typedef struct + { + P_EXTENT start; /* Current dimension */ + P_EXTENT outer; /* Outer bounding rectangle */ + P_EXTENT inner; /* Inner bounding rectangle */ + unsigned short int flags; /* TRUE if the rubber band is resizable */ + unsigned short int minx; /* Max and Min limits only used if resize is TRUE */ + unsigned short int miny; + unsigned short int maxx; + unsigned short int maxy; + P_POINT grid_snap; + } W_RUBBER_BAND; +typedef struct + { + unsigned short int flags; /* see below */ + P_EXTENT extent; /* position and size relative to parent */ + short int mouse_icon; /* handle of mouse icon */ + unsigned char background; /* Auto clear to black,white or none on redraws */ + unsigned char filler; + } W_WINDATA; +typedef struct + { + P_POINT pos; /* position within window */ + unsigned char height; + char ascent; + unsigned char width; + unsigned char flags; + } W_CURSOR; +#define W_CURSOR_OBLOID 0x01 +#define W_CURSOR_NO_FLASH 0x02 +#define W_CURSOR_GREY 0x04 +typedef struct + { + short int bitmap; + P_POINT pos; + P_RECT rect; + unsigned short int mode; + unsigned long int time; + } WS_WIN_BITMAP; +#define WS_WIN_BITMAP_GREY 0x8000 +typedef struct + { + short int bit_set; + short int bit_clr; + short int bit_inv; + short int bit_gr_set; + short int bit_gr_clr; + short int bit_gr_inv; + P_POINT offset; + unsigned short int time; + } W_SPRITE; +#define MAX_SET_SPRITE 13 +#define W_SPRITE_CLIP_CHILDREN 0x0001 +typedef struct + { + short int id; /* Window id */ + short int type; /* Clock type */ + P_POINT pos; + short int offset; /* Time offset */ + short int flags; /* Clock flags */ + short int font; + short int style; + } WS_CREATE_CLOCK; +typedef struct + { + short int FontId; + unsigned char Styles; + unsigned char FontStyles; + short int BaseOffset; + } G_FONT_CONFIG; +typedef struct + { + unsigned char BodyColour; + unsigned char ShadowColour; + unsigned char LightColour; + unsigned char filler; + unsigned short int Flags; + short int ShadowSizeX; + short int ShadowSizeY; + short int LightSizeX; + short int LightSizeY; + short int Spacing; + } G_SHADOW; +#define G_COLOUR_BLACK 0 +#define G_COLOUR_WHITE 1 +#define G_COLOUR_GREY 2 +#define G_COLOUR_NONE 3 +#define G_COLOUR_DARK_GREY 4 +#define G_COLOUR_LIGHT_GREY 5 +#define G_COLOUR_MAX 5 +#define G_SHADOW_SOLID 0x01 +#define G_SHADOW_CORNER_1 W_BORD_CORNER_1 +#define G_SHADOW_CORNER_4 W_BORD_CORNER_4 +#define WE_KEY 0x0001 +#define WE_REDRAW 0x0002 +#define WE_STATUS 0x0004 +#define WE_MOUSE 0x0008 +#define WE_OTHERS 0x0010 +#define WE_ESC 0x8000 +#define WE_NORMAL 0x0FFF +#define WSIPC_LINK_PASTE 0x0004 +#define WSIPC_LINK_SERVER 0x0003 +#define WSIPC_CLIENT_TO_SERVER 0x0100 +#define WSIPC_OS_CLIENT_DIED 0x0200 +#define WSIPC_NOTIFY 0x0300 +#define WSIPC_ALERT 0x0400 +#define WSIPC_WATCHALL 0x0500 +#define IPC_HEAD_FLAG_REPORT_ERRORS 0x0100 +#define IPC_HEAD_FLAG_READ_FLAGS 0x0200 +typedef struct + { + unsigned char *data; + unsigned char word_len; + unsigned char flags; + WS_EVENT *read; + union + { + unsigned int read_flags; /* What sort of events to read */ + unsigned char *reply; /* Optional address for reply buffers */ + }r; + }IPC_HEAD; +typedef struct + { + P_POINT pixels; /* Display size */ + unsigned short int width_1000_pixels_mm; + unsigned short int height_1000_pixels_mm; + unsigned char set_is_dark; + unsigned char version_id; + unsigned short int system_font_handle; + unsigned short int flags; + unsigned short int dummy; + } W_SERVER_INFO; +#define W_SERVER_INFO_FLAG_GREY1 0x0001 +typedef struct + { + unsigned short int client_handle; /* S_CCB table index */ + W_SERVER_INFO info; + } CONNECT_INFO; +typedef struct + { + int (*write)(struct _WSERV_SPEC *,short int *,WS_EV *,unsigned int,unsigned int); + void (*close)(struct _WSERV_SPEC *); + void (*init_transmit)(struct _WSERV_SPEC *); + void (*panic)(struct _WSERV_SPEC *,unsigned int); + } CLINK_REDIRECTOR; +typedef struct + { + /* The following symbols are only used in debug mode but have been left + in as they be useful for future expansion */ + unsigned char *log; + char *par_file; + void (*cpanic_handler)(int); + /**/ + unsigned short int usage_count; + unsigned char *p_commands; + unsigned char *p_end; /* End is not always the end of the buffer,this is because + the limit may be constrained by the receiveing end */ + union + { + struct + { + unsigned char commands[1]; + } local; + struct + { + unsigned char commands[1]; + } metafile; + unsigned char buf[MAX_CLIENT_TO_WSERV_BUFFER]; + } msg; + } WSERV_CLIENT_DATA; +typedef struct _WSERV_SPEC /* WSERV_SPEC */ + { + unsigned short int handle_check; + CONNECT_INFO conn; + char error; + unsigned char leaves_disabled; + unsigned short int cpanic; + CLINK_REDIRECTOR redirector; /* magic cookie - switches between :- */ + /* 1) IPC to WSERV,*/ + /* 2) metafile code,*/ + /* 3) and p_io() */ + union /* link :- link specific parts */ + { + struct /* local link */ + { + unsigned short int wserv_pid; + IPC_HEAD ipc_head; + } local; + struct /* metafile recording */ + { + unsigned char *io_channel; /* p_io() - to link-layer-like device */ + struct _WSERV_SPEC * display; /* if display while recording: */ + /* else NULL */ + unsigned char *transmit_start; + } metafile; + } link; + unsigned short int os_ds; /* Operating system DS */ + } WSERV_SPEC; +typedef struct + { + P_POINT size; + char seg_name[14]; + } W_OPEN_BIT_SEG; +typedef struct + { + UWORD checksum; + P_POINT size; + UWORD byte_size; + ULONG offset; + }WS_PIC_HEADER; +typedef struct + { + P_FSIG sig; + UWORD count; + WS_PIC_HEADER wspic; + } PIC_HEAD; +/* Flags used in field set and the flag field in the window structure */ +#define W_WIN_INPUT_ONLY 0x01 +#define W_WIN_RUBBER_BAND_CAPTURE 0x02 +#define W_WIN_INACTIVE 0x04 +#define W_WIN_MOUSE_MOVE 0x08 +#define W_WIN_MOUSE_DRAG 0x10 +#define W_WIN_MOUSE_GRAB 0x20 +#define W_WIN_DOUBLE_PIXEL 0x40 +#define W_WIN_FOREGROUND_ONLY 0x80 +#define W_WIN_PRIORITY 0x100 +#define W_WIN_NO_REDRAW 0x200 +#define W_WIN_NO_MOUSE 0x400 +#define W_WIN_RUBBER_BAND_COMPLETE_ON_RELEASE 0x800 +#define W_WIN_ALL_FLAGS 0xfff +/* Flags used in field set only */ +#define W_WIN_EXTENT 0x1000 +#define W_WIN_MOUSE_ICON 0x2000 +#define W_WIN_BACKGROUND 0x4000 +#define W_STATUS_HIDDEN 0x8000 /* Used internally to mark window as hidden */ +/* Status flags */ +#define W_UNINITIALISED 0x80 +#define W_REDRAW 0x40 +#define W_BACKGROUND 0x20 /* Window is invisible because it is background */ +#define W_SET_INVISIBLE 0x10 /* Window is set to invisible by client */ +#define W_XXXXXXX 0x08 +#define W_INVALID 0x04 /* The whole window contents is invalid */ + +#define X_WIN_BACK_NO_REDRAW 0x08 /* Private */ +#define X_WIN_BACK_GREY_REDRAW 0x80 /* Private */ +#define W_WIN_BACK_NONE 0x00 +#define W_WIN_BACK_CLR 0x01 +#define W_WIN_BACK_SET 0x02 +#define W_WIN_BACK_BITMAP 0x03 +#define W_WIN_BACK_NONE_NO_REDRAW (00+X_WIN_BACK_NO_REDRAW) +#define W_WIN_BACK_CLR_NO_REDRAW (01+X_WIN_BACK_NO_REDRAW) +#define W_WIN_BACK_SET_NO_REDRAW (02+X_WIN_BACK_NO_REDRAW) +#define W_WIN_BACK_GREY_CLR (00+X_WIN_BACK_GREY_REDRAW) +#define W_WIN_BACK_GREY_NONE (16+X_WIN_BACK_GREY_REDRAW) +#define W_WIN_BACK_GREY_SET (32+X_WIN_BACK_GREY_REDRAW) +#define W_WIN_BACK_GREY_BITMAP (48+X_WIN_BACK_GREY_REDRAW) +#define W_WIN_BACK_GREY_CLR_NO_REDRAW 0x00 +#define W_WIN_BACK_GREY_NONE_NO_REDRAW 0x10 +#define W_WIN_BACK_GREY_SET_NO_REDRAW 0x20 +#define W_VER_DOUBLE_BITS 0x0001 +#define X_CORNER_BOTTOM 0x40 +#define X_CORNER_RIGHT 0x80 +#define W_CORNER_TOP_LEFT 0x00 +#define W_CORNER_TOP_RIGHT X_CORNER_RIGHT +#define W_CORNER_BOTTOM_LEFT X_CORNER_BOTTOM +#define W_CORNER_BOTTOM_RIGHT (X_CORNER_RIGHT+X_CORNER_BOTTOM) +#define WSERV_FLAG_NO_SHELL_REBOOT 0x0001 +#define WSERV_FLAG_NO_NOTIFIER_REBOOT 0x0002 +#define WSERV_FLAG_NO_PANIC_NOTIFYS 0x0004 +#define WSERV_FLAG_HOOK_NOTIFIER 0x0008 +#define WSERV_FLAG_UPDATE_MSGS 0x0010 +#define WSERV_FLAG_LOW_BATTERY_WARNINGS 0x0020 +#define WSERV_FLAG_HUNG_UP_SW 0x0040 +#define WSERV_FLAG_SW_NO_LOW_BATTERY 0x0080 +#define WSERV_FLAG_SW_NO_PACKS 0x0100 +#define WSERV_FLAG_SW_NO_LINK 0x0200 +#define WSERV_FLAG_SW_NO_CAPS 0x0400 +#define WSERV_FLAG_TOP_BIT 0x8000 /* Can not be set */ +#define W_CONNECT_AT_BACK 0x01 +#define W_CONNECT_CONNECTED 0x01 /* Only used in replys to wClientInfo() */ +#define W_CONNECT_USER_FLAG 0x02 +#define W_CONNECT_SYSTEM_MODAL 0x04 +#define W_CONNECT_PRIORITY 0x40 +#define W_CONNECT_DISABLE_LEAVES 0x80 +#define WS_TEMPORARY_GC 1 +#define WS_BIT_WRITE 0x01 +#define WS_BIT_SEG 0x02 +#define WS_BIT_SEG_NAME 0x04 +#define WS_BIT_SEG_ACCESS (WS_BIT_SEG|WS_BIT_SEG_NAME) +#define WS_BIT_SEG_ZERO_SIZE 0x08 +#define WS_BIT_MASK (WS_BIT_WRITE+WS_BIT_SEG+WS_BIT_SEG_NAME+WS_BIT_SEG_ZERO_SIZE) +#define WS_BIT_ROM 0x80 +#define WS_BIT_FILE 0x100 +#define WX_BIT_GREY 0x8000 /* secret do not use */ +#define WS_CLOCK_SMALL_DIGITAL 0x00 +#define WS_CLOCK_MEDIUM 0x01 +#define WS_CLOCK_LARGE_ANALOG 0x02 +#define WS_CLOCK_MEDIUM2 0x03 +#define WS_CLOCK_XL_ANALOG 0x04 +#define WS_CLOCK_FORMATTED 0x05 +#define WS_CLOCK_MAX 0x06 +#define WS_CLOCK_VINE 0x06 +#define WS_CLOCK_MAX_VINE 0x07 /* Last clock type on vine plus 1 */ +#define WS_CLOCK_MEDIUM3 0x06 +#define WS_CLOCK_XL2_ANALOG 0x07 +#define WS_CLOCK_MAX_OAK 0x08 /* Last clock type on oak plus 1 */ +#define CLOCK_FLAG_COLON_OFFSET 0x04 +#define CLOCK_FLAG_DIGITAL 0x08 +#define CLOCK_FLAG_WSRV 0x04 +#define CLOCK_FLAG_XXXX 0x08 +#define WS_CLOCK_WITH_DATE 0x10 +#define WS_CLOCK_WITH_SECONDS 0x20 +#define WS_CLOCK_FORCE_ANALOG 0x40 +#define WS_CLOCK_FORCE_DIGITAL 0x80 +#define WS_CLOCK_AM_PM 0x100 +#define WS_CLOCK_AM_PM_BUT_NOT_IN_MEDIUM_ANALOG 0x400 +#define WS_CLOCK_CENTRED 0x200 +#define WS_CLOCK_WITH_DATE_EXTRA 0x400 +#define WS_CLOCK_GREY 0x800 +#define WS_CLOCK_DBL_PLANE 0x1000 +#define WS_CLOCK_RIGHT_ALIGN 0x2000 +#define WS_CLOCK_SUMMER_TIME 0x4000 +#define WS_CLOCK_BOX 0x8000 +#define OLD_CLOCK_FLAGS 0xFFF0 +#define WS_BITMAP_CLOCK_SIZE_X 36 +#define WS_BITMAP_CLOCK_SIZE_Y 32 +#define WS_BITMAP_LARGE_CLOCK_SIZE_X 66 +#define WS_BITMAP_LARGE_CLOCK_SIZE_Y 60 +#define WS_BITMAP_XL_CLOCK_SIZE_X 99 +#define WS_BITMAP_XL_CLOCK_SIZE_Y 99 +#define WS_BITMAP_MEDIUM2_CLOCK_SIZE_X 58 +#define WS_BITMAP_MEDIUM2_CLOCK_SIZE_Y 51 +#define WS_LEFT_POS_CONS 189 +#define WS_LEFT_POS_CORP 109 +#define WS_TOP_POS 0 +#define WS_WIDTH 51 +#define WS_HEIGHT 80 +#define WS_WIDTH_V4 64 +#define WS_WIDTH_SMALL_V4 32 +#define WS_WIDTH_V4C 51 +#define WS_WIDTH_SMALL_V4C 32 +#define WS_WIDTH_VINE 36 /* Same number as small but different width on vine */ +/* Basic WSERV-to-client message types +*/ +#define WM_KEY 1 +#define WM_MOUSE 2 +#define WM_REDRAW 3 +#define WM_BACKGROUND 5 +#define WM_FOREGROUND 6 +#define WM_RUBBER 7 +#define WM_USER_MSG 8 +#define WM_ACTIVE 9 +#define WM_CANCELLED 11 +#define WM_KEYBOARD_STATE_CHANGE 12 +#define WM_RUBBER_BAND_INIT 13 +#define WM_DEICONISE 14 +#define WM_ATTACHED 15 +#define WM_DETACHED 16 +#define WM_COMMAND 17 +#define WM_TASK_KEY 18 +#define WM_TASK_UPDATE 19 +#define WM_ON 20 +#define WM_ESCAPE 21 +#define WM_DATE_CHANGED 22 +#define WM_MAX_WSERV 23 +#define WM_NULL_EVENT 24 +#define WS_BITMAP_GREY 0x4000 +#define WS_BITMAP_GREY_SIZE_X 192 +#define WS_BITMAP_GREY_SIZE_Y 16 +#define WS_BITMAP_BASE 0x4001 +#define WS_FONT_BASE 0x4000 +#define WS_FONT_BASE2 0x6000 +#define WS_MI_BASE 0x4002 +#define WS_LAST_CLIENT_POSITION 100 +/* system mouse icon handles */ +#define W_WIN_MI_STANDARD 0x4000 /* index 0 + Base 0x4000 */ +#define W_WIN_MI_NULL 0x4001 /* index 1 + Base 0x4000 */ +#define WM_MOUSE_RELEASE 1 +#define WM_MOUSE_PRESS 2 +#define WM_MOUSE_MOVE 3 +#define P_MAX_COORD 0x7fff +#define WS_MAX_PRINT_TEXT_LEN 246 +#define WS_MAX_PRINT_CLIP_TEXT_LEN 244 +#define WS_MAX_PRINT_BOX_TEXT_LEN 236 +#define WS_MAX_XPRINT_TEXT_LEN 244 +#define WS_MAX_SHADOW_TEXT_LEN 234 +#define WS_MAX_FORMATTED_CLOCK 238 +#define W_MAX_FONT_CONFIG 24 +#define WM_BAND_NOMOVE 0 +#define WM_BAND_MOVE 1 +#define WM_BAND_RESIZE 2 +#define WM_BAND_CANCEL 3 +#define WM_BAND_ERROR 4 +#define W_BAND_RESIZE 0x01 +#define W_BAND_INNER 0x02 +#define W_BAND_OUTER 0x04 +#define W_BAND_START 0x08 +#define W_BAND_COMPLETE_ON_UP 0x10 +#define W_BAND_KILL_CAPTURE 0x20 +#define W_BAND_GRID_SNAP_SIZE 0x40 +#define W_XXXX_GRID_SNAP_POS 0x80 /* Secret internal #define */ +#define W_BAND_GRID_SNAP (W_XXXX_GRID_SNAP_POS|W_BAND_GRID_SNAP_SIZE) +#define WS_TYPE_MASK 0xF0 +#define WS_VERSION_MASK 0x0F +#define WS_TYPE_MC 0x00 +#define WS_TYPE_S3 0x10 +#define WS_TYPE_HC 0x20 +#define WS_TYPE_MCA 0x30 +#define WS_TYPE_S3A 0x40 +#define WS_TYPE_HCA 0x50 +#define WS_TYPE_S3C 0x60 +#define WS_TYPE_VINE 0x70 +#define WS_VERSION_2 0x00 +#define WS_VERSION_3 0x01 +#define WS_VERSION_3_5 0x02 +#define WS_VERSION_4 0x02 +/* The alert type is made of a base value one of ...*/ +#define WS_ALERT_CLIENT 0x00 +#define WS_ALERT_TIMED 0x01 +#define WS_ALERT_CANCEL 0x08 +/* ...with one or none of the following flags or'ed in */ +#define WS_ALERT_PERMANENT 0x02 +#define WS_ALERT_UPDATE 0x04 /* Wserv internal use only */ +#define WS_ALERT_B 0x10 +#define WS_UPDATE_NAME 0x01 +#define WS_UPDATE_CLOCK 0x02 +#define WSERV_PANIC_FIRST 81 +#define WSERV_PANIC_LAST 116 +#define W_STATUS_WINDOW_OFF 0 +#define W_STATUS_WINDOW_SMALL 1 +#define W_STATUS_WINDOW_BIG 2 +#define W_STATUS_WINDOW_CTBY 3 +#define W_STATUS_WINDOW_MAX W_STATUS_WINDOW_CTBY +#define W_STATUS_WIN_NO_DIAMOND -1 +#define W_STATUS_WINDOW_ICON -1 +typedef struct + { + unsigned char hposition; + unsigned char length; + unsigned short int offset; + } DESC; +typedef struct + { + unsigned char zero; + unsigned char filler; + DESC desc[3]; + } WS_ALERT_DESC; +#define G_OPEN_MODE_NORMAL 0 +#define G_OPEN_MODE_OFFSET 1 +#define G_OPEN_MODE_LONG_PTR_OFFSET 2 +#define G_OPEN_MODE_WORD_PTR_OFFSET 3 +#define MAX_G_OPEN_MODE 3 +#define W_SYSTEM_FONT_S3B 0 +#define W_SYSTEM_FONT_S3 1 +#define W_SYSTEM_FONT_INTERNAL_S3B 2 +#define W_SYSTEM_FONT_INTERNAL_S3 3 +#ifdef __cplusplus +extern "C" { +#endif +#pragma save +extern void cdecl wsAlertA(int,short int *,const char *,const char *,...); +extern int cdecl wsAlertUpdate(const char *,const char *,...); +extern int cdecl wsAlertW(int,const char *,const char *,...); +extern int cdecl wAllDump(char *,unsigned int); +#pragma call(reg_param =>(bx,cx,dx,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int gOpenBit(const char *,unsigned int,unsigned int,void *); +extern int gGetBit(unsigned int,unsigned int,unsigned int,void *); +extern int gPeekBit(unsigned int,const P_POINT *,unsigned int,void *); +#pragma call(reg_param =>(bx,cx,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int gReadFontHeader(const char *name,int index,unsigned char *buf); +extern int wInquireWindowOffset(unsigned int,unsigned int,P_POINT *); +extern int gQueryBit(int,int,P_POINT *); +#pragma call(reg_param =>(bx,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int gReadFontGroupHeader(const char *name,unsigned char *buf); +extern int wInquireWindow(unsigned int,W_WINDATA *); +extern int wInquireStatusWindow(int state,P_EXTENT *ext); +extern void wCompatibilityMode(unsigned int flags,WSERV_SPEC *wSpec); +extern int gInitBit(const char *,int *); +extern void gInquireChecksum(int id,unsigned short int *checksum); +#pragma call(reg_param =>(bx,si,ax,cx,dx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void gPrintBoxText(const P_RECT *,unsigned int,unsigned int,unsigned int,const char *,unsigned int); +#pragma call(reg_param =>(dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int gPlayBack(void *); +extern unsigned int wDisableLeaves(unsigned int); +extern void wGetEventWait(WS_EV *); +extern void wGetEventUpdate(unsigned int); +extern void wPanic(unsigned int); +extern void wSelect(WSERV_SPEC *); +extern int gCheckBitmapID(unsigned int); +#pragma call(reg_param =>(dx,cx,di),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int gFontInfo(unsigned int,unsigned int,G_FONT_INFO *); +extern void wGetEventSpecial(WS_EV *,unsigned int); +#pragma call(reg_param =>(dx,si,di,cx,ax),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int gTextWidth(unsigned int,unsigned int,const char *,unsigned int); +extern int gTextCount(unsigned int,unsigned int,const char *,unsigned int,unsigned int *); +extern int gGetWidthTable(unsigned int,unsigned int,unsigned char *); +#pragma call(reg_param =>(di,cx,dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void gRecordToMetaFile(WSERV_SPEC *,void *,unsigned int); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(bx,cx,si,di,EPOC_SAVE)) +extern void wBeginRedrawGC0(unsigned int,const P_RECT *); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(bx,dx,si,di,EPOC_SAVE)) +extern int gCreateGC0(unsigned int); +extern void gCreateTempGC0(unsigned int); +extern void gSetGC0(unsigned int); +extern void wBeginRedrawWinGC0(unsigned int); +#pragma call(reg_param =>(si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern int wGetCommand(unsigned char *); +extern void wGetProcessList(unsigned short int *); +extern void wSupportInfo(W_SUPPORT_INFO *); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(cx,dx,si,di,EPOC_SAVE)) +extern int wCancelBusyMsg(void); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(si,di,EPOC_SAVE)) +extern void wStartup(void); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void wsScreenExt(P_EXTENT *); +extern void gClrRect(const P_RECT *,unsigned short int); +extern int gCloseMetaFile(void); +extern void gCopyBit(const P_POINT *,unsigned int,const P_RECT *,unsigned int); +extern int gDrawBit(const P_POINT *,int,const P_RECT *,int,int); +extern void gCopyRect(const P_RECT *,const P_POINT *,int); +extern int gCreateGC(unsigned int,unsigned int,G_GC *); +extern void gCreateTempGC(unsigned int,unsigned int,G_GC *); +extern void gDrawLine(int,int,int,int); +extern void gDrawPolyLine(int,int,short int *); +extern void gFreeTempGC(void); +extern void gInvObloid(P_EXTENT *); +extern int gOpenFont(const char *); +extern int gOpenFontIndex(const char *,unsigned int); +extern int gOpenMouseIcon(const char *,unsigned int); +extern unsigned int gPrintClipText(int,int,const char *,int,int); +extern void gPrintText(int,int,const char *,int); +extern int gCreateBit(unsigned int,void *); +extern int gSaveBit(const char *,unsigned int); +extern int gSaveRect(const char *,unsigned int,const P_RECT *); +extern int gInitMultiSave(const char *,int); +extern int gSaveMultiBit(int,int); +extern int gSaveMultiRect(int,int,const P_RECT *); +extern int gEndMultiSave(int); +extern void gSetGC(unsigned int,unsigned int,G_GC *); +extern void gXPrintText(int,int,const char *,unsigned int,unsigned int); +extern int wAttachToClient(unsigned int); +extern void wAttachToForegroundClient(void); +extern void wBeginRedraw(unsigned int,const P_RECT *); +extern void wBeginRedrawGC(unsigned int,const P_RECT *,unsigned int,G_GC *); +extern void wBeginRedrawWin(unsigned int); +extern void wBeginRedrawWinGC(unsigned int,unsigned int,G_GC *); +extern void wCallDYL(unsigned int,unsigned int,unsigned int,void *); +extern int wCallDYLReply(unsigned int,unsigned int,unsigned int,void *,void *); +extern int wCancelCaptureKey(unsigned int,unsigned int,unsigned int); +extern void wCancelGetEvent(void); +extern void wCancelSystemModal(unsigned int); +extern int wCaptureKey(unsigned int,unsigned int,unsigned int); +extern int wSetTaskKey(unsigned int,unsigned int,unsigned int); +extern int wSetBackTaskKey(unsigned int,unsigned int,unsigned int); +extern int wCancelTaskKey(unsigned int,unsigned int,unsigned int); +extern int wCancelBackTaskKey(unsigned int,unsigned int,unsigned int); +extern void wCaptureMouse(unsigned int); +extern void wChangeWinBitmap(unsigned int,unsigned int,WS_WIN_BITMAP *); +extern void wClientIconised(unsigned int); +extern unsigned int wClientInfo(unsigned int); +extern void wClientPosition(unsigned int,unsigned int); +extern void wCloseDown(void); +extern int wCreateWindow(unsigned int,unsigned int,W_WINDATA *,unsigned short int); +extern void wDetachClient(void); +extern void wDisablePauseKey(void); +extern void wAppKeyHandler(void); +extern void wDrawTextCursor(unsigned int,W_CURSOR *); +extern void wTextCursor(unsigned int,W_CURSOR *); +extern void wEnablePauseKey(void); +extern void wEndCompute(void); +extern void wEraseTextCursor(void); +extern void wEscapeOff(void); +extern void wEscapeOn(void); +extern void wFree(unsigned int); +extern unsigned int wGetWindowPosition(unsigned int); +extern void wInvalidateRect(unsigned int,const P_RECT *); +extern int wSetWinBitmap(unsigned int,unsigned int,WS_WIN_BITMAP *); +extern int wSetPriorityControl(unsigned int flag); +extern int gConfigureFonts(int count,G_FONT_CONFIG *cfg); +extern int wSetSystemFont(int type,int font,unsigned int style); +extern int wCreateSprite(int winId,const P_POINT *pos,int flags,int count,W_SPRITE *sprite); +extern int wSetSprite(int id,const P_POINT *pos,int index,W_SPRITE *); +extern int wsSetList(int count,char **list,int pos); +extern void wsSelectList(int move); +extern void gShadowText(int,int,G_SHADOW *,const char *,int); +extern void gDrawObject(int type,const P_RECT *,int flags); +extern void gBorder2Rect(int type,const P_RECT *,int flags); +extern void gBorder2(int type,int flags); +extern int gCreateFontHeader(G_FONT_INFO *info,char *SegName); +extern void wInformInactivity(void); +extern void wDisableKeyClick(int); +extern int wLoadDYL(const char *); +extern void wReassignRootWindow(unsigned int); +extern void wReleaseMouse(void); +extern void wRubberBand(unsigned int,unsigned int,W_RUBBER_BAND *); +extern void wScrollRect(unsigned int,const P_RECT *,const P_POINT *); +extern void wScrollWin(unsigned int,const P_POINT *); +extern int wsCreateClock(unsigned int,unsigned int,int,int,int); +extern int wsCreateClock2(WS_CREATE_CLOCK *,char *); +extern void wsDisable(void); +extern void wsDisableTemp(void); +extern void wsEnable(void); +extern void wsEnableTemp(void); +extern void wStatusWindow(int); +extern void wsSetClock(unsigned int,int); +extern void wSetWindow(unsigned int,unsigned int,W_WINDATA *); +extern int wSetBusyMsg(const char *,unsigned int); +extern void wStartCompute(void); +extern void wsUpdate(unsigned int); +extern void wInformOn(void); +extern void wInformOnAll(unsigned int); +extern int wSystem(unsigned int,unsigned int); +extern void wSystemModal(unsigned int); +extern void wUserMsg(void); +extern void wValidateRect(unsigned int,const P_RECT *); +extern int wInfoMsg(const char *); +extern int wInfoMsgCorner(const char *,unsigned int); +extern void gSetOpenAddress(unsigned int,unsigned long int); +extern void wDrawButton(const P_RECT *,const char *,unsigned int); +extern void wDrawButton2(int,const P_RECT *,const char *,unsigned int); +extern unsigned int wInquireCompatibility(void); +extern int wSendCommand(unsigned short int,unsigned char *,unsigned short int); +#pragma call(reg_param =>(si,di,cx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void wConnect(WSERV_SPEC *,unsigned int,unsigned int); +#pragma call(reg_param =>(dx),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void wGetEvent(WS_EV *); +#pragma call(reg_param =>(bx,cx,dx,di,si),reg_saved =>(bx,cx,dx,si,di,EPOC_SAVE)) +extern void gBorder(unsigned int); +extern void gBorderRect(const P_RECT *,unsigned int); +extern void gDrawBox(const P_RECT *); +extern void gFillPattern(const P_RECT *,unsigned int,unsigned int); +extern void wsAlertCancel(void); +extern int wCheckPoint(void); +extern void wCleanUp(void); +extern void wCloseWindowTree(unsigned int); +extern void wDisconnect(void); +extern void wEndRedraw(void); +extern void wFlush(void); +extern void wInitialiseWindowTree(unsigned int); +extern void wInvalidateWin(unsigned int); +extern void wMakeInvisible(unsigned int); +extern void wMakeVisible(unsigned int); +extern void wValidateWin(unsigned int); +extern void wWindowPosition(unsigned int,unsigned int); +#pragma restore +#ifdef __cplusplus +} +#endif + +#endif // WLIB_H \ No newline at end of file diff --git a/code/SIBOSDK/include/wr_io.h b/code/SIBOSDK/include/wr_io.h new file mode 100644 index 0000000..0d67eaa --- /dev/null +++ b/code/SIBOSDK/include/wr_io.h @@ -0,0 +1,142 @@ +/* HEADER - WR_IO.H +World structures and constants. +Copyright (c) Psion PLC 1991. + + VER DATE BY DESCRIPTION +----- -------- ---- ----------- +1.00F NSM Final release +2.00A 1/6/93 MHS S3B release +*/ +#ifndef WR_IO_H +#define WR_IO_H + +#include +#include +#include + +#define WR_FIND_CITY 10 +#define WR_FIND_COUNTRY 11 +#define WR_FIND_EXACT 12 +#define WR_NEXT 13 +#define WR_BACK 14 +#define WR_GET_HOME 15 +#define WR_SET_HOME 16 +#define WR_GET_DEFAULT_COUNTRY 17 +#define WR_SET_DEFAULT_COUNTRY 18 +#define WR_GET_DIAL_STRING 19 +#define WR_EXTRA 20 +#define WR_SET_EXTRA 21 +#define WR_GET_CITY_DATA 22 +#define WR_GET_COUNTRY_DATA 23 +#define WR_CALC 24 +#define WR_NEXT_LOCK 25 +#define WR_GET_DIAL_STRING_B 26 + +#define WR_MAX_NAME 20 +#define WR_MAX_DIAL 16 +#define WR_MAX_CODE 8 +#define WR_MAX_INTRA 4 +#define WR_MAX_INTER 4 +#define WR_MAX_DIAL_STRING 24 +/* new (S3B) max length of output string 40 - E_MAX_DTMF_DIAL_B */ +#define WR_MAX_DIAL_STRING_B 40 +#define WR_MAX_IN_STRING 64 + +#define WR_UNITS_MILES 0 +#define WR_UNITS_KILOMETERS 1 +#define WR_UNITS_NAUTICAL 2 + +#define WR_START_STATE 1 +#define WR_END_STATE 0 + +#define WR_HOME_DONE 0 +#define WR_HOME_SET 1 +#define WR_HOME_DOING 2 + +#define WR_NOT_FOUND E_GEN_FAIL +#define WR_FOUND 0 + +#define WR_EXTRA_ADD_CITY 0 +#define WR_EXTRA_UPDATE_CITY 1 +#define WR_EXTRA_DELETE_CITY 2 +#define WR_EXTRA_UPDATE_COUNTRY 3 +#define WR_EXTRA_ADD_HOME 4 + +#define WR_DELETED 0 +#define WR_REVERTED 1 + +#define WR_TOO_MANY_ERR -23 +#define WR_NOTVALID_ERR -25 +#define WR_DELHOME_ERR -26 +#define WR_DELCAPITAL_ERR -27 +#define WR_DUPLICATE_ERR -28 + +typedef struct /* Lat long */ + { + WORD iLat; + WORD iLong; + } LATL; + +typedef struct + { + TEXT city[WR_MAX_NAME+1]; + TEXT country[WR_MAX_NAME+1]; + } WR_FIND_RES; + +typedef struct + { + WR_FIND_RES f; + UBYTE units; /* Also baseGMT */ + UBYTE DST; + WORD GMT; + LATL latl; + TEXT dial[WR_MAX_DIAL+1]; + TEXT STD[WR_MAX_CODE+1]; + P_POINT pos; + } WR_CITY_DATA; + +typedef struct + { + TEXT dialIntra[WR_MAX_INTRA+1]; + TEXT dialInter[WR_MAX_INTER+1]; + TEXT dial[WR_MAX_CODE+1]; + UBYTE dummy; + } CO_DIAL; + +typedef struct + { + WR_FIND_RES f; + BYTE baseGMT; + UBYTE DST; + WORD GMT; + CO_DIAL dial; + } WR_COUNTRY_DATA; + +typedef union + { + WR_CITY_DATA ci; + WR_COUNTRY_DATA co; + } WR_EXTRA_DATA; + +typedef struct + { + WORD distance; + WORD sunRise; + WORD sunSet; + WORD always; + } WR_CALC_OUT; + +typedef union + { + WR_CITY_DATA in; + WR_CALC_OUT out; + } WR_CALC_DATA; + +typedef struct + { + UWORD time; + UWORD date; + UWORD amPm; + } TIMEDATE; + +#endif // WR_IO_H \ No newline at end of file diff --git a/code/SIBOSDK/include/wsdyl.h b/code/SIBOSDK/include/wsdyl.h new file mode 100644 index 0000000..324d54b --- /dev/null +++ b/code/SIBOSDK/include/wsdyl.h @@ -0,0 +1,41 @@ +/* HEADER - WSDYL.H +Copyright (C) Psion PLC 1991 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +*/ +#ifndef WSDYL_H +#define WSDYL_H + +#include +#include +#include + +typedef struct +{ +P_OBJECT obj; +P_RECT total; +P_RECT clip; +P_RECT workrect; +/* +The following three elements are grouped together to match the layout of +the unpublished BM_DATA structure. +*/ +unsigned short int seg; +unsigned char *addr; +unsigned short int bytewid; +unsigned short int trmode; +short int x_offset; +short int y_offset; +unsigned char *work_space; +unsigned char *user_handle; +P_POINT *alt_offset; +unsigned short int bitmap_segment; +P_POINT size; +unsigned char *bitmap_addr; +unsigned int osdataseg; +unsigned char *reply_addr; +unsigned int reply_len; +} DYL_CALL; + +#endif // WSDYL_H diff --git a/code/SIBOSDK/include/wskeys.h b/code/SIBOSDK/include/wskeys.h new file mode 100644 index 0000000..229693f --- /dev/null +++ b/code/SIBOSDK/include/wskeys.h @@ -0,0 +1,80 @@ +/* HEADER - WSKEYS.H +Copyright (C) Psion PLC 1991 + VER DATE BY DESCRIPTION +===== ======== === =========== +1.00F 26/04/90 NSM First relase +*/ +#ifndef WSKEYS_H +#define WSKEYS_H + +#define W_SHIFT_MODIFIER 0x02 +#define W_CTRL_MODIFIER 0x04 +#define W_PSION_MODIFIER 0x08 +#define W_CAPS_MODIFIER 0x10 +#define W_NUM_LOCK_MODIFIER 0x20 +#define W_MOUSE_OUTSIDE 0x40 +#define W_MOUSE_DOWN 0x80 +#define W_FUNC_MODIFIER 0x80 /* Doubles up as mouse or func */ +#define W_RUSSIAN_MODIFIER 0x1000 + +#define W_KEY_REPEATED 0x800 +#define W_SPECIAL_KEY 0x0200 + +#define W_KEY_DELETE_LEFT 8 +#define W_KEY_TAB 9 +#define W_KEY_RETURN 13 +#define W_KEY_ESCAPE 27 +#define W_KEY_DELETE_RIGHT 127 + +#define W_KEY_UP 0x0100 +#define W_KEY_DOWN 0x0101 +#define W_KEY_RIGHT 0x0102 +#define W_KEY_LEFT 0x0103 +#define W_KEY_PAGE_UP 0x0104 +#define W_KEY_PAGE_DOWN 0x0105 +#define W_KEY_HOME 0x0106 +#define W_KEY_END 0x0107 +#define W_KEY_TASK 0x0108 +#define W_KEY_VOICE 0x0109 + +#define W_KEY_CAPS_LOCK 0x010c + +#define W_KEY_BACKLIGHT 0x120 +#define W_KEY_INFO 0x121 +#define W_KEY_MENU 0x122 +#define W_KEY_HELP 0x123 +#define W_KEY_DIAMOND 0x124 + +#define W_KEY_MODE 0x0130 +#define W_KEY_APP1 0x0131 +#define W_KEY_APP2 0x0132 +#define W_KEY_APP3 0x0133 +#define W_KEY_APP4 0x0134 +#define W_KEY_APP5 0x0135 +#define W_KEY_APP6 0x0136 +#define W_KEY_APP7 0x0137 +#define W_KEY_APP8 0x0138 +#define W_KEY_APP9 0x0139 + +#define W_KEY_IR_BRING 0x0140 +#define W_KEY_IR_SEND 0x0141 +#define W_KEY_IR_LINK 0x0142 + +#define W_KEY_CALC_CLEAR 0x001b +#define W_KEY_CALC_MEM_CLEAR 0x0150 +#define W_KEY_CALC_MEM_RECALL 0x0151 +#define W_KEY_CALC_MEM_MINUS 0x0152 +#define W_KEY_CALC_MEM_PLUS 0x0153 +#define W_KEY_CALC_CHNG_SIGN 0x0154 +#define W_KEY_CALC_PERCENT 0x0155 +#define W_KEY_CALC_DECIMAL 0x0156 +#define W_KEY_CALC_MEM_INPUT 0x0158 + +#define W_KEY_LCD 0x2000 +#define W_KEY_LCD_MINUS 0x2001 +#define W_KEY_ON 0x2002 +#define W_KEY_OFF 0x2003 + +#define PERMITTED_MODS (W_SHIFT_MODIFIER+W_CTRL_MODIFIER+W_PSION_MODIFIER+W_MOUSE_DOWN+W_CAPS_MODIFIER+W_NUM_LOCK_MODIFIER) + +#endif // WSKEYS_H diff --git a/code/SIBOSDK/include/xactive.g b/code/SIBOSDK/include/xactive.g new file mode 100644 index 0000000..7bb3038 --- /dev/null +++ b/code/SIBOSDK/include/xactive.g @@ -0,0 +1,31 @@ +/* Generated by Ctran from xactive.cl */ +#define XACTIVE_G +#ifndef APPMAN_G +#include +#endif +/* Class Numbers */ +#define C_LOGONA 7 +#define C_UNLOAD 8 +/* Method Numbers */ +/* Property of logona */ +typedef struct { +unsigned short int pid; +void *owner; +unsigned short int mess; +} PRS_LOGONA; +typedef struct pr_logona +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_LOGONA logona; +} PR_LOGONA; +/* Property of unload */ +typedef struct { +int cathand; +} PRS_UNLOAD; +typedef struct pr_unload +{ +PRS_ROOT root; +PRS_ACTIVE active; +PRS_UNLOAD unload; +} PR_UNLOAD; diff --git a/code/SIBOSDK/include/xactive.ing b/code/SIBOSDK/include/xactive.ing new file mode 100644 index 0000000..cd99ed8 --- /dev/null +++ b/code/SIBOSDK/include/xactive.ing @@ -0,0 +1,29 @@ +; Generated by Ctran from xactive.cl +XACTIVE_ING equ 1 +IFNDEF APPMAN_ING + INCLUDE ..\inc\APPMAN.ING +ENDIF +; Class Numbers +C_LOGONA equ 7 +C_UNLOAD equ 8 +; Method Numbers +; Property of logona +PRS_LOGONA struc +LogonaPid dw ? +LogonaOwner dw ? +LogonaMess dw ? +PRS_LOGONA ends +PR_LOGONA struc +LogonaRoot PRS_ROOT <> +LogonaActive PRS_ACTIVE <> +LogonaLogona PRS_LOGONA <> +PR_LOGONA ends +; Property of unload +PRS_UNLOAD struc +UnloadCathand dw ? +PRS_UNLOAD ends +PR_UNLOAD struc +UnloadRoot PRS_ROOT <> +UnloadActive PRS_ACTIVE <> +UnloadUnload PRS_UNLOAD <> +PR_UNLOAD ends diff --git a/code/SIBOSDK/include/xadd.ext b/code/SIBOSDK/include/xadd.ext new file mode 100644 index 0000000..bed1770 --- /dev/null +++ b/code/SIBOSDK/include/xadd.ext @@ -0,0 +1,138 @@ +Generated by Ctran from xadd.cat +LIBRARY xadd +CLASS prvinfo win +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS prvview dlgchain +{ +DECLARE pvv_done +DECLARE pvv_pages_done +DECLARE pvv_new_page +DECLARE pvv_margins +DECLARE pvv_init +DECLARE pvv_false +HAS_METHOD +HAS_PROPERTY +} +CLASS prvpage win +{ +DECLARE pvp_margins +HAS_METHOD +HAS_PROPERTY +} +CLASS prvcomm comman +{ +DECLARE pvc_preview_print +DECLARE pvc_preview_margins +DECLARE pvc_preview_options +DECLARE pvc_preview_jump +DECLARE pvc_preview_exit +HAS_METHOD +HAS_PROPERTY +} +CLASS prvjump_dlg dlgbox +{ +HAS_METHOD +} +CLASS prvoptions_dlg dlgbox +{ +HAS_METHOD +} +CLASS xprinter lprinter +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS logona active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS unload active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS calimgwn win +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS calwin bwin +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS runmemo active +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS ipcstat active +{ +DECLARE ipcs_set_message +DECLARE ipcs_wait +DECLARE ipcs_key +HAS_METHOD +HAS_PROPERTY +} +CLASS atssv server +{ +DECLARE sv_free +DECLARE sv_key +HAS_METHOD +HAS_PROPERTY +} +CLASS atstim timer +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS oprinter xprinter +{ +DECLARE lpr_print_command +HAS_METHOD +HAS_PROPERTY +} +CLASS ohelpdlg helpdlg +{ +HAS_METHOD +} +CLASS atsdial dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS scprnctl dlgbox +{ +HAS_METHOD +HAS_PROPERTY +} +CLASS scpgsetup prnctrl +{ +HAS_METHOD +} +CLASS gridwin bwin +{ +DECLARE gw_get_cell_rect +DECLARE gw_draw_cells +DECLARE gw_move_to +DECLARE gw_set_col_width +DECLARE gw_set_row_height +DECLARE gw_get_current +DECLARE gw_zoom +DECLARE gw_highlight +DECLARE gw_get_data +HAS_METHOD +HAS_PROPERTY +} +CLASS matchwin gridwin +{ +DECLARE mw_start_match +DECLARE mw_stop_match +DECLARE mw_hit_maxlen +HAS_METHOD +HAS_PROPERTY +} diff --git a/code/SIBOSDK/include/xadd.g b/code/SIBOSDK/include/xadd.g new file mode 100644 index 0000000..700099f --- /dev/null +++ b/code/SIBOSDK/include/xadd.g @@ -0,0 +1,11 @@ +/* Generated by Ctran from xadd.cat */ +#define XADD_G +#ifndef OLIB_G +#include +#endif +/* Category Numbers */ +/* EPOC */ +#define CAT_XADD_XADD 0 +#define CAT_XADD_OLIB 1 +#define CAT_XADD_FORM 2 +#define CAT_XADD_HWIM 3 diff --git a/code/SIBOSDK/include/xadd.ing b/code/SIBOSDK/include/xadd.ing new file mode 100644 index 0000000..d7094e7 --- /dev/null +++ b/code/SIBOSDK/include/xadd.ing @@ -0,0 +1,10 @@ +; Generated by Ctran from xadd.cat +XADD_ING equ 1 +IFNDEF OLIB_ING + INCLUDE ..\inc\OLIB.ING +ENDIF +; Category Numbers +CAT_XADD_XADD equ 0 +CAT_XADD_OLIB equ 1 +CAT_XADD_FORM equ 2 +CAT_XADD_HWIM equ 3 diff --git a/code/SIBOSDK/include/xdlgbox.g b/code/SIBOSDK/include/xdlgbox.g new file mode 100644 index 0000000..3b8f42e --- /dev/null +++ b/code/SIBOSDK/include/xdlgbox.g @@ -0,0 +1,31 @@ +/* Generated by Ctran from xdlgbox.cl */ +#define XDLGBOX_G +#ifndef DLGBOX_G +#include +#endif +#ifndef SERDLGS_G +#include +#endif +/* Class Numbers */ +#define C_ATSDIAL 17 +/* Method Numbers */ +/* Property of atsdial */ +typedef struct { +void *owner; +void *main; +void *buts; +PR_WIN *filter; +short int filmethod; +short int chlist; +short int pid; +short int ret; +unsigned short int locked; +} PRS_ATSDIAL; +typedef struct pr_atsdial +{ +PRS_ROOT root; +PRS_WIN win; +PRS_DLGCHAIN dlgchain; +PRS_DLGBOX dlgbox; +PRS_ATSDIAL atsdial; +} PR_ATSDIAL; diff --git a/code/SIBOSDK/include/xdlgbox.ing b/code/SIBOSDK/include/xdlgbox.ing new file mode 100644 index 0000000..c14b51a --- /dev/null +++ b/code/SIBOSDK/include/xdlgbox.ing @@ -0,0 +1,30 @@ +; Generated by Ctran from xdlgbox.cl +XDLGBOX_ING equ 1 +IFNDEF DLGBOX_ING + INCLUDE ..\inc\DLGBOX.ING +ENDIF +IFNDEF SERDLGS_ING + INCLUDE ..\inc\SERDLGS.ING +ENDIF +; Class Numbers +C_ATSDIAL equ 17 +; Method Numbers +; Property of atsdial +PRS_ATSDIAL struc +AtsdialOwner dw ? +AtsdialMain dw ? +AtsdialButs dw ? +AtsdialFilter dw ? +AtsdialFilmethod dw ? +AtsdialChlist dw ? +AtsdialPid dw ? +AtsdialRet dw ? +AtsdialLocked dw ? +PRS_ATSDIAL ends +PR_ATSDIAL struc +AtsdialRoot PRS_ROOT <> +AtsdialWin PRS_WIN <> +AtsdialDlgchain PRS_DLGCHAIN <> +AtsdialDlgbox PRS_DLGBOX <> +AtsdialAtsdial PRS_ATSDIAL <> +PR_ATSDIAL ends diff --git a/code/SIBOSDK/include/xedit.g b/code/SIBOSDK/include/xedit.g new file mode 100644 index 0000000..205097a --- /dev/null +++ b/code/SIBOSDK/include/xedit.g @@ -0,0 +1,28 @@ +/* Generated by Ctran from xedit.cl */ +#define XEDIT_G +#ifndef LODGER_G +#include +#endif +/* Class Numbers */ +#define C_XEDIT 26 +/* Method Numbers */ +/* Constants for xedit */ +#define XEDIT_MAX_LEN 8 +/* Types for xedit */ +typedef struct +{ +char *pstr; +} SE_XEDIT; +/* Property of xedit */ +typedef struct { +unsigned char current; +unsigned char width; +char data[XEDIT_MAX_LEN+2]; +} PRS_XEDIT; +typedef struct pr_xedit +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LODGER lodger; +PRS_XEDIT xedit; +} PR_XEDIT; diff --git a/code/SIBOSDK/include/xedit.ing b/code/SIBOSDK/include/xedit.ing new file mode 100644 index 0000000..69e087d --- /dev/null +++ b/code/SIBOSDK/include/xedit.ing @@ -0,0 +1,26 @@ +; Generated by Ctran from xedit.cl +XEDIT_ING equ 1 +IFNDEF LODGER_ING + INCLUDE ..\inc\LODGER.ING +ENDIF +; Class Numbers +C_XEDIT equ 26 +; Method Numbers +; Constants for xedit +XEDIT_MAX_LEN equ (8) +; Types for xedit +SE_XEDIT struc +SE_XEDITPstr dw ? +SE_XEDIT ends +; Property of xedit +PRS_XEDIT struc +XeditCurrent db ? +XeditWidth db ? +XeditData db (1) * XEDIT_MAX_LEN+2 dup (?) +PRS_XEDIT ends +PR_XEDIT struc +XeditRoot PRS_ROOT <> +XeditWin PRS_WIN <> +XeditLodger PRS_LODGER <> +XeditXedit PRS_XEDIT <> +PR_XEDIT ends diff --git a/code/SIBOSDK/include/xprinter.g b/code/SIBOSDK/include/xprinter.g new file mode 100644 index 0000000..f79395c --- /dev/null +++ b/code/SIBOSDK/include/xprinter.g @@ -0,0 +1,18 @@ +/* Generated by Ctran from xprinter.cl */ +#define XPRINTER_G +#ifndef LPRINTER_G +#include +#endif +/* Class Numbers */ +#define C_XPRINTER 6 +/* Method Numbers */ +/* Property of xprinter */ +typedef struct { +short int locked; +} PRS_XPRINTER; +typedef struct pr_xprinter +{ +PRS_ROOT root; +PRS_LPRINTER lprinter; +PRS_XPRINTER xprinter; +} PR_XPRINTER; diff --git a/code/SIBOSDK/include/xprinter.ing b/code/SIBOSDK/include/xprinter.ing new file mode 100644 index 0000000..587f36f --- /dev/null +++ b/code/SIBOSDK/include/xprinter.ing @@ -0,0 +1,17 @@ +; Generated by Ctran from xprinter.cl +XPRINTER_ING equ 1 +IFNDEF LPRINTER_ING + INCLUDE ..\inc\LPRINTER.ING +ENDIF +; Class Numbers +C_XPRINTER equ 6 +; Method Numbers +; Property of xprinter +PRS_XPRINTER struc +XprinterLocked dw ? +PRS_XPRINTER ends +PR_XPRINTER struc +XprinterRoot PRS_ROOT <> +XprinterLprinter PRS_LPRINTER <> +XprinterXprinter PRS_XPRINTER <> +PR_XPRINTER ends diff --git a/code/SIBOSDK/include/xpulldwn.g b/code/SIBOSDK/include/xpulldwn.g new file mode 100644 index 0000000..1e96689 --- /dev/null +++ b/code/SIBOSDK/include/xpulldwn.g @@ -0,0 +1,20 @@ +/* Generated by Ctran from xpulldwn.cl */ +#define XPULLDWN_G +#ifndef PULLDOWN_G +#include +#endif +/* Class Numbers */ +#define C_XPULLDWN 81 +/* Method Numbers */ +/* Constants for xpulldwn */ +#define PULLDOWN_3b_LEFT 4 +#define PULLDOWN_3b_RIGHT 3 +#define PULLDOWN_3b_BOTTOM 3 +#define PULLDOWN_3b_TOP 4 +/* Property of xpulldwn */ +typedef struct pr_xpulldwn +{ +PRS_ROOT root; +PRS_WIN win; +PRS_LISTBOX listbox; +} PR_XPULLDWN; diff --git a/code/SIBOSDK/include/xpulldwn.ing b/code/SIBOSDK/include/xpulldwn.ing new file mode 100644 index 0000000..235aa83 --- /dev/null +++ b/code/SIBOSDK/include/xpulldwn.ing @@ -0,0 +1,19 @@ +; Generated by Ctran from xpulldwn.cl +XPULLDWN_ING equ 1 +IFNDEF PULLDOWN_ING + INCLUDE ..\inc\PULLDOWN.ING +ENDIF +; Class Numbers +C_XPULLDWN equ 81 +; Method Numbers +; Constants for xpulldwn +PULLDOWN_3b_LEFT equ (4) +PULLDOWN_3b_RIGHT equ (3) +PULLDOWN_3b_BOTTOM equ (3) +PULLDOWN_3b_TOP equ (4) +; Property of xpulldwn +PR_XPULLDWN struc +XpulldwnRoot PRS_ROOT <> +XpulldwnWin PRS_WIN <> +XpulldwnListbox PRS_LISTBOX <> +PR_XPULLDWN ends diff --git a/code/SIBOSDK/ldd/atimdvr.asm b/code/SIBOSDK/ldd/atimdvr.asm new file mode 100644 index 0000000..7a3c024 --- /dev/null +++ b/code/SIBOSDK/ldd/atimdvr.asm @@ -0,0 +1,446 @@ + title ATIMDVR -- Attached timer device driver example + subttl Copyright (c) Psion PLC 1991 + name ATIMDVR +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 1.00A 01/02/92 JH Alpha release +; +TURBOC equ 1 +; + include epocdef.inc + include epocmac.inc + include epocpan.inc + include epoclib.inc + include epocser.inc + +HandlerDisable equ 000h ; the hnadler should not be called +HandlerEnable equ 001h ; the handler should be called +; +TimerEnt struc + TimerIo ChanEnt <> ; I/O device driver hdr + ReadRq RqEnt <> ; read request info + ReadStat dw ? ; read completion status + InStrategy dw ? ; internal control + WaitHandler dw ? ; wait handler handle + TimerChan dw ? ; open timer channel handle + Timeout dd ? ; read timout + TimerStat dw ? ; timer completion status +TimerEnt ends + + CodeSeg + + ProcBegin@ AttachedTimerLDD +; ================= +; The externally loadable Attached timer device table + dw LDDSignature + db 'ATM',0,0,0,0,0 + dw (VectorEnd-Vector)/2 +Vector: + dw AttachedTimerInstall + dw AttachedTimerRemove + dw AttachedTimerHold + dw AttachedTimerResume + dw AttachedTimerReset + dw AttachedTimerUnits + dw AttachedTimerOpen + dw AttachedTimerStrategy +VectorHandler: + dw AttachedTimerHandler +VectorEnd: + ProcEnd noret + + + ProcBegin@ AttachedTimerInstall,far +; ===================== +; Called on device installation by the operating system +; + clc ; installed OK + ret + ProcEnd noret + + + ProcBegin@ AttachedTimerRemove,far +; ==================== +; Always allow to be removed. +; + clc ; removed ok. + ret + ProcEnd noret + + + ProcBegin@ AttachedTimerHold,far +; ================== +; This does not need to do anything. +; + ret + ProcEnd noret + + + ProcBegin@ AttachedTimerResume,far +; ==================== +; This does not need to do anything. +; + ret + ProcEnd noret + + + ProcBegin@ AttachedTimerReset,far +; =================== +; This will never be called since we dont request it to be called. +; The lower level driver and timer driver will handle the process +; terminating abnormally. +; + ProcEnd noret + + + ProcBegin@ AttachedTimerUnits,far +; =================== +; Called by device query units operating system service +; + mov ax, -1 ; supports many open requests + ret + ProcEnd noret + + + ProcBegin@ AttachedTimerOpen,far +; ================== +; Called by the IoOpen system service +; +; In: +; DX - device handle +; SI - ptr to OpenEnt struct +; Out: +; Carry clear +; BX - open channel handle +; DX - device handle as passed +; Carry set +; AL - error number +; DX - device handle as passed +; + cld + mov cx, (size TimerEnt) + HeapAllocateCell + jc endOpen ; return that error + mov bx, ax + +; Initialise the allocated cell to zero. + mov di, ax + shr cx, 1 ; alloc cells should be even no of bytes. + xor ax, ax + rep stosw ; initialize all struct to zero + +; Add the waithandler function + mov al, (VectorHandler-Vector)/2 + IoAddHandler + jc freeCellExit ; report the add handler error + mov [bx].WaitHandler, ax ; handler handle + +; Open a timer channel + push bx ; save the alloc cell handle + mov cx, sp ; save SP for now + xor ax, ax + push ax + mov ax, ':' shl 8 + 'M' + push ax + mov ax, 'I' shl 8 + 'T' + push ax + mov bx, sp ; BX is pointer to name to 'TIM:' + IoOpen ; CX and DX are irrelvant for a timer + mov sp, cx + pop bx + jc freeHandlerExit ; report the timer open error. + mov [bx].TimerChan, ax + +; Set up the channel header + mov [bx].ChanSignature, IoChanSignature + mov [bx].ChanLibHandle, dx + mov [bx].ChanNext, bx ; were a root driver for now + +; Attach this driver to the currently open driver Hierarchy + mov cx, bx ; channel were attaching + mov al, IoFuncAttach + mov bx, [si].OpenChan ; driver to attach to + IoWithWait + clc ; return BX (ie what attached to) + +; Finished the open request +endOpen: + ret + +; An error has occured, free the handler then cell in BX and return an error +freeHandlerExit: + push ax + push bx + mov bx, [bx].WaitHandler + IoRemoveHandler + pop bx + pop ax + +; An error has occured, free the cell in BX and return an error +freeCellExit: + push ax + HeapFreeCell + pop ax ; AL has the error code + stc + ret + ProcEnd noret + + + ProcBegin@ StrategyVectorTable +; =================== +; The strategy vector jump table +; + dw StrategyDefault ; IoFuncPanic + dw StrategyRead ; IoFuncRead + dw StrategyDefault ; IoFuncWrite + dw StrategyClose ; IoFuncClose + dw StrategyCancel ; IoFuncCancel + dw StrategyDefault ; IoFuncAttach + dw StrategyDefault ; IoFuncDetach + dw StrategySet ; IoFuncSet + dw StrategySense ; IoFuncSense +StrategyVectorEnd: + ProcEnd noret + + + ProcBegin@ CancelTimer +; =========== +; Cancel the outstanding timer request +; In: +; BX = TimerEnt ptr +; Out: +; NONE +; + push bx + mov bx, [bx].TimerChan + mov al, IoFuncCancel ; cancel the queued timer + IoWithWait + pop bx + lea di, [bx].TimerStat + IoWaitForStatus ; use up completion signal + ret + ProcEnd noret + + ProcBegin@ CancelRead +; ========== +; Cancel the outstanding read request on the lower driver +; In: +; BX = TimerEnt ptr +; Out: +; NONE +; + mov al, IoFuncCancel ; cancel the queued read + IoWithWait + lea di, [bx].ReadStat + IoWaitForStatus ; use up completion signal + ret + ProcEnd noret + + ProcBegin@ SignalReadAX +; ============ +; Complete the orignal read request with the completion status in AX +; In: +; AX = completion status to report +; BX = control block ptr as allocated by open +; Out: +; NONE +; + xor di, di ; complete the original read request + xchg di, [bx].ReadRq.RqStatusPtr + mov word ptr [di], ax + IoSignal + ret + ProcEnd noret + + ProcBegin@ CancelAnyRequests +; ================= +; Cancel any outstanding attached driver and timer requests. +; In: +; BX = control block ptr as allocated by open +; Out: +; NONE +; + cmp [bx].ReadRq.RqStatusPtr, 0 + je noRequestsQueued + call CancelRead + call CancelTimer + push bx + mov bx, [bx].WaitHandler + mov cl, HandlerDisable + IoEnableHandler + pop bx + mov ax, CancelErr + call SignalReadAX + +noRequestsQueued: + ret + ProcEnd noret + + ProcBegin@ AttachedTimerStrategy,far +; ===================== +; Called by the applications I/O services. +; In: +; BX = control block ptr as allocated by open +; SI = RqEnt pointer +; Out: +; Carry clear +; The request was sucessfully queued, (may have completed) +; Carry set +; The request failed to start +; + cld + mov [bx].InStrategy, 1 ; anti nesting + mov di, [si].RqStatusPtr + mov word ptr [di], PendingErr ; request now pending + mov ax, di ; pre-load AX + mov di, [si].RqFunction + cmp di, (StrategyVectorEnd-StrategyVectorTable)/2 + ja StrategyDefault + mov cx, [si].RqA1Ptr ; pre-load CX and DX + mov dx, [si].RqA2Ptr + shl di, 1 ; vector table entry + jmp word ptr cs:StrategyVectorTable[di] + +; This device driver does not handle this function, pass it up the driver +; hierarchy to a driver that may support this function. +StrategyDefault: + mov [bx].InStrategy, 0 + IoSuper ; pass request to next dvr + ret + +StrategyRead: + cmp [bx].ReadRq.RqStatusPtr, 0 + jne panicPending ; already a read queued + mov [bx].ReadRq.RqStatusPtr, ax + mov [bx].ReadRq.RqA1Ptr, cx + mov [bx].ReadRq.RqA2Ptr, dx + lea di, [bx].ReadStat ; Q an attached dvr read + mov al, IoFuncRead + IoAsynchronousNoError ; Queue a read on lower dvr + lea di, [bx].TimerStat + lea cx, [bx].Timeout + push bx + push [bx].WaitHandler + mov bx, [bx].TimerChan + mov al, IoFuncRead + IoAsynchronousNoError ; Queue a read on the timer channel +; now let the wait handler be callable + pop bx + mov cl, HandlerEnable + IoEnableHandler + pop bx + and [bx].InStrategy, 0 + clc + ret + +; The process is making a 2nd call of a function that is already outstanding. +panicPending: + mov al, PanicIoPending + ProcPanic ; stop calling process. + +StrategyCancel: + call CancelAnyRequests + and [bx].InStrategy, 0 + jmp short completeRequestOk + +; This driver defines the IoFuncSet function to set the read timout. +StrategySet: + mov di, cx ; RqA1Ptr is a pointer to a long + mov ax, [di] + mov word ptr [bx].Timeout, ax + mov ax, [di+2] + mov word ptr [bx+2].Timeout, ax + and [bx].InStrategy, 0 + jmp short completeRequestOk + +; This driver defines the IoFuncSense function to sense the read timout. +StrategySense: + mov di, cx ; RqA1Ptr is a pointer to a long + mov ax, word ptr [bx].Timeout + mov word ptr [di], ax + mov ax, word ptr [bx+2].Timeout + mov word ptr [di+2], ax +completeRequestOk: + mov di, [si].RqStatusPtr + and word ptr [di], 0 ; complete request OK. + IoSignal + and [bx].InStrategy, 0 + clc + ret + +StrategyClose: + call CancelAnyRequests + push bx + push [bx].WaitHandler + mov bx, [bx].TimerChan + IoClose ; close the timer + pop bx + IoRemoveHandler ; remove the waithandler + pop bx + mov al, IoFuncDetach ; detach from lower driver + IoWithWait + HeapFreeCell ; alloc cell freed !!! + mov di, [si].RqStatusPtr + and word ptr [di], 0 ; complete request OK. + IoSignal + clc + ret + + ProcEnd noret + + ProcBegin@ AttachedTimerHandler,far +; ==================== +; Called by the operating system when the applications I/O semaphore has +; been signalled. See if its one of our requests that have been completed. +; The operating system will automatically stop any nesting if it called this +; handler, however we will get called if we are in the strategy vector and +; use synchronous I/O requests. The driver has set itself up such that this +; will only ever be called if there is an outstanding request by only +; enabling the handler when a read request is received. +; +; In: +; BX = as passed to IoAddHandler +; Out: +; Carry clear +; The signal was not for us. +; Carry set +; AL = 0 - we used signal, allow handler to be disabled. +; AL = 1 - we used signal, keep the handler enabled. +; + + cmp [bx].InStrategy, 1 + jne notInAttachedTimerStrategy +signalNotForThisDriver: + clc ; get out as fast as possible + ret ; as event definatly not for us. + +notInAttachedTimerStrategy: + cmp [bx].ReadStat, PendingErr + je readRequestNotComplete +; The read request has completed. + call CancelTimer + mov ax, [bx].ReadStat ; read completion result + jmp short signalAXdisableHandler + +readRequestNotComplete: + cmp [bx].TimerStat, PendingErr + je signalNotForThisDriver +; The timer request has completed. + call CancelRead + mov ax, InActivityErr ; read inactivity on timeout +signalAXdisableHandler: + call SignalReadAX + xor al, al ; we used signal + stc ; handler now disabled. + ret + ProcEnd noret + + + EndCodeSeg +; +stack segment stack para 'data' +; +stack ends +; + end AttachedTimerLDD diff --git a/code/SIBOSDK/ldd/epocdef.inc b/code/SIBOSDK/ldd/epocdef.inc new file mode 100644 index 0000000..1dfd846 --- /dev/null +++ b/code/SIBOSDK/ldd/epocdef.inc @@ -0,0 +1,731 @@ + .xlist +; Include file - EPOCDEF.INC +; Epoc/Os standard definitions include file +; Copyright (c) Psion PLC 1989-91. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; 2.12F 08/05/91 NSM Final release +; +EPOCDEF_INC = 1 +; +Sibo = 0 +S3b = 0 +S3c = 0 +S3d = 0 +S3r = 0 +S39 = 0 +S3 = 0 +S3Pc = 0 +Vine = 0 +Prot = 0 +Asic1 = 1 +Asic9 = 0 +HandHeld = 0 +LapTop = 1 +IbmPc = 1 +RomServer = 0 +McLink = 0 +Consumer = 0 +Corporate = 0 +Dpmi = 0 +TickTock = 0 +DoubleSpeed = 0 +Condor = 0 +OvalDisable = 0 +S3cExtra = 0 +ifdef BUILDPH +S3Pc = 1 +endif +ifdef BUILDDL +Dpmi = 1 +endif +ifdef BUILDHH +S3 = 1 +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Consumer = 1 +TickTock = 1 +endif +ifdef BUILDSB +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Consumer = 1 +S3b = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +TickTock = 1 +endif +ifdef BUILDSC +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +S3c = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +TickTock = 1 +endif +ifdef BUILDWA +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +S3c = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +TickTock = 1 +S3cExtra = 1 +endif +ifdef BUILDSR +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Consumer = 1 +S3b = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +TickTock = 1 +S3r = 1 +endif +ifdef BUILDVN +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Consumer = 1 +S3b = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +TickTock = 1 +Vine = 1 +Condor = 1 +endif +ifdef BUILDPT +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Consumer = 1 +S3b = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +Prot = 1 +TickTock = 1 +DoubleSpeed = 1 +endif +ifdef BUILDSD +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Consumer = 1 +S3b = 1 +S39 = 1 +Asic1 = 0 +Asic9 = 1 +TickTock = 1 +Condor = 1 +S3d = 1 +OvalDisable = 1 +endif +ifdef BUILDCH +Sibo = 1 +HandHeld = 1 +LapTop = 0 +IbmPc = 0 +Corporate = 1 +TickTock = 1 +endif +ifdef BUILDLT +Sibo = 1 +IbmPc = 0 +endif +ifdef BUILDRM +RomServer = 1 +endif +ifdef BUILDMC +McLink = 1 +endif +; +PriorityForeground = 080h +PriorityBackground = 070h +; +LcdUnknown = -1 +Lcd640X400 = 0 +Lcd640X200Small = 1 +Lcd640X200Big = 2 +Lcd720X348 = 3 +Lcd160X80 = 4 +Lcd240X80 = 5 +; +PcHerc = Lcd720X348 +PcCga = Lcd640X200Big +PcMda = 6 +PcEgaMono = 7 +PcEgaColour = 8 +PcVgaMono = 9 +PcVgaColour = 10 +; +Lcd480X160 = 11 +Lcd240X100 = 12 +Lcd240X120 = 13 +Lcd240X160 = 14 +Lcd640X200 = 15 +Lcd640X240 = 16 +; +OldPsu = 0 +MaximPsu = 1 +PanPsu = 2 +PanA9Psu = 3 +BatteryUnknown = 0 +BatteryAlkaline = 1 +BatteryNicad600 = 2 +BatteryNicad1000 = 3 +BatteryNicad500 = 4 +BatteryNicad850 = 5 +; +IsAColdStart = 0 +IsAPowerFailStart = 1 +IsAResetStart = 2 +IsAKernelFault = 3 +IsANewOsStart = 4 +; +HwInt0Revector = 0 +HwInt1Revector = 1 +HwInt2Revector = 2 +HwInt3Revector = 3 +HwInt4Revector = 4 +HwIrq0Revector = 5 +HwIrq1Revector = 6 +HwIrq2Revector = 7 +HwIrq3Revector = 8 +HwIrq4Revector = 9 +HwIrq5Revector = 10 +HwIrq6Revector = 11 +HwIrq7Revector = 12 +; +if IbmPc +TicksPerSecond = 18 +endif +if Sibo +TicksPerSecond = 32 +endif +FileSystemNameSize = 5 +MaxDeviceSize = 8 +MaxNameSize = 8 +MaxExtSize = 4 +MaxNameESize = (MaxNameSize+MaxExtSize) +MaxPathSize = 080h +DeviceSeparator = ':' +ExtSeparator = '.' +MatchAny = '*' +MatchSingle = '?' +MaxErrorTextSize = 64 +MaxNotifyTextSize = 64 +MaxOptionTextSize = 16 +MaxDayName = 32 +MaxMonthName = MaxDayName +MaxSuffixes = 31 +MaxCommandBuffer = 127 +PidMask = 0fffh +MaxEnvNameSize = 16 +MaxAlarms = 2 +MaxPassword = 8 +BackLightDisable = 8000h +BackLightOff = 0 +BackLightOn = 1 +BackLightToggle = 2 +BackLightQuery = 3 +FrcCounting = 0 +FrcRepeating = 1 +; +SoundKeyboardEnable = 00001h +SoundBuzzerEnable = 00002h +SoundDeviceEnable = 00004h +SoundLoud = 00008h +SoundLoudBuzzer = 00010h +SoundDisable = 08000h +SoundMaxVolume = 0 +SoundMinVolume = 5 +SoundMaxBpm = 240 +SoundMinBpm = 2 +; +DiskAPresent = 0000000000000001b +DiskAActive = 0000000000000010b +DiskBPresent = 0000000000000100b +DiskBActive = 0000000000001000b +DiskCPresent = 0000000000010000b +DiskCActive = 0000000000100000b +DiskDPresent = 0000000001000000b +DiskDActive = 0000000010000000b +PortAOpen = 0000000100000000b +PortAActive = 0000001000000000b +PortBOpen = 0000010000000000b +PortBActive = 0000100000000000b +PortCOpen = 0001000000000000b +PortCActive = 0010000000000000b +MainsInactive = 0100000000000000b +CondorActive = 1000000000000000b +; +CPBInRom = 0 +CPBInRam = 1 +CPBMaxPriority = 0c0h +CPBMinPriority = 040h +MaxHeapGrowBy = 0400h +HeapGrowByDefault = 080h +MaxProcesses = 018h +; +CreateSegmentLow = 0 +CreateSegmentHigh = 1 +CreateSegmentDevice = 2 +CreateSegmentLocked = 3 +; +DevFuncInstall = 000h +DevFuncRemove = 001h +DevFuncHold = 002h +DevFuncResume = 003h +DevFuncReset = 004h +DevFuncUnits = 005h +DevFuncOpen = 006h +DevFuncStrategy = 007h +; +DevHoldNormal = 000h +DevHoldPowerDown = 001h +DevHoldPowerFail = 002h +; +DevFuncInstallPDD = DevFuncInstall +DevFuncRemovePDD = DevFuncRemove +DevFuncOpenPDD = (DevFuncRemovePDD+1) +DevFuncStrategyPDD = (DevFuncOpenPDD+1) +; Generic I/O r=ests +IoFuncPanic = 000h +IoFuncRead = 001h +SoundChannel1 = IoFuncRead +TimerRelative = IoFuncRead +IoFuncWrite = 002h +SoundChannel2 = IoFuncWrite +TimerAbsolute = IoFuncWrite +IoFuncClose = 003h +IoFuncCancel = 004h +IoFuncAttach = 005h +IoFuncDetach = 006h +IoFuncSet = 007h +IoFuncSense = 008h +IoFuncFlush = 009h +IoFuncAlarm = IoFuncFlush +; The File System +IoFuncSeek = 00ah +IoFuncDial = IoFuncSeek +IoFuncSetEof = 00bh +; Data Link I/O + Wserv +IoFuncConnect = 00ah +IoFuncDisconnect = 00bh +; Wserv functions +IoFuncWriteReply = 00ch +; Serial/llmac +IoFuncTest = 00ah +IoFuncControl = 00bh +IoFuncInquire = 00ch +IoFuncSuperFrame = 00dh +IoFuncStop = 00eh +IoFuncStart = 00fh +; Serial LDD to Serial PDD I/O defines +IoFuncEnable = 010h +IoFuncSetDevice = 011h +; Modem driver functions +IoFuncModemInit = 010h +IoFuncModemDial = 011h +IoFuncModemWaitCall = 012h +IoFuncModemSense = 013h +IoFuncModemSet = 014h +IoFuncModemCancel = 015h +IoFuncModemWrite = 016h +; For 3B sound device +IoSoundPlay = 010h +IoSoundRecord = 011h +IoSoundPlayO = 012h +; +ModeOpen = 00000h +ModeCreate = 00001h +ModeReplace = 00002h +ModeAppend = 00003h +ModeUnique = 00004h +; +ModeStream = 00000h +ModeStreamText = 00010h +ModeText = 00020h +ModeDir = 00030h +ModeFormat = 00040h +ModeDevice = 00050h +ModeNode = 00060h +; +ModeUpdate = 00100h +ModeRandom = 00200h +ModeShare = 00400h +; +ModeLowDensity = 01000h +; +ModeServiceMask = 0000fh +ModeFormatMask = 000f0h +ModeAccessMask = 00f00h +; +SeekAddress = 00h +SeekFromStart = 01h +SeekFromEnd = 02h +SeekFromCurrent = 03h +SeekRecordSense = 04h +SeekRecordSet = 05h +SeekRewind = 06h +; +FileAttWrite = 00001h +FileAttHidden = 00002h +FileAttSystem = 00004h +FileAttVolume = 00008h +FileAttDirectory = 00010h +FileAttModified = 00020h +FileAttRead = 00100h +FileAttExecute = 00200h +FileAttStream = 00400h +FileAttText = 00800h +; +FileChangeDirRoot = 0 +FileChangeDirParent = 1 +FileChangeDirSubdir = 2 +; +FileStatusEnt struc +FileVersionNo dw ? +FileAtt dw ? +FileSize dd ? +FileModDate dd ? +FileSpare db 4 dup (?) +FileStatusEnt ends +; +MaxVolumeName = 32 +FileMediaUnknown = 0 +FileMediaFloppy = 1 +FileMediaHardDisk = 2 +FileMediaFlash = 3 +FileMediaRam = 4 +FileMediaRom = 5 +FileMediaWriteProtected = 6 +FileMediaCompressible = 08000h +FileMediaDynamic = 04000h +FileMediaInternal = 02000h +FileMediaDualDensity = 01000h +FileMediaFormattable = 00800h +; +DeviceStatusEnt struc +DeviceVersionNo dw ? +DeviceMediaType dw ? +DeviceIsRemovable dw ? +DeviceStatusSize dd ? +DeviceStatusFree dd ? +DeviceStatusName db MaxVolumeName dup (?) +DeviceBatteryState dw ? +DeviceSpare db 16 dup (?) +DeviceStatusEnt ends +; +FileNodeFlat = 0 +FileNodeHierarchical = 1 +; +NodeStatusEnt struc +NodeVersionNo dw ? +NodeType dw ? +NodeSupportsFormat dw ? +NodeStatusSpare db 26 dup (?) +NodeStatusEnt ends +; +FileBlockShift = 9 +FileBlockSize = 00200h +FileMaxRecordSize = 00100h +FileMaxStreamSize = 04000h +; +JustifyLeft = 0 +JustifyRight = 1 +JustifyCentre = 2 +; +ParseWildAny = 00001h +ParseWildName = 00002h +ParseWildExt = 00004h +; +DtobTypeFixed = 00h +DtobTypeExponent = 01h +DtobTypeGeneral = 02h +DtobMaxExponent = 99 +DtobGenLimit = 40h +FloatSignificantDigits = 15 +; +DtobEnt struc +DtobType db ? +DtobWidth db ? +DtobNdec db ? +DtobPoint db ? +DtobTriad db ? +DtobTrilen db ? +DtobEnt ends +; +FullParseEnt struc +FullParseSystem db ? +FullParseDevice db ? +FullParsePath db ? +FullParseName db ? +FullParseExt db ? +FullParseFlags db ? +FullParseEnt ends +; +GenParseEnt struc +GenParseSourceNamePtr dw ? +GenParseRelatedNamePtr dw ? +GenParseDefaultsPtr dw ? +GenParseTargetNamePtr dw ? +GenParseInfoPtr dw ? +GenParseDeviceSeparator db ? +GenParsePathSeparator db ? +GenParseExtSeparator db ? +GenParseMaxDeviceSize db ? +GenParseMaxPathSize db ? +GenParseMaxNameSize db ? +GenParseMaxExtSize db ? +GenParseDummy db ? +GenParseEnt ends +; +CDataEnt struc +CDataCountryCode dw ? +CDataGmtOffset dw ? +CDataDateType db ? +CDataTimeType db ? +CDataCurrencySymbolPosition db ? +CDataCurrencySpaceRequired db ? +CDataCurrencyDecimalPlaces db ? +CDataCurrencyNegativeInBrackets db ? +CDataCurrencyTriadsAllowed db ? +CDataThousandsSeparator db ? +CDataDecimalSeparator db ? +CDataDateSeparator db ? +CDataTimeSeparator db ? +CDataCurrencySymbol db 9 dup(?) +CDataStartOfWeek db ? +CDataSummerTime db ? +CDataClockType db ? +CDataDayAbbreviation db ? +CDataMonthAbbreviation db ? +CDataWorkDays db ? +CDataUnits db ? +CDataEscCharacter db ? +CDataSpare db 8 dup(?) +CDataEnt ends +; +DyScEnt struc +DyScDays dw 2 dup(?) +DyScSeconds dw 2 dup(?) +DyScEnt ends +; +DateEnt struc +DateYear db ? +DateMonth db ? +DateDay db ? +DateHour db ? +DateMinute db ? +DateSecond db ? +DateYearDay dw ? +DateEnt ends +; +MessEnt struc +MessNext dw ? +MessStatusPtr dw ? +MessType dw ? +MessPid dw ? +MessEnt ends +; +CPBlock struc +CPBCodeParas dw ? +CPBInitialIp dw ? +CPBStackParas dw ? +CPBDataParas dw ? +CPBHeapParas dw ? +CPBCommandLine dw ? +CPBChecksum dw ? +CPBMinHeap dw ? +CPBPriority db ? +CPBRamOrRom db ? +CPBName db ? +CPBlock ends +; +IoChanSignature = 01101h +IoHandlerSignature = 01121h +DbfChanSignature = 01141h +LIBChanSignature = 01161h +LDDSignature = 0dd01h +PDDSignature = 0dd21h +LIBSignature = 0dd41h +VectorInfoSize = 8 +; +LibEnt struc +LibSignature dw ? +LibInfo db VectorInfoSize dup(?) +LibCount dw ? +LibBase dw ? +LibEnt ends +; +OpenEnt struc +OpenNamePtr dw ? +OpenMode dw ? +OpenChan dw ? +OpenEnt ends +; +RqEnt struc +RqFunction dw ? +RqA1Ptr dw ? +RqA2Ptr dw ? +RqStatusPtr dw ? +RqEnt ends +; +ChanEnt struc +ChanSignature dw ? +ChanNext dw ? +ChanLibHandle dw ? +ChanEnt ends +; +SndEnt struc +SndBeatsPerMinute db ? +SndVolume db ? +SndEnt ends +; +PassEnt struc +PassData db (MaxPassword*2) dup(?) +PassPos dw ? +PassEnt ends +; +IntEnt struc +IntFrame dw ? +IntBP dw ? +IntES dw ? +IntDS dw ? +IntPC dw ? +IntCS dw ? +IntFLAGS dw ? +IntEnt ends +; +DataEnt struc +DataWordDead dw ? +DataHandNext dw ? +DataHandPrev dw ? +DataCountrySeg dw ? +DataClassHandle dw ? +DataClassPtr dw ? +DataEClassHandle dw ? +DataEClassPtr dw ? +DataEnterFramePtr dw ? +Dataw_ws dw ? +Dataw_am dw ? +DatawClientData dw ? +Datawserv_channel dw ? +DataT dw ? +Datar dw ? +DataOsFramePtr dw ? +DataATFlag db ? +DataHeapLocked db ? +DataProcessNamePtr dw ? +DataCommandPtr dw ? +DataTest dw ? +DataApp1 dw ? +DataApp2 dw ? +DataApp3 dw ? +DataApp4 dw ? +DataApp5 dw ? +DataApp6 dw ? +DataApp7 dw ? +DataDialogPtr dw ? +DataGate dw ? +DataLocked dw ? +DataStatusNamePtr dw ? +DataUsedPathNamePtr dw ? +DataEnt ends +; +; Major exit error numbers +KillExit = 0 +PanicExit = 1 +TaskPanicExit = 2 +; Minor exit error numbers +NoErr = 0 +FailErr = -1 +ArgumentErr = -2 +OsErr = -3 +NotSupportedErr = -4 +UnderflowErr = -5 +OverflowErr = -6 +RangeErr = -7 +DivideByZeroErr = -8 +InUseErr = -9 +NoMemoryErr = -10 +IoAllocErr = NoMemoryErr +NoSegmentsErr = -11 +NoSemaphoreErr = -12 +NoProcessErr = -13 +AlreadyOpenErr = -14 +NotOpenErr = -15 +ImageErr = -16 +NoReceiverErr = -17 +NoDevicesErr = -18 +NoFileSystemErr = -19 +FailedToStartErr = -20 +FontNotLoadedErr = -21 +TooWideErr = -22 +TooManyItemsErr = -23 +BatLowSoundErr = -24 +BatLowFlashErr = -25 +BatLowIRDAErr = -26 +; +ExistsErr = -32 +NotExistsErr = -33 +WriteErr = -34 +ReadErr = -35 +EofErr = -36 +FullErr = -37 +NameErr = -38 +AccessErr = -39 +LockedErr = -40 +DeviceErr = -41 +DirErr = -42 +RecordErr = -43 +ReadOnlyErr = -44 +IoInvalidErr = -45 +PendingErr = -46 +VolumeErr = -47 +CancelErr = -48 +ReservedErr = -49 +DisconnectErr = -50 +ConnectErr = -51 +ReTransmitErr = -52 +LineErr = -53 +InActivityErr = -54 +ParityErr = -55 +FrameErr = -56 +OverrunErr = -57 +ModemConnectErr = -58 +ModemBusyErr = -59 +ModemNoAnswerErr = -60 +ModemBlacklistErr = -61 +NotReadyErr = -62 +UnknownErr = -63 +DirFullErr = -64 +WriteProtectErr = -65 +CorruptMediaErr = -66 +AbortErr = -67 +EraseErr = -68 +InvalidFileErr = -69 + .list + diff --git a/code/SIBOSDK/ldd/epoclib.inc b/code/SIBOSDK/ldd/epoclib.inc new file mode 100644 index 0000000..62e98e8 --- /dev/null +++ b/code/SIBOSDK/ldd/epoclib.inc @@ -0,0 +1,284 @@ + .xlist +; Include file - EPOCLIB.INC +; Epoc/Os plib standard include file. +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +EPOCLIB_INC equ 1 +; +_TANDW = 0 +ifdef LATTICE +CodeSeg macro +pgroup group prog +PGROUP equ +prog segment byte public 'prog' + assume cs:pgroup + endm +EndCodeSeg macro +prog ends + endm +DataSeg macro +dgroup group data,udata +DGROUP equ +data segment word public 'data' + assume ds:dgroup,es:dgroup,ss:dgroup + endm +EndDataSeg macro +data ends + endm +UDataSeg macro +udata segment word public 'data' + endm +EndUDataSeg macro +udata ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN NAME:TYPE + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC NAME +NAME label TYPE + ENDM +GLREF_C MACRO NAME + EXTRN NAME:NEAR + ENDM +endif +; +ifdef TURBOC +_TANDW = 1 +CodeSeg macro +PGROUP group _TEXT +pgroup equ +_TEXT segment byte public 'CODE' + assume cs:PGROUP + endm +EndCodeSeg macro +_TEXT ends + endm +DataSeg macro +DGROUP group _DATA,_BSS +dgroup equ +_DATA segment word public 'DATA' + assume ds:DGROUP,es:DGROUP,ss:DGROUP + endm +EndDataSeg macro +_DATA ends + endm +UDataSeg macro +_BSS segment word public 'BSS' + endm +EndUDataSeg macro +_BSS ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN _&NAME:TYPE +NAME EQU _&NAME + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC _&NAME +_&NAME label TYPE +NAME EQU _&NAME + ENDM +GLREF_C MACRO NAME + EXTRN _&NAME:NEAR +NAME EQU _&NAME + ENDM +endif +ifdef WATCOMC +REG_PARAM equ 1 +ifdef _MSC +_TANDW = 1 +endif +CodeSeg macro +PGROUP group _TEXT +pgroup equ +_TEXT segment byte public 'CODE' + assume cs:PGROUP + endm +EndCodeSeg macro +_TEXT ends + endm +DataSeg macro +DGROUP group _DATA,_BSS +dgroup equ +_DATA segment word public 'DATA' + assume ds:DGROUP,es:DGROUP,ss:DGROUP + endm +EndDataSeg macro +_DATA ends + endm +UDataSeg macro +_BSS segment word public 'BSS' + endm +EndUDataSeg macro +_BSS ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN NAME&_:TYPE +NAME EQU NAME&_ + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC NAME&_ +NAME&_ label TYPE +NAME EQU NAME&_ + ENDM +GLREF_C MACRO NAME + EXTRN NAME&_:NEAR +NAME EQU NAME&_ + ENDM +endif +ifdef JPIC +REG_PARAM equ 1 +ifdef _MSC +_TANDW = 1 +endif +CodeSeg macro +_TEXT segment byte public 'CODE' + assume cs:_TEXT + endm +EndCodeSeg macro +_TEXT ends + endm +DataSeg macro +DGROUP group _DATA,_BSS +dgroup equ +_DATA segment word public 'DATA' + assume ds:DGROUP,es:DGROUP,ss:DGROUP + endm +EndDataSeg macro +_DATA ends + endm +UDataSeg macro +_BSS segment word public 'BSS' + endm +EndUDataSeg macro +_BSS ends + endm +GLREF_D MACRO NAME,TYPE + EXTRN _&NAME:TYPE +NAME EQU _&NAME + ENDM +GLDEF_D MACRO NAME,TYPE + PUBLIC _&NAME +_&NAME label TYPE +NAME EQU _&NAME + ENDM +GLREF_C MACRO NAME + EXTRN _&NAME:NEAR +NAME EQU _&NAME + ENDM +endif +; +LOCAL_D MACRO NAME,TYPE +NAME label TYPE + ENDM +; +ProcBegin macro _Name,_Type,_Registers +ifdef TURBOC + ProcBeginBody _&_Name,_Type,_Registers +endif +ifdef JPIC + ProcBeginBody _&_Name,_Type,_Registers +endif +ifdef WATCOMC + ProcBeginBody _Name&_,_Type,_Registers +_Name EQU _Name&_ +endif +ifdef LATTICE + ProcBeginBody _Name,_Type,_Registers +endif + endm +ProcBegin@ macro _Name,_Type,_Registers + ProcBeginBody _Name,_Type,_Registers + endm +ProcBeginBody macro _Name,_Type,_Registers +_DI = 0 +_SI = 0 +if _TANDW +ifnb <_Registers> + irpc _flags,_Registers +ifidni <_flags>, +_DI = 1 +endif +ifidni <_flags>, +_SI = 1 +endif + endm +endif +endif +; +ProcEnd macro _flag +ifb <_flag> +if _DI + pop di +endif +if _SI + pop si +endif +if _TANDW +ifidni <_Type>, + pop bp +endif +endif +ifdef LATTICE +ifidni <_Type>, + pop bp +endif +endif + ret +endif +&_Name endp + endm +; + public _Name +ifidni <_Type>, +_Name proc far +else +_Name proc near +endif +ifidni <_Type>, +if _TANDW + push bp + mov bp, sp +endif +ifdef LATTICE + push bp + mov bp, sp +endif +Arg1 equ <[bp+4]> +Arg2 equ <[bp+6]> +Arg3 equ <[bp+8]> +Arg4 equ <[bp+10]> +Arg5 equ <[bp+12]> +Arg6 equ <[bp+14]> +Arg7 equ <[bp+16]> +Arg8 equ <[bp+18]> +endif +ifidni <_Type>, +if _TANDW + mov bx, sp +endif +ifdef LATTICE + mov bx, sp +endif +Arg1 equ <[bx+2]> +Arg2 equ <[bx+4]> +Arg3 equ <[bx+6]> +Arg4 equ <[bx+8]> +Arg5 equ <[bx+10]> +Arg6 equ <[bx+12]> +Arg7 equ <[bx+14]> +Arg8 equ <[bx+16]> +endif +if _SI + push si +endif +if _DI + push di +endif + endm +; + .list diff --git a/code/SIBOSDK/ldd/epocmac.inc b/code/SIBOSDK/ldd/epocmac.inc new file mode 100644 index 0000000..c2c249f --- /dev/null +++ b/code/SIBOSDK/ldd/epocmac.inc @@ -0,0 +1,512 @@ + .xlist +; Include file - EPOCMAC.INC +; Epoc/Os standard OS macro call definitions include file +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; 2.01F 25/03/91 NSM Added a number of extra functions. +; +EPOCMAC_INC equ 1 +; +__IntBase = 080h +; +BeginInterrupt macro __Name,__VIntBase +__IntVector = 0 +__Name macro + int __VIntBase + endm +IntEntry macro __EntName,__VIntVector +ifdef __DeclareNames +Nm&&__EntName = __VIntVector +endif +__EntName macro + mov ah, __VIntVector + int __VIntBase + endm +__IntVector = __IntVector+1 + endm +__IntBase = __IntBase+1 + endm +; +BeginInterrupt SegManager,%__IntBase +IntEntry SegFreeMemory,%__IntVector +IntEntry SegCreate,%__IntVector +IntEntry SegDelete,%__IntVector +IntEntry SegOpen,%__IntVector +IntEntry SegClose,%__IntVector +IntEntry SegSize,%__IntVector +IntEntry SegAdjustSize,%__IntVector +IntEntry SegFind,%__IntVector +IntEntry SegCopyTo,%__IntVector +IntEntry SegCopyFrom,%__IntVector +IntEntry SegLock,%__IntVector +IntEntry SegUnLock,%__IntVector +IntEntry SegRamDiskUsed,%__IntVector +IntEntry SegCloseLockedOrDevice,%__IntVector +IntEntry SegTotalK,%__IntVector +; +BeginInterrupt HeapManager,%__IntBase +IntEntry HeapAllocateCell,%__IntVector +IntEntry HeapReAllocateCell,%__IntVector +IntEntry HeapAdjustCellSize,%__IntVector +IntEntry HeapFreeCell,%__IntVector +IntEntry HeapCellSize,%__IntVector +IntEntry HeapSetGranularity,%__IntVector +IntEntry HeapFreeMemory,%__IntVector +; +BeginInterrupt SemManager,%__IntBase +IntEntry SemCreate,%__IntVector +IntEntry SemDelete,%__IntVector +IntEntry SemWait,%__IntVector +IntEntry SemSignalOnce,%__IntVector +IntEntry SemSignalMany,%__IntVector +IntEntry SemSignalOnceNoReSched,%__IntVector +; +BeginInterrupt MessManager,%__IntBase +IntEntry MessInit,%__IntVector +IntEntry MessReceiveAsynchronous,%__IntVector +IntEntry MessReceiveWithWait,%__IntVector +IntEntry MessReceiveCancel,%__IntVector +IntEntry MessSend,%__IntVector +IntEntry MessSendReceiveAsynchronous,%__IntVector +IntEntry MessSendReceiveWithWait,%__IntVector +IntEntry MessFree,%__IntVector +IntEntry MessSignal,%__IntVector +IntEntry MessSignalCancel,%__IntVector +IntEntry MessSignalCancelX,%__IntVector +; +BeginInterrupt LibManager,%__IntBase +IntEntry LibLoad,%__IntVector +IntEntry LibUnLoad,%__IntVector +IntEntry LibLink,%__IntVector +IntEntry LibFind,%__IntVector +IntEntry LibHandle,%__IntVector +IntEntry LibCreate,%__IntVector +IntEntry LibCreateByHandle,%__IntVector +IntEntry LibDestroy,%__IntVector +IntEntry LibCopy,%__IntVector +IntEntry LibOpen,%__IntVector +IntEntry LibLoadFile,%__IntVector +IntEntry LibReClass,%__IntVector +IntEntry LibReClassByHandle,%__IntVector +; +BeginInterrupt DevManager,%__IntBase +IntEntry IoOpen,%__IntVector +IntEntry DevOpenPDD,%__IntVector +IntEntry DevGetPDDAddress,%__IntVector +IntEntry DevInstall,%__IntVector +IntEntry DevHold,%__IntVector +IntEntry DevResume,%__IntVector +IntEntry DevLoadLDD,%__IntVector +IntEntry DevLoadPDD,%__IntVector +IntEntry DevDelete,%__IntVector +IntEntry DevQueryUnits,%__IntVector +IntEntry DevFind,%__IntVector +IntEntry DevRemove,%__IntVector +IntEntry DevVector,%__IntVector +; +BeginInterrupt IoManager,%__IntBase +IntEntry IoAsynchronous,%__IntVector +IntEntry IoAsynchronousNoError,%__IntVector +IntEntry IoWithWait,%__IntVector +IntEntry IoRoot,%__IntVector +IntEntry IoSuper,%__IntVector +IntEntry IoWaitForSignal,%__IntVector +IntEntry IoWaitForStatus,%__IntVector +IntEntry IoYield,%__IntVector +IntEntry IoSignal,%__IntVector +IntEntry IoSignalByPid,%__IntVector +IntEntry IoSignalByPidNoReSched,%__IntVector +IntEntry IoAddHandler,%__IntVector +IntEntry IoRemoveHandler,%__IntVector +IntEntry IoEnableHandler,%__IntVector +IntEntry IoRequestReset,%__IntVector +IntEntry IoRequestResetCancel,%__IntVector +IntEntry IoClose,%__IntVector +IntEntry IoRead,%__IntVector +IntEntry IoWrite,%__IntVector +IntEntry IoSeek,%__IntVector +IntEntry IoKeyAndMouseWithWait,%__IntVector +IntEntry IoAddApplicationHandler,%__IntVector +IntEntry IoRemoveApplicationHandler,%__IntVector +IntEntry IoEnableApplicationHandler,%__IntVector +IntEntry IoShiftStates,%__IntVector +IntEntry IoWaitForSignalNoHandler,%__IntVector +IntEntry IoSignalKillAsynchronous,%__IntVector +IntEntry IoSignalKillCancel,%__IntVector +IntEntry IoKeyAndMouseAsynchronous,%__IntVector +IntEntry IoNextHalfSecond,%__IntVector +IntEntry IoPlaySoundA,%__IntVector +IntEntry IoPlaySoundW,%__IntVector +IntEntry IoPlaySoundCancel,%__IntVector +IntEntry IoRecordSoundA,%__IntVector +IntEntry IoRecordSoundW,%__IntVector +IntEntry IoRecordSoundCancel,%__IntVector +IntEntry IoPlaySoundAO,%__IntVector +IntEntry IoPlaySoundWO,%__IntVector +; +BeginInterrupt FilManager,%__IntBase +IntEntry FilConnect,%__IntVector +IntEntry FilExecute,%__IntVector +IntEntry FilParse,%__IntVector +IntEntry FilPathGet,%__IntVector +IntEntry FilPathSet,%__IntVector +IntEntry FilPathTest,%__IntVector +IntEntry FilDelete,%__IntVector +IntEntry FilRename,%__IntVector +IntEntry FilStatusGet,%__IntVector +IntEntry FilStatusSet,%__IntVector +IntEntry FilStatusDevice,%__IntVector +IntEntry FilStatusSystem,%__IntVector +IntEntry FilMakeDirectory,%__IntVector +IntEntry FilOpenUnique,%__IntVector +IntEntry FilSystemAttach,%__IntVector +IntEntry FilSystemDetach,%__IntVector +IntEntry FilPathGetById,%__IntVector +IntEntry FilChangeDirectory,%__IntVector +IntEntry FilSetInitialPath,%__IntVector +IntEntry FilSetFileDate,%__IntVector +IntEntry FilLocChanged,%__IntVector +IntEntry FilLocDevice,%__IntVector +IntEntry FilLocReadPdd,%__IntVector +; +BeginInterrupt ProcManager,%__IntBase +IntEntry ProcId,%__IntVector +IntEntry ProcIdByName,%__IntVector +IntEntry ProcGetPriority,%__IntVector +IntEntry ProcSetPriority,%__IntVector +IntEntry ProcCreate,%__IntVector +IntEntry ProcCreateTask,%__IntVector +IntEntry ProcResume,%__IntVector +IntEntry ProcSuspend,%__IntVector +IntEntry ProcKill,%__IntVector +IntEntry ProcPanicById,%__IntVector +IntEntry ProcNameById,%__IntVector +IntEntry ProcFind,%__IntVector +IntEntry ProcRename,%__IntVector +IntEntry ProcTerminate,%__IntVector +IntEntry ProcOnTerminate,%__IntVector +IntEntry ProcWatchAllExits,%__IntVector +IntEntry ProcGetOwner,%__IntVector +IntEntry ProcKillReason,%__IntVector +; +BeginInterrupt TimManager,%__IntBase +IntEntry TimSleepForTenths,%__IntVector +IntEntry TimSleepForTicks,%__IntVector +IntEntry TimGetSystemTime,%__IntVector +IntEntry TimSetSystemTime,%__IntVector +IntEntry TimSystemTimeToDaySeconds,%__IntVector +IntEntry TimDaySecondsToSystemTime,%__IntVector +IntEntry TimDaySecondsToDate,%__IntVector +IntEntry TimDateToDaySeconds,%__IntVector +IntEntry TimDaysInMonth,%__IntVector +IntEntry TimDayOfWeek,%__IntVector +IntEntry TimNameOfDay,%__IntVector +IntEntry TimNameOfMonth,%__IntVector +IntEntry TimWaitAbsolute,%__IntVector +IntEntry TimWeekNumber,%__IntVector +IntEntry TimNameOfDayAbb,%__IntVector +IntEntry TimNameOfMonthAbb,%__IntVector +; +BeginInterrupt ConvManager,%__IntBase +IntEntry ConvUnsignedIntToBuffer,%__IntVector +IntEntry ConvUnsignedLongIntToBuffer,%__IntVector +IntEntry ConvIntToBuffer,%__IntVector +IntEntry ConvLongIntToBuffer,%__IntVector +IntEntry ConvArgumentsToBuffer,%__IntVector +IntEntry ConvStringToUnsignedInt,%__IntVector +IntEntry ConvStringToUnsignedLongInt,%__IntVector +IntEntry ConvStringToInt,%__IntVector +IntEntry ConvStringToLongInt,%__IntVector +IntEntry ConvFloatToBuffer,%__IntVector +IntEntry ConvStringToFloat,%__IntVector +; +BeginInterrupt GenManager,%__IntBase +IntEntry GenVersion,%__IntVector +IntEntry GenLcdType,%__IntVector +IntEntry GenStartReason,%__IntVector +IntEntry GenParse,%__IntVector +IntEntry LongUnsignedIntRandom,%__IntVector +IntEntry GenGetCountryData,%__IntVector +IntEntry GenGetErrorText,%__IntVector +IntEntry GenGetOsData,%__IntVector +IntEntry GenDeferredMode,%__IntVector +IntEntry GenNotify,%__IntVector +IntEntry GenNotifyError,%__IntVector +IntEntry GenNotifyHook,%__IntVector +IntEntry GenNotifyUnHook,%__IntVector +IntEntry GenGetRamSizeInParas,%__IntVector +IntEntry GenGetCommandLine,%__IntVector +IntEntry GenGetSoundFlags,%__IntVector +IntEntry GenSetSoundFlags,%__IntVector +IntEntry GenSound,%__IntVector +IntEntry GenMarkActive,%__IntVector +IntEntry GenMarkNonActive,%__IntVector +IntEntry GenGetText,%__IntVector +IntEntry GenGetNotifyState,%__IntVector +IntEntry GenSetNotifyState,%__IntVector +IntEntry GenGetAutoSwitchOffValue,%__IntVector +IntEntry GenSetAutoSwitchOffValue,%__IntVector +IntEntry GenSetRevector,%__IntVector +IntEntry GenResetRevector,%__IntVector +IntEntry GenGetLanguageCode,%__IntVector +IntEntry GenGetSuffixes,%__IntVector +IntEntry GenGetAmPmText,%__IntVector +IntEntry GenSetCountryData,%__IntVector +IntEntry GenGetBatteryType,%__IntVector +IntEntry GenSetBatteryType,%__IntVector +IntEntry GenEnvBufferGet,%__IntVector +IntEntry GenEnvBufferSet,%__IntVector +IntEntry GenEnvBufferDelete,%__IntVector +IntEntry GenEnvBufferFind,%__IntVector +IntEntry GenEnvStringGet,%__IntVector +IntEntry GenEnvStringSet,%__IntVector +IntEntry GenEnvStringDelete,%__IntVector +IntEntry GenEnvStringFind,%__IntVector +IntEntry GenCrc,%__IntVector +IntEntry GenRomVersion,%__IntVector +IntEntry GenAlarmHook,%__IntVector +IntEntry GenAlarmUnHook,%__IntVector +IntEntry GenAlarmId,%__IntVector +IntEntry GenPasswordSet,%__IntVector +IntEntry GenPasswordTest,%__IntVector +IntEntry GenPasswordControl,%__IntVector +IntEntry GenPasswordQuery,%__IntVector +IntEntry GenTickle,%__IntVector +IntEntry GenSetConfig,%__IntVector +IntEntry GenMaskInit,%__IntVector +IntEntry GenMaskEncrypt,%__IntVector +IntEntry GenMaskDecrypt,%__IntVector +IntEntry GenSetOnEvents,%__IntVector +IntEntry GenGetAutoMains,%__IntVector +IntEntry GenSetAutoMains,%__IntVector +IntEntry GenCsToDsAlias,%__IntVector +IntEntry GenDsToCsAlias,%__IntVector +IntEntry GenSetCapsLockMode,%__IntVector +; +BeginInterrupt FloatManager,%__IntBase +ifndef SmallInclude +IntEntry FloatSin,%__IntVector +IntEntry FloatCos,%__IntVector +IntEntry FloatTan,%__IntVector +IntEntry FloatASin,%__IntVector +IntEntry FloatACos,%__IntVector +IntEntry FloatATan,%__IntVector +IntEntry FloatExp,%__IntVector +IntEntry FloatLn,%__IntVector +IntEntry FloatLog,%__IntVector +IntEntry FloatSqrt,%__IntVector +IntEntry FloatPow,%__IntVector +IntEntry FloatRand,%__IntVector +IntEntry FloatMod,%__IntVector +IntEntry FloatInt,%__IntVector +endif +; +BeginInterrupt WservOpcodes,%__IntBase +; +BeginInterrupt HardwareManager,%__IntBase +ifndef SmallInclude +IntEntry HwComboOn,%__IntVector +IntEntry HwComboOff,%__IntVector +IntEntry HwPacksOn,%__IntVector +IntEntry HwPacksOff,%__IntVector +IntEntry HwSetA2Control1Bits,%__IntVector +IntEntry HwClearA2Control1Bits,%__IntVector +IntEntry HwReadA2Control1,%__IntVector +IntEntry HwWriteA2Control1,%__IntVector +IntEntry HwSetA2Control2Bits,%__IntVector +IntEntry HwClearA2Control2Bits,%__IntVector +IntEntry HwReadA2Control2,%__IntVector +IntEntry HwWriteA2Control2,%__IntVector +IntEntry HwSetA2Control3Bits,%__IntVector +IntEntry HwClearA2Control3Bits,%__IntVector +IntEntry HwReadA2Control3,%__IntVector +IntEntry HwWriteA2Control3,%__IntVector +IntEntry HwSelectChannel,%__IntVector +IntEntry HwGetSupplyStatus,%__IntVector +IntEntry HwLcdContrastDelta,%__IntVector +IntEntry HwReadLcdContrast,%__IntVector +IntEntry HwSwitchOff,%__IntVector +IntEntry HwNullFrame,%__IntVector +IntEntry HwExit,%__IntVector +IntEntry HwGetCombo,%__IntVector +IntEntry HwFreeCombo,%__IntVector +IntEntry HwGetChannel,%__IntVector +IntEntry HwFreeChannel,%__IntVector +IntEntry HwGetPsuType,%__IntVector +IntEntry HwSupplyWarnings,%__IntVector +IntEntry HwForceSupplyReading,%__IntVector +IntEntry HwGetBackLight,%__IntVector +IntEntry HwSetBackLight,%__IntVector +IntEntry HwBackLight,%__IntVector +IntEntry HwComboOnInput,%__IntVector +IntEntry HwSupplyInfo,%__IntVector +IntEntry HwScreenSeg,%__IntVector +IntEntry HwGetScreenMode,%__IntVector +IntEntry HwSetScreenMode,%__IntVector +IntEntry HwSetPCurrent,%__IntVector +IntEntry HwSetFCurrent,%__IntVector +IntEntry HwGetScanCodes,%__IntVector +IntEntry HwGetSsdData,%__IntVector +IntEntry HwResetBatteryStatus,%__IntVector +IntEntry HwEnableAutoBatReset,%__IntVector +IntEntry HwGetBatData,%__IntVector +IntEntry HwDetectSoakTestFixture,%__IntVector +IntEntry HwReLogPacks,%__IntVector +IntEntry HwSetIRPowerLevel,%__IntVector +IntEntry HwReturnTickCount,%__IntVector +IntEntry HwReturnExpansionPortState,%__IntVector +IntEntry HwExpansionOn,%__IntVector +IntEntry HwExpansionOff,%__IntVector +endif +; +BeginInterrupt GenDataSegment,%__IntBase +BeginInterrupt ProcPanic,%__IntBase +BeginInterrupt ProcCopyFromById,%__IntBase +BeginInterrupt ProcCopyToById,%__IntBase +BeginInterrupt CharIsDigit,%__IntBase +BeginInterrupt CharIsHexDigit,%__IntBase +BeginInterrupt CharIsPrintable,%__IntBase +BeginInterrupt CharIsAlphabetic,%__IntBase +BeginInterrupt CharIsAlphaNumeric,%__IntBase +BeginInterrupt CharIsUpperCase,%__IntBase +BeginInterrupt CharIsLowerCase,%__IntBase +BeginInterrupt CharIsSpace,%__IntBase +BeginInterrupt CharIsPunctuation,%__IntBase +BeginInterrupt CharIsGraphic,%__IntBase +BeginInterrupt CharIsControl,%__IntBase +BeginInterrupt CharToUpperChar,%__IntBase +BeginInterrupt CharToLowerChar,%__IntBase +BeginInterrupt CharToFoldedChar,%__IntBase +BeginInterrupt BufferCopy,%__IntBase +BeginInterrupt BufferSwap,%__IntBase +BeginInterrupt BufferCompare,%__IntBase +BeginInterrupt BufferCompareFolded,%__IntBase +BeginInterrupt BufferMatch,%__IntBase +BeginInterrupt BufferMatchFolded,%__IntBase +BeginInterrupt BufferLocate,%__IntBase +BeginInterrupt BufferLocateFolded,%__IntBase +BeginInterrupt BufferSubBuffer,%__IntBase +BeginInterrupt BufferSubBufferFolded,%__IntBase +BeginInterrupt BufferJustify,%__IntBase +BeginInterrupt StringCopy,%__IntBase +BeginInterrupt StringCopyFolded,%__IntBase +BeginInterrupt StringConvertToFolded,%__IntBase +BeginInterrupt StringCompare,%__IntBase +BeginInterrupt StringCompareFolded,%__IntBase +BeginInterrupt StringMatch,%__IntBase +BeginInterrupt StringMatchFolded,%__IntBase +BeginInterrupt StringLocate,%__IntBase +BeginInterrupt StringLocateFolded,%__IntBase +BeginInterrupt StringLocateInReverse,%__IntBase +BeginInterrupt StringLocateInReverseFolded,%__IntBase +BeginInterrupt StringSubString,%__IntBase +BeginInterrupt StringSubStringFolded,%__IntBase +BeginInterrupt StringLength,%__IntBase +BeginInterrupt StringValidateName,%__IntBase +BeginInterrupt LongIntCompare,%__IntBase +BeginInterrupt LongIntMultiply,%__IntBase +BeginInterrupt LongIntDivide,%__IntBase +BeginInterrupt LongUnsignedIntCompare,%__IntBase +BeginInterrupt LongUnsignedIntMultiply,%__IntBase +BeginInterrupt LongUnsignedIntDivide,%__IntBase +BeginInterrupt FloatAdd,%__IntBase +BeginInterrupt FloatSubtract,%__IntBase +BeginInterrupt FloatMultiply,%__IntBase +BeginInterrupt FloatDivide,%__IntBase +BeginInterrupt FloatCompare,%__IntBase +BeginInterrupt FloatNegate,%__IntBase +BeginInterrupt FloatToInt,%__IntBase +BeginInterrupt FloatToUnsignedInt,%__IntBase +BeginInterrupt FloatToLong,%__IntBase +BeginInterrupt FloatToUnsignedLong,%__IntBase +BeginInterrupt IntToFloat,%__IntBase +BeginInterrupt UnsignedIntToFloat,%__IntBase +BeginInterrupt LongToFloat,%__IntBase +BeginInterrupt UnsignedLongToFloat,%__IntBase +BeginInterrupt LibSend,%__IntBase +BeginInterrupt LibSendSuper,%__IntBase +BeginInterrupt LibSendExact,%__IntBase +BeginInterrupt LibEnter,%__IntBase +BeginInterrupt LibLeave,%__IntBase +BeginInterrupt Dummy,%__IntBase +BeginInterrupt GenIntByNumber,%__IntBase +BeginInterrupt WservFunctions,%__IntBase +BeginInterrupt LibSendExit,%__IntBase +BeginInterrupt DbfManager,%__IntBase +ifndef SmallInclude +IntEntry DbfOpen,%__IntVector +IntEntry DbfClose,%__IntVector +IntEntry DbfFlush,%__IntVector +IntEntry DbfTrash,%__IntVector +IntEntry DbfCopyDown,%__IntVector +IntEntry DbfCompress,%__IntVector +IntEntry DbfCopyFile,%__IntVector +IntEntry DbfFileSize,%__IntVector +IntEntry DbfExtHeaderRead,%__IntVector +IntEntry DbfExtHeaderWrite,%__IntVector +IntEntry DbfVersion,%__IntVector +IntEntry DbfAbsReadSense,%__IntVector +IntEntry DbfAbsRead,%__IntVector +IntEntry DbfNextRead,%__IntVector +IntEntry DbfBackRead,%__IntVector +IntEntry DbfFirstRead,%__IntVector +IntEntry DbfLastRead,%__IntVector +IntEntry DbfAppend,%__IntVector +IntEntry DbfEraseRead,%__IntVector +IntEntry DbfUpdate,%__IntVector +IntEntry DbfFindRead,%__IntVector +IntEntry DbfSense,%__IntVector +IntEntry DbfCount,%__IntVector +IntEntry DbfDescRecordRead,%__IntVector +IntEntry DbfDescRecordWrite,%__IntVector +IntEntry DbfFindReadField,%__IntVector +endif +BeginInterrupt LibEnterSend,%__IntBase +BeginInterrupt IoKeyAndMouseStatus,%__IntBase +BeginInterrupt StringCapitalise,%__IntBase +BeginInterrupt ProcIndStringCopyFromById,%__IntBase +BeginInterrupt IoNextHalfSecondStatus,%__IntBase + +BeginInterrupt IoSerManager,%__IntBase +ifndef SmallInclude +IntEntry IoSerOpen,%__IntVector +IntEntry IoSerAddHandler,%__IntVector +IntEntry IoSerRemoveHandler,%__IntVector +IntEntry IoSerSetHandler,%__IntVector +IntEntry IoSerHandlerSaveError,%__IntVector +IntEntry IoSerOpenHandler,%__IntVector +IntEntry IoSerOpenTimerHandler,%__IntVector +IntEntry IoSerFree,%__IntVector +IntEntry IoSerCloseTimerHandler,%__IntVector +IntEntry IoSerDetachFree,%__IntVector +IntEntry IoSerTimerOpen,%__IntVector +IntEntry IoSerTimerCancel,%__IntVector +IntEntry IoSerTimerClose,%__IntVector +IntEntry IoSerAttachOnOpenChan,%__IntVector +IntEntry IoSerSenseOnOpenChan,%__IntVector +IntEntry IoSerOnOpenChan,%__IntVector +IntEntry IoSerCheckWriteSI,%__IntVector +IntEntry IoSerCheckReadSI,%__IntVector +IntEntry IoSerSignalUserWriteOk,%__IntVector +IntEntry IoSerSignalUserWrite,%__IntVector +IntEntry IoSerSignalUserReadOk,%__IntVector +IntEntry IoSerSignalUserRead,%__IntVector +IntEntry IoSerSignalUser,%__IntVector +IntEntry IoSerQueueRead,%__IntVector +IntEntry IoSerQueueWrite,%__IntVector +IntEntry IoSerQueueSuper,%__IntVector +IntEntry IoSerQueueTimer,%__IntVector +IntEntry IoSerCancelIoRequest,%__IntVector +IntEntry IoSerCancelAllSignalUser,%__IntVector +IntEntry IoSerSignalCompleteOK,%__IntVector +IntEntry IoSerSignalComplete,%__IntVector +IntEntry IoSerSyncWrite,%__IntVector +endif +BeginInterrupt HwSetRomBank,%__IntBase +BeginInterrupt HwGetRomBank,%__IntBase +BeginInterrupt IoActivity,%__IntBase + .list + diff --git a/code/SIBOSDK/ldd/epocpan.inc b/code/SIBOSDK/ldd/epocpan.inc new file mode 100644 index 0000000..b59201e --- /dev/null +++ b/code/SIBOSDK/ldd/epocpan.inc @@ -0,0 +1,91 @@ + .xlist +; Include file - EPOCPAN.INC +; Epoc/Os standard panic number include file +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +EPOCPAN_INC = 1 +; +PanicTest0 = 00 ; Test code panic +PanicSem0 = 01 ; Invalid function number for semaphore manager +PanicSem1 = 02 ; Semaphore number out of range +PanicSem2 = 03 ; Semaphore not allocated +PanicSem3 = 04 ; Initial semaphore count not 0 or +ve +PanicSem4 = 05 ; Signal count not >= 0 +PanicProc0 = 06 ; Invalid function number for process manager +PanicProc1 = 07 ; Process Id out of range +PanicProc2 = 08 ; Task tried to create a task +PanicTim0 = 09 ; Invalid function number for time manager +PanicSeg0 = 10 ; Invalid function number for segment manager +PanicSeg1 = 11 ; Size was negative +PanicSeg2 = 12 ; Type was neither CreateLow or High or Device +PanicSeg3 = 13 ; Segment handle was invalid +PanicSeg4 = 14 ; Segment copy would have been out of range +PanicHeap0 = 15 ; Invalid function number for heap manager +PanicHeap1 = 16 ; Heap is not allocated +PanicHeap2 = 17 ; Cell being reduced by more than its size +PanicHeap3 = 18 ; Attempt to set heap granularity > MaxHeapGrowBy +PanicHeap4 = 19 ; Cell base address invalid +PanicMess0 = 20 ; Invalid function number for message manager +PanicMess1 = 21 ; Messages are already initialized +PanicMess2 = 22 ; Messages are not initialized +PanicMess3 = 23 ; Cannot initialize with 0 messages in the que +PanicIo0 = 24 ; Invalid function number for I/o manager +PanicIo1 = 25 ; Invalid Io channel +PanicIo2 = 26 ; Device requested panic +PanicIo3 = 27 ; Invalid handler handle +PanicIo4 = 28 ; Key and Mouse already hooked +PanicIo5 = 29 ; Key and Mouse requesting process is not a task +PanicDev0 = 30 ; Invalid function number for device manager +PanicDev1 = 31 ; Inavlid device handle +PanicFile0 = 32 ; Invalid function number for file manager +PanicFile1 = 33 ; Process already connected to file server +PanicFile2 = 34 ; Argument was'nt IoFuncSet or IoFuncSense +PanicLib0 = 35 ; Invalid function number for library manager +PanicLib1 = 36 ; Invalid library handle +PanicLib2 = 37 ; Invalid function number for library +PanicLib3 = 38 ; Invalid LIB file channel +PanicLib4 = 39 ; Invalid DYL index number +PanicFs0 = 40 ; Invalid message to file server +PanicFs1 = 41 ; Process has not connected to file server +PanicConv0 = 42 ; Invalid function number for conversion manager +PanicGen0 = 43 ; Invalid function number for general manager +PanicGen1 = 44 ; Attempt to unhook from alarm or notify when not already hooked +PanicGen2 = 45 ; Invalid revector address +PanicFlt0 = 46 ; Invalid function number for conversion manager +PanicEnter0 = 47 ; Leave called before a call to enter +PanicObj0 = 48 ; No method available to handle message +PanicObj1 = 49 ; Invalid reclass attempted +PanicObj2 = 50 ; Unknown category in LibHandle +PanicObj3 = 51 ; Unknown class in LibCreate +PanicObj4 = 52 ; Supersend called from outside a method +PanicObj5 = 53 ; Attempt to get a handle before being linked +PanicObj6 = 54 ; Missing external categories in LibLink +PanicObj7 = 55 ; Object does not point to a valid class +PanicLink0 = 56 ; Invalid link layer completion code +PanicWin0 = 57 ; Invalid function number for window manager +PanicHw0 = 58 ; Invalid function number for hardware manager +PanicHw1 = 59 ; Unexpected interrupt +PanicHw2 = 60 ; User wrote out of range +PanicHw3 = 61 ; User left interrupts off +PanicHaymd0 = 62 ; Bad things going on in the i/o system +PanicDivide = 63 ; Divide by zero interrupt +PanicOverflow = 64 ; Overflow interrupt +PanicDbf0 = 65 ; Invalid function number for Dbf manager +PanicDbf1 = 66 ; Invalid DBF Io channel +PanicDbf2 = 67 ; Invalid parameter for DBF function +PanicDead0 = 68 ; Address 0 overwrite +PanicStack0 = 69 ; Stack below 100h +PanicEnv0 = 70 ; Environment name size > EnvMaxNameSize +PanicSStep = 71 ; Single step interrupt +PanicBreak = 72 ; Break point interrupt +PanicIoPending = 73 ; Io was already pending +PanicIoSer0 = 74 ; Invalid function number for serial I/O manager +PanicIoAsic9 = 75 ; Call to an asic1 function on asic9 machines +PanicLib5 = 76 ; Trying to find a .DYL not in a visible bank +PanicEM$1 = 77 ; FP Emulator exception +PanicSem5 = 78 ; Semaphore count exceeds 07fffh + .list diff --git a/code/SIBOSDK/ldd/epocser.inc b/code/SIBOSDK/ldd/epocser.inc new file mode 100644 index 0000000..319bc43 --- /dev/null +++ b/code/SIBOSDK/ldd/epocser.inc @@ -0,0 +1,298 @@ + .xlist +; Include file - EPOCSER.INC +; Epoc/Os standard Serial Driver defines +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 JH Final release +; 2.01F 05/10/90 JH Added a define for Constant speed DTE modems +; +EPOCSER_INC equ 1 +; Serial port characteristics +SerialCharEnt struc + SerialCharTbaud db ? ; transmit Baud rate selector + SerialCharRbaud db ? ; receive Baud rate selector + SerialCharFrame db ? ; number of data, parity and stop bits + SerialCharParity db ? ; parity selector + SerialCharHandshake db ? ; handshake flags + SerialCharXon db ? ; XON character + SerialCharXoff db ? ; XOFF character + SerialCharFlags db ? ; control flags + SerialCharTmask dd ? ; terminator mask +SerialCharEnt ends + +; Function numbers to use to call PDD functions +SerPDDFuncOpen equ 0 +SerPDDFuncClose equ 2 +SerPDDFuncStart equ 4 +SerPDDFuncStop equ 6 +SerPDDFuncSet equ 8 +SerPDDFuncSense equ 10 +SerPDDFuncControl equ 12 +SerPDDFuncEnquire equ 14 +SerPDDFuncEnable equ 16 +SerPDDFuncSetHandlerCS equ 18 + +; +SERPARITY_ERR equ 0ffh +SERFRAME_ERR equ 0feh +SEROVERRUN_ERR equ 0fdh + +SERNOCHAR equ 0ffffh + +; Baud rates +P_BAUD_50 equ 01h +P_BAUD_75 equ 02h +P_BAUD_110 equ 03h +P_BAUD_134 equ 04h +P_BAUD_150 equ 05h +P_BAUD_300 equ 06h +P_BAUD_600 equ 07h +P_BAUD_1200 equ 08h +P_BAUD_1800 equ 09h +P_BAUD_2000 equ 0Ah +P_BAUD_2400 equ 0Bh +P_BAUD_3600 equ 0Ch +P_BAUD_4800 equ 0Dh +P_BAUD_7200 equ 0Eh +P_BAUD_9600 equ 0Fh +P_BAUD_19200 equ 10h +P_BAUD_38400 equ 11h +P_BAUD_56000 equ 12h +P_BAUD_115000 equ 13h + +; allocation of frame bits +P_DATA_FRM equ 0fh ; number of data bits mask +P_DATA_5 equ 0h ; 5 data bits +P_DATA_6 equ 1h ; 6 data bits +P_DATA_7 equ 2h ; 7 data bits +P_DATA_8 equ 3h ; 8 data bits +P_TWOSTOP equ 10h ; 2 stop bits if set, 1 if clear +P_PARITY equ 20h ; 1 parity bit if set, 0 if clear + +; parity - ignored unless P_PARITY is set +P_PAR_EVEN equ 1h ; even parity +P_PAR_ODD equ 2h ; odd parity +P_PAR_MARK equ 3h ; mark parity +P_PAR_SPACE equ 4h ; space parity + +; handshaking control +P_OBEY_XOFF equ 01h ; respond to received XOFF (and XON) if set +P_SEND_XOFF equ 02h ; send XOFF/XON to control receive buf if set +P_IGN_CTS equ 04h ; ignore the state of CTS if set +P_OBEY_DSR equ 08h ; obey the state of DSR if set +P_FAIL_DSR equ 10h ; fail if DSR goes OFF if set +P_OBEY_DCD equ 20h ; obey the state of DCD if set +P_FAIL_DCD equ 40h ; fail if DCD goes OFF if set + +; flags control +P_IGNORE_PARITY equ 01h ; ignore parity errors + +; For P_FCTRL function +P_SRCTRL_CTS equ 01h +P_SRCTRL_DSR equ 02h +P_SRCTRL_DCD equ 04h +P_SRCTRL_DTR equ 08h +P_SRCTRL_RTS equ 10h + +P_SRDTR_ON equ 1h ; to set DTR to MARK +P_SRDTR_OFF equ 2h ; to set DTR to SPACE + +; Bit masks for P_FINQ function +P_SRINQ_50 equ 0001h +P_SRINQ_75 equ 0002h +P_SRINQ_110 equ 0004h +P_SRINQ_134 equ 0008h +P_SRINQ_150 equ 0010h +P_SRINQ_300 equ 0020h +P_SRINQ_600 equ 0040h +P_SRINQ_1200 equ 0080h +P_SRINQ_1800 equ 0100h +P_SRINQ_2000 equ 0200h +P_SRINQ_2400 equ 0400h +P_SRINQ_3600 equ 0800h +P_SRINQ_4800 equ 1000h +P_SRINQ_7200 equ 2000h +P_SRINQ_9600 equ 4000h +P_SRINQ_19200 equ 8000h +; second baud rate word +P_SRINQ_38400 equ 0001h +P_SRINQ_56000 equ 0002h + +; 2nd set of info +P_SRINQ_DATA5 equ 0001h ; supports 5 data bits +P_SRINQ_DATA6 equ 0002h ; supports 6 data bits +P_SRINQ_DATA7 equ 0004h ; supports 7 data bits +P_SRINQ_DATA8 equ 0008h ; supports 8 data bits +P_SRINQ_STOP2 equ 0010h ; supports 2 stop bits (as well as 1) +P_SRINQ_PAREVEN equ 0020h ; supports even parity +P_SRINQ_PARODD equ 0040h ; supports odd parity +P_SRINQ_PARMARK equ 0080h ; supports mark parity +P_SRINQ_PARSPACE equ 0100h ; supports space parity +P_SRINQ_SETDTR equ 0200h ; can set DTR +P_SRINQ_SPLIT equ 0400h ; supports split Baud rates +P_SRINQ_XONXOFF equ 0800h ; Supports soft xon/xoff characters + +; CRC generator section +; The Low and High bytes of the 16 bit CRC +CrcEnt struc + CrcLow db ? ; CRC low byte + CrcHigh db ? ; CRC high byte +CrcEnt ends + +;Serial Driver Media Access Control section (LLMAC) +; +P_MAXILEN equ 300 ; maximum length of information field + +;Frame type codes +LA_LPDU equ 0 ; The Link Acknowledge PDU +LD_LPDU equ 1 ; The Link disconnect PDU +LR_LPDU equ 2 ; The Link Request PDU +LT_LPDU equ 3 ; The Link Data PDU +P_FRM_BROKEN equ 4 ; A broken frame + +FrameEnt struc + FrameType db ? ; frame type + FrameSeq db ? ; frame sequence + FrameLen dw ? ; length of information field + FramePbuf dw ? ; ptr to data buffer +FrameEnt ends + +; LLMAC layer characteristics +LlmacEnt struc + LlmacIlen dw ? ; maximum information field length + LlmacSpeed dw ? ; nominal speed in characters per second + LlmacRtint dw ? ; suggested retransmission interval +LlmacEnt ends + +; LINK layer structures and defines +; IoFuncConnect service connection modes */ +P_LINK_ACCP equ 0 ; want link as acceptor +P_LINK_INIT equ 1 ; want link as initiator + +; Link layer states +P_LINK_IDLE equ 0 ; no connection - idle +P_LINK_IDLE_LR equ 1 ; no connection - awaiting LR +P_LINK_DATA_IDLE equ 2 ; connected - idle +P_LINK_DATA_LA equ 3 ; connected - awaiting LA +P_LINK_IDLE_LA equ 4 ; not connected - awaiting LA (or LT) to LR + +;State and event log record +LinkLogEnt struc + LinkLogState db ? ; Link layer state (as defined above) + LinkLogEvent db ? ; Event that occured +LinkLogEnt ends + +P_LINK_NLOG equ 32 ; Max number of debug events,states we record +P_LINK_LOG_MASK equ 0C0h +P_LINK_LOG_PANIC equ 0C0h ; panic number +P_LINK_LOG_MAC equ 0 ; MAC request or timer +P_LINK_LOG_REQ equ 80h ; User request +P_LINK_LOG_COMP equ 40h ; User completion + +LinkDataEnt struc + LinkDataLlmac LlmacEnt <> + LinkDataBrokenCount dw ? ; count of broken frames + LinkDataRetranCount dw ? ; re-transmission count +LinkDataEnt ends + +; Comms I/O drivers shared code header structs +; Flag defines +RQ_TIMER equ 01h ; a timer has been started +RQ_SUPER equ 02h ; a supervisory read has been started +RQ_WRITE equ 04h ; a write has been started +RQ_READ equ 08h ; a data read has been started +RQ_DISABLE_HANDLER equ 10h ; set to disable handers +RQ_ANY equ (RQ_TIMER or RQ_SUPER or RQ_WRITE or RQ_READ) + +;Flag bits to indicate various features of the link layer event. +QUEUE_XMIT_LA equ 20h ; queue an LA when the transmit completes +LINK_ACTIVE equ 40h ; set between a P_FCONNECT and a disconnect +USER_DATA_PENDING equ 80h + +; DONT CHANGE THE ORDER OF THIS !! +IoRequestEnt struc + IoRequestChan ChanEnt <> ; I/O control block + IoRequestWaitHandler dw ? ; wait handler vector number + IoRequestRqRead RqEnt <> ; Read request packet + IoRequestRqWrite RqEnt <> ; Write request packet + IoRequestRqSuper RqEnt <> ; Supervisorry request packet + IoRequestTimerPcb dw ? ; open Timer cb + IoRequestTimerStat dw ? ; timer completion status + IoRequestReadStat dw ? ; read completion status + IoRequestWriteStat dw ? ; write completion status + IoRequestSuperStat dw ? ; supervisory completion status + IoRequestFlags db ? ; controlling flags + IoRequestState db ? ; current internal state +IoRequestEnt ends + +LnkEnt struc + LnkIoRequest IoRequestEnt <> ; I/O header + LnkLinkData LinkDataEnt <> ; Link layer data + LnkNumberLog dw ? ; current log table event no. + LnkLogTable db (size LinkLogEnt)*P_LINK_NLOG dup (?) +LnkEnt ends + +; XMODEM structures and defines +; IoFuncConnect service connection modes */ +P_XMDM_ACCP equ 0 ; want link as acceptor +P_XMDM_INIT equ 1 ; want link as initiator + +; Xmodem link types +P_XMDM_CRCORCHECKSUM equ 0 +P_XMDM_CRCMODE equ 1 +P_XMDM_CHECKSUMMODE equ 2 +P_YMODEM_MODE equ 3 +P_YMODEM_G_MODE equ 4 +P_XMDM_ONE_K equ 8000h + +;Xmodem/Ymodem supported flags +P_FXMDM_SENSE equ 0ffh ; I/O function number +P_XSUP_XMODEM equ 01h ; original Xmodem checksum +P_XSUP_XMODEM_CRC equ 02h ; Xmodem with CRC +P_XSUP_ONE_K_OPTION equ 04h ; 1k frames +P_XSUP_YMODEM equ 08h ; Ymodem +P_XSUP_YMODEM_G equ 10h ; Ymodem-G + +; Xmodem State defines +P_XMDM_IDLE equ P_LINK_IDLE ; idle state (no connection) +P_XMDM_CONNECT_RECEIVE equ 1 ; receive connect state +P_XMDM_CONNECT_TRANSMIT equ 2 ; Transmit connect state +P_XMDM_DATA_RECEIVE equ 3 ; receive data state +P_XMDM_DATA_TRANSMIT equ 4 ; transmit data state +P_XMDM_DATA_TRANSMIT_ACK equ 5 ; awaiting ACK to transmitted data + +;State and event log record +XmdmLogEnt struc + LinkLogEnt <> +XmdmLogEnt ends + +P_XMDM_NLOG equ P_LINK_NLOG ; Max number of debug events,states we record +P_XMDM_LOG_MASK equ P_LINK_LOG_MASK +P_XMDM_LOG_PANIC equ P_LINK_LOG_PANIC ; panic number +P_XMDM_LOG_REQ equ P_LINK_LOG_REQ ; User request +P_XMDM_LOG_COMP equ P_LINK_LOG_COMP ; User completion + +; Modem driver info +; what options are selected +P_MDM_TONE equ 01h +P_MDM_BELL equ 02h +P_MDM_NO_MODULATION equ 04h +P_MDM_CONSTANT_SPEED equ 08h ; modem provides constant speed interface if set + +; error correction types +P_MDM_ERRCORRECT_NONE equ 00h +P_MDM_ERRCORRECT equ 01h +P_MDM_ERRCORRECT_MNP equ 02h +P_MDM_ERRCORRECT_V42 equ 03h + +ModemCharEnt struc + ModemCharSupport dw ? ; flags saying what supported + ModemCharOptions dw ? ; Selected options + ModemCharBaudRate dw ? ; Baud rate running at + ModemCharConnHand db ? ; Connected handshaking + ModemCharCallHand db ? ; Wait for call handshaking +ModemCharEnt ends + + .list diff --git a/code/SIBOSDK/ldd/makefile b/code/SIBOSDK/ldd/makefile new file mode 100644 index 0000000..e2345f6 --- /dev/null +++ b/code/SIBOSDK/ldd/makefile @@ -0,0 +1,24 @@ +TASM = C:\BC\TASM +TLINK = C:\BC\TLINK +EMAKE = C:\TOOLS\EMAKE +all: snddvr.img sndfrc.img atimdvr.img +snddvr.img: snddvr.exe + $(EMAKE) -s -t2 snddvr +snddvr.exe: snddvr.obj + $(TLINK) /v /n snddvr +snddvr.obj: snddvr.asm + $(TASM) /ml snddvr.asm,snddvr.obj +sndfrc.img: sndfrc.exe + $(EMAKE) -s -t2 sndfrc +sndfrc.exe: sndfrc.obj + $(TLINK) /v /n sndfrc +sndfrc.obj: sndfrc.asm + $(TASM) /ml sndfrc.asm,sndfrc.obj +atimdvr.img: atimdvr.exe + $(EMAKE) -s -t2 atimdvr +atimdvr.exe: atimdvr.obj + $(TLINK) /v /n atimdvr +atimdvr.obj: atimdvr.asm + $(TASM) /ml atimdvr.asm,atimdvr.obj + + diff --git a/code/SIBOSDK/ldd/ossibo.inc b/code/SIBOSDK/ldd/ossibo.inc new file mode 100644 index 0000000..2d856fe --- /dev/null +++ b/code/SIBOSDK/ldd/ossibo.inc @@ -0,0 +1,241 @@ + .xlist +; Include file - OSSIBO.INC +; Epoc/Os Sibo include file. +; Copyright (c) Psion PLC 1989-90. +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 2.00F 30/09/90 NSM Final release +; +NoNullFrames equ 1 +; +A1Ent struc +A1Dummy dw ? +A1Control dw ? +A1LcdSize dw ? +A1LcdControl dw ? +A1InterruptMask dw ? +A1NonSpecificEoi dw ? +A1TimerEoi dw ? +A1FrcEoi dw ? +A1ResetWatchDog dw ? +A1FrcControl dw ? +A1ProtectionOn dw ? +A1ProtectionUpper dw ? +A1ProtectionLower dw ? +A1SoundLsw dw ? +A1SoundMsw dw ? +A1SoundControl dw ? +A1Ent ends +; +A1Status equ A1Control +A1ProtectionOff equ A1ProtectionOn +A1InterruptStatus equ A1LcdControl +; +A1StatusR record LcdData:2,Rtc4Hz:1,SldMsw:1,ComboBusy:1,Rtc32Hz:1,ExternalNmi:1,WatchDogNmi:1,SldTx:1,A1SldEnable:1,LcdEnable:1,Ram512:1,Ram128:1,FrcSource:1,TickRate:1,FrcMode:1 +A1LcdSizeR record LcdMLineEnable:1,LcdNumberOfPixels:5,LcdEndOfFrame:10 +A1LcdControlR record LcdMode:2,LcdMLineRate:5,LcdRate:5 +A1InterruptMaskR record SldTransmit:1,SldReceive:1,FrcExpired:1,Asic2Int:1,ExpIntLeftA:1,ExpIntRightB:1,Mains:1,Timer:1 +ExpAddressLeftA equ 0200h +ExpAddressRightB equ 0100h +ExpChannelLeftA equ SelectChannel6 +ExpChannelRightB equ SelectChannel5 +; +A2Ent struc +A2Dummy db 080h dup(?) +A2Index dw ? +A2Control dw ? +A2Control1 dw ? +A2Control2 dw ? +A2Control3 dw ? +A2SerialData dw ? +A2SerialControl dw ? +A2ChannelControl dw ? +A2Ent ends +; +A2External equ A2Control1 +A2InterruptStatus equ A2Control2 +A2Status equ A2Control3 +A2KeyData equ A2SerialControl +A2SlaveData equ A2ChannelControl +A2IControl0 equ 0 +A2IControl1 equ 1 +A2IWrite equ 2 +A2IDDR equ 3 +; +A2InterruptStatusR record SlaveDataOverrun:1,SlaveDataControl:1,SlaveDataValid:1,ExpansionInterrupt:1,DoorInterrupt:1 +A2StatusR record A2RevId:1,A2XExt:1,A2Sdis:1,SerialBusy:1,SerialClockState:1,ResetFlag:1,WakeUp:1,OnKey:1 +A2Control1R record SerialClockRate:2,KeyScan:4 +A2Control2R record ClockEnable7:1,ClockEnable6:1,ClockEnable5:1,BuzzerMode:1,BuzzerVolume:1,BuzzerToggle:1,XySwitch:1,DigitizerEnable:1 +A2Control3R record ElEnable:1,VhControl:1,ExpansionEnable:1,DoorEnable:1,SerialEnable:1,A2SldEnable:1,Ps34Acknowledge:1,SerialNull:1 +A2ChannelControlR record MultiplexEnable:1,ChannelSelect:3,Pack4Enable:1,Pack3Enable:1,Pack2Enable:1,Pack1Enable:1 +; +SerialWriteSingle equ 10000000b +SerialWriteMulti equ 10010000b +SerialReadSingle equ 11000000b +SerialReadMulti equ 11010000b +SerialReset equ 00000000b +SerialSelect equ 01000000b +ClockRateSlow equ 2 +ClockRateMedium equ 0 +ClockRateFast equ 3 +SelectChannel0 equ (4 shl ChannelSelect) +SelectChannel1 equ (mask Pack1Enable) +SelectChannel2 equ (mask Pack2Enable) +SelectChannel3 equ (mask Pack3Enable) +SelectChannel4 equ (mask Pack4Enable) +SelectChannel5 equ (5 shl ChannelSelect) +SelectChannel6 equ (6 shl ChannelSelect) +SelectChannel7 equ (7 shl ChannelSelect) +; +Asic4Id equ 001h +Asic5PackId equ 002h +Asic5NormalId equ 003h +Asic6Id equ 004h +Asic8Id equ 005h +Asic2SlaveId equ 01fh +; +A3Ent struc +A3Adc db ? +A3Control1 db ? +A3Setup db ? +A3Control2 db ? +A3Dummy1 db 3 dup (?) +A3Control3 db ? +A3Dummy2 db 5 dup (?) +A3Status db ? +A3Dummy3 db ? +A3Ent ends +; +A3AdcLsbR record InvertedBit:1,OtherBits:7 +A3AdcMsbR record Polarity:1,Overrange:1,AdcBits:4 +A3Control1R record Vcc5Enable:1,Vcc4Enable:1,Vcc3Enable:1,DtoaBits:5 +A3Control2R record AnalogueMultiplex:2,VhSoftStart:1,Vee2SoftStart:1,Vee1SoftStart:1,VhEnable:1,Vee2Enable:1,Vee1Enable:1 +A3Control3R record AdcReadHighEnable:1,OffEnable:1,xDummy1:1 +A3StatusR record PowerFail:1,ColdStart:1 +Ps34ControlR record Ps34Vcc3:1,xDummy2:1,Ps34Vcc4:1,xDummy3:1,Ps34Vcc5:1,xDummy4:3 +; +AdcDigitizer equ 0 +AdcVh equ 1 +AdcMainBattery equ 2 +AdcLithiumBattery equ 3 +A3SetupValue equ 2 +A3SelectId equ (SerialSelect or Asic5NormalId) +A3InfoByte equ 080h +; +Vee1SoftStartDelay equ (30*128) +Vee2SoftStartDelay equ (30*128) +VhSoftStartDelay equ (100*128) +Vee1OffDelay equ (100*128) +Vee2OffDelay equ (100*128) +VhOffDelay equ (100*128) +Vcc3Delay equ (25*128) +Vcc4Delay equ (25*128) +Vcc5Delay equ (25*128) +Vcc1_4To5Delay equ (3) ; Pan only in ms. +; +PS34R_ADC equ 0 +PS34R_STATUS equ 1 +PS34W_CONTROL equ 0 +PS34W_DTOA equ 1 +PS34W_OFF equ 0eh +; +PS34STATR record pPowerFail:1,pColdStart:1,pVhready:1,pPenup:1,pNc:1,pAdmsb:3 +PS34CONTR record pVcc3:1,pVee1:1,pVcc4:1,pVee2:1,pVcc5:1,pVh:1,pVhpower:2 +PS34DTOAR record pNcc:1,pAdcsel:2,pDac:5 +; +ADCSEL_ADCIN equ 0 +ADCSEL_VIN equ 1 +ADCSEL_VH equ 2 +ADCSEL_VBATT equ 3 +; +VHP1TO8 equ 0 +VHP1TO4 equ 1 +VHP1TO2 equ 2 +VHP1TO1 equ 3 +; +; Asic5 info byte structure +; +A5InfoByteR record A5TTL:1,A5Modem:1,A5MultiDrop:1,A5Barcode:1,A5Other:2,A5Parallel:1,A5Rs232:1 +A5OtherRom equ (1 shl A5Other) +A5OtherMCRTTL equ (3 shl A5Other) +A5MCR equ (2 shl A5Other) +; +PPowerControl equ 0100h +PPowerControlR record PVcc5Enable:1,PSoundEnable:1,PVee1Enable:1,PDropVoltage:1,PDac:4 +PPia record PSoundVol:2,PClearCold:1,PDcPresent:1,PColdFlag:1,PLithiumWarn:1,PVinWarn:1 +PSoundControl equ 0200h +; +if Consumer +DefaultLcdContrast equ 7 +else +DefaultLcdContrast equ 15 +endif +; +InterruptBase equ 078h +; +KeyPollColumns equ 10 +KeyInitialDelay equ 24 +if Consumer +KeyRepeatDelay equ 2 +else +KeyRepeatDelay equ 4 +endif +PenUpDelay equ 16 +MouseDownDelay equ 8 +KeySettleDelay equ 24 +KeyCntrlMask equ 00000001b +KeyLeftShiftMask equ 00000010b +KeyPsionMask equ 00000100b +KeyCapsMask equ 00001000b +KeyRightShiftMask equ 00010000b +DigitizerRowMask equ 00010000b +PsionScanCode equ 6 +CapsScanCode equ 5 +PsionUpScanCode equ 65 +; +PostRomTest equ 010h +PostSystemRamTest equ 020h +PostVideoRamTest equ 030h +PostComplete equ 0f0h +if Consumer +PostPort equ 0h +else +PostPort equ 01ffh +endif +; +if HandHeld +VideoRamSegment equ 00040h +VideoRamBase equ 00000h +if Corporate +VideoRamWords equ 00320h +else +VideoRamWords equ 00500h +endif +else +VideoRamSegment equ 0b800h +VideoRamBase equ 00000h +VideoRamWords equ 04000h +endif +; +CalSeg equ 0fffeh +CalEnt struc +CalVsupCLsw dw ? +CalVsupCMsw dw ? +CalVsupM dw ? +CalVlthCLsw dw ? +CalVlthCMsw dw ? +CalVlthM dw ? +CalType dw ? +CalEnt ends +; +CHKeyDataR record CHInSled:1,CHMains:1,CHDummy:2 +; +Vcc4OffFrames equ 25 ; Gives 512 frames = 10.0 ms +; +Vcc1_4to5OffFrames equ 20 ; Gives 392 frames = 6.0 ms +Vcc1_4to5OnTime equ 4 ; Gives 4 ms +; +IntBXHw equ -2 + .list + diff --git a/code/SIBOSDK/ldd/read.me b/code/SIBOSDK/ldd/read.me new file mode 100644 index 0000000..06cfca3 --- /dev/null +++ b/code/SIBOSDK/ldd/read.me @@ -0,0 +1,72 @@ +1) BUILDING SNDDVR.LDD, SNDFRC.LDD, ATIMDVR.LDD + ============================================ + +These drivers are supplied as both source (in this directory) and as +built drivers (in \SIBOSDK\LIB). + +To rebuild them you must use the Borland Turbo assembler. The file +MAKEFILE is supplied to simplify the building of all three drivers. +If necessary, edit the first two lines of MAKEFILE to agree with the +directory containing a copy of the Borland Turbo files TASM.EXE and +TLINK.EXE. + +Provided that the directory containing Borland Turbo MAKE.EXE is in +your path, you can then build all three drivers by typing: + + make RETURN + + +2) A note on SNDFRC.LDD + ==================== + +The SNDFRC driver is for the Series 3, since the Series 3a has a +built-in FRC device driver. SNDFRC is provided as an illustration +only. + +The driver code assumes that, while it is running, no system +code makes use of the Series 3 free-running counter (FRC). The +FRC, however, is used when sounding the buzzer and when the +Flash filing system writes to a Flash SSD. + +Writing to a Flash SSD or sounding the buzzer (for example, with +p_sound) while the SNDFRC driver is in use will cause the driver +to hang indefinitely. It is also likely that opening the driver +while writing to a Flash SSD is in progress could adversely affect +the Flash file device driver. + +Commercial software should not make use of the Series 3 FRC in the +manner illustrated in this example. + + +3) The HC Barcode Drivers + ====================== + +The following Barcode decoder/device drivers are provided +(in \SIBOSDK\LIB) for use on the HC: + + BAREAN.LDD + BARC39.LDD + BARITF.LDD + BARMPLES.LDD + BAR128.LDD + BARRAW.LDD + +4) The HC and Workabout Fast Charger Drivers + ========================================= + +The following drivers are provided (in \SIBOSDK\LIB): + + SYS$CHGH.LDD fast charger driver for the HC + SYS$FCHG.LDD fast charger driver for the Workabout + +The header file FCHARGE.H is also provided (in \SIBOSDK\INCLUDE). + +4) The Series 3c and Siena IR Drivers + ================================== + +The following drivers are provided (in \SIBOSDK\LIB): + + ACCESSIR.LDD the AcessIR driver, AIR: + IRLPT.LDD IR printer port driver, IRP: + +The header file MUX.H is also provided (in \SIBOSDK\INCLUDE). diff --git a/code/SIBOSDK/ldd/snddvr.asm b/code/SIBOSDK/ldd/snddvr.asm new file mode 100644 index 0000000..574d5b1 --- /dev/null +++ b/code/SIBOSDK/ldd/snddvr.asm @@ -0,0 +1,395 @@ + title SNDDVR -- Epoc/Os Sound Device Driver Example + subttl Copyright (c) Psion PLC 1992 + name SNDDVR +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 1.00A 21/04/92 JH Alpha release +; +TURBOC equ 1 +; + include epocdef.inc + include epocmac.inc + include epoclib.inc + include epocser.inc + include ossibo.inc + +HandlerDisable equ 000h ; the hnadler should not be called +HandlerEnable equ 001h ; the handler should be called + + CodeSeg + + ProcBegin@ SnddvrLDD +; ========== +; The externally loadable device table + dw LDDSignature + db 'MUS',0,0,0,0,0 + dw (VectorEnd-Vector)/2 +Vector: + dw SnddvrInstall + dw SnddvrRemove + dw SnddvrHold + dw SnddvrResume + dw SnddvrReset + dw SnddvrUnits + dw SnddvrOpen + dw SnddvrStrategy +VectorHandler: + dw SnddvrHandler +VectorEnd: + ProcEnd noret + +SoundChanOpen db ? + + ProcBegin@ CancelWrite +; =========== +; Cancel any outstanding I/O write request. +; Set the completion status word to E_FILE_CANCEL and signal the I/O +; semaphore. +; In: +; BX - sound control block ptr +; Out: +; NONE +; + mov dl, CancelErr + IoSerSignalUserWrite ; complete any write with E_FILE_CANCEL + IoSerTimerCancel ; harmless if nothing queued + mov al, HandlerDisable + IoSerSetHandler ; make SnddvrHandler non callable +; FALL THROUGH to StopSound + ProcEnd noret +; + + ProcBegin@ StopSound +; ========= +; Stop the sound by turning off the sound chip and shuting down the +; amplifier. +; In: +; BX - sound control block ptr +; Out: +; NONE +; + mov dx, PSoundControl + mov al, 1 + out dx, al ; stop sound chip + HwComboOff ; stop amplifier + ret + ProcEnd noret +; + + ProcBegin@ PlaySounds +; ========== +; Play any more sounds available. +; Set the note volume from bits 6 and 7 of the first byte. +; Write the note to the chip from bits 0-5 of the first byte. +; Queue the timer to expire on timeout specified in 2nd byte. +; In: +; BX - channel control blk +; Out: +; AL as required by SnddvrHandler routine +; + cmp [bx].IoRequestRqWrite.RqA2Ptr, 0 + je finishedAllNotes + cld + dec [bx].IoRequestRqWrite.RqA2Ptr ; one less note to play + mov si, [bx].IoRequestRqWrite.RqA1Ptr + lodsw ; note+volume to AL, duration to AH + mov [bx].IoRequestRqWrite.RqA1Ptr, si + xor cx, cx + mov cl, ah ; the duration (in 1/10ths) + push ax + shr ax, 1 ; factor out the volume bits + and al, 60h ; into bits 5+6 for the hardware + mov ah, al + mov al, A2IWrite + out A2Index, al + mov al, ah + out A2Control, al ; set the volume for that note + pop ax + mov dx, PSoundControl + and al, 3fh ; bottom 6 bits are note info + out dx, al ; and play the note + xor dx, dx + IoSerQueueTimer ; DX:CX is timeout in 1/10ths + mov al, 1 ; enable handler + ret +finishedAllNotes: + call StopSound ; stop sound activity + IoSerSignalUserWriteOk ; write request completed ok + xor ax, ax ; disable handler + ret + ProcEnd noret +; + + ProcBegin@ SnddvrInstall,far +; ============= +; Install vector called when application calls p_loadldd() +; In: +; NONE +; Out: +; Carry clear if installed ok +; Carry set if failed to install +; + and SoundChanOpen, 0 ; no channel open yet + clc ; installed OK + ret + ProcEnd noret +; + + ProcBegin@ SnddvrRemove,far +; ============ +; Remove vector called when application calls p_devdel() +; In: +; NONE +; Out: +; Carry clear if removed ok +; Carry set if failed to remove +; + cmp SoundChanOpen, 0 + je soundRemoved ; dont do anything if not open + mov al, InUseErr + stc ; channel open, fail to remove + ret + ProcEnd noret +; + + ProcBegin@ SnddvrReset,far +; =========== +; Reset vector called if the client terminated. +; We can only get a reset if weve got channel open and client died +; since we cancel the reset request when the channel is closed. +; NOTE: The clients data space no longer exists thus all data required to +; close down the channel must be avaliable in the drivers space. +; In: +; NONE +; Out: +; NONE +; + call StopSound + HwFreeCombo ; allow other sound components to work. + and SoundChanOpen, 0 ; no channel open now +soundRemoved: + clc ; removed OK. + ret + ProcEnd noret + + + ProcBegin@ SnddvrHold,far +; ========== +; Hold called when another driver loaded or switched off/power fail. +; In: +; AH - reason. +; Out: +; NONE + + cmp SoundChanOpen, 0 + je soundHeld ; dont do anything if not open + call StopSound ; stop any current sounds. +soundHeld: + ret + ProcEnd noret + + ProcBegin@ SnddvrResume,far +; ============ +; Resume called after a Hold to allow the driver to continue. +; If we were running the outstanding timer request will complete at some +; in the future at which point we will play the next note. +; Note - we dont immediatly start playing the note that was being played +; when the hold was called - this may be a bug for some applications. +; In: +; NONE +; Out: +; NONE + + cmp SoundChanOpen, 0 + je soundResumed ; dont do anything if not open + HwComboOn ; waithandler will run eventually +soundResumed: + ret ; when the timer expires if we were active. + ProcEnd noret + + ProcBegin@ SnddvrUnits,far +; =========== +; We can only handle 1 sound channel at a time. +; + mov ax, 1 ; support 1 unit at a time + ret + ProcEnd noret + + ProcBegin@ SnddvrOpen,far +; ========== +; Open the sound device driver. +; This runs is the context of the process that has called p_open("MUS:"). +; +; In: +; DS=ES=SS - Process data space. +; DX - OS device handle +; SI - ptr to OpenEnt struct +; Out: +; DX - OS device handle +; Carry Clear +; BX - channel, DX is as passed (device handle) +; Carry Set +; AL - error number +; +; All device drivers MUST have a ChanEnt as first item at returned BX +; + HwGetCombo ; see if already in use, if not grab it + jc sndAlreadyInUse + +; allocate in clients heap the I/O control block, add vector 9 as a +; waithandler and open a timer channel. Tidies up all resources if there +; are any errors. + mov cx, (size IoRequestEnt) + IoSerOpenTimerHandler + jc endOpenNoMemory ; sets up ChanEnt, returns BX + +; request reset vector be called if client terminates before closing channel + xchg bx, dx + xor cx, cx + IoRequestReset ; BX=device handle, CX= channel indicator + xchg bx, dx + mov SoundChanOpen, 1 + clc ; Opened Ok, BX=channel, DX=device + ret +; +endOpenNoMemory: + push ax + HwFreeCombo ; free up as failed + pop ax + stc +sndAlreadyInUse: + ret + ProcEnd noret + + ProcBegin@ SnddvrHandler,far +; ============== +; Called when an I/O signal is generated, it may be our timer to indicate +; that we should play the next note if any. +; In: +; DS,ES,SS == Process data space +; BX = the open sound channel +; Out: +; Carry clear +; Did not consume signal +; Carry set +; al = 0 - Leave handler disabled +; al = non 0 - Enable handler +; + +; check that were not currently in any StategyVector code, (anti nesting) + test [bx].IoRequestFlags, RQ_DISABLE_HANDLER + jnz signalNotForUs + +; see if we currently have a timer request outstanding + test [bx].IoRequestFlags, RQ_TIMER + jz signalNotForUs ; timer not queued + +; see if the outstanding timer has completed + cmp [bx].IoRequestTimerStat, PendingErr + je signalNotForUs ; timer still pending + +; timer completed, play next sound if any and re-queue timer + and [bx].IoRequestFlags, NOT RQ_TIMER + call PlaySounds ; returns AL as required + stc + ret +signalNotForUs: + clc ; we didnt use the signal + ret + ProcEnd noret + + + ProcBegin@ SnddvrStrategy,far +; ============== +; Strategy vector called by an I/O request on the opened sound device driver +; channel. +; The wait handler may be called (when enabled ) unless we block it when we +; call a sync I/O request. Allowing the waithandler to run whilst in the +; strategy vector is generally not a good thing to do. +; In this particular example there are synchronous calls to the I/O system +; to cancel the outstanding timer (if queued) and use the signal generated +; by the cancel. +; +; In: +; DS,ES,SS == Process data space +; BX == channel control block from open request +; DX == device handle +; SI == RqEnt pointer +; Out: +; Carry clear +; - request queued sucessfully (may have completed) +; Carry set +; - error queuing the I/O request +; + cld + +; Stop the WaitHandler from being called temporarily + or [bx].IoRequestFlags, RQ_DISABLE_HANDLER + + mov al, byte ptr [si].RqFunction + cmp al, IoFuncWrite + jne tryCancel + +; P_FWRITE I/O function request + mov di, [si].RqA2Ptr + mov cx, [di] ; length to write + mov di, [si].RqA1Ptr ; ptr to data to write + mov si, [si].RqStatusPtr + IoSerCheckWriteSI ; set *SI to Pending, PendingPanic's + mov [bx].IoRequestRqWrite.RqA2Ptr, cx + mov [bx].IoRequestRqWrite.RqA1Ptr, di + mov al, HandlerEnable + IoSerSetHandler ; make SnddvrHandler callable + HwComboOn ; start the amplifier + call PlaySounds ; start the sound + and [bx].IoRequestFlags, NOT RQ_DISABLE_HANDLER + ret +tryCancel: + cmp al, IoFuncCancel + jne tryClose + +; P_FCANCEL I/O function request + call CancelWrite ; cancel any outstanding requests + and [bx].IoRequestFlags, NOT RQ_DISABLE_HANDLER + jmp short signalOk ; cancel completed ok. +tryClose: + cmp al, IoFuncClose + jne notForUs + +; P_FCLOSE I/O function request + push bx + push dx + call CancelWrite ; cancel any outstanding requests + +; cancel the request to call the Reset vector + pop bx ; our I/O device handle + xor cx, cx ; MUST be same as passed to IoRequestReset + IoRequestResetCancel ; dont call reset vector now + +; close timer, remove handler, free alloc + pop bx + IoSerCloseTimerHandler + HwFreeCombo ; not in use any more + and SoundChanOpen, 0 ; no channel open now +signalOk: + xor ax, ax + mov di, [si].RqStatusPtr + stosw ; set completion status word to zero + IoSignal ; complete the I/O request + xor ax, ax ; also clears carry + ret +notForUs: + and [bx].IoRequestFlags, NOT RQ_DISABLE_HANDLER + IoRoot ; pass on request as not for us + ret + ProcEnd noret + + EndCodeSeg +; +stack segment stack para 'data' +; +stack ends +; + end SnddvrLDD + diff --git a/code/SIBOSDK/ldd/sndfrc.asm b/code/SIBOSDK/ldd/sndfrc.asm new file mode 100644 index 0000000..ba7302f --- /dev/null +++ b/code/SIBOSDK/ldd/sndfrc.asm @@ -0,0 +1,521 @@ + title SNDFRC -- Epoc/Os Sound Device Driver Using FRC + subttl Copyright (c) Psion PLC 1992 + name SNDFRC +; +; VER DATE BY DESCRIPTION +; ----- -------- ---- ----------- +; 1.00A 21/04/92 JH Alpha release +; +TURBOC equ 1 +; + include epocdef.inc + include epocmac.inc + include epocpan.inc + include epoclib.inc + include epocser.inc + include ossibo.inc + +HandlerDisable equ 000h ; the hnadler should not be called +HandlerEnable equ 001h ; the handler should be called + +MAX_NOTES equ 500 + +; This is allocated in the user space for the I/O channel +SndFrcEnt struc + SndFrcIo ChanEnt <> ; I/O channel hdr, MUST be first + SndFrcWrite RqEnt <> + SndFrcHandler dw ? + SndFrcFlags dw ? + SndFrcPstat dw ? +SndFrcEnt ends + +SndChannel struc + Pid dw ? ; owning channel pid + OpenFrcChan db ? ; channel open status (KEEP ORDER) + WriteStat db ? ; write completion status (ORDER) + DataPtr dw ? ; where we are in buffer + DataLength dw ? ; number of notes to play + DataPreBuffer dw ? ; First Frc timout ptr + DataBuffer dw MAX_NOTES dup (?) +SndChannel ends + + CodeSeg + + ProcBegin@ SndfrcLDD +; ========== +; The externally loadable device table + dw LDDSignature + db 'MUS',0,0,0,0,0 + dw (VectorEnd-Vector)/2 +Vector: + dw SndfrcInstall + dw SndfrcRemove + dw SndfrcHold + dw SndfrcResume + dw SndfrcReset + dw SndfrcUnits + dw SndfrcOpen + dw SndfrcStrategy +VectorHandler: + dw SndfrcHandler +VectorEnd: + ProcEnd noret + +SoundChan SndChannel <> + + ProcBegin@ disableFrcInt +; ============= +; Disable the generation of Frc interrupts +; + pushf + cli + in al, A1InterruptMask + and al, not (mask FrcExpired) + out A1InterruptMask, al ; stop Interrupt controller from + popf ; generating Frc interrupts + ret + ProcEnd +; + ProcBegin@ enableFrcInt +; ============ +; Starts the free running counter. +; + pushf + cli + in al, A1Control + or al, mask FrcSource or mask FrcMode + out A1Control, al ; set 512khz and prescale mode + mov ax, 5120 ; request a FrcInt every 10ms + out A1FrcControl, ax + out A1FrcEoi, al ; clear any junk Frc Interrupt + in al, A1InterruptMask + or al, mask FrcExpired ; allow interrupt controller to + out A1InterruptMask, al ; generate a Frc Interrupt + popf + ret + ProcEnd noret +; + + ProcBegin@ FrcInterrupt,far +; ============ +; The Frc interrupt routine. +; Although we could get addressability to the clients data space since it is +; possible that the operating system is currently moving the +; data space of the client in which case the data buffer to be played +; may not be valid. +; The ISR is called by the operating system after all registers have been +; preserved. +; We MUST NOT cause a reschedule directly since the ISR would take a long +; time to complete if we did. +; +; Called in the context of whatever was running when the interrupt went off +; + out A1FrcEoi, al ; clear Frc Interrupt + mov si, SoundChan.DataPtr + cmp byte ptr cs:[si+1], 0 ; look at the duration byte + je finishedThatNote ; if zero goto the next note + dec byte ptr cs:[si+1] ; reduce timeout +endFrcInterrupt: + stc ; no potential reschedule required +endFrcInterruptFlags: + out A1NonSpecificEoi, al ; finish the ISR + ret + +finishedThatNote: + cmp SoundChan.DataLength, 0 + je finishedAllNotes + dec SoundChan.DataLength ; one less note to play + inc si + inc si ; find next note,volume and duration + mov SoundChan.DataPtr, si ; updated ptr + mov al, byte ptr cs:[si] + push ax + shr ax, 1 ; factor out the volume bits + and al, 60h ; into bits 5+6 for the hardware + mov ah, al + mov al, A2IWrite + out A2Index, al + mov al, ah + out A2Control, al ; set the volume for that note + pop ax + mov dx, PSoundControl + and al, 3fh ; bottom 6 bits are note info + out dx, al ; and play that note + jmp short endFrcInterrupt +finishedAllNotes: + call StopSound + mov SoundChan.WriteStat, 0 ; finished playing that lot + mov bx, SoundChan.Pid ; get the channel owner + IoSignalByPidNoReSched ; signal ourselves, causes handler + clc ; reschedule if possible + jmp short endFrcInterruptFlags + ProcEnd noret +; + + ProcBegin@ setFrcIntVector +; =============== +; Set the ISR pointer to our FRC interrupt routine. +; MUST be done with ints disabled so we cant be moved by the operating +; system whilst setting the address. +; + pushf + cli + push bx + mov al, HwIrq5Revector + mov bx, offset FrcInterrupt + mov cx, cs ; this ok as ints disabled. + GenSetRevector + pop bx + popf + ret + ProcEnd noret +; + + ProcBegin@ StopSound +; ========= +; Stop the sound generation. +; + call disableFrcInt ; Stop Frc interrupts + mov dx, PSoundControl + mov al, 1 + out dx, al ; stop sound chip + HwComboOff ; stop amplifier + ret + ProcEnd noret + + ProcBegin@ SndfrcInstall,far +; ============= +; Install vector called when application calls p_loadldd() +; Set OpenFrcChan to zero. +; In: +; NONE +; Out: +; Carry clear if installed ok +; Carry set if failed to install +; + and SoundChan.OpenFrcChan, 0 + clc ; installed OK + ret + ProcEnd noret +; + + ProcBegin@ SndfrcRemove,far +; ============ +; Remove vector called when application calls p_devdel() +; + cmp SoundChan.OpenFrcChan, 0 + je soundRemoved + mov al, InUseErr + stc ; channel open, fail to remove + ret + ProcEnd noret +; + + ProcBegin@ SndfrcReset,far +; =========== +; Reset vector called if the client terminated. +; We can only get a reset if weve got channel open and client died +; since we cancel the reset request when the channel is closed. +; NOTE: The clients data space no longer exists thus all data required to +; close down the channel must be avaliable in the drivers space. +; In: +; NONE +; Out: +; NONE +; + call StopSound ; disable Frc ints etc + mov al, HwIrq5Revector + GenResetRevector ; restore the default ROM ISR vector + mov al, mask FrcExpired + HwFreeChannel ; free Frc resource + HwFreeCombo ; free up sound usage resource + and word ptr SoundChan.OpenFrcChan, 0 ; all closed now +soundRemoved: + clc ; removed OK. + ret + ProcEnd noret + + + ProcBegin@ SndfrcHold,far +; ========== +; Hold called when another driver loaded or switched off/power fail. +; In: +; AH - reason. +; Out: +; NONE + + cmp SoundChan.OpenFrcChan, 0 + je soundHeld ; dont do anything if not open + call StopSound ; shut down ints and sound +soundHeld: + ret + ProcEnd noret + + ProcBegin@ SndfrcResume,far +; ============ +; Resume called after a Hold to allow the driver to continue. +; If we were running enabling the Frc interrupt will cause the +; FrcInt routine to be called thus allowing us to count down the current +; duration as though nothing had happened before going to the next note. +; In: +; NONE +; Out: +; NONE +; + cmp SoundChan.OpenFrcChan, 0 + je soundResumed ; dont do anything if not open + call setFrcIntVector ; we may have moved, set CS correctly + cmp SoundChan.WriteStat, PendingErr + jne soundResumed ; dont enable ints if no write queued + HwComboOn ; switch amplifier on + call enableFrcInt ; continue where we left off +soundResumed: + ret + ProcEnd noret + + ProcBegin@ SndfrcUnits,far +; =========== +; We can only handle 1 sound channel at a time. +; + mov ax, 1 ; support 1 unit at a time + ret + ProcEnd noret + + ProcBegin@ SndfrcOpen,far +; ========== +; Open the sound device driver. +; This runs is the context of the process that has called p_open("MUF:"). +; +; In: +; DS=ES=SS - Process data space. +; DX - OS device handle +; SI - ptr to OpenEnt struct +; Out: +; DX - OS device handle +; Carry Clear +; BX - channel, DX is as passed (device handle) +; Carry Set +; AL - error number +; +; All device drivers MUST have a ChanEnt as first item at returned BX +; + HwGetCombo ; see if snd already in use, if not grab it + jc sndAlreadyInUse + mov al, mask FrcExpired + HwGetChannel ; see if FRC already in use, if not grab it + jc endFrcInUse + mov cx, (size SndFrcEnt) + HeapAllocateCell + jc endOpenNoMemory ; get users I/O channel + mov bx, ax ; the allocated cell handle + mov al, (VectorHandler-Vector)/2 + IoAddHandler ; handler handle in AX + jc endOpenFreeMemory + mov [bx].SndFrcHandler, ax + xchg bx, dx + xor cx, cx + IoRequestReset ; call Reset if client terminates + xchg bx, dx + mov [bx].SndFrcIo.ChanNext, bx ; we are a root device + mov [bx].SndFrcIo.ChanSignature, IoChanSignature + mov [bx].SndFrcIo.ChanLibHandle, dx ; This is our device handle + and [bx].SndFrcPstat, 0 ; no write pending yet + and [bx].SndFrcFlags, 0 + ProcId + mov SoundChan.Pid, ax ; remember client id for ISR + mov SoundChan.OpenFrcChan, 1 ; now open + call setFrcIntVector ; set up the ISR address ptr + clc + ret + +endOpenFreeMemory: + push ax + HeapFreeCell + pop ax +endOpenNoMemory: + push ax + mov al, mask FrcExpired + HwFreeChannel ; free Frc resource + pop ax +endFrcInUse: + push ax + HwFreeCombo ; free sound resource as failed somewhere + pop ax + stc +sndAlreadyInUse: + ret + ProcEnd noret + + ProcBegin@ SndfrcHandler,far +; ============== +; Called when an I/O signal is generated and were enabled. We should only +; enabled when a write request is outstanding. +; We need to check the LOW side drivers completion status to see if all the +; notes have been played yet (SoundChan.WriteStat!=E_FILE_PENDING). +; Typically write the handler defensivly since complex drivers may leave the +; handler enabled other than when a request is outstanding. +; +; In: +; DS,ES,SS == Process data space +; BX == channel control block from open request +; Out: +; Carry clear +; Did not consume signal +; Carry set +; al = 0 - Leave handler disabled +; al = non 0 - Enable handler +; + test [bx].SndFrcFlags, RQ_DISABLE_HANDLER + jnz signalNotForUs ; we are in StategyVector code + cmp [bx].SndFrcPstat, 0 + je signalNotForUs ; no write request queued yet + mov al, SoundChan.WriteStat + cmp al, PendingErr + je signalNotForUs ; pending write request not finished + cbw + xor si, si + xchg si, [bx].SndFrcPstat ; no write queued if Pstat is zero + mov [si], ax + IoSignal ; complete the original write request + xor ax, ax ; disable handler now + stc + ret +signalNotForUs: + clc + ret + ProcEnd noret + + ProcBegin@ CancelWrite +; =========== +; Cancel any outstanding write request +; + xor di, di + xchg di, [bx].SndFrcPstat + or di, di ; see if any write is currently queued + jz noWriteQueued + push bx + mov bx, [bx].SndFrcHandler + mov cl, HandlerDisable + IoEnableHandler ; make SndfrcHandler non callable + pop bx + call StopSound ; stops Frc ints + mov word ptr [di], CancelErr ; set write completion stat + IoSignal ; and signal write completion +noWriteQueued: + mov SoundChan.WriteStat, 0 + ret + ProcEnd noret +; + + ProcBegin@ SndfrcStrategy,far +; ============== +; Strategy vector called by an I/O request on the opened sound device driver +; channel. +; The wait handler may be called (when enabled ) unless we block it when we +; call a sync I/O request. Allowing the waithandler to run whilst in the +; strategy vector is generally not a good thing to do. +; In this particular example there are infact no sync calls to the I/O system +; thus the wait handler cannot be run. In more complex drivers it may be +; difficult to determine all possible paths through the code thus the driver +; should be written defensivly (use RQ_DISABLE_HANDLER type mechanism). +; In: +; DS,ES,SS == Process data space +; BX == channel control block from open request +; DX == device handle +; SI == RqEnt pointer +; Out: +; Carry clear +; - request queued sucessfully (may have completed) +; Carry set +; - error queuing the I/O request +; + cld + or [bx].SndFrcFlags, RQ_DISABLE_HANDLER + mov al, byte ptr [si].RqFunction + cmp al, IoFuncWrite + jne tryCancel + cmp [bx].SndFrcPstat, 0 + jne writeQueued ; panic if write already queued + mov di, [si].RqA2Ptr + mov cx, [di] ; length to write + cmp cx, MAX_NOTES + jae writeQueued ; length too much, panic dvr + mov di, [si].RqStatusPtr + mov word ptr [di], PendingErr + mov [bx].SndFrcPstat, di ; write request now queued + mov si, [si].RqA1Ptr ; ptr to data to write as sound + mov di, offset SoundChan.DataPreBuffer + and word ptr [di], 0 ; set pre buffer len to zero + mov SoundChan.DataPtr, di + inc di + inc di + mov SoundChan.DataLength, cx ; this many notes to play + mov SoundChan.WriteStat, PendingErr + pushf + cli ; we can set ES when ints are off + push cs + pop es ; copy the notes+vol and duration + popf ; into buf we can access in ISR + rep movsw ; dont use CS override + mov es, [bp].IntES + push bx + mov bx, [bx].SndFrcHandler + mov cl, HandlerEnable + IoEnableHandler ; allow waithandler to be called + pop bx + HwComboOn + call enableFrcInt ; start the sound off + and [bx].SndFrcFlags, NOT RQ_DISABLE_HANDLER + xor ax, ax ; queued OK + ret +writeQueued: + mov al, PanicIoPending + ProcPanic ; stop bad applications + +tryCancel: + cmp al, IoFuncCancel + jne tryClose + call CancelWrite ; stop any queued write + and [bx].IoRequestFlags, NOT RQ_DISABLE_HANDLER + jmp short signalOk ; cancel completed ok. +tryClose: + cmp al, IoFuncClose + jne notForUs + call CancelWrite ; stop any queued writes + push bx + push [bx].SndFrcHandler + push dx + mov al, HwIrq5Revector + GenResetRevector + pop bx ; channel handle + xor cx, cx + IoRequestResetCancel ; dont call Reset vector now + pop bx ; handler handle + IoRemoveHandler + pop bx ; alloc handle + HeapFreeCell + mov al, mask FrcExpired + HwFreeChannel ; free Frc resource + HwFreeCombo ; not in use any more + and word ptr SoundChan.OpenFrcChan, 0 ; all closed now +signalOk: + xor ax, ax + mov di, [si].RqStatusPtr + stosw ; the I/O request completed OK + IoSignal + xor ax, ax ; also clears carry + ret +notForUs: + and [bx].IoRequestFlags, NOT RQ_DISABLE_HANDLER + IoRoot ; pass on request as not for us + ret + ProcEnd noret + + EndCodeSeg +; +stack segment stack para 'data' +; +stack ends +; + end SndfrcLDD + diff --git a/code/SIBOSDK/ldd/t_atim.c b/code/SIBOSDK/ldd/t_atim.c new file mode 100644 index 0000000..f5555d4 --- /dev/null +++ b/code/SIBOSDK/ldd/t_atim.c @@ -0,0 +1,64 @@ +/* +T_ATIM.C - Test the attached timer a bit + +Written by John, February 1992 +*/ + +#include +#include +#include + +LOCAL_C VOID panic( + INT num, + INT errno) + { + UBYTE b[100]; + + p_errs(&b[p_atos(&b[0],"panic num %d - ",num)],errno); + t_panic(&b[0]); + } + +GLDEF_C main(VOID) + { + UWORD len; + WORD stat; + INT ret; + UBYTE *pcb; + ULONG timeout; + UBYTE bb[10]; + GLREF_D P_DEVICE p_wind,p_file; + + p_inst(&p_wind,&p_file,NULL_D); + if (ret=p_loadldd("ATIMDVR.LDD")) + panic(1,ret); + if (ret=p_open(&pcb,"TTY:A")) + panic(2,ret); + if (ret=p_open(&pcb,"ATM:",0)) + panic(3,ret); + timeout=50L; /* 5 second timeout */ + if (ret=p_iow(pcb,P_FSET,&timeout)) + panic(4,ret); + +/* +Once the device driver hierarchy has been set up the I/O requests are +identical between a driver with and a driver without an attached timeout +driver, except of course that the attached timeout driver will not wait +forever if no characters can be read. +*/ + len=10; + p_ioc(pcb,P_FREAD,&stat,&bb[0],&len); + p_iow(pcb,P_FCANCEL); + p_waitstat(&stat); + if (stat!=E_FILE_CANCEL) + panic(5,stat); + if ((ret=p_read(pcb,&bb[0],10))!=E_FILE_INACT) + panic(6,ret); /* times out after 5 seconds */ + + + p_close(pcb); + p_close(pcb); + if (ret=p_devdel("ATM",E_LDD)) + panic(7,ret); + return(0); + } + diff --git a/code/SIBOSDK/ldd/t_mus.c b/code/SIBOSDK/ldd/t_mus.c new file mode 100644 index 0000000..34b01eb --- /dev/null +++ b/code/SIBOSDK/ldd/t_mus.c @@ -0,0 +1,118 @@ +/* +T_MUS.C - Test the musical sound driver a bit + +Written by John, April 1992 +*/ + +#include + +/* all are 1 sec duration by default */ +LOCAL_D UBYTE notes[] = { +/* Basic note numbers */ + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, + 0x38, + 0x39, + 0x3a, + 0x29, + 0x3b, + 0x3c, + 0x3d, + 0x0e, + 0x3e, + 0x2c, + 0x3f, + 0x04, + 0x05, + 0x25, + 0x2f, + 0x06, + 0x07 + }; + +LOCAL_D WORD volume=0; /* volume to use */ +LOCAL_D WORD length=10; /* length of notes */ + +LOCAL_C VOID panic( + INT num, + INT errno) + { + TEXT b[100]; + + p_errs(&b[p_atob(&b[0],"panic num %d - ",&num)],errno); + t_panic(&b[0]); + } + +GLDEF_C main(VOID) + { + INT ret,i; + VOID *pcb; + UBYTE bb[100],*p; + + p_loadldd("SNDDVR.LDD"); + if (ret=p_open(&pcb,"MUS:",-1)) + panic(2,ret); + p_puts("Musical notes tester - ? for help"); + FOREVER + { + p_print("Next>"); + p_gets(p=(&bb[0])); + p=p_skipwh(p); + if (!*p) + continue; + switch (p_toupper(*p++)) + { + case '?': + p_puts("Q - Quit"); + p_puts("V - Volume 0-3"); + p_puts("L - Length 0-100"); + p_puts("P - Play scale"); + break; + case 'Q': /* Quit */ + p_close(pcb); + if (ret=p_devdel("MUS",E_LDD)) + panic(7,ret); + return(0); + case 'V': /* Volume */ + if (p_stoi(&p,&volume)<0) + volume=0; + if (volume<0 || volume>3) + volume=0; + break; + case 'L': /* Length */ + if (p_stoi(&p,&length)<0) + length=10; + if (length<0 || length>100) + length=10; + break; + case 'P': /* play that lot */ + for (i=0;i + +/* all are 1 sec duration by default */ +LOCAL_D UBYTE notes[] = { +/* Basic note numbers */ + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, + 0x38, + 0x39, + 0x3a, + 0x29, + 0x3b, + 0x3c, + 0x3d, + 0x0e, + 0x3e, + 0x2c, + 0x3f, + 0x04, + 0x05, + 0x25, + 0x2f, + 0x06, + 0x07 + }; + +LOCAL_D WORD volume=0; /* volume to use */ +LOCAL_D WORD length=100; /* length of notes */ + +LOCAL_C VOID panic( + INT num, + INT errno) + { + TEXT b[100]; + + p_errs(&b[p_atob(&b[0],"panic num %d - ",&num)],errno); + t_panic(&b[0]); + } + +GLDEF_C main(VOID) + { + INT ret,i; + VOID *pcb; + UBYTE bb[100],*p; + + p_loadldd("SNDFRC.LDD"); + if (ret=p_open(&pcb,"MUS:",-1)) + panic(2,ret); + p_puts("Musical notes tester - ? for help"); + FOREVER + { + p_print("Next>"); + p_gets(p=(&bb[0])); + p=p_skipwh(p); + if (!*p) + continue; + switch (p_toupper(*p++)) + { + case '?': + p_puts("Q - Quit"); + p_puts("V - Volume 0-3"); + p_puts("L - Length 0-256"); + p_puts("P - Play scale"); + break; + case 'Q': /* Quit */ + p_close(pcb); + if (ret=p_devdel("MUS",E_LDD)) + panic(7,ret); + return(0); + case 'V': /* Volume */ + if (p_stoi(&p,&volume)<0) + volume=0; + if (volume<0 || volume>3) + volume=0; + break; + case 'L': /* Length */ + if (p_stoi(&p,&length)<0) + length=100; + if (length<0 || length>256) + length=100; + break; + case 'P': /* play that lot */ + for (i=0;i +#include +#include +#include +#include +#include "nolayout.h" +#include "notes.def" + +GLREF_D PR_HWIMMAN *w_am; +GLREF_D PR_WSERV *w_ws; +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D PR_VAFLAT *DatApp1; +GLREF_D PR_NOCOMMAN *DatApp2; +GLREF_D PR_EDWIN *DatApp3; +GLREF_D NOTE *DatApp4; + +GLDEF_D LAYOUT_DATA ld; + +LOCAL_C VOID RotateStatusWindow(VOID) + { + P_EXTENT ext; + + if (ld.Version4) + { + if (!ld.StatusWindow--) + ld.StatusWindow=W_STATUS_WINDOW_BIG; + wStatusWindow(ld.StatusWindow); + wInquireStatusWindow(-1,&ext); + ld.StatusWindowWidth=ext.width; + } + else + { + if (ld.StatusWindow^=TRUE) + { + wsEnable(); + ld.StatusWindowWidth=WS_WIDTH; + } + else + { + wsDisable(); + ld.StatusWindowWidth=0; + } + } + } + +LOCAL_C VOID InitStatusWindow(VOID) + { + if (ld.Version4) + wsSetList(W_STATUS_WINDOW_ICON,NULL,0); + RotateStatusWindow(); + } + +LOCAL_C VOID GetFontHeightData(VOID) + { + G_FONT_INFO font; + + gFontInfo(WS_FONT_SYSTEM,0,&font); + ld.FontHeight=font.height; + ld.FontAscent=font.ascent; + } + +LOCAL_C VOID CreateTextWindows(PR_NOCOMMAN *self) + { + self->nocomman.tagwin=f_new(CAT_NOTES_NOTES,C_NOTAGWIN); + self->nocomman.cntwin=f_new(CAT_NOTES_NOTES,C_NOCNTWIN); + } + +LOCAL_C VOID InitTextWindow(VOID *win,INT x,INT y,INT width) + { + W_WINDATA wd; + + wd.background=W_WIN_BACK_NONE; + wd.extent.tl.x=x; + wd.extent.tl.y=y+EDGE_TLY; + wd.extent.width=width; + wd.extent.height=ld.FontHeight+2; + p_send5(win,O_WN_CONNECT,NULL,W_WIN_BACKGROUND|W_WIN_EXTENT,&wd); + hInitVis(win); + } + +LOCAL_C VOID MoveWindowLeft(INT wid,INT change) + { + W_WINDATA wd; + + wInquireWindow(wid,&wd); + wd.extent.tl.x+=change; + wSetWindow(wid,W_WIN_EXTENT,&wd); + } + +LOCAL_C UINT CalculateYValues(UWORD *py1,UWORD *py2) + { + UWORD NumLines; + UWORD LineHeight; + UWORD spare; + + LineHeight=ld.FontHeight+2; + NumLines=(ld.ScreenHeight-REQD_EDGE_PIXELS)/LineHeight; + spare=ld.ScreenHeight-REQD_EDGE_PIXELS-LineHeight*NumLines; + spare>>=1; /* excess goes to second "spare" region */ + *py1=EDGE_HEIGHT+LineHeight+BASIC_GAP_BETWEEN_WINDOWS+spare; + *py2=ld.ScreenHeight-(EDGE_HEIGHT+LineHeight); + return(NumLines-2); + } + +LOCAL_C VOID SetupInEdwin(IN_EDWIN *pInit,INT delx,INT flags,INT maxlen) + { + pInit->vulen=ld.ScreenWidth-ld.StatusWindowWidth-delx; + pInit->flags=flags; + pInit->maxlen=maxlen; + pInit->contents[0]=0; + } + +LOCAL_C PR_NOWIN *CreateNowin(INT class,IN_EDWIN *pIned,IN_EDWIN_X *pIX) + { + PR_NOWIN *nowin; + + nowin=f_newsend(CAT_NOTES_NOTES,class,O_WN_INIT,pIned,pIX); + hInitVis(nowin); + return(nowin); + } + +#define EDWIN_FLGS (IN_EDWIN_VULEN_PIXELS|IN_EDWIN_POSITION_SUPPLIED) + +LOCAL_C VOID InitialiseWindows(PR_NOCOMMAN *self) + { + UWORD x1,x2; + UWORD y1,y2; + UWORD NumNotesLines; + IN_EDWIN ined; + IN_EDWIN_X inedx; + + CreateTextWindows(self); + x1=p_send2(self->nocomman.tagwin,O_WN_SENSE); + x2=p_send2(self->nocomman.cntwin,O_WN_SENSE); + NumNotesLines=CalculateYValues(&y1,&y2); + SetupInEdwin(&ined,x1,EDWIN_FLGS|IN_EDWIN_FONT_SUPPLIED,40); + inedx.pos.x=x1; + inedx.pos.y=0; + if (ld.Version4) + { + inedx.font=WS_FONT_SYSTEM; + inedx.style=G_STY_BOLD; + } + else + { + inedx.font=WS_FONT_BASE+1; + inedx.style=G_STY_NORMAL; + } + self->nocomman.edit[0]=CreateNowin(C_NOTITWIN,&ined,&inedx); + SetupInEdwin(&ined,0,EDWIN_FLGS|IN_EDWIN_VISLINES_SUPPLIED| + IN_EDWIN_LEFT_CURSOR|IN_EDWIN_CLIPBOARD,512); + inedx.pos.x=0; + inedx.pos.y=y1; + inedx.vislines=NumNotesLines; + inedx.clip=NULL; + self->nocomman.edit[1]=CreateNowin(C_NOWIN,&ined,&inedx); + SetupInEdwin(&ined,x2,EDWIN_FLGS,20); + inedx.pos.x=0; + inedx.pos.y=y2; + self->nocomman.edit[2]=CreateNowin(C_NOFNDWIN,&ined,&inedx); + InitTextWindow(self->nocomman.tagwin,0,0,x1); + InitTextWindow(self->nocomman.cntwin, + ld.ScreenWidth-ld.StatusWindowWidth-x2,y2,x2); + } + +LOCAL_C VOID InitialiseLayout(PR_NOCOMMAN *self) + { + ld.Version4= + ((wserv_channel->conn.info.version_id&WS_VERSION_MASK) >= WS_VERSION_4); + InitStatusWindow(); + ld.ScreenWidth=wserv_channel->conn.info.pixels.x; + ld.ScreenHeight=wserv_channel->conn.info.pixels.y; + GetFontHeightData(); + InitialiseWindows(self); + DatApp3=self->nocomman.edit[NOTES_WINDOW]->nowin.edwin; + } + +LOCAL_C VOID FocusTo(PR_NOCOMMAN *self,INT which) + { + if (w_ws->wserv.cli) + p_send3(w_ws->wserv.cli,O_WN_EMPHASISE,FALSE); + self->nocomman.which=which; + w_ws->wserv.cli=(PR_WIN *)self->nocomman.edit[which]; + p_send3(w_ws->wserv.cli,O_WN_EMPHASISE,TRUE); + } + +LOCAL_C VOID FocusToWithCheck(PR_NOCOMMAN *self,INT which) + { + if (which==self->nocomman.which) + return; + FocusTo(self,which); + } + +LOCAL_C VOID RecordChange(PR_NOWIN *win,LENBUF *lb) + { + PR_EDWIN *edwin; + SE_EDWIN sense; + + edwin=win->nowin.edwin; + if (!(edwin->edwin.change)) + return; + p_send3(edwin,O_WN_SENSE,&sense); + lb->buf=f_realloc(lb->buf,sense.len); + lb->len=sense.len; + p_bcpy(lb->buf,sense.buf,sense.len); + edwin->edwin.change=FALSE; + } + +LOCAL_C VOID RecordAnyChanges(PR_NOCOMMAN *self) + { + RecordChange(self->nocomman.edit[TITLE_WINDOW],&DatApp4->title); + RecordChange(self->nocomman.edit[NOTES_WINDOW],&DatApp4->note); + } + +LOCAL_C VOID SetCurrentNote(PR_NOCOMMAN *self) + { + DatApp4=ePointToNote(self->nocomman.where); + } + +LOCAL_C VOID LoadEditor(PR_NOWIN *win,LENBUF *lb) + { + PR_EDWIN *edwin; + SE_EDWIN set; + + edwin=win->nowin.edwin; + set.buf=lb->buf; + set.len=lb->len; + p_send3(edwin,O_WN_SET,&set); + edwin->edwin.change=FALSE; + } + +LOCAL_C VOID LoadTagStatus(PR_NOCOMMAN *self) + { + p_send3(self->nocomman.tagwin,O_WN_SET,DatApp4->tagged); + } + +LOCAL_C VOID LoadWhereAndCount(PR_NOCOMMAN *self) + { + p_send4(self->nocomman.cntwin, + O_WN_SET,self->nocomman.where+1,DatApp1->varoot.nrec); + } + +LOCAL_C VOID LoadWindows(PR_NOCOMMAN *self) + { + LoadEditor(self->nocomman.edit[TITLE_WINDOW],&DatApp4->title); + LoadEditor(self->nocomman.edit[NOTES_WINDOW],&DatApp4->note); + LoadWhereAndCount(self); + LoadTagStatus(self); + } + +LOCAL_C VOID CheckEditing(PR_NOCOMMAN *self) + { + if (self->nocomman.which==NOTES_WINDOW) + return; + hInfoPrint(NOSTR_ONLY_IN_NOTES); + p_leave(RUN_ACTIVE_USED); + } + +LOCAL_C VOID GiveTagCount(VOID) + { + hInfoPrint(NOSTR_TAG_COUNT,eCountTaggedNotes()); + } + +LOCAL_C INT RunDialog(INT class,INT resid,VOID *rbuf) + { + DL_DATA dd; + + dd.id=resid; + dd.rbuf=rbuf; + dd.pdlg=NULL; + return(hLaunchDial(CAT_NOTES_NOTES,class,&dd)); + } + +LOCAL_C VOID TagCurrentNote(INT clear) + { + DatApp4->tagged=(!clear); + } + +LOCAL_C VOID SetTo(PR_NOCOMMAN *self,INT where) + { + self->nocomman.where=where; + SetCurrentNote(self); + LoadWindows(self); + } + +LOCAL_C VOID WinEmphasise(PR_NOCOMMAN *self,INT which,INT state) + { + p_send3(self->nocomman.edit[which]->nowin.edwin,O_WN_EMPHASISE,state); + } + +LOCAL_C VOID SetCursorWidth(PR_NOCOMMAN *self,INT which,INT width) + { + PR_EDWIN *edwin; + SCRIMG_WIN win; + + edwin=self->nocomman.edit[which]->nowin.edwin; + p_send3(edwin->edwin.scrimg,O_SI_SENSE,&win); + win.cwidth=width; + p_send4(edwin->edwin.scrimg,O_SI_SET,&win,NULL); + } + +LOCAL_C VOID SetEdwinSelect(PR_NOCOMMAN *self,INT which,INT aoff,INT coff) + { + SET_EDWIN set; + + set.flags=SET_EDWIN_CURSOR|SET_EDWIN_ANCHOR; + set.anchor=aoff; + set.cursor=coff; + p_send3(self->nocomman.edit[which]->nowin.edwin,O_EW_SET,&set); + } + +LOCAL_C VOID DrawImmediately(PR_WIN *win) + { + p_send2(win,O_WN_DODRAW); + } + +LOCAL_C VOID Search(PR_NOCOMMAN *self,LENBUF *lb,INT here,INT which) + { + INT ind; + + if (self->nocomman.casesens) + ind=p_bsub(lb->buf,lb->len, + self->nocomman.pattern.buf,self->nocomman.pattern.len); + else + ind=p_bsubi(lb->buf,lb->len, + self->nocomman.pattern.buf,self->nocomman.pattern.len); + if (ind<0) + return; + if (here!=self->nocomman.where) + SetTo(self,here); + if (self->nocomman.pattern.len) + { + if (which!=self->nocomman.which) + { + WinEmphasise(self,self->nocomman.which,FALSE); + SetCursorWidth(self,which,0); + WinEmphasise(self,which,TRUE); + } + SetEdwinSelect(self,which,ind,ind+self->nocomman.pattern.len); + if (which!=self->nocomman.which) + { + DrawImmediately((PR_WIN *)self->nocomman.cntwin); + DrawImmediately((PR_WIN *)self->nocomman.tagwin); + wFlush(); + p_sleep(5L); + WinEmphasise(self,which,FALSE); + SetCursorWidth(self,which,2); + WinEmphasise(self,self->nocomman.which,TRUE); + } + } + p_leave(RUN_ACTIVE_USED); + } + +LOCAL_C VOID DoSearch(PR_NOCOMMAN *self,INT here,INT direction) + { + PR_EDWIN *edwin; + INT k; + INT count; + NOTE *pn; + + RecordAnyChanges(self); + edwin=self->nocomman.edit[FIND_WINDOW]->nowin.edwin; + p_send3(edwin,O_WN_SENSE,&self->nocomman.pattern); + edwin->edwin.change=FALSE; + k=DatApp1->varoot.nrec; + count=k-1; + while (k--) + { + here+=direction; + if (here<0) + here=count; + else if (here>count) + here=0; + pn=ePointToNote(here); + if (self->nocomman.findtype!=FIND_NOTES_ONLY) + Search(self,&pn->title,here,TITLE_WINDOW); + if (self->nocomman.findtype!=FIND_TITLE_ONLY) + Search(self,&pn->note,here,NOTES_WINDOW); + } + hInfoPrint(NOSTR_NOT_FOUND); + } + +LOCAL_C INT EdwinChanged(PR_NOCOMMAN *self,INT which) + { + return(self->nocomman.edit[which]->nowin.edwin->edwin.change); + } + +LOCAL_C VOID CheckIfChanged(PR_NOCOMMAN *self) + { + if (EdwinChanged(self,TITLE_WINDOW)) + return; + if (EdwinChanged(self,NOTES_WINDOW)) + return; + hInfoPrint(NOSTR_NOT_CHANGED); + p_leave(RUN_ACTIVE_USED); + } + +LOCAL_C WORD GetLinkableData(ULONG *pFmt) + { + return(p_send3(w_am->appman.system,O_SY_LINK_PASTE,pFmt)); + } + +#pragma METHOD_CALL + +METHOD VOID nocomman_com_init(PR_NOCOMMAN *self) + { + DatApp2=self; + eInitialiseEngine(); + SetCurrentNote(self); + InitialiseLayout(self); + LoadWhereAndCount(self); + FocusTo(self,TITLE_WINDOW); + InitLinkServer(); + } + +METHOD VOID nocomman_com_statwin(PR_NOCOMMAN *self) + { + INT change; + INT i; + + change=ld.StatusWindowWidth; + RotateStatusWindow(); + change-=ld.StatusWindowWidth; + for (i=0; i<3; i++) + p_send3(self->nocomman.edit[i],O_NW_INCREASE_WIDTH,change); + MoveWindowLeft(self->nocomman.cntwin->win.id,change); + } + +METHOD VOID nocomman_com_exit(VOID) + { + p_exit(0); + } + +METHOD VOID nocomman_ncon_new(PR_NOCOMMAN *self) + { + RecordAnyChanges(self); + self->nocomman.where=eAppendNullEntry(); + SetCurrentNote(self); + LoadWindows(self); + FocusToWithCheck(self,TITLE_WINDOW); + } + +METHOD VOID nocomman_ncon_insert(PR_NOCOMMAN *self) + { + RecordAnyChanges(self); + if (!self->nocomman.clip.title.len && !self->nocomman.clip.note.len) + { + hInfoPrint(NOSTR_NO_NOTE_INSERTED); + return; + } + self->nocomman.where=eAppendNullEntry(); + SetCurrentNote(self); + eTakeCopy(DatApp4,&self->nocomman.clip); + LoadWindows(self); + } + +METHOD VOID nocomman_ncon_copy(PR_NOCOMMAN *self) + { + NOTE new; + + RecordAnyChanges(self); + if (!DatApp4->title.len && !DatApp4->note.len) + { + hInfoPrint(NOSTR_NO_NOTE_COPIED); + return; + } + eTakeCopy(&new,DatApp4); + eZeroNote(&self->nocomman.clip); + self->nocomman.clip=new; + hInfoPrint(NOSTR_NOTE_COPIED); + } + +METHOD VOID nocomman_ncon_delete(PR_NOCOMMAN *self) + { + if (!hConfirm(NOSTR_DELETE_NOTE)) + return; + self->nocomman.where=eDeleteNote(self->nocomman.where); + SetCurrentNote(self); + LoadWindows(self); + } + +METHOD VOID nocomman_ncon_record(PR_NOCOMMAN *self) + { + CheckIfChanged(self); + RecordAnyChanges(self); + hInfoPrint(NOSTR_NOTE_RECORDED); + } + +METHOD VOID nocomman_ncon_undo(PR_NOCOMMAN *self) + { + CheckIfChanged(self); + if (hConfirm(NOSTR_UNDO_EDITING)) + LoadWindows(self); + } + +METHOD VOID nocomman_ncoe_insert(PR_NOCOMMAN *self) + { + CheckEditing(self); + if (!(p_send2(DatApp3,O_EW_PASTE_CLIP))) + hInfoPrint(NOSTR_NO_TEXT_INSERTED); + } + +METHOD VOID nocomman_ncoe_copy(PR_NOCOMMAN *self) + { + CheckEditing(self); + if (!(p_send2(DatApp3,O_EW_REPLACE_CLIP))) + hInfoPrint(NOSTR_NO_TEXT_COPIED); + else + hInfoPrint(NOSTR_TEXT_COPIED); + } + +METHOD VOID nocomman_ncoe_bring(PR_NOCOMMAN *self) + { + INT lkpid; + ULONG lkfmt; + + CheckEditing(self); + lkpid=p_send3(w_am->appman.system,O_SY_LINK_PASTE,&lkfmt); + if (!lkpid || !(lkfmt & (1<nocomman.which; + if (mods&W_SHIFT_MODIFIER) + { + if (!which--) + which=FIND_WINDOW; + } + else if (which++==FIND_WINDOW) + which=TITLE_WINDOW; + FocusTo(self,which); + } + +METHOD VOID nocomman_ncot_set(PR_NOCOMMAN *self,INT commid) + { + if (commid>=O_NCOT_SET_ALL) + eTagAllNotes(commid-O_NCOT_SET_ALL); + else + TagCurrentNote(commid-O_NCOT_SET); + LoadTagStatus(self); + GiveTagCount(); + } + +METHOD VOID nocomman_ncox_goto(PR_NOCOMMAN *self) + { + UWORD where; + + where=self->nocomman.where; + if (!RunDialog(C_NODL_GOTO,NODL_GOTO,&where)) + return; + if (where==self->nocomman.where) + return; + RecordAnyChanges(self); + SetTo(self,where); + } + +METHOD VOID nocomman_ncox_moveto(PR_NOCOMMAN *self) + { + UWORD where; + + where=0; + if (!RunDialog(C_NODL_GOTO,NODL_MOVETO,&where)) + return; + if (where==self->nocomman.where) + return; + RecordAnyChanges(self); + eMoveNoteTo(where,self->nocomman.where); + SetTo(self,where); + } + +METHOD VOID nocomman_ncos_options(PR_NOCOMMAN *self) + { + RunDialog(C_NODL_OPTIONS,NODL_OPTIONS,NULL); + } + +METHOD VOID nocomman_nco_quick_find(PR_NOCOMMAN *self,INT dir) + { + INT here; + + here=EdwinChanged(self,FIND_WINDOW)? + DatApp1->varoot.nrec: self->nocomman.where; + DoSearch(self,here,dir); + } + +METHOD VOID nocomman_ncos_forwards(PR_NOCOMMAN *self) + { + DoSearch(self,self->nocomman.where,+1); + } + +METHOD VOID nocomman_ncos_backwards(PR_NOCOMMAN *self) + { + DoSearch(self,self->nocomman.where,-1); + } + +METHOD VOID nocomman_ncos_first(PR_NOCOMMAN *self) + { + DoSearch(self,DatApp1->varoot.nrec,+1); + } + +METHOD VOID nocomman_ncos_last(PR_NOCOMMAN *self) + { + DoSearch(self,DatApp1->varoot.nrec,-1); + } + diff --git a/code/SIBOSDK/notes/nodlgs.c b/code/SIBOSDK/notes/nodlgs.c new file mode 100644 index 0000000..2238d3c --- /dev/null +++ b/code/SIBOSDK/notes/nodlgs.c @@ -0,0 +1,42 @@ +/* NODLGS.C */ + +#include +#include +#include + +GLREF_D PR_VAFLAT *DatApp1; +GLREF_D PR_NOCOMMAN *DatApp2; + +#pragma METHOD_CALL + +METHOD VOID nodl_goto_dl_dyn_init(PR_DLGBOX *self) + { + SE_NCEDIT set; + + set.high=DatApp1->varoot.nrec; + set.value=(*(UWORD *)self->dlgbox.rbuf)+1; + set.flags=SE_NCEDIT_VALUE|SE_NCEDIT_HIGH; + hDlgSet(1,&set); + } + +METHOD INT nodl_goto_dl_key(PR_DLGBOX *self) + { + *(UWORD *)self->dlgbox.rbuf=hDlgSenseNcedit(1)-1; + return(WN_KEY_CHANGED); + } + +#define NODL_OPTIONS_CASESENS 1 +#define NODL_OPTIONS_FINDTYPE 2 + +METHOD VOID nodl_options_dl_dyn_init(PR_DLGBOX *self) + { + hDlgSetChlist(NODL_OPTIONS_CASESENS,DatApp2->nocomman.casesens); + hDlgSetChlist(NODL_OPTIONS_FINDTYPE,DatApp2->nocomman.findtype); + } + +METHOD INT nodl_options_dl_key(PR_DLGBOX *self) + { + DatApp2->nocomman.casesens=hDlgSenseChlist(NODL_OPTIONS_CASESENS); + DatApp2->nocomman.findtype=hDlgSenseChlist(NODL_OPTIONS_FINDTYPE); + return(WN_KEY_CHANGED); + } diff --git a/code/SIBOSDK/notes/noengine.c b/code/SIBOSDK/notes/noengine.c new file mode 100644 index 0000000..9100379 --- /dev/null +++ b/code/SIBOSDK/notes/noengine.c @@ -0,0 +1,130 @@ +/* NOENGINE.C */ + +#include +#include +#include + +GLREF_D PR_VAFLAT *DatApp1; + +GLDEF_C NOTE *ePointToNote(INT pos) + { + return((NOTE *)p_send3(DatApp1,O_VA_PREC,pos)); + } + +GLDEF_C INT eAppendNullEntry(VOID) + { + NOTE note; + + if (DatApp1->varoot.nrec==MAX_NUMBER_NOTES) + { + hInfoPrint(NOSTR_MAX_NUMBER_NOTES); + p_leave(RUN_ACTIVE_CLEANUP_NONOTIFY); + } + p_bfil(¬e,sizeof(NOTE),0); + p_send3(DatApp1,O_VA_APPEND,¬e); + return(DatApp1->varoot.nrec-1); + } + +LOCAL_C VOID ZeroLenBuf(LENBUF *lb) + { + p_free(lb->buf); + lb->buf=NULL; + lb->len=0; + } + +GLDEF_C VOID eZeroNote(NOTE *pn) + { + ZeroLenBuf(&pn->title); + ZeroLenBuf(&pn->note); + pn->tagged=FALSE; + } + +GLDEF_C INT eDeleteNote(INT pos) + { + if (DatApp1->varoot.nrec==1) + { + eZeroNote(ePointToNote(0)); + return(0); + } + p_send3(DatApp1,O_VA_DELETE,pos); + p_send(DatApp1,O_VA_COMPRESS); + if (pos==DatApp1->varoot.nrec) + pos--; + return(pos); + } + +GLDEF_C VOID eInitialiseEngine(VOID) + { + DatApp1=f_newsend(CAT_NOTES_OLIB,C_VAFLAT,O_VA_INIT,sizeof(NOTE),4); + eAppendNullEntry(); + } + +GLDEF_C INT eCountTaggedNotes(VOID) + { + INT ret; + INT i; + NOTE *pn; + + ret=0; + pn=ePointToNote(0); + i=DatApp1->varoot.nrec; + while (i--) + { + if (pn->tagged) + ret++; + pn++; + } + return(ret); + } + +GLDEF_C VOID eTagAllNotes(INT clear) + { + INT set; + INT i; + NOTE *pn; + + set=(!clear); + pn=ePointToNote(0); + i=DatApp1->varoot.nrec; + while (i--) + { + pn->tagged=set; + pn++; + } + } + +#pragma save,ENTER_CALL + +LOCAL_C INT TakeCopyLenBuf(LENBUF *targ,LENBUF *src) + { + targ->buf=f_alloc(src->len); + p_bcpy(targ->buf,src->buf,src->len); + targ->len=src->len; + return(0); + } + +#pragma restore + +GLDEF_C VOID eTakeCopy(NOTE *targ,NOTE *src) + { + INT ret; + + TakeCopyLenBuf(&targ->title,&src->title); + ret=p_enter3(TakeCopyLenBuf,&targ->note,&src->note); + if (ret) + { + p_free(targ->title.buf); + targ->title.buf=0; + p_leave(ret); + } + targ->tagged=src->tagged; + } + +GLDEF_C VOID eMoveNoteTo(INT newpos,INT pos) + { + NOTE moving; + + moving=*ePointToNote(pos); + p_send3(DatApp1,O_VA_DELETE,pos); + p_send4(DatApp1,O_VA_INSERT,newpos,&moving); + } diff --git a/code/SIBOSDK/notes/nolayout.h b/code/SIBOSDK/notes/nolayout.h new file mode 100644 index 0000000..2001291 --- /dev/null +++ b/code/SIBOSDK/notes/nolayout.h @@ -0,0 +1,26 @@ +/* NOLAYOUT.H */ + +typedef struct + { + UBYTE Version4; + UBYTE StatusWindow; + UWORD StatusWindowWidth; + UWORD ScreenWidth; + UWORD ScreenHeight; + UWORD FontHeight; + UWORD FontAscent; + } LAYOUT_DATA; + +#define DOUBLE_SHADOW_WIDTH 2 + +#define EDGE_TLX 5 +#define EDGE_TLY 2 +#define EDGE_BRX (EDGE_TLX+DOUBLE_SHADOW_WIDTH) +#define EDGE_BRY (EDGE_TLY+DOUBLE_SHADOW_WIDTH) +#define EDGE_WIDTH (EDGE_TLX+EDGE_BRX) +#define EDGE_HEIGHT (EDGE_TLY+EDGE_BRY) + +#define BASIC_GAP_BETWEEN_WINDOWS 1 +#define REQD_EDGE_PIXELS (3*EDGE_HEIGHT+2*BASIC_GAP_BETWEEN_WINDOWS) + +#define TEXT_WINDOW_EDGE_WIDTH 3 diff --git a/code/SIBOSDK/notes/nolinksv.c b/code/SIBOSDK/notes/nolinksv.c new file mode 100644 index 0000000..a722ce0 --- /dev/null +++ b/code/SIBOSDK/notes/nolinksv.c @@ -0,0 +1,38 @@ +/* NOLINKSV.C */ + +#include +#include + +GLREF_D PR_EDWIN *DatApp3; + +GLDEF_C VOID InitLinkServer(VOID) + { + f_newsend(CAT_NOTES_NOTES,C_NOLINKSV,O_SV_INIT); + } + +LOCAL_C VOID DestroyLinker(PR_NOLINKSV *self) + { + hDestroy(self->nolinksv.ewls); + self->nolinksv.ewls=NULL; + } + +#pragma METHOD_CALL + +METHOD VOID nolinksv_ls_set_format(PR_NOLINKSV *self,INT type) + { + DestroyLinker(self); + self->nolinksv.ewls=f_newsend(CAT_NOTES_HWIM,C_EWLINKSV, + O_EWLS_INIT,DatApp3,type); + } + +METHOD INT nolinksv_ls_get_data(PR_NOLINKSV *self,INT len) + { + if (len>0) + { + if (((INT)(self->linksv.len=p_send4(self->nolinksv.ewls, + O_EWLS_EXTRACT,&self->linksv.buf,len)))>=0) + return(TRUE); + } + DestroyLinker(self); + return(FALSE); + } diff --git a/code/SIBOSDK/notes/nomain.c b/code/SIBOSDK/notes/nomain.c new file mode 100644 index 0000000..61b8812 --- /dev/null +++ b/code/SIBOSDK/notes/nomain.c @@ -0,0 +1,20 @@ +/* NOMAIN.C */ + +#include + +#define APPMAN_FLGS (FLG_APPMAN_RSCFILE|FLG_APPMAN_SRSCFILE|FLG_APPMAN_CLEAN) + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV wserv; + + p_linklib(0); + app.flags=APPMAN_FLGS|FLG_APPMAN_LINKING|FLG_APPMAN_IPCS| + FLG_APPMAN_FULLSCREEN; + wserv.com_cat=app.wserv_cat=p_getlibh(CAT_NOTES_NOTES); + app.wserv_class=C_NOWSERV; + wserv.com_class=C_NOCOMMAN; + p_send4(p_new(CAT_NOTES_HWIM,C_HWIMMAN),O_AM_INIT,&app,&wserv); + } + diff --git a/code/SIBOSDK/notes/notes.afl b/code/SIBOSDK/notes/notes.afl new file mode 100644 index 0000000..7578d91 --- /dev/null +++ b/code/SIBOSDK/notes/notes.afl @@ -0,0 +1,3 @@ +notes.pic +notes.rsc +notes.shd diff --git a/code/SIBOSDK/notes/notes.cat b/code/SIBOSDK/notes/notes.cat new file mode 100644 index 0000000..3d1e018 --- /dev/null +++ b/code/SIBOSDK/notes/notes.cat @@ -0,0 +1,165 @@ +IMAGE notes + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE hwimman.g +INCLUDE edwin.g +INCLUDE ipc.g + +CLASS nowin bwin + { + REPLACE wn_key + REPLACE wn_emphasise + REPLACE wn_draw + REPLACE wn_init + ADD nw_increase_width + ADD nw_init=p_dummy + PROPERTY 1 + { + PR_EDWIN *edwin; + } + } + +CLASS notitwin nowin + { + REPLACE wn_key + } + +CLASS nofndwin nowin + { + REPLACE destroy + REPLACE wn_draw + REPLACE wn_key + REPLACE nw_init + PROPERTY + { + TEXT *prompt; + UWORD len; + UWORD x; + UWORD y; + } + } + +CLASS notagwin win + { + REPLACE wn_set + REPLACE wn_sense + REPLACE wn_draw + PROPERTY + { + UWORD on; + } + } + +CLASS nocntwin win + { + REPLACE wn_set + REPLACE wn_sense + REPLACE wn_draw + PROPERTY + { + UWORD val; + UWORD max; + } + } + +CLASS nocomman comman + { + REPLACE com_init + REPLACE com_statwin + REPLACE com_exit + ADD ncon_new + ADD ncon_insert + ADD ncon_copy + ADD ncon_delete + ADD ncon_record + ADD ncon_undo + ADD ncoe_insert + ADD ncoe_copy + ADD ncoe_bring + ADD ncoe_evaluate + ADD ncoe_sum=p_dummy + ADD ncow_title + ADD ncow_notes=nocomman_ncow_title + ADD ncow_find=nocomman_ncow_title + ADD ncos_options + ADD ncos_forwards + ADD ncos_backwards + ADD ncos_first + ADD ncos_last + ADD ncot_set + ADD ncot_clear=nocomman_ncot_set + ADD ncot_set_all=nocomman_ncot_set + ADD ncot_clear_all=nocomman_ncot_set + ADD ncox_goto + ADD ncox_moveto + ADD ncox_symbols=p_dummy + ADD ncox_psetup + ADD ncox_print=p_dummy + ADD nco_switch_focus + ADD nco_quick_find + TYPES + { + typedef struct + { + UBYTE len; + TEXT *buf; + } LENBUF; + typedef struct + { + LENBUF title; + LENBUF note; + UWORD tagged; + } NOTE; + } + CONSTANTS + { + TITLE_WINDOW 0 + NOTES_WINDOW 1 + FIND_WINDOW 2 + MAX_NUMBER_NOTES 99 + FIND_NOTES_ONLY 0 + FIND_TITLE_ONLY 1 + FIND_EITHER_WIN 2 + } + PROPERTY + { + PR_NOWIN *edit[3]; + UWORD which; + PR_NOTAGWIN *tagwin; + PR_NOCNTWIN *cntwin; + WORD where; + UBYTE casesens; + UBYTE findtype; + NOTE clip; + SE_EDWIN pattern; + } + } + +CLASS nowserv wserv + { + REPLACE ws_background + } + +CLASS nolinksv linksv + { + REPLACE ls_set_format + REPLACE ls_get_data + PROPERTY + { + PR_EWLINKSV *ewls; + } + } + +CLASS nodl_goto dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } + +CLASS nodl_options dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } diff --git a/code/SIBOSDK/notes/notes.def b/code/SIBOSDK/notes/notes.def new file mode 100644 index 0000000..430ed50 --- /dev/null +++ b/code/SIBOSDK/notes/notes.def @@ -0,0 +1,12 @@ +GLREF_C NOTE *ePointToNote(INT pos); +GLREF_C INT eAppendNullEntry(VOID); +GLREF_C VOID eZeroNote(NOTE *pn); +GLREF_C INT eDeleteNote(INT pos); +GLREF_C VOID eInitialiseEngine(VOID); +GLREF_C INT eCountTaggedNotes(VOID); +GLREF_C VOID eTagAllNotes(INT clear); +GLREF_C VOID eTagCurrentNote(INT clear); +GLREF_C VOID eTakeCopy(NOTE *targ,NOTE *src); +GLREF_C VOID eMoveNoteTo(INT newpos,INT pos); + +GLREF_C VOID InitLinkServer(VOID); diff --git a/code/SIBOSDK/notes/notes.ms b/code/SIBOSDK/notes/notes.ms new file mode 100644 index 0000000..a5bd624 --- /dev/null +++ b/code/SIBOSDK/notes/notes.ms @@ -0,0 +1,3 @@ +Notes + +5000 diff --git a/code/SIBOSDK/notes/notes.plk b/code/SIBOSDK/notes/notes.plk new file mode 100644 index 0000000..62740c6 --- /dev/null +++ b/code/SIBOSDK/notes/notes.plk @@ -0,0 +1,2 @@ +notes1.pic +notes2.pic diff --git a/code/SIBOSDK/notes/notes.pr b/code/SIBOSDK/notes/notes.pr new file mode 100644 index 0000000..00b33cb --- /dev/null +++ b/code/SIBOSDK/notes/notes.pr @@ -0,0 +1,45 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile notes.cat + +#if %remake #or (notes.rg #older notes.re) #or (notes.rg #older notes.g) #then + #run "re notes" no_window no_abort +#endif + +#if (notes.rsg #older notes.rss) #or (notes.rsg #older notes.rg) #then + #file delete notes.rsg + #run "rs notes" no_window no_abort +#endif + +#if notes.rzc #older notes.rsg #then + #run "rch notes" no_window no_abort + #file delete notes.img +#endif + +#compile nocomman.c +#compile nodlgs.c +#compile noengine.c +#compile nolinksv.c +#compile nomain.c +#compile nowin.c +#compile nowserv.c + +#if (notes.pic #older notes1.pic) #or (notes.pic #older notes2.pic) #then + #run "wspcx -l notes" no_window no_abort + #file delete notes.img +#endif + +#if notes.shd #older notes.ms #then + #run "makeshd notes" no_window no_abort + #file delete notes.img +#endif + +#if (notes.img #older notes.afl) #or (notes.img #older notes.pic) #then + #file delete notes.img +#endif + +#pragma link(hwim.lib) + +#link notes.img diff --git a/code/SIBOSDK/notes/notes.re b/code/SIBOSDK/notes/notes.re new file mode 100644 index 0000000..28e34e5 --- /dev/null +++ b/code/SIBOSDK/notes/notes.re @@ -0,0 +1,31 @@ +#include + +_O_COM_EXIT +_O_NCON_NEW +_O_NCON_INSERT +_O_NCON_COPY +_O_NCON_DELETE +_O_NCON_RECORD +_O_NCON_UNDO +_O_NCOE_INSERT +_O_NCOE_COPY +_O_NCOE_BRING +_O_NCOE_EVALUATE +_O_NCOE_SUM +_O_NCOW_TITLE +_O_NCOW_NOTES +_O_NCOW_FIND +_O_NCOS_OPTIONS +_O_NCOS_FORWARDS +_O_NCOS_BACKWARDS +_O_NCOS_FIRST +_O_NCOS_LAST +_O_NCOT_SET +_O_NCOT_CLEAR +_O_NCOT_SET_ALL +_O_NCOT_CLEAR_ALL +_O_NCOX_GOTO +_O_NCOX_MOVETO +_O_NCOX_SYMBOLS +_O_NCOX_PSETUP +_O_NCOX_PRINT diff --git a/code/SIBOSDK/notes/notes.rss b/code/SIBOSDK/notes/notes.rss new file mode 100644 index 0000000..4f8ac3c --- /dev/null +++ b/code/SIBOSDK/notes/notes.rss @@ -0,0 +1,330 @@ +/* NOTES.RSS */ + +#include +#include +#include +#include + +RESOURCE WSERV_INFO notes_accs + { + menbar_id=notes_menubar; + first_com=O_COM_EXIT; + accel={'x', + 'a','j','k','d','r','u', + 'i','c','b','e','z', + 't','n','f', + 'o','s','w','q','l', + '+','-','*','/', + 'g','m','h','y','p'}; + } + +RESOURCE MENU_BAR notes_menubar + { + items = + { + MENU_BAR_ITEM + { + menu_id=notes_menu; + mb_item="Notes"; + }, + MENU_BAR_ITEM + { + menu_id=edit_menu; + mb_item="Edit"; + }, + MENU_BAR_ITEM + { + menu_id=windows_menu; + mb_item="Windows"; + }, + MENU_BAR_ITEM + { + menu_id=search_menu; + mb_item="Search"; + }, + MENU_BAR_ITEM + { + menu_id=tag_menu; + mb_item="Tag"; + }, + MENU_BAR_ITEM + { + menu_id=special_menu; + mb_item="Special"; + } + }; + } + +RESOURCE MENU notes_menu + { + items = + { + MENU_ITEM + { + com_id=O_NCON_NEW; + mn_item="New note"; + }, + MENU_ITEM + { + com_id=O_NCON_INSERT; + mn_item="Insert note"; + }, + MENU_ITEM + { + com_id=O_NCON_COPY; + mn_item="Copy note"; + }, + MENU_ITEM + { + com_id=O_NCON_DELETE; + mn_item="Delete note"; + }, + MENU_ITEM + { + com_id=O_NCON_RECORD; + mn_item="Record"; + }, + MENU_ITEM + { + com_id=O_NCON_UNDO; + mn_item="Undo"; + } + }; + } + +RESOURCE MENU edit_menu + { + items = + { + MENU_ITEM + { + com_id=O_NCOE_INSERT; + mn_item="Insert text"; + }, + MENU_ITEM + { + com_id=O_NCOE_COPY; + mn_item="Copy text"; + }, + MENU_ITEM + { + com_id=O_NCOE_BRING; + mn_item="Bring"; + }, + MENU_ITEM + { + com_id=O_NCOE_EVALUATE; + mn_item="Evaluate"; + }, + MENU_ITEM + { + com_id=O_NCOE_SUM; + mn_item="Sum"; + } + }; + } + +RESOURCE MENU windows_menu + { + items = + { + MENU_ITEM + { + com_id=O_NCOW_TITLE; + mn_item="Title window"; + }, + MENU_ITEM + { + com_id=O_NCOW_NOTES; + mn_item="Notes window"; + }, + MENU_ITEM + { + com_id=O_NCOW_FIND; + mn_item="Find window"; + } + }; + } + +RESOURCE MENU search_menu + { + items = + { + MENU_ITEM + { + com_id=O_NCOS_OPTIONS; + mn_item="Options"; + }, + MENU_ITEM + { + com_id=O_NCOS_FORWARDS; + mn_item="Search forwards"; + }, + MENU_ITEM + { + com_id=O_NCOS_BACKWARDS; + mn_item="Search backwards"; + }, + MENU_ITEM + { + com_id=O_NCOS_FIRST; + mn_item="Search first"; + }, + MENU_ITEM + { + com_id=O_NCOS_LAST; + mn_item="Search last"; + } + }; + } + +RESOURCE MENU tag_menu + { + items = + { + MENU_ITEM + { + com_id=O_NCOT_SET; + mn_item="Set"; + }, + MENU_ITEM + { + com_id=O_NCOT_CLEAR; + mn_item="Clear"; + }, + MENU_ITEM + { + com_id=O_NCOT_SET_ALL; + mn_item="Tag all"; + }, + MENU_ITEM + { + com_id=O_NCOT_CLEAR_ALL; + mn_item="Clear all"; + } + }; + } + +RESOURCE MENU special_menu + { + items = + { + MENU_ITEM + { + com_id=O_NCOX_GOTO; + mn_item="Go to"; + }, + MENU_ITEM + { + com_id=O_NCOX_MOVETO; + mn_item="Move to"; + }, + MENU_ITEM + { + com_id=O_NCOX_SYMBOLS; + mn_item="Show symbols"; + }, + MENU_ITEM + { + com_id=O_NCOX_PSETUP; + mn_item="Print setup"; + }, + MENU_ITEM + { + com_id=O_NCOX_PRINT; + mn_item="Print"; + }, + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +RESOURCE STRING nostr_find_prompt { str="Find: "; } /* includes space */ +RESOURCE STRING nostr_max_number_notes { str="Maximum number of notes already reached"; } + +RESOURCE STRING nostr_no_note_inserted { str="No note to insert"; } +RESOURCE STRING nostr_note_copied { str="Note copied"; } +RESOURCE STRING nostr_no_note_copied { str="No note to copy"; } +RESOURCE STRING nostr_note_recorded { str="Note recorded"; } + +RESOURCE STRING nostr_no_text_inserted { str="No text to insert"; } +RESOURCE STRING nostr_no_text_copied { str="No text to copy"; } +RESOURCE STRING nostr_text_copied { str="Text copied"; } +RESOURCE STRING nostr_only_in_notes { str="Only available in notes window"; } +RESOURCE STRING nostr_tag_count { str="Number of notes currently tagged: %d"; } +RESOURCE STRING nostr_delete_note { str="Delete this note"; } +RESOURCE STRING nostr_undo_editing { str="Undo editing"; } +RESOURCE STRING nostr_not_found { str="Not found"; } +RESOURCE STRING nostr_not_changed { str="Not changed"; } + +RESOURCE DIALOG nodl_goto + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + title="Go to"; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Note number"; + info=NCEDIT + { + low=1; + high=99; + }; + } + }; + } + +RESOURCE DIALOG nodl_moveto + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + title="Move note"; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="New note number"; + info=NCEDIT + { + low=1; + high=99; + }; + } + }; + } + +RESOURCE MENU nom_find_types + { + items = + { + CHOICE_ITEM { str="Just notes";}, + CHOICE_ITEM { str="Just title";}, + CHOICE_ITEM { str="Title and notes";} + }; + } + +RESOURCE DIALOG nodl_options + { + title="Options for search"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Case sensitive"; + info=CHLIST { rid=-SYS_NO_YES; }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Search"; + info=CHLIST { rid=nom_find_types; }; + } + }; + } diff --git a/code/SIBOSDK/notes/notes1.pic b/code/SIBOSDK/notes/notes1.pic new file mode 100644 index 0000000..63d830f Binary files /dev/null and b/code/SIBOSDK/notes/notes1.pic differ diff --git a/code/SIBOSDK/notes/notes2.pic b/code/SIBOSDK/notes/notes2.pic new file mode 100644 index 0000000..eeb14f9 Binary files /dev/null and b/code/SIBOSDK/notes/notes2.pic differ diff --git a/code/SIBOSDK/notes/notesrel.prj b/code/SIBOSDK/notes/notesrel.prj new file mode 100644 index 0000000..5e96ff0 --- /dev/null +++ b/code/SIBOSDK/notes/notesrel.prj @@ -0,0 +1,23 @@ +notesrel.prj ! release files list +notes.pr ! TS project file +make.bat ! makes NOTES.APP +! +nolayout.h ! layout constants +notes.def ! function prototypes +notes.cat ! category file +notes.re ! resource externals +notes.rss ! resource script +! +nocomman.c ! command manager +nodlgs.c ! dialogs +noengine.c ! engine +nolinksv.c ! link server +nomain.c ! main +nowin.c ! note window +nowserv.c ! window server +! +notes.afl ! add file list +notes1.pic ! s3 icon +notes2.pic ! s3a icon +notes.plk ! icon link file +notes.ms ! shell data source file diff --git a/code/SIBOSDK/notes/nowin.c b/code/SIBOSDK/notes/nowin.c new file mode 100644 index 0000000..39ef104 --- /dev/null +++ b/code/SIBOSDK/notes/nowin.c @@ -0,0 +1,164 @@ +/* NOWIN.C */ + +#include +#include +#include +#include "nolayout.h" + +GLREF_D PR_NOCOMMAN *DatApp2; +GLREF_D LAYOUT_DATA ld; + +LOCAL_C VOID DrawTextInWindow(INT wid,TEXT *pstr) + { + W_WINDATA wd; + + wInquireWindow(wid,&wd); + wd.extent.tl.x=wd.extent.tl.y=0; + gPrintBoxText((P_RECT *)(&wd.extent),ld.FontAscent+1, + G_TEXT_ALIGN_CENTRE,0,pstr,p_slen(pstr)); + } + +#pragma METHOD_CALL + +METHOD VOID nowin_wn_key(PR_NOWIN *self,INT keycode,INT mods) + { + if (keycode==W_KEY_TAB) + p_send3(DatApp2,O_NCO_SWITCH_FOCUS,mods); + else + p_send4(self->nowin.edwin,O_WN_KEY,keycode,mods); + } + +METHOD VOID nowin_wn_emphasise(PR_NOWIN *self,INT emphasise) + { + p_supersend3(self,O_WN_EMPHASISE,emphasise); + p_send3(self->nowin.edwin,O_WN_EMPHASISE,emphasise); + } + +METHOD VOID nowin_wn_draw(PR_NOWIN *self) + { + p_supersend2(self,O_WN_DRAW); + p_send2(self->nowin.edwin,O_WN_DRAW); + } + +METHOD VOID nowin_wn_init(PR_NOWIN *self,IN_EDWIN *pined,IN_EDWIN_X *pinx) + { + W_WINDATA wd; + + wd.extent.tl=pinx->pos; + wd.extent.width=pined->vulen; + wd.extent.height=ld.FontHeight+2; + if (pined->flags&IN_EDWIN_VISLINES_SUPPLIED) + wd.extent.height*=pinx->vislines; + wd.extent.height+=EDGE_HEIGHT; + p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + self->win.flags=PR_BWIN_CORNER_4|PR_BWIN_SHADOW_2; + pinx->pos.x=EDGE_TLX; + pinx->pos.y=EDGE_TLY; + pined->vulen-=EDGE_WIDTH; + p_send4(self,O_NW_INIT,pined,pinx); + self->nowin.edwin=f_newsend(CAT_NOTES_HWIM,C_EDWIN, + O_WN_INIT,pined,self,pinx); + } + +METHOD VOID nowin_nw_increase_width(PR_NOWIN *self,INT increase) + { + W_WINDATA wd; + PR_EDWIN *edwin; + + wInvalidateWin(self->win.id); + wInquireWindow(self->win.id,&wd); + wd.extent.width+=increase; + wSetWindow(self->win.id,W_WIN_EXTENT,&wd); + edwin=self->nowin.edwin; + p_send3(edwin,O_EW_SENSE_SIZE,&wd.extent); + edwin->edwin.margins.right+=increase; + wd.extent.width+=increase; + p_send4(edwin,O_EW_SET_SIZE,&wd.extent,NULL); + } + +METHOD VOID notitwin_wn_key(PR_NOWIN *self,INT keycode,INT mods) + { + if (keycode==W_KEY_RETURN) + p_send3(DatApp2,O_NCO_SWITCH_FOCUS,mods); + else + p_supersend4(self,O_WN_KEY,keycode,mods); + } + +METHOD VOID nofndwin_wn_key(PR_NOWIN *self,INT keycode,INT mods) + { + if (keycode==W_KEY_RETURN) + p_send3(DatApp2,O_NCO_QUICK_FIND,mods&W_SHIFT_MODIFIER? -1: +1); + else + p_supersend4(self,O_WN_KEY,keycode,mods); + } + +METHOD VOID nofndwin_destroy(PR_NOFNDWIN *self) + { + p_free(self->nofndwin.prompt); + p_supersend2(self,O_DESTROY); + } + +METHOD VOID nofndwin_nw_init(PR_NOFNDWIN *self,IN_EDWIN *pined,IN_EDWIN_X *pinx) + { + UWORD width; + + self->nofndwin.x=EDGE_TLX; + self->nofndwin.y=EDGE_TLY+(1+ld.FontAscent); + self->nofndwin.len= + hLoadResource(NOSTR_FIND_PROMPT,&self->nofndwin.prompt)-1; + width=gTextWidth(WS_FONT_SYSTEM,G_STY_ITALIC, + self->nofndwin.prompt,self->nofndwin.len); + pinx->pos.x=EDGE_TLX+width; + pined->vulen-=width; + } + +METHOD VOID nofndwin_wn_draw(PR_NOFNDWIN *self) + { + p_supersend2(self,O_WN_DRAW); + hSetGStyle(G_STY_ITALIC); + gPrintText(self->nofndwin.x,self->nofndwin.y, + self->nofndwin.prompt,self->nofndwin.len); + hSetGStyle(G_STY_NORMAL); + } + +METHOD VOID notagwin_wn_set(PR_NOTAGWIN *self,INT on) + { + if (on==self->notagwin.on) + return; + wInvalidateWin(self->win.id); + self->notagwin.on=on; + } + +#define TICK_SYM_AS_STRING "\014" + +METHOD VOID notagwin_wn_draw(PR_NOTAGWIN *self) + { + DrawTextInWindow(self->win.id,self->notagwin.on? TICK_SYM_AS_STRING: ""); + } + +METHOD INT notagwin_wn_sense(PR_NOTAGWIN *self) + { + return(hGetSWid(TICK_SYM_AS_STRING)+TEXT_WINDOW_EDGE_WIDTH); + } + +METHOD VOID nocntwin_wn_set(PR_NOCNTWIN *self,INT val,INT max) + { + if (val==self->nocntwin.val && max==self->nocntwin.max) + return; + wInvalidateWin(self->win.id); + self->nocntwin.val=val; + self->nocntwin.max=max; + } + +METHOD VOID nocntwin_wn_draw(PR_NOCNTWIN *self) + { + TEXT buf[10]; + + p_atos(&buf[0],"%d/%d",self->nocntwin.val,self->nocntwin.max); + DrawTextInWindow(self->win.id,&buf[0]); + } + +METHOD INT nocntwin_wn_sense(PR_NOCNTWIN *self) + { + return(hGetSWid("99/99")+TEXT_WINDOW_EDGE_WIDTH); + } diff --git a/code/SIBOSDK/notes/nowserv.c b/code/SIBOSDK/notes/nowserv.c new file mode 100644 index 0000000..17efcd6 --- /dev/null +++ b/code/SIBOSDK/notes/nowserv.c @@ -0,0 +1,21 @@ +/* NOWSERV.C */ + +#include + +GLREF_D PR_HWIMMAN *w_am; +GLREF_D PR_NOCOMMAN *DatApp2; +GLREF_D PR_EDWIN *DatApp3; + +#pragma METHOD_CALL + +METHOD VOID nowserv_ws_background(PR_NOWSERV *self) + { + INT fmt; + + if (!(self->wserv.flags&PR_WSERV_RECEIVED_KEY)) + return; + fmt=0; + if (DatApp2->nocomman.which==NOTES_WINDOW && DatApp3->edwin.select) + fmt=(1<appman.system,O_SY_LINK_SERVER,fmt,0); + } diff --git a/code/SIBOSDK/oopdemo/cc.bat b/code/SIBOSDK/oopdemo/cc.bat new file mode 100644 index 0000000..b95f574 --- /dev/null +++ b/code/SIBOSDK/oopdemo/cc.bat @@ -0,0 +1,3 @@ +@echo off +call checkvid +tscx %1.c /fpunnamed /%jpivid% diff --git a/code/SIBOSDK/oopdemo/checkvid.bat b/code/SIBOSDK/oopdemo/checkvid.bat new file mode 100644 index 0000000..5c6199f --- /dev/null +++ b/code/SIBOSDK/oopdemo/checkvid.bat @@ -0,0 +1,2 @@ +@if not "%jpivid%"=="v2" set jpivid=v0 + diff --git a/code/SIBOSDK/oopdemo/dirlist.c b/code/SIBOSDK/oopdemo/dirlist.c new file mode 100644 index 0000000..cee1e15 --- /dev/null +++ b/code/SIBOSDK/oopdemo/dirlist.c @@ -0,0 +1,31 @@ +/* +DIRLIST +*/ + +#include +#include + +#pragma METHOD_CALL + +METHOD INT dirlist_va_test(PR_DIRLIST *self,RC_VAXVAR *prec1,RC_VAXVAR *prec2) +/* +Firstly perform a 2 way test on file or dir name records. +Order dir names before file names. +Otherwise order names alphabetically. +Return 0 if equal, <0 if *prec1 is before *prec2, >0 if after. +*/ + { + FAST DIRLIST_ITEM *p1,*p2; + FAST INT ret; + + ret=0; + p1=(DIRLIST_ITEM *)prec1->buf; + p2=(DIRLIST_ITEM *)prec2->buf; + if ((p1->info.status&P_FADIR)^(p2->info.status&P_FADIR)) + ret=(p1->info.status&P_FADIR)?-1:+1; + else /* both records either dir or file names */ + ret=p_scmp(&p1->name[0],&p2->name[0]); + if (self->varoot.key.desc) + ret=(-ret); /* reverse result if required */ + return(ret); + } diff --git a/code/SIBOSDK/oopdemo/dirmain.c b/code/SIBOSDK/oopdemo/dirmain.c new file mode 100644 index 0000000..39b56d0 --- /dev/null +++ b/code/SIBOSDK/oopdemo/dirmain.c @@ -0,0 +1,105 @@ +/* +DIRLIST +*/ + +#include +#include + +LOCAL_D VOID *dcb=NULL; +LOCAL_D VOID *hand; + +LOCAL_C VOID error(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]); + } + +LOCAL_C VOID panic(TEXT *msg, INT errno) + { + error(msg,errno); + p_leave(0); + } + +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 %7lu %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 VOID CDECL PrintDirList(TEXT *dir) + { + INT ret; + UWORD i,count; + DIRLIST_ITEM *pd,d; + RC_VAXVAR rec; + + p_send2(hand,O_VA_RESET); + if ((ret=p_open(&dcb,dir,P_FDIR))!=0) + panic("Failed to open directory file",ret); + while (!(ret=p_iow(dcb,P_FREAD,&d.name[0],&d.info))) + { + rec.buf=(UBYTE *)&d; + rec.len=sizeof(d.info)+p_slen(&d.name[0])+1; + p_send4(hand,O_VA_INSERTISQ,&rec,&i); + } + p_close(dcb); + dcb=NULL; + if (ret!=E_FILE_EOF) + panic("Failed to read directory",ret); + if (!(count=p_send2(hand,O_VA_COUNT))) + p_printf("No files found"); + else + { + for (i=0;iname[0],&pd->info); + } + } + } + +GLDEF_C INT CDECL DoDirLists(VOID) + { + TEXT name[P_FNAMESIZE]; + + hand=f_newsend(CAT_PRNDIR_PRNDIR,C_DIRLIST,O_VA_INIT,16); + while (p_getl(">",&name[0],P_FNAMESIZE)) + PrintDirList(&name[0]); + p_send2(hand,O_DESTROY); + return(0); + } + +GLDEF_C INT main(VOID) + { + INT err; + + p_linklib(0); + if ((err=p_enter((VOID *)DoDirLists))!=0) + error("Called p_leave",err); + return(0); + } diff --git a/code/SIBOSDK/oopdemo/dylsort.c b/code/SIBOSDK/oopdemo/dylsort.c new file mode 100644 index 0000000..014b367 --- /dev/null +++ b/code/SIBOSDK/oopdemo/dylsort.c @@ -0,0 +1,51 @@ +/* +DYLSORT.C +*/ + +#include +#include + +GLREF_D VOID *DatCommandPtr; + +GLDEF_D P_RECT _DefScreenRect; + +LOCAL_D INT array[] = {10,1,5,7,9,3,6,8,4,2}; + +#pragma save,ENTER_CALL + +LOCAL_C INT RunSort(HANDLE dyl) + { + VOID *sort; + + sort=f_newlibh(dyl,C_ISORT); + p_send4(sort,O_SORT,&array[0],10); + p_send2(sort,O_DESTROY); + return(0); + } + +#pragma restore + +GLDEF_C INT main(VOID) + { + INT err,i; + HANDLE dyl; + VOID *dcb; + + p_openlib(&dcb,DatCommandPtr); + err=p_loadfilelib(dcb,0,&dyl,TRUE); + if (!err) + { + _DefScreenRect.tl.x=0; + _DefScreenRect.tl.y=0; + _DefScreenRect.br.x=40; + _DefScreenRect.br.y=8; + + p_printf("Sorting..."); + err=p_enter2(RunSort,dyl); + p_unloadlib(dyl); + for (i=0;i<10;i+=2) + p_printf("%4d %4d",array[i],array[i+1]); + p_getch(); + } + return(err); + } diff --git a/code/SIBOSDK/oopdemo/dylsort.dfl b/code/SIBOSDK/oopdemo/dylsort.dfl new file mode 100644 index 0000000..98e9631 --- /dev/null +++ b/code/SIBOSDK/oopdemo/dylsort.dfl @@ -0,0 +1 @@ +sort.dyl diff --git a/code/SIBOSDK/oopdemo/dylsort.pr b/code/SIBOSDK/oopdemo/dylsort.pr new file mode 100644 index 0000000..7062a2b --- /dev/null +++ b/code/SIBOSDK/oopdemo/dylsort.pr @@ -0,0 +1,7 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#pragma link(olib.lib) +#pragma link(dylsort) +#link dylsort diff --git a/code/SIBOSDK/oopdemo/hello.afl b/code/SIBOSDK/oopdemo/hello.afl new file mode 100644 index 0000000..58bb4cc --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello.afl @@ -0,0 +1,3 @@ +hello.pic +hello.rzc +hello.shd diff --git a/code/SIBOSDK/oopdemo/hello.cat b/code/SIBOSDK/oopdemo/hello.cat new file mode 100644 index 0000000..72f45f0 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello.cat @@ -0,0 +1,19 @@ +IMAGE hello + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE hwimman.g + +CLASS hellows wserv +window server active object + { + REPLACE ws_dyn_init + } + +CLASS hellobw bwin +bordered window + { + REPLACE wn_init + REPLACE wn_draw + } diff --git a/code/SIBOSDK/oopdemo/hello.ms b/code/SIBOSDK/oopdemo/hello.ms new file mode 100644 index 0000000..5e9fef7 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello.ms @@ -0,0 +1,3 @@ +Hello + +0 diff --git a/code/SIBOSDK/oopdemo/hello.pic b/code/SIBOSDK/oopdemo/hello.pic new file mode 100644 index 0000000..51b7607 Binary files /dev/null and b/code/SIBOSDK/oopdemo/hello.pic differ diff --git a/code/SIBOSDK/oopdemo/hello.pr b/code/SIBOSDK/oopdemo/hello.pr new file mode 100644 index 0000000..d2128b8 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello.pr @@ -0,0 +1,41 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#set version=0x100F +#set priority=0x80 +#set heapsize=0x80 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort +#endif + +#if %main.rzc #older %main.rsg #then + #run "rch %main" no_window no_abort +#endif + +#compile o_hello.c + +#if %main.shd #older %main.ms #then + #run "makeshd %main" no_window no_abort + #file delete %main.img +#endif + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main + diff --git a/code/SIBOSDK/oopdemo/hello.re b/code/SIBOSDK/oopdemo/hello.re new file mode 100644 index 0000000..8d3b206 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello.re @@ -0,0 +1,3 @@ +#include + +_O_COM_EXIT diff --git a/code/SIBOSDK/oopdemo/hello.rss b/code/SIBOSDK/oopdemo/hello.rss new file mode 100644 index 0000000..87cdd12 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello.rss @@ -0,0 +1,40 @@ +/* + HELLO.RSS + +English resource file for Hello World application + +*/ + +#include +#include + +RESOURCE WSERV_INFO hello_accs + { + menbar_id=hello_menbar; + first_com=O_COM_EXIT; + accel={'x'}; /* Exit */ + } + +RESOURCE MENU_BAR hello_menbar + { + 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"; + } + }; + } diff --git a/code/SIBOSDK/oopdemo/hello2.afl b/code/SIBOSDK/oopdemo/hello2.afl new file mode 100644 index 0000000..b37736a --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello2.afl @@ -0,0 +1,3 @@ +hello.pic +hello2.rzc +hello2.shd diff --git a/code/SIBOSDK/oopdemo/hello2.cat b/code/SIBOSDK/oopdemo/hello2.cat new file mode 100644 index 0000000..389f9de --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello2.cat @@ -0,0 +1,31 @@ +IMAGE hello2 + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE hwimman.g + +CLASS hellows wserv +window server active object + { + REPLACE ws_dyn_init + } + +CLASS hellobw bwin +bordered window + { + REPLACE wn_init + REPLACE wn_draw + REPLACE wn_set + PROPERTY + { + UWORD isbye; + } + } + +CLASS hellocm comman +command manager + { + ADD com_hello + ADD com_bye + } diff --git a/code/SIBOSDK/oopdemo/hello2.ms b/code/SIBOSDK/oopdemo/hello2.ms new file mode 100644 index 0000000..2445b28 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello2.ms @@ -0,0 +1,3 @@ +Hello2 + +0 diff --git a/code/SIBOSDK/oopdemo/hello2.pr b/code/SIBOSDK/oopdemo/hello2.pr new file mode 100644 index 0000000..1370435 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello2.pr @@ -0,0 +1,41 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#set version=0x100F +#set priority=0x80 +#set heapsize=0x80 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort +#endif + +#if (%main.rzc #older %main.rsg) #or (%main.rsg #older %main.rss) #then + #run "rch %main" no_window no_abort +#endif + +#compile o_hello2.c + +#if %main.shd #older %main.ms #then + #run "makeshd %main" no_window no_abort + #file delete %main.img +#endif + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main + diff --git a/code/SIBOSDK/oopdemo/hello2.re b/code/SIBOSDK/oopdemo/hello2.re new file mode 100644 index 0000000..d278edc --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello2.re @@ -0,0 +1,6 @@ +#include +#include + +_O_COM_EXIT +_O_COM_HELLO +_O_COM_BYE diff --git a/code/SIBOSDK/oopdemo/hello2.rss b/code/SIBOSDK/oopdemo/hello2.rss new file mode 100644 index 0000000..ff021b8 --- /dev/null +++ b/code/SIBOSDK/oopdemo/hello2.rss @@ -0,0 +1,68 @@ +/* + HELLO.RSS + +English resource file for Hello World application + +*/ + +#include +#include + +RESOURCE WSERV_INFO hello_accs + { + menbar_id=hello_menbar; + first_com=O_COM_EXIT; + accel={'x', /* Exit */ + 'h', /* Hello */ + 'b'}; /* Bye */ + } + +RESOURCE MENU_BAR hello_menbar + { + items= + { + MENU_BAR_ITEM + { + menu_id=message_menu; + mb_item="Message"; + }, + MENU_BAR_ITEM + { + menu_id=special_menu; + mb_item="Special"; + } + }; + } + +RESOURCE MENU message_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_HELLO; + mn_item="Say hello"; + }, + MENU_ITEM + { + com_id=O_COM_BYE; + mn_item="Say goodbye"; + } + }; + } + +RESOURCE MENU special_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +RESOURCE STRING hello_message {str="Hello World";} + +RESOURCE STRING bye_message {str="Goodbye Cruel World";} diff --git a/code/SIBOSDK/oopdemo/isort.c b/code/SIBOSDK/oopdemo/isort.c new file mode 100644 index 0000000..5e69799 --- /dev/null +++ b/code/SIBOSDK/oopdemo/isort.c @@ -0,0 +1,35 @@ +/* +ISORT.C +*/ + +#include + +#define IdataBuf ((INT *)DataBuf) + +LOCAL_C INT OrdFunc(INT i,INT j,VOID *DataBuf) +/* +order function used in qsort +*/ + { + return(IdataBuf[i]-IdataBuf[j]); + } + +LOCAL_C VOID ExchFunc(INT i,INT j,VOID *DataBuf) +/* +exchange function used in qsort +*/ + { + INT k; + + k=IdataBuf[i]; + IdataBuf[i]=IdataBuf[j]; + IdataBuf[j]=k; + } + +#pragma METHOD_CALL + +METHOD VOID isort_sort(PR_ROOT *self,INT *start,INT num) + { + p_qsort(num,OrdFunc,ExchFunc,start); + } + diff --git a/code/SIBOSDK/oopdemo/lf.bat b/code/SIBOSDK/oopdemo/lf.bat new file mode 100644 index 0000000..8eec323 --- /dev/null +++ b/code/SIBOSDK/oopdemo/lf.bat @@ -0,0 +1,3 @@ +@echo off +call checkvid +tscx %1.pr /l /%jpivid% diff --git a/code/SIBOSDK/oopdemo/lfc.bat b/code/SIBOSDK/oopdemo/lfc.bat new file mode 100644 index 0000000..74e04b9 --- /dev/null +++ b/code/SIBOSDK/oopdemo/lfc.bat @@ -0,0 +1,3 @@ +@echo off +if exist %1.dyl del %1.dyl +tscx %1.pr /l /v0 diff --git a/code/SIBOSDK/oopdemo/make.bat b/code/SIBOSDK/oopdemo/make.bat new file mode 100644 index 0000000..319ca30 --- /dev/null +++ b/code/SIBOSDK/oopdemo/make.bat @@ -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 diff --git a/code/SIBOSDK/oopdemo/o_hello.c b/code/SIBOSDK/oopdemo/o_hello.c new file mode 100644 index 0000000..d57a743 --- /dev/null +++ b/code/SIBOSDK/oopdemo/o_hello.c @@ -0,0 +1,52 @@ +/* +O_HELLO +*/ + +#include +#include +#include + +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D VOID *w_am; + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV ws; + + p_linklib(0); + app.flags=/*FLG_APPMAN_FULLSCREEN|*/FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN| + FLG_APPMAN_SRSCFILE/*|FLG_APPMAN_IPCS|FLG_APPMAN_LINKING*/; + app.wserv_cat=p_getlibh(CAT_HELLO_HELLO); + ws.com_cat=p_getlibh(CAT_HELLO_HWIM); + app.wserv_class=C_HELLOWS; + ws.com_class=C_COMMAN; + p_send4(p_new(CAT_HELLO_HWIM,C_HWIMMAN),O_AM_INIT,&app,&ws); + } + +#pragma METHOD_CALL + +METHOD VOID hellows_ws_dyn_init(PR_HELLOWS *self) + { + self->wserv.cli=f_new(CAT_HELLO_HELLO,C_HELLOBW); + p_send2(self->wserv.cli,O_WN_INIT); + } + +METHOD VOID hellobw_wn_init(PR_HELLOBW *self) + { + W_WINDATA wd; + + wd.extent.tl.x=0; + wd.extent.tl.y=0; + wd.extent.width=wserv_channel->conn.info.pixels.x; + wd.extent.height=wserv_channel->conn.info.pixels.y; + p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + p_send3(self,O_WN_VISIBLE,WV_INITVIS); + p_send3(self,O_WN_EMPHASISE,TRUE); + } + +METHOD VOID hellobw_wn_draw(PR_HELLOBW *self) + { + p_supersend2(self,O_WN_DRAW); + gPrintText(50,50,"Hello World",11); + } diff --git a/code/SIBOSDK/oopdemo/o_hello2.c b/code/SIBOSDK/oopdemo/o_hello2.c new file mode 100644 index 0000000..1516a6a --- /dev/null +++ b/code/SIBOSDK/oopdemo/o_hello2.c @@ -0,0 +1,75 @@ +/* +O_HELLO +*/ + +#include +#include +#include + +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D PR_HWIMMAN *w_am; +GLREF_D PR_WSERV *w_ws; + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV ws; + + p_linklib(0); + app.flags=/*FLG_APPMAN_FULLSCREEN|*/FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN| + FLG_APPMAN_SRSCFILE/*|FLG_APPMAN_IPCS|FLG_APPMAN_LINKING*/; + app.wserv_cat=p_getlibh(CAT_HELLO2_HELLO2); + ws.com_cat=p_getlibh(CAT_HELLO2_HELLO2); + app.wserv_class=C_HELLOWS; + ws.com_class=C_HELLOCM; + p_send4(p_new(CAT_HELLO2_HWIM,C_HWIMMAN),O_AM_INIT,&app,&ws); + } + +#pragma METHOD_CALL + +METHOD VOID hellows_ws_dyn_init(PR_HELLOWS *self) + { + self->wserv.cli=f_new(CAT_HELLO2_HELLO2,C_HELLOBW); + p_send2(self->wserv.cli,O_WN_INIT); + } + +METHOD VOID hellobw_wn_init(PR_HELLOBW *self) + { + W_WINDATA wd; + + wd.extent.tl.x=0; + wd.extent.tl.y=0; + wd.extent.width=wserv_channel->conn.info.pixels.x; + wd.extent.height=wserv_channel->conn.info.pixels.y; + p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + p_send3(self,O_WN_VISIBLE,WV_INITVIS); + /* hInitVis(self); */ + p_send3(self,O_WN_EMPHASISE,TRUE); + } + +METHOD VOID hellobw_wn_draw(PR_HELLOBW *self) + { + UINT resid; + TEXT buf[40]; + + resid=self->hellobw.isbye ? BYE_MESSAGE:HELLO_MESSAGE; + p_send(w_am,O_AM_LOAD_RES_BUF,resid,&buf[0]); + p_supersend2(self,O_WN_DRAW); + gPrintText(50,50,&buf[0],p_slen(&buf[0])); + } + +METHOD VOID hellobw_wn_set(PR_HELLOBW *self,UINT isbye) + { + self->hellobw.isbye=isbye; + p_send2(self,O_WN_DODRAW); + } + +METHOD VOID hellocm_com_hello(PR_HELLOCM *self) + { + p_send3(w_ws->wserv.cli,O_WN_SET,FALSE); + } + +METHOD VOID hellocm_com_bye(PR_HELLOCM *self) + { + p_send3(w_ws->wserv.cli,O_WN_SET,TRUE); + } diff --git a/code/SIBOSDK/oopdemo/o_timer.c b/code/SIBOSDK/oopdemo/o_timer.c new file mode 100644 index 0000000..d896ac0 --- /dev/null +++ b/code/SIBOSDK/oopdemo/o_timer.c @@ -0,0 +1,72 @@ +/* +O_TIMER +*/ + +#include +#include +#include +#include + +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D VOID *w_am; + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV ws; + + p_linklib(0); + app.flags=FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN|FLG_APPMAN_SRSCFILE; + app.wserv_cat=p_getlibh(CAT_TIMER_TIMER); + ws.com_cat=p_getlibh(CAT_TIMER_HWIM); + app.wserv_class=C_TIMERWS; + ws.com_class=C_COMMAN; + p_send4(p_new(CAT_TIMER_HWIM,C_HWIMMAN),O_AM_INIT,&app,&ws); + } + +#pragma METHOD_CALL + +METHOD VOID timerws_ws_dyn_init(PR_TIMERWS *self) + { + self->wserv.cli=f_new(CAT_TIMER_TIMER,C_TIMERBW); + p_send2(self->wserv.cli,O_WN_INIT); + f_newsend(CAT_TIMER_TIMER,C_MYTIMER,O_AO_INIT,"TIM:",-1); + } + +METHOD VOID timerbw_wn_init(PR_TIMERBW *self) + { + W_WINDATA wd; + + wd.extent.tl.x=0; + wd.extent.tl.y=0; + wd.extent.width=wserv_channel->conn.info.pixels.x; + wd.extent.height=wserv_channel->conn.info.pixels.y; + p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + p_send3(self,O_WN_VISIBLE,WV_INITVIS); + p_send3(self,O_WN_EMPHASISE,TRUE); + } + +METHOD VOID mytimer_ao_init(PR_MYTIMER *self,TEXT *devname,INT mode) + { + p_supersend4(self,O_AO_INIT,devname,mode); + self->active.priority=PRIORITY_ACTIVE_REPEATER; + p_send3(w_am,O_AM_ADD_TASK,self); + p_send2(self,O_AO_QUEUE); + } + +METHOD VOID mytimer_ao_queue(PR_MYTIMER *self) + { + LONG delay; + + delay=20; + p_ioc4(self->active.pcb,P_FREAD,&self->active.stat,&delay); + self->active.isactive=TRUE; + } + +METHOD INT mytimer_ao_run(PR_MYTIMER *self) + { + self->mytimer.count+=1; + hInfoPrint(TIMER_INFO,self->mytimer.count); + p_send2(self,O_AO_QUEUE); + return(RUN_ACTIVE_USED); + } diff --git a/code/SIBOSDK/oopdemo/oopdemo.prj b/code/SIBOSDK/oopdemo/oopdemo.prj new file mode 100644 index 0000000..91f2ba8 --- /dev/null +++ b/code/SIBOSDK/oopdemo/oopdemo.prj @@ -0,0 +1,56 @@ +OOPDEMO.PRJ ! This list file +! +PRNDIR.CAT ! Directory print category file +DIRLIST.C ! Directory print DIRLIST methods +DIRMAIN.C ! Directory print main() +PRNDIR.PR ! Directory print project link file +! +SORT.CAT ! Sort DYL category file +ISORT.C ! Sort method function +SORT.PR ! Sort project link file +! +RSORT.CAT ! Root sort DYL category file +ROOT.C ! Root sort method function +RSORT.PR ! Root sort project link file +! +RUNSORT.C ! Use the sort DYL +RUNSORT.PR ! Link file for above +! +DYLSORT.C ! Sort, using a built-in DYL +DYLSORT.PR ! Link file for above +DYLSORT.DFL ! DYL file list for above +! +HELLO.PIC ! Icon used for the following 3 demonstration programs +! +HELLO.CAT ! Hello World category file +HELLO.RE ! Hello World resource externals file +HELLO.RSS ! Hello World application resource file +O_HELLO.C ! Hello World method source file +HELLO.MS ! Hello World shell data source file +HELLO.AFL ! Hello World add-file list +HELLO.PR ! Hello World project file +! +HELLO2.CAT ! Hello World (2) category file +HELLO2.RE ! Hello World (2) resource externals file +HELLO2.RSS ! Hello World (2) application resource file +O_HELLO2.C ! Hello World (2) method source file +HELLO2.MS ! Hello World (2) shell data source file +HELLO2.AFL ! Hello World (2) add-file list +HELLO2.PR ! Hello World (2) project file +! +TIMER.CAT ! Timer category file +TIMER.RE ! Timer resource externals file +TIMER.RSS ! Timer application resource file +O_TIMER.C ! Timer method source file +TIMER.MS ! Timer shell data source file +TIMER.AFL ! Timer add-file list +TIMER.PR ! Timer project file +! +UNNAMED.PR ! General project file for cc.bat +! +VID.BAT ! Set/clear JPI VID pragma +CHECKVID.BAT ! Check JPI VID pragma +CC.BAT ! cc batch file +LF.BAT ! IMG link batch file +LFC.BAT ! DYL link batch file +MAKE.BAT ! Project make batch file diff --git a/code/SIBOSDK/oopdemo/prndir.cat b/code/SIBOSDK/oopdemo/prndir.cat new file mode 100644 index 0000000..401e8d8 --- /dev/null +++ b/code/SIBOSDK/oopdemo/prndir.cat @@ -0,0 +1,21 @@ +IMAGE prndir + +EXTERNAL olib + +INCLUDE varray.g +INCLUDE p_file.h + + +CLASS dirlist vaxvar +Directory list + { + REPLACE va_test sort by various criteria + TYPES + { + typedef struct + { + P_INFO info; + TEXT name[P_FNAMESIZE]; + } DIRLIST_ITEM; + } + } diff --git a/code/SIBOSDK/oopdemo/prndir.pr b/code/SIBOSDK/oopdemo/prndir.pr new file mode 100644 index 0000000..d4ad20d --- /dev/null +++ b/code/SIBOSDK/oopdemo/prndir.pr @@ -0,0 +1,10 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#pragma link(olib.lib) +#pragma link(prndir) +#pragma link(dirlist) +#pragma link(dirmain) + +#link prndir diff --git a/code/SIBOSDK/oopdemo/root.c b/code/SIBOSDK/oopdemo/root.c new file mode 100644 index 0000000..2104e32 --- /dev/null +++ b/code/SIBOSDK/oopdemo/root.c @@ -0,0 +1,35 @@ +/* +ROOT.C +*/ + +#include + +#define IdataBuf ((INT *)DataBuf) + +LOCAL_C INT OrdFunc(INT i,INT j,VOID *DataBuf) +/* +order function used in qsort +*/ + { + return(IdataBuf[i]-IdataBuf[j]); + } + +LOCAL_C VOID ExchFunc(INT i,INT j,VOID *DataBuf) +/* +exchange function used in qsort +*/ + { + INT k; + + k=IdataBuf[i]; + IdataBuf[i]=IdataBuf[j]; + IdataBuf[j]=k; + } + +#pragma METHOD_CALL + +METHOD VOID root_sort(PR_ROOT *self,INT *start,INT num) + { + p_qsort(num,OrdFunc,ExchFunc,start); + } + diff --git a/code/SIBOSDK/oopdemo/rsort.cat b/code/SIBOSDK/oopdemo/rsort.cat new file mode 100644 index 0000000..8ebcb6a --- /dev/null +++ b/code/SIBOSDK/oopdemo/rsort.cat @@ -0,0 +1,15 @@ +LIBRARY rsort + +INCLUDE p_std.h +INCLUDE p_object.h + +CLASS root + { + ADD destroy + ADD sort Sort a given list of integers + PROPERTY + { + P_OBJECT pc; Class link + } + } + diff --git a/code/SIBOSDK/oopdemo/rsort.pr b/code/SIBOSDK/oopdemo/rsort.pr new file mode 100644 index 0000000..55427e1 --- /dev/null +++ b/code/SIBOSDK/oopdemo/rsort.pr @@ -0,0 +1,8 @@ +#system epoc dyl +#set epocinit=iplib +#model small jpi + +#pragma link(olib.lib) +#pragma link(rsort) +#pragma link(root) +#link rsort diff --git a/code/SIBOSDK/oopdemo/runsort.c b/code/SIBOSDK/oopdemo/runsort.c new file mode 100644 index 0000000..5cc8f23 --- /dev/null +++ b/code/SIBOSDK/oopdemo/runsort.c @@ -0,0 +1,51 @@ +/* +RUNSORT.C +*/ + +#include +#include + +GLREF_D VOID *DatCommandPtr; + +GLDEF_D P_RECT _DefScreenRect; + +LOCAL_D INT array[] = {10,1,5,7,9,3,6,8,4,2}; + +#pragma save,ENTER_CALL + +LOCAL_C INT RunSort(HANDLE dyl) + { + VOID *sort; + + sort=f_newlibh(dyl,C_ISORT); + p_send4(sort,O_SORT,&array[0],10); + p_send2(sort,O_DESTROY); + return(0); + } + +#pragma restore + +GLDEF_C INT main(VOID) + { + INT err,i; + HANDLE dyl; + TEXT buf[P_FNAMESIZE]; + + p_fparse("sort.dyl",DatCommandPtr,&buf[0],NULL); + err=p_loadlib(&buf[0],&dyl,TRUE); + if (!err) + { + _DefScreenRect.tl.x=0; + _DefScreenRect.tl.y=0; + _DefScreenRect.br.x=40; + _DefScreenRect.br.y=8; + + p_printf("Sorting..."); + err=p_enter2(RunSort,dyl); + p_unloadlib(dyl); + for (i=0;i<10;i+=2) + p_printf("%4d %4d",array[i],array[i+1]); + p_getch(); + } + return(err); + } diff --git a/code/SIBOSDK/oopdemo/runsort.pr b/code/SIBOSDK/oopdemo/runsort.pr new file mode 100644 index 0000000..e0597b7 --- /dev/null +++ b/code/SIBOSDK/oopdemo/runsort.pr @@ -0,0 +1,7 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#pragma link(olib.lib) +#pragma link(runsort) +#link runsort diff --git a/code/SIBOSDK/oopdemo/sort.cat b/code/SIBOSDK/oopdemo/sort.cat new file mode 100644 index 0000000..96c133b --- /dev/null +++ b/code/SIBOSDK/oopdemo/sort.cat @@ -0,0 +1,11 @@ +LIBRARY sort + +EXTERNAL olib + +INCLUDE olib.g + +CLASS isort root + { + ADD sort Sort a given list of integers + } + diff --git a/code/SIBOSDK/oopdemo/sort.pr b/code/SIBOSDK/oopdemo/sort.pr new file mode 100644 index 0000000..c2e3c5e --- /dev/null +++ b/code/SIBOSDK/oopdemo/sort.pr @@ -0,0 +1,8 @@ +#system epoc dyl +#set epocinit=iplib +#model small jpi + +#pragma link(olib.lib) +#pragma link(sort) +#pragma link(isort) +#link sort diff --git a/code/SIBOSDK/oopdemo/timer.afl b/code/SIBOSDK/oopdemo/timer.afl new file mode 100644 index 0000000..96a9022 --- /dev/null +++ b/code/SIBOSDK/oopdemo/timer.afl @@ -0,0 +1,3 @@ +hello.pic +timer.rzc +timer.shd diff --git a/code/SIBOSDK/oopdemo/timer.cat b/code/SIBOSDK/oopdemo/timer.cat new file mode 100644 index 0000000..febb61f --- /dev/null +++ b/code/SIBOSDK/oopdemo/timer.cat @@ -0,0 +1,30 @@ +IMAGE timer + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE hwimman.g + +CLASS timerws wserv +window server active object + { + REPLACE ws_dyn_init + } + +CLASS timerbw bwin +bordered window + { + REPLACE wn_init + } + +CLASS mytimer active +timer active object + { + REPLACE ao_init + REPLACE ao_queue + REPLACE ao_run + PROPERTY + { + UWORD count; + } + } diff --git a/code/SIBOSDK/oopdemo/timer.ms b/code/SIBOSDK/oopdemo/timer.ms new file mode 100644 index 0000000..f1ca1e4 --- /dev/null +++ b/code/SIBOSDK/oopdemo/timer.ms @@ -0,0 +1,3 @@ +Timer + +0 diff --git a/code/SIBOSDK/oopdemo/timer.pr b/code/SIBOSDK/oopdemo/timer.pr new file mode 100644 index 0000000..80f2276 --- /dev/null +++ b/code/SIBOSDK/oopdemo/timer.pr @@ -0,0 +1,38 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#set version=0x100F +#set priority=0x80 +#set heapsize=0x80 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort + #run "rch %main" no_window no_abort +#endif + +#compile o_timer.c + +#if %main.shd #older %main.ms #then + #run "makeshd %main" no_window no_abort + #file delete %main.img +#endif + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main + diff --git a/code/SIBOSDK/oopdemo/timer.re b/code/SIBOSDK/oopdemo/timer.re new file mode 100644 index 0000000..8d3b206 --- /dev/null +++ b/code/SIBOSDK/oopdemo/timer.re @@ -0,0 +1,3 @@ +#include + +_O_COM_EXIT diff --git a/code/SIBOSDK/oopdemo/timer.rss b/code/SIBOSDK/oopdemo/timer.rss new file mode 100644 index 0000000..05571a2 --- /dev/null +++ b/code/SIBOSDK/oopdemo/timer.rss @@ -0,0 +1,42 @@ +/* + HELLO.RSS + +English resource file for Hello World application + +*/ + +#include +#include + +RESOURCE WSERV_INFO timer_accs + { + menbar_id=timer_menbar; + first_com=O_COM_EXIT; + accel={'x'}; /* Exit */ + } + +RESOURCE MENU_BAR timer_menbar + { + 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 STRING timer_info {str="Counted to %u";} diff --git a/code/SIBOSDK/oopdemo/unnamed.pr b/code/SIBOSDK/oopdemo/unnamed.pr new file mode 100644 index 0000000..96416fd --- /dev/null +++ b/code/SIBOSDK/oopdemo/unnamed.pr @@ -0,0 +1,6 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile %main +#link %main diff --git a/code/SIBOSDK/oopdemo/vid.bat b/code/SIBOSDK/oopdemo/vid.bat new file mode 100644 index 0000000..4ccb4d5 --- /dev/null +++ b/code/SIBOSDK/oopdemo/vid.bat @@ -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 + diff --git a/code/SIBOSDK/pr/clib.pr b/code/SIBOSDK/pr/clib.pr new file mode 100644 index 0000000..8c0df02 --- /dev/null +++ b/code/SIBOSDK/pr/clib.pr @@ -0,0 +1,73 @@ +#system epoc img +#model small jpi + +#message "Epoc/Os CLIB library project file" + +#pragma check(index=>off, + range=>off, + overflow=>off, + stack=>off, + nil_ptr=>off + ) +#pragma optimize(speed=>off) +#pragma option(ansi=>off) + +#pragma define( _ENV => off, _WINDOWS => off, _DLL => off, _OVL => off, _OS2 => off, _WINDLL=>off) +#pragma define( _SMALL_INLINE=>on) +#pragma define( _EPOC=>on) + +#message "Compiling standard object files" +#compile iplib.a +#compile iplib2.a +#compile iplib8.a +#compile iclib2.a +#compile iclib4.a +#compile iclib.a +#compile icat.a +#compile nofloat.a +#compile r_emul.a +#dolink dummy.lib + +#message "Compiling RLIB library files" +#compile coreinit.a +#compile corertl.a +#compile cpplow.a +#compile new.cpp +#message "Making shared library RLIB.LIB" +#dolink rlib.lib + +#message "Compiling core CLIB library files" +#compile coremain.a +#compile coresig.a +#compile coremath.a +#compile corefile.a +#compile coremem.a +#compile coreio.a + +#message "Compiling CLIB C library files" +#compile cdata.c +#compile clib1.a +#compile clib2.c +#compile printf.c +#compile scanf.c +#compile cstr.a +#compile cio1.a +#compile cio2.c +#compile csys.c +#compile epoc.a +#compile epoc1.c + +#message "Compiling CLIB CPP library files" +#compile bcd.cpp +#compile complex.cpp +#compile coniostr.cpp +#compile fstream.cpp +#compile ioinline.cpp +#compile iostream.cpp +#compile stdiostr.cpp +#compile stream.cpp +#compile strstrea.cpp + +#message "Making C library CLIB.LIB" +#dolink clib.lib + diff --git a/code/SIBOSDK/pr/ptempl.pr b/code/SIBOSDK/pr/ptempl.pr new file mode 100644 index 0000000..ad87d0f --- /dev/null +++ b/code/SIBOSDK/pr/ptempl.pr @@ -0,0 +1,8 @@ +#system epoc img +#set epocinit=iplib +#model small jpi +#pragma define(EPOC=>1,JPIC=>1) + +#compile %main +#link %prjname + diff --git a/code/SIBOSDK/pr/template.pr b/code/SIBOSDK/pr/template.pr new file mode 100644 index 0000000..ac171dc --- /dev/null +++ b/code/SIBOSDK/pr/template.pr @@ -0,0 +1,7 @@ +#system epoc img +#model small jpi +#pragma define(EPOC=>1,JPIC=>1) + +#compile %main +#link %prjname + diff --git a/code/SIBOSDK/pr/unnamed.pr b/code/SIBOSDK/pr/unnamed.pr new file mode 100644 index 0000000..998a9e7 --- /dev/null +++ b/code/SIBOSDK/pr/unnamed.pr @@ -0,0 +1,8 @@ +#system epoc img +#model small jpi +#pragma define(EPOC=>1,JPIC=>1) + +#compile %main +#link %prjname + + diff --git a/code/SIBOSDK/record/checkvid.bat b/code/SIBOSDK/record/checkvid.bat new file mode 100644 index 0000000..5c6199f --- /dev/null +++ b/code/SIBOSDK/record/checkvid.bat @@ -0,0 +1,2 @@ +@if not "%jpivid%"=="v2" set jpivid=v0 + diff --git a/code/SIBOSDK/record/make.bat b/code/SIBOSDK/record/make.bat new file mode 100644 index 0000000..319ca30 --- /dev/null +++ b/code/SIBOSDK/record/make.bat @@ -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 diff --git a/code/SIBOSDK/record/rec3b.prj b/code/SIBOSDK/record/rec3b.prj new file mode 100644 index 0000000..4e93133 --- /dev/null +++ b/code/SIBOSDK/record/rec3b.prj @@ -0,0 +1,23 @@ +rec3b.prj ! This list file +! +record.cat ! Cat file for application +record.re ! Hash defines from cat file needed in resource file +record.hlp ! Help text resources +record.rss ! Resource file for application +! +reccli.c ! client bordered window +reccom.c ! Command manager code +recdial.c ! Dialogs +receng.c ! Engine +recwserv.c ! Application WSERV +waveao.c ! Sound active objects +wvefile.c ! Sound file +! +record.ms ! Source for shell data on record +record.afl ! Lists the files to be built into record.img +record.pic ! Application icon +record.pr ! Project file for Record +! +VID.BAT ! Set/clear debug status +CHECKVID.BAT ! Check debug status +MAKE.BAT ! Project make file diff --git a/code/SIBOSDK/record/reccli.c b/code/SIBOSDK/record/reccli.c new file mode 100644 index 0000000..9b510c0 --- /dev/null +++ b/code/SIBOSDK/record/reccli.c @@ -0,0 +1,473 @@ +/* +RECCLI.C + +The record application's client window and its components +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GLREF_D PR_RECWSERV * const w_ws; +GLREF_D PR_APPMAN * const w_am; +GLREF_D PR_RECENG * const receng; + +#define TIMEBAR_HEIGHT 13 + +#define RECBUT_HIDE_DRAW 0 +#define RECBUT_HIDE_HIDE 1 +#define RECBUT_HIDE_CLEAR 2 + +#define RECBUT_HALF_WIDTH 34 +#define RECBUT_HALF_HEIGHT 10 +#define RECBUT_ASCENT 16 +#define RECBUT_MARGIN 20 + +#define RECCLI_NBUTTONS 5 +#define RECCLI_3BUT_MASK 0x7 /* 1st 3 buttons */ +#define RECCLI_STOP_MASK 0x8 /* 4th button */ +#define RECCLI_START_MASK 0x10 /* 5th button */ + +LOCAL_D UBYTE recbut_hide[RECCLI_NBUTTONS]= + {RECBUT_HIDE_CLEAR,RECBUT_HIDE_HIDE,RECBUT_HIDE_CLEAR,RECBUT_HIDE_HIDE,RECBUT_HIDE_HIDE}; + +LOCAL_C TEXT *NextZTS(TEXT *str) + { + while (*str++); + return(str); + } + +LOCAL_C VOID StartFRC(PR_TIMEBAR *self) + { + UWORD tick,mode; + + mode=E_FRC_REPEATING; + tick=100; + p_iow4(self->active.pcb,P_FSTART,&mode,&tick); + } + +LOCAL_C INT BarLength(PR_TIMEBAR *self) + { + INT width; + + width=self->timebar.rect.br.x-self->timebar.rect.tl.x-2; + if (self->timebar.tenths0) + width-=(UINT)((width*self->timebar.tenths)/self->timebar.tenths0); + return(width); + } + +LOCAL_C VOID DrawBar(PR_TIMEBAR *self,INT border,INT createGC) + { + INT x1,x2; + P_RECT r; + + x1=self->timebar.x; + x2=BarLength(self); + if (x2==x1 && self->timebar.visible && !border) + return; + if (createGC) + gCreateTempGC0(self->timebar.wid); + r=self->timebar.rect; + if (!self->timebar.visible) + { + gClrRect(&r,G_TRMODE_CLR); + goto exit; + } + if (border) + gBorderRect(&r,W_BORD_CORNER_1); + p_insrec(&r,1,1); + if (x1>x2) + { + gClrRect(&r,G_TRMODE_CLR); + x1=0; + } + self->timebar.x=x2; + r.tl.x+=x1; + r.br.x=r.tl.x+x2-x1; + gFillPattern(&r,WS_BITMAP_GREY,G_TRMODE_REPL); + exit: + if (createGC) + { + gFreeTempGC(); + wFlush(); + } + } + +LOCAL_C VOID DrawButton(PR_RECBUT *self,INT state) + { + wDrawButton2(W_BUTTON_TYPE_2,&self->recbut.rect,&self->recbut.inlabel[0],state); + } + +LOCAL_C VOID PrintHeader(PR_RECCLI *self,INT y,TEXT *fmt,...) + { + INT len; + TEXT bb[256]; + P_RECT rect; + + rect.tl.x=8; + rect.tl.y=y; + rect.br.x=rect.tl.x+self->reccli.width-16; + rect.br.y=y+30; + if (fmt==NULL) + { + gClrRect(&rect,G_TRMODE_CLR); + return; + } + len=p_atob(&bb[0],fmt,&fmt+1); + gPrintBoxText(&rect,20,G_TEXT_ALIGN_CENTRE,0,&bb[0],len); + } + +LOCAL_C VOID HideButtons(PR_RECCLI *self,INT mask) +/* +Set the hidden state of the buttons to hide depending on the bits in mask. +*/ + { + INT i; + + for (i=0;i>=1) + self->reccli.recbut[i]->recbut.hide=(mask&1)?recbut_hide[i]:RECBUT_HIDE_DRAW; + } + +LOCAL_C VOID DrawWin(PR_RECCLI *self) + { + G_GC gc; + + gc.flags=G_GC_FLAG_BOTH_PLANES; + gCreateTempGC(self->win.id,G_GC_MASK_GREY,&gc); + p_send2(self,O_WN_DRAW); + gFreeTempGC(); + } + +LOCAL_C VOID PrintDuration(PR_RECCLI *self,TEXT *buf,ULONG tenths) + { + ULONG seconds; + UINT secs; + P_DAYSEC ds; + P_DATE dt; + + seconds=tenths/10; + if (seconds<60) + { + secs=(UINT)seconds; + p_atos(buf,"%d.%d %s",secs,(UINT)tenths-10*secs,self->reccli.secs); + return; + } + p_sttods(&seconds,&ds); + p_dstodt(&ds,&dt); + ds.day-=25567; /* base days at Jan 1 1970 */ + if (ds.day>0) + { /* show number of days */ + p_atos(buf,"%ld ",ds.day); + buf+=p_slen(buf); + } + if (dt.hour>0 || ds.day>0) + { /* show number of hours */ + p_atos(buf,"%02d%c",dt.hour,self->reccli.tsep); + buf+=p_slen(buf); + } + p_atos(buf,"%02d%c%02d",dt.minute,self->reccli.tsep,dt.second); + } + +#pragma METHOD_CALL + +METHOD VOID timebar_tb_draw(PR_TIMEBAR *self) + { + self->timebar.x=0; + DrawBar(self,TRUE,FALSE); + } + +METHOD VOID timebar_ao_init(PR_TIMEBAR *self,INT wid,P_RECT *prect) + { + self->active.priority=PRIORITY_ACTIVE_REPEATER; + p_send3(w_am,O_AM_ADD_TASK,self); + self->timebar.wid=wid; + self->timebar.rect=*prect; + } + +METHOD VOID timebar_ao_queue(PR_TIMEBAR *self) + { + p_ioc3(self->active.pcb,P_FREAD,&self->active.stat); + self->active.isactive=TRUE; + } + +METHOD INT timebar_ao_run(PR_TIMEBAR *self) + { + if (self->active.stat<0) + { /* possibly because the machine was switched off then on */ + StartFRC(self); /* restart the FRC */ + self->active.stat=0; + } + self->timebar.tenths-=self->active.stat; + if (self->timebar.tenths<=0) + { + self->timebar.tenths=0; /* stops re-queue */ + p_close(self->active.pcb); + self->active.pcb=NULL; + } + DrawBar(self,FALSE,TRUE); + if (self->timebar.tenths) + timebar_ao_queue(self); + return(RUN_ACTIVE_USED); + } + +METHOD VOID timebar_tb_start(PR_TIMEBAR *self,ULONG *tenths) + { + self->timebar.tenths0=*tenths; + self->timebar.tenths=self->timebar.tenths0; + self->timebar.x=0; + self->timebar.visible=TRUE; + if (self->timebar.tenths<10 || p_open(&self->active.pcb,"FRC:",-1)<0) + return; + StartFRC(self); + DrawBar(self,TRUE,TRUE); + timebar_ao_queue(self); + } + +METHOD VOID timebar_tb_stop(PR_TIMEBAR *self) + { + p_send2(self,O_AO_CANCEL); + self->timebar.visible=FALSE; + p_close(self->active.pcb); + self->active.pcb=NULL; + } + +METHOD VOID recbut_destroy(PR_RECBUT *self) + { + p_free(self->recbut.buttxt); + p_supersend2(self,O_DESTROY); + } + +METHOD VOID recbut_rb_init(PR_RECBUT *self,INT wid,P_POINT *pc,INT rid) + { + self->recbut.wid=wid; + self->recbut.rect.tl.x=pc->x-RECBUT_HALF_WIDTH; + self->recbut.rect.br.x=pc->x+RECBUT_HALF_WIDTH; + self->recbut.rect.tl.y=pc->y-RECBUT_HALF_HEIGHT; + self->recbut.rect.br.y=pc->y+RECBUT_HALF_HEIGHT; + hLoadResource(rid,&self->recbut.buttxt); + self->recbut.inlabel=(TEXT *)(((WORD *)self->recbut.buttxt)+1); + self->recbut.caption=NextZTS(self->recbut.inlabel); + self->recbut.caplen=p_slen(self->recbut.caption); + } + +METHOD VOID recbut_rb_draw(PR_RECBUT *self) + { + P_RECT r; + + if (self->recbut.hide==RECBUT_HIDE_HIDE) + return; + r.tl.x=self->recbut.rect.tl.x-RECBUT_MARGIN; + r.br.x=self->recbut.rect.br.x+RECBUT_MARGIN; + r.br.y=self->recbut.rect.tl.y; + r.tl.y=r.br.y-(2*RECBUT_HALF_HEIGHT); + if (self->recbut.hide==RECBUT_HIDE_CLEAR) + { + gClrRect(&r,G_TRMODE_CLR); + gClrRect(&self->recbut.rect,G_TRMODE_CLR); + return; + } + DrawButton(self,0); + gPrintBoxText(&r,RECBUT_ASCENT,G_TEXT_ALIGN_CENTRE,0,self->recbut.caption,self->recbut.caplen); + } + +METHOD VOID recbut_rb_depress(PR_RECBUT *self) + { + gCreateTempGC0(self->recbut.wid); + DrawButton(self,2); + wFlush(); + p_sleep(2L); + DrawButton(self,0); + wFlush(); + gFreeTempGC(); + } + +METHOD VOID recbut_rb_hide(PR_RECBUT *self,INT hide) + { + self->recbut.hide=hide; + } + +METHOD VOID reccli_destroy(PR_RECCLI *self) + { + p_free(self->reccli.clitxt); + p_supersend2(self,O_DESTROY); + } + +METHOD VOID reccli_wn_connect(PR_RECCLI *self,PR_WIN *par,UINT fields,W_WINDATA *pwd) + { + INT i,dx; + P_POINT c; + P_RECT rect; + E_CONFIG config; + + p_getctd(&config); + self->reccli.tsep=config.timeSeparator; + self->reccli.width=pwd->extent.width; + pwd->background=W_WIN_BACK_CLR|W_WIN_BACK_GREY_CLR; + p_supersend5(self,O_WN_CONNECT,par,fields|W_WIN_BACKGROUND,pwd); + hInitVis(self); + p_send3(self,O_WN_EMPHASISE,TRUE); + rect.tl.x=12; + rect.br.x=self->reccli.width-rect.tl.x; + rect.tl.y=74; + rect.br.y=rect.tl.y+TIMEBAR_HEIGHT; + self->reccli.timebar=f_newsend(CAT_RECORD_RECORD,C_TIMEBAR,O_AO_INIT,self->win.id,&rect); + dx=(self->reccli.width-6)/6; + c.y=130; + for (i=0;ireccli.recbut[i]=f_newsend(CAT_RECORD_RECORD,C_RECBUT,O_RB_INIT,self->win.id,&c,CLIBUT_REC_NEW+i); + } + HideButtons(self,RECCLI_STOP_MASK|RECCLI_START_MASK); + hLoadResource(RECCLI_TEXT,&self->reccli.clitxt); + self->reccli.secs=(TEXT *)(((WORD *)self->reccli.clitxt)+1); + self->reccli.title=NextZTS(self->reccli.secs); + self->reccli.sub=NextZTS(self->reccli.title); + wValidateWin(self->win.id); /* saves screen flicker on startup */ + } + +METHOD VOID reccli_wn_draw(PR_RECCLI *self) + { + INT i,len,y; + WVEFILE_INFO info; + TEXT name[16]; + TEXT duration[20],total[20]; + G_GC gc; + + p_supersend(self,O_WN_DRAW); /* draw border */ + p_send2(self->reccli.timebar,O_TB_DRAW); /* draw time bar */ + /* draw buttons */ + for (i=0;ireccli.recbut[i++])); + p_send3(receng,O_ENG_FILE_INFO,&info); + *p_bcpy(&name[0],info.name,len=info.nmlen)=0; + p_scap(&name[0]); + if (*info.device!='M') + { + name[len++]='['; + name[len++]=*info.device; + name[len++]=']'; + } + name[len]=0; + gc.style=G_STY_BOLD; + gc.font=FONT_ID_SWISS_16; + gSetGC(0,G_GC_MASK_STYLE|G_GC_MASK_FONT,&gc); + y=8; + if (info.duration) + { + PrintDuration(self,&duration[0],(LONG)info.duration); + /* %s %s %d Kbyte */ + PrintHeader(self,y,self->reccli.title,&name[0],&duration[0],(INT)(info.flen>>10)); + } + else + PrintHeader(self,y,"%s",&name[0]); /* might be a % character in name[] */ + y=40; + if (info.repeats<=1 && info.silence==0) + { + PrintHeader(self,y,NULL); /* clear rectangle */ + return; + } + gc.style=G_STY_NORMAL; + gc.font=FONT_ID_SWISS_13; + gSetGC(0,G_GC_MASK_STYLE|G_GC_MASK_FONT,&gc); + PrintDuration(self,&duration[0],(LONG)info.silence); + PrintDuration(self,&total[0],info.total); + /* Repeats: %d Trailing silence: %s Total: %s */ + PrintHeader(self,y,self->reccli.sub,info.repeats,&duration[0],&total[0]); + } + +METHOD VOID reccli_cl_update(PR_RECCLI *self) + { + p_send2(self->reccli.timebar,O_TB_STOP); + self->reccli.running=FALSE; + w_ws->wserv.filter=NULL; + wDisableKeyClick(FALSE); + HideButtons(self,RECCLI_STOP_MASK|RECCLI_START_MASK); + DrawWin(self); + wFlush(); + } + +METHOD VOID reccli_wn_key(PR_RECCLI *self,UINT keycode,UINT modifiers) + { + switch (keycode) + { + case W_KEY_TAB: + recbut_rb_depress(self->reccli.recbut[0]); + hWservComSend(O_COM_RECORD_NEW); + break; + case ' ': + recbut_rb_depress(self->reccli.recbut[1]); + hWservComSend(O_COM_RE_RECORD); + break; + case W_KEY_RETURN: + recbut_rb_depress(self->reccli.recbut[2]); + p_send2(receng,O_ENG_SOUND_PLAY); + break; + } + } + +METHOD INT reccli_cl_sound_filter(PR_RECCLI *self,UINT keycode,UINT modifiers) + { + if (keycode==W_KEY_ESCAPE) + { + p_send2(receng,O_ENG_SOUND_STOP); + recbut_rb_depress(self->reccli.recbut[3]); + } + return(WN_KEY_CHANGED); + } + +METHOD INT reccli_cl_pause_filter(PR_RECCLI *self,UINT keycode,UINT modifiers) +/* +Waiting to record. +*/ + { + if (keycode==W_KEY_ESCAPE) + p_send3(receng,O_ENG_OPEN_FILE,NULL); + else if (keycode==' ') + { + w_ws->wserv.filter=NULL; + p_send3(receng,O_ENG_SOUND_RECORD,self->reccli.duration); + } + return(WN_KEY_CHANGED); + } + +METHOD VOID reccli_cl_begin_sound(PR_RECCLI *self,ULONG *tenths) + { + p_send3(self->reccli.timebar,O_TB_START,tenths); + self->reccli.running=TRUE; + w_ws->wserv.filter=(PR_WIN *)self; + w_ws->wserv.filmethod=-O_CL_SOUND_FILTER; + wDisableKeyClick(TRUE); + HideButtons(self,RECCLI_3BUT_MASK|RECCLI_START_MASK); + DrawWin(self); + wFlush(); + } + +METHOD VOID reccli_cl_pause(PR_RECCLI *self,UINT duration) + { + self->reccli.duration=duration; + w_ws->wserv.filter=(PR_WIN *)self; + w_ws->wserv.filmethod=-O_CL_PAUSE_FILTER; + HideButtons(self,RECCLI_3BUT_MASK|RECCLI_STOP_MASK); + DrawWin(self); + wFlush(); + } + +METHOD VOID recman_am_clean_up(PR_RECMAN *self,INT err,UBYTE *htask) + { + PR_RECCLI *cli; + + cli=(PR_RECCLI *)w_ws->wserv.cli; + w_ws->wserv.filter=NULL; + wDisableKeyClick(FALSE); + p_send2(cli->reccli.timebar,O_TB_STOP); + p_supersend4(self,O_AM_CLEAN_UP,err,htask); + p_send3(receng,O_ENG_OPEN_FILE,NULL); + } diff --git a/code/SIBOSDK/record/reccom.c b/code/SIBOSDK/record/reccom.c new file mode 100644 index 0000000..121f084 --- /dev/null +++ b/code/SIBOSDK/record/reccom.c @@ -0,0 +1,151 @@ +/* +RECCOM.C + +Sound record/playback application command manager +*/ + +#include +#include +#include +#include + +GLREF_D PR_RECENG * const receng; +GLREF_D TEXT * const DatUsedPathNamePtr; + +LOCAL_C INT LaunchDial(VOID *buf,INT id,INT class) + { + DL_DATA dial_data; + + dial_data.id=id; + dial_data.rbuf=buf; + dial_data.pdlg=NULL; + return(hLaunchDial(CAT_RECORD_RECORD,class,&dial_data)); + } + +LOCAL_C VOID RecordToNewFile(TEXT *fname,INT DefaultName) + { + INT len; + P_FPARSE crk; + RECRBUF rb; + + rb.duration=((RECENG_PREFS *)p_send2(receng,O_ENG_SENSE_PREFS))->duration; + f_fparse(fname,DatUsedPathNamePtr,&rb.fname[0],&crk); + len=crk.system+crk.device+crk.path; + if (DefaultName) + len+=crk.name; + rb.fname[len]=0; + if (!LaunchDial(&rb,RECORD_NEW_DL,DefaultName?C_RECNEWDEF:C_RECNEW)) + p_send3(receng,O_ENG_OPEN_FILE,NULL); + } + +#pragma METHOD_CALL + +METHOD INT reccom_com_file_change(PR_RECCOM *self,INT command,TEXT *newname) + { + p_send2(receng,O_ENG_SOUND_STOP); + switch (command) + { + case H_COMMAND_CREATE_FILE: + p_send3(receng,O_ENG_NEW_FILE,newname); + p_send2(receng,O_ENG_VIEW_UPDATE); + RecordToNewFile((TEXT *)p_send2(receng,O_ENG_SENSE_FILE),TRUE); + break; + case H_COMMAND_OPEN_FILE: + p_send3(receng,O_ENG_OPEN_FILE,newname); + break; + } + return(0); /* no leave() */ + } + + +METHOD VOID reccom_com_new_file(PR_RECCOM *self) +/* +Called on selecting the New file menu command. +*/ + { + TEXT fspec[4]; + + fspec[0]=p_send2(receng,O_ENG_DEFAULT_DISK); + fspec[1]=':'; + fspec[2]=0; + RecordToNewFile(&fspec[0],FALSE); + } + +METHOD VOID reccom_com_record_new(PR_RECCOM *self) +/* +Called on pressing the Record new (Tab) button. +*/ + { + INT i,device; + P_INFO info; + TEXT name[32]; + TEXT fspec[P_FNAMESIZE]; + + device=p_send2(receng,O_ENG_DEFAULT_DISK); + for (i=1;i<100;i++) + { + hAtos(&name[0],DFLT_FNAME,device,i); /* "%c:RECORD%02d" */ + p_fparse(&name[0],DatUsedPathNamePtr,&fspec[0],NULL); + if (p_finfo(&fspec[0],&info)) + { /* file does not exist - so use the generated name */ + RecordToNewFile(&fspec[0],TRUE); + return; + } + } + RecordToNewFile("",FALSE); + } + +METHOD VOID reccom_com_open_file(PR_RECCOM *self) +/* +Called on selecting the Open file menu command. +*/ + { + RECRBUF rb; + + p_scpy(&rb.fname[0],(TEXT *)p_send2(receng,O_ENG_SENSE_FILE)); + if (!LaunchDial(&rb,OPEN_FILE_DL,C_RECOPEN)) + return; + /* rb.fname[] contains file name */ + p_send3(receng,O_ENG_OPEN_FILE,&rb.fname); + } + +METHOD VOID reccom_com_re_record(PR_RECCOM *self) +/* +Called on pressing the Record over (Space) button. +*/ + { + TEXT *fname; + WVEFILE_INFO info; + P_INFO finfo; + RECRBUF rb; + + p_send3(receng,O_ENG_FILE_INFO,&info); + fname=(TEXT *)p_send2(receng,O_ENG_SENSE_FILE); + if (!info.duration) + { /* file does not exist? */ + if (p_finfo(fname,&finfo)<0) + RecordToNewFile(fname,TRUE); + return; + } + rb.duration=info.duration; + p_scpy(&rb.fname[0],fname); + if (!LaunchDial(&rb,RE_RECORD_DL,C_RECEXIST)) + return; + } + +METHOD VOID reccom_com_set_repeat(PR_RECCOM *self) + { + LaunchDial(NULL,SET_REP_DL,C_SETREP); + } + +METHOD VOID reccom_com_rep_alarm(PR_RECCOM *self) + { + if (!hConfirm(ADJUST_ALARM_CONFIRM)) + return; + p_send4(receng,O_ENG_SET_REPEATS,0,150); /* set total time to 15 seconds */ + } + +METHOD VOID reccom_com_preferences(PR_RECCOM *self) + { + LaunchDial(NULL,PREFERENCES_DL,C_SETPREF); + } diff --git a/code/SIBOSDK/record/recdial.c b/code/SIBOSDK/record/recdial.c new file mode 100644 index 0000000..ef42975 --- /dev/null +++ b/code/SIBOSDK/record/recdial.c @@ -0,0 +1,190 @@ +/* +RECDIAL.C + +Sound record/playback command dialogs +*/ + +#include +#include +#include +#include +#include + +GLREF_D PR_RECENG * const receng; +GLREF_D PR_RECWSERV * const w_ws; + +LOCAL_C VOID TenthsToDouble(DOUBLE *pdbl,UINT tenths) +/* +Convert 10ths of a second to a double float. +*/ + { + WORD ten,x; + DOUBLE c; + + x=tenths; + p_itof(pdbl,&x); + ten=10; + p_itof(&c,&ten); + p_fdiv(pdbl,&c); + } + +LOCAL_C INT DoubleToTenths(DOUBLE *pdbl) +/* +Convert a double float to 10ths of a second. +*/ + { + WORD x; + DOUBLE c; + + x=10; + p_itof(&c,&x); + p_fmul(&c,pdbl); + p_inti(&x,&c); + return(x); + } + +LOCAL_C VOID SetTenthsFledit(INT item,UINT val) + { + DOUBLE dbl; + + TenthsToDouble(&dbl,val); + hDlgSetFledit(item,&dbl); + } + +LOCAL_C INT SenseTenthsFledit(INT item) + { + DOUBLE dbl; + + hDlgSenseFledit(item,&dbl); + return(DoubleToTenths(&dbl)); + } + +#pragma METHOD_CALL + +METHOD VOID setrep_dl_dyn_init(PR_SETREP *self) +/* +Dialog for setting repeat count and trailing silence. +*/ + { + WVEFILE_INFO info; + + p_send3(receng,O_ENG_FILE_INFO,&info); + hDlgSetNcedit(1,info.repeats); + SetTenthsFledit(2,info.silence); + } + +METHOD INT setrep_dl_key(PR_SETREP *self,INT index,INT keycode) +/* +Dialog for setting repeat count and trailing silence. +*/ + { + UINT repeats,silence; + + repeats=hDlgSenseNcedit(1); + silence=SenseTenthsFledit(2); + p_send4(receng,O_ENG_SET_REPEATS,repeats,silence); + return(WN_KEY_CHANGED); + } + +METHOD VOID setpref_dl_dyn_init(PR_SETPREF *self) +/* +Dialog for setting record/playback preferences. +*/ + { + RECENG_PREFS *pprefs; + + pprefs=(RECENG_PREFS *)p_send2(receng,O_ENG_SENSE_PREFS); + hDlgSetChlist(1,pprefs->volume); + SetTenthsFledit(2,pprefs->duration); + hDlgSetChlist(3,pprefs->disk); + } + +METHOD INT setpref_dl_key(PR_SETPREF *self,INT index,INT keycode) +/* +Dialog for setting record/playback preferences. +*/ + { + RECENG_PREFS prefs; + + prefs.volume=hDlgSenseChlist(1); + prefs.disk=hDlgSenseChlist(3); + prefs.duration=SenseTenthsFledit(2); + p_send3(receng,O_ENG_SET_PREFS,&prefs); + return(WN_KEY_CHANGED); + } + +METHOD VOID recnew_dl_dyn_init(PR_RECNEW *self) +/* +The dialog for recording to a new file. +*/ + { + RECRBUF *prb; + + prb=(RECRBUF *)self->dlgbox.rbuf; + if (prb->fname[0]) + hDlgSet(1,&prb->fname[0]); + SetTenthsFledit(3,prb->duration); + } + +METHOD VOID recnewdef_dl_set_size(PR_RECNEWDEF *self) + { + p_supersend2(self,O_DL_SET_SIZE); + hDlgTakeFocus(3); + } + +METHOD INT recnew_dl_key(PR_RECNEW *self,INT index,INT keycode) +/* +All dialogs for recording to a new or existing file share this code. +*/ + { + RECRBUF *prb; + INT MaxDuration; + + prb=(RECRBUF *)self->dlgbox.rbuf; + hDlgSense(1,&prb->fname[0]); + prb->duration=SenseTenthsFledit(3); + MaxDuration=p_send3(receng,O_ENG_NEW_FILE,&prb->fname[0]); + if (MaxDuration<0) + { + if (MaxDuration==E_FILE_VOLUME) + hInfoPrint(NO_RECORD_FLASH); + else + hInfoPrintErr(MaxDuration); + return(WN_KEY_NO_CHANGE); + } + if (prb->duration/10>MaxDuration) + { + SetTenthsFledit(3,10*MaxDuration); + hInfoPrint(NO_SPACE_RESET); + return(WN_KEY_NO_CHANGE); + } + p_send3(w_ws->wserv.cli,O_CL_PAUSE,prb->duration); + return(WN_KEY_CHANGED); + } + +METHOD VOID recexist_dl_dyn_init(PR_RECEXIST *self) +/* +The dialog for recording to an existing file. +*/ + { + hDlgSet(1,&((RECRBUF *)self->dlgbox.rbuf)->fname[0]); + p_supersend2(self,O_DL_DYN_INIT); + } + +METHOD VOID recexist_dl_set_size(PR_RECEXIST *self) +/* +The dialog for recording to an existing file. +*/ + { + p_supersend2(self,O_DL_SET_SIZE); + hDlgTakeFocus(3); + } + +METHOD INT recopen_dl_key(PR_RECOPEN *self,INT index,INT keycode) +/* +The dialog for opening a file. +*/ + { + hDlgSense(1,&((RECRBUF *)self->dlgbox.rbuf)->fname[0]); + return(WN_KEY_CHANGED); + } diff --git a/code/SIBOSDK/record/receng.c b/code/SIBOSDK/record/receng.c new file mode 100644 index 0000000..d6a5a32 --- /dev/null +++ b/code/SIBOSDK/record/receng.c @@ -0,0 +1,202 @@ +/* +RECENG.C + +Sound record/playback application engine +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RECENG_ENVNAME "REC$PREF" +#define RECENG_ENVNAMELEN 8 + +GLREF_D PR_HWIMMAN * const w_am; + +LOCAL_C UINT ConvDurationTo2Ks(UINT tenths) +/* +Convert 10ths of a second to 2Kbyte units +*/ + { + return((tenths*25+0x3f)>>6); + } + +LOCAL_C INT IsDeviceSuitable(INT device) + { + P_DINFO dinfo; + TEXT dspec[16]; + + if (device!='M') + { + p_scpy(&dspec[0],"LOC::M:"); + dspec[P_FSYSNAMESIZE]=device; + p_dinfo(&dspec[0],&dinfo); + return((dinfo.mediatype&0xff)==P_FMEDIA_RAM); + } + return(TRUE); + } + +LOCAL_C INT DiskToDevice(INT disk) + { + if (disk==0) + return('A'); + if (disk==1) + return('M'); + if (disk==2) + return('B'); + } + +LOCAL_C VOID CheckSoundCompletion(INT stat) + { + if (stat==E_GEN_FAIL) + hInfoPrint(-SYS_SOUND_DISABLED); + else + f_leave(stat); + } + +#pragma METHOD_CALL + +METHOD VOID receng_eng_init(PR_RECENG *self,PR_ROOT *hview,UINT mupdate,UINT msound) + { + self->receng.prefs.duration=20; /* two seconds */ + self->receng.prefs.disk=1; /* Internal (M:) */ + self->receng.hview=hview; + self->receng.mupdate=mupdate; + self->receng.msound=msound; + self->receng.wvefile=f_new(CAT_RECORD_RECORD,C_WVEFILE); + self->receng.waveao=f_newsend(CAT_RECORD_RECORD,C_WAVEAO,O_AO_INIT,self,O_ENG_DONE_RECORD,O_ENG_DONE_PLAY); + } + +METHOD TEXT *receng_eng_sense_file(PR_RECENG *self) + { + return((TEXT *)p_send2(self->receng.wvefile,O_WVE_SENSE_FNAME)); + } + +METHOD INT receng_eng_default_disk(PR_RECENG *self) +/* +Returns the default device letter for new recordings. +Based on the "dialog" local disk number (0:A, 1:M, 2:B). +Guaranteed to return a suitable disk. +*/ + { + INT device; + TEXT fspec[P_FNAMESIZE]; + + p_send2(self,O_ENG_SENSE_PREFS); + device=DiskToDevice(self->receng.prefs.disk); /* try user-specified preference first */ + if (!IsDeviceSuitable(device)) + { /* preference is unsuitable */ + device='M'; /* fallback if the default device is unsuitable */ + p_getpth(&fspec[0]); + if (IsDeviceSuitable(fspec[P_FSYSNAMESIZE])) + device=fspec[P_FSYSNAMESIZE]; + } + return(device); + } + +METHOD VOID receng_eng_view_update(PR_RECENG *self) + { + p_send2(self->receng.hview,self->receng.mupdate); + } + +METHOD INT receng_eng_new_file(PR_RECENG *self,TEXT *pname) + { + return(p_send3(self->receng.wvefile,O_WVE_NEW,pname)); + } + +METHOD VOID receng_eng_open_file(PR_RECENG *self,TEXT *pname) + { + p_send3(self->receng.wvefile,O_WVE_OPEN,pname); + p_send3(w_am,O_AM_NEW_FILENAME,receng_eng_sense_file(self)); + receng_eng_view_update(self); + } + +METHOD VOID receng_eng_done_record(PR_RECENG *self,INT stat) + { + CheckSoundCompletion(stat); + receng_eng_open_file(self,NULL); + } + +METHOD VOID receng_eng_done_play(PR_RECENG *self,INT stat) + { + CheckSoundCompletion(stat); + receng_eng_view_update(self); + } + +METHOD VOID receng_eng_sound_play(PR_RECENG *self) + { + INT v; + WVEFILE_INFO info; + + p_send2(self,O_ENG_SENSE_PREFS); + v=0; /* loud */ + if (self->receng.prefs.volume==1) + v=2; /* medium */ + else if (self->receng.prefs.volume==2) + v=5; /* quiet */ + p_send3(self->receng.wvefile,O_WVE_SENSE_INFO,&info); + if (info.duration==0) + { + hInfoPrint(NO_DATA_NO_PLAY); + return; + } + p_send4(self->receng.waveao,O_WV_PLAY,p_send2(self->receng.wvefile,O_WVE_SENSE_FNAME),v); + p_send3(self->receng.hview,self->receng.msound,&info.total); + } + +METHOD VOID receng_eng_sound_record(PR_RECENG *self,UINT duration) + { + UINT num2Ks; + ULONG tenths; + TEXT *name; + + num2Ks=ConvDurationTo2Ks(duration); + tenths=num2Ks; + tenths=(tenths<<6)/25; + name=(TEXT *)p_send2(self->receng.wvefile,O_WVE_SENSE_FNAME); + if (name[P_FSYSNAMESIZE]=='M') + p_delete(name); /* free space for the sound server */ + p_send4(self->receng.waveao,O_WV_RECORD,name,num2Ks); + p_send3(self->receng.hview,self->receng.msound,&tenths); + } + +METHOD VOID receng_eng_sound_stop(PR_RECENG *self) + { + p_send2(self->receng.waveao,O_WV_STOP); + } + +METHOD VOID receng_eng_set_repeats(PR_RECENG *self,UINT repeats,UINT tenths) + { + p_send4(self->receng.wvefile,O_WVE_SET_REPEATS,repeats,tenths); + receng_eng_view_update(self); + } + +METHOD VOID receng_eng_file_info(PR_RECENG *self,WVEFILE_INFO *pi) + { + p_send3(self->receng.wvefile,O_WVE_SENSE_INFO,pi); + } + +METHOD RECENG_PREFS *receng_eng_sense_prefs(PR_RECENG *self) + { + INT len; + TEXT bb[P_ENVMAX]; + + len=p_getenviron(RECENG_ENVNAME,RECENG_ENVNAMELEN,&bb[0]); + if (len==sizeof(RECENG_PREFS)) + self->receng.prefs=*(RECENG_PREFS *)&bb[0]; + return(&self->receng.prefs); + } + +METHOD VOID receng_eng_set_prefs(PR_RECENG *self,RECENG_PREFS *new) + { + if (!p_bcmp(&self->receng.prefs,sizeof(RECENG_PREFS),new,sizeof(RECENG_PREFS))) + return; /* no change */ + self->receng.prefs=*new; + f_leave(p_setenviron(RECENG_ENVNAME,RECENG_ENVNAMELEN,&self->receng.prefs,sizeof(RECENG_PREFS))); + } diff --git a/code/SIBOSDK/record/record.afl b/code/SIBOSDK/record/record.afl new file mode 100644 index 0000000..979d1fb --- /dev/null +++ b/code/SIBOSDK/record/record.afl @@ -0,0 +1,3 @@ +record.pic +record.rzc +record.shd diff --git a/code/SIBOSDK/record/record.cat b/code/SIBOSDK/record/record.cat new file mode 100644 index 0000000..130136d --- /dev/null +++ b/code/SIBOSDK/record/record.cat @@ -0,0 +1,244 @@ +IMAGE record + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE p_std.h +INCLUDE p_gen.h +INCLUDE p_que.h +INCLUDE p_object.h +INCLUDE p_file.h +INCLUDE epoc.h +INCLUDE wlib.h +INCLUDE olib.g +INCLUDE varray.g +INCLUDE appman.g +INCLUDE timer.g +INCLUDE bwin.g +INCLUDE matcher.g +INCLUDE listbox.g +INCLUDE pulldown.g +INCLUDE hwimman.g + +CLASS waveao active +Sound file record and play + { + REPLACE ao_init Queue into appman and init callback + REPLACE ao_run Call back + REPLACE ao_cancel Cancel sound + ADD wv_record Start recording a file + ADD wv_play Start playing a file + ADD wv_stop Start playing/recording a file + PROPERTY + { + WORD request; Request type + PR_ROOT *hdone; Callback handle on completion + UWORD done_record; Callback method on record completion + UWORD done_play; Callback method on playback completion + } + } + +CLASS wvefile root +Sound file + { + ADD wve_new Create a new file + ADD wve_open Open an existing file + ADD wve_sense_fname Sense the file name (for reading) + ADD wve_sense_info Fill in a WVEFILE_INFO struct + ADD wve_set_repeats Set the repeat and silence + TYPES + { + typedef struct + { + TEXT *device; address of device character + TEXT *name; file name component + WORD ret; possible error return + WORD nmlen; length of file name + UWORD duration; duration in 10ths of a sec + UWORD silence; silence in 10ths of a second + UWORD repeats; number of repeats + ULONG total; total time in seconds (with repeats & silence) + ULONG samples; number of samples + ULONG flen; file length + } WVEFILE_INFO; + } + PROPERTY + { + VOID *fcb; + WORD ret; + P_FPARSE crk; + TEXT fname[P_FNAMESIZE]; + P_INFO info; + SndFile head; + } + } + +CLASS receng root + { + ADD eng_init + ADD eng_new_file Start a new file + ADD eng_open_file Open an existing file (close any current file) + ADD eng_sense_file Get the current file name + ADD eng_file_info Get information on the current file + ADD eng_default_disk Return default device for new file + ADD eng_view_update Call back view to update itself + ADD eng_done_record Callback from active object on record completion + ADD eng_done_play Callback from active object on play completion + ADD eng_sound_play Play the current file + ADD eng_sound_record Record to the current file + ADD eng_sound_stop Stop the current record or playback + ADD eng_set_repeats Set the number of repeats and trailing silence + ADD eng_set_prefs Set the persistent preferences + ADD eng_sense_prefs Sense the persistent preferences + TYPES + { + typedef struct + { + WORD volume; volume for playback + WORD duration; maximum duration in 10ths of a sec + WORD disk; preferred disk for new files + } RECENG_PREFS; + } + PROPERTY 2 + { + PR_WVEFILE *wvefile; digital sound file + PR_WAVEAO *waveao; record/play active object + PR_ROOT *hview; callback view handle + UWORD mupdate; callback view method for update + UWORD msound; callback view method for begin sound + RECENG_PREFS prefs; persistent preferences + } + } + +CLASS reccom comman + { + REPLACE com_file_change from System application + ADD com_set_repeat Set repeat menu command + ADD com_rep_alarm Repeat for alarm menu command + ADD com_preferences Set preferences menu command + ADD com_new_file New file menu command + ADD com_open_file Open file menu command + ADD com_record_new Record new (Tab) button + ADD com_re_record Record over (Space) button + TYPES + { + typedef struct + { + WORD duration; + TEXT fname[P_FNAMESIZE]; + } RECRBUF; + } + } + +CLASS recman hwimman + { + REPLACE am_clean_up + } + +CLASS recwserv wserv + { + REPLACE ws_dyn_init + } + +CLASS timebar active + { + REPLACE ao_init Queue into appman and set priority + REPLACE ao_queue Queue next read + REPLACE ao_run Update on tick + ADD tb_start Start time bar + ADD tb_stop Stop time bar + ADD tb_draw For redraw + PROPERTY + { + WORD visible; Visible if TRUE + WORD wid; Window id of landlord + LONG tenths0; Initial value of timer + LONG tenths; Counted down value of timer + WORD x; Bar value in pixels + P_RECT rect; Bar rectangle + } + } + +CLASS recbut root + { + REPLACE destroy + ADD rb_init + ADD rb_draw + ADD rb_depress + ADD rb_hide + PROPERTY + { + WORD hide; Hide button if TRUE + WORD wid; Window id of landlord + P_RECT rect; Button rectangle + VOID *buttxt; As loaded from resource file + TEXT *inlabel; Button label + TEXT *caption; Caption above button + WORD caplen; Caption length + } + } + +CLASS reccli bwin + { + REPLACE destroy + REPLACE wn_connect + REPLACE wn_draw + REPLACE wn_key + ADD cl_update Viewed data has changed + ADD cl_sound_filter To catch keys while recording or playing + ADD cl_pause_filter To catch keys while waiting to record + ADD cl_begin_sound + ADD cl_pause + PROPERTY 6 + { + PR_TIMEBAR *timebar; + PR_RECBUT *recbut[5]; + UINT duration; Stored for pause to record + WORD running; TRUE if sound record/play running + WORD width; Window width + VOID *clitxt; Allocated resource + TEXT *secs; Seconds suffix + TEXT *title; Title format string + TEXT *sub; Subtitle format string + TEXT tsep; Time separator + UBYTE spare; + } + } + +CLASS setrep dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } + +CLASS setpref dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } + +CLASS recnew dlgbox +Record to new file dialog + { + REPLACE dl_dyn_init + REPLACE dl_key + } + +CLASS recnewdef recnew +Record to new file dialog with a default name + { + REPLACE dl_set_size + } + +CLASS recexist recnew +Record to existing file dialog + { + REPLACE dl_dyn_init + REPLACE dl_set_size + } + +CLASS recopen dlgbox +Open file dialog + { + REPLACE dl_key + } diff --git a/code/SIBOSDK/record/record.hlp b/code/SIBOSDK/record/record.hlp new file mode 100644 index 0000000..8bd4bf5 --- /dev/null +++ b/code/SIBOSDK/record/record.hlp @@ -0,0 +1,60 @@ +/* +RECORD.HLP + +Help file for Series 3a RECORD app +*/ + + + +RESOURCE HELP_ARRAY record_help +{ +topic="Record"; +topic_id=record_help_index; +} + +RESOURCE TOPIC_ARRAY record_help_index +{ +id_lst= +{ +record_alarms, +record_voice +}; +} + +RESOURCE HELP_ARRAY record_alarms +{ +topic="Recording alarm sounds"; +strlst= +{ +STRING {str="Use `New file' (or Tab) to start recording to a file";}, +STRING {str="Press Enter to play it back ";}, +STRING {str="To try again, use Space to record to the same file";}, +STRING {str="";}, +STRING {str="Esc stops recording or playback";}, +STRING {str="";}, +STRING {str="Sound files have a built-in "<34>"number of repeats"<34>" and length";}, +STRING {str="of silence between the repeats. Set these with `Set repeat'";}, +STRING {str="";}, +STRING {str="Sound files appear automatically in `Set alarm' dialogs";} +}; +} + +RESOURCE HELP_ARRAY record_voice +{ +topic="Recording voice notes"; +strlst= +{ +STRING {str="In the System screen, move to `Record' and use";}, +STRING {str="`Create new list' and change the `Directory for files'";}, +STRING {str="line. Then voice recordings will not appear in the";}, +STRING {str="`Set alarm' dialogs";}, +STRING {str="";}, +STRING {str="Use `Assign button' and make a button-press go";}, +STRING {str="to this list";}, +STRING {str="";}, +STRING {str="Use this button-press, then Tab, Enter and Space";}, +STRING {str="to record each new note";} +}; +} + + diff --git a/code/SIBOSDK/record/record.ms b/code/SIBOSDK/record/record.ms new file mode 100644 index 0000000..1807070 --- /dev/null +++ b/code/SIBOSDK/record/record.ms @@ -0,0 +1,3 @@ +Record.WVE +\WVE\ +1003 diff --git a/code/SIBOSDK/record/record.pic b/code/SIBOSDK/record/record.pic new file mode 100644 index 0000000..f9206fe Binary files /dev/null and b/code/SIBOSDK/record/record.pic differ diff --git a/code/SIBOSDK/record/record.pr b/code/SIBOSDK/record/record.pr new file mode 100644 index 0000000..1b3c5bf --- /dev/null +++ b/code/SIBOSDK/record/record.pr @@ -0,0 +1,46 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#set version=0x118F +#set priority=0x80 +#set heapsize=0x48 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort +#endif + +#if %main.rzc #older %main.rsg #then + #run "rch %main" no_window no_abort +#endif + +#compile reccli.c +#compile reccom.c +#compile recdial.c +#compile receng.c +#compile recwserv.c +#compile waveao.c +#compile wvefile.c + +#if %main.shd #older %main.ms #then + #run "makeshd %main" no_window no_abort + #file delete %main.img +#endif + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main diff --git a/code/SIBOSDK/record/record.re b/code/SIBOSDK/record/record.re new file mode 100644 index 0000000..518c107 --- /dev/null +++ b/code/SIBOSDK/record/record.re @@ -0,0 +1,9 @@ +#include + +_C_RECCOM +_O_COM_EXIT +_O_COM_SET_REPEAT +_O_COM_REP_ALARM +_O_COM_PREFERENCES +_O_COM_NEW_FILE +_O_COM_OPEN_FILE diff --git a/code/SIBOSDK/record/record.rss b/code/SIBOSDK/record/record.rss new file mode 100644 index 0000000..5177d7f --- /dev/null +++ b/code/SIBOSDK/record/record.rss @@ -0,0 +1,354 @@ +/* +RECORD.RSS + +Resource file for Sound recording Handheld Application +*/ + +#include +#include +#include + +RESOURCE WSERV_INFO record_accs + { + menbar_id=record_menu; + first_com=O_COM_EXIT; +/* follows order in cat file command manager */ + accel={'x', /* Exit */ + 'r', /* Set repeat */ + 'a', /* Repeat for alarm */ + 'q', /* Set preferences */ + 'n', /* New file */ + 'o' /* Open file */ + }; + } + +RESOURCE MENU_BAR record_menu + { + items = + { + MENU_BAR_ITEM + { + menu_id=file_menu; + mb_item="File"; + }, + MENU_BAR_ITEM + { + menu_id=repeats_menu; + mb_item="Repeats"; + }, + MENU_BAR_ITEM + { + menu_id=special_menu; + mb_item="Special"; + } + }; + } + +RESOURCE MENU file_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_NEW_FILE; + mn_item="New file"; + }, + MENU_ITEM + { + com_id=O_COM_OPEN_FILE; + mn_item="Open file"; + } + }; + } + +RESOURCE MENU repeats_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_SET_REPEAT; + mn_item="Set repeat"; + }, + MENU_ITEM + { + com_id=O_COM_REP_ALARM; + mn_item="Adjust for alarm"; + } + }; + } + +RESOURCE MENU special_menu + { + items = + { + MENU_ITEM + { + com_id=O_COM_PREFERENCES; + mn_item="Set preferences"; + }, + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +RESOURCE STRING dflt_fname { str="%c:RECORD%02d"; } + +RESOURCE STRING no_space_reset { str="Insufficient disk space - Maximum duration reset"; } + +RESOURCE STRING no_record_flash { str="Can't record to a Flash SSD"; } + +RESOURCE STRING no_data_no_play { str="No sound to play"; } + +RESOURCE STRING adjust_alarm_confirm { str="Adjust repeat for use as an alarm"; } + +/* DIALOG RESOURCES */ + +RESOURCE DIALOG set_rep_dl +/* Dialog used by the "Set repeat" menu item */ + { + title="Set repeat"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Repeat count"; + info=NCEDIT + { + low=1; + high=1000; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Trailing silence (sec)"; + info=FLTEDIT + { + low=0.0; + high=1000.0; + ndec=1; + }; + } + }; + } + +RESOURCE MENU volume_list + { + items= + { + CHOICE_ITEM {str="Loud";}, + CHOICE_ITEM {str="Medium";}, + CHOICE_ITEM {str="Quiet";} + }; + } + +RESOURCE MENU disk_list + { + items= + { + CHOICE_ITEM {str="A";}, + CHOICE_ITEM {str="Internal";}, + CHOICE_ITEM {str="B";} + }; + } + +RESOURCE DIALOG preferences_dl +/* Dialog used by the "Set preferences" menu item */ + { + title="Set preferences"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Playback volume"; + info=CHLIST{rid=volume_list;}; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Default duration (sec)"; + info=FLTEDIT + { + low=0.0; + high=3000.0; + ndec=1; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Default disk for new files"; + info=CHLIST{rid=disk_list;}; + } + }; + } + +RESOURCE DIALOG open_file_dl +/* Dialog used by the "Open file" menu item */ + { + title="Open file"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK; + class=C_FNSELWN; + prompt="File:"; + info=FNSELWN + { + flags=IN_FNSELWN_STANDARD; + fname=""; + }; + } + }; + } + +RESOURCE DIALOG record_new_dl +/* Dialog presented before recording to a new file */ + { + title="Record to new file"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK; + class=C_FNEDIT; + prompt="File:"; + info=FNEDIT + { + flags=IN_FNEDIT_STANDARD; + fname=""; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Maximum duration (sec)"; + info=FLTEDIT + { + low=0.0; + high=3000.0; + current=0.0; + ndec=1; + }; + } + }; + } + +RESOURCE DIALOG re_record_dl +/* Dialog presented before recording to an existing file */ + { + title="Record over existing file"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK; + class=C_FNSELWN; + prompt="File:"; + info=FNSELWN + { + flags=IN_FNSELWN_STANDARD; + fname=""; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Maximum duration (sec)"; + info=FLTEDIT + { + low=0.0; + high=3000.0; + current=0.0; + ndec=1; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="The data in the existing file will be replaced"; + }; + } + }; + } + +RESOURCE STRING_ARRAY reccli_text + { + strlst= + { + STRING { str="sec"; }, + STRING { str="%s %s %d Kbyte"; }, + STRING { str="Repeats: %d Trailing silence: %s Total: %s"; } + }; + } + +/* The order of the following 5 items must not be changed */ + +RESOURCE STRING_ARRAY clibut_rec_new +/* "Record new" button */ + { + strlst= + { + STRING {str="Tab";}, /* button text */ + STRING {str="Record new";} /* button label */ + }; + } + +RESOURCE STRING_ARRAY clibut_rec_over +/* "Record over" button */ + { + strlst= + { + STRING {str="Space";}, /* button text */ + STRING {str="Record over";} /* button label */ + }; + } + +RESOURCE STRING_ARRAY clibut_play +/* "Play" button */ + { + strlst= + { + STRING {str="Enter";}, /* button text */ + STRING {str="Play";} /* button label */ + }; + } + +RESOURCE STRING_ARRAY clibut_stop +/* "Stop" button */ + { + strlst= + { + STRING {str="Esc";}, /* button text */ + STRING {str="Stop";} /* button label */ + }; + } + +RESOURCE STRING_ARRAY clibut_start +/* "Start recording" button */ + { + strlst= + { + STRING {str="Space";}, /* button text */ + STRING {str="Start recording";} /* button label */ + }; + } + +#include "record.hlp" + diff --git a/code/SIBOSDK/record/recwserv.c b/code/SIBOSDK/record/recwserv.c new file mode 100644 index 0000000..8a54531 --- /dev/null +++ b/code/SIBOSDK/record/recwserv.c @@ -0,0 +1,55 @@ +/* + RECWSERV.C + +Wserv subclass for Sound record/playback application +*/ + +#include +#include +#include +#include +#include + +GLREF_D PR_HWIMMAN * const w_am; +GLREF_D UBYTE *DatCommandPtr; +GLREF_D UBYTE *DatUsedPathNamePtr; +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D PR_GATE *DatGate; + +GLDEF_D PR_RECENG *receng; + +#pragma METHOD_CALL + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV ws; + + p_linklib(0); + app.flags=FLG_APPMAN_FULLSCREEN|FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN| + FLG_APPMAN_SRSCFILE; + app.wserv_cat=ws.com_cat=p_getlibh(CAT_RECORD_RECORD); + app.wserv_class=C_RECWSERV; + ws.com_class=C_RECCOM; + p_send4(p_new(CAT_RECORD_RECORD,C_RECMAN),O_AM_INIT,&app,&ws); + } + +METHOD VOID recwserv_ws_dyn_init(PR_RECWSERV *self) + { + W_WINDATA wd; + + p_setpth("\\WVE\\"); + wd.extent.tl.x=0; + wd.extent.tl.y=0; + wd.extent.height=wserv_channel->conn.info.pixels.y; + wd.extent.width=wserv_channel->conn.info.pixels.x-DatGate->gate.x.bsww; + self->wserv.cli=f_newsend(CAT_RECORD_RECORD,C_RECCLI, + O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + wsSetList(W_STATUS_WINDOW_ICON,NULL,W_STATUS_WIN_NO_DIAMOND); + wStatusWindow(W_STATUS_WINDOW_BIG); + self->wserv.help_index_id=RECORD_HELP; + receng=f_newsend(CAT_RECORD_RECORD,C_RECENG,O_ENG_INIT,self->wserv.cli,O_CL_UPDATE,O_CL_BEGIN_SOUND); + p_send4(self->wserv.com,O_COM_FILE_CHANGE,w_am->hwimman.command, + DatUsedPathNamePtr); + } + diff --git a/code/SIBOSDK/record/vid.bat b/code/SIBOSDK/record/vid.bat new file mode 100644 index 0000000..4ccb4d5 --- /dev/null +++ b/code/SIBOSDK/record/vid.bat @@ -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 + diff --git a/code/SIBOSDK/record/waveao.c b/code/SIBOSDK/record/waveao.c new file mode 100644 index 0000000..93056cf --- /dev/null +++ b/code/SIBOSDK/record/waveao.c @@ -0,0 +1,64 @@ +/* +WAVEAO.C + +Active object to record and playback sound +*/ + +#include + +#define WAVEAO_REQUEST_RECORD 0 +#define WAVEAO_REQUEST_PLAY 1 + +GLREF_D PR_APPMAN * const w_am; + +#pragma METHOD_CALL + +METHOD VOID waveao_ao_init(PR_WAVEAO *self,PR_ROOT *hdone,UINT done_record,UINT done_play) + { + self->active.priority=PRIORITY_ACTIVE_VOICE; + p_send3(w_am,O_AM_ADD_TASK,self); + self->waveao.hdone=hdone; + self->waveao.done_record=done_record; + self->waveao.done_play=done_play; + } + +METHOD INT waveao_ao_run(PR_WAVEAO *self) + { + if (self->active.stat==E_FILE_CANCEL) + self->active.stat=0; + p_send3(self->waveao.hdone,(self->waveao.request==WAVEAO_REQUEST_RECORD)? + self->waveao.done_record:self->waveao.done_play,self->active.stat); + return(RUN_ACTIVE_USED); + } + +METHOD VOID waveao_ao_cancel(PR_WAVEAO *self) + { + p_playsoundcancel(); /* entirely equivalent to p_recordsoundcancel */ + p_supersend2(self,O_AO_CANCEL); + } + +METHOD VOID waveao_wv_play(PR_WAVEAO *self,TEXT *name,UINT volume) + { + if (!self->active.isactive) + { + p_playsounda(name,0,volume,&self->active.stat); + self->active.isactive=TRUE; + self->waveao.request=WAVEAO_REQUEST_PLAY; + } + } + +METHOD VOID waveao_wv_record(PR_WAVEAO *self,TEXT *name,UINT len) + { + if (!self->active.isactive) + { + p_recordsounda(name,len,&self->active.stat); + self->active.isactive=TRUE; + self->waveao.request=WAVEAO_REQUEST_RECORD; + } + } + +METHOD VOID waveao_wv_stop(PR_WAVEAO *self) + { + p_playsoundcancel(); /* entirely equivalent to p_recordsoundcancel */ + } + diff --git a/code/SIBOSDK/record/wvefile.c b/code/SIBOSDK/record/wvefile.c new file mode 100644 index 0000000..e9c8b47 --- /dev/null +++ b/code/SIBOSDK/record/wvefile.c @@ -0,0 +1,190 @@ +/* + WVEFILE.C + +Sound record/playback sound file +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +LOCAL_C ULONG SamplesToTenths(ULONG samples) + { + return((samples>>4)/50); + } + +LOCAL_C ULONG EffectiveSamples(ULONG samples) +/* +Converts the number of byte samples to the effective number of +samples for playback by rounding up to the nearest 0x800 (2K) +boundary and adding another 0x600. +*/ + { + return(((samples+0x7ff)&(~0x7ff))+0x600); + } + +LOCAL_C VOID CloseFile(PR_WVEFILE *self) + { + p_close(self->wvefile.fcb); + self->wvefile.fcb=NULL; + } + +LOCAL_C VOID StoreFileName(PR_WVEFILE *self,TEXT *fname) + { + CloseFile(self); + f_fparse(fname,NULL,&self->wvefile.fname[0],&self->wvefile.crk); + hEnsurePath(&self->wvefile.fname[0]); + } + +#pragma METHOD_CALL + + +METHOD INT wvefile_wve_new(PR_WVEFILE *self,TEXT *fname) +/* +Return the maximum duration in seconds consistent with the space on fspec +as a positive number. Otherwise return a negative error number. +*/ + { + UINT minfree; + INT SSDType; + P_DINFO dinfo; + + StoreFileName(self,fname); + p_dinfo(&self->wvefile.fname[0],&dinfo); + minfree=0x1000; /* need at least approx half a seconds worth of space */ + SSDType=dinfo.mediatype&0xff; + if (SSDType==P_FMEDIA_FLASH) + return(E_FILE_VOLUME); + if (SSDType==P_FMEDIA_ROM || SSDType==P_FMEDIA_WRITEPROTECTED) + return(E_FILE_PROTECT); + if (dinfo.mediatype&P_FMEDIA_INTERNAL) + minfree+=0x2800; /* since the sound server takes 0x2800 bytes to run */ + if (p_finfo(&self->wvefile.fname[0],&self->wvefile.info)>=0) + { + if (!(self->wvefile.info.status&P_FAWRITE)) + return(E_FILE_RDONLY); + dinfo.free+=self->wvefile.info.size; /* credit length of existing file */ + } + if (dinfo.freewvefile.ret=p_finfo(&self->wvefile.fname[0],&self->wvefile.info); + if (self->wvefile.ret<0) + return; + CloseFile(self); /* file can be open after an error in playback */ + self->wvefile.ret=p_open(&self->wvefile.fcb,&self->wvefile.fname[0],P_FSHARE); + if (self->wvefile.ret<0) + return; + self->wvefile.ret=p_read(self->wvefile.fcb,&self->wvefile.head,sizeof(SndFile)); + if (self->wvefile.ret<0) + { + close: + CloseFile(self); + return; + } + if (p_scmp(&self->wvefile.head.Signature[0],ALawSignature)) + { + self->wvefile.ret=E_FILE_INVALID; + goto close; + } + /* Wany "bootleg" files exist with incorrect Samples field */ + /* The sound system services work off the file length and not Samples */ + /* So we patch Samples here to the correct value */ + self->wvefile.head.Samples=self->wvefile.info.size-sizeof(SndFile); + if (self->wvefile.head.Repeats==0) + self->wvefile.head.Repeats=1; + } + +METHOD TEXT *wvefile_wve_sense_fname(PR_WVEFILE *self) + { + return(&self->wvefile.fname[0]); + } + +METHOD VOID wvefile_wve_sense_info(PR_WVEFILE *self,WVEFILE_INFO *pi) +/* +Write all kinds of information to *pi. +*/ + { + ULONG samples; + + p_bfil(pi,sizeof(WVEFILE_INFO),0); + pi->device=&self->wvefile.fname[self->wvefile.crk.system]; + pi->name=pi->device+self->wvefile.crk.device+self->wvefile.crk.path; + pi->nmlen=self->wvefile.crk.name; + if (self->wvefile.fcb==NULL) + return; + pi->duration=SamplesToTenths(self->wvefile.head.Samples); + pi->silence=(WORD)(((ULONG)self->wvefile.head.SilenceInTicks*5)>>4); + samples=EffectiveSamples(self->wvefile.head.Samples); + samples+=250*(ULONG)self->wvefile.head.SilenceInTicks; /* 250 samples per tick */ + if (self->wvefile.head.Repeats>1 && self->wvefile.head.SilenceInTicks<2) + samples+=500; /* the minimum silence between repeats */ + pi->repeats=self->wvefile.head.Repeats; + pi->total=SamplesToTenths(samples*pi->repeats); + pi->samples=self->wvefile.head.Samples; + pi->flen=self->wvefile.info.size; + } + +METHOD VOID wvefile_wve_set_repeats(PR_WVEFILE *self,UINT repeats,UINT tenths) +/* +If repeats is zero or more, set the number of repeats and the trailing silence +to tenths in 1/10s of a second. +If repeats is zero, set the silence such that the total duration with the +current number of repeats is equal to tenths. +*/ + { + INT ret; + INT silence,maxrepeats; + LONG total,period; + + ret=0; + if (self->wvefile.fcb==NULL) + return; + if (repeats>0) + silence=(INT)(((ULONG)tenths<<4)/5); /* convert to ticks */ + else + { /* tenths is total desired time */ + repeats=self->wvefile.head.Repeats; + total=tenths; + total*=800; /* convert tenths to samples */ + period=EffectiveSamples(self->wvefile.head.Samples); + maxrepeats=(INT)(total/(period+500)); + if (repeats<2 || repeats>maxrepeats) + repeats=maxrepeats; + if (repeats==0) + repeats=1; + silence=0; + if (repeats>1) + silence=(INT)((total-repeats*period+249*repeats)/(250*repeats)); + } + if (silence==self->wvefile.head.SilenceInTicks && repeats==self->wvefile.head.Repeats) + return; /* no change */ + self->wvefile.head.SilenceInTicks=silence; + self->wvefile.head.Repeats=repeats; + CloseFile(self); + ret=p_open(&self->wvefile.fcb,&self->wvefile.fname[0],P_FUPDATE); + if (ret>=0) + { + ret=p_write(self->wvefile.fcb,&self->wvefile.head,sizeof(SndFile)); + CloseFile(self); + } + wvefile_wve_open(self,NULL); + f_leave(ret); + } + + diff --git a/code/SIBOSDK/resource/s3_.rss b/code/SIBOSDK/resource/s3_.rss new file mode 100644 index 0000000..6509c9b --- /dev/null +++ b/code/SIBOSDK/resource/s3_.rss @@ -0,0 +1,1389 @@ +SYSTEM +/* +(No comment to be placed on the first line of this file!) + +S3_.RSS + +System Resource file for Series 3 + +*/ + +#include +#include +#include +#include + +/****************** THE SPECIAL CHARACTERS ************************/ + +/* leave most of these alone, but translate the NSWE */ + +GLOBAL RESOURCE STRING sys_special_characters { str="+-*/<,>.NSWE"; } + +/************************* STRINGS ********************************/ + +GLOBAL RESOURCE STRING sys_string { str="%s"; } +GLOBAL RESOURCE STRING sys_dimmed_msg {str="This item is not available";} +GLOBAL RESOURCE STRING sys_locked_msg {str="This item cannot be changed";} +GLOBAL RESOURCE STRING sys_busy { str="Busy"; } +GLOBAL RESOURCE STRING sys_scanning { str="Scanning"; } +GLOBAL RESOURCE STRING sys_printing_to { str="Printing to %s";} +GLOBAL RESOURCE STRING sys_page_is { str="(page %u)";} + +GLOBAL RESOURCE STRING sys_copied_prompt {str="Copied";} +GLOBAL RESOURCE STRING sys_copying_prompt {str="Saving as \"%s\"";} +GLOBAL RESOURCE STRING sys_loading_prompt {str="Loading \"%s\"";} +GLOBAL RESOURCE STRING sys_merging_prompt {str="Merging in \"%s\"";} +GLOBAL RESOURCE STRING sys_nothing_to_bring {str="Nothing to bring";} +GLOBAL RESOURCE STRING sys_not_found {str="Not found"; } +GLOBAL RESOURCE STRING sys_nothing_to_find {str="Nothing to find";} + +GLOBAL RESOURCE STRING sys_compress_prompt {str="Compressing \"%s\"";} +GLOBAL RESOURCE STRING sys_not_compressible {str="Cannot compress on Flash";} + +GLOBAL RESOURCE STRING sys_password_incorrect {str="Incorrect password";} +GLOBAL RESOURCE STRING sys_password_not_confirmed {str="Password not confirmed";} + +GLOBAL RESOURCE STRING sys_range_reset {str="Out of range - reset to limit";} +GLOBAL RESOURCE STRING sys_invalid_num {str="Number is not valid";} +GLOBAL RESOURCE STRING sys_invalid_margins { str="Invalid margins. Reset ?"; } +GLOBAL RESOURCE STRING sys_invalid_char { str="Undiallable character"; } +GLOBAL RESOURCE STRING sys_out_of_range {str="Value out of range: %s = %s";} + /* as used in "Value out of range: Max = 20.45 */ + +GLOBAL RESOURCE STRING sys_edit_nchars {str="Maximum number of characters reached";} + +GLOBAL RESOURCE STRING sys_popout_help {str="Press Tab to change this item";} + +GLOBAL RESOURCE STRING sys_help_string {str="Help: %s";} + +GLOBAL RESOURCE STRING sys_replace_disk {str="Replace the application disk";} + + /* the prompts for a file selector and a pack selector */ +GLOBAL RESOURCE STRING sys_name {str="Name";} +GLOBAL RESOURCE STRING sys_pack {str="Disk";} + + /* part of the title line of a filelist */ +GLOBAL RESOURCE STRING sys_filelist_disk {str="Disk ";} + +GLOBAL RESOURCE STRING sys_flist_reset { str="File list reset"; } +GLOBAL RESOURCE STRING sys_device_memory { str="Internal"; } +GLOBAL RESOURCE STRING sys_path_is { str="Path is %s"; } +GLOBAL RESOURCE STRING sys_choose_directory { str="Choose a directory"; } +GLOBAL RESOURCE STRING sys_choose_filename { str="Choose a filename"; } +GLOBAL RESOURCE STRING sys_choose_new_directory { str="Directory already exists"; } +GLOBAL RESOURCE STRING sys_exists_over { str="File already exists: overwrite?"; } + +/* Next two strings have a maximum length of 5 characters each */ +GLOBAL RESOURCE STRING sys_max { str="Max"; } +GLOBAL RESOURCE STRING sys_min { str="Min"; } + +GLOBAL RESOURCE STRING sys_dec_places { str="Decimal places"; } +GLOBAL RESOURCE STRING sys_sig_digits { str="Significant digits"; } +GLOBAL RESOURCE STRING sys_evaldlg_title { str="Set \"Evaluate\" format"; } +GLOBAL RESOURCE STRING sys_nothing_to_eval { str="Nothing to evaluate"; } +GLOBAL RESOURCE STRING sys_toolong_to_eval { str="Too long to evaluate"; } + +GLOBAL RESOURCE STRING sys_xonxoff_string {str="Xon/xoff ";} +GLOBAL RESOURCE STRING sys_header_str { str="Enter header details"; } +GLOBAL RESOURCE STRING sys_footer_str { str="Enter footer details"; } + +/* max len of next 2 strs is 9 (including the space and the brackets) */ +GLOBAL RESOURCE STRING sys_centimetres { str=" (cm)"; } +GLOBAL RESOURCE STRING sys_inches { str=" (in)"; } + +GLOBAL RESOURCE STRING sys_dev_notready { str=" Absent!"; } +GLOBAL RESOURCE STRING sys_dev_corrupt { str=" Unformatted!"; } +GLOBAL RESOURCE STRING sys_dev_unknown { str=" Unrecognised!"; } +GLOBAL RESOURCE STRING sys_dev_info { str=", %luK free"; } + +GLOBAL RESOURCE STRING sys_mtype_unknown { str="Unknown"; } +GLOBAL RESOURCE STRING sys_mtype_floppy { str="Floppy"; } +GLOBAL RESOURCE STRING sys_mtype_hard { str="Hard"; } +GLOBAL RESOURCE STRING sys_mtype_flash { str="Flash"; } +GLOBAL RESOURCE STRING sys_mtype_ram { str="Ram"; } +GLOBAL RESOURCE STRING sys_mtype_rom { str="Rom"; } +GLOBAL RESOURCE STRING sys_mtype_protected { str="Protected"; } + +/* Maximum of 14 character widths for the following 5 strings */ +GLOBAL RESOURCE STRING sys_files_tagged { str="(Tagged files)"; } +GLOBAL RESOURCE STRING sys_no_files { str="(No files)"; } +GLOBAL RESOURCE STRING sys_no_disk { str="(No disk)"; } +GLOBAL RESOURCE STRING sys_unformatted { str="(Unformatted)"; } +GLOBAL RESOURCE STRING sys_unrecognised { str="(Unrecognised)"; } + +GLOBAL RESOURCE STRING sys_sound_fail { str="Sound in use - please retry"; } + +/*********** THE ALLOWED SPECIAL KEYS FOR ACTION BUTTONS ******************/ + +/* You can translate the text, but no more than six characters each */ + +GLOBAL RESOURCE ACLIST_ARRAY sys_button_text + { + button= + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Enter"; + }, + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Esc"; + }, + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Del"; + }, + PUSH_BUT + { + keycode=W_KEY_SPACE; + str="Space"; + }, + PUSH_BUT + { + keycode=W_KEY_UP; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_DOWN; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_RIGHT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_LEFT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Tab"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Menu"; + } + }; + } + + +/************************* ACTION LISTS ******************************/ + +/* Change the keycodes too, but don't lose the minus signs */ + +GLOBAL RESOURCE ACLIST_ARRAY sys_ac_no_yes + { + button = + { + PUSH_BUT + { + keycode=-'n'; + str="No"; + }, + PUSH_BUT + { + keycode='y'; + str="Yes"; + } + }; + } + +GLOBAL RESOURCE ACLIST_ARRAY sys_ac_continue + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Continue"; + } + }; + } + +GLOBAL RESOURCE ACLIST_ARRAY sys_ac_abandon + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Abandon"; + } + }; + } + +GLOBAL RESOURCE ACLIST_ARRAY sys_append_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Append"; + } + }; + } + +/* Careful not to make the combined width of these strings much wider */ + +GLOBAL RESOURCE ACLIST_ARRAY sys_smart_dial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Cancel"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Free input"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Dial"; + }, + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Dial out"; + } + }; + } + +GLOBAL RESOURCE ACLIST_ARRAY sys_freedial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Clear"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Redial"; + } + }; + } + +/************************* CHOICE LISTS *****************************/ + +GLOBAL RESOURCE MENU sys_no_yes + { + items = + { + CHOICE_ITEM { str= "No";}, + CHOICE_ITEM { str="Yes";} + }; + } + +GLOBAL RESOURCE MENU sys_offon_menu + { + items = + { + CHOICE_ITEM { str="Off";}, + CHOICE_ITEM { str= "On";} + }; + } + +GLOBAL RESOURCE MENU sys_printer_units_chlist + { + items = + { + CHOICE_ITEM { str= "Inches";}, /* matches with E_IMPERIAL */ + CHOICE_ITEM { str= "Centimetres";} /* matches with E_METRIC */ + }; + } + +GLOBAL RESOURCE MENU sys_printer_device_chlist + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";} + }; + } + +GLOBAL RESOURCE MENU sys_baud_rate_chlist + { + items = + { + CHOICE_ITEM { str= "9600";}, + CHOICE_ITEM { str= "4800";}, + CHOICE_ITEM { str= "2400";}, + CHOICE_ITEM { str= "1200";}, + CHOICE_ITEM { str= "600";}, + CHOICE_ITEM { str= "300";} + }; + } + +GLOBAL RESOURCE MENU sys_data_bits_chlist + { + items = + { + CHOICE_ITEM { str="5";}, + CHOICE_ITEM { str="6";}, + CHOICE_ITEM { str="7";}, + CHOICE_ITEM { str="8";} + }; + } + +GLOBAL RESOURCE MENU sys_stop_bits_chlist + { + items = + { + CHOICE_ITEM { str="1";}, + CHOICE_ITEM { str="2";} + }; + } + +GLOBAL RESOURCE MENU sys_parity_chlist + { + items = + { + CHOICE_ITEM { str="None";}, + CHOICE_ITEM { str="Even";}, + CHOICE_ITEM { str= "Odd";} + }; + } + +GLOBAL RESOURCE MENU sys_format_chlist + { + items = + { + CHOICE_ITEM { str="Fixed";}, + CHOICE_ITEM { str="Scientific";}, + CHOICE_ITEM { str="General";}, + CHOICE_ITEM { str="Hexadecimal";} + }; + } + +GLOBAL RESOURCE MENU sys_rad_deg + { + items = + { + CHOICE_ITEM { str= "Radians";}, + CHOICE_ITEM { str= "Degrees";} + }; + } + +/* IMPORTANT, order in next array must be same as in page_size menu below */ +/* Also, at most 10 entries allowed, and the first two cannot be altered */ +/* But change any of the others, if you wish */ +/* 1 mm is 1440/25.4 units in the dimensions used, so eg 148 mm is 8391 */ +/* so you could have {width=8391; ... for one entry (an A5 letter size) */ + +GLOBAL RESOURCE PAGE_SIZE_ARRAY sys_page_dimensions + { + page_size= + { + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_EXECUTIVE; length=PAGE_LENGTH_EXECUTIVE;}, + PAGE_SIZE {width=PAGE_WIDTH_LEGAL; length=PAGE_LENGTH_LEGAL;}, + PAGE_SIZE {width=PAGE_WIDTH_LETTER; length=PAGE_LENGTH_LETTER;}, + PAGE_SIZE {width=PAGE_WIDTH_MONARCH; length=PAGE_LENGTH_MONARCH;}, + PAGE_SIZE {width=PAGE_WIDTH_DL; length=PAGE_LENGTH_DL;} + }; + } + +GLOBAL RESOURCE MENU sys_page_size + { + items= + { + CHOICE_ITEM {str="A4";}, + CHOICE_ITEM {str="Custom";}, + CHOICE_ITEM {str="Executive";}, + CHOICE_ITEM {str="Legal";}, + CHOICE_ITEM {str="Letter";}, + CHOICE_ITEM {str="Monarch";}, + CHOICE_ITEM {str="DL";} + }; + } + +GLOBAL RESOURCE MENU sys_orient + { + items= + { + CHOICE_ITEM {str="Portrait";}, + CHOICE_ITEM {str="Landscape";} + }; + } + +GLOBAL RESOURCE MENU sys_prn_pos + { + items= + { + CHOICE_ITEM {str="Normal";}, + CHOICE_ITEM {str="Superscript";}, + CHOICE_ITEM {str="Subscript";} + }; + } + +GLOBAL RESOURCE MENU sys_headfoot_align + { + items= + { + CHOICE_ITEM {str="Left";}, + CHOICE_ITEM {str="Right";}, + CHOICE_ITEM {str="Centred";}, + CHOICE_ITEM {str="Justified";}, + CHOICE_ITEM {str="Two column";}, + CHOICE_ITEM {str="Three column";} + }; + } + +GLOBAL RESOURCE MENU sys_pgno_choice + { + items= + { + CHOICE_ITEM {str="1,2,3";}, + CHOICE_ITEM {str="I,II,III";}, + CHOICE_ITEM {str="i,ii,iii";} + }; + } + + +/************************* DIALOGS ********************************/ + +GLOBAL RESOURCE DIALOG sys_error_dialog + { + flags=DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_continue; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_query_dialog + { + flags = DLGBOX_ACTION_LIST|DLGBOX_REPORT_ACT_HORIZ; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_no_yes; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_printing_dialog + { + flags=DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_abandon; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_set_port_dialog + { + title="Set Serial port"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Baud rate"; + info=CHLIST + { + rid=sys_baud_rate_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Data bits"; + info=CHLIST + { + rid=sys_data_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Stop bits"; + info=CHLIST + { + rid=sys_stop_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Parity"; + info=CHLIST + { + rid=sys_parity_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Ignore parity"; + info=CHLIST + { + rid=sys_no_yes; + nsel=0; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_set_hshk_dialog + { + title="Set serial handshake"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Xon/Xoff"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Rts/Cts"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Dsr/Dtr"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Dcd"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_printer_config_dialog + { + title="Printer configuration"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Printer device"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + info=CHLIST + { + rid=sys_printer_device_chlist; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial characteristics "; + info=TXTMESS + { + str="9600 "; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial handshaking "; + info=TXTMESS + { + str="Xon/Xoff Off "; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK|DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_FNEDIT; + prompt="File:"; + info=FNEDIT { flags=IN_FNEDIT_NO_AUTOQUERY; }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Units"; + info=CHLIST + { + rid=sys_printer_units_chlist; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_eval_dialog + { + title="Set Calculator format"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Format"; + info=CHLIST { rid=sys_format_chlist; }; + }, + CONTROL + { + class=C_NCEDIT; + /* The following line must be the longer of the 2 above strings */ + /* sys_dec_places and sys_sig_digits */ + prompt="Significant digits"; + info=NCEDIT + { + high=12; + low=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Trigonometry units"; + info=CHLIST { rid=sys_rad_deg; }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_country_selector_dialog + { + title="Append country"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_WLDSELWN; + prompt="Country"; + info=WLDSELWN {flags=IN_WLDSELWN_COUNTRY|IN_WLDSELWN_SETHOME; }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_append_aclist; + }; + } + }; + } + +GLOBAL RESOURCE CONTROL sys_smart_dial_item + { + class=C_EDWIN; + prompt=; + info=EDWIN + { + maxlen=WR_MAX_DIAL_STRING; + vulen=20; + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_NO_AUTOSELECT; + }; + } + +GLOBAL RESOURCE DIALOG sys_smart_dial_dialog + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="Dial"; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_smart_dial_aclist; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_freedial_dialog + { + title="Free-form dialling"; + flags = DLGBOX_NO_WAIT|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_FREEDIAL; + prompt=; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_freedial_aclist; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_flist_dialog + { + title="Specify filelist"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Filename pattern"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + }, + CONTROL + { + class=C_EDWIN; + prompt="Full path"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_print_control_dl + { + title="Print setup"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_NOTIFY_ESCAPE; + controls= + { + CONTROL + { + class=C_TEXTWIN; + prompt="Page size"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Margins"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Header"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Footer"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Paging control"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Printer model"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_paging_control_dl + { + title="Paging control"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Number for first page"; + info=NCEDIT + { + low=1; + high=9999; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Allow widows/orphans"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Page number style"; + info=CHLIST{rid=sys_pgno_choice;}; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_printer_model + { + title="Set printer"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + prompt="Select printer"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + info=CHLIST{}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Default font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_margins_dl + { + title="Margins"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_FLTEDIT; + prompt="Top"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Left"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Right"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Bottom"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_headfoot_dl + { + title="*"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Text"; + info=EDWIN + { + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_ACCEPT_TABS; + maxlen=80; + vulen=20; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Alignment"; + info=CHLIST{rid=sys_headfoot_align;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="On first page"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Vertical offset"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_pagesize_dl + { + title="Page size"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_CHLIST; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + prompt="Page size"; + info=CHLIST{rid=sys_page_size;}; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Width"; + info=FLTEDIT + { + low=0; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Height"; + info=FLTEDIT + { + low=0; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Orientation"; + info=CHLIST{rid=sys_orient;}; + } + }; + } + +GLOBAL RESOURCE DIALOG sys_font_dl + { + title="Font"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Font"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Size"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Underline"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Bold"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Italic"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Print position"; + info=CHLIST{rid=sys_prn_pos;}; + } + }; + } + +GLOBAL RESOURCE CONTROL sys_txtmess + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + } + + +/************************* HELP ********************************/ + +GLOBAL RESOURCE TOPIC_ARRAY sys_help_index_data +{ +id_lst= +{ +sys_help_on_off, +sys_time_basics, +sys_help_edit, +sys_help_dialog, +sys_help_statwin, +sys_help_dialling, +sys_help_files, +sys_help_filsels, +sys_help_print +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_index +{ +topic="Index"; +topic_id=sys_help_index_data; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_on_help +{ +topic="About Help"; +strlst= +{ +STRING {str="To choose a topic:""then Enter";}, +STRING {str="";}, +STRING {str="Esc returns to previous screen";}, +STRING {str="Control-Esc exits";}, +STRING {str="";}, +STRING {str="Control-Help for an index";} +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_dialog +{ +topic="Menu/dialog tips"; +strlst= +{ +STRING {str="Use hot-keys (""-N etc) for menu options";}, +STRING {str="";}, +STRING {str="Tab often lists choices in dialogs";} +}; +} + + + +GLOBAL RESOURCE HELP_ARRAY sys_help_statwin +{ +topic="Status window"; +strlst= +{ +STRING {str="Press ""-Menu for a Status Window";}, +STRING {str="Control-Menu sets it on/off";} +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_dialling +{ +topic="Dialling"; +strlst= +{ +STRING {str="Find an entry then press Dial (""-Help)";}, +STRING {str="";}, +STRING {str=" marks numbers; Shift-Dial inserts a ";}, +STRING {str="";}, +STRING {str="Control-Dial "" free-form dialler";} +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_filsels +{ +topic="File selection"; +strlst= +{ +STRING {str="Press Tab to choose from a full list of";}, +STRING {str="files/directories:";}, +STRING {str="Typing matches files";}, +STRING {str="Shift-Letter matches directories";}, +STRING {str="Control-Letter matches disks";}, +STRING {str="";}, +STRING {str="On System screen:";}, +STRING {str="Menu now gives file/directory options;";}, +STRING {str="+- (or Shift-"")""tag/untag a file";}, +STRING {str="*/""tag/untag all";}, +STRING {str="";}, +STRING {str="In dialogs:";}, +STRING {str="""-Tab gives full path";}, +STRING {str="For quick wildcarding,";}, +STRING {str="use Control-Tab then Control-Enter";} +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_edit +{ +topic="Editing"; +strlst= +{ +STRING {str="Use "" to move cursor";}, +STRING {str="The Control and "" keys increase movement";}, +STRING {str="";}, +STRING {str="Shift-"" highlights text:";}, +STRING {str="Use Delete to cut, or `Copy' to copy text";}, +STRING {str="then `Insert' pastes the text back in;";}, +STRING {str="Shift-Delete deletes text without";}, +STRING {str="changing what `Insert' will next insert";}, +STRING {str="";}, +STRING {str="Quick delete methods (when no highlight):";}, +STRING {str="Shift-Delete: character forwards";}, +STRING {str="Shift-""-Delete: to end of line";}, +STRING {str="""-Delete: to beginning of line";}, +STRING {str="";}, +STRING {str="Quick highlight methods:";}, +STRING {str="Shift-Control-Home: current word";}, +STRING {str="Shift-Control-End: current paragraph";} +}; +} + +GLOBAL RESOURCE TOPIC_ARRAY sys_help_x_help +{ +id_lst= +{ +sys_help_on_help +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_help_files +{ +topic="Files"; +strlst= +{ +STRING {str="Create with `New file'";}, +STRING {str="";}, +STRING {str="Select from System screen";}, +STRING {str="";}, +STRING {str="Copy with `Save as'";} +}; +} + + +GLOBAL RESOURCE HELP_ARRAY sys_help_print +{ +topic="How to print"; +strlst= +{ +STRING {str="Set Printer Model with `Print setup'";}, +STRING {str="in Word/Agenda/Data, then use `Print'";} +}; +} + +GLOBAL RESOURCE HELP_ARRAY sys_time_basics +{ +topic="Time basics"; /* DON'T change to just "Basics" */ +strlst= +{ +STRING {str="Set `Home city', then `Time and date'";}, +STRING {str="";}, +STRING {str="Set `Summer times' on/off when they change";}, +STRING {str="";}, +STRING {str="`Formats' sets 12/24 hour clocks";} +}; +} + + +GLOBAL RESOURCE HELP_ARRAY sys_help_on_off +{ +topic="On/off"; +strlst= +{ +STRING {str="Esc turns on";}, +STRING {str="-1 turns off";} +}; +} + +GLOBAL RESOURCE TOPIC_ARRAY sys_help_x_index +{ +id_lst= +{ +sys_help_index +}; +} + +/************************* LATER ADDITIONS ********************************/ + +GLOBAL RESOURCE STRING sys_wdr_general { str="General"; } + /* Name of general printer driver */ + +GLOBAL RESOURCE STRING sys_dial_out { str="9,"; } /* 5 chars max */ +GLOBAL RESOURCE STRING sys_skipping_page { str="(skipping page %u)";} diff --git a/code/SIBOSDK/resource/sa_.rss b/code/SIBOSDK/resource/sa_.rss new file mode 100644 index 0000000..a101b88 --- /dev/null +++ b/code/SIBOSDK/resource/sa_.rss @@ -0,0 +1,1836 @@ +SYSTEM +/* +(No comment to be placed on the first line of this file!) + +SA_.RSS + +System Resource file for Series 3a + +*/ + +#include +#include +#include +#include + +/****************** THE SPECIAL CHARACTERS ************************/ + +/* leave most of these alone, but translate the NSWE */ + +RESOURCE STRING sys_special_characters { str="+-*/<,>.NSWE"; } + +/************************* STRINGS ********************************/ + +RESOURCE STRING sys_string { str="%s"; } +RESOURCE STRING sys_dimmed_msg {str="This item is not available";} +RESOURCE STRING sys_locked_msg {str="This item cannot be changed";} +RESOURCE STRING sys_busy { str="Busy"; } +RESOURCE STRING sys_scanning { str="Scanning"; } +RESOURCE STRING sys_printing_to { str="Printing to %s";} +RESOURCE STRING sys_page_is { str="(page %u)";} + +RESOURCE STRING sys_copied_prompt {str="Copied";} +RESOURCE STRING sys_copying_prompt {str="Saving as \"%s\"";} +RESOURCE STRING sys_loading_prompt {str="Loading \"%s\"";} +RESOURCE STRING sys_merging_prompt {str="Merging in \"%s\"";} +RESOURCE STRING sys_nothing_to_bring {str="Nothing to bring";} +RESOURCE STRING sys_not_found {str="Not found"; } +RESOURCE STRING sys_nothing_to_find {str="Nothing to find";} + +RESOURCE STRING sys_compress_prompt {str="Compressing \"%s\"";} +RESOURCE STRING sys_not_compressible {str="Cannot compress on Flash";} + +RESOURCE STRING sys_password_incorrect {str="Incorrect password";} +RESOURCE STRING sys_password_not_confirmed {str="Password not confirmed";} + +RESOURCE STRING sys_range_reset {str="Out of range - reset to limit";} +RESOURCE STRING sys_invalid_num {str="Number is not valid";} +RESOURCE STRING sys_invalid_margins { str="Invalid margins. Reset?"; } +RESOURCE STRING sys_invalid_char { str="Undiallable character"; } +RESOURCE STRING sys_out_of_range {str="Value out of range: %s = %s";} +/* as used in "Value out of range: Max = 20.45 */ + +RESOURCE STRING sys_edit_nchars {str="Maximum number of characters reached";} + +RESOURCE STRING sys_popout_help {str="Press Tab to change this item";} + +RESOURCE STRING sys_help_string {str="Help: %s";} + +RESOURCE STRING sys_replace_disk {str="Replace the application disk";} + +/* the prompts for a file selector and a pack selector */ +RESOURCE STRING sys_name {str="Name";} +RESOURCE STRING sys_pack {str="Disk";} + +/* part of the title line of a filelist */ +RESOURCE STRING sys_filelist_disk {str="Disk ";} + +RESOURCE STRING sys_flist_reset { str="File list reset"; } +RESOURCE STRING sys_device_memory { str="Internal"; } +RESOURCE STRING sys_path_is { str="Path is %s"; } +RESOURCE STRING sys_choose_directory { str="Choose a directory"; } +RESOURCE STRING sys_choose_filename { str="Choose a filename"; } +RESOURCE STRING sys_choose_new_directory { str="Directory already exists"; } +RESOURCE STRING sys_exists_over { str="File already exists: overwrite?"; } + +/* Next two strings have a maximum length of 5 characters each */ +RESOURCE STRING sys_max { str="Max"; } +RESOURCE STRING sys_min { str="Min"; } + +RESOURCE STRING sys_dec_places { str="Decimal places"; } +RESOURCE STRING sys_sig_digits { str="Significant digits"; } +RESOURCE STRING sys_evaldlg_title { str="Set \"Evaluate\" format"; } +RESOURCE STRING sys_nothing_to_eval { str="Nothing to evaluate"; } +RESOURCE STRING sys_toolong_to_eval { str="Too long to evaluate"; } + +RESOURCE STRING sys_xonxoff_string {str="Xon/xoff ";} +RESOURCE STRING sys_header_str { str="Enter header details"; } +RESOURCE STRING sys_footer_str { str="Enter footer details"; } + +/* max len of next 2 strs is 9 (including the space and the brackets) */ +RESOURCE STRING sys_centimetres { str=" (cm)"; } +RESOURCE STRING sys_inches { str=" (inches)"; } + +RESOURCE STRING sys_dev_notready { str=" Absent!"; } +RESOURCE STRING sys_dev_corrupt { str=" Unformatted!"; } +RESOURCE STRING sys_dev_unknown { str=" Unrecognised!"; } +RESOURCE STRING sys_dev_info { str=", %luK free"; } + +RESOURCE STRING sys_mtype_unknown { str="Unknown"; } +RESOURCE STRING sys_mtype_floppy { str="Floppy"; } +RESOURCE STRING sys_mtype_hard { str="Hard"; } +RESOURCE STRING sys_mtype_flash { str="Flash"; } +RESOURCE STRING sys_mtype_ram { str="Ram"; } +RESOURCE STRING sys_mtype_rom { str="Rom"; } +RESOURCE STRING sys_mtype_protected { str="Protected"; } + +/* Maximum of 14 character widths for the following 5 strings */ +RESOURCE STRING sys_files_tagged { str="(Tagged files)"; } +RESOURCE STRING sys_no_files { str="(No files)"; } +RESOURCE STRING sys_no_disk { str="(No disk)"; } +RESOURCE STRING sys_unformatted { str="(Unformatted)"; } +RESOURCE STRING sys_unrecognised { str="(Unrecognised)"; } + +RESOURCE STRING sys_sound_fail { str="Sound in use - please retry"; } + +/*********** THE ALLOWED SPECIAL KEYS FOR ACTION BUTTONS ******************/ + +/* You can translate the text, but no more than six characters each */ + +RESOURCE ACLIST_ARRAY sys_button_text + { + button= + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Enter"; + }, + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Esc"; + }, + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Del"; + }, + PUSH_BUT + { + keycode=W_KEY_SPACE; + str="Space"; + }, + PUSH_BUT + { + keycode=W_KEY_UP; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_DOWN; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_RIGHT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_LEFT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Tab"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Menu"; + } + }; + } + + +/************************* ACTION LISTS ******************************/ + +/* Change the keycodes too, but don't lose the minus signs */ + +RESOURCE ACLIST_ARRAY sys_ac_no_yes + { + button = + { + PUSH_BUT + { + keycode=-'n'; + str="No"; + }, + PUSH_BUT + { + keycode='y'; + str="Yes"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_continue + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Continue"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_abandon + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Abandon"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_append_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Append"; + } + }; + } + +/* Careful not to make the combined width of these strings much wider */ + +RESOURCE ACLIST_ARRAY sys_smart_dial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Cancel"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Free input"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Dial"; + }, + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Dial out"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_freedial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Clear"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Redial"; + } + }; + } + +/************************* CHOICE LISTS *****************************/ + +RESOURCE MENU sys_no_yes + { + items = + { + CHOICE_ITEM { str= "No";}, + CHOICE_ITEM { str="Yes";} + }; + } + +RESOURCE MENU sys_offon_menu + { + items = + { + CHOICE_ITEM { str="Off";}, + CHOICE_ITEM { str= "On";} + }; + } + +RESOURCE MENU sys_printer_units_chlist + { + items = + { + CHOICE_ITEM { str= "Inches";}, /* matches with E_IMPERIAL */ + CHOICE_ITEM { str= "Centimetres";} /* matches with E_METRIC */ + }; + } + +RESOURCE MENU sys_printer_device_chlist + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";} + }; + } + +RESOURCE MENU sys_baud_rate_chlist + { + items = + { + CHOICE_ITEM { str= "19200";}, /* new for S3a */ + CHOICE_ITEM { str= "9600";}, + CHOICE_ITEM { str= "4800";}, + CHOICE_ITEM { str= "2400";}, + CHOICE_ITEM { str= "1200";}, + CHOICE_ITEM { str= "600";}, + CHOICE_ITEM { str= "300";} + }; + } + +RESOURCE MENU sys_data_bits_chlist + { + items = + { + CHOICE_ITEM { str="5";}, + CHOICE_ITEM { str="6";}, + CHOICE_ITEM { str="7";}, + CHOICE_ITEM { str="8";} + }; + } + +RESOURCE MENU sys_stop_bits_chlist + { + items = + { + CHOICE_ITEM { str="1";}, + CHOICE_ITEM { str="2";} + }; + } + +RESOURCE MENU sys_parity_chlist + { + items = + { + CHOICE_ITEM { str="None";}, + CHOICE_ITEM { str="Even";}, + CHOICE_ITEM { str= "Odd";} + }; + } + +RESOURCE MENU sys_format_chlist + { + items = + { + CHOICE_ITEM { str="Fixed";}, + CHOICE_ITEM { str="Scientific";}, + CHOICE_ITEM { str="General";}, + CHOICE_ITEM { str="Hexadecimal";} + }; + } + +RESOURCE MENU sys_rad_deg + { + items = + { + CHOICE_ITEM { str= "Radians";}, + CHOICE_ITEM { str= "Degrees";} + }; + } + +/* IMPORTANT, order in next array must be same as in page_size menu below */ +/* Also, at most 10 entries allowed, and the first two cannot be altered */ +/* But change any of the others, if you wish */ +/* 1 mm is 1440/25.4 units in the dimensions used, so eg 148 mm is 8391 */ +/* so you could have {width=8391; ... for one entry (an A5 letter size) */ + +RESOURCE PAGE_SIZE_ARRAY sys_page_dimensions + { + page_size= + { + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_EXECUTIVE; length=PAGE_LENGTH_EXECUTIVE;}, + PAGE_SIZE {width=PAGE_WIDTH_LEGAL; length=PAGE_LENGTH_LEGAL;}, + PAGE_SIZE {width=PAGE_WIDTH_LETTER; length=PAGE_LENGTH_LETTER;}, + PAGE_SIZE {width=PAGE_WIDTH_MONARCH; length=PAGE_LENGTH_MONARCH;}, + PAGE_SIZE {width=PAGE_WIDTH_DL; length=PAGE_LENGTH_DL;} + }; + } + +RESOURCE MENU sys_page_size + { + items= + { + CHOICE_ITEM {str="A4";}, + CHOICE_ITEM {str="Custom";}, + CHOICE_ITEM {str="Executive";}, + CHOICE_ITEM {str="Legal";}, + CHOICE_ITEM {str="Letter";}, + CHOICE_ITEM {str="Monarch";}, + CHOICE_ITEM {str="DL";} + }; + } + +RESOURCE MENU sys_orient + { + items= + { + CHOICE_ITEM {str="Portrait";}, + CHOICE_ITEM {str="Landscape";} + }; + } + +RESOURCE MENU sys_prn_pos + { + items= + { + CHOICE_ITEM {str="Normal";}, + CHOICE_ITEM {str="Superscript";}, + CHOICE_ITEM {str="Subscript";} + }; + } + +RESOURCE MENU sys_headfoot_align + { + items= + { + CHOICE_ITEM {str="Left";}, + CHOICE_ITEM {str="Right";}, + CHOICE_ITEM {str="Centred";}, + CHOICE_ITEM {str="Justified";}, + CHOICE_ITEM {str="Two column";}, + CHOICE_ITEM {str="Three column";} + }; + } + +RESOURCE MENU sys_pgno_choice + { + items= + { + CHOICE_ITEM {str="1,2,3";}, + CHOICE_ITEM {str="I,II,III";}, + CHOICE_ITEM {str="i,ii,iii";} + }; + } + +/************************* DIALOGS ********************************/ + +RESOURCE DIALOG sys_error_dialog + { + flags=DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_continue; + }; + } + }; + } + +RESOURCE DIALOG sys_query_dialog + { + flags = DLGBOX_ACTION_LIST|DLGBOX_REPORT_ACT_HORIZ; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_no_yes; + }; + } + }; + } + +RESOURCE DIALOG sys_printing_dialog + { + flags=DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_abandon; + }; + } + }; + } + +RESOURCE DIALOG sys_set_port_dialog + { + title="Set Serial port"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Baud rate"; + info=CHLIST + { + rid=sys_baud_rate_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Data bits"; + info=CHLIST + { + rid=sys_data_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Stop bits"; + info=CHLIST + { + rid=sys_stop_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Parity"; + info=CHLIST + { + rid=sys_parity_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Ignore parity"; + info=CHLIST + { + rid=sys_no_yes; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_set_hshk_dialog + { + title="Set serial handshake"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Xon/Xoff"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Rts/Cts"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Dsr/Dtr"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Dcd"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_printer_config_dialog + { + title="Printer configuration"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Printer device"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + info=CHLIST + { + rid=sys_printer_device_chlist; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial characteristics "; + info=TXTMESS + { + str="19200 "; /* changed for S3a */ + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial handshaking "; + info=TXTMESS + { + str="Xon/Xoff Off "; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK|DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_FNEDIT; + prompt="File:"; + info=FNEDIT { flags=IN_FNEDIT_NO_AUTOQUERY; }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Units"; + info=CHLIST + { + rid=sys_printer_units_chlist; + }; + } + }; + } + +RESOURCE DIALOG sys_eval_dialog + { + title="Set Calculator format"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Format"; + info=CHLIST { rid=sys_format_chlist; }; + }, + CONTROL + { + class=C_NCEDIT; + /* The following line must be the wider of the 2 above strings */ + /* sys_dec_places and sys_sig_digits */ + prompt="Significant digits"; + info=NCEDIT + { + high=12; + low=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Trigonometry units"; + info=CHLIST { rid=sys_rad_deg; }; + } + }; + } + +RESOURCE DIALOG sys_country_selector_dialog + { + title="Append country"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_WLDSELWN; + prompt="Country"; + info=WLDSELWN {flags=IN_WLDSELWN_COUNTRY|IN_WLDSELWN_SETHOME; }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_append_aclist; + }; + } + }; + } + +RESOURCE CONTROL sys_smart_dial_item + { + class=C_EDWIN; + prompt=; + info=EDWIN + { + maxlen=WR_MAX_DIAL_STRING; + vulen=20; + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_NO_AUTOSELECT; + }; + } + +RESOURCE DIALOG sys_smart_dial_dialog + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="Dial"; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_smart_dial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_freedial_dialog + { + title="Free-form dialling"; + flags = DLGBOX_NO_WAIT|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_FREEDIAL; + prompt=; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_freedial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_flist_dialog + { + title="Specify filelist"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Filename pattern"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + }, + CONTROL + { + class=C_EDWIN; + prompt="Full path"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + } + }; + } + +RESOURCE DIALOG sys_print_control_dl + { + title="Print setup"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_NOTIFY_ESCAPE; + controls= + { + CONTROL + { + class=C_TEXTWIN; + prompt="Page size"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Margins"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Header"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Footer"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Paging control"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Printer model"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_paging_control_dl + { + title="Paging control"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Number for first page"; + info=NCEDIT + { + low=1; + high=9999; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Allow widows/orphans"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Page number style"; + info=CHLIST{rid=sys_pgno_choice;}; + } + }; + } + +RESOURCE DIALOG sys_printer_model + { + title="Set printer"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + prompt="Select printer"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + info=CHLIST{}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Default font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_margins_dl + { + title="Margins"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_FLTEDIT; + prompt="Top"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Left"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Right"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Bottom"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_headfoot_dl + { + title="*"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Text"; + info=EDWIN + { + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_ACCEPT_TABS; + maxlen=80; + vulen=20; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Alignment"; + info=CHLIST{rid=sys_headfoot_align;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="On first page"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Vertical offset"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_pagesize_dl + { + title="Page size"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_CHLIST; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + prompt="Page size"; + info=CHLIST{rid=sys_page_size;}; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Width"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Height"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Orientation"; + info=CHLIST{rid=sys_orient;}; + } + }; + } + +RESOURCE DIALOG sys_font_dl + { + title="Font"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Font"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Size"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Underline"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Bold"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Italic"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Print position"; + info=CHLIST{rid=sys_prn_pos;}; + } + }; + } + +RESOURCE CONTROL sys_txtmess + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + } + +/************************* HELP ********************************/ + +#define ARROWS + +RESOURCE TOPIC_ARRAY sys_help_index_data +{ +id_lst= +{ +sys_help_on_off, +sys_time_basics, +sys_help_edit, +sys_help_dialog, +sys_help_statwin, +sys_help_dialling, +sys_help_files, +sys_help_filsels, +sys_help_evaluate, +sys_help_print, +sys_help_in_use, +sys_help_no_sys_mem +}; +} + +RESOURCE HELP_ARRAY sys_help_index +{ +topic="Index"; +topic_id=sys_help_index_data; +} + +RESOURCE HELP_ARRAY sys_help_on_help +{ +topic="About Help"; +strlst= +{ +STRING {str="To choose a topic:""then Enter";}, +STRING {str="";}, +STRING {str="Esc returns to previous Help screen";}, +STRING {str="Control-Esc exits Help";}, +STRING {str="";}, +STRING {str="Control-Help for an index";}, +STRING {str="(works from main application screen)";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialog +{ +topic="Menu/dialog tips"; +strlst= +{ +STRING {str="Press Menu key to see a menu.";}, +STRING {str="Use "ARROWS" to choose the option,";}, +STRING {str="then press Enter.";}, +STRING {str="";}, +STRING {str="Hot-keys (""-N etc) access";}, +STRING {str="menu options directly";}, +STRING {str="";}, +STRING {str="Tab often lists choices in dialogs";} +}; +} + +RESOURCE HELP_ARRAY sys_help_statwin +{ +topic="Screen display"; +strlst= +{ +STRING {str="Press "" to switch";}, +STRING {str="between an application's screens";}, +STRING {str="";}, +STRING {str="`Zoom in/out' to change character size";}, +STRING {str="";}, +STRING {str="Press ""-Menu for a Status Window";}, +STRING {str="Control-Menu may set it large/small/off";}, +STRING {str="(depending on the application)";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialling +{ +topic="Dialling"; +strlst= +{ +STRING {str="Find an entry in Data/Agenda,";}, +STRING {str="then press Dial (""-Help)";}, +STRING {str="";}, +STRING {str=" marks numbers; Shift-Dial inserts a ";}, +STRING {str="";}, +STRING {str="Control-Dial for a free-form dialler";} +}; +} + +RESOURCE HELP_ARRAY sys_help_filsels +{ +topic="File selection"; +strlst= +{ +STRING {str="Press Tab in dialogs to choose from a";}, +STRING {str="full list of files/directories:";}, +STRING {str="Typing matches with filenames";}, +STRING {str="Shift+letter matches directories";}, +STRING {str="Control+letter matches disks";}, +STRING {str="";}, +STRING {str="Press Tab on System screen:";}, +STRING {str="Menu then gives file/directory options;";}, +STRING {str="+- (or Shift-"")""tag/untag a file";}, +STRING {str="*/""tag/untag all";}, +STRING {str="";}, +STRING {str="In dialogs:";}, +STRING {str="-Tab gives full path";}, +STRING {str="To select a wildcard filespec in a";}, +STRING {str="dialog, use Control-Tab, type the";}, +STRING {str="filespec, then Control-Enter";} +}; +} + +RESOURCE HELP_ARRAY sys_help_edit +{ +topic="Editing"; +strlst= +{ +STRING {str="Use "" to move cursor";}, +STRING {str="Control and "" keys increase movement";}, +STRING {str="";}, +STRING {str="Shift-"" highlights text:";}, +STRING {str="Use Delete to cut to the clipboard (or";}, +STRING {str="`Copy' to copy), then `Insert' to";}, +STRING {str="paste the text back in;";}, +STRING {str="Shift-Delete deletes text without";}, +STRING {str="changing the clipboard";}, +STRING {str="";}, +STRING {str="Use `Bring' options to copy text";}, +STRING {str="highlighted in a different application";}, +STRING {str="";}, +STRING {str="Quick delete methods (when no highlight)";}, +STRING {str="Shift-Delete: character forwards";}, +STRING {str="Shift-""-Delete: to end of line";}, +STRING {str="-Delete: to beginning of line";}, +STRING {str="";}, +STRING {str="Quick highlight methods";}, +STRING {str="Shift-Control-Home: current word";}, +STRING {str="Shift-Control-End: current paragraph";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_help +{ +id_lst= +{ +sys_help_on_help +}; +} + +RESOURCE HELP_ARRAY sys_help_files +{ +topic="Files"; +strlst= +{ +STRING {str="Create files with `New file'";}, +STRING {str="";}, +STRING {str="Copy files with `Copy file', but use";}, +STRING {str="`Save as' for Data and Agenda files";}, +STRING {str="";}, +STRING {str="To open: use `Open file', or highlight";}, +STRING {str="and Enter on System screen";}, +STRING {str="";}, +STRING {str="To delete: exit file, highlight on";}, +STRING {str="System screen and then `Delete file'";}, +STRING {str="";}, +STRING {str="To rename file: `Rename file' on";}, +STRING {str="System screen";}, +STRING {str="";}, +STRING {str="`Backup files' and `Restore files'";}, +STRING {str="on System screen";}, +STRING {str="";}, +STRING {str="`Merge in', `Compress file', `Save'";}, +STRING {str="and `Revert' in relevant applications";} +}; +} + +RESOURCE HELP_ARRAY sys_help_print +{ +topic="Printing/print preview"; +strlst= +{ +STRING {str="In applications which can Print, first";}, +STRING {str="use `Print setup' to set `Printer Model'";}, +STRING {str="";}, +STRING {str="Use `Print preview' to see a preview";}, +STRING {str="with its own menu of options. (You";}, +STRING {str="don't have to wait for the preview";}, +STRING {str="to finish calculating: Esc cancels, etc).";}, +STRING {str="Print preview's menu includes `Print'";}, +STRING {str="";}, +STRING {str="Use %D and %T in headers and footers";}, +STRING {str="(part of `Print setup') to print the";}, +STRING {str="date and time automatically.";}, +STRING {str="%Finserts the filename;";}, +STRING {str="%Pthe page number;";}, +STRING {str="%%a%character.";}, +STRING {str="(In Word or Sheet, you can use %M, eg";}, +STRING {str="`Page %P of %M', for eg `Page 1 of 6')";} +}; +} + +RESOURCE HELP_ARRAY sys_time_basics +{ +topic="Time basics"; +strlst= +{ +STRING {str="In `Time', set `Home city',";}, +STRING {str="then set `Time and date'";}, +STRING {str="";}, +STRING {str="Set `Summer times' on/off when";}, +STRING {str="they change";}, +STRING {str="";}, +STRING {str="`Formats' to set 12/24 hour clocks";} +}; +} + +RESOURCE HELP_ARRAY sys_help_on_off +{ +topic="On/off"; +strlst= +{ +STRING {str="Esc (or an application button) turns on";}, +STRING {str="-1 turns off";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_index +{ +id_lst= +{ +sys_help_index +}; +} + +/************************* LATER ADDITIONS ********************************/ + +/* Name of general printer driver */ +RESOURCE STRING sys_wdr_general { str="General"; } + +RESOURCE STRING sys_dial_out { str="9,"; } /* 5 chars max */ +RESOURCE STRING sys_skipping_page { str="(skipping page %u)";} + +/************************* NEW FOR Series 3a *****************************/ + +/* TTT: This file is entirely new for the S3a. +You must translate EVERY text string, accelerator etc in this +file (except those marked "Do not translate", of course) - not just +those things which are marked with TTT */ + + +/* TTT: Only used by developers */ +RESOURCE STRING sys_debugging_num_cells {str="Diagnostics: %d (%u)";} + +/********* for Calendar Window in Agenda **********/ + +/* TTT: eg "Calendar 1998" or "Calendar 1993-1994" */ +RESOURCE STRING sys_calendar {str="Calendar %Y";} + +/*********************** FOR PRINT PREVIEW ******************************/ +/* TTT: "Print preview" option in Word, Agenda, Sheet... uses these: */ +RESOURCE STRING sys_page {str="page";} +RESOURCE STRING sys_pages {str="pages";} +RESOURCE STRING sys_preview_busy {str="Busy, cannot print yet";} +RESOURCE STRING sys_display_margins {str="Show margins";} +RESOURCE STRING sys_hide_margins {str="Hide margins";} + +RESOURCE STRING sys_opening_prompt {str="Opening \"%s\"";} + +/* TTT: NB "Print preview" is a standard WP term... if every Wp in your +country uses one term for this, you must use it too */ +RESOURCE STRING sys_print_preview {str="Print preview";} + +/* TTT length of longest in sys_preview_margins_chlist + length of longest +in sys_preview_options_chlist must be less than 50 */ +RESOURCE MENU sys_preview_margins_chlist + { + items= + { + CHOICE_ITEM {str="Margins off";}, + CHOICE_ITEM {str="Margins on";} + }; + } + +RESOURCE MENU sys_preview_options_chlist + { + items= + { + CHOICE_ITEM {str="Facing pages";}, + CHOICE_ITEM {str="1 page";}, + CHOICE_ITEM {str="2 pages";}, + CHOICE_ITEM {str="3 pages";}, + CHOICE_ITEM {str="4 pages";} + }; + } + +RESOURCE DIALOG sys_preview_options_dialog + { + title="Display"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt=""; + info=CHLIST{rid=sys_preview_options_chlist;}; + } + }; + } + +RESOURCE DIALOG sys_preview_jump_dialog + { + title="Jump to page"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Page number"; + info=NCEDIT + { + low=1; + high=9999; + }; + } + }; + } + +RESOURCE WSERV_INFO sys_preview_acc + { + menbar_id=sys_preview_menubar; + first_com=O_PVC_PREVIEW_PRINT; + accel= + { + 'p', /* Print */ + 'm', /* Margins */ + 'd', /* Pages to display */ + 'j', /* Jump to page */ + '*' /* Exit preview */ + }; + } + +RESOURCE MENU_BAR sys_preview_menubar + { + items = + { + MENU_BAR_ITEM + { + menu_id=sys_preview_menu; + mb_item="Preview"; + } + }; + } + +RESOURCE MENU sys_preview_menu + { + items = + { + MENU_ITEM + { + com_id=O_PVC_PREVIEW_PRINT; + mn_item="Print"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_MARGINS; +/* TTT: use whichever's the longer: "Show margins" or "Hide margins" */ + mn_item="Show margins"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_OPTIONS; + mn_item="Pages to display"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_JUMP|BREAK_LINE_FOLLOWS; + mn_item="Jump to page"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_EXIT; + mn_item="Exit preview"; + } + }; + } + +RESOURCE MENU sys_printer_devices + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";}, + CHOICE_ITEM { str= "Fax";} + }; + } + +RESOURCE CONTROL sys_print_control_device + { + class=C_TEXTWIN; +/* TTT: You'll see this on the bottom of the Print Setup dialog +in Word, Agenda... */ + prompt="Printer device"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE CONTROL sys_print_preview_settings + { +/* TTT: You'll see this on the bottom of the Printer configuration dialog +in the Shell */ + class=C_TEXTWIN; + prompt="Print preview"; + info=TXTMESS + { + str="Facing pages,Margins off"; /* TTT widest possible */ + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE DIALOG sys_preview_settings_dl + { + title="Preview settings"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Display"; + info=CHLIST{rid=sys_preview_options_chlist;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Margins"; + info=CHLIST{rid=sys_offon_menu;}; + } + }; + } + +RESOURCE MENU sys_standard_sounds + { + items= + { +/* TTT: Built-in sounds, when you're setting an alarm in Time */ + CHOICE_ITEM {str="Rings";}, + CHOICE_ITEM {str="Chimes";}, + CHOICE_ITEM {str="Fanfare";}, + CHOICE_ITEM {str="Soft bells";}, + CHOICE_ITEM {str="Church bell";} + }; + } + +/* TTT: do not translate */ +RESOURCE STRING sys_alarm_standard_name {str="SYS$AL01";} +/* TTT: The "silent" sound, when setting an alarm */ +RESOURCE STRING sys_silent_alarm {str="Silent";} +/* TTT: If you try to play a sound, but sound is disabled... */ +RESOURCE STRING sys_sound_disabled {str="Sound disabled";} +/* TTT: do not translate the next one */ +RESOURCE STRING sys_word_rom { str="ROM::WORD.APP"; } +/* TTT: the user has refused to replace an SSD */ +RESOURCE STRING sys_restart_from_sys { str="Press Esc to exit application"; } + +/* TTT: when creating a new file: eg gives "Myfile" created +You can change these around if you like, eg we could've done the English +as str="Created \"%s\"" to give Created "Myfile" */ +RESOURCE STRING srt_file_created { str="\"%s\" created"; } +RESOURCE STRING srt_file_opened { str="\"%s\" opened"; } +RESOURCE STRING srt_file_saved { str="\"%s\" saved"; } +RESOURCE STRING srt_file_compressed { str="\"%s\" compressed"; } +RESOURCE STRING srt_file_merged { str="\"%s\" merged in"; } +RESOURCE STRING sys_saving_prompt {str="Saving \"%s\"";} +RESOURCE STRING sys_reloading_prompt {str="Reopening \"%s\"";} +RESOURCE STRING sys_converting_prompt {str="Converting \"%s\"";} + +/* TTT: When we refuse to save the file, because it hasn't changed */ +RESOURCE STRING sys_not_changed {str="Not changed";} +/* TTT: When you're exiting, but it failed to save the file for some reason */ +RESOURCE STRING sys_confirm_continue {str="Not saved, continue anyway?";} +/* TTT: When you're using the "Exit, lose changes" option: */ +RESOURCE STRING sys_confirm_change_loss {str="Confirm the loss of all changes";} +/* TTT: used with the previous two strings */ +RESOURCE STRING sys_losing_changes {str="(`Yes' discards all changes)";} +RESOURCE STRING sys_nothing_to_print {str="Nothing to print";} +RESOURCE STRING sys_nothing_to_insert {str="Nothing to insert";} +RESOURCE STRING sys_nothing_to_copy {str="Nothing to copy";} +/* TTT: preferably use the same word as the "Revert" menu option */ +RESOURCE STRING sys_revert_to_saved {str="Revert to saved?";} + +/* TTT: For use in menus (hotkeys) */ +RESOURCE STRING sys_shift_key_name {str="Shift";} + +/* TTT: When you use "Current country only" (or diamond key) World App... */ +RESOURCE STRING srt_space_only { str=" (only)"; } + +RESOURCE STRING sys_change_password {str="Change password";} + +RESOURCE DIALOG sys_set_password_dl + { + title = "Set password"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + }, + CONTROL + { + class=C_XEDIT; + prompt="Confirm password"; + } + }; + } + +RESOURCE DIALOG sys_get_password_dl + { + title = "Password protected"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + } + }; + } + +/* TTT Extra help - translate this! */ +/* BUT DON'T MAKE THE TEXT WIDER THAN WILL FIT ON COMPATIBILITY MODE SCREENS +(BEAR IN MIND THAT THIS HELP IS AVAILABLE TO COMPATIBILITY MODE APP) */ + +RESOURCE HELP_ARRAY sys_help_evaluate +{ +topic="Calculations (`Evaluate')"; +strlst= +{ +STRING {str="Type a calculation in Data/Word/Agenda";}, +STRING {str="(without `=' or spaces),";}, +STRING {str="then `Evaluate' for result";} +}; +} + +RESOURCE HELP_ARRAY sys_help_memo +{ +topic="Memo editor"; +strlst= +{ +STRING {str="This is like the Word Processor without";}, +STRING {str="a `File' menu. Use `Edit memo' in the Agenda";}, +STRING {str="to create a memo";}, +STRING {str="";}, +STRING {str="Agenda memos can be up to 4K long. One set of";}, +STRING {str="styles is kept for all memos in an agenda file";}, +STRING {str="";}, +STRING {str="Use `Password' to make a memo secure";}, +STRING {str="and use it again to remove or change the password";}, +STRING {str="";}, +STRING {str="Use `Exit' when you've finished the memo";}, +STRING {str="";}, +STRING {str="To delete a memo edit it, delete all text";}, +STRING {str="(`Highlight all text' then the Delete key) and `Exit'";} +}; +} + +RESOURCE HELP_ARRAY sys_help_in_use +{ +topic="File or device in use"; /* TTT copy this from the software please */ +strlst= +{ +STRING {str="You will see this message if you try to";}, +STRING {str="copy, delete or rename a file which is";}, +STRING {str="open (ie in bold on the System screen).";}, +STRING {str="Exit the file first.";}, +STRING {str="";}, +STRING {str="You will also see it if you try";}, +STRING {str="to use, at the same time, two of:";}, +STRING {str="`Remote link' in the System screen";}, +STRING {str="3Link's Comms application";}, +STRING {str="Printing to a serial port printer";} +}; +} + +RESOURCE HELP_ARRAY sys_help_no_sys_mem +{ +topic="No system memory"; /* TTT copy this from the software please */ +strlst= +{ +STRING {str="This message usually means all of your";}, +STRING {str="internal memory has been used up.";}, +STRING {str="Exit some open files, or delete";}, +STRING {str="unwanted files from the `Internal'";}, +STRING {str="disk, to free some more memory";}, +STRING {str="";}, +STRING {str="You may also see this message if a Word";}, +STRING {str="or Sheet file reaches its maximum size.";}, +STRING {str="In this case internal memory is";}, +STRING {str="probably NOT full - the message means the";}, +STRING {str="application has reached its memory limit";}, +STRING {str="";}, +STRING {str="(If an agenda has repeating entries,";}, +STRING {str="`Find' and `Print preview' may also";}, +STRING {str="temporarily cause the Agenda to reach";}, +STRING {str="its memory limit and display this message)";} +}; +} + +RESOURCE HELP_ARRAY sys_help_calendar +{ +topic="Calendars"; +strlst= +{ +STRING {str="Whenever you are entering a date in a dialog, you";}, +STRING {str="can press Tab to display a one month calendar";}, +STRING {str="";}, +STRING {str="Shift-Tab (or a second Tab) gives a three month calendar";}, +STRING {str="Control-Tab (or a third Tab) gives a 12 month calendar";}, +STRING {str="";}, +STRING {str="In the calendars:";}, +STRING {str=""ARROWS" move the cursor around the screen";}, +STRING {str="Psion-"" move a screen at a time";}, +STRING {str="";}, +STRING {str="Shift-"" (or <>) move one day at a time";}, +STRING {str="Shift-"" move by weeks";}, +STRING {str="Control-"" move by months";}, +STRING {str="Control-"" move by years";}, +STRING {str="";}, +STRING {str="Space moves to today";} +}; +} diff --git a/code/SIBOSDK/resource/sc_.rss b/code/SIBOSDK/resource/sc_.rss new file mode 100644 index 0000000..b47a5d4 --- /dev/null +++ b/code/SIBOSDK/resource/sc_.rss @@ -0,0 +1,2012 @@ +SYSTEM +/* +(No comment to be placed on the first line of this file!) + +SC_.RSS + +System Resource file for Series 3c + +*/ + +#include +#include "hwim.rh" +#include +#include "symbols.h" + +STRUCT KEYPAIR + { + BYTE latin; /* Latin character value */ + BYTE cyril; /* Cyrillic character value */ + } + +STRUCT KEYLIST + { + STRUCT list[]; + } + +#define ARROWS4 + +/****************** THE SPECIAL CHARACTERS ************************/ +/* The first four characters are used by the file selector to tag one, +untag one, tag all & untag all. The next four are the "nudge" keys used by +most numeric/date editors. (Two down, two up.) Next is the keycode used in +EDWIN.C to indicate a soft or hard hyphen. NSWE are the compass points used +by the Lat-Long editor. These are followed by the degree symbol used in the +same editor. Next is the bullet symbol used by Help and by the Agenda. +The last two symbols were added in September 1995 to support code pages +other than 850 (esp. 1251 for Russia!). See #define H_SC_TPLUS et seq. +in SYMBOLS.H */ + +/* TTT Leave most of these alone, but translate the NSWE */ + +RESOURCE STRING sys_special_characters { str="+-*/<,>.NSWE"; } + +/************************* STRINGS ********************************/ + +RESOURCE STRING sys_string { str="%s"; } +RESOURCE STRING sys_dimmed_msg {str="This item is not available";} +RESOURCE STRING sys_locked_msg {str="This item cannot be changed";} +RESOURCE STRING sys_busy { str="Busy"; } +RESOURCE STRING sys_scanning { str="Scanning"; } +RESOURCE STRING sys_printing_to { str="Printing to %s";} +RESOURCE STRING sys_page_is { str="(page %u)";} + +RESOURCE STRING sys_copied_prompt {str="Copied";} +RESOURCE STRING sys_copying_prompt {str="Saving as \"%s\"";} +RESOURCE STRING sys_loading_prompt {str="Loading \"%s\"";} +RESOURCE STRING sys_merging_prompt {str="Merging in \"%s\"";} +RESOURCE STRING sys_nothing_to_bring {str="Nothing to bring";} +RESOURCE STRING sys_not_found {str="Not found"; } +RESOURCE STRING sys_nothing_to_find {str="Nothing to find";} + +RESOURCE STRING sys_compress_prompt {str="Compressing \"%s\"";} +RESOURCE STRING sys_not_compressible {str="Cannot compress on Flash";} + +RESOURCE STRING sys_password_incorrect {str="Incorrect password";} +RESOURCE STRING sys_password_not_confirmed {str="Password not confirmed";} + +RESOURCE STRING sys_range_reset {str="Out of range - reset to limit";} +RESOURCE STRING sys_invalid_num {str="Number is not valid";} +RESOURCE STRING sys_invalid_margins { str="Invalid margins. Reset?"; } +RESOURCE STRING sys_invalid_char { str="Undiallable character"; } +RESOURCE STRING sys_out_of_range {str="Value out of range: %s = %s";} +/* as used in "Value out of range: Max = 20.45 */ + +RESOURCE STRING sys_edit_nchars {str="Maximum number of characters reached";} + +RESOURCE STRING sys_popout_help {str="Press Tab to change this item";} + +RESOURCE STRING sys_help_string {str="Help: %s";} + +RESOURCE STRING sys_replace_disk {str="Replace the application disk";} + +/* the prompts for a file selector and a pack selector */ +RESOURCE STRING sys_name {str="Name";} +RESOURCE STRING sys_pack {str="Disk";} + +/* part of the title line of a filelist */ +RESOURCE STRING sys_filelist_disk {str="Disk ";} + +RESOURCE STRING sys_flist_reset { str="File list reset"; } +RESOURCE STRING sys_device_memory { str="Internal"; } +RESOURCE STRING sys_path_is { str="Path is %s"; } +RESOURCE STRING sys_choose_directory { str="Choose a directory"; } +RESOURCE STRING sys_choose_filename { str="Choose a filename"; } +RESOURCE STRING sys_choose_new_directory { str="Directory already exists"; } +RESOURCE STRING sys_exists_over { str="File already exists: overwrite?"; } + +/* Next two strings have a maximum length of 5 characters each */ +RESOURCE STRING sys_max { str="Max"; } +RESOURCE STRING sys_min { str="Min"; } + +RESOURCE STRING sys_dec_places { str="Decimal places"; } +RESOURCE STRING sys_sig_digits { str="Significant digits"; } +RESOURCE STRING sys_evaldlg_title { str="Set \"Evaluate\" format"; } +RESOURCE STRING sys_nothing_to_eval { str="Nothing to evaluate"; } +RESOURCE STRING sys_toolong_to_eval { str="Too long to evaluate"; } + +RESOURCE STRING sys_xonxoff_string {str="XON/XOFF ";} +RESOURCE STRING sys_header_str { str="Enter header details"; } +RESOURCE STRING sys_footer_str { str="Enter footer details"; } + +/* max len of next 2 strs is 9 (including the space and the brackets) */ +RESOURCE STRING sys_centimetres { str=" (cm)"; } +RESOURCE STRING sys_inches { str=" (inches)"; } + +RESOURCE STRING sys_dev_notready { str=" Absent!"; } +RESOURCE STRING sys_dev_corrupt { str=" Unformatted!"; } +RESOURCE STRING sys_dev_unknown { str=" Unrecognised!"; } +RESOURCE STRING sys_dev_info { str=", %luK free"; } + +RESOURCE STRING sys_mtype_unknown { str="Unknown"; } +RESOURCE STRING sys_mtype_floppy { str="Floppy"; } +RESOURCE STRING sys_mtype_hard { str="Hard"; } +RESOURCE STRING sys_mtype_flash { str="Flash"; } +RESOURCE STRING sys_mtype_ram { str="Ram"; } +RESOURCE STRING sys_mtype_rom { str="Rom"; } +RESOURCE STRING sys_mtype_protected { str="Protected"; } +/* Maximum of 14 character widths for the following 5 strings */ +RESOURCE STRING sys_files_tagged { str="(Tagged files)"; } +RESOURCE STRING sys_no_files { str="(No files)"; } +RESOURCE STRING sys_no_disk { str="(No disk)"; } +RESOURCE STRING sys_unformatted { str="(Unformatted)"; } +RESOURCE STRING sys_unrecognised { str="(Unrecognised)"; } + +RESOURCE STRING sys_sound_fail { str="Sound in use - please retry"; } + +/*********** THE ALLOWED SPECIAL KEYS FOR ACTION BUTTONS ******************/ + +/* You can translate the text, but no more than six characters each */ + +RESOURCE ACLIST_ARRAY sys_button_text + { + button= + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Enter"; + }, + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Esc"; + }, + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Del"; + }, + PUSH_BUT + { + keycode=W_KEY_SPACE; + str="Space"; + }, + PUSH_BUT + { + keycode=W_KEY_UP; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_DOWN; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_RIGHT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_LEFT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Tab"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Menu"; + } + }; + } + + +/************************* ACTION LISTS ******************************/ + +/* Change the keycodes too, but don't lose the minus signs */ + +RESOURCE ACLIST_ARRAY sys_ac_no_yes + { + button = + { + PUSH_BUT + { + keycode=-'n'; + str="No"; + }, + PUSH_BUT + { + keycode='y'; + str="Yes"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_continue + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Continue"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_abandon + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Abandon"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_append_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Append"; + } + }; + } + +/* Careful not to make the combined width of these strings much wider */ + +RESOURCE ACLIST_ARRAY sys_smart_dial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Cancel"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Free input"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Dial"; + }, + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Dial out"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_freedial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Clear"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Redial"; + } + }; + } + +/************************* CHOICE LISTS *****************************/ + +RESOURCE MENU sys_no_yes + { + items = + { + CHOICE_ITEM { str= "No";}, + CHOICE_ITEM { str="Yes";} + }; + } + +RESOURCE MENU sys_offon_menu + { + items = + { + CHOICE_ITEM { str="Off";}, + CHOICE_ITEM { str= "On";} + }; + } + +RESOURCE MENU sys_printer_units_chlist + { + items = + { + CHOICE_ITEM { str= "Inches";}, /* matches with E_IMPERIAL */ + CHOICE_ITEM { str= "Centimetres";} /* matches with E_METRIC */ + }; + } + +RESOURCE MENU sys_printer_device_chlist + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";} + }; + } + + +RESOURCE MENU sys_baud_rate_chlist + { + items = + { + CHOICE_ITEM { str= "19200";}, /* new for S3a */ + CHOICE_ITEM { str= "9600";}, + CHOICE_ITEM { str= "4800";}, + CHOICE_ITEM { str= "2400";}, + CHOICE_ITEM { str= "1200";}, + CHOICE_ITEM { str= "600";}, + CHOICE_ITEM { str= "300";} + }; + } + +RESOURCE MENU sys_data_bits_chlist + { + items = + { + CHOICE_ITEM { str="5";}, + CHOICE_ITEM { str="6";}, + CHOICE_ITEM { str="7";}, + CHOICE_ITEM { str="8";} + }; + } + +RESOURCE MENU sys_stop_bits_chlist + { + items = + { + CHOICE_ITEM { str="1";}, + CHOICE_ITEM { str="2";} + }; + } + +RESOURCE MENU sys_parity_chlist + { + items = + { + CHOICE_ITEM { str="None";}, + CHOICE_ITEM { str="Even";}, + CHOICE_ITEM { str= "Odd";} + }; + } + +RESOURCE MENU sys_format_chlist + { + items = + { + CHOICE_ITEM { str="Fixed";}, + CHOICE_ITEM { str="Scientific";}, + CHOICE_ITEM { str="General";}, + CHOICE_ITEM { str="Hexadecimal";} + }; + } + +RESOURCE MENU sys_rad_deg + { + items = + { + CHOICE_ITEM { str= "Radians";}, + CHOICE_ITEM { str= "Degrees";} + }; + } + +/* IMPORTANT, order in next array must be same as in page_size menu below */ +/* Also, at most 10 entries allowed, and the first two cannot be altered */ +/* But change any of the others, if you wish */ +/* 1 mm is 1440/25.4 units in the dimensions used, so eg 148 mm is 8391 */ +/* so you could have {width=8391; ... for one entry (an A5 letter size) */ + +RESOURCE PAGE_SIZE_ARRAY sys_page_dimensions + { + page_size= + { + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_EXECUTIVE; length=PAGE_LENGTH_EXECUTIVE;}, + PAGE_SIZE {width=PAGE_WIDTH_LEGAL; length=PAGE_LENGTH_LEGAL;}, + PAGE_SIZE {width=PAGE_WIDTH_LETTER; length=PAGE_LENGTH_LETTER;}, + PAGE_SIZE {width=PAGE_WIDTH_MONARCH; length=PAGE_LENGTH_MONARCH;}, + PAGE_SIZE {width=PAGE_WIDTH_DL; length=PAGE_LENGTH_DL;} + }; + } + +RESOURCE MENU sys_page_size + { + items= + { + CHOICE_ITEM {str="A4";}, + CHOICE_ITEM {str="Custom";}, + CHOICE_ITEM {str="Executive";}, + CHOICE_ITEM {str="Legal";}, + CHOICE_ITEM {str="Letter";}, + CHOICE_ITEM {str="Monarch";}, + CHOICE_ITEM {str="DL";} + }; + } + +RESOURCE MENU sys_orient + { + items= + { + CHOICE_ITEM {str="Portrait";}, + CHOICE_ITEM {str="Landscape";} + }; + } + +RESOURCE MENU sys_prn_pos + { + items= + { + CHOICE_ITEM {str="Normal";}, + CHOICE_ITEM {str="Superscript";}, + CHOICE_ITEM {str="Subscript";} + }; + } + +RESOURCE MENU sys_headfoot_align + { + items= + { + CHOICE_ITEM {str="Left";}, + CHOICE_ITEM {str="Right";}, + CHOICE_ITEM {str="Centred";}, + CHOICE_ITEM {str="Justified";}, + CHOICE_ITEM {str="Two column";}, + CHOICE_ITEM {str="Three column";} + }; + } + +RESOURCE MENU sys_pgno_choice + { + items= + { + CHOICE_ITEM {str="1,2,3";}, + CHOICE_ITEM {str="I,II,III";}, + CHOICE_ITEM {str="i,ii,iii";} + }; + } + +/************************* DIALOGS ********************************/ + +RESOURCE DIALOG sys_error_dialog + { + flags=DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_continue; + }; + } + }; + } + +RESOURCE DIALOG sys_query_dialog + { + flags = DLGBOX_ACTION_LIST|DLGBOX_REPORT_ACT_HORIZ; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_no_yes; + }; + } + }; + } + +RESOURCE DIALOG sys_printing_dialog + { + flags=DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_abandon; + }; + } + }; + } + +RESOURCE DIALOG sys_set_port_dialog + { + title="Set Serial port"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Baud rate"; + info=CHLIST + { + rid=sys_baud_rate_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Data bits"; + info=CHLIST + { + rid=sys_data_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Stop bits"; + info=CHLIST + { + rid=sys_stop_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Parity"; + info=CHLIST + { + rid=sys_parity_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Ignore parity"; + info=CHLIST + { + rid=sys_no_yes; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_set_hshk_dialog + { + title="Set serial handshake"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="XON/XOFF"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="RTS/CTS"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="DSR/DTR"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="DCD"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_printer_config_dialog + { + title="Printer configuration"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Printer device"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + info=CHLIST + { + rid=sys_printer_device_chlist; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial characteristics "; + info=TXTMESS + { + str="19200 "; /* changed for S3a */ + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial handshaking "; + info=TXTMESS + { + str="XON/XOFF Off "; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK|DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_FNEDIT; + prompt="File:"; + info=FNEDIT { flags=IN_FNEDIT_NO_AUTOQUERY; }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Units"; + info=CHLIST + { + rid=sys_printer_units_chlist; + }; + } + }; + } + +RESOURCE DIALOG sys_eval_dialog + { + title="Set Calculator format"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Format"; + info=CHLIST { rid=sys_format_chlist; }; + }, + CONTROL + { + class=C_NCEDIT; + /* The following line must be the wider of the 2 above strings */ + /* sys_dec_places and sys_sig_digits */ + prompt="Significant digits"; + info=NCEDIT + { + high=12; + low=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Trigonometry units"; + info=CHLIST { rid=sys_rad_deg; }; + } + }; + } + +RESOURCE DIALOG sys_country_selector_dialog + { + title="Append country"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_WLDSELWN; + prompt="Country"; + info=WLDSELWN {flags=IN_WLDSELWN_COUNTRY|IN_WLDSELWN_SETHOME; }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_append_aclist; + }; + } + }; + } + +RESOURCE CONTROL sys_smart_dial_item + { + class=C_EDWIN; + prompt=; + info=EDWIN + { + maxlen=WR_MAX_DIAL_STRING; + vulen=20; + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_NO_AUTOSELECT; + }; + } + +RESOURCE DIALOG sys_smart_dial_dialog + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="Dial"; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_smart_dial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_freedial_dialog + { + title="Free-form dialling"; + flags = DLGBOX_NO_WAIT|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_FREEDIAL; + prompt=; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_freedial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_flist_dialog + { + title="Specify filelist"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Filename pattern"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + }, + CONTROL + { + class=C_EDWIN; + prompt="Full path"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + } + }; + } + +RESOURCE DIALOG sys_print_control_dl + { + title="Print setup"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_NOTIFY_ESCAPE|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + prompt="Page size"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Margins"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Header"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Footer"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Paging control"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Printer model"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_paging_control_dl + { + title="Paging control"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Number for first page"; + info=NCEDIT + { + low=1; + high=9999; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Allow widows/orphans"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Page number style"; + info=CHLIST{rid=sys_pgno_choice;}; + } + }; + } + +RESOURCE DIALOG sys_printer_model + { + title="Set printer"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + prompt="Select printer"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + info=CHLIST{}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Default font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_margins_dl + { + title="Margins"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_FLTEDIT; + prompt="Top"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Left"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Right"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Bottom"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_headfoot_dl + { + title="*"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Text"; + info=EDWIN + { + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_ACCEPT_TABS; + maxlen=80; + vulen=20; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Alignment"; + info=CHLIST{rid=sys_headfoot_align;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="On first page"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Vertical offset"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_pagesize_dl + { + title="Page size"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_CHLIST; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + prompt="Page size"; + info=CHLIST{rid=sys_page_size;}; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Width"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Height"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Orientation"; + info=CHLIST{rid=sys_orient;}; + } + }; + } + +RESOURCE DIALOG sys_font_dl + { + title="Font"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Font"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Size"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Underline"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Bold"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Italic"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Print position"; + info=CHLIST{rid=sys_prn_pos;}; + } + }; + } + +RESOURCE CONTROL sys_txtmess + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + } + +/************************* HELP ********************************/ + +RESOURCE TOPIC_ARRAY sys_help_index_data +{ +id_lst= +{ +sys_help_on_off, +sys_time_basics, +sys_help_infrared, +sys_help_edit, +sys_help_dialog, +sys_help_statwin, +sys_help_files, +sys_help_filsels, +sys_help_evaluate, +sys_help_print, +sys_help_in_use, +sys_help_appnotready, +sys_help_dialling, +sys_help_no_sys_mem +}; +} + +RESOURCE HELP_ARRAY sys_help_index +{ +topic="Index"; +topic_id=sys_help_index_data; +} + +RESOURCE HELP_ARRAY sys_help_on_help +{ +topic="Using Help"; +strlst= +{ +STRING {str="To choose a topic: press "" keys, then Enter.";}, +STRING {str="";}, +STRING {str="The help topics should help you to perform your tasks. In";}, +STRING {str="each topic, menus and menu options are shown in";}, +STRING {str="apostrophes, eg `File'; other help topics are shown in double";}, +STRING {str="quotes, eg \"Basics\".";}, +STRING {str="";}, +STRING {str="A small arrow pointing up or down in the top or bottom";}, +STRING {str="right-hand corners of the help window means that there is";}, +STRING {str="more text.";}, +STRING {str="";}, +STRING {str="Press Esc to return to the previous Help screen.";}, +STRING {str="Control-Esc exits Help.";}, +STRING {str="";}, +STRING {str="Press Control-Help for an alphabetical index. Note: this";}, +STRING {str="works from each main application screen and may also";}, +STRING {str="include general help topics.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialog +{ +topic="Commands & actions"; +strlst= +{ +STRING {str="Press Menu key to see a menu of command options, use """;}, +STRING {str="to select an option, then press Enter.";}, +STRING {str="";}, +STRING {str="Some options work straight away; others display a \"dialog\"";}, +STRING {str="for more information. See \"Entering information\".";}, +STRING {str="Use \"hot-key\", eg ""-N, listed beside option to access it";}, +STRING {str="directly (hold down "" key and press letter).";} +}; +} + +RESOURCE HELP_ARRAY sys_help_statwin +{ +topic="Screen display"; +strlst= +{ +STRING {str="Use ""-> and ""-< to change contrast.";}, +STRING {str="";}, +STRING {str="Press "" to switch between \"views\" in an application.";}, +STRING {str="";}, +STRING {str="Use `Zoom in/out' to change size of text.";}, +STRING {str="";}, +STRING {str="In the System screen and most applications, a Status";}, +STRING {str="window can be displayed, showing general status information,";}, +STRING {str="eg time, date etc.";}, +STRING {str="To switch it on: use Control-Menu.";}, +STRING {str="To reduce its size: press Control-Menu again.";}, +STRING {str="To switch it off: press Control-Menu once more.";}, +STRING {str="To display it temporarily: use ""-Menu.";}, +STRING {str="To set up what is displayed in the Status window: use `Status";}, +STRING {str="window' option in the System screen.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialling +{ +topic="Dialling telephone numbers"; +strlst= +{ +STRING {str="The Series 3c can generate the sounds used when dialling";}, +STRING {str="from push-button telephones.";}, +STRING {str="To dial a number marked with a telephone symbol "":";}, +STRING {str="Find an entry in Data/Agenda then press Dial (""-Help).";}, +STRING {str="";}, +STRING {str="To insert a "" before entering a number to mark an entry,";}, +STRING {str="press Shift-""-Help.";}, +STRING {str="To dial a number you enter: press Control-""-Help and type";}, +STRING {str="in the number to dial.";}, +STRING {str="To use a dial out code (eg if you are dialling from work): set";}, +STRING {str="the `Dialling' details in the System screen.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_filsels +{ +topic="Entering information"; +strlst= +{ +STRING {str="Start the application for the data you want to enter, eg";}, +STRING {str="Agenda, and simply type your data in. When the Series 3c";}, +STRING {str="needs information, it will display a \"dialog\".";}, +STRING {str="";}, +STRING {str="Press Enter to accept the settings in a dialog.";}, +STRING {str="Press Esc to remove the dialog without setting new";}, +STRING {str="information.";}, +STRING {str="In dialogs:";}, +STRING {str="Some lines have arrows around settings, eg `All sound " " On ""'.";}, +STRING {str="Press "" or "" to change the setting or press Tab to display a";}, +STRING {str="list. When a list is displayed, use "" to highlight";}, +STRING {str="an option, then press Enter to select it.";}, +STRING {str="";}, +STRING {str="When entering dates, press Tab to display a calendar then:";}, +STRING {str=""" moves the cursor around the calendar.";}, +STRING {str="Spacebar moves to today.";}, +STRING {str="""-"" moves a month at a time.";}, +STRING {str=""" moves a week at a time.";}, +STRING {str="Press Enter when you've found the date.";}, +STRING {str="";}, +STRING {str="For filenames in dialogs, Shift-Tab gives full path of file.";}, +STRING {str="Press Tab to choose from a list of files.";}, +STRING {str="Type first letter of filename to move highlight to that file;";}, +STRING {str="Shift+letter to move to a directory; Control+letter to move to";}, +STRING {str="a disk.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_edit +{ +topic="Editing text"; +strlst= +{ +STRING {str="Use "" to move cursor.";}, +STRING {str="Control "" to move a word at a time.";}, +STRING {str="";}, +STRING {str="Shift-"" to highlight text, then use:";}, +STRING {str="Delete to cut it to the clipboard (or `Copy' to copy it), then";}, +STRING {str="`Insert' to \"paste\" the text back in; use Shift-Delete to delete";}, +STRING {str="text without changing what's on the \"clipboard\".";}, +STRING {str="";}, +STRING {str="To copy text from another application: highlight text to copy";}, +STRING {str="in the other application, then use `Bring' option to insert text";}, +STRING {str="at cursor position.";}, +STRING {str="";}, +STRING {str="Quick delete methods (without highlighting):";}, +STRING {str="Shift-Delete: character forwards";}, +STRING {str="Shift-""-Delete: to end of line";}, +STRING {str="""-Delete: to beginning of line";}, +STRING {str="";}, +STRING {str="Quick highlight methods:";}, +STRING {str="Shift-Control-Home: current word";}, +STRING {str="Shift-Control-End: current paragraph";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_help +{ +id_lst= +{ +sys_help_on_help +}; +} + +RESOURCE HELP_ARRAY sys_help_files +{ +topic="Managing files"; +strlst= +{ +STRING {str="All your information is stored in files. Most files you can work";}, +STRING {str="on are listed under the application icons in the System screen.";}, +STRING {str="Note: \"Files\" on the System screen is the file manager application.";}, +STRING {str="";}, +STRING {str="To create a new file: use `New file' on `File' menu in the";}, +STRING {str="System screen or in the application.";}, +STRING {str="To save a file: use `Save' or `Save as' in the application.";}, +STRING {str="To open a file: highlight its name and press Enter on System";}, +STRING {str="screen or use `Open file' in the application.";}, +STRING {str="To exit a file: highlight bold filename in System screen and";}, +STRING {str="press Delete.";}, +STRING {str="To copy, move or delete files: highlight filename and use `File'";}, +STRING {str="menu options in the System screen.";}, +STRING {str="";}, +STRING {str="Press Tab on System screen for File selector:";}, +STRING {str="Menu gives file/directory options. Use + - (or Shift "" to";}, +STRING {str="tag/untag files. * / tag/untag all files.";}, +STRING {str="Files are stored on disk in \"directories\".";}, +STRING {str="Each application has an associated file extension, eg DAT for";}, +STRING {str="Data files.";}, +STRING {str="To find out others: highlight the application icon in the";}, +STRING {str="System screen and use `About application' to show directory";}, +STRING {str="and file extension. Note: filename extensions are not listed in";}, +STRING {str="the System screen.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_print +{ +topic="Printing/previewing"; +strlst= +{ +STRING {str="Set your printer configuration using `Printer' in the System";}, +STRING {str="screen.";}, +STRING {str="";}, +STRING {str="In applications which can Print, first use `Print setup' on";}, +STRING {str="`Special' menu to set `Printer model'.";}, +STRING {str="";}, +STRING {str="Use `Print preview' to see a preview; it has its own menu of";}, +STRING {str="options (including `Print'). Note: you don't have to wait for";}, +STRING {str="the preview to finish calculating - Esc cancels.";}, +STRING {str="";}, +STRING {str="Use %D and %T in headers and footers (part of `Print setup')";}, +STRING {str="to print the date and time automatically.";}, +STRING {str="Other codes include:";}, +STRING {str="%F for the filename";}, +STRING {str="%P for the page number";}, +STRING {str="%% for a % character";}, +STRING {str="In Word or Sheet, you can use %M for total pages in a file. Eg in";}, +STRING {str="a file 6 pages long, `Page %P of %M' prints `Page 1 of 6'";}, +STRING {str="on the first page.";} +}; +} + +RESOURCE HELP_ARRAY sys_time_basics +{ +topic="Date & time settings"; +strlst= +{ +STRING {str="In Time, set `Home city', then set `Time and date'.";}, +STRING {str="";}, +STRING {str="Set `Summer times' on/off when they change.";}, +STRING {str="";}, +STRING {str="Use `Formats' to set 12/24 hour clocks.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_on_off +{ +topic="Turning on & off"; +strlst= +{ +STRING {str="Press ON/Esc or an application button to turn on; OFF (""-1)";}, +STRING {str="to turn off.";}, +STRING {str="";}, +STRING {str="In the System screen, use `Auto switch off' to make the";}, +STRING {str="Series 3c switch off after a certain period without a";}, +STRING {str="keypress; this will save battery power.";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_index +{ +id_lst= +{ +sys_help_index +}; +} + +/************************* LATER ADDITIONS ********************************/ + +/* Name of general printer driver */ +RESOURCE STRING sys_wdr_general { str="General"; } + +RESOURCE STRING sys_dial_out { str="9,"; } /* 5 chars max */ + +RESOURCE STRING sys_skipping_page { str="(skipping page %u)";} + +/************************* NEW FOR XWIM ********************************/ + +/* TTT: Only used by developers */ +RESOURCE STRING sys_debugging_num_cells {str="Diagnostics: %d (%u)";} + +/********* for Calendar Window in Agenda **********/ + +/* TTT: eg "Calendar 1998" or "Calendar 1993-1994" */ +RESOURCE STRING sys_calendar {str="Calendar %Y";} + +/*********************** FOR PRINT PREVIEW ******************************/ +/* TTT: "Print preview" option in Word, Agenda, Sheet... uses these: */ +RESOURCE STRING sys_page {str="page";} +RESOURCE STRING sys_pages {str="pages";} +RESOURCE STRING sys_preview_busy {str="Busy, cannot print yet";} +RESOURCE STRING sys_display_margins {str="Show margins";} +RESOURCE STRING sys_hide_margins {str="Hide margins";} + +RESOURCE STRING sys_opening_prompt {str="Opening \"%s\"";} + +/* TTT: NB "Print preview" is a standard WP term... if every Wp in your +country uses one term for this, you must use it too */ +RESOURCE STRING sys_print_preview {str="Print preview";} + +/* TTT length of longest in sys_preview_margins_chlist + length of longest +in sys_preview_options_chlist must be less than 50 */ +RESOURCE MENU sys_preview_margins_chlist + { + items= + { + CHOICE_ITEM {str="Margins off";}, + CHOICE_ITEM {str="Margins on";} + }; + } + +RESOURCE MENU sys_preview_options_chlist + { + items= + { + CHOICE_ITEM {str="Facing pages";}, + CHOICE_ITEM {str="1 page";}, + CHOICE_ITEM {str="2 pages";}, + CHOICE_ITEM {str="3 pages";}, + CHOICE_ITEM {str="4 pages";} + }; + } + +RESOURCE DIALOG sys_preview_options_dialog + { + title="Display"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt=""; + info=CHLIST{rid=sys_preview_options_chlist;}; + } + }; + } + +RESOURCE DIALOG sys_preview_jump_dialog + { + title="Jump to page"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Page number"; + info=NCEDIT + { + low=1; + high=9999; + }; + } + }; + } + +RESOURCE WSERV_INFO sys_preview_acc + { + menbar_id=sys_preview_menubar; + first_com=O_PVC_PREVIEW_PRINT; + accel= + { + 'p', /* Print */ + 'm', /* Margins */ + 'd', /* Pages to display */ + 'j', /* Jump to page */ + '*' /* Exit preview */ + }; + } + +RESOURCE MENU_BAR sys_preview_menubar + { + items = + { + MENU_BAR_ITEM + { + menu_id=sys_preview_menu; + mb_item="Preview"; + } + }; + } + +RESOURCE MENU sys_preview_menu + { + items = + { + MENU_ITEM + { + com_id=O_PVC_PREVIEW_PRINT; + mn_item="Print"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_MARGINS; +/* TTT: use whichever's the longer: "Show margins" or "Hide margins" */ + mn_item="Show margins"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_OPTIONS; + mn_item="Pages to display"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_JUMP|BREAK_LINE_FOLLOWS; + mn_item="Jump to page"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_EXIT; + mn_item="Exit preview"; + } + }; + } + +RESOURCE MENU sys_printer_devices + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";}, + CHOICE_ITEM { str= "Fax";} + }; + } + +RESOURCE CONTROL sys_print_control_device + { + class=C_TEXTWIN; +/* TTT: You'll see this on the bottom of the Print Setup dialog +in Word, Agenda... */ + prompt="Printer device"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE CONTROL sys_print_preview_settings + { +/* TTT: You'll see this on the bottom of the Printer configuration dialog +in the Shell */ + class=C_TEXTWIN; + prompt="Print preview"; + info=TXTMESS + { + str="Facing pages,Margins off"; /* TTT widest possible */ + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE DIALOG sys_preview_settings_dl + { + title="Preview settings"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Display"; + info=CHLIST{rid=sys_preview_options_chlist;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Margins"; + info=CHLIST{rid=sys_offon_menu;}; + } + }; + } + +RESOURCE MENU sys_standard_sounds + { + items= + { +/* TTT: Built-in sounds, when you're setting an alarm in Time */ + CHOICE_ITEM {str="Rings";}, + CHOICE_ITEM {str="Chimes";}, + CHOICE_ITEM {str="Fanfare";}, + CHOICE_ITEM {str="Soft bells";}, + CHOICE_ITEM {str="Church bell";} + }; + } + +/* TTT: do not translate */ +RESOURCE STRING sys_alarm_standard_name {str="SYS$AL01";} +/* TTT: The "silent" sound, when setting an alarm */ +RESOURCE STRING sys_silent_alarm {str="Silent";} +/* TTT: If you try to play a sound, but sound is disabled... */ +RESOURCE STRING sys_sound_disabled {str="Sound disabled";} +/* TTT: do not translate the next one */ +RESOURCE STRING sys_word_rom { str="ROM::WORD.APP"; } +/* TTT: the user has refused to replace an SSD */ +RESOURCE STRING sys_restart_from_sys { str="Press Esc to exit application"; } + +/* TTT: when creating a new file: eg gives "Myfile" created +You can change these around if you like, eg we could've done the English +as str="Created \"%s\"" to give Created "Myfile" */ +RESOURCE STRING srt_file_created { str="\"%s\" created"; } +RESOURCE STRING srt_file_opened { str="\"%s\" opened"; } +RESOURCE STRING srt_file_saved { str="\"%s\" saved"; } +RESOURCE STRING srt_file_compressed { str="\"%s\" compressed"; } +RESOURCE STRING srt_file_merged { str="\"%s\" merged in"; } +RESOURCE STRING sys_saving_prompt {str="Saving \"%s\"";} +RESOURCE STRING sys_reloading_prompt {str="Reopening \"%s\"";} +RESOURCE STRING sys_converting_prompt {str="Converting \"%s\"";} + +/* TTT: When we refuse to save the file, because it hasn't changed */ +RESOURCE STRING sys_not_changed {str="Not changed";} +/* TTT: When you're exiting, but it failed to save the file for some reason */ +RESOURCE STRING sys_confirm_continue {str="Not saved, continue anyway?";} +/* TTT: When you're using the "Exit, lose changes" option: */ +RESOURCE STRING sys_confirm_change_loss {str="Confirm the loss of all changes";} +/* TTT: used with the previous two strings */ +RESOURCE STRING sys_losing_changes {str="(`Yes' discards all changes)";} +RESOURCE STRING sys_nothing_to_print {str="Nothing to print";} +RESOURCE STRING sys_nothing_to_insert {str="Nothing to insert";} +RESOURCE STRING sys_nothing_to_copy {str="Nothing to copy";} +/* TTT: preferably use the same word as the "Revert" menu option */ +RESOURCE STRING sys_revert_to_saved {str="Revert to saved?";} + +/* TTT: For use in menus (hotkeys) */ +RESOURCE STRING sys_shift_key_name {str="Shift";} + +/* TTT: When you use "Current country only" (or diamond key) World App... */ +RESOURCE STRING srt_space_only { str=""; } + +RESOURCE STRING sys_change_password {str="Change password";} + +RESOURCE DIALOG sys_set_password_dl + { + title = "Set password"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + }, + CONTROL + { + class=C_XEDIT; + prompt="Confirm password"; + } + }; + } + +RESOURCE DIALOG sys_get_password_dl + { + title = "Password protected"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + } + }; + } + +/* TTT Extra help - translate this! */ +/* BUT DON'T MAKE THE TEXT WIDER THAN WILL FIT ON COMPATIBILITY MODE SCREENS +(BEAR IN MIND THAT THIS HELP IS AVAILABLE TO COMPATIBILITY MODE APP) */ + +RESOURCE HELP_ARRAY sys_help_evaluate +{ +topic="Calculations - Using `Evaluate'"; +strlst= +{ +STRING {str="Use `Evaluate' to work out the result of a calculation as you";}, +STRING {str="type it in, eg in Word.";}, +STRING {str="";}, +STRING {str="Type a calculation (without = or spaces), then use `Evaluate'";}, +STRING {str="on `Edit' menu for result.";}, +STRING {str="";}, +STRING {str="To set the format for results: set `\"Evaluate\" format' in the";}, +STRING {str="System screen.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_memo +{ +topic="Memo editor"; +strlst= +{ +STRING {str="Put cursor on entry and use `Edit memo' in Agenda to create";}, +STRING {str="a memo for an entry, eg meeting notes.";}, +STRING {str="";}, +STRING {str="Agenda memos can be up to 4K long. One set of styles is kept";}, +STRING {str="for all memos in an Agenda file.";}, +STRING {str="";}, +STRING {str="Use `Password' to protect a memo and use it again to remove";}, +STRING {str="or change the password.";}, +STRING {str="";}, +STRING {str="Use `Exit' when you've finished the memo.";}, +STRING {str="";}, +STRING {str="To delete a memo, edit it, delete all text in Memo editor";}, +STRING {str="(`Highlight all text', then press Delete key) and `Exit'.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_in_use +{ +topic="File or device in use"; +strlst= +{ +STRING {str="You will see this message if you try to copy, delete or rename";}, +STRING {str="a file which is open (ie in bold on the System screen). Exit the";}, +STRING {str="file first.";}, +STRING {str="";}, +STRING {str="You will also see it if you have used `Communications' in";}, +STRING {str="System screen to set `Link cable', and then try to print to a";}, +STRING {str="serial port printer.";}, +STRING {str="Set `Use' line in `Communications' to `None' before printing.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_no_sys_mem +{ +topic="No system memory"; +strlst= +{ +STRING {str="This message usually means all your Internal memory has";}, +STRING {str="been used up. Exit some open files, or delete unwanted files";}, +STRING {str="from the Internal disk, to free some more memory.";}, +STRING {str="";}, +STRING {str="It may also appear if a Word or Sheet file reaches its";}, +STRING {str="maximum size. In this case Internal memory is probably NOT";}, +STRING {str="full - the message means the application has reached its";}, +STRING {str="memory limit. You will need to split the file.";}, +STRING {str="";}, +STRING {str="(If an Agenda has repeating entries, `Find' and `Print preview'";}, +STRING {str="may also temporarily cause the Agenda to reach its memory";}, +STRING {str="limit and display this message.)";} +}; +} + +RESOURCE HELP_ARRAY sys_help_calendar +{ +topic="Calendars"; +strlst= +{ +STRING {str="Whenever you are entering a date in a dialog, you can press";}, +STRING {str="Tab to display a calendar.";}, +STRING {str="";}, +STRING {str="In the calendars:";}, +STRING {str=""" move the cursor around the screen;";}, +STRING {str="Psion-"" move a month at a time;";}, +STRING {str="Shift-"" (or <>) move one day at a time;";}, +STRING {str="Shift-"" move by weeks;";}, +STRING {str="Control-"" move by months;";}, +STRING {str="Control-"" move by years.";}, +STRING {str="";}, +STRING {str="Spacebar moves to today.";} +}; +} + +/************************* NEW FOR Workabout **************************/ +/* INCLUDED IN ALL BUILDS, BUT DUMMY RESOURCES USED FOR OTHER BUILDS */ + +RESOURCE DIALOG sys_s3c_print_control_dl + { + title=""; + } + + RESOURCE STRING sys_s3c_page_setup { str=""; } + +RESOURCE HELP_ARRAY sys_help_battery +{ + topic=""; +} + +/************************* NEW FOR Siena ******************************/ +/* INCLUDED IN ALL BUILDS, BUT DUMMY RESOURCES USED FOR OTHER BUILDS */ + +RESOURCE DIALOG sys_vine_file_info_dl + { + title=""; + } + +RESOURCE KEYLIST sys_russian_keys +{ +/* Used in Russian model to map between keyboard modes (latin and cyrillic) + + Used by Siena to map menu keys < > and , to . ? and ' + This is necessary when menu is on screen and user presses unmodified key + hoping to highlight relevent menu option +*/ + +} + + +RESOURCE HELP_ARRAY sys_help_infrared +{ +topic="Infrared"; +strlst= +{ +STRING {str="Lets you copy information to and from another Psion that";}, +STRING {str="has Infrared.";}, +STRING {str="";}, +STRING {str="To turn Infrared on: select `Communications' in the System";}, +STRING {str="screen and set the `Use' line to `Psion IR'. Note: Leave `Power";}, +STRING {str="setting' set to `High'.";}, +STRING {str="";}, +STRING {str="To use Infrared: select the data to copy, then transfer it.";}, +STRING {str="";}, +STRING {str="To select:";}, +STRING {str=""" File - highlight its name in the System screen.";}, +STRING {str=""" Agenda entry - put the cursor on the entry. The copied entry";}, +STRING {str="will have the same date, time and alarm as the original.";}, +STRING {str=""" Data entry - find the entry, or highlight specific text in an entry.";}, +STRING {str=""" Information in other applications - just highlight the text";}, +STRING {str="in Word & Program, the calculation or result in Calc, or the";}, +STRING {str="cell(s) in Sheet.";}, +STRING {str="";}, +STRING {str="To transfer the data:";}, +STRING {str="Point the Series 3c and the other Psion at each other and";}, +STRING {str="make sure they are less than 60cm (2 feet) apart.";}, +STRING {str="Press Psion-Tab on the sending Series 3c, then "".";}, +STRING {str="On the receiving Psion, move to appropriate application for";}, +STRING {str="information, or the System screen to receive a whole file, then";}, +STRING {str="use Infrared receive (Psion-Tab, then "").";} +}; +} + +RESOURCE HELP_ARRAY sys_help_appnotready +{ +topic="Application not ready"; +strlst= +{ +STRING {str="You will see this message if you try to use Infrared when:";}, +STRING {str=""" a dialog is being displayed in the receiving application.";}, +STRING {str=""" Help is being displayed in the receiving application.";}, +STRING {str=""" the receiving application does not support Infrared.";}, +STRING {str=""" the receiving application is \"busy\" and not ready to receive";}, +STRING {str="information.";}, +STRING {str="Check the receiving application, then try Infrared again.";} +}; +} + + +RESOURCE STRING sys_ir_disabled { str="Infrared is disabled"; } + +RESOURCE MENU sys_ir_power_level + { + items = + { + CHOICE_ITEM { str="High";}, + CHOICE_ITEM { str="Low";} + }; + } + +RESOURCE STRING sys_printer_ir { str = "Infrared"; } + +RESOURCE MENU sys_baud_rate_chlist_x + { + items = + { + CHOICE_ITEM { str= "300";}, + CHOICE_ITEM { str= "600";}, + CHOICE_ITEM { str= "1200";}, + CHOICE_ITEM { str= "2400";}, + CHOICE_ITEM { str= "4800";}, + CHOICE_ITEM { str= "9600";}, + CHOICE_ITEM { str= "19200";}, + CHOICE_ITEM { str= "38400";}, + CHOICE_ITEM { str= "57600";} + }; + } + +RESOURCE CONTROL sys_baud_control_x + { + class=C_CHLIST; + prompt="Baud rate"; + info=CHLIST + { + rid=sys_baud_rate_chlist_x; + nsel=8; + }; + } + +/* End of File: SC_.RSS */ + diff --git a/code/SIBOSDK/resource/ss_.rss b/code/SIBOSDK/resource/ss_.rss new file mode 100644 index 0000000..271fa64 --- /dev/null +++ b/code/SIBOSDK/resource/ss_.rss @@ -0,0 +1,2018 @@ +SYSTEM +/* +(No comment to be placed on the first line of this file!) + +SS_.RSS + +System Resource file for Siena + +*/ + +#include +#include "hwim.rh" +#include +#include "symbols.h" + +STRUCT KEYPAIR + { + BYTE latin; /* Latin character value */ + BYTE cyril; /* Cyrillic character value */ + } + +STRUCT KEYLIST + { + STRUCT list[]; + } + +#define ARROWS4 + +/****************** THE SPECIAL CHARACTERS ************************/ +/* The first four characters are used by the file selector to tag one, +untag one, tag all & untag all. The next four are the "nudge" keys used by +most numeric/date editors. (Two down, two up.) Next is the keycode used in +EDWIN.C to indicate a soft or hard hyphen. NSWE are the compass points used +by the Lat-Long editor. These are followed by the degree symbol used in the +same editor. Next is the bullet symbol used by Help and by the Agenda. +The last two symbols were added in September 1995 to support code pages +other than 850 (esp. 1251 for Russia!). See #define H_SC_TPLUS et seq. +in SYMBOLS.H */ + +/* TTT Leave most of these alone, but translate the NSWE */ + +RESOURCE STRING sys_special_characters { str="+-*/<,>.NSWE"; } + +/************************* STRINGS ********************************/ + +RESOURCE STRING sys_string { str="%s"; } +RESOURCE STRING sys_dimmed_msg {str="This item is not available";} +RESOURCE STRING sys_locked_msg {str="This item cannot be changed";} +RESOURCE STRING sys_busy { str="Busy"; } +RESOURCE STRING sys_scanning { str="Scanning"; } +RESOURCE STRING sys_printing_to { str="Printing to %s";} +RESOURCE STRING sys_page_is { str="(page %u)";} + +RESOURCE STRING sys_copied_prompt {str="Copied";} +RESOURCE STRING sys_copying_prompt {str="Saving as \"%s\"";} +RESOURCE STRING sys_loading_prompt {str="Loading \"%s\"";} +RESOURCE STRING sys_merging_prompt {str="Merging in \"%s\"";} +RESOURCE STRING sys_nothing_to_bring {str="Nothing to bring";} +RESOURCE STRING sys_not_found {str="Not found"; } +RESOURCE STRING sys_nothing_to_find {str="Nothing to find";} + +RESOURCE STRING sys_compress_prompt {str="Compressing \"%s\"";} +RESOURCE STRING sys_not_compressible {str="Cannot compress on Flash";} + +RESOURCE STRING sys_password_incorrect {str="Incorrect password";} +RESOURCE STRING sys_password_not_confirmed {str="Password not confirmed";} + +RESOURCE STRING sys_range_reset {str="Out of range - reset to limit";} +RESOURCE STRING sys_invalid_num {str="Number is not valid";} +RESOURCE STRING sys_invalid_margins { str="Invalid margins. Reset?"; } +RESOURCE STRING sys_invalid_char { str="Undiallable character"; } +RESOURCE STRING sys_out_of_range {str="Value out of range: %s = %s";} +/* as used in "Value out of range: Max = 20.45 */ + +RESOURCE STRING sys_edit_nchars {str="Maximum number of characters reached";} + +RESOURCE STRING sys_popout_help {str="Press Tab to change this item";} + +RESOURCE STRING sys_help_string {str="Help: %s";} + +RESOURCE STRING sys_replace_disk {str="Replace the application disk";} + +/* the prompts for a file selector and a pack selector */ +RESOURCE STRING sys_name {str="Name";} +RESOURCE STRING sys_pack {str="Disk";} + +/* part of the title line of a filelist */ +RESOURCE STRING sys_filelist_disk {str="Disk ";} + +RESOURCE STRING sys_flist_reset { str="File list reset"; } +RESOURCE STRING sys_device_memory { str="Internal"; } +RESOURCE STRING sys_path_is { str="Path is %s"; } +RESOURCE STRING sys_choose_directory { str="Choose a directory"; } +RESOURCE STRING sys_choose_filename { str="Choose a filename"; } +RESOURCE STRING sys_choose_new_directory { str="Directory already exists"; } +RESOURCE STRING sys_exists_over { str="File already exists: overwrite?"; } + +/* Next two strings have a maximum length of 5 characters each */ +RESOURCE STRING sys_max { str="Max"; } +RESOURCE STRING sys_min { str="Min"; } + +RESOURCE STRING sys_dec_places { str="Decimal places"; } +RESOURCE STRING sys_sig_digits { str="Significant digits"; } +RESOURCE STRING sys_evaldlg_title { str="Set \"Evaluate\" format"; } +RESOURCE STRING sys_nothing_to_eval { str="Nothing to evaluate"; } +RESOURCE STRING sys_toolong_to_eval { str="Too long to evaluate"; } + +RESOURCE STRING sys_xonxoff_string {str="XON/XOFF ";} +RESOURCE STRING sys_header_str { str="Enter header details"; } +RESOURCE STRING sys_footer_str { str="Enter footer details"; } + +/* max len of next 2 strs is 9 (including the space and the brackets) */ +RESOURCE STRING sys_centimetres { str=" (cm)"; } +RESOURCE STRING sys_inches { str=" (inches)"; } + +RESOURCE STRING sys_dev_notready { str=" Absent!"; } +RESOURCE STRING sys_dev_corrupt { str=" Unformatted!"; } +RESOURCE STRING sys_dev_unknown { str=" Unrecognised!"; } +RESOURCE STRING sys_dev_info { str=", %luK free"; } + +RESOURCE STRING sys_mtype_unknown { str="Unknown"; } +RESOURCE STRING sys_mtype_floppy { str="Floppy"; } +RESOURCE STRING sys_mtype_hard { str="Hard"; } +RESOURCE STRING sys_mtype_flash { str="Flash"; } +RESOURCE STRING sys_mtype_ram { str="Ram"; } +RESOURCE STRING sys_mtype_rom { str="Rom"; } +RESOURCE STRING sys_mtype_protected { str=""; } +/* Maximum of 14 character widths for the following 5 strings */ +RESOURCE STRING sys_files_tagged { str="(Tagged files)"; } +RESOURCE STRING sys_no_files { str="(No files)"; } +RESOURCE STRING sys_no_disk { str="(No disk)"; } +RESOURCE STRING sys_unformatted { str="(Unformatted)"; } +RESOURCE STRING sys_unrecognised { str="(Unrecognised)"; } + +RESOURCE STRING sys_sound_fail { str="Sound in use - please retry"; } + +/*********** THE ALLOWED SPECIAL KEYS FOR ACTION BUTTONS ******************/ + +/* You can translate the text, but no more than six characters each */ + +RESOURCE ACLIST_ARRAY sys_button_text + { + button= + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Enter"; + }, + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Esc"; + }, + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Del"; + }, + PUSH_BUT + { + keycode=W_KEY_SPACE; + str="Space"; + }, + PUSH_BUT + { + keycode=W_KEY_UP; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_DOWN; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_RIGHT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_LEFT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Tab"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Menu"; + } + }; + } + + +/************************* ACTION LISTS ******************************/ + +/* Change the keycodes too, but don't lose the minus signs */ + +RESOURCE ACLIST_ARRAY sys_ac_no_yes + { + button = + { + PUSH_BUT + { + keycode=-'n'; + str="No"; + }, + PUSH_BUT + { + keycode='y'; + str="Yes"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_continue + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Continue"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_abandon + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Abandon"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_append_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Append"; + } + }; + } + +/* Careful not to make the combined width of these strings much wider */ + +RESOURCE ACLIST_ARRAY sys_smart_dial_aclist + { + } + +RESOURCE ACLIST_ARRAY sys_freedial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Clear"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Redial"; + } + }; + } + +/************************* CHOICE LISTS *****************************/ + +RESOURCE MENU sys_no_yes + { + items = + { + CHOICE_ITEM { str= "No";}, + CHOICE_ITEM { str="Yes";} + }; + } + +RESOURCE MENU sys_offon_menu + { + items = + { + CHOICE_ITEM { str="Off";}, + CHOICE_ITEM { str= "On";} + }; + } + +RESOURCE MENU sys_printer_units_chlist + { + items = + { + CHOICE_ITEM { str= "Inches";}, /* matches with E_IMPERIAL */ + CHOICE_ITEM { str= "Centimetres";} /* matches with E_METRIC */ + }; + } + +RESOURCE MENU sys_printer_device_chlist + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";} + }; + } + + +RESOURCE MENU sys_baud_rate_chlist + { + items = + { + CHOICE_ITEM { str= "19200";}, /* new for S3a */ + CHOICE_ITEM { str= "9600";}, + CHOICE_ITEM { str= "4800";}, + CHOICE_ITEM { str= "2400";}, + CHOICE_ITEM { str= "1200";}, + CHOICE_ITEM { str= "600";}, + CHOICE_ITEM { str= "300";} + }; + } + +RESOURCE MENU sys_data_bits_chlist + { + items = + { + CHOICE_ITEM { str="5";}, + CHOICE_ITEM { str="6";}, + CHOICE_ITEM { str="7";}, + CHOICE_ITEM { str="8";} + }; + } + +RESOURCE MENU sys_stop_bits_chlist + { + items = + { + CHOICE_ITEM { str="1";}, + CHOICE_ITEM { str="2";} + }; + } + +RESOURCE MENU sys_parity_chlist + { + items = + { + CHOICE_ITEM { str="None";}, + CHOICE_ITEM { str="Even";}, + CHOICE_ITEM { str= "Odd";} + }; + } + +RESOURCE MENU sys_format_chlist + { + items = + { + CHOICE_ITEM { str="Fixed";}, + CHOICE_ITEM { str="Scientific";}, + CHOICE_ITEM { str="General";}, + CHOICE_ITEM { str="Hexadecimal";} + }; + } + +RESOURCE MENU sys_rad_deg + { + items = + { + CHOICE_ITEM { str= "Radians";}, + CHOICE_ITEM { str= "Degrees";} + }; + } + +/* IMPORTANT, order in next array must be same as in page_size menu below */ +/* Also, at most 10 entries allowed, and the first two cannot be altered */ +/* But change any of the others, if you wish */ +/* 1 mm is 1440/25.4 units in the dimensions used, so eg 148 mm is 8391 */ +/* so you could have {width=8391; ... for one entry (an A5 letter size) */ + +RESOURCE PAGE_SIZE_ARRAY sys_page_dimensions + { + page_size= + { + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_EXECUTIVE; length=PAGE_LENGTH_EXECUTIVE;}, + PAGE_SIZE {width=PAGE_WIDTH_LEGAL; length=PAGE_LENGTH_LEGAL;}, + PAGE_SIZE {width=PAGE_WIDTH_LETTER; length=PAGE_LENGTH_LETTER;}, + PAGE_SIZE {width=PAGE_WIDTH_MONARCH; length=PAGE_LENGTH_MONARCH;}, + PAGE_SIZE {width=PAGE_WIDTH_DL; length=PAGE_LENGTH_DL;} + }; + } + +RESOURCE MENU sys_page_size + { + items= + { + CHOICE_ITEM {str="A4";}, + CHOICE_ITEM {str="Custom";}, + CHOICE_ITEM {str="Executive";}, + CHOICE_ITEM {str="Legal";}, + CHOICE_ITEM {str="Letter";}, + CHOICE_ITEM {str="Monarch";}, + CHOICE_ITEM {str="DL";} + }; + } + +RESOURCE MENU sys_orient + { + items= + { + CHOICE_ITEM {str="Portrait";}, + CHOICE_ITEM {str="Landscape";} + }; + } + +RESOURCE MENU sys_prn_pos + { + items= + { + CHOICE_ITEM {str="Normal";}, + CHOICE_ITEM {str="Superscript";}, + CHOICE_ITEM {str="Subscript";} + }; + } + +RESOURCE MENU sys_headfoot_align + { + items= + { + CHOICE_ITEM {str="Left";}, + CHOICE_ITEM {str="Right";}, + CHOICE_ITEM {str="Centred";}, + CHOICE_ITEM {str="Justified";}, + CHOICE_ITEM {str="Two column";}, + CHOICE_ITEM {str="Three column";} + }; + } + +RESOURCE MENU sys_pgno_choice + { + items= + { + CHOICE_ITEM {str="1,2,3";}, + CHOICE_ITEM {str="I,II,III";}, + CHOICE_ITEM {str="i,ii,iii";} + }; + } + +/************************* DIALOGS ********************************/ + +RESOURCE DIALOG sys_error_dialog + { + flags=DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_continue; + }; + } + }; + } + +RESOURCE DIALOG sys_query_dialog + { + flags = DLGBOX_ACTION_LIST|DLGBOX_REPORT_ACT_HORIZ; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_no_yes; + }; + } + }; + } + +RESOURCE DIALOG sys_printing_dialog + { + flags=DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_abandon; + }; + } + }; + } + +RESOURCE DIALOG sys_set_port_dialog + { + title="Set Serial port"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Baud rate"; + info=CHLIST + { + rid=sys_baud_rate_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Data bits"; + info=CHLIST + { + rid=sys_data_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Stop bits"; + info=CHLIST + { + rid=sys_stop_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Parity"; + info=CHLIST + { + rid=sys_parity_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Ignore parity"; + info=CHLIST + { + rid=sys_no_yes; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_set_hshk_dialog + { + title="Set serial handshake"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="XON/XOFF"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="RTS/CTS"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="DSR/DTR"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="DCD"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_printer_config_dialog + { + title="Printer configuration"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Printer device"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + info=CHLIST + { + rid=sys_printer_device_chlist; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial setup"; + info=TXTMESS + { + str="19200 "; /* changed for S3a */ + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Handshaking"; + info=TXTMESS + { + str="XON/XOFF Off "; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK|DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_FNEDIT; + prompt="File:"; + info=FNEDIT { flags=IN_FNEDIT_NO_AUTOQUERY; }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Units"; + info=CHLIST + { + rid=sys_printer_units_chlist; + }; + } + }; + } + +RESOURCE DIALOG sys_eval_dialog + { + title="Set Calculator format"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Format"; + info=CHLIST { rid=sys_format_chlist; }; + }, + CONTROL + { + class=C_NCEDIT; + /* The following line must be the wider of the 2 above strings */ + /* sys_dec_places and sys_sig_digits */ + prompt="Significant digits"; + info=NCEDIT + { + high=12; + low=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Trigonometry units"; + info=CHLIST { rid=sys_rad_deg; }; + } + }; + } + +RESOURCE DIALOG sys_country_selector_dialog + { + title="Append country"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_WLDSELWN; + prompt="Country"; + info=WLDSELWN {flags=IN_WLDSELWN_COUNTRY|IN_WLDSELWN_SETHOME; }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_append_aclist; + }; + } + }; + } + +RESOURCE CONTROL sys_smart_dial_item + { + class=C_TEXTWIN; + prompt=; + flags=DLGBOX_ITEM_DEAD; + info=TXTMESS + { + str=" "; + }; + } + +RESOURCE DIALOG sys_smart_dial_dialog + { + flags=DLGBOX_RBUF_FILLED|DLGBOX_NOTIFY_ENTER|DLGBOX_SMALL_FONT|DLGBOX_NOTIFY_ALL_ACT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="Number to dial"; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_continue; + }; + } + }; + } + +RESOURCE DIALOG sys_freedial_dialog + { + title="Free-form dialling"; + flags = DLGBOX_NO_WAIT|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_FREEDIAL; + prompt=; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_freedial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_flist_dialog + { + title="Specify filelist"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Filename pattern"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + }, + CONTROL + { + class=C_EDWIN; + prompt="Full path"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + } + }; + } + +RESOURCE DIALOG sys_print_control_dl + { + title="Print setup"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_NOTIFY_ESCAPE|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + prompt="Page size"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Margins"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Header"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Footer"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Paging"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Printer"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_paging_control_dl + { + title="Paging control"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Number for first page"; + info=NCEDIT + { + low=1; + high=9999; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Allow widows/orphans"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Page number style"; + info=CHLIST{rid=sys_pgno_choice;}; + } + }; + } + +RESOURCE DIALOG sys_printer_model + { + title="Set printer"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + prompt="Printer"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + info=CHLIST{}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Default"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_margins_dl + { + title="Margins"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_FLTEDIT; + prompt="Top"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Left"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Right"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Bottom"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_headfoot_dl + { + title="*"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Text"; + info=EDWIN + { + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_ACCEPT_TABS; + maxlen=80; + vulen=20; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Alignment"; + info=CHLIST{rid=sys_headfoot_align;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="On first page"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Vertical offset"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_pagesize_dl + { + title="Page size"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_CHLIST; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + prompt="Page size"; + info=CHLIST{rid=sys_page_size;}; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Width"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Height"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Orientation"; + info=CHLIST{rid=sys_orient;}; + } + }; + } + +RESOURCE DIALOG sys_font_dl + { + title="Font"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Font"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Size"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Underline"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Bold"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Italic"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Print position"; + info=CHLIST{rid=sys_prn_pos;}; + } + }; + } + +RESOURCE CONTROL sys_txtmess + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + } + +/************************* HELP ********************************/ + +RESOURCE TOPIC_ARRAY sys_help_index_data +{ +id_lst= +{ +sys_help_on_off, +sys_time_basics, +sys_help_infrared, +sys_help_edit, +sys_help_dialog, +sys_help_statwin, +sys_help_files, +sys_help_filsels, +sys_help_evaluate, +sys_help_print, +sys_help_in_use, +sys_help_appnotready, +sys_help_no_sys_mem +}; +} + +RESOURCE HELP_ARRAY sys_help_index +{ +topic="Index"; +topic_id=sys_help_index_data; +} + +RESOURCE HELP_ARRAY sys_help_on_help +{ +topic="About Help"; +strlst= +{ +STRING {str="To choose a topic:""then Enter";}, +STRING {str="";}, +STRING {str="Esc returns to previous Help";}, +STRING {str="screen";}, +STRING {str="Control-Esc exits Help";}, +STRING {str="";}, +STRING {str="Control-Help for an index";}, +STRING {str="(works from main application";}, +STRING {str="screen)";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialog +{ +topic="Menu/dialog tips"; +strlst= +{ +STRING {str="Press Menu key to see a menu, use";}, +STRING {str=""" to select an option, then";}, +STRING {str="press Enter";}, +STRING {str="";}, +STRING {str="Use hot-key, eg ""-N, listed beside";}, +STRING {str="option to access it directly (hold";}, +STRING {str="down "" and press letter)";}, +STRING {str="";}, +STRING {str="Tab often lists choices available";}, +STRING {str="on dialog lines with arrows";} +}; +} + +RESOURCE HELP_ARRAY sys_help_statwin +{ +topic="Screen display"; +strlst= +{ +STRING {str="Use Fn-> and Fn-< to change";}, +STRING {str="contrast";}, +STRING {str="";}, +STRING {str="Press "" to switch between";}, +STRING {str="screens in an application";}, +STRING {str="";}, +STRING {str="Use `Zoom in/out' to change";}, +STRING {str="character size";}, +STRING {str="";}, +STRING {str="Press ""-Menu for a temporary";}, +STRING {str="Information window";}, +STRING {str="In some applications Control-Menu";}, +STRING {str="may turn an Information window";}, +STRING {str="on/off permanently";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialling +{ +} + +RESOURCE HELP_ARRAY sys_help_filsels +{ +topic="File selection"; +strlst= +{ +STRING {str="Press Tab in dialogs to choose";}, +STRING {str="from a full list of files/directories,";}, +STRING {str="then:";}, +STRING {str="Typing matches with filenames";}, +STRING {str="Shift+letter matches directories";}, +STRING {str="Control+letter matches disks";}, +STRING {str="";}, +STRING {str="Press Tab on System screen for";}, +STRING {str="File selector:";}, +STRING {str="Menu then gives file/directory";}, +STRING {str="options. Use +- (or Shift-"") to";}, +STRING {str="tag/untag files";}, +STRING {str=<158><246>" tag/untag all files";}, +STRING {str="";}, +STRING {str="In `File' dialogs:";}, +STRING {str="""-Tab gives full path of file";}, +STRING {str="To select multiple files, press";}, +STRING {str="Control-Tab, type the `Filename";}, +STRING {str="pattern', then press Control-Enter";} +}; +} + +RESOURCE HELP_ARRAY sys_help_edit +{ +topic="Editing"; +strlst= +{ +STRING {str="Use "" to move cursor";}, +STRING {str="Control and "" with "" keys";}, +STRING {str="increase movement";}, +STRING {str="";}, +STRING {str="Shift-"" highlights text, then";}, +STRING {str="use:";}, +STRING {str="Del to cut it to the clipboard (or";}, +STRING {str="`Copy' to copy it), then `Insert' to";}, +STRING {str="paste the text back in; use";}, +STRING {str="Shift-Del to delete text without";}, +STRING {str="changing what's on the clipboard";}, +STRING {str="";}, +STRING {str="To copy text from another";}, +STRING {str="application: highlight text to copy";}, +STRING {str="in the other application, then use";}, +STRING {str="`Bring' option to insert text at";}, +STRING {str="cursor position";}, +STRING {str="";}, +STRING {str="Quick delete methods (without";}, +STRING {str="highlighting):";}, +STRING {str="Shift-Del: character forwards";}, +STRING {str="Shift-""-Del: to end of line";}, +STRING {str="""-Del: to beginning of line";}, +STRING {str="";}, +STRING {str="Quick highlight methods:";}, +STRING {str="Shift-Control-Home: current word";}, +STRING {str="Shift-Control-End: current";}, +STRING {str="paragraph";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_help +{ +id_lst= +{ +sys_help_on_help +}; +} + +RESOURCE HELP_ARRAY sys_help_files +{ +topic="Files"; +strlst= +{ +STRING {str="To work on files, see options on";}, +STRING {str="`File' menu in application:";}, +STRING {str="";}, +STRING {str="`New file' to create files";}, +STRING {str="";}, +STRING {str="`Open file' to open files (or";}, +STRING {str="highlight and press Enter on";}, +STRING {str="System screen; press Shift-Enter";}, +STRING {str="to open without closing previous";}, +STRING {str="file)";}, +STRING {str="";}, +STRING {str="`Merge in', `Compress file', `Save'";}, +STRING {str="and `Revert' options are in relevant";}, +STRING {str="applications";}, +STRING {str="";}, +STRING {str="Other file operations are done on";}, +STRING {str="System screen:";}, +STRING {str="Copying, deleting, renaming,";}, +STRING {str="backing up & restoring file(s)";}, +STRING {str="Note: to copy Data or Agenda files,";}, +STRING {str="use `Save as' in application to";}, +STRING {str="create compressed copy of file";}, +STRING {str="";}, +STRING {str="To exit file: highlight bold filename";}, +STRING {str="on System screen and press Del";} +}; +} + +RESOURCE HELP_ARRAY sys_help_print +{ +topic="Printing/previewing"; +strlst= +{ +STRING {str="In applications which can Print,";}, +STRING {str="first use `Print setup' on `Special'";}, +STRING {str="menu to set `Printer Model'";}, +STRING {str="";}, +STRING {str="Use `Print preview' to see a";}, +STRING {str="preview; it has its own menu of";}, +STRING {str="options (including `Print'). (You";}, +STRING {str="don't have to wait for the preview";}, +STRING {str="to finish calculating: Esc cancels,";}, +STRING {str="etc.)";}, +STRING {str="";}, +STRING {str="Use %D and %T in headers and";}, +STRING {str="footers (part of `Print setup') to";}, +STRING {str="print the date and time";}, +STRING {str="automatically";}, +STRING {str="Other codes include:";}, +STRING {str="%Ffor the filename";}, +STRING {str="%Pfor the page number";}, +STRING {str="%%for a%character";}, +STRING {str="%Mfor total pages in file, eg";}, +STRING {str="`Page %P of %M' (Word and Sheet";}, +STRING {str="applications only)";} +}; +} + +RESOURCE HELP_ARRAY sys_time_basics +{ +topic="Time basics"; +strlst= +{ +STRING {str="In Time, set `Home city', then set";}, +STRING {str="`Time and date'";}, +STRING {str="";}, +STRING {str="Set `Summer times' on/off when";}, +STRING {str="they change";}, +STRING {str="";}, +STRING {str="Use `Formats' to set 12/24 hour";}, +STRING {str="clocks";} +}; +} + +RESOURCE HELP_ARRAY sys_help_on_off +{ +topic="Turning on & off"; +strlst= +{ +STRING {str="ON/CE (or an application button)";}, +STRING {str="turns on; OFF turns off";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_index +{ +id_lst= +{ +sys_help_index +}; +} + +/************************* LATER ADDITIONS ********************************/ + +/* Name of general printer driver */ +RESOURCE STRING sys_wdr_general { str="General"; } + +RESOURCE STRING sys_dial_out { str="9,"; } /* 5 chars max */ + +RESOURCE STRING sys_skipping_page { str="(skipping page %u)";} + +/************************* NEW FOR XWIM ********************************/ + +/* TTT: Only used by developers */ +RESOURCE STRING sys_debugging_num_cells {str="Diagnostics: %d (%u)";} + +/********* for Calendar Window in Agenda **********/ + +/* TTT: eg "Calendar 1998" or "Calendar 1993-1994" */ +RESOURCE STRING sys_calendar {str="Calendar %Y";} + +/*********************** FOR PRINT PREVIEW ******************************/ +/* TTT: "Print preview" option in Word, Agenda, Sheet... uses these: */ +RESOURCE STRING sys_page {str="page";} +RESOURCE STRING sys_pages {str="pages";} +RESOURCE STRING sys_preview_busy {str="Busy, cannot print yet";} +RESOURCE STRING sys_display_margins {str="Show margins";} +RESOURCE STRING sys_hide_margins {str="Hide margins";} + +RESOURCE STRING sys_opening_prompt {str="Opening \"%s\"";} + +/* TTT: NB "Print preview" is a standard WP term... if every Wp in your +country uses one term for this, you must use it too */ +RESOURCE STRING sys_print_preview {str="Print preview";} + +/* TTT length of longest in sys_preview_margins_chlist + length of longest +in sys_preview_options_chlist must be less than 50 */ +RESOURCE MENU sys_preview_margins_chlist + { + items= + { + CHOICE_ITEM {str="Margins off";}, + CHOICE_ITEM {str="Margins on";} + }; + } + +RESOURCE MENU sys_preview_options_chlist + { + items= + { + CHOICE_ITEM {str="Facing pages";}, + CHOICE_ITEM {str="1 page";}, + CHOICE_ITEM {str="2 pages";}, + CHOICE_ITEM {str="3 pages";}, + CHOICE_ITEM {str="4 pages";} + }; + } + +RESOURCE DIALOG sys_preview_options_dialog + { + title="Display"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt=""; + info=CHLIST{rid=sys_preview_options_chlist;}; + } + }; + } + +RESOURCE DIALOG sys_preview_jump_dialog + { + title="Jump to page"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Page number"; + info=NCEDIT + { + low=1; + high=9999; + }; + } + }; + } + +RESOURCE WSERV_INFO sys_preview_acc + { + menbar_id=sys_preview_menubar; + first_com=O_PVC_PREVIEW_PRINT; + accel= + { + 'p', /* Print */ + 'm', /* Margins */ + 'd', /* Pages to display */ + 'j', /* Jump to page */ + '?' /* Exit preview */ + }; + } + +RESOURCE MENU_BAR sys_preview_menubar + { + items = + { + MENU_BAR_ITEM + { + menu_id=sys_preview_menu; + mb_item="Preview"; + } + }; + } + +RESOURCE MENU sys_preview_menu + { + items = + { + MENU_ITEM + { + com_id=O_PVC_PREVIEW_PRINT; + mn_item="Print"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_MARGINS; +/* TTT: use whichever's the longer: "Show margins" or "Hide margins" */ + mn_item="Show margins"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_OPTIONS; + mn_item="Pages to display"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_JUMP|BREAK_LINE_FOLLOWS; + mn_item="Jump to page"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_EXIT; + mn_item="Exit preview"; + } + }; + } + +RESOURCE MENU sys_printer_devices + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";}, + CHOICE_ITEM { str= "Fax";} + }; + } + +RESOURCE CONTROL sys_print_control_device + { + class=C_TEXTWIN; +/* TTT: You'll see this on the bottom of the Print Setup dialog +in Word, Agenda... */ + prompt="Device"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE CONTROL sys_print_preview_settings + { +/* TTT: You'll see this on the bottom of the Printer configuration dialog +in the Shell */ + class=C_TEXTWIN; + prompt="Print preview"; + info=TXTMESS + { + str="Facing pages,Margins off"; /* TTT widest possible */ + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE DIALOG sys_preview_settings_dl + { + title="Preview settings"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Display"; + info=CHLIST{rid=sys_preview_options_chlist;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Margins"; + info=CHLIST{rid=sys_offon_menu;}; + } + }; + } + +RESOURCE MENU sys_standard_sounds + { + items= + { +/* TTT: Built-in sounds, when you're setting an alarm in Time */ + CHOICE_ITEM {str="Alert";}, + CHOICE_ITEM {str="Phone";}, + CHOICE_ITEM {str="Chime";}, + CHOICE_ITEM {str="Fanfare";}, + CHOICE_ITEM {str="Cavalry";}, + CHOICE_ITEM {str="Signal";} + }; + } + +/* TTT: do not translate */ +RESOURCE STRING sys_alarm_standard_name {str="SYS$AL01";} +/* TTT: The "silent" sound, when setting an alarm */ +RESOURCE STRING sys_silent_alarm {str="Silent";} +/* TTT: If you try to play a sound, but sound is disabled... */ +RESOURCE STRING sys_sound_disabled {str="Sound disabled";} +/* TTT: do not translate the next one */ +RESOURCE STRING sys_word_rom { str="ROM::WORD.APP"; } +/* TTT: the user has refused to replace an SSD */ +RESOURCE STRING sys_restart_from_sys { str="Press Esc to exit application"; } + +/* TTT: when creating a new file: eg gives "Myfile" created +You can change these around if you like, eg we could've done the English +as str="Created \"%s\"" to give Created "Myfile" */ +RESOURCE STRING srt_file_created { str="\"%s\" created"; } +RESOURCE STRING srt_file_opened { str="\"%s\" opened"; } +RESOURCE STRING srt_file_saved { str="\"%s\" saved"; } +RESOURCE STRING srt_file_compressed { str="\"%s\" compressed"; } +RESOURCE STRING srt_file_merged { str="\"%s\" merged in"; } +RESOURCE STRING sys_saving_prompt {str="Saving \"%s\"";} +RESOURCE STRING sys_reloading_prompt {str="Reopening \"%s\"";} +RESOURCE STRING sys_converting_prompt {str="Converting \"%s\"";} + +/* TTT: When we refuse to save the file, because it hasn't changed */ +RESOURCE STRING sys_not_changed {str="Not changed";} +/* TTT: When you're exiting, but it failed to save the file for some reason */ +RESOURCE STRING sys_confirm_continue {str="Not saved, continue anyway?";} +/* TTT: When you're using the "Exit, lose changes" option: */ +RESOURCE STRING sys_confirm_change_loss {str="Confirm the loss of all changes";} +/* TTT: used with the previous two strings */ +RESOURCE STRING sys_losing_changes {str="(`Yes' discards all changes)";} +RESOURCE STRING sys_nothing_to_print {str="Nothing to print";} +RESOURCE STRING sys_nothing_to_insert {str="Nothing to insert";} +RESOURCE STRING sys_nothing_to_copy {str="Nothing to copy";} +/* TTT: preferably use the same word as the "Revert" menu option */ +RESOURCE STRING sys_revert_to_saved {str="Revert to saved?";} + +/* TTT: For use in menus (hotkeys) */ +RESOURCE STRING sys_shift_key_name {str="Shift";} + +/* TTT: When you use "Current country only" (or diamond key) World App... */ +RESOURCE STRING srt_space_only { str=""; } + +RESOURCE STRING sys_change_password {str="Change password";} + +RESOURCE DIALOG sys_set_password_dl + { + title = "Set password"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + }, + CONTROL + { + class=C_XEDIT; + prompt="Confirm password"; + } + }; + } + +RESOURCE DIALOG sys_get_password_dl + { + title = "Password protected"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + } + }; + } + +/* TTT Extra help - translate this! */ +/* BUT DON'T MAKE THE TEXT WIDER THAN WILL FIT ON COMPATIBILITY MODE SCREENS +(BEAR IN MIND THAT THIS HELP IS AVAILABLE TO COMPATIBILITY MODE APP) */ + +RESOURCE HELP_ARRAY sys_help_evaluate +{ +topic="Calculations"; +strlst= +{ +STRING {str="Type a calculation (without an =";}, +STRING {str="sign or spaces), then use";}, +STRING {str="`Evaluate' on `Edit' menu for result";}, +STRING {str="";}, +STRING {str="Note: multiply appears as * and";}, +STRING {str="divide as / on screen, even if you";}, +STRING {str="used the "<158>" and "<246>" keys to enter";}, +STRING {str="them";} +}; +} + +RESOURCE HELP_ARRAY sys_help_memo +{ +topic="Memo editor"; +strlst= +{ +STRING {str="This is like the Word Processor";}, +STRING {str="without a `File' menu. Put cursor on";}, +STRING {str="entry and use `Edit memo' in";}, +STRING {str="Agenda to create a memo for an";}, +STRING {str="entry";}, +STRING {str="";}, +STRING {str="Agenda memos can be up to 4K";}, +STRING {str="long. One set of styles is kept for";}, +STRING {str="all memos in an Agenda file";}, +STRING {str="";}, +STRING {str="Use `Password' to protect a memo";}, +STRING {str="and use it again to remove or";}, +STRING {str="change the password";}, +STRING {str="";}, +STRING {str="Use `Exit' when you've finished the";}, +STRING {str="memo";}, +STRING {str="";}, +STRING {str="To delete a memo, edit it, delete all";}, +STRING {str="text in Memo editor (`Highlight all";}, +STRING {str="text', then press Del key) and";}, +STRING {str="`Exit'";} +}; +} + +RESOURCE HELP_ARRAY sys_help_in_use +{ +topic="File or device in use"; +strlst= +{ +STRING {str="You will see this message if you";}, +STRING {str="try to copy, delete or rename a file";}, +STRING {str="which is open (ie in bold on the";}, +STRING {str="System screen). Exit the file first";}, +STRING {str="";}, +STRING {str="You will also see it if you have used";}, +STRING {str="`Communications' in System screen";}, +STRING {str="to set `Serial cable', and then try to";}, +STRING {str="print to a serial port printer";}, +STRING {str="Set `Use' line in `Communications'";}, +STRING {str="to `None' before printing";} +}; +} + +RESOURCE HELP_ARRAY sys_help_no_sys_mem +{ +topic="No system memory"; +strlst= +{ +STRING {str="This message usually means all";}, +STRING {str="your Internal memory has been";}, +STRING {str="used up. Exit some open files, or";}, +STRING {str="delete unwanted files from the";}, +STRING {str="Internal disk, to free some more";}, +STRING {str="memory";}, +STRING {str="";}, +STRING {str="It may also appear if a Word or";}, +STRING {str="Sheet file reaches its maximum";}, +STRING {str="size. In this case internal memory";}, +STRING {str="is probably NOT full - the message";}, +STRING {str="means the application has reached";}, +STRING {str="its memory limit. You will need to";}, +STRING {str="split the file";}, +STRING {str="";}, +STRING {str="(If an Agenda has repeating";}, +STRING {str="entries, `Find' and `Print preview'";}, +STRING {str="may also temporarily cause the";}, +STRING {str="Agenda to reach its memory limit";}, +STRING {str="and display this message)";} +}; +} + +RESOURCE HELP_ARRAY sys_help_calendar +{ +topic="Calendars"; +strlst= +{ +STRING {str="Whenever you are entering a date";}, +STRING {str="in a dialog, you can press Tab to";}, +STRING {str="display a calendar";}, +STRING {str="";}, +STRING {str="In the calendars:";}, +STRING {str=""" move the cursor around the";}, +STRING {str="screen";}, +STRING {str="Psion-"" move a month at a time";}, +STRING {str="Shift-"" (or <>) move one day at a";}, +STRING {str="time";}, +STRING {str="Shift-"" move by weeks";}, +STRING {str="Control-"" move by months";}, +STRING {str="Control-"" move by years";}, +STRING {str="";}, +STRING {str="Spacebar moves to today";} +}; +} + +/************************* NEW FOR Workabout **************************/ +/* INCLUDED IN ALL BUILDS, BUT DUMMY RESOURCES USED FOR OTHER BUILDS */ + +RESOURCE DIALOG sys_s3c_print_control_dl + { + title=""; + } + + RESOURCE STRING sys_s3c_page_setup { str=""; } + +RESOURCE HELP_ARRAY sys_help_battery +{ + topic=""; +} + +/************************* NEW FOR Siena ******************************/ +/* INCLUDED IN ALL BUILDS, BUT DUMMY RESOURCES USED FOR OTHER BUILDS */ + +RESOURCE DIALOG sys_vine_file_info_dl + { + title="Last modified"; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_DEAD; + prompt="Time"; + info=TXTMESS{ }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_DEAD; + prompt="Date"; + info=TXTMESS{ }; + } + }; + } + +RESOURCE KEYLIST sys_russian_keys +{ +/* Used in Russian model to map between keyboard modes (latin and cyrillic) + + Used by Siena to map menu keys < > and , to . ? and ' + This is necessary when menu is on screen and user presses unmodified key + hoping to highlight relevent menu option +*/ + + list= + { + KEYPAIR { latin='<'; cyril=','; }, + KEYPAIR { latin='>'; cyril='.'; }, + KEYPAIR { latin='?'; cyril=39; } + }; +} + +RESOURCE HELP_ARRAY sys_help_infrared +{ +topic="Infrared"; +strlst= +{ +STRING {str="Lets you copy information to and";}, +STRING {str="from another Psion that has";}, +STRING {str="Infrared";}, +STRING {str="";}, +STRING {str="To turn Infrared on: select";}, +STRING {str="`Communications' in System screen";}, +STRING {str="and set `Use' line to `Infrared'";}, +STRING {str="Note: leave `Power setting' set to";}, +STRING {str="`High'";}, +STRING {str="";}, +STRING {str="To use Infrared: select data to";}, +STRING {str="copy, then transfer it";}, +STRING {str="";}, +STRING {str="To select a:";}, +STRING {str="* File - highlight name in System";}, +STRING {str="screen";}, +STRING {str="* Agenda entry - put cursor on";}, +STRING {str="entry. (Copied entry will have same";}, +STRING {str="date, time and alarm as original)";}, +STRING {str="* Data entry - find entry, or";}, +STRING {str="highlight specific text in an entry";}, +STRING {str="* Information in other applications";}, +STRING {str="- just highlight text in Word &";}, +STRING {str="Program, calculation or result in";}, +STRING {str="Calc, or cell(s) in Sheet";}, +STRING {str="";}, +STRING {str="To transfer the data:";}, +STRING {str="Point Siena and other Psion at each";}, +STRING {str="other and make sure they are less";}, +STRING {str="than 60cm (2 feet) apart";}, +STRING {str="Press "" button on sending Siena";}, +STRING {str="On receiving Siena, move to";}, +STRING {str="appropriate application for";}, +STRING {str="information, or System screen to";}, +STRING {str="receive a whole file, then press """;}, +STRING {str="button";} +}; +} + +RESOURCE HELP_ARRAY sys_help_appnotready +{ +topic="Application not ready"; +strlst= +{ +STRING {str="You will see this message if you";}, +STRING {str="try to use Infrared when:";}, +STRING {str="";}, +STRING {str="* a dialog is on screen in the";}, +STRING {str="receiving application";}, +STRING {str="";}, +STRING {str="* Help is on screen in the receiving";}, +STRING {str="application";}, +STRING {str="";}, +STRING {str="* the receiving application does";}, +STRING {str="not support Infrared";}, +STRING {str="";}, +STRING {str="* the receiving application is";}, +STRING {str="\"busy\" and not ready to receive";}, +STRING {str="information";}, +STRING {str="";}, +STRING {str="Check the receiving application,";}, +STRING {str="then try Infrared again";} +}; +} + +RESOURCE STRING sys_ir_disabled { str="Infrared is disabled"; } + +RESOURCE MENU sys_ir_power_level + { + items = + { + CHOICE_ITEM { str="High";}, + CHOICE_ITEM { str="Low";} + }; + } + +RESOURCE STRING sys_printer_ir { str = "Infrared"; } + +RESOURCE MENU sys_baud_rate_chlist_x + { + } + +RESOURCE CONTROL sys_baud_control_x + { + } + +/* End of File: SS_.RSS */ + diff --git a/code/SIBOSDK/resource/sw_.rss b/code/SIBOSDK/resource/sw_.rss new file mode 100644 index 0000000..e1f4fb7 --- /dev/null +++ b/code/SIBOSDK/resource/sw_.rss @@ -0,0 +1,1836 @@ +SYSTEM +/* +(No comment to be placed on the first line of this file!) + +SW_.RSS + +System Resource file for Workabout + +*/ + +#include +#include "hwim.rh" +#include +#include "symbols.h" + +#define ARROWS4 + +/****************** THE SPECIAL CHARACTERS ************************/ + +/* leave most of these alone, but translate the NSWE */ + +RESOURCE STRING sys_special_characters { str="+-*/<;>,NSWE"; } + +/************************* STRINGS ********************************/ + +RESOURCE STRING sys_string { str="%s"; } +RESOURCE STRING sys_dimmed_msg {str="This item is not available";} +RESOURCE STRING sys_locked_msg {str="This item cannot be changed";} +RESOURCE STRING sys_busy { str="Busy"; } +RESOURCE STRING sys_scanning { str="Scanning"; } +RESOURCE STRING sys_printing_to { str="Printing to %s";} +RESOURCE STRING sys_page_is { str="(page %u)";} + +RESOURCE STRING sys_copied_prompt {str="Copied";} +RESOURCE STRING sys_copying_prompt {str="Saving as \"%s\"";} +RESOURCE STRING sys_loading_prompt {str="Loading \"%s\"";} +RESOURCE STRING sys_merging_prompt {str="Merging in \"%s\"";} +RESOURCE STRING sys_nothing_to_bring {str="Nothing to bring";} +RESOURCE STRING sys_not_found {str="Not found"; } +RESOURCE STRING sys_nothing_to_find {str="Nothing to find";} + +RESOURCE STRING sys_compress_prompt {str="Compressing \"%s\"";} +RESOURCE STRING sys_not_compressible {str="Cannot compress on Flash";} + +RESOURCE STRING sys_password_incorrect {str="Incorrect password";} +RESOURCE STRING sys_password_not_confirmed {str="Password not confirmed";} + +RESOURCE STRING sys_range_reset {str="Out of range - reset to limit";} +RESOURCE STRING sys_invalid_num {str="Number is not valid";} +RESOURCE STRING sys_invalid_margins { str="Invalid margins. Reset?"; } +RESOURCE STRING sys_invalid_char { str="Undiallable character"; } +RESOURCE STRING sys_out_of_range {str="Value out of range: %s = %s";} +/* as used in "Value out of range: Max = 20.45 */ + +RESOURCE STRING sys_edit_nchars {str="Maximum number of characters reached";} + +RESOURCE STRING sys_popout_help {str="Press Tab to change this item";} + +RESOURCE STRING sys_help_string {str="Help: %s";} + +RESOURCE STRING sys_replace_disk {str="Replace the application disk";} + +/* the prompts for a file selector and a pack selector */ +RESOURCE STRING sys_name {str="Name";} +RESOURCE STRING sys_pack {str="Disk";} + +/* part of the title line of a filelist */ +RESOURCE STRING sys_filelist_disk {str="Disk ";} + +RESOURCE STRING sys_flist_reset { str="File list reset"; } +RESOURCE STRING sys_device_memory { str="Internal"; } +RESOURCE STRING sys_path_is { str="Path is %s"; } +RESOURCE STRING sys_choose_directory { str="Choose a directory"; } +RESOURCE STRING sys_choose_filename { str="Choose a filename"; } +RESOURCE STRING sys_choose_new_directory { str="Directory already exists"; } +RESOURCE STRING sys_exists_over { str="File already exists: overwrite?"; } + +/* Next two strings have a maximum length of 5 characters each */ +RESOURCE STRING sys_max { str="Max"; } +RESOURCE STRING sys_min { str="Min"; } + +RESOURCE STRING sys_dec_places { str="Decimal places"; } +RESOURCE STRING sys_sig_digits { str="Significant digits"; } +RESOURCE STRING sys_evaldlg_title { str="Set \"Evaluate\" format"; } +RESOURCE STRING sys_nothing_to_eval { str="Nothing to evaluate"; } +RESOURCE STRING sys_toolong_to_eval { str="Too long to evaluate"; } + +RESOURCE STRING sys_xonxoff_string {str="XON/XOFF ";} +RESOURCE STRING sys_header_str { str="Enter header details"; } +RESOURCE STRING sys_footer_str { str="Enter footer details"; } + +/* max len of next 2 strs is 9 (including the space and the brackets) */ +RESOURCE STRING sys_centimetres { str=" (cm)"; } +RESOURCE STRING sys_inches { str=" (inches)"; } + +RESOURCE STRING sys_dev_notready { str=" Absent!"; } +RESOURCE STRING sys_dev_corrupt { str=" Unformatted!"; } +RESOURCE STRING sys_dev_unknown { str=" Unrecognised!"; } +RESOURCE STRING sys_dev_info { str=", %luK free"; } + +RESOURCE STRING sys_mtype_unknown { str="Unknown"; } +RESOURCE STRING sys_mtype_floppy { str="Floppy"; } +RESOURCE STRING sys_mtype_hard { str="Hard"; } +RESOURCE STRING sys_mtype_flash { str="Flash"; } +RESOURCE STRING sys_mtype_ram { str="Ram"; } +RESOURCE STRING sys_mtype_rom { str="Rom"; } +RESOURCE STRING sys_mtype_protected { str="Protected"; } + +/* Maximum of 14 character widths for the following 5 strings */ +RESOURCE STRING sys_files_tagged { str="(Tagged files)"; } +RESOURCE STRING sys_no_files { str="(No files)"; } +RESOURCE STRING sys_no_disk { str="(No disk)"; } +RESOURCE STRING sys_unformatted { str="(Unformatted)"; } +RESOURCE STRING sys_unrecognised { str="(Unrecognised)"; } + +RESOURCE STRING sys_sound_fail { str="Sound in use - please retry"; } + +/*********** THE ALLOWED SPECIAL KEYS FOR ACTION BUTTONS ******************/ + +/* You can translate the text, but no more than six characters each */ + +RESOURCE ACLIST_ARRAY sys_button_text + { + button= + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Enter"; + }, + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Esc"; + }, + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Del"; + }, + PUSH_BUT + { + keycode=W_KEY_SPACE; + str="Space"; + }, + PUSH_BUT + { + keycode=W_KEY_UP; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_DOWN; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_RIGHT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_LEFT; + str=; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Tab"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Menu"; + } + }; + } + + +/************************* ACTION LISTS ******************************/ + +/* Change the keycodes too, but don't lose the minus signs */ + +RESOURCE ACLIST_ARRAY sys_ac_no_yes + { + button = + { + PUSH_BUT + { + keycode=-'n'; + str="No"; + }, + PUSH_BUT + { + keycode='y'; + str="Yes"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_continue + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Continue"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_ac_abandon + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Abandon"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_append_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Append"; + } + }; + } + +/* Careful not to make the combined width of these strings much wider */ + +RESOURCE ACLIST_ARRAY sys_smart_dial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_ESCAPE; + str="Cancel"; + }, + PUSH_BUT + { + keycode=W_KEY_MENU; + str="Free input"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Dial"; + }, + PUSH_BUT + { + keycode=W_KEY_RETURN; + str="Dial out"; + } + }; + } + +RESOURCE ACLIST_ARRAY sys_freedial_aclist + { + button = + { + PUSH_BUT + { + keycode=W_KEY_DELETE_LEFT; + str="Clear"; + }, + PUSH_BUT + { + keycode=W_KEY_TAB; + str="Redial"; + } + }; + } + +/************************* CHOICE LISTS *****************************/ + +RESOURCE MENU sys_no_yes + { + items = + { + CHOICE_ITEM { str= "No";}, + CHOICE_ITEM { str="Yes";} + }; + } + +RESOURCE MENU sys_offon_menu + { + items = + { + CHOICE_ITEM { str="Off";}, + CHOICE_ITEM { str= "On";} + }; + } + +RESOURCE MENU sys_printer_units_chlist + { + items = + { + CHOICE_ITEM { str= "Inches";}, /* matches with E_IMPERIAL */ + CHOICE_ITEM { str= "Centimetres";} /* matches with E_METRIC */ + }; + } + +RESOURCE MENU sys_printer_device_chlist + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";} + }; + } + + +RESOURCE MENU sys_baud_rate_chlist + { + items = + { + CHOICE_ITEM { str= "19200";}, /* new for S3a */ + CHOICE_ITEM { str= "9600";}, + CHOICE_ITEM { str= "4800";}, + CHOICE_ITEM { str= "2400";}, + CHOICE_ITEM { str= "1200";}, + CHOICE_ITEM { str= "600";}, + CHOICE_ITEM { str= "300";} + }; + } + +RESOURCE MENU sys_data_bits_chlist + { + items = + { + CHOICE_ITEM { str="5";}, + CHOICE_ITEM { str="6";}, + CHOICE_ITEM { str="7";}, + CHOICE_ITEM { str="8";} + }; + } + +RESOURCE MENU sys_stop_bits_chlist + { + items = + { + CHOICE_ITEM { str="1";}, + CHOICE_ITEM { str="2";} + }; + } + +RESOURCE MENU sys_parity_chlist + { + items = + { + CHOICE_ITEM { str="None";}, + CHOICE_ITEM { str="Even";}, + CHOICE_ITEM { str= "Odd";} + }; + } + +RESOURCE MENU sys_format_chlist + { + items = + { + CHOICE_ITEM { str="Fixed";}, + CHOICE_ITEM { str="Scientific";}, + CHOICE_ITEM { str="General";}, + CHOICE_ITEM { str="Hexadecimal";} + }; + } + +RESOURCE MENU sys_rad_deg + { + items = + { + CHOICE_ITEM { str= "Radians";}, + CHOICE_ITEM { str= "Degrees";} + }; + } + +/* IMPORTANT, order in next array must be same as in page_size menu below */ +/* Also, at most 10 entries allowed, and the first two cannot be altered */ +/* But change any of the others, if you wish */ +/* 1 mm is 1440/25.4 units in the dimensions used, so eg 148 mm is 8391 */ +/* so you could have {width=8391; ... for one entry (an A5 letter size) */ + +RESOURCE PAGE_SIZE_ARRAY sys_page_dimensions + { + page_size= + { + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_A4; length=PAGE_LENGTH_A4;}, + PAGE_SIZE {width=PAGE_WIDTH_EXECUTIVE; length=PAGE_LENGTH_EXECUTIVE;}, + PAGE_SIZE {width=PAGE_WIDTH_LEGAL; length=PAGE_LENGTH_LEGAL;}, + PAGE_SIZE {width=PAGE_WIDTH_LETTER; length=PAGE_LENGTH_LETTER;}, + PAGE_SIZE {width=PAGE_WIDTH_MONARCH; length=PAGE_LENGTH_MONARCH;}, + PAGE_SIZE {width=PAGE_WIDTH_DL; length=PAGE_LENGTH_DL;} + }; + } + +RESOURCE MENU sys_page_size + { + items= + { + CHOICE_ITEM {str="A4";}, + CHOICE_ITEM {str="Custom";}, + CHOICE_ITEM {str="Executive";}, + CHOICE_ITEM {str="Legal";}, + CHOICE_ITEM {str="Letter";}, + CHOICE_ITEM {str="Monarch";}, + CHOICE_ITEM {str="DL";} + }; + } + +RESOURCE MENU sys_orient + { + items= + { + CHOICE_ITEM {str="Portrait";}, + CHOICE_ITEM {str="Landscape";} + }; + } + +RESOURCE MENU sys_prn_pos + { + items= + { + CHOICE_ITEM {str="Normal";}, + CHOICE_ITEM {str="Superscript";}, + CHOICE_ITEM {str="Subscript";} + }; + } + +RESOURCE MENU sys_headfoot_align + { + items= + { + CHOICE_ITEM {str="Left";}, + CHOICE_ITEM {str="Right";}, + CHOICE_ITEM {str="Centred";}, + CHOICE_ITEM {str="Justified";}, + CHOICE_ITEM {str="Two column";}, + CHOICE_ITEM {str="Three column";} + }; + } + +RESOURCE MENU sys_pgno_choice + { + items= + { + CHOICE_ITEM {str="1,2,3";}, + CHOICE_ITEM {str="I,II,III";}, + CHOICE_ITEM {str="i,ii,iii";} + }; + } + +/************************* DIALOGS ********************************/ + +RESOURCE DIALOG sys_error_dialog + { + flags=DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_continue; + }; + } + }; + } + +RESOURCE DIALOG sys_query_dialog + { + flags = DLGBOX_ACTION_LIST|DLGBOX_REPORT_ACT_HORIZ; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_no_yes; + }; + } + }; + } + +RESOURCE DIALOG sys_printing_dialog + { + flags=DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_ac_abandon; + }; + } + }; + } + +RESOURCE DIALOG sys_set_port_dialog + { + title="Set Serial port"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Baud rate"; + info=CHLIST + { + rid=sys_baud_rate_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Data bits"; + info=CHLIST + { + rid=sys_data_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Stop bits"; + info=CHLIST + { + rid=sys_stop_bits_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Parity"; + info=CHLIST + { + rid=sys_parity_chlist; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Ignore parity"; + info=CHLIST + { + rid=sys_no_yes; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_set_hshk_dialog + { + title="Set serial handshake"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="XON/XOFF"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="RTS/CTS"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="DSR/DTR"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="DCD"; + info=CHLIST + { + rid=sys_offon_menu; + nsel=0; + }; + } + }; + } + +RESOURCE DIALOG sys_printer_config_dialog + { + title="Printer configuration"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Printer device"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + info=CHLIST + { + rid=sys_printer_device_chlist; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial characteristics "; + info=TXTMESS + { + str="19200 "; /* changed for S3a */ + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Serial handshaking "; + info=TXTMESS + { + str="XON/XOFf Off "; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + flags=DLGBOX_ITEM_NEEDS_PACK|DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_FNEDIT; + prompt="File:"; + info=FNEDIT { flags=IN_FNEDIT_NO_AUTOQUERY; }; + } +/* 'Units' control omitted for Workabout */ + }; + } + +RESOURCE DIALOG sys_eval_dialog + { + title="Set Calculator format"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Format"; + info=CHLIST { rid=sys_format_chlist; }; + }, + CONTROL + { + class=C_NCEDIT; + /* The following line must be the wider of the 2 above strings */ + /* sys_dec_places and sys_sig_digits */ + prompt="Significant digits"; + info=NCEDIT + { + high=12; + low=0; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Trigonometry units"; + info=CHLIST { rid=sys_rad_deg; }; + } + }; + } + +RESOURCE DIALOG sys_country_selector_dialog + { + title="Append country"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_WLDSELWN; + prompt="Country"; + info=WLDSELWN {flags=IN_WLDSELWN_COUNTRY|IN_WLDSELWN_SETHOME; }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_append_aclist; + }; + } + }; + } + +RESOURCE CONTROL sys_smart_dial_item + { + class=C_EDWIN; + prompt=; + info=EDWIN + { + maxlen=WR_MAX_DIAL_STRING; + vulen=20; + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_NO_AUTOSELECT; + }; + } + +RESOURCE DIALOG sys_smart_dial_dialog + { + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_ACTION_LIST|DLGBOX_RBUF_FILLED|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD|DLGBOX_ITEM_UNDERLINED; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + str="Dial"; + }; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_smart_dial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_freedial_dialog + { + title="Free-form dialling"; + flags = DLGBOX_NO_WAIT|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_FREEDIAL; + prompt=; + }, + CONTROL + { + class=C_ACLIST; + info=ACLIST + { + rid=sys_freedial_aclist; + }; + } + }; + } + +RESOURCE DIALOG sys_flist_dialog + { + title="Specify filelist"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Filename pattern"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + }, + CONTROL + { + class=C_EDWIN; + prompt="Full path"; + info=EDWIN + { + maxlen=P_FNAMESIZE; + vulen=18; + flags=IN_EDWIN_VULEN_CHARACTERS; + }; + } + }; + } + +RESOURCE DIALOG sys_print_control_dl + { + title="Print setup"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_NOTIFY_ESCAPE|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + prompt="Page size"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Margins"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Header"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Footer"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Paging control"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } +/* 'Printer model' control omitted for Workabout */ + }; + } + +RESOURCE DIALOG sys_paging_control_dl + { + title="Paging control"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Number for first page"; + info=NCEDIT + { + low=1; + high=9999; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Allow widows/orphans"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Page number style"; + info=CHLIST{rid=sys_pgno_choice;}; + } + }; + } + +RESOURCE DIALOG sys_printer_model + { + title="Set printer"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + prompt="Select printer"; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + info=CHLIST{}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Default font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE DIALOG sys_margins_dl + { + title="Margins"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_FLTEDIT; + prompt="Top"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Left"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Right"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Bottom"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_headfoot_dl + { + title="*"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_EDWIN; + prompt="Text"; + info=EDWIN + { + flags=IN_EDWIN_VULEN_CHARACTERS|IN_EDWIN_ACCEPT_TABS; + maxlen=80; + vulen=20; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Alignment"; + info=CHLIST{rid=sys_headfoot_align;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="On first page"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Font"; + info=TXTMESS + { + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Vertical offset"; + info=FLTEDIT + { + low=0; + high=9.99; + ndec=2; + }; + } + }; + } + +RESOURCE DIALOG sys_pagesize_dl + { + title="Page size"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_APPEND_UNITS_TITLE; + controls= + { + CONTROL + { + class=C_CHLIST; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + prompt="Page size"; + info=CHLIST{rid=sys_page_size;}; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Width"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_FLTEDIT; + prompt="Height"; + info=FLTEDIT + { + low=1; + high=45; + ndec=2; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Orientation"; + info=CHLIST{rid=sys_orient;}; + } + }; + } + +RESOURCE DIALOG sys_font_dl + { + title="Font"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + class=C_CHLIST; + prompt="Font"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Size"; + info=CHLIST{}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Underline"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Bold"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Italic"; + info=CHLIST{rid=sys_no_yes;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Print position"; + info=CHLIST{rid=sys_prn_pos;}; + } + }; + } + +RESOURCE CONTROL sys_txtmess + { + class=C_TEXTWIN; + flags=DLGBOX_ITEM_CENTRE|DLGBOX_ITEM_DEAD; + info=TXTMESS + { + flags=IN_TEXTWIN_AL_CENTRE; + }; + } + +/************************* HELP ********************************/ + +RESOURCE TOPIC_ARRAY sys_help_index_data +{ +id_lst= +{ +sys_help_on_off, +sys_help_battery, +sys_help_calendar, +sys_help_edit, +sys_help_dialog, +sys_help_statwin, +sys_help_files, +sys_help_filsels, +sys_help_evaluate, +sys_help_print, +sys_help_in_use, +sys_help_no_sys_mem +}; +} + +RESOURCE HELP_ARRAY sys_help_index +{ +topic="Index"; +topic_id=sys_help_index_data; +} + +RESOURCE HELP_ARRAY sys_help_on_help +{ +topic="About Help"; +strlst= +{ +STRING {str="To choose topic:""then Enter.";}, +STRING {str="Ctrl-Esc displays Help index.";}, +STRING {str="Esc exits Help index.";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialog +{ +topic="Menu/dialog tips"; +strlst= +{ +STRING {str="Press Menu key to see menu bar.";}, +STRING {str=" moves between menus.";}, +STRING {str=" moves between options.";}, +STRING {str="Enter selects highlighted option.";}, +STRING {str="";}, +STRING {str="Accelerator-keys (""-X etc.)";}, +STRING {str="access menu options directly.";}, +STRING {str="";}, +STRING {str="Tab often lists choices in dialogs";} +}; +} + +RESOURCE HELP_ARRAY sys_help_statwin +{ +topic="Screen display"; +strlst= +{ +STRING {str="Press ""-Tab to switch";}, +STRING {str="between applications.";}, +STRING {str="";}, +STRING {str="`Zoom in/out' to change";}, +STRING {str="character size.";}, +STRING {str="";}, +STRING {str="Depending on the application,";}, +STRING {str="press ""-Menu for a Status";}, +STRING {str="Window or Ctrl-Menu to set size";} +}; +} + +RESOURCE HELP_ARRAY sys_help_dialling +{ +topic="Dialling"; +strlst= +{ +STRING {str="";} +}; +} + +RESOURCE HELP_ARRAY sys_help_filsels +{ +topic="File selection"; +strlst= +{ +STRING {str="Press Tab in file selection dialogs";}, +STRING {str="to choose from a full list of";}, +STRING {str="files/directories. ""-Tab";}, +STRING {str="displays full path. Typing:";}, +STRING {str="Letter matches filename";}, +STRING {str="Shift+letter matches directory";}, +STRING {str="Ctrl+letter matches drive";}, +STRING {str="";}, +STRING {str="In file-related dialogs:";}, +STRING {str="""-Tab gives full path";}, +STRING {str="To select a wildcard filespec in a";}, +STRING {str="dialog, use Ctrl-Tab, type the";}, +STRING {str="filespec, then press Ctrl-Enter";} +}; +} + +RESOURCE HELP_ARRAY sys_help_edit +{ +topic="Editing"; +strlst= +{ +STRING {str="In the full-screen text editors:";}, +STRING {str="Use "ARROWS4" to move cursor Ctrl";}, +STRING {str="and "" keys increase movement.";}, +STRING {str="";}, +STRING {str="Shift-"ARROWS4" highlights text:";}, +STRING {str="Use Delete to cut text to the";}, +STRING {str="clipboard (or `Copy text' to copy,";}, +STRING {str="it) then `Insert text' to paste";}, +STRING {str="the text back in.";}, +STRING {str="Shift-Del deletes text without";}, +STRING {str="changing the contents of the";}, +STRING {str="clipboard.";}, +STRING {str="";}, +STRING {str="Use `Bring' option to copy text";}, +STRING {str="which has been highlighted in";}, +STRING {str="another application.";}, +STRING {str="";}, +STRING {str="Quick delete methods (when";}, +STRING {str="no text is highlighted):";}, +STRING {str="Shift-Del: next character";}, +STRING {str="Shift-""-Del: to end of line";}, +STRING {str="""-Del: to beginning of line";}, +STRING {str="";}, +STRING {str="Quick highlight methods:";}, +STRING {str="""-Shift-Ctrl-"": current word";}, +STRING {str="""-Shift-Ctrl-"": current line";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_help +{ +id_lst= +{ +sys_help_on_help +}; +} + +RESOURCE HELP_ARRAY sys_help_files +{ +topic="Files in applications"; +strlst= +{ +STRING {str="See `New file', `Open file',";}, +STRING {str="`Merge in', `Compress file',";}, +STRING {str="`Save as', `Save' and `Revert'";}, +STRING {str="in relevant applications";}, +STRING {str="";}, +STRING {str="Various file handling facilities";}, +STRING {str="are provided in both the";}, +STRING {str="System Interfaces";} +}; +} + +RESOURCE HELP_ARRAY sys_help_print +{ +topic="Printing/Preview"; +strlst= +{ +STRING {str="In applications which can";}, +STRING {str="Print, first use `Print setup'";}, +STRING {str="to set `Printer Model'";}, +STRING {str="";}, +STRING {str="Use `Print preview' to see a";}, +STRING {str="preview with its own menu of";}, +STRING {str="options. (You don't have to";}, +STRING {str="wait for the preview to finish";}, +STRING {str="calculating: Esc cancels, etc).";}, +STRING {str="Print preview's menu usually";}, +STRING {str="includes a `Print' option";} +}; +} + +RESOURCE HELP_ARRAY sys_time_basics +{ +topic="Time basics"; +strlst= +{ +STRING {str="";} +}; +} + +RESOURCE HELP_ARRAY sys_help_on_off +{ +topic="On/off"; +strlst= +{ +STRING {str="On/Esc turns on";}, +STRING {str="Off turns off";} +}; +} + +RESOURCE TOPIC_ARRAY sys_help_x_index +{ +id_lst= +{ +sys_help_index +}; +} + +/************************* LATER ADDITIONS ********************************/ + +/* Name of general printer driver */ +RESOURCE STRING sys_wdr_general { str="General"; } + +RESOURCE STRING sys_dial_out { str="9,"; } /* 5 chars max */ +RESOURCE STRING sys_skipping_page { str="(skipping page %u)";} + +/************************* NEW FOR Series 3a *****************************/ + +/* TTT: This file is entirely new for the S3a. +You must translate EVERY text string, accelerator etc in this +file (except those marked "Do not translate", of course) - not just +those things which are marked with TTT */ + + +/* TTT: Only used by developers */ +RESOURCE STRING sys_debugging_num_cells {str="Diagnostics: %d (%u)";} + +/********* for Calendar Window in Agenda **********/ + +/* TTT: eg "Calendar 1998" or "Calendar 1993-1994" */ +RESOURCE STRING sys_calendar {str="Calendar %Y";} + +/*********************** FOR PRINT PREVIEW ******************************/ +/* TTT: "Print preview" option in Word, Agenda, Sheet... uses these: */ +RESOURCE STRING sys_page {str="page";} +RESOURCE STRING sys_pages {str="pages";} +RESOURCE STRING sys_preview_busy {str="Busy, cannot print yet";} +RESOURCE STRING sys_display_margins {str="Show margins";} +RESOURCE STRING sys_hide_margins {str="Hide margins";} + +RESOURCE STRING sys_opening_prompt {str="Opening \"%s\"";} + +/* TTT: NB "Print preview" is a standard WP term... if every Wp in your +country uses one term for this, you must use it too */ +RESOURCE STRING sys_print_preview {str="Print preview";} + +/* TTT length of longest in sys_preview_margins_chlist + length of longest +in sys_preview_options_chlist must be less than 50 */ +RESOURCE MENU sys_preview_margins_chlist + { + items= + { + CHOICE_ITEM {str="Margins off";}, + CHOICE_ITEM {str="Margins on";} + }; + } + +RESOURCE MENU sys_preview_options_chlist + { + items= + { + CHOICE_ITEM {str="Facing pages";}, + CHOICE_ITEM {str="1 page";}, + CHOICE_ITEM {str="2 pages";}, + CHOICE_ITEM {str="3 pages";}, + CHOICE_ITEM {str="4 pages";} + }; + } + +RESOURCE DIALOG sys_preview_options_dialog + { + title="Display"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt=""; + info=CHLIST{rid=sys_preview_options_chlist;}; + } + }; + } + +RESOURCE DIALOG sys_preview_jump_dialog + { + title="Jump to page"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED|DLGBOX_NO_DDP; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Page number"; + info=NCEDIT + { + low=1; + high=9999; + }; + } + }; + } + +RESOURCE WSERV_INFO sys_preview_acc + { + menbar_id=sys_preview_menubar; + first_com=O_PVC_PREVIEW_PRINT; + accel= + { + 'p', /* Print */ + 'm', /* Margins */ + 'd', /* Pages to display */ + 'j', /* Jump to page */ + '*' /* Exit preview */ + }; + } + +RESOURCE MENU_BAR sys_preview_menubar + { + items = + { + MENU_BAR_ITEM + { + menu_id=sys_preview_menu; + mb_item="Preview"; + } + }; + } + +RESOURCE MENU sys_preview_menu + { + items = + { + MENU_ITEM + { + com_id=O_PVC_PREVIEW_PRINT; + mn_item="Print"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_MARGINS; +/* TTT: use whichever's the longer: "Show margins" or "Hide margins" */ + mn_item="Show margins"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_OPTIONS; + mn_item="Pages to display"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_JUMP|BREAK_LINE_FOLLOWS; + mn_item="Jump to page"; + }, + MENU_ITEM + { + com_id=O_PVC_PREVIEW_EXIT; + mn_item="Exit preview"; + } + }; + } + +RESOURCE MENU sys_printer_devices + { + items = + { + CHOICE_ITEM { str= "Parallel";}, + CHOICE_ITEM { str= "Serial";}, + CHOICE_ITEM { str= "File";}, + CHOICE_ITEM { str= "Fax";} + }; + } + +RESOURCE CONTROL sys_print_control_device + { + class=C_TEXTWIN; +/* TTT: You'll see this on the bottom of the Print Setup dialog +in Word, Agenda... */ + prompt="Printer device"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE CONTROL sys_print_preview_settings + { +/* TTT: You'll see this on the bottom of the Printer configuration dialog +in the Shell */ + class=C_TEXTWIN; + prompt="Print preview"; + info=TXTMESS + { + str="Facing pages,Margins off"; /* TTT widest possible */ + flags=IN_TEXTWIN_POPOUT; + }; + } + +RESOURCE DIALOG sys_preview_settings_dl + { + title="Preview settings"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + prompt="Display"; + info=CHLIST{rid=sys_preview_options_chlist;}; + }, + CONTROL + { + class=C_CHLIST; + prompt="Margins"; + info=CHLIST{rid=sys_offon_menu;}; + } + }; + } + +RESOURCE MENU sys_standard_sounds + { + items= + { +/* TTT: Built-in sounds, when you're setting an alarm in Time */ + CHOICE_ITEM {str="Rings";}, + CHOICE_ITEM {str="Chimes";}, + CHOICE_ITEM {str="Fanfare";}, + CHOICE_ITEM {str="Soft bells";}, + CHOICE_ITEM {str="Church bell";} + }; + } + +/* TTT: do not translate */ +RESOURCE STRING sys_alarm_standard_name {str="SYS$AL01";} +/* TTT: The "silent" sound, when setting an alarm */ +RESOURCE STRING sys_silent_alarm {str="Silent";} +/* TTT: If you try to play a sound, but sound is disabled... */ +RESOURCE STRING sys_sound_disabled {str="Sound disabled";} +/* TTT: do not translate the next one */ +RESOURCE STRING sys_word_rom { str="ROM::WORD.APP"; } +/* TTT: the user has refused to replace an SSD */ +RESOURCE STRING sys_restart_from_sys { str="Press Esc to exit application"; } + +/* TTT: when creating a new file: eg gives "Myfile" created +You can change these around if you like, eg we could've done the English +as str="Created \"%s\"" to give Created "Myfile" */ +RESOURCE STRING srt_file_created { str="\"%s\" created"; } +RESOURCE STRING srt_file_opened { str="\"%s\" opened"; } +RESOURCE STRING srt_file_saved { str="\"%s\" saved"; } +RESOURCE STRING srt_file_compressed { str="\"%s\" compressed"; } +RESOURCE STRING srt_file_merged { str="\"%s\" merged in"; } +RESOURCE STRING sys_saving_prompt {str="Saving \"%s\"";} +RESOURCE STRING sys_reloading_prompt {str="Reopening \"%s\"";} +RESOURCE STRING sys_converting_prompt {str="Converting \"%s\"";} + +/* TTT: When we refuse to save the file, because it hasn't changed */ +RESOURCE STRING sys_not_changed {str="Not changed";} +/* TTT: When you're exiting, but it failed to save the file for some reason */ +RESOURCE STRING sys_confirm_continue {str="Not saved, continue anyway?";} +/* TTT: When you're using the "Exit, lose changes" option: */ +RESOURCE STRING sys_confirm_change_loss {str="Confirm the loss of all changes";} +/* TTT: used with the previous two strings */ +RESOURCE STRING sys_losing_changes {str="(`Yes' discards all changes)";} +RESOURCE STRING sys_nothing_to_print {str="Nothing to print";} +RESOURCE STRING sys_nothing_to_insert {str="Nothing to insert";} +RESOURCE STRING sys_nothing_to_copy {str="Nothing to copy";} +/* TTT: preferably use the same word as the "Revert" menu option */ +RESOURCE STRING sys_revert_to_saved {str="Revert to saved?";} + +/* TTT: For use in menus (hotkeys) */ +RESOURCE STRING sys_shift_key_name {str="Shift";} + +/* TTT: When you use "Current country only" (or diamond key) World App... */ +RESOURCE STRING srt_space_only { str=" (only)"; } + +RESOURCE STRING sys_change_password {str="Change password";} + +RESOURCE DIALOG sys_set_password_dl + { + title = "Set password"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + }, + CONTROL + { + class=C_XEDIT; + prompt="Confirm password"; + } + }; + } + +RESOURCE DIALOG sys_get_password_dl + { + title = "Password protected"; + flags=DLGBOX_NOTIFY_ENTER; + controls= + { + CONTROL + { + class=C_XEDIT; + prompt="Enter password"; + } + }; + } + +/* TTT Extra help - translate this! */ +/* BUT DON'T MAKE THE TEXT WIDER THAN WILL FIT ON COMPATIBILITY MODE SCREENS +(BEAR IN MIND THAT THIS HELP IS AVAILABLE TO COMPATIBILITY MODE APP) */ + +RESOURCE HELP_ARRAY sys_help_evaluate +{ +topic="Evaluate"; +strlst= +{ +STRING {str="In applications such as the";}, +STRING {str="program editor, type a";}, +STRING {str="calculation (without `=' or";}, +STRING {str="spaces). Then use `Evaluate'";}, +STRING {str="menu option for result";} +}; +} + +RESOURCE HELP_ARRAY sys_help_memo +{ +topic="Memo editor"; +} + +RESOURCE HELP_ARRAY sys_help_in_use +{ +topic="File or device in use"; +strlst= +{ +STRING {str="You will see this message if you";}, +STRING {str="try to copy, delete or rename a";}, +STRING {str="file which is currently open.";}, +STRING {str="Exit the file then try again.";}, +STRING {str="";}, +STRING {str="You will also see it if you try to";}, +STRING {str="use, at the same time, through";}, +STRING {str="the same port, two serial devices,";}, +STRING {str="such as:";}, +STRING {str="The `Remote link' option";}, +STRING {str="A Comms application";}, +STRING {str="A printer";} +}; +} + +RESOURCE HELP_ARRAY sys_help_no_sys_mem +{ +topic="No system memory"; +strlst= +{ +STRING {str="This message usually means all";}, +STRING {str="the internal memory has been";}, +STRING {str="used up. Exit some open files,";}, +STRING {str="or delete unwanted files from";}, +STRING {str="the `Internal' disk, to free";}, +STRING {str="some more memory";} +}; +} + +RESOURCE HELP_ARRAY sys_help_calendar +{ +topic="Calendars"; +strlst= +{ +STRING {str="When you are entering a date";}, +STRING {str="in a dialog, you can press Tab";}, +STRING {str="to display a one month calendar";}, +STRING {str="";}, +STRING {str="In the calendar: "ARROWS" move";}, +STRING {str="the cursor around the screen";}, +STRING {str="""-"" move a month";}, +STRING {str="Ctrl-"" move a year";}, +STRING {str="Space moves to today";} +}; +} + +/************************* NEW FOR Workabout *****************************/ + +RESOURCE DIALOG sys_s3c_print_control_dl + { + title="Print setup"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_NOTIFY_ESCAPE|DLGBOX_SMALL_FONT; + controls= + { + CONTROL + { + class=C_TEXTWIN; + prompt="Page setup"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Units"; + flags=DLGBOX_ITEM_UNDERLINED; + info=CHLIST + { + rid=sys_printer_units_chlist; + }; + }, + CONTROL + { + class=C_TEXTWIN; + prompt="Model"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { /* copy from sys_print_control_device */ + class=C_TEXTWIN; + prompt="Device"; + info=TXTMESS + { + str=""; + flags=IN_TEXTWIN_POPOUT; + }; + }, + CONTROL + { /* copy from sys_print_preview_settings */ + class=C_TEXTWIN; + prompt="Preview"; + info=TXTMESS + { + str="Facing pages,Margins off"; /* TTT widest possible */ + flags=IN_TEXTWIN_POPOUT; + }; + } + }; + } + +RESOURCE STRING sys_s3c_page_setup { str="Page setup"; } + +RESOURCE HELP_ARRAY sys_help_battery +{ +topic="Battery information"; +strlst= +{ +STRING {str="Press Shift-Ctrl-B in any";}, +STRING {str="application to display the";}, +STRING {str="battery information dialog";} +}; +} diff --git a/code/SIBOSDK/s3atool/iconeda.app b/code/SIBOSDK/s3atool/iconeda.app new file mode 100644 index 0000000..8895486 Binary files /dev/null and b/code/SIBOSDK/s3atool/iconeda.app differ diff --git a/code/SIBOSDK/s3atool/spya.app b/code/SIBOSDK/s3atool/spya.app new file mode 100644 index 0000000..43348ff Binary files /dev/null and b/code/SIBOSDK/s3atool/spya.app differ diff --git a/code/SIBOSDK/src/bcd.cpp b/code/SIBOSDK/src/bcd.cpp new file mode 100644 index 0000000..3fbd1b1 --- /dev/null +++ b/code/SIBOSDK/src/bcd.cpp @@ -0,0 +1,180 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* BCD.CPP - BCD number class implementation. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include + +#pragma module(init_prio=>22) + + bcd::bcd(int x) { + + int_to_dec((unsigned long) abs(x)); + if(x < 0) + bcd_array[9]|=0x80; +} + + bcd::bcd(unsigned x) { + + int_to_dec((unsigned long) x); +} + + bcd::bcd(long x) { + + int_to_dec((unsigned long) labs(x)); + if(x < 0) + bcd_array[9]|=0x80; +} + + bcd::bcd(unsigned long x) { + + int_to_dec(x); +} + +bcd bcd::operator-() { + + bcd_array[9]^=0x80; + return *this; +} + +ostream& operator<<(ostream& os, bcd& b) { + + os << real(b); + return os; +} + +istream& operator>>(istream& is, bcd& b) { + + long double n; + + is >> n; + b.real_to_dec(n); + return is; +} + +void bcd::bcd_copy_to(unsigned char *source) { + + int n=0; + + while(n < 10) { + bcd_array[n] = source[n]; + ++n; + } +} + + +void bcd::bcd_copy_from(unsigned char *dest) { + + int n=0; + + while(n < 10) { + dest[n] = bcd_array[n]; + ++n; + } +} + +void bcd::int_to_dec(unsigned long x) { + + char s[32]; + int l, n, c, p; + unsigned char cv; + + if(!x) + exp=ExpZero; + else + exp=110 + (int)log10((double) (x)); + ultoa(x, s, 10); + l=strlen(s); + p=0; + while(p < 10) { + bcd_array[p++]=0; + } + p=8; + n=0; + while(n < l) { + c=s[n++]; + cv=(c-0x30)<<4; + if(n == l) { + bcd_array[p]=cv; + break; + } + c=s[n++]; + cv|=(c-0x30); + bcd_array[p--]=cv; + } +} + +#pragma save +#pragma call(reg_param=>(ax)) +extern "C" long double _cvt_bcd(unsigned char/* <_SS>*/ *); +#pragma restore + +long double bcd::dec_to_real() { + + long double n; + unsigned char bcd_temp[10]; + + bcd_copy_from(bcd_temp); + n=_cvt_bcd(bcd_temp); + n*= pow10((double)(exp-127)); + return n; +} + +void bcd::real_to_dec(long double x, int decimals) { + + long double zero = 0; + long double norm; + int k,clear,n; + unsigned char bcd_temp[10]; + + if ( x < zero ) { + x = -x; + bcd_temp[9] = 0x80; + } + else + bcd_temp[9] = 0; + + if ( x == zero ) + k = -10000; + else { + k = 1 + (int) floorl( log10l(x) + 0.001 ); + } + + while (1) { + norm = x; + if ( k != -10000 ) + norm *= _pow_int(10,18-k); + + _bcd( norm, (char near *)bcd_temp ); + if ( k == -10000 ) { + k = 1; + break; + } + if ( ( bcd_temp[8] >> 4 ) != 0 ) + break; + k -= 1; + } + exp = 109 + k; + + if((k < 0) && (decimals != _BcdMaxDecimals)) { + clear = abs(k) + decimals; + n = 0; + while(clear) { + bcd_temp[n] &= ~0x0F; + if(--clear == 0) + break; + bcd_temp[n] &= ~0xF0; + --clear; + ++n; + } + } + bcd_copy_to(bcd_temp); +} + + \ No newline at end of file diff --git a/code/SIBOSDK/src/cdata.c b/code/SIBOSDK/src/cdata.c new file mode 100644 index 0000000..24845f5 --- /dev/null +++ b/code/SIBOSDK/src/cdata.c @@ -0,0 +1,220 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* cdata.c - C library data * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* Written by Simon Knight. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Modified by NSM. * +* * +*--------------------------------------------------------------------------*/ +#define _USE_TIME +#include + +char _cvt_buf[64]; /* real number conversion buffer */ +int daylight=0; /* daylight saving flag */ +time_t timezone=0; /* timezone variable */ + +struct lconv _lconv={".", "", "", "", "", "", "", "", "", "", + CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, + CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX }; + +jmp_buf _EOFhandler; /* EOF error jump environment */ +int _open_init; +int _s_args; /* argument count */ +int _vp_ret; /* character count */ +int _vs_count; /* character count */ + +int (*_vs_fill)(FILE *st); /* filler function pointer */ +int (*_vp_flush)(FILE *st); /* output function pointer */ + +/*-------------------------------------------------------------------------* +* error message output - data declarations * +*--------------------------------------------------------------------------*/ + +#ifdef OLDERRORS +char *sys_errlist[]= +{"Unknown Error", +"Error Zero", +"Invalid Function Code", +"File Not Found", +"Path Not Found", +"Too Many Open Files", +"Access Denied", +"Invalid Handle", +"Memory Blocks Destroyed", +"Not Enough Core", +"Invalid Memory Block Address", +"Invalid Environment", +"Invalid Format", +"Invalid Access Code", +"Invalid Data", +"", +"Invalid Drive", +"Attempt To Remove CurDir", +"Not Same Device", +"No More Files", +"Invalid Argument", +"Not Directory", +"Is Directory", +"Corrupted EXE File", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"Cross-Device Link", +"Math Argument Invalid", +"Result Too Large", +"File Locking Deadlock", +"Unknown Error" +}; + +int sys_nerr=38; /* number of system error strings */ +#endif + +char _sys_errbuf[128]; /* error message buffer */ + +/*-------------------------------------------------------------------------* +* Character type array. * +*--------------------------------------------------------------------------*/ + +char _ctype[257] = { +0,/* -1 EOF */ +_IS_CTL,/* 0 NUL */ +_IS_CTL,/* 1 SOH */ +_IS_CTL,/* 2 STX */ +_IS_CTL,/* 3 ETX */ +_IS_CTL,/* 4 EOT */ +_IS_CTL,/* 5 ENQ */ +_IS_CTL,/* 6 ACK */ +_IS_CTL,/* 7 BEL */ +_IS_CTL,/* 8 BS */ +_IS_CTL|_IS_SP,/* 9 HT */ +_IS_CTL|_IS_SP,/* A LF */ +_IS_CTL|_IS_SP,/* B VT */ +_IS_CTL|_IS_SP,/* C FF */ +_IS_CTL|_IS_SP,/* D CR */ +_IS_CTL,/* E SO */ +_IS_CTL,/* F SI */ +_IS_CTL,/* 10 DLE */ +_IS_CTL,/* 11 DC1 */ +_IS_CTL,/* 12 DC2 */ +_IS_CTL,/* 13 DC3 */ +_IS_CTL,/* 14 DC4 */ +_IS_CTL,/* 15 NAK */ +_IS_CTL,/* 16 SYN */ +_IS_CTL,/* 17 ETB */ +_IS_CTL,/* 18 CAN */ +_IS_CTL,/* 19 EM */ +_IS_CTL,/* 1A SUB */ +_IS_CTL,/* 1B ESC */ +_IS_CTL,/* 1C FS */ +_IS_CTL,/* 1D GS */ +_IS_CTL,/* 1E RS */ +_IS_CTL,/* 1F UF */ +_IS_SP,/* 20 '\ ' */ +_IS_PUN,/* 21 ! */ +_IS_PUN,/* 22 " */ +_IS_PUN,/* 23 # */ +_IS_PUN,/* 24 $ */ +_IS_PUN,/* 25 % */ +_IS_PUN,/* 26 & */ +_IS_PUN,/* 27 ' */ +_IS_PUN,/* 28 ( */ +_IS_PUN,/* 29 ) */ +_IS_PUN,/* 2A * */ +_IS_PUN,/* 2B + */ +_IS_PUN,/* 2C ,*/ +_IS_PUN,/* 2D - */ +_IS_PUN,/* 2E . */ +_IS_PUN,/* 2F / */ +_IS_DIG,/* 30 0 */ +_IS_DIG,/* 31 1 */ +_IS_DIG,/* 32 2 */ +_IS_DIG,/* 33 3 */ +_IS_DIG,/* 34 4 */ +_IS_DIG,/* 35 5 */ +_IS_DIG,/* 36 6 */ +_IS_DIG,/* 37 7 */ +_IS_DIG,/* 38 8 */ +_IS_DIG,/* 39 9 */ +_IS_PUN,/* 3A : */ +_IS_PUN,/* 3B ; */ +_IS_PUN,/* 3C < */ +_IS_PUN,/* 3D = */ +_IS_PUN,/* 3E > */ +_IS_PUN,/* 3F ? */ +_IS_PUN,/* 40 @ */ +_IS_UPP|_IS_HEX,/* 41 A */ +_IS_UPP|_IS_HEX,/* 42 B */ +_IS_UPP|_IS_HEX,/* 43 C */ +_IS_UPP|_IS_HEX,/* 44 D */ +_IS_UPP|_IS_HEX,/* 45 E */ +_IS_UPP|_IS_HEX,/* 46 F */ +_IS_UPP,/* 47 G */ +_IS_UPP,/* 48 H */ +_IS_UPP,/* 49 I */ +_IS_UPP,/* 4A J */ +_IS_UPP,/* 4B K */ +_IS_UPP,/* 4C L */ +_IS_UPP,/* 4D M */ +_IS_UPP,/* 4E N */ +_IS_UPP,/* 4F O */ +_IS_UPP,/* 50 P */ +_IS_UPP,/* 51 Q */ +_IS_UPP,/* 52 R */ +_IS_UPP,/* 53 S */ +_IS_UPP,/* 54 T */ +_IS_UPP,/* 55 U */ +_IS_UPP,/* 56 V */ +_IS_UPP,/* 57 W */ +_IS_UPP,/* 58 X */ +_IS_UPP,/* 59 Y */ +_IS_UPP,/* 5A Z */ +_IS_PUN,/* 5B [ */ +_IS_PUN,/* 5C \ */ +_IS_PUN,/* 5D ] */ +_IS_PUN,/* 5E ^ */ +_IS_PUN,/* 5F _ */ +_IS_PUN,/* 60 ` */ +_IS_LOW|_IS_HEX,/* 61 a */ +_IS_LOW|_IS_HEX,/* 62 b */ +_IS_LOW|_IS_HEX,/* 63 c */ +_IS_LOW|_IS_HEX,/* 64 d */ +_IS_LOW|_IS_HEX,/* 65 e */ +_IS_LOW|_IS_HEX,/* 66 f */ +_IS_LOW,/* 67 g */ +_IS_LOW,/* 68 h */ +_IS_LOW,/* 69 i */ +_IS_LOW,/* 6A j */ +_IS_LOW,/* 6B k */ +_IS_LOW,/* 6C l */ +_IS_LOW,/* 6D m */ +_IS_LOW,/* 6E n */ +_IS_LOW,/* 6F o */ +_IS_LOW,/* 70 p */ +_IS_LOW,/* 71 q */ +_IS_LOW,/* 72 r */ +_IS_LOW,/* 73 s */ +_IS_LOW,/* 74 t */ +_IS_LOW,/* 75 u */ +_IS_LOW,/* 76 v */ +_IS_LOW,/* 77 w */ +_IS_LOW,/* 78 x */ +_IS_LOW,/* 79 y */ +_IS_LOW,/* 7A z */ +_IS_PUN,/* 7B { */ +_IS_PUN,/* 7C | */ +_IS_PUN,/* 7D } */ +_IS_PUN,/* 7E ~ */ +_IS_CTL,/* 7F DEL */ +0}; + diff --git a/code/SIBOSDK/src/cio1.a b/code/SIBOSDK/src/cio1.a new file mode 100644 index 0000000..ff0997d --- /dev/null +++ b/code/SIBOSDK/src/cio1.a @@ -0,0 +1,306 @@ +(* Release 3.00 *) + +(* c_io1 - common low level I/O *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Modified by NSM.*) + +include "corelib.inc" +include "epocdefs.inc" + +module cio1 + +(***************************************************************************) +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __filbuf + +select _TEXT +(* +int fgetc(FILE *st) +*) + +public _fgetc : + + push bx + push cx + push dx + push si + mov bx, ax + mov cx, [bx][_flag] + dec word [bx][_cnt] + js callfunc + mov si, [bx][_ptr] + inc word [bx][_ptr] + mov al, [si] + sub ah, ah +done: + test cx, _F_BIN + jnz noTrans + cmp al, CTLZ + je fgEOF + cmp al, 0DH + jne noTrans + mov ax, bx + call _fgetc +noTrans: + pop si + pop dx + pop cx + pop bx + ret 0 + +callfunc: + push bx + mov ax, bx + call __filbuf + pop bx + jmp done + +fgEOF: + or word [bx][_flag], _F_EOF + mov ax, -1 + jmp noTrans + +(* _fgetc ENDP *) + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __flsbuf +extrn __flusher + +select _TEXT +(* +int fputc(int ch, FILE *st) +*) + +public _fputc : + + push cx + push dx + push si + test word [bx][_flag], _F_BIN + jnz fpOK + cmp al, -1 + je fpError + cmp al, CTLZ + je fpEOF + cmp al, 0AH + jne fpOK + push bx + mov ax, 0DH + call _fputc + pop bx + mov ax, 0AH +fpOK: + dec word [bx][_cnt] + js callfunc + mov si, [bx][_ptr] + inc word [bx][_ptr] + mov [si], al + cmp al, 0AH + jne done + test word [bx][_flag], _F_LBUF + jz done + mov ax, bx + call __flusher +done: + pop si + pop dx + pop cx + ret 0 + +callfunc: + call __flsbuf + jmp done +fpError: + mov ax, -1 + jmp done + +fpEOF: + or word [bx][_flag], _F_CTZ + jmp fpOK + +(* _fputc ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +select _DATA + +extrn __ungotchar + +select _TEXT +public _ungetch : +(* +int ungetch(int c) +Returns character to console input stream. Returns EOF if __ungotchar +is occupied. +*) + + cmp word [__ungotchar], -1 + jne occupied + cmp ax, -1 + je occupied + mov [__ungotchar], ax + jmp ungetchDone +occupied: + mov ax, EOF +ungetchDone: + ret 0 + +(* _ungetch ENDP *) + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __ioerr + +public _chmod : +(* +int chmod(char *path, int attribute) +Returns -1 on error and sets _errno. +*) + + push bx + push cx + push di + mov cx, bx + mov bx, ax + mov di, 1 + cmp cx, S_IREAD + je chRdonly + mov cx, FileAttWrite + jmp chGotmode +chRdonly: + sub cx, cx +chGotmode: + sub al, al + mov ah, NmFilStatusSet + int FilManager + jnc chSuccess + call __ioerr (* set errno *) + mov ax, -1 + jmp chDone +chSuccess: + sub ax, ax +chDone: + pop di + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __ioerr + +public __chmod : +(* +int _chmod(char *path, int mode, int attribute) +mode 0 - returns file attribute. +mode 1 - sets file attribute to attribute. +Returns -1 on error. Low level DOS function. +*) + + push bx + push cx + push di + sub sp, FileEnt + test bx, bx + mov bx, ax + jz getAtt + mov di, FileAttWrite | FileAttHidden | FileAttSystem + and cx, di + xor cl, FileAttWrite + sub al, al + mov ah, NmFilStatusSet + int FilManager + jnc chSuccess +chFailed: + call __ioerr (* set errno *) + mov ax, -1 + jmp chDone +getAtt: + mov cx, sp + sub al, al + mov ah, NmFilStatusGet + int FilManager + jc chFailed + mov bx, sp + mov ax, [bx][FileAtt] + and ax, FileAttWrite | FileAttHidden | FileAttSystem + xor al, FileAttWrite +chSuccess: + sub ax, ax +chDone: + add sp, FileEnt + pop di + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __ioerr + +public _access : +(* +int access(char *path, int mode) +Returns 0 if mode available. +Returns -1 on error. +*) + +exist = 0 +write = 2 +read = 4 +rdwr = 6 + + push bx + push cx + push dx + sub sp, FileEnt + mov cx, sp + mov dx, bx + mov bx, ax + sub al, al + mov ah, NmFilStatusGet + int FilManager + jnc accSuccess + call __ioerr (* set errno *) +accNo: + mov ax, -1 + jmp accDone +accSuccess: + test dx, dx + je accYes + test dx, write + jz accYes + mov bx, sp + test byte [bx][FileAtt], FileAttWrite + jz accNo +accYes: + sub ax, ax +accDone: + add sp, FileEnt + pop dx + pop cx + pop bx + ret 0 + +end + + diff --git a/code/SIBOSDK/src/cio2.c b/code/SIBOSDK/src/cio2.c new file mode 100644 index 0000000..eee1edd --- /dev/null +++ b/code/SIBOSDK/src/cio2.c @@ -0,0 +1,1665 @@ +/* Release 3.00 */ +/*-------------------------------------------------------------------------* +* * +* cio2.c - common I/O * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* Written by Simon Knight. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Modified by NSM. * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_TIME +#define _USE_CONIO +#include "clib.h" + +/**************************************************************************** +* buffer flushing functions. * +****************************************************************************/ + +int _flsbuf(int ch, FILE *st) { + + int flag; + + ch&=0xFF; + flag=st->_flag; + if( (!flag) || (flag&_F_ERR)) + return(-1); + if((flag&_F_EOF) && (flag&_F_IN)) { + lseek(st->_file, 0L, SEEK_END); + st->_flag|=_F_RST; + st->_flag&=(~(_F_IN|_F_EOF)); + if(st->_size) { + _flusher(st); + --st->_cnt; + *st->_ptr++= (char) ch; + return(ch); + } + } + else { + if((!(flag&_F_WRIT)) || (flag&_F_IN) + || ((!(flag&_F_BIN)) && ((char) ch == EOF))) { + st->_flag|=_F_ERR; + return(-1); + } /* return error */ + if(st->_size) { /* buffered */ + if(_flusher(st)== -1 ) /* flush buffer */ + return(-1); + --st->_cnt; /* put overflow char in buffer */ + *st->_ptr++= (char) ch; + return(ch); + } + st->_flag&=~_F_RST; /* clear reset flag */ + if(flag&_F_APP) + lseek(st->_file, 0L, SEEK_END); /* unbuffered - write data */ + } + st->_cnt=0; /* set buffer pointers */ + st->_ptr=NULL; + st->_flag|=_F_OUT; /* set output flag */ + if(_write(st->_file,&ch,1) != 1) { + st->_flag|=_F_ERR; + return(-1); + } + if((ch == _CTLZ) && (!(flag&(_F_BIN|_F_DEV)))) + /* ctl z - set EOF flag if */ + st->_flag|=_F_EOF; /* text mode and not device */ + return(ch); +} + +int _flusher(FILE *st) /* empties output buffer */ + +{ + unsigned wnum, flag; + char zbuf[128]; + long pos; + int nr, sr; + + flag=st->_flag; + if(flag&(_F_IN|_F_EOF)) + return(-1); + if(flag&_F_RST) /* set up reset buffer for output */ + { + st->_flag&=(~_F_RST); + st->_flag|=_F_OUT; + st->_cnt=st->_size; + st->_ptr=st->_base; + return(0); /* return - buffer wasn't full */ + } + if(st->_cnt<0) + st->_cnt=0; + wnum=st->_size-st->_cnt; + if(wnum == 0) /* nothing to do - return */ + return(0); /* buffer empty */ + if(flag&_F_BIN) /* binary mode */ + { + if(flag&_F_APP) + lseek(st->_file, 0L, SEEK_END); /* append */ + if(_write(st->_file, st->_base, wnum) != wnum) + goto error; + } + else /* text mode */ + { + if(flag&_F_APP) { + pos = lseek(st->_file, -128L, SEEK_END); + if(pos < 0) + lseek(st->_file, 0, SEEK_SET); + nr = _read(st->_file, zbuf, 128); + sr = nr; + if (nr == -1) + goto error; + while(--sr >= 0) { + if(zbuf[sr] != _CTLZ) + break; + } + pos = sr - nr + 1; + lseek(st->_file, pos, SEEK_END); /* append after last cltZ */ + } + if(_write(st->_file, st->_base, wnum) == -1) + goto error; + if(st->_flag&_F_CTZ) { + st->_flag|=_F_EOF; + st->_cnt=0; + st->_ptr=st->_base; + return(0); + } + } + st->_cnt=st->_size; /* set buffer pointers */ + st->_ptr=st->_base; + st->_flag|=_F_OUT; /* set output flag */ + return(0); +error: + st->_flag|=_F_ERR; + st->_cnt=0; + return(-1); +} + +/**************************************************************************** +* buffer filling functions * +****************************************************************************/ + +int _filbuf(FILE *st) +{ + int ch, n, flag; + + flag=st->_flag; + if((!flag)||(flag&(_F_EOF|_F_ERR))) + return(-1); + if((flag&_F_OUT) || (!(flag&_F_READ))) + { + st->_flag|=_F_ERR; + return(-1); /* return error */ + } + if(st->_size) /* buffered */ + { + if(_filler(st) <= 0 ) /* fill buffer */ + return(-1); + --st->_cnt; /* get first char from buffer */ + ch=*st->_ptr++; + return(ch&0xFF); /* return first character in buffer */ + } + st->_cnt=0; /* reset pointers */ + st->_flag|=_F_IN; /* set input flag */ + st->_ptr=NULL; + st->_flag&=~_F_RST; + for(n=0; n<2; n++) /* unbuffered - read character */ + { + if(_read(st->_file, &ch, 1) != 1) + { + st->_flag|=_F_EOF; + return(-1); + } + ch&=0xFF; + if((flag&_F_BIN)||(ch != '\r')) /* dont translate if binary mode */ + break; + } + if((!(flag&(_F_BIN|_F_DEV))) && (ch == _CTLZ)) + st->_flag|=_F_EOF; /* ctl z end of file */ + return(ch); +} + +int _filler(FILE *st) /* fills buffer */ +{ + int flag, num; + + flag=st->_flag; + if(flag&(_F_OUT|_F_EOF)) + return(-1); + if(flag&_F_RST) + st->_flag&=~_F_RST; + num =_read(st->_file, st->_base, st->_size); + st->_ptr=st->_base; + if(( num == -1) && (num != st->_size)) + goto error; + st->_cnt=num; /* reset pointers */ + st->_flag|=_F_IN; /* set input flag */ + if(num == 0) + { + st->_flag|=_F_EOF; /* end of file */ + return(-1); + } + return(num); +error: /* read error */ + st->_flag|=_F_ERR; + st->_cnt=0; + return(-1); +} + +int fputchar(int ch) +{ + return(fputc(ch, stdout)); +} + +int fgetchar() +{ + return(fgetc(stdin)); +} + +/**************************************************************************** +* ungetc - put character back onto input stream * +****************************************************************************/ + +int ungetc(int ch, FILE *st) +{ + int flag; + + flag=st->_flag; + if((!flag) || (flag&_F_ERR)) + return(EOF); + if(ch == EOF) + return(EOF); /* return EOF if error, EOF or not read mode */ + if(flag&_F_OUT) + { + st->_flag|=_F_ERR; + return(EOF); /* return EOF if error, EOF or not read mode */ + } + ch&=0xFF; + st->_flag&=(~_F_EOF); /* clear EOF */ + if((flag&_F_RST) || (st->_size == 0)) + { + st->_flag&=(~_F_RST); + st->_flag|=_F_IN; + if(st->_size) + st->_ptr=st->_base; + else + st->_ptr= (char *) &st->_pback; + if((ch == 0xA) && (!(st->_flag&_F_BIN))) { + st->_cnt=2; + *((unsigned *)st->_ptr)=0xA0D; + } + else { + st->_cnt=1; + *st->_ptr=ch; + } + return(ch); + } + if((ch == 0xA) && (!(st->_flag&_F_BIN)) && (st->_cnt < st->_size-2)) { + *--st->_ptr= (char) 0xD; + st->_cnt++; + } + *--st->_ptr= (char) ch; /* buffer not full - put it in buffer */ + st->_cnt++; + return(ch); +} + +/**************************************************************************** +* rewind - rewind and clear error flag * +****************************************************************************/ + +void rewind(FILE *st) +{ + if(st->_flag) + { + st->_flag&=(~_F_ERR); + fseek(st, 0L, SEEK_SET); + } + return; +} + +/**************************************************************************** +* flushall - flush all open streams * +****************************************************************************/ + +int flushall() +{ + int n, count; + + count=0; + for(n=0; n< _open_max; n++) + { + if(_iob[n]._flag) /* inc count if open file */ + { + fflush(&_iob[n]); /* flush buffer */ + count++; + } + } + return(count); /* return number of open streams */ +} + +void _flushall() +{ + int n; + + for(n=0; n<_open_max; n++) + { + if((_iob[n]._flag) && (_iob[n]._size)) + _flusher(&_iob[n]); /* flush buffer */ + } + return; /* return number of open streams */ +} + +/**************************************************************************** +* fopen - open stream * +****************************************************************************/ + +#define _WRITE 2 +#define NODEFMODE 4 +#define _READ 8 + +FILE *fopen(const char *path, const char *type) +{ + int num; + int handle, flag, mode; + + flag=_F_RST; + mode=0; + if(_scan_type(type, &flag, &mode) < 0) /* get access mode */ + return(NULL); + handle=_open_stream(path, &flag, mode); /* open the file */ + if(handle < 0) + return(NULL); + num=_free_stream(); /* find a free stream */ + if(num < 0) + { + close(handle); + return(NULL); + } + return(_alloc_stream(&_iob[num], handle, flag)); +} /* allocate the stream */ + +int _scan_type(const char *type, int *fptr, int *mptr) +{ /* evaluate file mode */ + int c, n; + + switch(type[0]) + { + case 'r': + *mptr|=(_READ|O_EXCL); + break; + case 'w': + *mptr|=(O_TRUNC|O_CREAT|_WRITE); + break; + case 'a': + *fptr|=_F_APP; + *mptr|=(_WRITE|O_APPEND|O_CREAT); + break; + default: + return(-1); + } + n=0; + do + { + c=type[++n]; + switch(c) + { + case'+': + *mptr|=(_READ|_WRITE); + break; + case'b': + *fptr|=_F_BIN; + *mptr|=NODEFMODE|O_BINARY; + break; + case't': + *mptr|=NODEFMODE|O_TEXT; + break; + default: + break; + } + } while((n < 3) && (c)); + return(0); +} + +int _open_stream(const char *path, int *fptr, int mode) +{ + unsigned access, permission; + + access=0; /* translates level 2 */ + permission=0; /* access and permission */ + if(!(mode&NODEFMODE)) /* flags to level 1 and */ + { /* uses open to get handle */ + if(_fmode==O_BINARY) + { + *fptr|=_F_BIN; + access= O_BINARY; + } + else + access=O_TEXT; + } + if(mode&_WRITE) + { + permission|=S_IWRITE; + if(mode&_READ) + { + *fptr|=_F_RDWR; + permission|=S_IREAD; + access|=O_RDWR; + } + else + { + *fptr|=_F_WRIT; + access|=O_WRONLY; + } + } + else + { + access|=O_RDONLY; + permission=S_IREAD; + *fptr|=_F_READ; + } + access|= (mode&(O_TEXT|O_BINARY|O_CREAT|O_TRUNC|O_EXCL|O_APPEND)); + return(open(path, access, permission)); +} + +int _valid_stream(FILE *st) /* checks stream pointer is valid */ +{ + if((st > &_iob[_open_max-1]) || (st < _iob) || (st->_flag==0) ) + return(FALSE); + return(TRUE); +} + +/**************************************************************************** +* fgetpos - get current stream position * +****************************************************************************/ + +int fgetpos(FILE *st, fpos_t *fp) +{ + long pos; + + pos=ftell(st); + if(pos == -1) + return(-1); + *fp= (fpos_t) pos; + return(0); +} + +/**************************************************************************** +* fsetpos - set current stream position * +****************************************************************************/ + +int fsetpos(FILE *st, const fpos_t *fp) +{ + return fseek(st, *fp, SEEK_SET); +} + +/*-------------------------------------------------------------------------* +* close.c - level 1 I/O - close file. * +*--------------------------------------------------------------------------*/ + +int close(int handle) +{ + int n; + + n=_close(handle); /* close file */ + if(n < 0) + return(-1); /* return -1 if error */ + _openfd[handle]=0; /* zero file descriptor */ + return(0); /* success - return 0 */ +} + +/*-------------------------------------------------------------------------* +* eof.c - level 1 I/O - test for eof. * +*--------------------------------------------------------------------------*/ + +int eof(int handle) +{ + if( (_openfd[handle]&O_TEXT) && (_openfd[handle]&_O_EOF)) + return(1); /* text file ctl z eof */ + if(_openfd[handle]&O_DEVICE) + return(0); /* device - no eof unless text mode */ + return(_eof(handle)); +} + +/*-------------------------------------------------------------------------* +* umask.c - level 1 I/O - set file permission mask. * +*--------------------------------------------------------------------------*/ + +unsigned umask(unsigned permission) +{ + unsigned ret; + + ret=_fmask; + _fmask=permission; + return(ret); +} + +/*-------------------------------------------------------------------------* +* filelength.c - returns file length. * +*--------------------------------------------------------------------------*/ + +long filelength(int handle) +{ + long pos, size; + + pos=tell(handle); /* save file position */ + if(pos == -1) + return(pos); + size=lseek(handle, 0L, SEEK_END); /* get file length */ + lseek(handle, pos, SEEK_SET); /* restore original file position */ + return(size); +} + +int rmtmp(void) +{ + int n, files; + + n=0; + files=0; + while(n < _open_max) + { + if (_tmpfiles[n]) + { + fclose(_tmpfptrs[n]); + unlink(_tmpfiles[n]); + _tmpfiles[n]=NULL; + ++files; + } + ++n; + } + _exit_tmp=NULL; + return(files); +} + +FILE *tmpfile(void) +{ + int handle,i; + FILE *ret; + char *e,*p,name[0x128]; + + name[0]=0; + if ((e=getenv("TMP"))!=NULL && (i=strlen(e))!=0) + { + strcpy(&name[0],e); + p=(&name[i-1]); + if (*p!='\\') + { + *p++='\\'; + *p=0; + } + } + if ((handle=_creat_temp(&name[0],FA_NORMAL))==(-1)) + return(NULL); + _openfd[handle]=O_BINARY|O_RDWR; + i=strlen(&name[0])+1; + if ((p=malloc(i))==NULL) + goto failed1; + strcpy(p,&name[0]); + _tmpfiles[handle]=p; + if ((ret=fdopen(handle,"w+b"))==NULL) + goto failed2; + _tmpfptrs[handle]=ret; + _exit_tmp=_exit2; + return(ret); +failed2: + free(_tmpfiles[handle]); + _tmpfiles[handle]=NULL; +failed1: + _openfd[handle]=0; + _close(handle); + return(NULL); +} + +/*-------------------------------------------------------------------------* +* console I/O section. * +*--------------------------------------------------------------------------*/ + +char *cgets(char *s) +{ + extern void *winHandle; + extern void p_xwind(void); + + if(!_p_init) + { + _i_putch=_d_putch; + _i_cgets=_d_cgets; + _p_init=-1; + if (winHandle==NULL) + p_xwind(); + } + return(_i_cgets(s)); +} + +int sopen(const char *path, int access, int shflag, ...) +{ + va_list _v_argptr; + + va_start(_v_argptr, shflag); + return(open(path, access|shflag, va_arg(_v_argptr, int))); +} + +/*-------------------------------------------------------------------------* +* macro equivalents. * +*--------------------------------------------------------------------------*/ + +int ferror(FILE *st) +{ + return((st)->_flag & _F_ERR); +} + +int feof(FILE *st) +{ + return((st)->_flag & _F_EOF); +} + +int fileno(FILE *st) +{ + return((st)->_file); +} + +int remove(const char *path) +{ + return(unlink(path)); +} + +int getc(FILE *st) +{ + return(fgetc(st)); +} + +int putc(int c, FILE *st) +{ + return(fputc(c, st)); +} + +int getchar() +{ + return(fgetc(stdin)); +} + +int putchar(int c) +{ + return(fputc(c, stdout)); +} + +/**************************************************************************** +* puts - send string to stdout * +****************************************************************************/ + +int puts(const char *s) +{ + int n, c, ret; + + n=0; + while((c=s[n++]) != 0) + { + if(putchar(c) == EOF) + { + ret=-1; + goto puts_error; + } + } + if(putchar('\n') == EOF) + { + ret=-1; + goto puts_error; + } + ret=fflush(stdout); +puts_error: + return(ret); +} + +/**************************************************************************** +* gets - get string from stdin * +****************************************************************************/ + +char *gets(char *s) +{ + int n, c; + char *ret; + + n=0; + while((c=getchar()) != '\n') + { + if(c < 0) + { + if((feof(stdin)) && (n)) + break; + ret=NULL; + goto gets_error; + } + s[n++]= (char) c; + } + s[n]=0; + ret=s; +gets_error: + return(ret); +} + +/**************************************************************************** +* fputs - put string on stream * +****************************************************************************/ + +int fputs(const char *s, FILE *st) +{ + int n, c, ret; + + ret=0; + n=0; + while((c=s[n++]) != 0) + { + if(fputc(c, st) == EOF ) + { + ret=-1; + break; + } + } + if(st->_flag&_F_DEV) + fflush(st); + return(ret); +} + +/**************************************************************************** +* fgets - get string from stream * +****************************************************************************/ + +char *fgets(char *s, int num, FILE *st) +{ + int n, c; + char *ret; + + n=0; + ret=s; + while( n < num-1) + { + c=fgetc(st); + if(c == -1) + { + if((feof(st)) && (n)) + break; + ret=NULL; + goto fgets_end; + } + s[n++]= (char) c; + if(c == '\n') + break; + } + s[n]=0; +fgets_end: + return(ret); +} + +/**************************************************************************** +* getw - get word from stream * +* putw - put word on stream * +****************************************************************************/ + +int getw(FILE *st) +{ + unsigned hibyte, lobyte; + + lobyte=fgetc(st); + hibyte=fgetc(st); + return( (hibyte*0x100)+lobyte); +} + +int putw(int num, FILE *st) +{ + int ret; + + fputc(num&0xFF, st); + ret=fputc((num&0xFF00)>>8, st); + return(ret); +} + +/**************************************************************************** +* clearerr - clear error and EOF flags and reset buffer status * +****************************************************************************/ + +void clearerr(FILE *st) + +{ + if(st->_flag) + { + st->_flag&=~(_F_ERR|_F_EOF|_F_CTZ); + _openfd[st->_file]&= (~_O_EOF); + } + return; +} + +/**************************************************************************** +* fseek - position stream pointer * +****************************************************************************/ + +int fseek(FILE *st, long offset, int orig) +{ + long ret, temp, pos; + int flag; + + flag=st->_flag; + if((!flag) || (flag&_F_ERR)) + { + errno=EBADF; + ret=-1; + goto fseek_end; + } + if(orig == SEEK_CUR) + { + if((!(flag&(_F_WRIT|_F_RST))) && (st->_size)) { + if(offset == 0) { + ret=0; + goto fseek_end; + } + else if(offset < 0) + pos=st->_ptr-st->_base; + else + pos=st->_cnt; + if(pos > labs(offset)) { + st->_cnt-=(short)offset; + st->_ptr+=(short)offset; + ret=0; + goto fseek_end; + } + } + temp=ftell(st); + ret=fseek(st, temp+offset, SEEK_SET); + if(ret) + ret = -1L; + goto fseek_end; + } + if((st->_size) && (flag&_F_OUT)) /* flush output buffer */ + _flusher(st); + st->_pback=0; /* reset buffer */ + st->_cnt=0; + st->_flag|=_F_RST; + ret=lseek(st->_file, offset, orig); + st->_flag&=~(_F_IN|_F_OUT|_F_EOF|_F_CTZ); /* clear direction flag and EOF */ + _openfd[st->_file]&=~(_O_EOF); +fseek_end: + if(ret < 0) + return(1); + return(0); +} + +/**************************************************************************** +* ftell - return stream pointer * +****************************************************************************/ + +long ftell(FILE *st) +{ + long pos, ret; + int flag; + + flag=st->_flag; + if((!flag) || (flag&_F_ERR)) + { + errno=EINVAL; + ret=-1L; + goto ftell_error; + } + if((flag&_F_RST) || (!st->_size)) /* unbuffered or reset stream */ + { + st->_cnt=0; + ret=tell(st->_file); + } + else if(flag&_F_OUT) /* output stream */ + { + _flusher(st); /* flush stream */ + ret=tell(st->_file); + } + else + { + pos=tell(st->_file); /* input stream */ + if(st->_pback != 0) + --pos; + if((flag&_F_BIN) && (st->_pback == 0xA0D)) + --pos; + ret=pos-st->_cnt; + } +ftell_error: + return(ret); +} + +/**************************************************************************** +* fflush - flush stream * +****************************************************************************/ + +int fflush(FILE *st) +{ + int flag, ret; + + if(st == NULL) + { + flushall(); + return(0); + } + flag=st->_flag; + if((!flag)||(flag&(_F_EOF|_F_ERR))) + { + ret=EOF; /* error EOF or not open */ + goto fflush_end; + } + if(!st->_size) + { + st->_cnt=0; + st->_flag|=_F_RST; + st->_flag&=~(_F_OUT|_F_IN); + ret=0; /* no buffer */ + goto fflush_end; + } + if(flag&_F_OUT) + ret=_flusher(st); /* flush output buffer */ + else + { + fseek(st, ftell(st), SEEK_SET); + ret=0; + goto fflush_end; + } + st->_pback=0; /* reset buffer */ + st->_cnt=0; + st->_flag|=_F_RST; + st->_flag&=~(_F_OUT|_F_IN); +fflush_end: + return(ret); +} + +/**************************************************************************** +* fdopen - assign stream to handle * +****************************************************************************/ + +#define _WRITE 2 +#define NODEFMODE 4 +#define _READ 8 + +FILE *fdopen(int handle, char *type) +{ + int num; + int flag, mode; + + flag=_F_RST; + mode=0; + if(handle < 0) /* bad handle */ + { + errno=EBADF; + return(NULL); + } + if(_scan_type(type, &flag, &mode) < 0) /* get the access mode */ + return(NULL); + if((!(mode&NODEFMODE))&&(_fmode==O_BINARY)) + flag|=_F_BIN; + if(mode&_WRITE) + { + if(mode&_READ) + flag|=_F_RDWR; + else + flag|=_F_WRIT; + } + else + flag|=_F_READ; + num=_free_stream(); /* find a free stream */ + if(num < 0) + { + close(handle); + return(NULL); + } + return(_alloc_stream(&_iob[num], handle, flag)); +} /* allocate the stream */ + +FILE * _alloc_stream(FILE *stream, int handle, int flag) +{ + stream->_file=handle; /* allocates buffer and sets flags */ + stream->_flag=flag; + stream->_cnt=0; + stream->_pback=0; + stream->_size=BUFSIZ; + if(_openfd[handle]&O_DEVICE) + stream->_flag|=_F_DEV; + if((stream->_base= (char *) malloc(BUFSIZ)) == NULL) + { + stream->_size=0; /* no memory for buffer */ + stream->_ptr=NULL; + errno=ENOMEM; + } + else + { + stream->_size=BUFSIZ; + stream->_ptr=stream->_base; + } + return(stream); +} + +int _free_stream() /* find a free stream */ +{ + int n; + + for(n=0; n < _open_max; n++) + { + if(_iob[n]._flag == 0) + return(n); + } + return(-1); +} + +/**************************************************************************** +* freopen - close existing stream and assign new file * +****************************************************************************/ + +FILE *freopen(const char *path, const char *type, FILE *st) +{ + int handle, flag, mode; + + if(fclose(st) == EOF) /* close old stream */ + return(NULL); + flag=_F_RST; + mode=0; + if(_scan_type(type, &flag, &mode) < 0) /* get file mode */ + goto fr_error; + handle=_open_stream(path, &flag, mode); /* open new */ + if(handle < 0) + goto fr_error; + return(_alloc_stream(st, handle, flag)); /* assign to stream */ +fr_error: + return(NULL); +} + +/**************************************************************************** +* fclose - close stream * +****************************************************************************/ + +int fclose(FILE *st) +{ + int ret; + + ret=0; + if(!_valid_stream(st)) + { + ret=-1; + goto fclose_error; + } + if(st->_size) + _flusher(st); /* flush buffer if any */ + if(close(st->_file) < 0) /* close file */ + ret=-1; + if((st->_base != NULL) && (!(st->_flag&_F_UBUF))) + free(st->_base); /* free system allocated buffer */ + st->_flag=0; /* free stream */ + if(_tmpfiles[st->_file]) + { + unlink(_tmpfiles[st->_file]); + free(_tmpfiles[st->_file]); + _tmpfiles[st->_file]=NULL; + } +fclose_error: + return(ret); +} + +/**************************************************************************** +* fcloseall - closes all streams except standards * +****************************************************************************/ + +int fcloseall(void) +{ + int n, count; + + count=0; + for(n=3; n < _open_max; n++) + { + if(fclose(&_iob[n]) == 0) + count++; + } + return(count); +} + +/**************************************************************************** +* setbuf - allocates user buffer to stream * +****************************************************************************/ + +void setbuf(FILE *st, char *buffer) +{ + if((!_valid_stream(st))||(!(st->_flag&_F_RST))||(st->_flag&_F_UBUF)) + return; + if(st->_base != NULL) /* free any system buffer */ + free(st->_base); + st->_base=buffer; /* use user buffer */ + st->_ptr=buffer; + if(buffer != NULL) + { + st->_size=BUFSIZ; + st->_flag|=_F_UBUF; + } + else + { + st->_size=0; + st->_flag&=~_F_LBUF; + } + return; +} + +/**************************************************************************** +* setvbuf - allocates user or system buffer to stream * +****************************************************************************/ + +int setvbuf(FILE *st, char *buffer, int type, size_t size) +{ + int flag; + + if((type < _IOFBF) || (type > _IONBF) || ((int) size < 0)) + return(1); + flag=st->_flag; + if((!_valid_stream(st))||(!(flag&_F_RST))||(size < 0)) + { + return(1); + } + if((st->_base != NULL) || (!(st->_flag&_F_UBUF))) /* free old buffer */ + free(st->_base); + st->_flag&=(~_F_LBUF|_F_IN|_F_OUT); + if(type != _IONBF) + { + if(buffer==NULL) + { /* allocate new system buffer */ + buffer=malloc(size); + if(buffer==NULL) + { + errno=ENOMEM; + return(1); + } + } + else /* user buffer */ + st->_flag|=_F_UBUF; + st->_base=buffer; + st->_ptr=buffer; + st->_size=size; + if(type == _IOLBF) /* line buffered */ + st->_flag|=_F_LBUF; + } + else /* no buffer */ + { + st->_size=0; + st->_base=NULL; + st->_ptr=NULL; + st->_cnt=0; + } +setvbuf_error: + return(0); +} + +/**************************************************************************** +* fread - get a number of data blocks from stream * +****************************************************************************/ + +size_t fread(void *buf, size_t size, size_t count, FILE *st) +{ + unsigned numtoread; + unsigned pos; + int flag; + char *buffer; + long total, numleft, p; + size_t ret; + + flag=st->_flag; + if((!flag) || (size == 0) || (count==0) || (flag&(_F_ERR|_F_EOF))) + { + ret=0; + goto fread_error; + } + if((flag&_F_OUT) || (!(st->_flag&_F_READ))) + { + st->_flag|=_F_ERR; + ret=0; + goto fread_error; + } + st->_flag|=_F_IN; + buffer=(char *)buf; + total=size*count; /* how many bytes are there to read */ + pos=0; + if((st->_size == 0) || (!(st->_flag&_F_BIN))) + { + for(p=0; p < total; p++) /* unbuffered */ + { + ret=getc(st); + if(ret == EOF ) + break; + buffer[pos]= (char) ret; + pos++; + } + } + else + { + numleft=total; + p=0; + do + { + if(st->_cnt == 0) /* fill empty buffer */ + { + if(_filler(st) <= 0) + break; /* error or EOF */ + } + if( (long) (unsigned) st->_cnt >= numleft) /* read entire item */ + numtoread = (unsigned) numleft; + else + numtoread=st->_cnt; /* read entire buffer */ + memcpy(buffer, st->_ptr, numtoread); + st->_cnt-=numtoread; + buffer+=numtoread; + st->_ptr+=numtoread; + numleft-=numtoread; + p+=numtoread; + }while(numleft); + } + ret=(int) p/size; +fread_error: + return(ret); /* return number of complete items read */ +} + +/**************************************************************************** +* fwrite - put a number of data blocks on stream * +****************************************************************************/ + +size_t fwrite(const void *buf, size_t size, size_t count, FILE *st) +{ + unsigned numtowrite; + unsigned pos; + char *buffer; + long total, numleft, p; + int flag; + size_t ret; + + flag=st->_flag; + if((!flag) || (size == 0) || (count==0) || (flag&(_F_ERR|_F_EOF))) + { + ret=0; + goto fwrite_error; + } + if((flag&_F_IN) || (!(st->_flag&_F_WRIT))) + { + st->_flag|=_F_ERR; + ret=0; + goto fwrite_error; + } + st->_flag|=_F_OUT; + buffer=(char *)buf; + pos=0; + total=size*count; + if((st->_size == 0) || (!(st->_flag&_F_BIN))) + { + for(p=0; p < total; p++) /* unbuffered */ + { + if(putc(buffer[pos], st) == -1) + break; + pos++; + } + } + else + { + numleft=total; + p=0; + do + { + if( (long) (unsigned) st->_cnt >= numleft) /* write entire item */ + numtowrite= (unsigned) numleft; + else + numtowrite=st->_cnt; /* write entire buffer */ + memcpy(st->_ptr, buffer, numtowrite); + st->_cnt-=numtowrite; + buffer+=numtowrite; + st->_ptr+=numtowrite; + numleft-= (long) numtowrite; + if(st->_cnt == 0) + { + if(_flusher(st) < 0) + break; /* error */ + } + p+=numtowrite; + }while(numleft); + } + ret=(int) p/size; +fwrite_error: + return(ret); /* return number of complete items written */ +} + +/*--------------------------------------------------------------------------* +* creat.c - creates a file. +*---------------------------------------------------------------------------*/ + +int creat(const char *path, int permission) +{ + int fh, fdesc; + + fdesc=_fmode; /* set RTL I/O flags */ + permission^=_fmask; + if(permission == S_IREAD) + { + permission=FA_RDONLY; + } + else + { + fdesc|=O_RDWR; + permission=FA_NORMAL; + } + if(_fmode&O_TEXT) + permission=FA_TEXT; + fh=_creat_trunc(path, permission); /* truncate if exists and !readonly */ + if((fh < 0) || (fh >= _open_max)) + return(-1); + if(isatty(fh)) + fdesc|=O_DEVICE; + _openfd[fh]=fdesc; /* store file descriptor */ + return(fh); /* return handle */ +} + +/*-------------------------------------------------------------------------* +* open.c - opens a file. * +* This function opens a file, setting DOS access and permision modes, * +* and stores access and translation modes in the file descriptor array * +* _openfd. * +*--------------------------------------------------------------------------*/ + +#pragma warn(wvnu => off) + +int open(const char *path, int access, ...) +{ + va_list varg; + int fh, fdesc; + unsigned permission; + + fdesc=0; + if(access&O_TEXT) /* defaults to _fmode */ + fdesc|=O_TEXT; + else if(access&O_BINARY) + fdesc|=O_BINARY; + else if( (_fmode == O_BINARY) || (_fmode == O_TEXT)) + fdesc|=_fmode; + else + fdesc|=O_BINARY; + if(access&(O_CREAT|O_APPEND|O_TRUNC)) /* create append or truncate */ + { + if(access&O_CREAT) + { + va_start(varg, access); + permission=va_arg(varg, unsigned); /* get permission */ + } + else + { + if(!(access&(O_RDWR|O_WRONLY))) + permission=S_IREAD; + else + permission=S_IREAD|S_IWRITE; + } + permission^=_fmask; /* exclusive or with fmask */ + if(permission == S_IREAD) /* set DOS access modes */ + { + permission=FA_RDONLY; + } + else + { + fdesc|=O_RDWR; + permission=FA_NORMAL; + } + if (fdesc&O_TEXT) + permission|=FA_TEXT; + if(_exists(path)) /* does file exist ? */ + { + if(access&O_EXCL) + { + errno=EEXIST; + return(-1); /* if exclusive flag return error */ + } + if(!(access&O_TRUNC)) + goto open_file; /* if not truncate open file */ + } + else if(!(access&O_CREAT)) /* create only if flag set */ + { + errno=ENOENT; + return(-1); + } + fh=_creat_trunc(path, permission); + } + else + { +open_file: /* open file */ + if(!(access&(O_RDWR|O_WRONLY))) + fdesc|=O_RDONLY; /* write access given */ + else + { + access&=~(O_RDONLY|O_WRONLY); + access|=O_RDWR; + fdesc|=O_RDWR; + } + access&=~(O_TEXT|O_BINARY); + if (fdesc&O_TEXT) + access|=O_TEXT; + fh=_open(path, access); + } + if((fh < 0) || (fh >= _open_max)) /* invalid handle from _open or _creat */ + return(-1); + if(access&O_APPEND) /* if O_APPEND set flag */ + fdesc|=O_APPEND; + if(isatty(fh)) /* check for character device */ + fdesc|=O_DEVICE; + _openfd[fh]=fdesc; /* store file descriptor */ + return(fh); /* return handle */ +} + +/*-------------------------------------------------------------------------* +* dup.c - level 1 I/O - force duplicate file handle. * +*--------------------------------------------------------------------------*/ + +int dup(int handle) +{ + int nh; + + if(((nh=_dup(handle)) == -1) || (nh >= _open_max)) + return(-1); /* duplication failed */ + _openfd[nh]=_openfd[handle]; /* copy file desc */ + return(nh); /* success - return new handle */ +} + +#pragma warn(wvnu => on) + +/*-------------------------------------------------------------------------* +* dup2.c - level 1 I/O - force duplicate file handle. * +*--------------------------------------------------------------------------*/ + +int dup2(int oldhandle, int newhandle) +{ + if(_openfd[newhandle]) /* close new handle if open */ + close(newhandle); /* at level 1 */ + if(_dup2(oldhandle, newhandle) < 0) + return(-1); /* duplication failed */ + _openfd[newhandle]=_openfd[oldhandle]; /* copy file desc */ + return(0); /* success - return 0 */ +} + +/*-------------------------------------------------------------------------* +* setmode.c - set file translation mode . * +*--------------------------------------------------------------------------*/ + + +int setmode(int handle, unsigned mode) +{ + int ret, n; + char name[P_FNAMESIZE]; + + if((mode != O_BINARY) && (mode != O_TEXT)) + { +invalid: + errno=EINVAL; + return(-1); + } + ret=-1; + if(_openfd[handle]) + { + _FsChanToName(getRealHandle(handle),&name[0]); + if (memcmp("LOC",&name[0],3)!=0) + goto invalid; + ret=_openfd[handle]&(O_BINARY|O_TEXT); /* save old mode */ + _openfd[handle]&= ~(O_BINARY|O_TEXT); /* mask out old mode */ + _openfd[handle]|=mode; /* set new mode */ + n=-1; + while(++n < _open_max) /* look for level 2 stream */ + { + if(_iob[n]._file == handle) + { + if(mode == O_BINARY) /* Binary - set flag */ + _iob[n]._flag|=_F_BIN; + else + _iob[n]._flag&=~(_F_BIN); /* Text - clear flag */ + break; + } + } + } + else + errno=EBADF; /* file wasn't open */ + return(ret); +} + +/*-------------------------------------------------------------------------* +* stat and fstat - return file status information in stat structure. * +*--------------------------------------------------------------------------*/ + +#define MAX_EXTS 4 +static char exec_exts[MAX_EXTS][5]={ ".BTF", ".OPO", ".APP",".IMG"}; + +int stat(const char *path, struct stat *statbuf) + +{ + int fmode, temp, drive, fh, n; + long time; + + if (!_isloc(path)) + { + errno=EINVAL; + return(-1); + } + temp=0; + fmode=_chmod(path, 0, 0); /* get access mode and file type */ + if(fmode == -1) + { + errno=ENOENT; + return(-1); + } + statbuf->st_nlink=1; /* nlink is always one */ + if(fmode&0x18) + { + statbuf->st_mode=S_IFDIR; + return(0); + } + else + temp|=S_IFREG; + if(fmode&1) + temp|=S_IREAD; + else + temp|=S_IREAD|S_IWRITE; + fh=_open(path, O_RDONLY); /* open the file */ + if(fh < 0) + return(-1); + if(isatty(fh)) /* is it a device */ + temp|=S_IFCHR; + else /* if it is a file get drive, length */ + /* and time info plus exec status */ + { + drive=_filedrive(fh); + statbuf->st_dev=drive; + statbuf->st_rdev=drive; + n=0; + while(n < MAX_EXTS) + { + if(strstr(path, exec_exts[n])) + { + temp|=S_IEXEC; + break; + } + ++n; + } + statbuf->st_size=filelength(fh); + time=get_utime(fh); + statbuf->st_atime=time; + statbuf->st_mtime=time; + statbuf->st_ctime=time; + } + statbuf->st_mode=temp; + _close(fh); /* close the file */ + return(0); +} + +int fstat(int handle, struct stat *statbuf) +{ + int fmode, temp, drive; + long time; + + temp=0; + fmode=_openfd[handle]; + if(fmode == 0) + { + errno=EBADF; + return(-1); + } + temp|=S_IFREG; /* get access etc from file descriptor */ + if(fmode&O_RDWR) + temp|=S_IREAD|S_IWRITE; + else if(fmode&O_WRONLY) + temp|=S_IWRITE; + else + temp|=S_IREAD; + if(fmode&O_DEVICE) + { + temp|=S_IFCHR; + drive=handle; + } + else /* if it is a file get length, drive */ + { /* and time info */ + statbuf->st_size=filelength(handle); + time=get_utime(handle); + statbuf->st_atime=time; + statbuf->st_mtime=time; + statbuf->st_ctime=time; + drive=_filedrive(handle); + } + statbuf->st_dev=drive; + statbuf->st_rdev=drive; + statbuf->st_mode=temp; + statbuf->st_nlink=1; /* nlink is always one */ + return(0); +} + +/*-------------------------------------------------------------------------* +* chsize - change size of file . * +*--------------------------------------------------------------------------*/ + +#define SECSIZE 2024L + +int chsize(int handle, long size) +{ + char *h; + int ret,mode; + + if ((h=getRealHandle(handle))==NULL) + return(-1); + if ((ret=_iow3(h,P_FSETEOF,&size))<0) + { + _ioerr(ret); + return(-1); + } + mode=P_FABS; + _iow4(h,P_FSEEK,&mode,&size); + return(0); +} + +/*-------------------------------------------------------------------------* +* getcwd.c - returns pointer to buffer containing current directory. * +*--------------------------------------------------------------------------*/ + +char *getcwd(char *buf, int maxlen) +{ + char temp[P_FNAMESIZE]; + int n,p,aflag; + + aflag=0; + _getPath(&temp[0]); + if(buf == NULL) + { + buf=(char *) malloc(maxlen); /* if buffer is null allocate memory */ + if(buf == NULL) + { + errno=ENOMEM; /* no memory - error */ + return(NULL); + } + aflag=1; + } + n=0; + p=P_FSYSNAMESIZE; + while(n < maxlen) /* copy maxlen bytes to buffer */ + { + if((buf[n++]=temp[p++]) == 0) + { + if ((n=strlen(&buf[0]))!=3) + buf[n-1]=0; + return(buf); + } + } + errno=ERANGE; /* string too long */ + if(aflag) /* free heap alocated buffer */ + free(buf); + return(NULL); +} + +/*-------------------------------------------------------------------------* +* console I/O * +*--------------------------------------------------------------------------*/ + +void cputs(const char *s) +{ + int n, c; + + n=0; + if(_ungotchar!=(-1)) + { + putch(_ungotchar); + _ungotchar=(-1); + } + while((c=s[n++]) != 0) + { + putch(c); + } + return; +} + diff --git a/code/SIBOSDK/src/clib1.a b/code/SIBOSDK/src/clib1.a new file mode 100644 index 0000000..14afaea --- /dev/null +++ b/code/SIBOSDK/src/clib1.a @@ -0,0 +1,1454 @@ +(* Release 3.00 *) + +(* clib1 - common misc stuff *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Written by NSM.*) + +include "corelib.inc" +include "epocdefs.inc" + +module clib1 + +segment _BSS(BSS, 28H) + +public __stream : org DataPtrSize + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public __swap : +(* +void _swap(void *p1, void *p2, size_t width) +swaps data at p1 with that at p2. +*) + + push di + push si + mov si, ax + mov di, bx +swapLoop: + mov al, [di] + movsb + mov [si][-1], al + loop swapLoop + pop si + pop di + ret 0 + +(* __swap ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public __rotl : +(* +int _rotl(int val, int shift) +returns val rotated left by shift bits +*) + + push cx + mov cl, bl + rol ax, cl + pop cx + ret 0 + +(* __rotl ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public __rotr : +(* +int _rotr(int val, int shift) +returns val rotated right by shift bits +*) + + push cx + mov cl, bl + ror ax, cl + pop cx + ret 0 + +(* __rotl ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public __lrotl : +(* +long _lrotl(long val, int shift) +returns val rotated left by shift bits +*) + + push cx + mov dx, bx + and cx, 31 +llLoop: + shl ax, 1 + rcl dx, 1 + jnc llCarryZero + or ax, 1 +llCarryZero: + loop llLoop + pop cx + ret 0 + +(* __rotl ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public __lrotr : +(* +long _lrotr(long val, int shift) +returns val rotated right by shift bits +*) + + push cx + mov dx, bx + and cx, 31 +lrLoop: + shr dx, 1 + rcr ax, 1 + jnc lrCarryZero + or dx, 8000H +lrCarryZero: + loop lrLoop + pop cx + ret 0 + +(* __rotl ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public _segread : (* copies segment registers into SEGREGS *) +(* +void segread(struct SREGS *segregs) +*) + +ES = 0 +CS = 2 +SS = 4 +DS = 6 + + push bx + mov bx, ax + mov [bx][ES], es + mov [bx][CS], cs + mov [bx][DS], ds + mov [bx][SS], ss + pop bx + ret 0 + +(* _segread ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public __enable : (* enable interrupts *) +public _enable : + + sti + ret 0 + +(* __enable ENDP *) + +public __disable : (* disable interrupts *) +public _disable : + + cli + ret 0 + +(* __disable ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +public _outportb : +public _outp : + + push dx + mov dx, ax + mov ax, bx + out byte dx, al + pop dx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +public _outportw : +public _outpw : + + push dx + mov dx, ax + mov ax, bx + out word dx, ax + pop dx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +public _inportb : +public _inp : + + push dx + mov dx, ax + in byte al, dx + sub ah, ah + pop dx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +public _inportw : +public _inpw : + + push dx + mov dx, ax + in word ax, dx + pop dx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +public _stackavail : +(* +size_t stackavail(void) +returns bytes left in stack. +*) + + mov ax, sp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +extrn __getDateAndTime + +public _gettime : (* gets system time *) +(* +void gettime(struct time *timeptr) +*) +hour = 0 +min = 1 +sec = 2 +hund = 3 +DataOsTimeInTicks = 420H +DataOsLcdType = 43BH + + push ax + push bx + push cx + push dx + push di + push si + mov cx, ax + call __getDateAndTime + mov si, cx + mov ax, [di][DateHour] + mov [si][hour], ax + mov al, [di][DateSecond] + mov [si][sec], al + int GenDataSegment + mov ax, es:[DataOsTimeInTicks] + mov bl, es:[DataOsLcdType] + cmp bl, Lcd640X200Small + jbe doSiboClock + cmp bl, Lcd160X80 + je doSiboClock + cmp bl, Lcd240X80 + jne doPcClock +doSiboClock: + test ax, ax + jns stillPositive + add al, 32 +stillPositive: + mov ah, al + mov al, 32 + sub al, ah + mov ah, al + add al, ah + add al, ah + jmp setHundreds +doPcClock: + sub dx, dx + mov bx, 655 + div bx +setHundreds: + mov [si][hund], al + pushf + cli + push ss + pop es + popf + add sp, (DateEnt + DyScEnt) + pop si + pop di + pop dx + pop cx + pop bx + pop ax + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +extrn __getDateAndTime +extrn __setDateAndTime + +public _settime : (* sets system time *) +(* +void settime(struct time *timeptr) +*) + +hour = 0 +min = 1 +sec = 2 +hund = 3 + + push ax + push cx + push di + push si + mov cx, ax + call __getDateAndTime + mov si, cx + mov ax, [si][hour] + mov [di][DateHour], ax + mov al, [si][sec] + mov [di][DateSecond], al + call __setDateAndTime + add sp, (DateEnt + DyScEnt) + pop si + pop di + pop cx + pop ax + ret 0 + +(*************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +extrn __getDateAndTime + +public _getdate : (* gets system date *) +(* +void getdate(struct date *dateptr) +*) + +year = 0 +day = 2 +mon = 3 + + push ax + push cx + push di + push si + mov cx, ax + call __getDateAndTime + mov si, cx + mov ax, [di][DateMonth] + xchg ah, al + add ax, 101H + mov [si][day], ax + mov al, [di][DateYear] + sub ah, ah + add ax, 1900 + mov [si][year], ax + add sp, (DateEnt + DyScEnt) + pop si + pop di + pop cx + pop ax + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +extrn __getDateAndTime +extrn __setDateAndTime + +public _setdate : (* sets system date *) +(* +void setdate(struct date *dateptr) +*) + +dateptr = frame +year = 0 +day = 2 +mon = 3 + + push ax + push cx + push di + push si + mov cx, ax + call __getDateAndTime + mov si, cx + mov ax, [si][day] + xchg ah, al + sub ax, 101H + mov [di][DateMonth], ax + mov ax, [si][year] + sub ax, 1900 + mov [di][DateYear], al + call __setDateAndTime + add sp, (DateEnt + DyScEnt) + pop si + pop di + pop cx + pop ax + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __vp_flush +extrn __vp_ret +extrn __stream + +select _TEXT + +extrn __fputn +(* +void _str_out(char far *s, int flag, int wid, int prec) +*) + +_NO_POINT = 10H +_L_JUST = 1 + +file = -2 +s = -4 +flag = -6 +wid = -8 +prec = -10 +tmode = -12 (* 0 = file is text mode *) +locals = 14 + +public __str_out : (* internal function *) + push bp + mov bp, sp + sub sp, locals + push di + push si + mov [bp][s], ax + mov [bp][flag], bx + mov [bp][wid], cx + mov [bp][prec], dx + mov bx, cx (* bx = wid *) + or dx, dx + jnz FindLen + test cx, _NO_POINT (* is No Precision bit set? *) + jnz FindLen + mov dx, 7FFFH + mov [bp][prec], dx (* [bp][prec] is now OK *) +FindLen: + mov di, [bp][s] (* di = s, find end of string *) + mov cx, -1 + sub ax, ax + cld + repne;scasb + not cx + dec cx + cmp cx, dx + jb LenShorter + mov cx, dx +LenShorter: + sub bx, cx (* trash bx (wid) *) + mov cx, bx (* cx = pad length *) +(* stat: ax = 0 | bx = trash | cx = pad len | ~dx = prec | ~es:di = s *) + mov bx, [__stream] (* ds:bx = FILE [near DOS] *) + mov [bp][file], bx (* save FILE in file for __fputn *) + mov di, [bx][_flag] (* di = FILE flags *) + and di, _F_BIN (* is file text mode? *) + mov [bp][tmode], di + mov di, [bx][_ptr] (* es:di = FILE buffer *) + sub dx, dx (* dx is the output count *) + mov bx, [bx][_cnt] (* bx is _cnt *) +(* stat: ax = trash | bx = _cnt | cx = pad len | dx = out count | es:di = dest *) + cmp cx, 0 + jle LeftPadDone + test word [bp][flag], _L_JUST + jnz LeftPadDone + mov al, 20H +LeftPadLoop: + dec bx + cmp bx, 0 (* have we run out of buffer space? *) + jl LeftClearBuffer + stosb (* insert pad character *) + inc dx (* inc output counter *) + loop LeftPadLoop + jmp LeftPadDone +LeftClearBuffer: + call __fputn (* Clear the buffer *) + mov al, 20H + jmp LeftPadLoop +LeftPadDone: + push cx (* save pad length *) + mov cx, [bp][prec] (* cx = precision *) + jcxz StrOutDone + mov si, [bp][s] (* ds:si = s *) + mov ah, 0AH +StrOutLoop: + lodsb + cmp ah, al (* is it a LineFeed? *) + jz TranslateLF + or al, al (* is it a 0C? *) + jz StrOutDone +JumpRet: + dec bx + cmp bx, 0 (* buffer space check *) + jl StrOutClearBuffer + stosb + inc dx (* inc output counter *) + loop StrOutLoop + jmp StrOutDone +StrOutClearBuffer: + push ax + call __fputn + pop ax + jmp JumpRet +TranslateLF: + cmp byte [bp][tmode], 0 (* Binary Mode?, Don't translate *) + jnz JumpRet + mov al, 0DH + dec bx + cmp bx, 0 + jl TranslateClearBuffer + stosb + mov al, ah + jmp JumpRet +TranslateClearBuffer: + call __fputn + mov ah, 0AH + jmp TranslateLF +StrOutDone: + pop cx + cmp cx, 0 + jle RightPadDone + test word [bp][flag], _L_JUST + je RightPadDone + mov al, 20H +RightPadLoop: + dec bx + cmp bx, 0 + jl RightClearBuffer + stosb + inc dx + loop RightPadLoop + jmp RightPadDone +RightClearBuffer: + call __fputn + mov al, 20H + jmp RightPadLoop +RightPadDone: +(* stat: ax = trash | bx = _cnt | cx = trash | dx = out count | es:di = end of dest *) + add [__vp_ret], dx + mov si, [__stream] (* ds:si = FILE *) + mov [si][_cnt], bx + mov [si][_ptr], di + pop si + pop di + mov sp, bp + pop bp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __vp_flush + +select _TEXT + +file = -2 + +public __fputn : + mov ax, bx + mov bx, [bp][file] + mov [bx][_cnt], ax + mov [bx][_ptr], di + push cx + push dx + push bx + mov ax, bx + call [__vp_flush] + pop bx + pop dx + pop cx + mov di, [bx][_ptr] + mov bx, [bx][_cnt] + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __vp_flush +extrn __fputn + +select _DATA + +extrn __stream +extrn __vp_ret + +select _TEXT + +public __justify : (* internal function *) +(* +void _justify(char *s, int flag, int wid) +*) + +nopoint = 10H +left = 1H +zero = 80H +VBUFSIZE = 256 + +temp = -2 +padchar = -6 +s = -10 +flag = -12 +wid = -14 +locals = 14 + + push bp + mov bp, sp + sub sp, locals + push di + push si + mov [bp][s], ax + mov [bp][flag], bx + mov [bp][wid], cx + + test word [bp][flag], ZFLAG + jz useSpace + mov dx, '0' + jmp gotPad +useSpace: + mov dx, 20H +gotPad: + mov [bp][padchar], dx + mov di, [bp][s] + mov cx, -1 + sub ax, ax +repne ; scasb + not cx + dec cx + mov bx, [bp][wid] + sub bx, cx + mov cx, bx (* cx is pad length *) + sub dx, dx (* dx now output count *) + mov bx, [__stream] (* ds:bx is FILE *) + mov [bp][temp], bx + mov di, [bx][_ptr] (* es:di is destination *) + mov bx, [bx][_cnt] (* bx is now _cnt, ds still FILE seg *) + mov si, [bp][s] + cmp cx, 0 + jle pad1Done + test word [bp][flag], left + jnz pad1Done + add dx, cx + mov al, [bp][padchar] + cmp al, '0' + jnz pad1Loop (* handle laeding zeros in FP number *) + cmp byte [si], '-' + je pad0 + cmp byte [si], '+' + jnz pad1Loop +pad0: + dec bx + cmp bx, 0 + jl call0 + movsb + inc dx +pad1Loop: + dec bx + cmp bx, 0 + jl call1 + stosb + loop pad1Loop + jmp pad1Done +call0: + call __fputn + mov al, [bp][padchar] + jmp pad0 +call1: + call __fputn + mov al, [bp][padchar] + jmp pad1Loop +pad1Done: +outLoop: + lodsb + or al, al + je outDone +outRet: + dec bx + cmp bx, 0 + jl call2 + stosb + inc dx + jmp outLoop +call2: + push ax + call __fputn + pop ax + jmp outRet +outDone: + cmp cx, 0 + jle pad2Done + test word [bp][flag], left + je pad2Done + add dx, cx + mov al, [bp][padchar] +pad2Loop: + dec bx + cmp bx, 0 + jl call3 + stosb + loop pad2Loop + jmp pad2Done +call3: + call __fputn + mov al, [bp][padchar] + jmp pad2Loop +pad2Done: + mov si, [bp][temp] + mov [si][_cnt], bx + mov [si][_ptr], di + add [__vp_ret], dx + pop si + pop di + mov sp, bp + pop bp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __vp_flush + +select _DATA + +extrn __stream +extrn __vp_ret + +select _TEXT + +public __vputc : (* internal function *) +(* +void _vputc(int ch) +*) + +char = -2 +locals = 2 + + push bp + mov bp, sp + sub sp, locals + mov [bp][char], ax + inc word [__vp_ret] (* increment char count *) + cmp al, 0AH + jne vpRet + mov bx, [__stream] + test word [bx][_flag], _F_BIN + jnz vpCont + mov ax, 0DH + call __vputc + mov ax, 0AH +vpRet: + mov bx, [__stream] +vpCont: + mov ax, [bx][_cnt] (* decrement stream count *) + dec ax + js vpCall + mov [bx][_cnt], ax + mov bx, [bx][_ptr] + mov al, [bp][char] + mov [bx], al (* put character in buffer *) + mov bx, [__stream] + inc word [bx][_ptr] (* increment pointer *) + cmp al, CTLZ + jne vpDone + test word [bx][_flag], _F_BIN + jz vpDone + or word [bx][_flag], _F_CTZ +vpDone: + mov sp, bp + pop bp + ret 0 + +vpCall: + mov ax, [__stream] + call [__vp_flush] + jmp vpRet + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __vs_fill +extrn _longjmp + +select _DATA + +extrn __stream +extrn __vs_count +extrn __EOFhandler + +select _TEXT + +public __vgetc : (* internal function *) +(* +int _vgetc() +*) + + push bp + push bx + mov bp, sp + inc word [__vs_count] (* increment char count *) +vsRet: + mov bx, [__stream] + mov ax, [bx][_cnt] (* decrement stream count *) + dec ax + js vsCall + mov [bx][_cnt], ax + mov bx, [bx][_ptr] + mov al, [bx] (* get character from buffer *) + sub ah, ah + mov bx, [__stream] + inc word [bx][_ptr] (* increment pointer *) + test word [bx][_flag], _F_BIN + jnz vsDone + cmp al, CTLZ + jne vsTrans + mov ax, -1 + jmp vsError +vsTrans: + cmp al, 0DH + jne vsDone + call __vgetc +vsDone: +vsError: + pop bx + pop bp + ret 0 + +vsCall: + mov ax, [__stream] + call [__vs_fill] + cmp ax, 0 + jg vsRet + jmp vsError + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _DATA + +extrn __stream +extrn __vs_count + +select _TEXT +public __vungetc : (* internal function *) +(* +int _vungetc(char) +*) + + cmp ax, -1 + je vunError + dec word [__vs_count] (* decrement char count *) + push bx + mov bx, [__stream] + inc word [bx][_cnt] (* increment stream count *) + dec word [bx][_ptr] (* decrement pointer *) + pop bx +vunError: + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __upperHex + +select _TEXT + +public _itoa : +(* +char *itoa ( value, strP, radix ) +int value +char *strP +int radix + +Convert a short integer value to ASCIIZ string at ( *strP ), using +a radix from 2..36. If the radix is 10 and value is negative +then prefix the output by '-'. + +The function return value equals strP. +*) + +ita_value = -2 +ita_strP = -6 +ita_radix = -8 +ita_buf = -26 +locals = 26 + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov [bp][ita_value], ax + mov [bp][ita_strP], bx + mov [bp][ita_radix], cx + mov di, [bp][ita_strP] + +(* If the request is invalid, generate an empty result*) + + mov bx, [bp][ita_radix] + cmp bx, 36 + ja ita_end + cmp bl, 2 + jb ita_end + + mov ax, [bp][ita_value] + +(* If the radix is decimal, then if the value is negative*) +(* put a sign on the result.*) + + cmp bl, 10 + jne ita_signSet + or ax, ax + jnl ita_signSet + + mov byte [di][0], '-' + inc di + neg ax + +ita_signSet: + lea si, [bp][ita_buf] + mov cx, si (* CX remembers start of string*) + +(* Now loop, taking each digit as modulo radix, and reducing the value*) +(* by dividing by radix, until the value is zeroed. Note that*) +(* at least one loop occurs even if the value begins as 0,*) +(* since we want "0" to be generated rather than "".*) + +ita_shortLoop: + sub dx, dx + div bx + mov [si], dl + inc si + or ax, ax + jnz ita_shortLoop + +(* The value has now been reduced to zero and the digits are in*) +(* the buffer.*) + + neg cx + add cx, si (* CX = length of the numeral*) + +(* The digits in the buffer must now be copied in reverse order into*) +(* the target string, translating to ASCII as they are moved.*) + +ita_copy: + cld + +ita_copyLoop: + dec si + mov al, [si] + sub al, 10 + jae ita_alphaDigit + add al, '0' + 10 + jmp ita_storeDigit + +ita_alphaDigit: + add al, [__upperHex] + +ita_storeDigit: + stosb + loop ita_copyLoop + +(* terminate the output string with a zero.*) + +ita_end: + mov al, 0 + stosb + +(* return a pointer to the string.*) + + mov ax, [bp][ita_strP][0] + pop si + pop di + pop dx + add sp, locals + pop bp + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __upperHex + +select _TEXT +(* ltoa - converts signed long integer to ASCIIZ string + ultoa - converts unsigned long integer to ASCIIZ string +*) + +public _ultoa : +(* +char *ultoa ( value, strP, radix ) + +long value; +char *strP; +int radix; + +Convert an unsigned long integer value to ASCIIZ string at ( *strP), +using a radix from 2..36. If the radix is 10 and value is negative +then prefix the output by '-'. + +The parameters are identical to _ltoa except that the value is not +signed. The function is implemented by jumping to shared code. + +The function return value equals strP. +*) + +lta_value = -4 +lta_strP = -8 +lta_radix = -10 +lta_buf = -44 +locals = 44 + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + sub si, si (* flag indicates "not signed" *) + jmp lta_shared + +(* The major work is done by ltoa. *) + +public _ltoa : +(* +char *ltoa ( value, strP, radix ) + +long value; +char *strP; +int radix; + +Convert an signed long integer value to ASCIIZ string at ( *strP), +using a radix from 2..36. + +The function return value equals strP. +*) + + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov si, 1 (* flag indicates "may be signed" *) + +(* ltoa jumps into here. *) + +lta_shared: + + mov [bp][lta_value], ax + mov [bp][lta_value][2], bx + mov [bp][lta_strP], cx + mov [bp][lta_radix], dx + mov di, [bp][lta_strP] + +(* If the request is invalid, generate an empty result *) + + mov bx, [bp][lta_radix] + cmp bx, 36 + ja lta_end + cmp bl, 2 + jb lta_end + + mov ax, [bp][lta_value] + mov cx, [bp][lta_value][2] + cmp cx, 0 + jnl lta_notSigned (* Is the value signed or unsigned ? *) + + cmp bl, 10 (* only decimal numerals are signed *) + jne lta_notSigned + or si, si + je lta_notSigned + + mov byte [di], '-' + inc di + not cx + neg ax + cmc (* negate CX:AX *) + adc cx, 0 + +(* Now loop, taking each digit as modulo radix, and reducing the value + by dividing by radix, until the value is zeroed. Note that + at least one loop occurs even if the value begins as 0, + since we want "0" to be generated rather than "". +*) + +lta_notSigned: (* BX = radix, CX:AX = value *) + lea si, [bp][lta_buf] + jcxz lta_shortLoop + +lta_longLoop: + xchg cx, ax + sub dx, dx + div bx + xchg ax, cx + div bx + mov [si], dl + inc si + jcxz lta_shortTest (* does the value fit in 16 bits ? *) + jmp lta_longLoop + +lta_shortLoop: + sub dx, dx + div bx + mov [si], dl + inc si +lta_shortTest: + or ax, ax + jnz lta_shortLoop + +(* The value has now been reduced to zero and the digits are in + the buffer. +*) + lea cx, [bp][lta_buf] + neg cx + add cx, si (* CX = length of numeral *) + +(* The digits in the buffer must now be copied in reverse order into + the target string, translating to ASCII as they are moved. +*) + +lta_copy: + cld + +lta_copyLoop: + dec si + mov al, [si] + sub al, 10 + jae lta_alphaDigit + add al, '0' + 10 + jmp lta_storeDigit + +lta_alphaDigit: + add al, [__upperHex] + +lta_storeDigit: + stosb + loop lta_copyLoop + +(* terminate the output string with a zero. *) + +lta_end: + mov al, 0 + stosb + +(* return a pointer to the string *) + + mov ax, [bp][lta_strP] + pop si + pop di + pop dx + add sp, locals + pop bp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _INIT(DATA,28H) + +extrn __clock_time (* initialisation routine for clock function *) +extrn __InitLoop + +select _TEXT +do_initclock : (* defined later on ! *) + +select _INIT +initclock : dw MAGIC + db PR4 + dw do_initclock + +select _DATA +public __proc_time : dw initclock, 0 + +select _TEXT + call __clock_time + mov [__proc_time], ax + mov [__proc_time][2], dx + jmp __InitLoop + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memwmove : +(* +void *memwmove(void *dest, void *source, unsigned num) + +Moves num words, selecting direction according to overlap. +Returns destination address. +*) + +s_high = -2 +s_low = -4 +num = -6 +locals = 6 + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov si, bx + mov di, ax + mov [bp][num], cx + push ax + jcxz moveDone + cmp di, si + jb moveDown + je moveDone +moveUp: (* destination is higher *) + std + dec cx + shl cx, 1 + add si, cx + add di, cx + mov cx, [bp][num] +moveDown: (* destination is lower *) +rep ; movsw + cld +moveDone: + pop ax (* return destination address. *) + pop si + pop di + pop dx + mov sp, bp + pop bp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memmove : +(* +void *memmove(void *dest, void *source, unsigned num) +Selects correct move direction and moves num bytes. +Returns destination address. +*) + +s_high = -2 +s_low = -4 +num = -6 +locals = 6 + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov si, bx + mov di, ax + push ax + jcxz moveDone + cmp di, si + jb moveDown + je moveDone +moveUp: (* destination is higher *) + std + add si, cx + dec si + add di, cx + dec di +moveDown: (* destination is lower *) +rep ; movsb + cld +moveDone: + pop ax (* return destination address *) + pop si + pop di + pop dx + mov sp, bp + pop bp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _movmem : +(* +void *movmem(void *source, void *dest, unsigned num) +Selects correct move direction and moves num bytes. +Returns nothing. +*) + +s_high = -2 +s_low = -4 +num = -6 +locals = 6 + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov si, ax + mov di, bx + jcxz moveDone + cmp di, si + jb moveDown + je moveDone +moveUp: (* destination is higher *) + std + add si, cx + dec si + add di, cx + dec di +moveDown: (* destination is lower *) +rep ; movsb + cld +moveDone: + pop si + pop di + pop dx + mov sp, bp + pop bp + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public _swab : +(* +void swab(void *source, void *dest, unsigned num) +Moves num bytes, selecting direction according to overlap. Swaps byte order. +Returns nothing. +*) + + push dx + push di + push si + mov si, ax + mov di, bx + shr cx, 1 + jcxz moveDone + cmp di, si + jb moveDown + je moveDone +moveUp: (* destination is higher *) + std + push cx + dec cx + shl cx, 1 + add si, cx + add di, cx + pop cx +moveDown: (* destination is lower *) +swabLoop: + lodsw + xchg al, ah + stosw + loop swabLoop + cld +moveDone: + pop si + pop di + pop dx + ret 0 + +end + diff --git a/code/SIBOSDK/src/clib2.c b/code/SIBOSDK/src/clib2.c new file mode 100644 index 0000000..e927e01 --- /dev/null +++ b/code/SIBOSDK/src/clib2.c @@ -0,0 +1,1965 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* clib2.c - common miscellaneous library functions. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* Written by Simon Knight. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Modified by NSM. * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_TIME +#include +#include + +_STATIC void _qsort(char *buf, size_t num, size_t width, + int (* compare)(const void *e1, const void *e2), + char *_partition); + +void _cvt(LONGDOUBLE x, int n, int *dec, int *sign, char * buf) { + unsigned char bcd[10]; + LONGDOUBLE zero = 0; + LONGDOUBLE norm; + int i, k, kp, xtra; + + if ( x < zero ) { + x = -x; + *sign = 1; + } else { + *sign = 0; + } + + if ( x == zero ) + k = -10000; + else { + k = 1 + (int) FLOORL( LOG10L(x) + 0.001 ); + } + + xtra=0; + while (1) { + norm = x; + if ( k != -10000 ) { + kp = 18 - k; + if(kp > LDBL_MAX_10_EXP-1) { + xtra = kp - (LDBL_MAX_10_EXP-1); + kp = LDBL_MAX_10_EXP-1; + } + norm *= _pow_int(10,kp); + if(xtra) + norm*=_pow_int(10,xtra);; + } + + _bcd( norm, (char *)bcd ); + if ( k == -10000 ) { + k = 1; + break; + } + if ( ( bcd[8] >> 4 ) != 0 ) + break; + k -= 1; + } + + *dec = k; + for (i=8; n>1; n-=2){ + unsigned tmp = bcd[i]; + i -= 1; + *((int*)buf) = ( '0' + '0'*256 ) + ((tmp & 15)<<8) + (tmp >> 4); + buf+=2; + } + if ( n ) { + unsigned tmp = bcd[i]; + *buf = '0' + (tmp >> 4); + ++buf; + } + *buf = '\0'; +} + + +_STATIC void _insert_str(char *buf, char c) { + + movmem(buf, &buf[1], strlen(buf)+1); + buf[0] = c; +} + +void _cvt_round(int n, int *dec, int fc) { + int prec, l; + + if(n < 0) + n=-n; + if(fc) + n+=*dec; + else if(n == 0) { + _cvt_buf[0]='\0'; + return; + } + if(n > 63) + n=63; + l = strlen(_cvt_buf); + if(l > n) { + prec = n; + if(_cvt_buf[prec] >= '5') { + do { + _cvt_buf[prec--] = '0'; + if(prec < 0) { + _insert_str(_cvt_buf, '1'); + ++(*dec); + ++n; + break; + } + ++_cvt_buf[prec]; + } while(_cvt_buf[prec] > '9'); + } + _cvt_buf[n] = '\0'; + } + else { + while(l < n) { + _cvt_buf[l++]='0'; + } + _cvt_buf[l] = '\0'; + } +} + +double pow10(int p) +{ + return(pow(10.0, (double) p)); +} + +double modf(double x, double *y){ + double tmp = _round((LONGDOUBLE) x); + + *y = tmp; + return x - tmp; +} + +long double modfl(long double x, long double *y){ + + long double tmp = _round(x); + *y = tmp; + return x - tmp; +} + +char * ecvt(double x, int n, int *dec, int *sign ) { + + _cvt((LONGDOUBLE)x,18,dec,sign,_cvt_buf); + _cvt_round(n, dec, 0); + return _cvt_buf; +} + +char * fcvt(double x, int n, int *dec, int *sign ) { + + _cvt((LONGDOUBLE) x,18,dec,sign,_cvt_buf); + _cvt_round(n, dec, 1); + return _cvt_buf; +} + +/*-------------------------------------------------------------------------* +* toupper and tolower - case conversion functions. * +*--------------------------------------------------------------------------*/ + +int toupper(int ch) +{ + if(_ctype[(ch)+1] & _IS_LOW) + ch-= 0x20; + return(ch); +} + +int tolower(int ch) +{ + if(_ctype[(ch)+1] & _IS_UPP) + ch+=0x20; + return(ch); +} + +int isalnum(int c) +{ + return(_ctype[(c)+1] & (_IS_DIG | _IS_UPP | _IS_LOW)); +} + +int isalpha(int c) +{ + return(_ctype[(c)+1] & (_IS_UPP | _IS_LOW)); +} + +int isascii(int c) +{ + return((unsigned)((c)) < 0x81); +} + +int iscntrl(int c) +{ + return(_ctype[(c)+1] & _IS_CTL); +} + +int isdigit(int c) +{ + return(_ctype[(c)+1] & _IS_DIG); +} + +int isgraph(int c) +{ + return((c) >= 0x21 && (c) <= 0x7e); +} + +int islower(int c) +{ + return(_ctype[(c)+1] & _IS_LOW); +} + +int isprint(int c) +{ + return((c) >= 0x20 && (c) <= 0x7e); +} + +int ispunct(int c) +{ + return(_ctype[(c)+1] & _IS_PUN); +} + +int isspace(int c) +{ + return(_ctype[(c)+1] & _IS_SP); +} + +int isupper(int c) +{ + return(_ctype[(c)+1] & _IS_UPP); +} + +int isxdigit(int c) +{ + return(_ctype[(c)+1] & (_IS_DIG | _IS_HEX)); +} + +int _toupper(int c) +{ + return(c + 'A' - 'a'); +} + +int _tolower(int c) +{ + return(c + 'a' - 'A'); +} + +int toascii(int c) +{ + return(c & 0x7f); +} + +/*-------------------------------------------------------------------------* +* misc math functions * +*--------------------------------------------------------------------------*/ + +extern double HUGE; /* overflow return value */ +double _ten16 = 10.0e16; + +/*-------------------------------------------------------------------------* +* abs and labs - return absolute value of integer. * +*--------------------------------------------------------------------------*/ + +int abs(int num) +{ + if(num < 0 ) + return(-num); + return(num); +} + +long labs(long num) +{ + if(num < 0 ) + return(-num); + return(num); +} + +double poly(double x, int degree, double coeffs[]) +{ + double result; + + result=coeffs[degree]; + while(--degree >= 0) + { + result=x*result+coeffs[degree]; + } + return(result); +} + +long double polyl(long double x, int degree, long double coeffs[]) +{ + long double result; + + result=coeffs[degree]; + while(--degree >= 0) + { + result=x*result+coeffs[degree]; + } + return(result); +} + +/*-------------------------------------------------------------------------* +* atoul - converts string to unsigned long integer * +*--------------------------------------------------------------------------*/ + +unsigned long atoul(const char *s) +{ + unsigned long num, c; + int n; + + n=0; + num=0; + while(isspace(s[n++])); /* skip leading white-space */ + --n; + while(isdigit((unsigned) (c=s[n++]))) /* total digits */ + { + num*=10; + num+=c-'0'; + } + return(num); +} + +/*-------------------------------------------------------------------------* +* atol - converts string to signed long integer. * +*--------------------------------------------------------------------------*/ + +#define MINUS 1 + +long atol(const char *s) +{ + long num; + int n, c, sign; + + n=0; + num=0; + sign=0; + while(isspace(s[n++])); /* skip leading white-space */ + --n; + switch(s[n]) /* get sign */ + { + case '-': + sign=MINUS; + case '+': + ++n; + break; + default: + break; + } + while(isdigit(c=s[n++])) /* total digits */ + { + num*=10; + num+=c-'0'; + } + if(sign == MINUS) /* set sign */ + num*=-1; + return(num); +} + +/*-------------------------------------------------------------------------* +* atoi - converts string to signed integer. * +*--------------------------------------------------------------------------*/ + +int atoi(const char *s) +{ + int num; + int n, c, sign; + + n=0; + num=0; + sign=0; + while(isspace(s[n++])); /* skip white-space */ + --n; + switch(s[n]) /* get sign */ + { + case '-': + sign=MINUS; + case '+': + ++n; + break; + default: + break; + } + while(isdigit(c=s[n++])) /* total digits */ + { + num*=10; + num+=c-'0'; + } + if(sign == MINUS) /* set sign */ + num*=-1; + return(num); +} + +/*-------------------------------------------------------------------------* +* atof - convert string to double precision real. * +*--------------------------------------------------------------------------*/ + +double atof(const char *s) +{ + int discard; + + return(_atof(s, 0, &discard)); /*_atof does the work */ +} + +long double atofl(const char *s) +{ + int discard; + + return(_atof(s, 0, &discard)); /*_atof does the work */ +} + +/*-------------------------------------------------------------------------* +* strtod - convert string to double and store last character scanned. * +*--------------------------------------------------------------------------*/ + +double strtod(const char *s, char **eptr) +{ + int pos; + double ret; + + ret=(double) _atof(s, _STD, &pos); /* _atof does the work */ + if(pos <= 0) + { + if(pos == -1) + errno=ERANGE; + if(eptr) + *eptr=(char *) s; + } + else if(eptr) + *eptr= (char *) &s[pos]; /* store address of last char scanned */ + return(ret); +} + +long double strtodl(const char *s, char **eptr) +{ + int pos; + long double ret; + + ret= _atof(s, _STD, &pos); /* _atof does the work */ + if(pos <= 0) + { + if(pos == -1) + errno=ERANGE; + if(eptr) + *eptr=(char *) s; + } + else if(eptr) + *eptr= (char *) &s[pos]; /* store address of last char scanned */ + return(ret); +} + +double _atof(const char *s, int flag, int *pos) +{ + char mbuf[18]; /* converts string to unpacked BCD */ + int n, p, point; /* then calls _acvt to convert to */ + int c, count, places; /* double */ + int exp; + int last_exp; + double ret; + + n=0; + p=0; + exp=0; + count=18; + point=0; + places=0; + last_exp=0; + while(isspace(s[n])) /* skip leading white-space */ + { + ++n; + } + if((c=s[n]) == '+') /* get sign of mantissa */ + ++n; + else if(c == '-') + { + ++n; + flag|=_MNEG; + } + while(s[n] == '0') /* skip leading zeros */ + { + ++n; + } + if(s[n] == DEC_POINT) + { + ++n; /* number less than 10e0 */ + while(s[n] == '0') + { + ++n; + --point; + } + while(isdigit(c=s[n])) /* store digits to precsion */ + { + if(count-- == 0) + break; + mbuf[p++]= (char) c; + ++n; + ++places; + } + point-=places; /* adjust for BCD */ + } + else if(!isdigit(s[n])) + { + *pos=0; + return(0); + } + else + { + while(isdigit(c=s[n])) /* number greater than 10e0 */ + { + if(count-- > 0) + mbuf[p++]= (char) c; /* store digits to precision */ + ++n; + ++places; + } + if(c == '.') + { + point=p; + ++n; + while(isdigit(c=s[n])) + { + if(count-- > 0) + mbuf[p++]= (char) c; + ++n; + } + point-=p; /* adjust exponent for decimal point */ + } + else if(places > 18) + point=places-18; /* adjust exponent for BCD */ + } + if(((c=tolower(c)) == 'd') || (c == 'e')) + { + ++n; + if((c=s[n]) == '+') /* get sign of exponent */ + ++n; + else if(c == '-') + { + ++n; + flag|=_ENEG; + } + while(isdigit(c=s[n++])) + { + exp*=10; + exp+=c - '0'; + if(exp < last_exp) + { + exp=1000; + break; + } + last_exp=exp; + } + if(flag&_ENEG) + exp*= -1; + --n; + } + exp+=point; /* calculate total exponent */ + if(exp > 308) + { + ret=HUGE_VAL; + if(flag&_MNEG) + ret*= -1; + *pos=-1; + return(ret); + } + else if(exp < -308) + { + *pos=-1; + return(0); + } + *pos=n; + ret=_acvt(flag, mbuf, exp, p); /* convert from BCD to double */ + return ret; +} + +/*-------------------------------------------------------------------------* +* strtol - converts string to signed long and stores address of * +* last character scanned. * +*--------------------------------------------------------------------------*/ + +long strtol(const char *s, char **eptr, int base) +{ + long num, last_val; + int n, c, flag, scanned; + + n=0; + num=0; + last_val=0; + flag=0; + scanned=0; + while(isspace(s[n])) /* skip white-space */ + { + ++n; + } + switch(s[n]) /* get sign */ + { + case '-': + flag|=_NEG; + case '+': + ++n; + break; + } + if(s[n] == '0') /* check for hex or octal prefixes */ + { + ++n; + if(tolower(s[n]) == 'x') + { + if((base == 16) || (base == 0)) + { + flag|=_HEX; + ++n; + } + else + return(0); + } + else if((base == 0) || (base == 8)) + flag|=_OCT; + else + scanned=1; + } + if((base > 36) || (base < 2)) + base=0; + if(base == 0) /* if base is 0 use prefix */ + { + if(flag&_HEX) + base=16; + else if(flag&_OCT) + base=8; + else + base=10; + } + while(1) + { + c=s[n]; + if(!isdigit(c)) + c=tolower(c)-'a'+10; /* convert to digit and total */ + else + c-='0'; + if((c >= base) || (c < 0)) /* exit if not in radix */ + break; + scanned=1; + num*= (long) base; + num+=c; + if(num < last_val) + { + errno=ERANGE; + if(flag&_NEG) + return(LONG_MIN); + return(LONG_MAX); + } + last_val=num; + ++n; + + } + if(!scanned) + { + *eptr= (char *) s; + return(0); + } + if(flag&_NEG) /* set sign */ + num*=-1; + if(eptr != NULL) /* store address of last character scanned */ + *eptr=(char *) &s[n]; + return(num); +} + +/*-------------------------------------------------------------------------* +* strtoul - converts string to unsigned long and stores address of * +* last character scanned. * +*--------------------------------------------------------------------------*/ + +unsigned long strtoul(const char *s, char **eptr, int base) +{ + unsigned long num; + unsigned long last_val; + int n, c, flag, scanned; + + n=0; + num=0; + last_val=0; + flag=0; + scanned=0; + while(isspace(s[n])) + { + ++n; + } + if(s[n] == '+') + ++n; + if(s[n] == '0') + { + ++n; + if(tolower(s[n]) == 'x') + { + if((base == 16) || (base == 0)) + { + flag|=_HEX; + ++n; + } + else + return(0); + } + else if((base == 8) || (base == 0)) + flag|=_OCT; + } + if((base > 36) || (base < 2)) + base=0; + if(base == 0) + { + if(flag&_HEX) + base=16; + else if(flag&_OCT) + base=8; + else + base=10; + } + while(1) + { + c=s[n]; + if(!isdigit(c)) + c=tolower(c)-'a'+10; + else + c-='0'; + if((c >= base) || (c < 0)) + break; + scanned=1; + num*=base; + num+= (long) (unsigned) c; + if(num < last_val) + { + errno=ERANGE; + return(ULONG_MAX); + } + last_val=num; + ++n; + + } + if(!scanned) + { + if(eptr != NULL) + *eptr= (char *) s; + return(0); + } + if(eptr != NULL) + *eptr= (char *) &s[n]; + return(num); +} + +/*-------------------------------------------------------------------------* +* gcvt - convert double precision real to ascii string. * +*--------------------------------------------------------------------------*/ + +char *gcvt(double num, int digits, char *buf) +{ + if((digits > 18) || ( digits < 0)) /* max precision is 18 */ + digits=18; + return(_f_fmt(buf, (LONGDOUBLE) num, 0x400, digits)); +} + +char *gcvtl(LONGDOUBLE num, int digits, char *buf) +{ + if((digits > 18) || ( digits < 0)) /* max precision is 18 */ + digits=18; + return(_f_fmt(buf, num, 0x400, digits)); +} + +/*-------------------------------------------------------------------------* +* div and ldiv - return quotient and remainder of division in structure * +*--------------------------------------------------------------------------*/ + +div_t div(int num, int den) +{ + div_t ret; + + ret.quot=num/den; + ret.rem= num%den; + return(ret); +} + +ldiv_t ldiv(long num, long den) +{ + ldiv_t ret; + + ret.quot=num/den; + ret.rem= num%den; + return(ret); +} + +/*-------------------------------------------------------------------------* +* strerror - return address of system message string. * +*--------------------------------------------------------------------------*/ + +char *strerror(int errnum) +{ +#ifdef OLDERRORS + if(errno > sys_nerr) + errnum=EFAULT; + return(sys_errlist[errnum+1]); /* message is system string only */ +#else + return(_getErrorText(errnum,_sys_errbuf)); +#endif +} + +char *_strerror(const char *str) +{ +#ifdef OLDERRORS + int ernum; + /* concatenates user message and */ + if(errno > sys_nerr) /* system message for last error */ + ernum=EFAULT; + else + ernum=errno; + if(str == NULL) + return(sys_errlist[ernum+1]); + sprintf(_sys_errbuf, "%.94s: %s\n", str, sys_errlist[ernum+1]); +#else + char err[0x128]; + + _getErrorText(errno,&err[0]); + if (str == NULL) + strcpy(_sys_errbuf,&err[0]); + sprintf(_sys_errbuf, "%.94s: %s\n", str, &err[0]); +#endif + return(_sys_errbuf); +} + +/*-------------------------------------------------------------------------* +* perror - prints user mesage and system message for last error * +*--------------------------------------------------------------------------*/ + +void perror(const char *str) +{ +#ifdef OLDERRORS + int ernum; + + if(errno > sys_nerr) + ernum=EFAULT; + else + ernum=errno; + if(str != NULL) + fprintf(stderr, "%.94s: ", str); + fprintf(stderr, "%s\n", sys_errlist[ernum+1]); +#else + fprintf(stderr, _strerror(str)); +#endif + return; +} + +/*-------------------------------------------------------------------------* +* rand, srand and randomize - random number generation. * +*--------------------------------------------------------------------------*/ + +_STATIC int _r_hptr=0; +_STATIC int _r_lptr=0; +_STATIC int _r_hr[_HMAX+1]; + +int rand() +{ + int result; + + if((_r_lptr == 0) && (_r_hptr == 0)) + srand(1); + if (_r_hptr == 0) + { + _r_hptr=_HMAX; + _r_lptr-=1; + } + else + { + _r_hptr-=1; + if(_r_lptr == 0) + _r_lptr=_HMAX; + else + _r_lptr-=1; + } + result=_r_hr[_r_hptr]+_r_hr[_r_lptr]; + _r_hr[_r_hptr]=result; + return(result&0x7FFF); +} + +void randomize(void) +{ + struct time t; + + gettime(&t); + srand(t.ti_sec+t.ti_hund); + return; +} + +void srand(unsigned seed) +{ + unsigned long x; + int i; + + _r_hptr=_HMAX; + _r_lptr=23; + x=(long)(unsigned) seed; + i=0; + do + { + x= x*3141592621L+17; + _r_hr[i++]= (int) (x/0x10000L); + } while (i <= _HMAX); + return; +} + +/*-------------------------------------------------------------------------* +* time module - system anf file time functions. * +*--------------------------------------------------------------------------*/ + +/* +Leap years - centennial years are only leap years if they are divisible by +400. Therefore the year 2000 is a leap year. MSDOS clock functions won't +work in 2100 anyway, so execption will not occur during the life of this code. +*/ + +_STATIC int _mtable[]= { 0, 31, 59, 90, 120, 151, + 181, 212, 243, 273, 304, 334, 365 }; + +_STATIC int _lmtable[]= { 0, 31, 60, 91, 121, 152, + 182, 213, 244, 274, 305, 335, 366 }; + +_STATIC char *_wdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; +_STATIC char *_months[]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + +_STATIC char *_fwdays[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; +_STATIC char *_fmonths[]= { "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" }; + +_STATIC char _asct_buf[28]; +_STATIC struct tm _tm_buf; + +/*-------------------------------------------------------------------------* +* ctime - convert time in seconds to string format. * +*--------------------------------------------------------------------------*/ + +char *ctime(const time_t *clock) +{ + struct date dte; /* uses static buffer */ + struct time tme; + int weekday; + char *buffer; + + buffer=_asct_buf; + weekday=_t_to_struct(*clock, &dte, &tme); + sprintf(buffer,"%s %s %.2d %.2d:%.2d:%.2d %.4d\n",_wdays[weekday], + _months[dte.da_mon-1],dte.da_day,tme.ti_hour,tme.ti_min, + tme.ti_sec,dte.da_year); + return(buffer); +} + +/*-------------------------------------------------------------------------* +* asctime - convert time structure to string format. * +*--------------------------------------------------------------------------*/ + +char *asctime(const struct tm *tme) +{ + char *buffer; + buffer=_asct_buf; + sprintf(buffer,"%s %s %.2d %.2d:%.2d:%.2d %.4d\n",_wdays[tme->tm_wday], + _months[tme->tm_mon],tme->tm_mday,tme->tm_hour,tme->tm_min, + tme->tm_sec,tme->tm_year+1900); + return(buffer); +} + +/*-------------------------------------------------------------------------* +* ftime - fills in timeb structure. * +*--------------------------------------------------------------------------*/ + +void ftime(struct timeb *tp) +{ + struct time st; + + gettime(&st); + tp->millitm=st.ti_hund*10; + time(&tp->time); + tp->dstflag=daylight; + if(timezone >= 0) + tp->timezone=1440-(((int) timezone)/60); + else + tp->timezone=(int) -(timezone/60); + return; +} + +/*-------------------------------------------------------------------------* +* low- level time functions. * +*--------------------------------------------------------------------------*/ + +struct tm *_t_to_tm(unsigned long clock) +{ + struct date dte; /* converts time in seconds to */ + struct time tme; /* struct tm format */ + struct tm *tmbuf; + + tmbuf=&_tm_buf; + tmbuf->tm_wday=_t_to_struct(clock, &dte, &tme); + tmbuf->tm_sec=tme.ti_sec; + tmbuf->tm_min=tme.ti_min; + tmbuf->tm_hour=tme.ti_hour; + tmbuf->tm_mday=dte.da_day; + tmbuf->tm_mon=dte.da_mon-1; + tmbuf->tm_year=dte.da_year-1900; + if(dte.da_year%4 == 0) /* 2000 is a leap year */ + tmbuf->tm_yday=_lmtable[dte.da_mon-1]; + else + tmbuf->tm_yday=_mtable[dte.da_mon-1]; + tmbuf->tm_yday+=dte.da_day-1; + tmbuf->tm_isdst=daylight; + return(tmbuf); + } +/*-------------------------------------------------------------------------* +* time - returns number of seconds since 01 01 1970 GMT * +*--------------------------------------------------------------------------*/ + +time_t time(time_t *tptr) +{ + struct date dte; + struct time tme; + time_t ret; + + getdate(&dte); /* get time and date from system */ + gettime(&tme); + ret=(time_t)_t_calc(dte, tme); /* convert to seconds GMT */ + if(tptr) + *tptr=ret; + return(ret); +} + +/*-------------------------------------------------------------------------* +* stime - set system clock from number of seconds after 01 01 1970 GMT * +*--------------------------------------------------------------------------*/ + +int stime(time_t *tptr) +{ + struct date dte; + struct time tme; + time_t val; + + val=*tptr+timezone; + if(daylight) + val+=3600; + _t_to_struct(val, &dte, &tme); /* convert seconds to years etc. */ + setdate(&dte); /* set system time */ + settime(&tme); + return(0); +} + +/*-------------------------------------------------------------------------* +* difftime - returns double time difference * +*--------------------------------------------------------------------------*/ + +double difftime(time_t t1, time_t t2) + +{ + return((double) (t1-t2)); +} + +/*-------------------------------------------------------------------------* +* tzset - does nothing in this implementation * +*--------------------------------------------------------------------------*/ + +void tzset(void) +{ + return; +} + +/*-------------------------------------------------------------------------* +* gmtime - converts time in seconds to structure GMT. * +*--------------------------------------------------------------------------*/ + +struct tm *gmtime(const time_t *clock) +{ + struct tm *ret; + + ret=_t_to_tm(*clock); + ret->tm_isdst=0; + return(ret); +} + +/*-------------------------------------------------------------------------* +* localtime - converts time in seconds to structure loca time. * +*--------------------------------------------------------------------------*/ + +struct tm *localtime(const time_t *clock) +{ + time_t tt; + struct tm *ret; + int dst; + + tt=*clock+timezone; + if(daylight) + { + tt+=3600; + dst=1; + } + else + dst=0; + ret=_t_to_tm(tt); + ret->tm_isdst=dst; + return(ret); +} + +/*-------------------------------------------------------------------------* +* clock - returns number of seconds since process started. * +*--------------------------------------------------------------------------*/ + +clock_t clock() +{ + clock_t tt; + + tt=_clock_time(); + if(tt < _proc_time) + tt+= _DAYSECS; + return(tt -_proc_time); +} + +clock_t _clock_time() +{ + struct time tme; + clock_t ret; + + gettime(&tme); + ret=tme.ti_hund; + ret+=((clock_t)tme.ti_sec)*100; + ret+=((clock_t)tme.ti_min)*6000; + ret+=((clock_t)tme.ti_hour)*360000L; + return(ret); +} + +time_t mktime(struct tm *timeptr) +{ + unsigned long ret; + int isdt; + + if(timeptr->tm_year < 0) + return((time_t) -1); + if((ret=_t_norm(timeptr)) == ULONG_MAX) + return((time_t) -1); + isdt=timeptr->tm_isdst; + memcpy(timeptr, _t_to_tm(ret), sizeof(struct tm)); + if(isdt >= 0) + timeptr->tm_isdst=isdt; + if(timeptr->tm_isdst) + ret-=3600; + ret-=timezone; + return(ret); +} + +size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) +{ + size_t fcount; + size_t scount; + int c, thour; + char temp[32]; + char *source; + int yday; + int yweek; + + fcount=0; + scount=0; + if(timeptr->tm_year%4 == 0) /* 2000 is a leap year */ + yday=_lmtable[timeptr->tm_mon]; + else + yday=_mtable[timeptr->tm_mon]; + yday+=timeptr->tm_mday; + while((c=format[fcount++]) != 0) + { + if(scount == maxsize) + return(0); + if(c == '%') + { + c=format[fcount++]; + if(c == 0) + break; + switch(c) + { + case '%': + if(scount == maxsize) + return(0); + s[scount++]=c; + continue; + case 'a': + source= _wdays[timeptr->tm_wday]; + break; + case 'A': + source= _fwdays[timeptr->tm_wday]; + break; + case 'b': + source=_months[timeptr->tm_mon]; + break; + case 'B': + source= _fmonths[timeptr->tm_mon]; + break; + case 'c': + source= asctime(timeptr); + break; + case 'd': + sprintf(temp, "%.2d", timeptr->tm_mday); + source=temp; + break; + case 'H': + sprintf(temp, "%.2d", timeptr->tm_hour); + source=temp; + break; + case 'I': + thour=timeptr->tm_hour; + if(thour > 12) + thour-=12; + sprintf(temp, "%.2d", thour); + source=temp; + break; + case 'j': + sprintf(temp, "%.2d", yday); + source=temp; + break; + case 'm': + sprintf(temp, "%.2d", timeptr->tm_mon+1); + source=temp; + break; + case 'M': + sprintf(temp, "%.2d", timeptr->tm_min); + source=temp; + break; + case 'p': + thour=timeptr->tm_hour; + if(thour > 12) + source="PM"; + else + source="AM"; + break; + case 'S': + sprintf(temp, "%.2d", timeptr->tm_sec); + source=temp; + break; + case 'U': + yweek=yday/7; + if(timeptr->tm_wday == 0) + ++yweek; + sprintf(temp, "%.2d", yweek); + source=temp; + break; + case 'w': + sprintf(temp, "%d", timeptr->tm_wday); + source=temp; + break; + case 'W': + yweek=yday/7; + if(timeptr->tm_wday == 1) + ++yweek; + sprintf(temp, "%.2d", yweek); + source=temp; + break; + case 'x': + sprintf(temp, "%s %s %d, %d", _wdays[timeptr->tm_wday], + _months[timeptr->tm_mon], + timeptr->tm_mday, + timeptr->tm_year+1900); + source=temp; + break; + case 'X': + sprintf(temp, "%.2d:%.2d:%.2d", timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); + source=temp; + break; + case 'y': + sprintf(temp, "%.2d", timeptr->tm_year); + source=temp; + break; + case 'Y': + source=itoa((timeptr->tm_year+1900), temp, 10); + break; + case 'Z': + continue; + default: + continue; + } + scount=_set_date(s, scount, maxsize, source); + continue; + } + if(scount == maxsize) + return(0); + s[scount++]=c; + } + if(scount == maxsize) + return(0); + s[scount]=0; + return(scount); +} + +char *_strtime(char *timestr) +{ + time_t tt; + struct tm *timeptr; + + time(&tt); + timeptr=localtime(&tt); + sprintf(timestr, "%.2d:%.2d:%.2d", timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); + return(timestr); +} + +char *_strdate(char *datestr) +{ + time_t tt; + struct tm *timeptr; + + time(&tt); + timeptr=localtime(&tt); + sprintf(datestr, "%.2d/%.2d/%.2d", timeptr->tm_mon+1, timeptr->tm_mday, timeptr->tm_year); + return(datestr); +} + +unsigned long _ytable(int year) +{ + + return( ((long)year * 365L) + (long)((year+1)/4) ); +} + + +size_t _set_date(char *s, size_t scount, size_t lim, char *st) +{ + int n=0; + int c; + + while(scount < lim) + { + c=st[n++]; + if(c == 0) + break; + s[scount]=c; + scount++; + } + return(scount); +} + +unsigned long _t_norm(struct tm *tp) +{ + unsigned long xdays; + long st, pt; + + st = (long)tp->tm_sec; + st += ((long)tp->tm_min*60); + st += ((long)tp->tm_hour*3600); + if(abs(tp->tm_mday) > 24800) + return(ULONG_MAX); + pt = ((long)(tp->tm_mday-1)*3600L*24L); + if(labs(st/2 + pt/2) > LONG_MAX/2) + return(ULONG_MAX); + st+=pt; + + tp->tm_year+=tp->tm_mon/12; + if(tp->tm_year < 0) + return(-1); + tp->tm_mon=tp->tm_mon%12; + if((tp->tm_year+1900)%4) + xdays=_mtable[tp->tm_mon]; + else + xdays=_lmtable[tp->tm_mon]; + if(tp->tm_year > 186) + return(ULONG_MAX); + xdays+=_ytable(tp->tm_year-70); + xdays*=(3600L*24L); + if((labs(st/2 + xdays/2) > LONG_MAX) || ((st < 0) && (labs(st) > xdays))) + return(ULONG_MAX); + return(st+xdays); +} + +unsigned long _t_calc(struct date dte, struct time tme) +{ + time_t ret; + int leap_year; + + leap_year=(dte.da_year%4 == 0); /* converts DOS format to seconds */ + dte.da_year-=1970; + ret= _ytable(dte.da_year);/* total days in years */ + if(leap_year) + ret+=_lmtable[dte.da_mon-1]; /* add days in months */ + else + ret+=_mtable[dte.da_mon-1]; + ret+=dte.da_day-1; /* add days in month */ + ret*=_DAYSECS; /* convert to seconds */ + ret+= ((long) tme.ti_hour)*3600; /* add hours in day */ + ret+=tme.ti_min*60; /* add hours in day */ + ret+=tme.ti_sec; /* add seconds */ + ret-=timezone; /* timezone and daylight saving */ + if(daylight) + ret-=3600; + return(ret); +} + +int _t_to_struct(unsigned long val, struct date *dte, struct time *tme) +{ + int n, wday; /* convert time in seconds to */ + long day; /* DOS format */ + + n=0; + day=val%_DAYSECS; + tme->ti_hour= (unsigned char) (day/3600); + day%=3600; + tme->ti_min= (unsigned char) (day/60); + tme->ti_sec= (unsigned char) (day%60); + tme->ti_hund=0; + val/=_DAYSECS; /* convert to days */ + wday= (int) (val%7); + wday = (wday+4)%7; + while(_ytable(n) <= val) + ++n; + dte->da_year=1969+n; + val-=_ytable(n-1); + n=0; + if(dte->da_year%4 == 0) /* 2000 is leap year so no exception */ + { + while(_lmtable[n] <= val) + ++n; + val-=_lmtable[n-1]; + } + else + { + while(_mtable[n] <= val) + ++n; + val-=_mtable[n-1]; + } + dte->da_mon= (unsigned char) n; + dte->da_day= (unsigned char) val+1; + return(wday); +} + +time_t get_utime(int handle) /* gets file time and converts */ +{ + struct utm ftime; + struct date dte; + struct time tme; + + _filetime(handle, &ftime); + tme.ti_sec = (unsigned char) ftime.u_sec; + tme.ti_min = (unsigned char) ftime.u_min; + tme.ti_hour= (unsigned char) ftime.u_hour; + dte.da_day= (unsigned char) ftime.u_day; + dte.da_mon= (unsigned char) ftime.u_mon; + dte.da_year=ftime.u_year+1980; + return(_t_calc(dte, tme)); +} + +/*-------------------------------------------------------------------------* +* qsort - sort array member using quicksort algorithm * +*--------------------------------------------------------------------------*/ + +_STATIC void _qsort(char *buf, size_t num, size_t width, + int (* compare)(const void *e1, const void *e2), + char *_partition)\ +{ + int i, j; + int new_num, right_num; + + while(num > 1) { + memcpy(_partition, &buf[(num/2)*width], width); /* get partition element */ + i= -width; + j=num*width; + while(1) { /* sort partition */ + do { + i+=width; + } while( (i < j) && (compare(&buf[i], _partition) < 0 ) ); + do { + j-=width; + } while( (i < j) && (compare(&buf[j], _partition) > 0) ); + if(i >= j) + break; + _swap(&buf[i], &buf[j], width); + } + new_num=i/width; + right_num= num-new_num; + if( new_num < right_num) { /* sort new partitions */ + _qsort(buf, new_num, width, compare, _partition); + num=right_num; + buf=&buf[i]; + } + else { + _qsort(&buf[i], right_num, width, compare, _partition); + num=new_num; + } + } + return; +} + +void qsort(void *base, size_t num, size_t width, + int (* compare)(const void *e1, const void *e2)) +{ + char *_partition; + + _partition=malloc(width); /* allocate buffer for partition member */ + if(_partition != NULL) + { + _qsort((char *)base, num, width, compare, _partition); /* sort array */ + free(_partition); + } + return; +} + +/*-------------------------------------------------------------------------* +* lfind - find key element in array. * +*--------------------------------------------------------------------------*/ + +char *lfind(const char *key, const char *base, unsigned *num, + unsigned width, int (* compare)(const void *e1, const void *e2)) +{ + const char *ptr; + unsigned count; + + count=*num; + ptr=base; + while(count--) + { + if(compare(key, ptr) == 0) + return(ptr); /* found key */ + ptr+=width; + } + return(NULL); /* key not found */ +} + +/*-------------------------------------------------------------------------* +* lfind - find key element in array and append if not present. * +*--------------------------------------------------------------------------*/ + +char *lsearch(const char *key, char *base, unsigned *num, + unsigned width, int (* compare)(const void *e1, const void *e2)) +{ + char *ptr; + unsigned count; + + count=*num; + ptr=base; + while(count--) + { + if(compare(key, ptr) == 0) + return(ptr); /* found key */ + ptr+=width; + } + memcpy(ptr, key, width); /* not found - append */ + return(ptr); +} + +/*-------------------------------------------------------------------------* +* bsearch - search for key member in sorted array. * +*--------------------------------------------------------------------------*/ + +void *bsearch(const void *key, const void *base, unsigned num, + unsigned width, int (* compare)(const void *e1, const void *e2)) +{ + long l, r, x; + int ret; + char *ptr; + + l = 0; + r = num; + do + { + x = (l+r)/2; + ptr = &((char *)base)[x*width]; + ret=compare(key, ptr); + if(ret < 0) + r = x - 1; + else if(ret > 0) + l = x + 1; + else + return(ptr); + } while (l < r); + ptr = &((char *)base)[l*width]; + return(compare(key,ptr) ? NULL : ptr); +} + +/*-------------------------------------------------------------------------* +* sbrk - returns -1 in this implementation. * +*--------------------------------------------------------------------------*/ + +#pragma warn(wpnu => off) + +char *sbrk(int incr) + +{ + return( (char *) 0xFFFF); +} + + +/*-------------------------------------------------------------------------* +* locale functions * +*--------------------------------------------------------------------------*/ + +_STATIC char _last_localeALL[4]="C"; +_STATIC char _last_localeCOLL[4]="C"; +_STATIC char _last_localeCTYP[4]="C"; +_STATIC char _last_localeNUM[4]="C"; +_STATIC char _last_localeTIME[4]="C"; +_STATIC char _last_localeMON[4]="C"; + +struct lconv *localeconv() + +{ + return(&_lconv); +} + +char * setlocale(int category, const char *locale) +{ + char *ret; + + if(locale) + { + if((strcmp(locale, "")) && (strcmp(locale, "C"))) + return(NULL); + } + switch(category) + { + case LC_ALL: + if(locale == NULL) + return(_last_localeALL); + ret=_last_localeALL; + strcpy(_last_localeALL, locale); + strcpy(_last_localeCOLL, locale); + strcpy(_last_localeCTYP, locale); + strcpy(_last_localeNUM, locale); + strcpy(_last_localeTIME, locale); + strcpy(_last_localeMON, locale); + return(ret); + break; + case LC_COLLATE: + if(locale == NULL) + return(_last_localeCOLL); + ret=_last_localeCOLL; + strcpy(_last_localeCOLL, locale); + return(ret); + break; + case LC_CTYPE: + if(locale == NULL) + return(_last_localeCTYP); + ret=_last_localeCTYP; + strcpy(_last_localeCTYP, locale); + return(ret); + break; + case LC_NUMERIC: + if(locale == NULL) + return(_last_localeNUM); + ret=_last_localeNUM; + strcpy(_last_localeNUM, locale); + return(ret); + break; + case LC_TIME: + if(locale == NULL) + return(_last_localeTIME); + ret=_last_localeTIME; + strcpy(_last_localeTIME, locale); + return(ret); + break; + case LC_MONETARY: + if(locale == NULL) + return(_last_localeMON); + ret=_last_localeMON; + strcpy(_last_localeMON, locale); + return(ret); + break; + default: + return(NULL); + } +} + +/*-------------------------------------------------------------------------* +* multi-byte functions * +*--------------------------------------------------------------------------*/ + +int mblen(const char *s, size_t n) +{ + if((s) && (s[0])) + return(1); + return(0); +} + +int mbtowc(wchar_t *pwc, const char *s, size_t n) +{ + if((s) && (pwc)) + { + *pwc=*s; + if(s[0]) + return(1); + } + return(0); +} + +int wctomb(char *s, wchar_t wchar) +{ + if(s) + { + *s=wchar; + return(1); + } + return(0); +} + +/*-------------------------------------------------------------------------* +* matherr - dummy math error handler. * +*--------------------------------------------------------------------------*/ + +int _matherr(struct exception *x) +{ + if(x != NULL); + return(0); +} + +/*-------------------------------------------------------------------------* +* misc compatibilty functions * +*--------------------------------------------------------------------------*/ + +#pragma warn(wpnu => on) + +void fnmerge(char *path,const char *drive,const char *dir,const char *name,const char *ext) + { + if (drive && *drive) + { + *path++ = *drive++; // may not need ++ on drive + *path++ = ':'; + } + if (dir && *dir) + { + path = stpcpy(path,dir); + if (*(path-1) != '\\' && *(path-1) != '/') + *path++ = '\\'; + } + if (name) + path=stpcpy(path,name); + if (ext && *ext) + { + if(*ext != '.') + *path++ = '.'; + path=stpcpy(path,ext); + } + *path = 0; + } + +int fnsplit(const char *path, char *drive, char *dir, char *name, char *ext) { + + int n, p, c; + int ret; + int dir_start, name_start, ext_start, path_end; + + n=0; + ret=0; + if((path[0]) && ((path[1] == ':') || (path[2] == ':'))) { + do { + c=path[n]; + drive[n]=c; + ++n; + } while (c != ':'); + ret |= DRIVE; + } + drive[n]='\0'; + dir_start=n; + name_start=n; + ext_start=0; + while((c=path[n]) != '\0') { + switch(c) { + case '.' : + if(!((path[n+1] == '.') || (path[n+1] == '\\') || (path[n+1] == '/'))) + ext_start=n; + ++n; + break; + case '/' : + case '\\': + name_start=++n; + ext_start=0; + break; + case '*' : + case '?' : + ret |= WILDCARDS; + default: + ++n; + break; + } + } + path_end=n; + if(ext_start == 0) + ext_start=n; + + n=dir_start; + p=0; + if(n < name_start) { + ret|=DIRECTORY; + while((n < name_start) && (p < MAXDIR-1)) { + dir[p++]=path[n++]; + } + } + dir[p]='\0'; + + n=name_start; + p=0; + if(n < ext_start) { + ret |= FILENAME; + while((n < ext_start) && (p < MAXFILE-1)) { + name[p++]=path[n++]; + } + } + name[p]='\0'; + + p=0; + if((ext_start >= name_start) && (path[ext_start])) { + n=ext_start; + ret |= EXTENSION; + while((n < path_end) && (p < MAXEXT-1)) { + ext[p++]=path[n++]; + } + } + ext[p]='\0'; + + return ret; +} + +void _makepath(char *path, const char *drive, const char *dir, + const char *name, const char *ext) +{ + int pos; + + if(drive) + strcpy(path, drive); + if(dir) + { + if((dir[0] != '\\') && (dir[0] != '/')) + strcat(path, "\\"); + strcat(path, dir); + pos=strlen(path)-1; + if(!((path[pos] == '\\') || (path[pos] == '/') && (!dir[0]))) + { + path[pos+1]='\\'; + path[pos+2]=0; + } + } + strcat(path, name); + if((ext) && (ext[0])) + { + if(ext[0] != '.') + { + pos=strlen(path); + path[pos]='.'; + path[pos+1]='\0'; + } + strcat(path, ext); + } + return; +} + +void _splitpath(const char *path, char *drive, char *dir, char *name, char *ext) { + int n, p, c; + int dir_start, name_start, ext_start, path_end; + + n=0; + if((path[0]) && ((path[1] == ':') || (path[2] == ':'))) { + do { + c=path[n]; + drive[n]=c; + ++n; + } while (c != ':'); + } + drive[n]='\0'; + dir_start=n; + name_start=n; + ext_start=0; + while((c=path[n]) != '\0') { + switch(c) { + case '.' : + if(!((path[n+1] == '.') || (path[n+1] == '\\') || (path[n+1] == '/'))) + ext_start=n; + ++n; + break; + case '/' : + case '\\': + name_start=++n; + ext_start=0; + break; + default: + ++n; + break; + } + } + path_end=n; + if(ext_start == 0) + ext_start=n; + + n=dir_start; + p=0; + while((n < name_start) && (p < _MAX_DIR-1)) { + dir[p++]=path[n++]; + } + dir[p]='\0'; + + n=name_start; + p=0; + while((n < ext_start) && (p < _MAX_FNAME-1)) { + name[p++]=path[n++]; + } + name[p]='\0'; + + p=0; + if(ext_start >= name_start) { + n=ext_start; + while((n < path_end) && (p < _MAX_EXT-1)) { + ext[p++]=path[n++]; + } + } + ext[p]='\0'; +} + +_STATIC char _spath[80]; + +char *searchpath(const char *filename) +{ + + _searchenv(filename, "PATH", _spath); + if(_spath[0]) + return(_spath); + return(NULL); +} + +/*-------------------------------------------------------------------------* +* strtok - separates tokens from string. * +*--------------------------------------------------------------------------*/ + +_STATIC char *_token; + +char *strtok(char *s1, const char *s2) +{ + int n, retn; + + if(s1 == NULL) + s1=_token; + if(s1 == NULL) + return(NULL); + /* use end of last token as starting point */ + n=strspn(s1, s2); /* skip leading deliminators */ + if(s1[n] == '\0') + return(NULL); + retn=n; /* save beginning of token */ + n+=strcspn(&s1[n], s2); /* find end of token */ + if(n == retn) + return(NULL); + if(s1[n]) + { + _token=&s1[n+1]; + s1[n]=0; /* terminate token */ + } + else + { + _token=NULL; + } + return(&s1[retn]); /* return address of token */ +} + +char *StrToPas(char *passtr, const char *s) { + + size_t l; + + l=strlen(s); + if(l > 255) + return NULL; + passtr[0]=(char) l; + return strcpy(&passtr[1], s); +} + +char *_ld_format(char *fmt_buf, LONGDOUBLE num, int flag, int prec) +{ + return _f_fmt(fmt_buf, num, flag, prec); +} + +char *_v_format(unsigned long l, char *s) +{ + return _fptoa(l, s); +} diff --git a/code/SIBOSDK/src/complex.cpp b/code/SIBOSDK/src/complex.cpp new file mode 100644 index 0000000..053db05 --- /dev/null +++ b/code/SIBOSDK/src/complex.cpp @@ -0,0 +1,239 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* COMPLEX.C - complex number class implementation. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include + +#pragma module(init_prio=>22) + +double norm(const complex& c) { + + double r, i; + + r=real(c); + i=imag(c); + return r*r + i*i; +} + +double arg(const complex& c) { + + return atan2(imag(c), real(c)); +} + +complex operator*(const complex& c1, const complex& c2) { + + double ires, rres; + double r1, r2, i1, i2; + + r1=real(c1); + i1=imag(c1); + r2=real(c2); + i2=imag(c2); + rres = r1*r2 - i1*i2; + ires = r1*i2 + r2*i1; + return complex(rres, ires); +} + +complex operator/(const complex& c1, const complex& c2) { + + double ires, rres; + double r1, r2, i1, i2; + + r1=real(c1); + i1=imag(c1); + r2=real(c2); + i2=imag(c2); + + rres=(i1*i2+r1*r2)/(r2*r2+i2*i2); + ires=(r2*i1-r1*i2)/(r2*r2+i2*i2); + + return complex(rres, ires); +} + +const complex& complex::operator*=(const complex& c2) { + + double ires, rres; + double r2, i2; + + r2=real(c2); + i2=imag(c2); + rres = re*r2 - im*i2; + ires = re*i2 + r2*im; + re=rres; + im=ires; + return *this; +} + +const complex& complex::operator/=(const complex& c2) { + + double ires, rres; + double r2, i2; + + r2=real(c2); + i2=imag(c2); + + ires=(im*r2 - i2*re)/(i2*i2 + r2*r2); + rres=(im-r2*ires)/i2; + re=rres; + im=ires; + return *this; +} + + +double abs(const complex& c) { + + double i, r; + + i=imag(c); + r=real(c); + return sqrt(r*r + i*i); +} + +complex acos(const complex& c) { + + complex r; + + r=sqrt(1 - c*c); + r=complex(-imag(r), real(r) ); + r=log(c + r); + return complex(imag(r), -real(r)); +} + +complex asin(const complex& c) { + + complex r; + + r=sqrt(1 - c*c); + r=log(complex(-imag(r), real(r)) + r); + return complex(imag(r), -real(r)); +} + +complex atan(const complex& c) { + + complex r, t; + + t=complex(-imag(c), real(c)); + r=log((1.0+t)/(1.0-t))/2.0; + return complex(imag(r), -real(r)); +} + +complex cos(const complex& c) { + + complex t; + + t=complex(-imag(c), real(c)); + return (exp(t) + exp(-t))/2.0; +} + + +complex cosh(const complex& c) { + + return (exp(c) + exp(-c))/2.0; +} + +complex exp(const complex& c) { + + double ex; + + ex=exp(real(c)); + return complex(ex*cos(imag(c)), ex*sin(imag(c))); +} + +complex log(const complex& c) { + + complex t; + + t=arg(c); + t=complex(-imag(t), real(t)); + return log(abs(c)) + t; +} + +complex log10(const complex& c) { + + complex t; + + t=arg(c); + t=complex(-imag(t), real(t)); + return (log(abs(c)) + t)/log(10.0); +} + +complex pow(const complex& base, double expo) { + + return exp(expo*log(base)); +} + +complex pow(double base, const complex& expo) { + + return exp(expo*log(base)); +} + +complex pow(const complex& base, const complex& expo) { + + return exp(expo*log(base)); +} + +complex sin(const complex& c) { + + complex t; + complex twoi(0.0, 2.0); + + t=complex(-imag(c), real(c)); + return complex((exp(t) - exp(-t))/twoi); +} + +complex sinh(const complex& c) { + + return (exp(c) - exp(-c))/2.0; +} + +complex sqrt(const complex& c) { + + complex t; + + t=sin(arg(c)/2.0); + t=complex(-imag(t), real(t)); + return sqrt(abs(c))*(cos(arg(c)/2.0) + t); +} + + +complex tan(const complex& c) { + + return sin(c)/cos(c); +} + +complex tanh(const complex& c) { + + return sinh(c)/cosh(c); +} + +ostream& operator<<(ostream& st, const complex& c) { + + st<< '(' << real(c) << ',' << imag(c) << ')'; + return st; +} + +istream& operator>>(istream& st, complex& c) { + + double r=0.0, i=0.0; + + if(st.peek() == '(') + st.get(); + st >> r; + if(st.peek() == ',') + st.get(); + st >> i; + if(st.peek() == ')') + st.get(); + c=complex(r, i); + return st; +} + + + \ No newline at end of file diff --git a/code/SIBOSDK/src/coniostr.cpp b/code/SIBOSDK/src/coniostr.cpp new file mode 100644 index 0000000..37ab641 --- /dev/null +++ b/code/SIBOSDK/src/coniostr.cpp @@ -0,0 +1,104 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* CONIOSTR.CPP - console I/O stream class implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_CONIO +#include +#include + + +#pragma module(init_prio=>22) + +extern "C" void _init_con(void) { + + conout.setf(ios::unitbuf); +} + +static conbuf inbuf; +static conbuf outbuf; + +istream conin(&inbuf); +ostream conout(&outbuf); + +int conbuf::underflow() { + + #define CGETS_MAX_NR 255 /* new line */ + + int nr, c; + char *buf; + + nr=ebuf()-eback(); + if(nr == 1) { + c=getche(); + if(c == EOF) { + return EOF; + } + *eback()=c; + } + else { + if (nr > CGETS_MAX_NR) /* new line */ + nr = CGETS_MAX_NR; /* new line */ + + buf=new char[nr+3]; + buf[0]=nr; + cgets(buf); + nr=buf[1]; + memcpy(eback(), buf+2, nr); /* corrected line */ + + delete buf; + } + setg(eback(), eback(), eback()+nr); + return *gptr(); + + #undef CGETS_MAX_NR /* new line */ + +} + +int conbuf::pbackfail(int c) { + + return ungetch(c); +} + +extern "C" unsigned _flush_init_magic; + +int conbuf::overflow(int c) { + + char *pt; + int nw; + + flush_magic=_flush_init_magic; + if(unbuffered()) { + if((c == EOF) || (putch(c) == EOF)) { + return EOF; + } + } + else { + pt=pbase(); + nw=pptr()-pt; + while(nw--) { + if(putch(*pt) == EOF) { + return EOF; + } + ++pt; + } + } + setp(pbase(), epptr()); + if((c != EOF) && (!unbuffered())) + sputc(c); + return c; +} + +int conbuf::sync() { + + overflow(); + setp(base(), ebuf()); + setg(base(), ebuf(), ebuf()); + return 0; +} + diff --git a/code/SIBOSDK/src/corefile.a b/code/SIBOSDK/src/corefile.a new file mode 100644 index 0000000..adf9b09 --- /dev/null +++ b/code/SIBOSDK/src/corefile.a @@ -0,0 +1,47 @@ +(* Release 3.00 *) + +(* c_files.a - file control memory *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Modified by NSM.*) + +include "corelib.inc" + +OPEN_MAX = 20 + +module files + +section +segment _DATA(DATA, 28H) + +select _DATA + +public __open_max: dw OPEN_MAX + +section +segment _BSS(BSS, 28H) + +public __iob: org OPEN_MAX * _iobSize + +public __openfd: org OPEN_MAX*2 + +public __openmp: org OPEN_MAX*2 + +public __openfl: org OPEN_MAX*2 + +section +segment _BSS(BSS, 28H) + +select _BSS +public __tmpfiles: org OPEN_MAX * DataPtrSize + + section +segment _BSS(BSS, 28H) + +select _BSS +public __tmpfptrs: org OPEN_MAX * DataPtrSize + +end diff --git a/code/SIBOSDK/src/coreinit.a b/code/SIBOSDK/src/coreinit.a new file mode 100644 index 0000000..159eb38 --- /dev/null +++ b/code/SIBOSDK/src/coreinit.a @@ -0,0 +1,257 @@ +(* Release 3.00 *) + +(* c_coreinit - common initialisation between PLIB and CLIB *) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Written by NSM.*) + +include "corelib.inc" +include "epocdefs.inc" + +module coreinit + +(***************************************************************************) +section +segment _MAGIC(MAGIC,68H) +segment _DATA(DATA,68H) +segment _CONST(DATA,48H) +segment _BSS(BSS,68H) +segment BSS_END(BSS,68H) + +group DGROUP(_MAGIC,_DATA,_CONST,_BSS,BSS_END) + +select _DATA + +public _winHandle : dw 0 +public __conName : db 'CON:*',0 + +(***************************************************************************) +section +segment _DATA(DATA,68H) +public __DefScreenRect : dw -1,0,0,0 + +(***************************************************************************) +section +segment _DATA(DATA,68H) +public __DefScreenMode : dw 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public __FatalErrorPos : + + push bx + mov bx, sp + mov ax, ss:[bx][2] + pop bx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public __FatalError : + + mov al, 80 + int ProcPanic + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn _winHandle +extrn _DatCommandPtr +extrn __DefScreenRect +extrn __DefScreenMode +extrn __conName + +select _TEXT + +extrn __FatalErrorPos +extrn __FatalError + +xMode = -2 +xParse = xMode-FullParseEnt +xBuf = xParse-MaxPathSize + +public _p_xwind : + push bp + mov bp, sp + add sp, xBuf + push ax + push bx + push cx + push dx + push di + push si +; + mov bx, [_DatCommandPtr] + test bx, bx + je noCommandLine + sub cx, cx + lea di, [bp][xBuf] + lea si, [bp][xParse] + sub al, al + mov ah, NmFilParse + int FilManager + jc noCommandLine + lea di, [bp][xBuf] + mov si, __conName + int StringCopy + add di, 5 + lea si, [bp][xBuf][FileSystemNameSize] + mov ax, [bp][xParse][FullParseDevice] + add al, ah + sub ah, ah + add si, ax + mov cl, [bp][xParse][FullParseName] + sub ch, ch + cld + rep ; movsb + sub al, al + stosb + jmp openCon +noCommandLine: + lea di, [bp][xBuf] + mov si, __conName + int StringCopy + mov byte [di][4], 0 +openCon: + lea bx, [bp][xBuf] + mov cx, -1 + mov ah, NmIoOpen + int DevManager + jnc openOk +; + call __FatalErrorPos + mov bx, FatalOpenConsole + jmp __FatalError +; +openOk: mov [_winHandle], ax +; + mov si, ds:[Datawserv_channel] + or si, si + jz old_window_server + mov al, [si][wserv_spec_info_version] + and al, 0FH + cmp al, 2 (* WS_VERSION_4 *) + jb old_window_server +; + sub sp, 32 (* SIZE W_SUPPORT_INFO *) + mov si, sp + mov ax, 0FF06H (* WOR_X_SUPPROT_INFO *) + int WservOpcodes + mov ax, [__DefScreenMode] + mov bx, [si] + add sp, 32 (* SIZE W_SUPPORT_INFO *) +; + test bx, 2 (* W_SUPPORT_CTBY_S3 *) + jz no_ctby_mode + test ax, 1 (* Use compatibility mode if set *) + jnz no_ctby_mode + push ax + push bx + mov word [bp][xMode], 20 (* P_SCR_COMPATIBILITY *) + lea cx, [bp][xMode] + xor ax, ax (* No compatibilty mode *) + push ax + mov dx, sp + mov bx, [_winHandle] + mov al, IoFuncSet + mov ah, NmIoWithWait + int IoManager + pop ax + pop bx + pop ax +; +no_ctby_mode: + test bx, 1 (* W_SUPPORT_CTBY_GREY *) + jz no_grey + test ax, 2 (* Use grey if set *) + jz no_grey +; + mov word [bp][xMode], 21 (* P_SCR_GREY *) + lea cx, [bp][xMode] + mov ax, TRUE + push ax + mov dx, sp + mov bx, [_winHandle] + mov al, IoFuncSet + mov ah, NmIoWithWait + int IoManager + pop ax +no_grey: +; +old_window_server: + mov di, __DefScreenRect + cmp word [di][RectTl][PointX], -1 + jne rectGood + sub ax, ax + mov [di][RectTl][PointX], ax + mov [di][RectTl][PointY], ax + mov ah, NmGenLcdType + int GenManager + mov bx, 60 + mov cx, 15 + cmp al, Lcd240X80 + jne try160X80 + mov bx, 40 + mov cx, 9 + jmp setBr +try160X80: + cmp al, Lcd160X80 + jne setBr + mov bx, 26 + mov cx, 9 +setBr: + mov [di][RectBr][PointX], bx + mov [di][RectBr][PointY], cx +rectGood: + mov word [bp][xMode], 5 (* P_SCR_WSET *) + lea cx, [bp][xMode] + mov dx, di + mov bx, [_winHandle] + mov al, IoFuncSet + mov ah, NmIoWithWait + int IoManager +; + mov word [bp][xMode], 3 (* P_SCR_POSA *) + lea cx, [bp][xMode] + xor ax, ax + push ax + push ax + mov dx, sp + mov al, IoFuncSet + mov ah, NmIoWithWait + int IoManager +; + lea di, [bp][xParse] + mov word [di], 1 + mov dx, di + mov word [bp][xMode], 9 (* P_SCR_CURSOR *) + mov al, IoFuncSet + mov ah, NmIoWithWait + int IoManager +; + pop si + pop di + pop dx + pop cx + pop bx + pop ax + mov sp, bp + pop bp + ret 0 +; + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _ClassTable : +public _ExtCatTable : + dw 0 + +end diff --git a/code/SIBOSDK/src/coreio.a b/code/SIBOSDK/src/coreio.a new file mode 100644 index 0000000..24607d9 --- /dev/null +++ b/code/SIBOSDK/src/coreio.a @@ -0,0 +1,1749 @@ +(* Release 3.00 *) + +(* c_coreio - low level IO stuff *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Written by NSM.*) + +include "corelib.inc" +include "epocdefs.inc" + +module coreio + +(***************************************************************************) +segment _DATA(DATA, 28H) + +public __fmode : dw O_TEXT (* default transaltion mode *) + +segment _BSS(BSS, 28H) + +public __fmask : org 2 (* default file permission mask *) + +segment _DATA(DATA, 28H) + +public __ungotchar : dw -1 (* temporary storage for console I/O *) + +segment _DATA(DATA, 28H) + +public __upperHex : db 'A' (* 'a' or 'A', chooses digit case *) + +segment _BSS(BSS, 28H) + +public __i_putch : org CodePtrSize +public __i_cgets : org CodePtrSize + +segment _BSS(BSS,28H) + +public __p_init : org 2 + +segment _BSS(BSS,28H) + +public __con_key : org ConEnt + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __p_init +extrn __i_putch +extrn __i_cgets +extrn __d_putch +extrn __d_cgets +extrn _winHandle + +select _TEXT + +extrn _p_xwind + +public _putch : + + cmp byte [__p_init], 0 + jne putchInitDone + mov word [__i_putch], __d_putch + mov word [__i_cgets], __d_cgets + not byte [__p_init] + cmp word [_winHandle], 0 + jne putchInitDone + call _p_xwind +putchInitDone: + jmp word [__i_putch] + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn _winHandle + +select _TEXT + +public __d_putch : +(* +int putch(int c) +*) + + push bx + push cx + push dx + mov dx, 1 + mov cx, ax + cmp ax, 0AH + jne notNewLine + mov ax, 0A0DH + inc dx +notNewLine: + push cx + push ax + mov cx, sp + mov bx, [_winHandle] + mov ah, NmIoWrite + int IoManager + pop ax + pop ax + jnc putchExit + mov ax, -1 +putchExit: + pop dx + pop cx + pop bx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __ungotchar +extrn _winHandle +extrn __con_key + +select _TEXT + +public _getch : +(* +int getch(void) +Checks for any character returned by ungetch then calls DOS. +*) + + mov ax, [__ungotchar] + cmp ax, -1 + jne charWaiting + push bx + push cx + push dx + mov cx, __con_key + mov dx, 1 + mov bx, [_winHandle] + mov ah, NmIoRead + int IoManager + pop dx + pop cx + pop bx + jc getchFailed + mov ax, [__con_key][ConKeyValue] + jmp charWaiting + +getchFailed: + sub ax, ax + +charWaiting: + mov word [__ungotchar], -1 + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn _putch +extrn _getch + +select _TEXT + +public _getche : +(* +int getche(void) +Checks for any charcater returned by ungetch then calls DOS. +*) + + call _getch + test ah, ah + jne badForPutch + jmp near _putch +badForPutch: + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _DATA + +extrn __ungotchar +extrn _winHandle + +select _TEXT + +public _kbhit : +(* +int kbhit(void) +Checks for any charcater waiting in keyboard buffer. +*) + + mov ax, [__ungotchar] + cmp ax, -1 + jne keyWaiting + push bx + push cx + push ax + mov cx, sp + mov bx, [_winHandle] + mov al, IoFuncTest + mov ah, NmIoWithWait + int IoManager + pop ax + pop cx + pop bx + jnc keyWaiting + sub ax, ax + +keyWaiting: + ret 0 + + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _INIT(DATA,28H) +segment _BSS(BSS,28H) + +extrn __exit1 +extrn __exit1_vector + +select _BSS + +Buf0 : org BUFSIZ +Buf1 : org BUFSIZ + +select _DATA + +extrn __iob +extrn __openfd +extrn __openmp +extrn __openfl +extrn _winHandle +extrn __exit_io +extrn __argin +extrn __argout +extrn __argapp +extrn __open +extrn __creat + +HandleData : dw 4000H, 4002H, 6002H +StreamData : dw 405H, 0C06H, 602H +StreamBuffers : dw Buf0, Buf1, 0 + +public __iosetup : dw 0 + +select _TEXT + +extrn __InitLoop + +do_initio : (* defined later on ! *) + +select _INIT + +initio : dw MAGIC + db PR2 + dw do_initio + +select _DATA + +public __doserrno : dw 0, initio + +select _TEXT + +extrn _p_xwind +extrn __FatalErrorPos +extrn __FatalError + +public __initio : + (* check for character devices on default paths *) + push di + push si + mov word [__exit_io], __exit1 + cmp word [__iosetup], 0 + je doInitIo + jmp near ioDone +doInitIo: + not word [__iosetup] + call _p_xwind + sub bx, bx + mov cx, bx + mov si, bx + mov di, __iob +ioLoop: + mov [di][bx][_file], cx + mov ax, [si][StreamBuffers] + or ax, ax + jz noBuf + mov word [di][bx][_size], BUFSIZ + mov [di][bx][_base], ax + mov [di][bx][_ptr], ax +noBuf: + mov ax, [si][StreamData] + mov dx, [si][HandleData] + jcxz doStdin + cmp cl, 1 + jne doStdErr +doStdout: + cmp word [__argout], 0 + je doDefault + push ax + push bx + mov ax, [__argout] + cmp word [__argapp], 0 + jne doAppend +doCreat: + mov bx, FA_TEXT + call __creat + cmp ax, 1 + pop bx + pop ax + je doRestOfFlags + jmp initioFailed +doStdin: + cmp word [__argin], 0 + je doDefault + push ax + push bx + mov ax, [__argin] + mov bx, O_TEXT | SH_DENYWR + call __open + test ax, ax + pop bx + pop ax + je doRestOfFlags + jmp initioFailed +doDefault: + or dh, 20H + or ah, 2H +doStdErr: + push ax + mov ax, [_winHandle] + mov [si][__openmp], ax + pop ax + mov word [si][__openfl], E_CONS | E_DEVICE +doRestOfFlags: + mov [di][bx][_flag], ax + mov [si][__openfd], dx +setDevice: + add bx, _iobSize + add si, 2 + inc cx + cmp cx, 3 + je ioDone + jmp ioLoop + +ioDone: + pop si + pop di + jmp __InitLoop + +doAppend: + mov bx, O_TEXT | O_RDWR + call __open + cmp ax, 1 + mov ax, [__argout] + jne doCreat + pop bx + pop ax + or ax, _F_APP + or dx, O_APPEND + jmp doRestOfFlags + +initioFailed: + call __FatalErrorPos + mov bx, FatalInitIo + jmp __FatalError + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __seterrno +extrn __open_max +extrn __openmp + +select _TEXT + +public __getHandle : + + mov cx, [__open_max] + mov di, __openmp + sub ax, ax + cld + repne; scasw + jne noHandlesLeft + sub di, __openmp+2 + ret 0 +noHandlesLeft: + mov ax, EMFILE + call __seterrno + mov ax, -1 + stc + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __seterrno +extrn __open_max +extrn __openmp +extrn __openfl + +select _TEXT +extrn __FatalErrorPos +extrn __FatalError + +public __checkHandle : + mov bx, ax + cmp ax, [__open_max] + jae invalidHandle + sub ax, ax + call __seterrno + shl bx, 1 + mov ax, [__openfl][bx] + mov bx, [__openmp][bx] + test bx, bx + je invalidHandle + test ax, E_DEVICE + je notAConsol + cmp bx, 1 + jne notAConsol + call __FatalErrorPos + mov bx, FatalConIo + jmp __FatalError +notAConsol: + clc + ret 0 + +invalidHandle: + mov ax, EBADF + call __seterrno + mov ax, -1 + stc + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __checkHandle + +select _TEXT + +public _getRealHandle : +(* +void *getRealHandle(int handle) +Get the plib handle from the clib handle. +*) + + push bx + call __checkHandle + mov ax, 0 + jc getRealExit + mov ax, bx +getRealExit: + pop bx + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __ioerr +extrn __getHandle +extrn __openfl +extrn __openmp + +select _TEXT + +public __creat : +public __creat_trunc : +(* +int _creat_trunc(char *path, int permission) +Creates file or truncates existing one. +*) + + push cx + mov cx, ModeReplace + +doCreate: + push bx + push dx + push di + mov dx, bx + mov bx, ax + push cx + call __getHandle + pop cx + jc creatExit + or cx, ModeUpdate | ModeRandom + mov [__openfl][di], dx + test dx, FA_TEXT + je creatBinary + or cx, ModeStreamText +creatBinary: + mov ah, NmIoOpen + int DevManager + jc creatFailed + mov [__openmp][di], ax + mov ax, di + shr ax, 1 +creatExit: + pop di + pop dx + pop bx + pop cx + ret 0 + +creatFailed: + call __ioerr + mov ax, -1 + jmp creatExit + +public __creat_new : +public _creatnew : +(* +int _creat_new(char *path, int permission) +Creates new file. +*) + push cx + mov cx, ModeCreate + jmp doCreate + +public __creat_temp : +(* +int _creat_temp(char *path, int permission) +Creates new unique file. +*) + + push cx + mov cx, ModeUnique + jmp doCreate + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __creat_temp +extrn _strcpy +extrn _strlen + +public _creattemp : + + push bp + mov bp, sp + sub sp, 80H + push bx + push cx + push ax + push bx + mov bx, ax + lea ax, [bp][-80H] + call _strcpy + lea ax, [bp][-80H] + call _strlen + cmp ax, 3 + je skipCheck + lea bx, [bp][-80H] + add bx, ax + cmp byte [bx], '\' + je skipCheck + mov word [bx], '\' +skipCheck: + lea ax, [bp][-80H] + pop bx + call __creat_temp + mov cx, ax + pop ax + lea bx, [bp][-80H] + add bx, 5 + call _strcpy + mov ax, cx + pop cx + pop bx + mov sp, bp + pop bp + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public __exists : + + push bx + push cx + sub sp, FileEnt + mov cx, sp + mov bx, ax + sub al, al + mov ah, NmFilStatusGet + int FilManager + mov ax, 0 + jc existsExit + inc ax +existsExit: + add sp, FileEnt + pop cx + pop bx + ret 0 + +(****************************************************************************) +section +segment _DATA(DATA, 28H) +segment _TEXT(CODE,28H) + +extrn __ioerr +extrn __getHandle +extrn __openmp +extrn __openfl + +select _TEXT + +public __open : +(* +int _open(char *path, int access) +opens file and returns handle. +*) + + push bx + push cx + push dx + push di + mov dx, bx + mov bx, ax + call __getHandle + jc openExit + mov cx, ModeOpen | ModeRandom + mov word [__openfl][di], 0 + test dx, O_TEXT + je openBinary + or cx, ModeStreamText +openBinary: + test dx, O_RDWR + je openReadonly + or cx, ModeUpdate +openReadonly: + and dl, 0F0H + cmp dl, SH_DENYWR + je allowShare + cmp dl, SH_DENYNO + jne noShare +allowShare: + or cx, ModeShare +noShare: + mov ah, NmIoOpen + int DevManager + jc openFailed + mov [__openmp][di], ax + mov ax, di + shr ax, 1 +openExit: + pop di + pop dx + pop cx + pop bx + ret 0 +openFailed: + call __ioerr + mov ax, -1 + jmp openExit + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __openmp +extrn __openfl + +extrn __ioerr +extrn __checkHandle +extrn __getHandle + +select _TEXT + +public __dup : +(* +int _dup(int handle) +returns the next free file handle. +*) + + push bx + push cx + push dx + push di + mov dx, ax + call __checkHandle + jc dupFailed + call __getHandle + jc dupFailed + mov bx, dx + shl bx, 1 + mov ax, [__openmp][bx] + mov [__openmp][di], ax + mov ax, [__openfl][bx] + mov [__openfl][di], ax + mov ax, di + shr ax, 1 +dupFailed: + pop di + pop dx + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __open_max +extrn __openmp +extrn __openfl + +select _TEXT + +extrn __ioerr +extrn __checkHandle +extrn __close + +public __dup2 : +(* +int _dup2(int oldhandle, int newhandle ) +close newhandle if open and duplicates oldhandle. +*) + + push bx + push cx + push dx + push di + mov cx, ax + mov dx, bx + call __checkHandle + jc dup2Failed + cmp dx, [__open_max] + jae dup2Failed + mov di, dx + shl di, 1 + cmp word [__openmp][di], 0 + je available + mov ax, dx + call __close +available: + mov bx, cx + shl bx, 1 + mov ax, [__openmp][bx] + mov [__openmp][di], ax + mov ax, [__openfl][bx] + mov [__openfl][di], ax + sub ax, ax +dup2Failed: + pop di + pop dx + pop cx + pop bx + ret 0 + +(*************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +_1bs : db 08H,20H,08H +_2bs : db 08H,08H,20H,20H,08H,08H + +extrn __ioerr +extrn __open_max +extrn __openfl +extrn __openmp +extrn _winHandle +extrn __checkHandle +extrn _getch +extrn _putch + +select _TEXT + +public __read : +(* +int _read(int handle, void *buffer, int num) +reads num bytes from file handle int buffer. +Returns number of bytes read or -1 for error. +*) + + push bx + push cx + push dx + push di + push si + mov di, cx + mov si, cx + jcxz readComplete + mov cx, bx + call __checkHandle + jc readExit + test ax, E_CONS + jne readConsole +readLoop: + mov dx, di + cmp dx, FileMaxStreamSize + jbe inRange + mov dx, FileMaxStreamSize +inRange: + push dx + mov ah, NmIoRead + int IoManager + pop dx + jc readError + cmp ax, dx + jne readShort + add cx, dx + sub di, dx + jne readLoop +readComplete: + mov ax, si + sub ax, di +readExit: + pop si + pop di + pop dx + pop cx + pop bx + ret 0 + +readError: + mov di, si + cmp al, EofErr + je readComplete + call __ioerr + mov ax, -1 + jmp readExit + +readShort: + sub di, ax + jmp readComplete + +readConsole: + cld + xchg cx, di +readCLoop: + call _getch + test ah, ah + jne readCLoop + cmp al, 0DH + jne tryBS + mov al, 0AH + call _putch + +saveAndComplete: + mov ax, 0A0DH + stosw + dec cx + dec cx + jmp readCComplete + +tryBS: + cmp al, 08H + jne gotChar + cmp cx, si + je readCLoop + dec di + inc cx + push bx + push cx + push dx + mov bx, [_winHandle] + mov cx, _1bs + mov dx, 3 + cmp byte [di], ' ' + jae notControl + mov cx, _2bs + mov dl, 6 +notControl: + mov ah, NmIoWrite + int IoManager + pop dx + pop cx + pop bx + jmp readCLoop + +gotChar: + cmp al, ' ' + jae outNotControl + push ax + mov al, '^' + call _putch + pop ax + push ax + add al, '@' + call _putch + pop ax + jmp saveAndContinue +outNotControl: + call _putch +saveAndContinue: + stosb + loop readCLoop + +readCComplete: + xchg cx, di + jmp readComplete + + +(*************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn _errno +extrn __openfd + +select _TEXT + +extrn __read +extrn __ioerr +extrn _lseek +extrn __write + +public _write : + +temp = -2 +appbuf = -4 +writesize = -6 +flag = -7 +reset = -8 +handle = -10 +buffer = -12 +num = -14 + +locals = 14 + +WRITE_BUF_SIZE = 400H + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov [bp][handle], ax + mov [bp][buffer], bx + mov [bp][num], cx + + mov byte [bp][reset], 0 + mov bx, [bp][handle] + shl bx, 1 + mov cx, [__openfd][bx] + jcxz near writeInvalid + test cx, O_RDWR+O_WRONLY (* test for correct access mode *) + je near writeAccess + cmp word [bp][num], 0 + je near writeEOF (* don't write zero bytes *) + test cx, O_APPEND + je dontAppend + mov di, cx (* append to EOF if flag set *) + sub ax, ax + mov dx, SEEK_END + test cx, O_TEXT + jz appNotText + dec ax + mov cx, ax + mov bx, ax + mov ax, [bp][handle] + call _lseek + cmp dx, -1 + je nextSeek + cmp ax, -1 + je nextSeek + mov ax, [bp][handle] + mov cx, 1 + lea bx, [bp][appbuf] + call __read + cmp word [_errno], 0 + jne near writeError + mov ax, -1 + mov dx, SEEK_END + cmp byte [bp][appbuf], CTLZ + je ctlzPresent + inc ax +ctlzPresent: + jmp appNotText +nextSeek: + mov dx, SEEK_END + sub ax, ax +appNotText: + mov cx, ax + mov bx, ax + mov ax, [bp][handle] + call _lseek +appendDone: + mov cx, di +dontAppend: + test cx, O_TEXT + je near writeBinary +writeText: (* test mode *) + test cx, _O_EOF (* error if EOF flag set *) + jne near writeEOF + mov cx, WRITE_BUF_SIZE + 2 + mov ah, NmHeapAllocateCell + int HeapManager + jc near writeNomem + inc ax + mov [bp][temp], ax + not byte [bp][reset] + shr cx, 1 (* write size is half that of buffer *) + dec cx + mov [bp][writesize], cx + mov si, [bp][buffer] +writeMainLoop: (* main loop - translate and *) + mov cx, [bp][num] (* write a block *) + jcxz allWritten + cmp cx, [bp][writesize] (* exit when all written *) + jb cxRight + mov cx, [bp][writesize] +cxRight: + sub [bp][num], cx + mov di, [bp][temp] + mov ah, 0AH + mov [di][-1], ah (* Dummy at buffer-1 *) + mov bh, CTLZ + mov bl, 0DH + (* this next loop is the time *) +writeTransLoop: (* one where transaltion takes place *) + lodsb + cmp al, ah + je doTrans (* no jump for no translate *) +doneTrans: + stosb + cmp al, bh + je writeCtlz (* ctl Z - terminate output *) + dec cx + jcxz writeBlock (* repeat loop body *) + lodsb + cmp al, ah + je doTrans + stosb + cmp al, bh + je writeCtlz + loop writeTransLoop + jmp writeBlock +doTrans: + cmp [di][-1], bl (* CR inserted here *) + je doneTrans + mov [di], bl + inc di + jmp doneTrans + +writeCtlz: + mov byte [bp][flag], 1 + jmp writeWrite +writeBlock: + mov byte [bp][flag], 0 (* write transalted block *) +writeWrite: + push cx + mov ax, [bp][handle] + mov bx, [bp][temp] + sub di, bx + mov cx, di + call __write + pop cx + cmp word [_errno], 0 + jne writeError (* write error *) +writeOK: + cmp byte [bp][flag], 0 + je writeMainLoop (* go back for another block *) +allWritten: + mov bx, [bp][handle] + shl bx, 1 + cmp byte [bp][flag], 0 + je dontSet + test word [__openfd][bx], O_DEVICE (* if !device and ctl Z set EOF flag *) + jne dontSet + or word [__openfd][bx], _O_EOF +dontSet: + sub si, [bp][buffer] + jmp writeDone +writeBinary: (* binary output done here *) + mov ax, [bp][handle] + mov cx, [bp][num] + mov bx, [bp][buffer] + call __write + cmp word [_errno], 0 + jne writeError + mov si, ax + mov bx, [bp][handle] + shl bx, 1 +writeDone: + or word [__openfd][bx], O_CHANGED (* set file changed flag *) +writeEnd: + cmp byte [bp][reset], 0 + je writeNoCell + mov bx, [bp][temp] + dec bx + mov ah, NmHeapFreeCell + int HeapManager +writeNoCell: + mov ax, si (* return *) + pop si + pop di + pop dx + mov sp, bp + pop bp + ret 0 + +writeError: (* error return *) + mov si, -1 + mov bx, ax + jmp writeSetErr +writeEOF: (* EOF return *) + sub si, si + jmp writeEnd +writeAccess: (* invalid access mode *) + mov si, -1 + mov bx, EACCESS + jmp writeSetErr +writeInvalid: (* bad file *) + mov si, -1 + mov bx, EBADF + jmp writeSetErr +writeNomem: (* no memory for buffer *) + mov bx, ENOMEM +writeSetErr: (* set errno *) + mov ax, bx + call __ioerr (* set errno *) + jmp writeEnd + +(*************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn _errno +extrn __openfd +extrn __open_max +extrn __read +extrn __ioerr + +select _TEXT + +public _read : + +handle = -2 +buffer = -4 +num = -6 +locals = 6 + + push bp + mov bp, sp + sub sp, locals + push dx + push di + push si + mov [bp][handle], ax + mov [bp][buffer], bx + mov [bp][num], cx + mov bx, [bp][handle] + shl bx, 1 + mov cx, [__openfd][bx] + jcxz near readInvalid + test cx, O_WRONLY + jne near readAccess (* access mode invalid *) + cmp word [bp][num], 0 (* read zero - do nothing *) + je near readEOF + test cx, O_TEXT + je near readBinary +readText: (* test mode *) + test cx, _O_EOF + jne near readEOF (* error - EOF flag set *) + mov cx, [bp][num] + mov bx, [bp][buffer] + mov di, bx + mov ax, [bp][handle] + call __read + cmp word [_errno], 0 + jne near readError +readOK: + mov cx, ax + jcxz readCtlz + cmp cx, 1 + je readOne +readOneContinue: + mov ah, 0DH + mov bh, CTLZ + mov si, [bp][buffer] +readTransLoop: (* translation loop *) + lodsb + cmp al, ah + je missCR (* skip LF *) + stosb + cmp al, bh + je readCtlz (* hit ctl Z - terminate input *) +missCR: + loop readTransLoop + jmp readDone +readCtlz: + mov bx, [bp][handle] + shl bx, 1 + test word [__openfd][bx], O_DEVICE (* if !device + ctl Z set EOF *) + jne dontSet + or word [__openfd][bx], _O_EOF + jcxz dontSet + dec di +dontSet: + jmp readDone +readBinary: (* binary read done here *) + mov ax, [bp][handle] + mov cx, [bp][num] + mov bx, [bp][buffer] + call __read + jmp readExit +readDone: + sub di, [bp][buffer] +readEnd: + mov ax, di +readExit: + pop si + pop di + pop dx + mov sp, bp + pop bp + ret 0 + +readError: (* return error *) + mov di, -1 + mov bx, ax + jmp readSetErr +readEOF: (* return EOF *) + sub di, di + jmp readEnd +readAccess: (* invbalid access mode *) + mov di, -1 + mov bx, EACCESS + jmp readSetErr +readInvalid: (* file not open *) + mov di, -1 + mov bx, EBADF +readSetErr: (* set errno *) + mov ax, bx + call __ioerr (* set errno *) + jmp readEnd + +readOne: + cmp word [bp][num], 1 + je readExit + jmp readOneContinue + +(*************************************************************************) +section +segment _DATA(DATA, 28H) +segment _TEXT(CODE,28H) + +extrn __ioerr +extrn __open_max +extrn __openfl +extrn __openmp +extrn __checkHandle + +select _TEXT + +public __write : +(* +int _write(int handle, void *buffer, int num) +writes num bytes to file handle from buffer. +Returns number of bytes written or -1 for error. Low level DOS function. +*) + + push bx + push cx + push dx + push di + push si + push bp + mov di, cx + mov si, cx + mov cx, bx + call __checkHandle + jc writeExit + mov bp, FileMaxStreamSize + test ax, E_DEVICE + je writeLoop + mov bp, 128 +writeLoop: + mov dx, di + cmp dx, bp + jbe inRange + mov dx, bp +inRange: + mov ah, NmIoWrite + int IoManager + jc writeError + add cx, dx + sub di, dx + jne writeLoop + mov ax, si +writeExit: + pop bp + pop si + pop di + pop dx + pop cx + pop bx + ret 0 + +writeError: + call __ioerr + mov ax, -1 + jmp writeExit + +(***************************************************************************) +section +segment _DATA(DATA, 28H) +segment _TEXT(CODE,28H) + +extrn __ioerr +extrn __openmp +extrn __openfl +extrn __open_max + +select _TEXT + +extrn __checkHandle +extrn __FsChanToName +extrn __chmod +extrn __seterrno + +public __close : +(* +int _close(int handle) +closes file and returns 0 if successful. Low level DOS function. +*) + + push bp + mov bp, sp + sub sp, 80H + push bx + push cx + push di + mov di, ax + + + mov bx, ax + cmp ax, [__open_max] + jae closeInvalidHandle + sub ax, ax + call __seterrno + shl bx, 1 + mov ax, [__openfl][bx] + mov bx, [__openmp][bx] + test bx, bx + je closeInvalidHandle + test ax, E_DEVICE + je closeNotAConsol + cmp bx, 1 + je doNoClose +closeNotAConsol: + call anyOtherHandles +doNoClose: + mov ax, 1 + je skipClose + push bx + mov ax, bx + lea bx, [bp][-80H] + call __FsChanToName + pop bx + mov ah, NmIoClose + int IoManager + jc closeFailed + sub ax, ax +skipClose: + mov word [di][__openmp], 0 + test ax, ax + jne closeExit + mov ax, [di][__openfl] + test ax, E_DEVICE + jne closeExit + and ax, FA_RDONLY | FA_HIDDEN | FA_SYSTEM + je closeExit + mov cx, ax + mov bx, 1 + lea ax, [bp][-80H] + call __chmod + sub ax, ax +closeExit: + pop di + pop cx + pop bx + mov sp, bp + pop bp + ret 0 + +closeInvalidHandle: + mov ax, EBADF + call __seterrno + mov ax, -1 + stc + jmp closeExit + +closeFailed: + call __ioerr + mov ax, -1 + jmp skipClose + +anyOtherHandles: + push cx + push si + shl di, 1 + mov cx, [__open_max] + sub si, si +anyLoop: + cmp si, di + je notThisOne + cmp [__openmp][si], bx + je gotOne +notThisOne: + inc si + inc si + loop anyLoop + inc cx +gotOne: + pop si + pop cx + ret 0 + +(****************************************************************************) +section +segment _DATA(DATA,28H) +segment _TEXT(CODE,28H) + +extrn __ioerr +extrn __openfl +extrn __checkHandle + +select _TEXT + +public __eof : +(* +int _eof(int handle) +returns file status - EOF 1, error -1, else 0. +*) + + push bx + push cx + push dx + push di + push si + mov di, ax + call __checkHandle + jc eofExit + sub ax, ax + shl dx, 1 + test word [di][__openfl], E_DEVICE + jne eofExit + push ax + push ax + mov di, sp + push ax + push ax + mov dx, sp + mov cx, SeekFromCurrent + mov ah, NmIoSeek + int IoManager + jc eofFailed + mov dx, di + mov cx, SeekFromEnd + mov ah, NmIoSeek + int IoManager + jc eofFailed + mov si, sp + sub dx, dx + mov ax, [si][2] + cmp [di][2], ax + jne notEof + mov ax, [si] + cmp [di], ax + jne notEof + inc dx +notEof: + mov [di], dx + mov dx, si + mov cx, SeekFromStart + mov ah, NmIoSeek + int IoManager + jc eofFailed + mov ax, [di] +eofExitPop: + add sp, 8 +eofExit: + pop si + pop di + pop dx + pop cx + pop bx + ret 0 + +eofFailed: + call __ioerr + mov ax, -1 + jmp eofExitPop + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __openfl + +select _TEXT + +extrn __checkHandle + +public _isatty : +(* +int isatty (int handle) +The return value is true (1) if handle is attached to a character device +such as the console or printer, or false (0) if handle is for an ordinary +file or is not valid. +*) + + push bx + push cx + push dx + push di + mov di, ax + call __checkHandle + jc isattyExit + sub ax, ax + shl di, 1 + test word [di][__openfl], E_DEVICE + je isattyExit + inc ax +isattyExit: + pop di + pop dx + pop cx + pop bx + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __ioerr +extrn __lseek +extrn __checkHandle + +public _lseek : +(* +long lseek(int handle, long offset, int where) +positions handles file pointer and returns new offset. +*) + + push bx + call __checkHandle + jc seekError + mov ax, bx + pop bx + jmp near __lseek +seekError: + cwd + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __ioerr + +select _TEXT + +extrn __checkHandle + +public _tell : +(* +long tell(int handle) +Returns offset of file pointer. +*) + + push bx + push cx + sub bx, bx + push bx + push bx + call __checkHandle + jc tellErr1 + mov cx, SeekFromCurrent + mov dx, sp + mov ah, NmIoSeek + int IoManager + jc tellErr + pop ax + pop dx +tellOk: + pop cx + pop bx + ret 0 +tellErr: + call __ioerr (* set errno *) + mov ax, -1 (* error return -1L *) +tellErr1: + cwd + add sp, 4 + jmp tellOk + +(*****************************************************************************) +section +segment _DATA(DATA, 28H) +segment _TEXT(CODE,28H) + +extrn __ioerr + +select _TEXT + +public _rmdir : +public _unlink : +(* +int unlink(char *filename) +Deletes file. Returns 0 if successful or -1 and sets errno. +*) + + push bx + mov bx, ax + sub al, al + mov ah, NmFilDelete + int FilManager + jnc unlinkOK + call __ioerr (* set errno *) + mov ax, -1 + jmp unlinkDone (* return -1 *) +unlinkOK: + sub ax, ax +unlinkDone: + pop bx + ret 0 + +(*****************************************************************************) +section +segment _DATA(DATA, 28H) +segment _TEXT(CODE,28H) + +extrn __ioerr + +select _TEXT + +public _rename : +(* +int rename(char *oldfile, char *newfile) +Renames file. Returns 0 if successful or -1 and sets errno. +*) + + push bx + push cx + mov cx, bx + mov bx, ax + sub al, al + mov ah, NmFilRename + int FilManager + jnc renameOK + call __ioerr (* set errno *) + mov ax, -1 + jmp renameDone (* return -1 *) +renameOK: + sub ax, ax +renameDone: + pop cx + pop bx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __doMakeAndChange + +public _mkdir : +(* +int mkdir(const char *path) +makes new sub-directory. +returns 0 if sucessful or -1 if not. +errno is set to ENOENT if the path was not found or EACCES if access denied. +*) + + push si + mov si, ax + mov ax, NmFilMakeDirectory * 100H + jmp near __doMakeAndChange + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __ioerr + +select _TEXT + +public _chdir : + +(* +int chdir(const char *path) +Changes current working directory. +returns 0 if sucessful or -1 if not (errno is set to ENOENT). +*) + + push si + mov si, ax + mov ax, NmFilPathSet * 100H +public __doMakeAndChange : + push di + push bx + sub sp, 80H + mov di, sp + push ax + int StringCopy + int StringLength + add di, ax + dec di + cmp byte [di], '\' + je skipCheck + mov word [di][1], '\' +skipCheck: + pop ax + mov bx, sp + int FilManager + jc chError + sub ax, ax + jmp chDone +chError: + call __ioerr (* set errno *) + mov ax, -1 (* return -1 *) +chDone: + add sp, 80H + pop bx + pop di + pop si + ret 0 + +end diff --git a/code/SIBOSDK/src/coremain.a b/code/SIBOSDK/src/coremain.a new file mode 100644 index 0000000..bc2e2fe --- /dev/null +++ b/code/SIBOSDK/src/coremain.a @@ -0,0 +1,673 @@ +(* Release 3.00 *) + +(* CoreMain - process startup and exit, args, environment. *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Written by NSM.*) + +include "corelib.inc" +include "epocdefs.inc" + +module CoreMain + +(****************************************************************************) +segment _MAGIC(DATA,28H) +segment _INIT(DATA,28H) +segment _CONST(DATA,28H) +segment _DATA(DATA,28H) +segment _BSS(BSS,28H) +segment _BSS_END(BSS,28H) + +group DGROUP(_MAGIC,_INIT,_CONST,_DATA,_BSS,_BSS_END) + +select _BSS + +public __argbuf : org 128 (* command line buffer *) +public __osmajor : org 2 +public __osminor : org 2 +public __exit_stk : org 32*CodePtrSize (* at/onexit function stack *) +public __exit_io : org CodePtrSize +public __exit_tmp : org CodePtrSize +public __exit_proc : org CodePtrSize +public __real_in : org CodePtrSize +public __real_out : org CodePtrSize +public __sigsetup : org 2 +public __exitbreak : org CodePtrSize +public __exitsig : org CodePtrSize +public @InitCount : org 2 +public @InitEnd : org 2 +public @InitDone : org 2 +public @ExitCode : org 2 +public @StackContextSP : org 2 +public @StackContextBP : org 2 + +select _DATA + +extrn __Term2 +extrn __init_start +extrn __bss_start + +public __exit_ptr : dw __exit_stk + (32*CodePtrSize) +public __exit_top : dw __exit_stk + (32*CodePtrSize) +public standard@haltChain : dw __Term2 +public @InitPointer : dw __init_start +public @InitPriority : db PRMAX +public __arg_init : db 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __exit + +select _DATA + +extrn __exit +extrn __exit_io +extrn __exit_tmp +extrn __exit_proc +extrn __init_start +extrn __const_start +extrn @RecursiveExit +extrn @InitPointer +extrn @InitCount +extrn @InitPriority +extrn @InitEnd +extrn @InitDone +extrn @ExitCode +extrn @StackContextSP +extrn @StackContextBP +extrn $Stage2 + +select _TEXT + +public _exit : + + mov [@ExitCode], ax + cmp byte [@RecursiveExit], 0 + je notAgain + call __exit +notAgain: + not byte [@RecursiveExit] + mov sp, [@StackContextSP] + mov bp, [@StackContextBP] + jmp near $TerminateProcess + +public __InitLoop : + + push di + push si + mov bx, [@InitPointer] + jmp traverseLoop +nextLoop: + add bx, InitSize +chainLoop: +traverseLoop: + cmp bx, [@InitEnd] + jae endOfArray + mov al, [@InitPriority] + cmp al, [bx][Priority] + jne nextLoop + lea ax, [bx][InitSize] + mov [@InitPointer], ax + dec word [@InitCount] + call [bx][ProcVar] + mov bx, [@InitPointer] + cmp word [@InitDone], 0 + je traverseLoop +initLoopRet: + pop si + pop di + ret 0 + +endOfArray: + cmp word [@InitCount], 0 + je stageComplete + +endOfList: + dec byte [@InitPriority] + js stageComplete + mov bx, __init_start + jmp chainLoop + +stageComplete: + inc word [@InitDone] + mov [@StackContextBP], bp + mov [@StackContextSP], sp + call $Stage2 + mov [@ExitCode], ax + +$TerminateProcess: + +public __Term2 : + extrn __exit_ptr + extrn __exit_top + extrn standard@haltChain + +(* reset halt chain to allow it to be re-used in termination code *) + + mov bx, here + xchg bx, [standard@haltChain] + call bx + +here: + mov bp, [@StackContextBP] + mov sp, [@StackContextSP] + mov si, [__exit_ptr] + mov di, [__exit_top] +exitLoop: + cmp si, di + je loopDone + call [si] + add si, 2 + jmp exitLoop +loopDone: + + jmp initLoopRet + +public __cleanup : + + mov cx, [__exit_io] + jcxz noCall1 + call cx +noCall1: + mov cx, [__exit_tmp] + jcxz noCall2 + call cx +noCall2: + mov cx, [__exit_proc] + jcxz noCall3 + call cx +noCall3: + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _BSS(BSS,28H) + +__env_buffer : org 256 + +select _TEXT + +public _getenv : + + push di + push si + mov si, __env_buffer + mov di, ax + mov ah, NmGenEnvStringGet + int GenManager + mov ax, si + jnc getenvExit + sub ax, ax +getenvExit: + pop si + pop di + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn _strlen +extrn _strcpy +extrn _strchr + +public _putenv : + + push bx + push di + push si + sub sp, (256+18) + cld + + mov bx, ax + call _strlen + mov di, ax + test ax, ax + je putenvFailed + cmp ax, (256+18) + jae putenvFailed + mov ax, sp + call _strcpy + mov bl, '=' + sub bh, bh + call _strchr + mov bx, ax + mov ah, NmGenEnvStringDelete + test bx, bx + je putenvDelete + mov si, bx + mov byte [si], 0 + inc si + cmp byte [si], 0 + je putenvDelete + mov ah, NmGenEnvStringSet +putenvDelete: + mov di, sp + int GenManager + jc putenvFailed + sub ax, ax +putenvExit: + add sp, (256+18) + pop si + pop di + pop bx + ret 0 + +putenvFailed: + mov ax, -1 + jmp putenvExit + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn @InitCount +extrn @InitEnd +extrn @InitDone +extrn __init_start +extrn __const_start + +select _TEXT + +public __InitSetup : + + mov ax, __const_start + sub ax, __init_start + mov bl, InitSize + div bl + sub ah, ah + mov [@InitCount], ax + mul bl + add ax, __init_start + mov [@InitEnd], ax + and word [@InitDone], 0 + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __argv +extrn __argc + +select _TEXT + +extrn _main + +public __init2 : + + mov ax, [__argc] + mov bx, __argv + jmp near _main + +(****************************************************************************) +section +segment _INIT(DATA,28H) +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _BSS(BSS, 28H) + +extrn __setargv +extrn __InitLoop + +select _TEXT + +do_initargc : (* defined later on ! *) + +select _INIT + +initargc : dw MAGIC + db PR1 + dw do_initargc + +select _BSS + +public __argv : org 32*DataPtrSize +public __argin : org DataPtrSize +public __argout : org DataPtrSize +public __argapp : org 2 + +select _DATA + +public __argc : dw initargc + +select _TEXT + + call __setargv + jmp __InitLoop + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn __exit + +select _DATA + +extrn __osmajor +extrn __osminor + +select _TEXT + +public __osversion : + +(* +void __osversion(void) +checks Epoc/Os version into __osver +*) + + mov ah, NmGenVersion + int GenManager + push ax + shr ax, 1 + shr ax, 1 + shr ax, 1 + shr ax, 1 + mov [__osmajor], ah + mov [__osminor], al + pop ax + and ah, 0FH + mov al, 0AH + mul ah + add [__osminor], ax + ret 0 + +(**************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _DATA + +extrn __argv +extrn __argbuf +extrn __argc +extrn __argin +extrn __argout +extrn __argapp +extrn __arg_init +extrn _DatCommandPtr + +select _TEXT + +extrn _strlen + +public __setargv : + + push di + push si + cld + cmp byte [__arg_init], 0 + jne initDone + not byte [__arg_init] + mov word [__argc], 0 + mov di, [_DatCommandPtr] + test di, di + je initDone + mov bx, __argv + call saveArg + mov ax, di + call _strlen + add di, ax + inc di + mov si, di + lodsb + cbw + add ax, si + mov dx, ax + mov di, __argbuf +convLoop: + cmp si, dx + jae initDone + lodsb + test al, al + je initDone + cmp al, ' ' + je convLoop + cmp al, '<' + je gotInRedir + cmp al, '>' + je gotOutRedir + cmp al, '"' + je gotString + dec si + mov al, ' ' +gotString: + mov cl, al + call saveArg +locateLoop: + cmp si, dx + jae gotLocate + lodsb + test al, al + je gotLocate + cmp al, cl + je gotLocate + stosb + jmp locateLoop +gotLocate: + sub al, al + stosb + jmp convLoop +initDone: + pop si + pop di + ret 0 +gotInRedir: + push bx + mov bx, __argin + jmp goLocate +gotOutRedir: + cmp byte [si], '>' + jne notAppend + lodsb + mov word [__argapp], ModeAppend +notAppend: + push bx + mov bx, __argout +goLocate: + cmp si, dx + jae noFileName + lodsb + test al, al + je noFileName + cmp al, ' ' + je goLocate + dec si + mov [bx], di + mov cl, ' ' + pop bx + jmp locateLoop +noFileName: + pop bx + jmp initDone + +saveArg: + cmp word [__argc], 32 + jae noRoomForMore + mov [bx], di + inc bx + inc bx + inc word [__argc] +noRoomForMore: + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +select _DATA + +extrn __sigsetup +extrn __exitbreak +extrn __exitsig + +select _TEXT + +extrn __FloatFinish + +public __exit : + +(* +void __exit(int code) +terminates process. +*) + + mov di, ax + mov cx, [__exitbreak] + jcxz noBreak + call cx +noBreak: + mov cx, [__exitsig] + jcxz noSig + call cx +noSig: + + call __FloatFinish + + mov ah, NmProcId + int ProcManager + mov bx, ax + mov ax, di + mov ah, NmProcKill + int ProcManager + +(****************************************************************************) +section +segment _DATA(DATA, 28H) +segment _TEXT(CODE,28H) + +extrn __exit_proc +extrn __exitbreak +extrn __exitsig +extrn __FloatFinish + +public __term_process : + + mov cx, [__exit_proc] + jcxz noCall4 + call cx +noCall4: + mov cx, [__exitbreak] + jcxz noBreak + call cx +noBreak: + mov cx, [__exitsig] + jcxz noSig + call cx +noSig: + jmp near __FloatFinish + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +select _DATA + +message : db 0AH,'Floating Point Not Loaded',0AH,0 + +select _TEXT + +extrn _puts + +public __real_pdef : +public __real_sdef : + + mov ax, message + jmp _puts + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _MAGIC(DATA,28H) +segment _INIT(DATA,28H) +segment _CONST(DATA,28H) +segment _DATA(DATA,28H) +segment _BSS(BSS,28H) +segment _BSS_END(BSS,28H) + +group DGROUP(_MAGIC,_INIT,_CONST,_DATA,_BSS,_BSS_END) + +extrn __EpocInit +extrn __exit +extrn __cleanup +extrn __osversion +extrn __FloatInit +extrn __InitSetup +extrn __InitLoop +extrn __init2 +extrn @ExitCode +select _TEXT (* Process initialisation starts here *) + +public __startup : + + call __EpocInit + + call __FloatInit (* initialise floating point if present *) + call __osversion (* get Epoc/Os version first *) + + call __InitSetup + call __InitLoop + + call __cleanup + + mov ax, [@ExitCode] + jmp near __exit + +public $Stage2 : + + call __init2 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __real_in +extrn __real_out +extrn __rreal_in +extrn __rreal_out + +select _TEXT + +extrn __initsig + +public __fp_1 : + + mov word [__real_in], __rreal_in (* initialise 'C' fp output *) + mov word [__real_out], __rreal_out + jmp near __initsig + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __real_in +extrn __real_out +extrn __real_pdef +extrn __real_sdef + +select _TEXT + +public __fp_0 : + + mov word [__real_in], __real_sdef + mov word [__real_out], __real_pdef + ret 0 + +end + + diff --git a/code/SIBOSDK/src/coremath.a b/code/SIBOSDK/src/coremath.a new file mode 100644 index 0000000..f491a3e --- /dev/null +++ b/code/SIBOSDK/src/coremath.a @@ -0,0 +1,1259 @@ +(************************************************************************) +(* *) +(* Release 3.00 *) +(* *) +(* CoreMATH - Common math support module. *) +(* *) +(* Copyright (C) 1989, 1990 Jensen and Partners. All Rights Reserved *) +(* Written by Simon Knight. *) +(* *) +(* Copyright (C) 1991 Psion PLC. All Rights Reserved *) +(* Modified by NSM. *) +(* *) +(************************************************************************) + +include "corelib.inc" +include "epocdefs.inc" + +module CoreMath + +(****************************************************************************) +segment _BSS(BSS,28H) + +public _matherr : org CodePtrSize +public __SH_sword : org 2 +public __exc_addr : org 2 + +segment _BSS(BSS,28H) + +public __fac : org 10 + +segment _DATA(DATA,28H) + +public _HUGE : db 098H,060H,0B9H,0D7H,0FFH,0FFH,0EFH,07FH + +segment _DATA(DATA,28H) + +public _LHUGE : db 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,07FH + +(****************************************************************************) +section + +extrn FIDRQQ +extrn _matherr +extrn FIWRQQ +extrn __seterrno + + +segment _TEXT(CODE,00048H) (*segment length = 000A2H*) + +public __report_math_error : + push bp + mov bp,sp + sub sp,30H + push di + push si + push cx + fwait + fld st(0),st(1) + fwait + fstp tbyte [bp][-30H],st(0) + fwait + fst st(1),st(0) + mov cx,ax + cmp word [_matherr],0 + je $1 + xor si,si +$0: + mov di,si + add di,bx + mov al,cs:[di] + mov [bp][si][-0AH],al + inc si + cmp si,0AH + jl $0 + mov [bp][-26H],cx + fwait + fld st(0),st(5) + fwait + fstp qword [bp][-22H],st(0) + nop + fwait + fwait + fld st(0),st(6) + fwait + fstp qword [bp][-1AH],st(0) + nop + fwait + lea ax,[bp][-0AH] + mov [bp][-24H],ax + lea ax,[bp][-26H] + call word [_matherr] + test ax,ax + jne $3 +$1: + cmp cx,1 + jne $4 + mov ax,EDOM +$2: + call __seterrno + fwait + fld st(0),st(1) + fwait + fstp st(1),st(0) + jmp $5 +$3: + fwait + fld qword st(0),[bp][-12H] + fwait + fstp st(1),st(0) + jmp $5 +$4: + mov ax,ERANGE + jmp $2 +$5: + fwait + fld tbyte st(0),[bp][-30H] + fwait + fstp st(2),st(0) + pop cx + pop si + pop di + mov sp,bp + pop bp + ret 0 + +segment _TEXT(CODE,28H) + +two: dw 2 + +extrn __report_math_error + +__lib_error: + push bp + push ax + push bx + push cx + push dx + mov bp,sp + sub sp,2 + test byte cs:[si][4], f_st5 (* is arg1 in st5? *) + jz not_st5 + fld st(0),st(5) + fstp st(1),st(0) + jmp st5_done +not_st5: + fst st(5), st(0) +st5_done: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1], 1 + mov ax, cs:[si][2] + jz me_positive + mov ax, cs:[si][0] +me_positive: + call ax + fstp st(1),st(0) + or ax,ax + jz me_ok + test byte cs:[si][4], f_two + jnz has_two + fldz st(0) + fstp st(7),st(0) +has_two: + lea bx,[si][5] + call __report_math_error +me_ok: + mov sp,bp + pop dx + pop cx + pop bx + pop ax + pop bp + ret 0 + +segment _TEXT(CODE,28H) +err_domain: + fldz st(0) + mov ax, _DOMAIN + ret 0 + +segment _TEXT(CODE,28H) +err_underflow: + fldz st(0) + mov ax, _UNDERFLOW + ret 0 + +segment _TEXT(CODE,28H) +err_plus_infinity: + extrn _HUGE + fld qword st(0), [_HUGE] + mov ax, _OVERFLOW + ret 0 + +segment _TEXT(CODE,28H) +err_minus_infinity: + call err_plus_infinity + fchs st(0) + ret 0 + +segment _TEXT(CODE,28H) +one:dw 1 +check_abs_one: + fld st(0),st(0) + fabs st(0) + ficomp word st(0), cs:[one] + fstsw [bp][-2] + fwait + test byte [bp][-1], 40H + jz ab1_err + ret 0 +ab1_err: + add sp,2 + jmp err_domain + +segment _TEXT(CODE,28H) +ldexp_err_pos: + fld st(0),st(6) + ftst st(0) + fstsw [bp][-2] + fstp st(0), st(0) + test byte [bp][-1], 1 + jnz err_underflow + jmp err_plus_infinity +ldexp_err_neg: + fld st(0),st(6) + ftst st(0) + fstsw [bp][-2] + fstp st(0), st(0) + test byte [bp][-1], 1 + jnz err_underflow + jmp err_minus_infinity + +segment _TEXT(CODE,28H) +public _hypotl: +public _hypot: +hypotCommon: + fmul st(0), st(0) + fld st(0), st(6) + fmul st(0), st(0) + faddp st(1), st(0) + fsqrt st(0) + ret 0 + +segment _TEXT(CODE,28H) + +public _ceill: +public _ceil: + push bp + mov bp,sp + sub sp,2 + +ceilCommon: + fstcw [bp][-2] + fwait + and byte [bp][-1], ~4 (* round towards +inf *) + fldcw [bp][-2] + frndint st(0) + or byte [bp][-1], 4 (* restore to chop *) + fldcw [bp][-2] + fwait + mov sp,bp + pop bp + ret 0 + +segment _TEXT(CODE,28H) +public _floorl: +public _floor: + push bp + mov bp,sp + sub sp,2 +floorCommon: + fstcw [bp][-2] + fwait + and byte [bp][-1], ~8 (* round towards -inf *) + fldcw [bp][-2] + frndint st(0) + or byte [bp][-1], 8 (* restore to chop *) + fldcw [bp][-2] + fwait + mov sp,bp + pop bp + ret 0 + +segment _TEXT(CODE,28H) +public __round: + frndint st(0) + ret 0 + +segment _TEXT(CODE,28H) +public __bcd: + push bp (* new *) + mov bp, sp (* new *) + sub sp, 2 (* new *) + fstcw [bp][-2] (* new *) + (* ensure round to nearest (80387 compatibility problem) *) + fwait (* new *) + push [bp][-2] (* new *) + and word [bp][-2], ~0C00H (* new *) + fldcw [bp][-2] (* new *) + + fld st(0), st(0) + xchg ax,bp + fbstp tbyte [bp], st(0) + xchg ax,bp + + pop [bp][-2] (* new *) + fldcw [bp][-2] (* new *) + fwait (* new *) + mov sp, bp (* new *) + pop bp (* new *) + ret 0 + +segment _TEXT(CODE,28H) +(* compute 2^st(0) , result is represented as st(0) * 2^st(4) *) +four: dw 4 +pow2: + fld1 st(0) + fxch st(0), st(1) + fst st(5), st(0) + frndint st(0) + fsub st(0), st(1) + fxch st(0), st(5) + fsub st(0), st(5) (* we now know that st(0) is in range [0..2) *) + fidiv word st(0), cs:[four] (* now in range [0..0.5] *) + f2xm1 st(0) + faddp st(1), st(0) + fmul st(0), st(0) + fmul st(0), st(0) + ret 0 + +segment _TEXT(CODE,28H) +public _fmodl: +public _fmod: + push bp + mov bp,sp +fmodCommon: + sub sp,2 + fld st(0), st(6) + ftst st(0) + fstsw [bp][-2] + test byte [bp][-1],40H + jnz fmod_zero + fxch st(0), st(1) +fmod_more: + fprem st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1], 4 + jnz fmod_more +fmod_zero: + fstp st(1),st(0) + mov sp,bp + pop bp + ret 0 + +segment _TEXT(CODE,28H) +public _frexpl : +public _frexp : + push bp + mov bp,sp + sub sp,2 + xchg bx,ax +frexpCommon: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1],40H + jnz frexp_zero + fxtract st(0) + fxch st(0), st(1) + fistp word [bx], st(0) + fwait + inc word [bx] + fidiv word st(0), cs:[two] +frexp_exit: + xchg bx,ax + mov sp,bp + pop bp + ret 0 +frexp_zero: + and word [bx], 0 + jmp frexp_exit + +segment _TEXT(CODE,28H) +public __clear87 : + push bx + push ax + mov bx, sp (* get current status word into ax *) + fstsw ss:[bx] + fclex + pop ax + pop bx (* clear status word *) + ret 0 + +segment _TEXT(CODE,28H) +public __fpreset : + ret 0 + +segment _TEXT(CODE,28H) +public __status87 : + push bx + push ax + mov bx, sp (* get current status word into ax *) + fstsw ss:[bx] + fwait + pop ax + pop bx + ret 0 + +segment _TEXT(CODE,28H) +public __control87 : +new = -2 +mask = -4 +locals = 4 + + push bp + mov bp, sp (* get current control word into ax *) + sub sp, locals + push bx + push cx + push dx + mov [bp][new], ax + mov [bp][mask], bx + push ax + mov bx, sp + fstcw ss:[bx] + fwait + pop ax (* ax has original value *) + + mov cx, [bp][mask] + jcxz con87Done (* mask is zero - return *) + mov dx, [bp][new] + and dx, cx (* ctrl = ((ctrl &~mask) | (new & mask)) *) + not cx + and ax, cx + or ax, dx + mov [bp][new], ax + fldcw [bp][new] +con87Done: + pop dx + pop cx + pop bx + mov sp, bp + pop bp + ret 0 + +segment _TEXT(CODE,28H) +Pi_By_4: dw 0C235H, 02168H, 0DAA2H, 0C90FH, 03FFEH +public _sin : +public _sinl : + push bp + mov bp, sp + sub sp, 2 + push cx + mov cl, 0 + jmp trig +public _cos: +public _cosl : + push bp + mov bp, sp + sub sp, 2 + push cx + mov cl, 2 + jmp trig +public _tan : +public _tanl : + push bp + mov bp, sp + sub sp, 2 + push cx + mov cl, 4 +trig: + push ax +trigCommon: + fxam st(0) (* '87 works while we enter routine*) + fstsw [bp][-2] + fwait + mov ah, [bp][-1] + fabs st(0) + fld tbyte st(0), cs:[Pi_By_4] + fxch st(0),st(1) + fprem st(0) + mov ch, ah + and ch, 2 + shr ch, 1 (* ch := sign *) + fstsw [bp][-2] + fwait + mov ax, [bp][-2] + mov al, ah + and al, 3 (* select the C3, C1, and C0 status bits*) + shl ah, 1 + shl ah, 1 + rcl al, 1 (* arrange them in the ls 3 bits of BX*) + add al, 0FCH + rcl al, 1 (* al now contains the octant number*) + cmp cl, 2 (* are we doing Cosine ?*) + jne trig_notCosine + add al, cl (* Cos (x) = Sin (x + 2 octants)*) + mov ch, 0 (* Cosine has even symmetry around 0*) +trig_notCosine: + and al, 7 + test al, 1 + jz trig_evens + fsubp st(1),st(0) (* overwrites pi/4 in st(1), pops.*) + jmp trig_ptan +trig_evens: + fstp st(1),st(0) +trig_ptan: + fptan st(0) + cmp cl, 4 + je trig_tangent + test al, 3 + jpe trig_sineOctant +trig_cosOctant: + fxch st(0), st(1) +trig_sineOctant: + fmul st(0), st(0) + fstp st(7), st(0) + fld st(0), st(0) + fmul st(0), st(0) + fadd st(0), st(7) + fsqrt st(0) + shr al, 1 + shr al, 1 + xor al, ch + jz trig_sineDiv + fchs st(0) +trig_sineDiv: + fdivp st(1), st(0) + jmp trig_end +trig_tangent: + mov ah, al + shr ah, 1 + and ah, 1 + xor ah, ch + jz trig_tanSigned + fchs st(0) +trig_tanSigned: + test al, 3 + jpe trig_ratio + fdivrp st(1),st(0) + jmp trig_end +trig_ratio: + fdivp st(1), st(0) +trig_end: + pop ax + pop cx + mov sp, bp + pop bp + ret 0 + +segment _TEXT(CODE,28H) +Pi_By_2: dw 0C235H, 02168H, 0DAA2H, 0C90FH, 03FFFH + +segment _TEXT(CODE,28H) +public _atan2l: +public _atan2: + push bp + mov bp,sp + sub sp,4 +atan2Common: + call atan20 + mov sp,bp + pop bp + ret 0 +atan20: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1],1 + je atan21 + fchs st(0) + call atan21 + fchs st(0) + ret 0 +atan21: + fld st(0), st(6) + ftst st(0) + fstsw [bp][-4] + fwait + test byte [bp][-3],1 + je atan22 + fchs st(0) + call atan22 + fldpi st(0) + fsubrp st(1),st(0) + ret 0 +atan22: + test byte [bp][-3],40H + jnz maybe_zero_zero +not_zero_zero: + fcom st(0), st(1) + fstsw [bp][-2] + fwait + test byte [bp][-1],1 + jz atan23 + fxch st(0), st(1) + fpatan st(1), st(0) + fld tbyte st(0),cs:[Pi_By_2] + fsubrp st(1),st(0) + ret 0 +atan23: + fpatan st(1),st(0) + ret 0 +maybe_zero_zero: + test byte [bp][-1],40H + jz not_zero_zero + fstp st(0), st(0) + push si + mov si, atan2_err_data + call __lib_error + pop si + ret 0 +atan2_err_data: dw err_domain, err_domain; db 0, "atan2", 0 + +segment _TEXT(CODE,28H) + +public _atanl: +public _atan: + push bp + mov bp,sp + sub sp,2 +atanCommon: + call atan0 + mov sp,bp + pop bp + ret 0 +atan0: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1],1 + je atan1 + fchs st(0) + call atan1 + fchs st(0) + ret 0 +atan1: + fld1 st(0) + fcom st(0), st(1) + fstsw [bp][-2] + fwait + test byte [bp][-1],1 + jnz atan2 + fpatan st(1), st(0) + ret 0 +atan2: + fxch st(0), st(1) + fpatan st(1),st(0) + fld tbyte st(0),cs:[Pi_By_2] + fsubrp st(1),st(0) + ret 0 + +segment _TEXT(CODE,28H) +public _logl : +public _log : + push bp + mov bp,sp + sub sp,2 +logCommon: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1], 41H + jnz log_error + fldln2 st(0) + fxch st(0),st(1) + fyl2x st(1),st(0) +log_exit: + mov sp,bp + pop bp + ret 0 +log_error: + push si + mov si, log_err_data + call __lib_error + pop si + jmp log_exit +log_err_data: dw err_domain, err_minus_infinity; db 0, "log", 0 + +segment _TEXT(CODE,28H) +public _log10l : +public _log10 : + push bp + mov bp,sp + sub sp,2 +log10Common: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1], 41H + jnz log10_error + fldlg2 st(0) + fxch st(0),st(1) + fyl2x st(1),st(0) +log10_exit: + mov sp,bp + pop bp + ret 0 +log10_error: + push si + mov si, log10_err_data + call __lib_error + pop si + jmp log10_exit +log10_err_data: dw err_domain, err_minus_infinity; db 0, "log10", 0 + +segment _TEXT(CODE,28H) +__math_magic_start: + +(* routines which use 8087 exception handling *) +(* to avoid explicit checks *) + +segment _TEXT(CODE,28H) +public _fabsl : +public _fabs: + mov byte ss:[InMathLib], 1 +fabsCommon: + fabs st(0) + mov byte ss:[InMathLib], 0DEH + ret 0 + +segment _TEXT(CODE,28H) +public _sqrtl : +public _sqrt : + mov byte ss:[InMathLib], 1 +sqrtCommon: +(* Return the square root of x, which must be greater than zero. *) + fsqrt st(0) (*invalid op possible*) + fwait + mov byte ss:[InMathLib], 0DEH +sqrt_exit: + ret 0 + dw magic, sqrt_exit, err_domain, err_domain; db 0, "sqrt", 0 + +segment _TEXT(CODE,28H) +public _expl : +public _exp : + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,2 +expCommon: + fst st(5), st(0) (* save parameter for error processing *) + fldl2e st(0) + fmulp st(1), st(0) + fist word [bp][-2], st(0) (* to check that it is not too large *) + fwait + call pow2 + fld st(0), st(4) (* retrieve integral part *) + fxch st(1), st(0) + fscale st(0), st(1) + fstp st(1),st(0) +exp_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, exp_exit, err_underflow, err_plus_infinity; db f_st5, "exp", 0 + +segment _TEXT(CODE,28H) +public __pow_int: + push cx + push bx + mov bx,ax + call powi0 + pop bx + pop cx + ret 0 + +powi0: + test ax,ax + jg powi3 + jne powi2 + fld1 st(0) + fstp st(1),st(0) + ret 0 + +powi2: + neg ax + call powi3 + fld1 st(0) + fdivrp st(1),st(0) + ret 0 + +powi3: + mov cx,17 + fld st(0), st(0) +powi4: + dec cx + add ax,ax + jnc powi4 + jmp powi7 +powi6: + fmul st(0),st(0) + add ax,ax + jnc powi7 + fmul st(0),st(1) +powi7: + loop powi6 + fstp st(1),st(0) +powi7_exit: + ret 0 + dw magic, powi7_exit, powi_err_neg, powi_err_pos; db f_st5, "pow", 0 +powi_err_neg: + test bx,bx + jl err_underflow + test bx,1 + jz err_plus_infinity + jmp err_minus_infinity +powi_err_pos: + test bx,bx + jl err_underflow + jmp err_plus_infinity + +segment _TEXT(CODE,28H) +public _powl : +public _pow : + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,4 +powCommon: + ftst st(0) + fstsw [bp][-2] + fwait + test byte [bp][-1], 41H + jnz pow_integral + fst st(5), st(0) (* save parameter for error processing *) + fld1 st(0) + fxch st(0),st(1) + fyl2x st(1),st(0) + fmul st(0), st(6) + fist word [bp][-2], st(0) (* to check that it is not too large *) + fwait +pow1: + call pow2 + fld st(0), st(4) (* retrieve integral part *) + fxch st(1), st(0) + fscale st(0), st(1) + fstp st(1),st(0) +pow_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, pow_exit, err_pow_neg, err_pow_pos; db f_st5+f_two, "pow", 0 + +pow_integral: + test byte [bp][-1], 40H + jnz pow_dom_err + fld st(0), st(6) + fist word [bp][-4], st(0) + ficomp word st(0), [bp][-4] + fstsw [bp][-2] + fwait + test byte [bp][-1], 40H + jz pow_dom_err + mov ax, [bp][-4] + call __pow_int + jmp pow_exit + dw magic, pow_exit, err_domain, err_domain; db f_st5+f_two, "pow", 0 + +err_pow_pos: + fld st(0), st(6) + ftst st(0) + fstsw [bp][-2] + fstp st(0),st(0) + test byte [bp][-1], 1 + jz err_plus_infinity + jmp err_underflow + +err_pow_neg: + fld st(0), st(6) + fistp word [bp][-2], st(0) + mov ax, [bp][-2] + call __pow_int +pown_exit: + ret 0 + dw magic, pown_exit, err_domain, err_domain; db f_st5+f_two, "pow", 0 + +pow_dom_err: + push si + mov si, pow_dom_err_data + call __lib_error + pop si + jmp pow_exit +pow_dom_err_data: dw err_domain, err_domain; db 0, "pow", 0 + + +segment _TEXT(CODE,28H) +public _tanhl : +public _tanh : + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,2 +tanhCommon: + fst st(5), st(0) (* save for error processing *) + fldl2e st(0) + fmulp st(1), st(0) + fist word [bp][-2], st(0) (* to check that it is not too large *) + fwait + call pow2 + fld st(0), st(4) (* retrieve integral part *) + fxch st(1), st(0) + fscale st(0), st(1) + fstp st(1), st(0) + fld1 st(0) + fdiv st(0), st(1) (* Exp (-x) *) + fst st(7), st(0) + fadd st(0), st(1) + fxch st(0), st(1) + fsub st(0), st(7) + fdivrp st(1), st(0) +tanh_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, tanh_exit, tanh_one, tanh_minus_one; db f_st5, "tanh", 0 + +tanh_one: + sub ax,ax + fld1 st(0) + ret 0 + +tanh_minus_one: + call tanh_one + fchs st(0) + ret 0 + +segment _TEXT(CODE,28H) +public _sinhl : +public _sinh : + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,2 +sinhCommon: + fst st(5), st(0) (* save for error processing *) + fldl2e st(0) + fmulp st(1), st(0) + fist word [bp][-2], st(0) (* to check that it is not too large *) + fwait + call pow2 + fld st(0), st(4) (* retrieve integral part *) + fxch st(1), st(0) + fscale st(0), st(1) + fstp st(1), st(0) + fld1 st(0) + fchs st(0) + fdiv st(0), st(1) (* - Exp (-x) *) + faddp st(1), st(0) + fidiv word st(0), cs:[two] +sinh_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, sinh_exit, err_minus_infinity, err_plus_infinity; db f_st5, "sinh", 0 + +segment _TEXT(CODE,28H) +public _coshl : +public _cosh : + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,2 +coshCommon: + fst st(5), st(0) (* save for error processing *) + fabs st(0) + fldl2e st(0) + fmulp st(1), st(0) + fist word [bp][-2], st(0) (* to check that it is not too large *) + fwait + call pow2 + fld st(0), st(4) (* retrieve integral part *) + fxch st(1), st(0) + fscale st(0), st(1) + fstp st(1), st(0) + fld1 st(0) + fdiv st(0), st(1) (* Exp (-x) *) + faddp st(1), st(0) + fidiv word st(0), cs:[two] +cosh_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, cosh_exit, err_plus_infinity, err_plus_infinity; db f_st5, "cosh", 0 + +segment _TEXT(CODE,28H) +public _asinl : +public _asin: + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,2 +asinCommon: + fst st(5), st(0) + fmul st(0), st(0) + fld1 st(0) + fsubrp st(1),st(0) + fsqrt st(0) + fwait + fdivr st(0),st(5) + fwait + call atan0 +asin_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, asin_exit, err_asin_neg, err_asin_pos; db f_st5, "asin", 0 + +err_asin_pos: + call check_abs_one + fld1 st(0) + fstp st(1),st(0) + fchs st(0) + fldpi st(0) + fscale st(0),st(1) + sub ax,ax + ret 0 + +err_asin_neg: + call err_asin_pos + fchs st(0) + ret 0 + +segment _TEXT(CODE,28H) +public _acosl : +public _acos : + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + sub sp,2 +acosCommon: + fst st(5), st(0) + fmul st(0), st(0) + fld1 st(0) + fsubrp st(1),st(0) + fsqrt st(0) + fdivr st(0),st(5) + fwait + call atan0 + fld tbyte st(0), cs:[Pi_By_2] + fsubrp st(1), st(0) +acos_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, acos_exit, err_acos_neg, err_acos_pos; db f_st5, "acos", 0 + +err_acos_pos: + call check_abs_one + fldz st(0) + sub ax,ax + ret 0 + +err_acos_neg: + call check_abs_one + fldpi st(0) + sub ax,ax + ret 0 + + +segment _TEXT(CODE,28H) +public _ldexpl : +public _ldexp: + mov byte ss:[InMathLib], 1 + push bp + mov bp,sp + push ax + fst st(5), st(0) + fild word st(0), [bp][-2] +ldexpCommon: + fst st(7), st(0) + fxch st(0),st(1) + fscale st(0), st(1) + fstp st(1), st(0) +ldexp_exit: + mov sp,bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, ldexp_exit, ldexp_err_neg, ldexp_err_pos; db f_st5+f_two, "ldexp", 0 + +segment _TEXT(CODE,28H) +ten:dw 10 + +public __acvt : + +(* converts ascii string of digits into packed BCD then into double *) + +flag = -2 +mbuf = -6 +exp = -8 +len = -10 +old_cw = -12 +stat_w = -14 +man = -24 +locals = 10 + + +_PNT = 4 +_MNEG = 1 +_STD = 8 +ERANGE = 34 + + mov byte ss:[InMathLib], 1 + push bp + mov bp, sp + sub sp, locals + mov [bp][flag], ax + mov [bp][mbuf], bx + mov [bp][exp], cx + mov [bp][len], dx + sub sp, 4 + mov cx, 5 + sub ax, ax +clearLoop: (* clear BCD local *) + push ax + loop clearLoop + push si + + mov cx, [bp][len] + mov si, [bp][mbuf] + lea bx, [bp][man] + shr cx, 1 + jnc acvtEven + sub ah, ah + add bx, cx + inc cx + jmp acvtOdd +acvtEven: + jcxz acvtZero + dec cx + add bx, cx + inc cx +acvtPack: (* pack number *) + lodsb + push cx + mov cl, 4 + shl al, cl + pop cx + mov ah, al +acvtOdd: + lodsb + and al, 0FH + or al, ah + mov ss:[bx], al + dec bx + loop acvtPack +acvtZero: + fild word st(0), cs:[ten] + fstp st(1), st(0) + mov ax, [bp][exp] + test ax,ax + jge positive_exp + neg ax + call __pow_int + fbld tbyte st(0), [bp][man] (* load mantissa *) + fxch st(1), st(0) + fdivp st(1), st(0) + fwait + jmp acvt_test_sign + dw magic, acvt_err_exit, err_underflow, err_underflow; db 0, "acvt", 0 +positive_exp: + call __pow_int + fbld tbyte st(0), [bp][man] (* load mantissa *) + fxch st(1), st(0) (* necessary for overflow handling *) + fmulp st(1), st(0) +acvt_test_sign: + test word [bp][flag], _MNEG + je acvt_exit + fchs st(0) (* change sign if negative *) +acvt_exit: + pop si + mov sp, bp + pop bp + mov byte ss:[InMathLib], 0DEH + ret 0 + dw magic, acvt_err_exit, err_minus_infinity, err_plus_infinity; db 0, "acvt", 0 +acvt_err_exit: + test word [bp][flag], _STD (* if called from strtod *) + jnz acvt_exit (* set errno on over/underflow *) + (* should restore errno here *) + jmp acvt_exit + +extrn __exc_addr + +segment _TEXT(CODE,28H) + +public __bcd_to_int : (* si = bcd, di = int mantissa *) + + ret 0 + +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _TEXT + +__math_magic_end: +public __math_excep: + (* called from floating point exception handler *) + (* 8087 status word on stack *) + + push bp + mov bp,sp + sub sp,2 + jmp pop_8087 +pop_8087_loop: + fstp st(0), st(0) +pop_8087: + fstsw [bp][-2] + fwait + and word [bp][-2], 3800H + cmp word [bp][-2], 0800H + jnz pop_8087_loop + cmp byte [InMathLib], 1 + jne user_error + mov byte [InMathLib], 0DEH + + (* search for handler *) + push si + push ax + push bx + mov si,[bp][4] +search_loop: + inc si + cmp word cs:[si], magic + jne search_loop + add si, 4 + mov ax, cs:[si][-2] (* resume address *) + mov [bp][4],ax (* adjust local return address *) + call __lib_error + pop bx + pop ax + pop si + mov sp,bp + pop bp + add sp, 2 + ret 0 (* discard ret to __sigFp *) + +user_error: + push ax + mov ax, [bp][4] + mov [__exc_addr], ax + pop ax + mov sp, bp + pop bp + ret 0 + +end + diff --git a/code/SIBOSDK/src/coremem.a b/code/SIBOSDK/src/coremem.a new file mode 100644 index 0000000..da3c9a6 --- /dev/null +++ b/code/SIBOSDK/src/coremem.a @@ -0,0 +1,202 @@ +(************************************************************************) +(* *) +(* Release 3.00 *) +(* *) +(* CoreMem - Common memory management module. *) +(* *) +(* Copyright (C) 1989, 1990 Jensen and Partners. All Rights Reserved *) +(* Written by Simon Knight. *) +(* *) +(* Copyright (C) 1991 Psion PLC. All Rights Reserved *) +(* Modified by NSM. *) +(* *) +(************************************************************************) + +include "corelib.inc" +include "epocdefs.inc" + +module CoreMem + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn _errno + +select _TEXT + + +public __ncalloc : +public _calloc : + + push cx + push dx + mul bx + or dx, dx + je __nmallocEntry + +__nmallocError : (* arrive here to return NULL *) + mov word [_errno], ENOMEM + sub ax, ax + pop dx + pop cx + ret 0 + +public __nmalloc : +public _malloc : + + push cx + push dx + or dl, 1 + +__nmallocEntry: + + or ax, ax + je __nmallocError (* return NULL if size = 0 *) + mov cx, ax + mov ah, NmHeapAllocateCell + int HeapManager + jc __nmallocError + test dl, dl + jne __noZeroFill (* was malloc, so no zero fill *) + push di + mov di, ax + mov dx, ax + sub ax, ax + cld + shr cx, 1 + rep; stosw + pop di + mov ax, dx +__noZeroFill: + pop dx + pop cx + ret 0 + + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +public _coreleft : +public __memavl : +public _nearcoreleft : + + push bx + mov ah, NmHeapFreeMemory + int HeapManager + pop bx + ret 0 + +(***************************************************************************) +section + +segment _TEXT(CODE,28H) + +select _TEXT + +public __nfree : +public _free : + + push ax + push bx + mov bx, ax + mov ah, NmHeapFreeCell + int HeapManager + pop bx + pop ax + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + +public __msize : +public __nmsize : + + push bx + mov bx, ax + mov ah, NmHeapCellSize + int HeapManager + pop bx + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __nheapchk + +select _TEXT + +public __heapchk : + + jmp near __nheapchk + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __nheapset + +select _TEXT + +public __heapset : + + jmp near __nheapset + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __nheapwalk + +select _TEXT + +public __heapwalk : + + jmp near __nheapwalk + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn _errno +extrn __nfree + +select _TEXT + +public __nrealloc : +public _realloc : + + test bx, bx + jne _notFree + push bx + mov bx, ax + call __nfree + pop bx + sub ax, ax + ret 0 + +_notFree: + push bx + push cx + mov cx, bx + mov bx, ax + mov ah, NmHeapReAllocateCell + int HeapManager + jnc reAllocExit + mov word [_errno], ENOMEM + sub ax, ax + +reAllocExit: + pop cx + pop bx + ret 0 + +end diff --git a/code/SIBOSDK/src/corertl.a b/code/SIBOSDK/src/corertl.a new file mode 100644 index 0000000..06c751d --- /dev/null +++ b/code/SIBOSDK/src/corertl.a @@ -0,0 +1,1149 @@ +(************************************************************************) +(* *) +(* Release 3.00 *) +(* *) +(* CoreRTL - Common run-time support module. *) +(* *) +(* Copyright (C) 1989, 1990 Jensen and Partners. All Rights Reserved *) +(* Written by Simon Knight. *) +(* *) +(* Copyright (C) 1991 Psion PLC. All Rights Reserved *) +(* Modified by NSM. *) +(* *) +(************************************************************************) + +include "corelib.inc" +include "epocdefs.inc" + +module CoreRTL + +(****************************************************************************) +section +segment _TEXT(CODE,28H); + +public N$StdRet : + + pop ax + pop bx + pop cx + pop dx + pop si + pop di + mov sp, bp + pop bp + ret 0 + +section +segment _TEXT(CODE,28H); + + +public N$UnsMol : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +public N$SgnMol : +(* Unsigned/signed multiplication *) +(* On overflow: modulus 2^32 wrap-around *) + push bp + mov bp,sp + + mov ax,[bp][High1] + and ax,ax + jnz UnsMol2 + add ax,[bp][High2] + jnz UnsMol1 + mov ax,[bp][Low1] + mul word [bp][Low2] + + pop bp + ret near 8 + +UnsMol1: + mul word [bp][Low1] + mov dx,[bp][Low1] + mov bp,[bp][Low2] + xchg bp,ax + mul dx + add dx,bp + pop bp + ret near 8 + +UnsMol2: + mov dx,[bp][High2] + and dx,dx + jnz UnsMol3 + mul word [bp][Low2] + mov dx,[bp][Low1] + mov bp,[bp][Low2] + xchg bp,ax + mul dx + add dx,bp + pop bp + ret near 8 + +UnsMol3: + push cx + mul word [bp][Low2] + mov cx,ax + mov ax,[bp][High2] + mul word [bp][Low1] + add cx,ax + mov ax,[bp][Low1] + mul word [bp][Low2] + add dx,cx + pop cx + pop bp + ret near 8 + +section +segment _TEXT(CODE,28H); + +extrn N$UnsMul + +public N$SgnDiv : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Signed division *) +(*On overflow: result MAXINT, OF set *) + push bp + mov bp,sp + push cx + push si + + xor si,si +(* DIV / 0 Test *) + mov dx,[bp][High2] + or dx,[bp][Low2] + jnz DivOK + extrn N$CnsDiv + add sp, 6 + jmp N$CnsDiv +DivOK: + mov dx,[bp][High1] + and dx,dx + jge SgnDiv5 + not si + neg dx + neg word [bp][Low1] + sbb dx,0 + mov [bp][High1],dx +SgnDiv5: + mov dx,[bp][High2] + and dx,dx + jg SgnDiv1 + jz SgnDiv6 + not si + neg dx + neg word [bp][Low2] + sbb dx,0 + mov [bp][High2],dx + jnz SgnDiv1 + +SgnDiv6: + mov cx,[bp][Low2] + jcxz SgnDiv0 + mov dx,[bp][High1] + cmp dx,cx + jae SgnDivA + mov ax,[bp][Low1] + div cx + xor dx,dx + +SgnDiv9: + add ax,si + adc dx,si + xor ax,si + xor dx,si + +SgnDiv7: + pop si + pop cx + pop bp + ret near 8 + +SgnDivA: + mov ax,dx + xor dx,dx + div cx + mov cx,ax + mov ax,[bp][Low1] + div word [bp][Low2] + mov dx,cx + jmp SgnDiv9 + +SgnDiv1: + push bx + mov cx,dx + mov bx,[bp][Low2] + mov dx,[bp][High1] + mov ax,[bp][Low1] + push cx + push bx +SgnDiv2: + shr dx,1 + rcr ax,1 + shr cx,1 + rcr bx,1 + and cx,cx + jnz SgnDiv2 + div bx + mov bx,ax + push cx + push ax + call near N$UnsMul + jo SgnDiv3 + cmp dx,[bp][High1] + ja SgnDiv3 + jb SgnDiv4 + cmp ax,[bp][Low1] + jbe SgnDiv4 +SgnDiv3: + dec bx +SgnDiv4: + mov ax,bx + xor dx,dx + pop bx + jmp SgnDiv9 + +SgnDiv0: + mov al,100 + add al,al + mov ax,0FFFFH + mov dx,07FFFH + jmp SgnDiv7 + +section +segment _TEXT(CODE,28H); + +extrn N$UnsMul + +public N$UnsDiv : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Unsigned division *) +(*On overflow: result MAXCARD, OF set *) + push bp + mov bp,sp + push cx + +(* DIV / 0 Test *) + mov cx,[bp][High2] + or cx,[bp][Low2] + jnz DivOK + extrn N$CnsDiv + add sp, 4 + jmp N$CnsDiv +DivOK: + mov cx,[bp][High2] + and cx,cx + jnz UnsDiv1 + add cx,[bp][Low2] + jz UnsDiv0 + + mov dx,[bp][High1] + cmp dx,cx + jae UnsDiv7 (*!!!!New special case *) + mov ax,[bp][Low1] + div cx + xor dx,dx + +UnsDiv8: + and ax,ax +UnsDiv9: + pop cx + pop bp + ret near 8 + +UnsDiv7: + mov ax,dx + xor dx,dx + div cx + mov cx,ax + mov ax,[bp][Low1] + div word [bp][Low2] + mov dx,cx + jmp UnsDiv8 + +UnsDiv1: + push bx + mov dx,[bp][High1] + mov ax,[bp][Low1] + mov bx,[bp][Low2] + push cx + push bx +UnsDiv2: + shr dx,1 + rcr ax,1 + shr cx,1 + rcr bx,1 + and cx,cx + jnz UnsDiv2 + div bx + mov bx,ax + push cx + push ax + call near N$UnsMul + jo UnsDiv3 + cmp dx,[bp][High1] + jb UnsDiv4 + ja UnsDiv3 + cmp ax,[bp][Low1] + jbe UnsDiv4 +UnsDiv3: + dec bx +UnsDiv4: + mov ax,bx + xor dx,dx + pop bx + jmp UnsDiv8 + +UnsDiv0: + mov al,100 + add al,al + mov ax,0FFFFH + mov dx,ax + jmp UnsDiv9 + + +section +segment _TEXT(CODE,28H); + +extrn N$UnsMul + +public N$SgnRem : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Signed remainder *) +(*On overflow: result 0, OF set *) + push bp + mov bp,sp + push cx + push si + +(* DIV / 0 Test *) + mov dx,[bp][High2] + or dx,[bp][Low2] + jnz DivOK + extrn N$CnsDiv + add sp, 6 + jmp N$CnsDiv +DivOK: + xor si,si + mov dx,[bp][High1] + and dx,dx + jge SgnRem5 + not si + neg dx + neg word [bp][Low1] + sbb dx,0 + mov [bp][High1],dx +SgnRem5: + mov dx,[bp][High2] + and dx,dx + jg SgnRem1 + jz SgnRem6 + neg dx + neg word [bp][Low2] + sbb dx,0 + mov [bp][High2],dx + jnz SgnRem1 + +SgnRem6: + mov cx,[bp][Low2] + jcxz SgnRem0 + mov ax,[bp][High1] + div cx + mov ax,[bp][Low1] + div cx + mov ax,dx + xor dx,dx + +SgnRem9: + add ax,si + adc dx,si + xor ax,si + xor dx,si + +SgnRem7: + pop si + pop cx + pop bp + ret near 8 + +SgnRem1: + push bx + mov cx,dx + mov bx,[bp][Low2] + mov dx,[bp][High1] + mov ax,[bp][Low1] + push cx + push bx +SgnRem2: + shr dx,1 + rcr ax,1 + shr cx,1 + rcr bx,1 + and cx,cx + jnz SgnRem2 + div bx + push cx + push ax + call near N$UnsMul + cmp dx,[bp][High1] + ja SgnRem3 + jb SgnRem4 + cmp ax,[bp][Low1] + jbe SgnRem4 +SgnRem3: + sub ax,[bp][Low2] + sbb dx,[bp][High2] +SgnRem4: + sub ax,[bp][Low1] + sbb dx,[bp][High1] + neg dx + neg ax + sbb dx,cx + pop bx + jmp SgnRem9 + +SgnRem0: + sub dx,dx + mov al,100 + add al,al + mov ax,dx + jmp SgnRem7 + +section +segment _TEXT(CODE,28H); + +extrn N$UnsMul + +public N$SgnMod : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Signed modulus *) +(*On overflow: result 0, OF set *) + push bp + mov bp,sp + push cx + push bx + +(* DIV / 0 Test *) + mov dx,[bp][High2] + or dx,[bp][Low2] + jnz DivOK + extrn N$CnsDiv + add sp, 6 + jmp N$CnsDiv +DivOK: + mov dx,[bp][High1] + mov bh, dh + and dx,dx + jge SgnMod5 + neg dx + neg word [bp][Low1] + sbb dx,0 + mov [bp][High1],dx +SgnMod5: + mov dx,[bp][High2] + mov bl,dh + and dx,dx + jg SgnMod1 + jz SgnMod6 + neg dx + neg word [bp][Low2] + sbb dx,0 + mov [bp][High2],dx + jnz SgnMod1 + +SgnMod6: + mov cx,[bp][Low2] + jcxz SgnMod0 + mov ax,[bp][High1] + div cx + mov ax,[bp][Low1] + div cx + mov ax,dx + xor dx,dx + +SgnMod9: + mov cx,ax + or cx,dx + jz SgnMod7 + xor bh,bl + jge SgnMod10 + sub ax,[bp][Low2] + sbb dx,[bp][High2] + not bl +SgnMod10: + shl bl,1 + jnc SgnMod7 + neg dx + neg ax + sbb dx,0 +SgnMod7: + pop bx + pop cx + pop bp + ret near 8 + +SgnMod1: + push si + mov cx,dx + mov si,[bp][Low2] + mov dx,[bp][High1] + mov ax,[bp][Low1] + push cx + push si +SgnMod2: + shr dx,1 + rcr ax,1 + shr cx,1 + rcr si,1 + and cx,cx + jnz SgnMod2 + div si + push cx + push ax + call near N$UnsMul + cmp dx,[bp][High1] + ja SgnMod3 + jb SgnMod4 + cmp ax,[bp][Low1] + jbe SgnMod4 +SgnMod3: + sub ax,[bp][Low2] + sbb dx,[bp][High2] +SgnMod4: + sub ax,[bp][Low1] + sbb dx,[bp][High1] + neg dx + neg ax + sbb dx,cx + pop si + jmp SgnMod9 + +SgnMod0: (* overflow *) + sub dx,dx + mov al,100 + add al,al + mov ax,dx + jmp SgnMod7 + +section +segment _TEXT(CODE,28H); + +extrn N$UnsMul + +public N$UnsRem : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Unsigned remainder/modulus *) +(*On overflow: result 0, OF set *) + push bp + mov bp,sp + push cx + +(* DIV / 0 Test *) + mov cx,[bp][High2] + or cx,[bp][Low2] + jnz DivOK + extrn N$CnsDiv + add sp, 4 + jmp N$CnsDiv +DivOK: + mov cx,[bp][High2] + and cx,cx + jnz UnsRem1 + add cx,[bp][Low2] + jz UnsRem0 + mov ax,[bp][High1] + xor dx,dx + div cx + mov ax,[bp][Low1] + div cx + mov ax,dx + xor dx,dx + +UnsRem9: + pop cx + pop bp + ret near 8 + +UnsRem1: + push bx + mov dx,[bp][High1] + mov ax,[bp][Low1] + mov bx,[bp][Low2] + push cx + push bx +UnsRem2: + shr dx,1 + rcr ax,1 + shr cx,1 + rcr bx,1 + and cx,cx + jnz UnsRem2 + div bx + sub ax,1 + adc ax,0 + push cx + push ax + call near N$UnsMul + add ax,[bp][Low2] + adc dx,[bp][High2] + jc UnsRem3 + cmp dx,[bp][High1] + jb UnsRem4 + ja UnsRem3 + cmp ax,[bp][Low1] + jbe UnsRem4 +UnsRem3: + sub ax,[bp][Low2] + sbb dx,[bp][High2] +UnsRem4: + sub ax,[bp][Low1] + sbb dx,[bp][High1] + neg dx + neg ax + sbb dx,cx + and ax,ax + pop bx + jmp UnsRem9 + +UnsRem0: + xor dx,dx + mov al,100 + add al,al + mov ax,dx + jmp UnsRem9 + +section +segment _TEXT(CODE,28H); + +public N$UnsMul : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Unsigned multiplication *) +(*On overflow: result MAXCARD, OF set *) + push bp + mov bp,sp + + mov ax,[bp][High1] + and ax,ax + jnz UnsMul1 + add ax,[bp][High2] + jnz UnsMul2 + mov ax,[bp][Low1] + mul word [bp][Low2] + +UnsMul8: + and ax,ax +UnsMul9: + pop bp + ret near 8 + +UnsMul1: + cmp word [bp][High2],0 + jnz UnsMul0 + mul word [bp][Low2] + jmp UnsMul3 +UnsMul2: + mul word [bp][Low1] +UnsMul3: + jc UnsMul0 + mov dx,[bp][Low1] + mov bp,[bp][Low2] + xchg ax,bp + mul dx + add dx,bp + jnc UnsMul8 + +UnsMul0: + mov al,100 + add al,al + stc + mov ax,0FFFFH + mov dx,ax + jmp UnsMul9 + +section +segment _TEXT(CODE,28H); + +public N$SgnMul : High1 = frame+6; Low1 = frame+4; High2 = frame+2; Low2 = frame +(*Signed multiplication *) +(*On overflow: result MAXINT, OF set *) + push bp + mov bp,sp + push si + + xor si,si + mov dx,[bp][High1] + and dx,dx + jge SgnMul5 + not si + neg dx + neg word [bp][Low1] + sbb dx,0 + mov [bp][High1],dx +SgnMul5: + mov dx,[bp][High2] + and dx,dx + jg SgnMul6 + jz SgnMul1 + not si + neg dx + neg word [bp][Low2] + sbb dx,0 + jz SgnMul1 + +SgnMul6: + cmp word [bp][High1],0 + jnz SgnMul0 + mov ax,dx + mul word [bp][Low1] + jmp SgnMul2 +SgnMul1: + mov ax,[bp][High1] + and ax,ax + jz SgnMul2 + mul word [bp][Low2] +SgnMul2: + jc SgnMul0 + mov dx,[bp][Low1] + mov bp,[bp][Low2] + xchg ax,bp + mul dx + add dx,bp + jc SgnMul0 + js SgnMul0 + + add ax,si + adc dx,si + xor ax,si + xor dx,si + +SgnMul7: + pop si + pop bp + ret near 8 + +SgnMul0: + mov al,100 + add al,al + mov ax,0FFFFH + mov dx,07FFFH + jmp SgnMul7 + +section +segment _TEXT(CODE,28H); + +public N$LngShl : + xor ch,ch + jcxz $lshl1 +$lshl2: + shl ax,1 + rcl dx,1 + loop $lshl2 +$lshl1: + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$LngShr : + xor ch,ch + jcxz $lshr1 +$lshr2: + sar dx,1 + rcr ax,1 + loop $lshr2 +$lshr1: + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$ULngShr : + xor ch,ch + jcxz $ulshr1 +$ulshr2: shr dx,1 + rcr ax,1 + loop $ulshr2 +$ulshr1: + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$MovByt : SourceSeg =frame+8; SourceOff = frame+6; DestSeg = frame+4; DestOff = frame+2; Count = frame + push bp + mov bp,sp + push cx; push si; push di + mov cx, [bp][Count] + mov di, [bp][DestOff] + mov si, [bp][SourceOff] + rep; movsb; + pop di; pop si; pop cx + pop bp + ret near 10 + +section +segment _TEXT(CODE,28H); + +public N$PushByt : SourceSeg = frame+4; SourceOff = frame+2; Count = frame + push bp + mov bp,sp + sub sp, [bp][Count] + push [bp][2] (* return ip *) + push cx; push si; push di + mov si, [bp][SourceOff] + mov cx, [bp][Count] + mov bp, [bp] (* restore bp *) + mov di, sp + add di, frame+frame+14 + rep; movsb + pop di; pop si; pop cx + ret near frame+6 + +section +segment _TEXT(CODE,28H); + +public N$PopByt : Data = frame+6; DestSeg = frame+4; DestOff = frame+2; Count = frame + push bp + mov bp,sp + push cx; push si; push di + mov cx, [bp][Count] + mov di, [bp][DestOff] + lea si, [bp][Data] + rep; movsb + lea bp, [si][-frame] + pop di; pop si; pop cx + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$SetOr : Data = frame+2; Count = frame + push bp + mov bp, sp + push ax; push bx; push cx; push si + mov cx, [bp][Count] + lea bp, [bp][Data] + mov si, cx +$loop: + mov al, [bp] + or [bp][si], al + inc bp + loop $loop + sub bp, frame + pop si; pop cx; pop bx; pop ax + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$SetDif : Data = frame+2; Count = frame + push bp + mov bp, sp + push ax; push bx; push cx; push si + mov cx, [bp][Count] + lea bp, [bp][Data] + mov si, cx +$loop: + mov al, [bp] + not al + and [bp][si], al + inc bp + loop $loop + sub bp, frame + pop si; pop cx; pop bx; pop ax + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$SetXor : Data = frame+2; Count = frame + push bp + mov bp, sp + push ax; push bx; push cx; push si + mov cx, [bp][Count] + lea bp, [bp][Data] + mov si, cx +$loop: + mov al, [bp] + xor [bp][si], al + inc bp + loop $loop + sub bp, frame + pop si; pop cx; pop bx; pop ax + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$SetAnd : Data = frame+2; Count = frame + push bp + mov bp, sp + push ax; push bx; push cx; push si + mov cx, [bp][Count] + lea bp, [bp][Data] + mov si, cx +$loop: + mov al, [bp] + and [bp][si], al + inc bp + loop $loop + sub bp, frame + pop si; pop cx; pop bx; pop ax + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$DupByt : Seg = frame+6; Off = frame+4; Data = frame+2; Count = frame + push bp + mov bp,sp + push di; push cx; push ax + mov al, [bp][Data] + mov cx, [bp][Count] + mov di, [bp][Off] + mov ah, al + shr cx,1 + rep; stosw + jnc $DupBytExit + stosb +$DupBytExit: + pop ax; pop cx; pop di + pop bp + ret near 8 + +section +segment _TEXT(CODE,28H); + +public N$EquByte : Data = frame+2; Count = frame +(* result in flags and ax *) + push bp + mov bp, sp + push cx; push si; push di + mov cx, [bp][Count] + lea si, [bp][Data] + mov di, si + add di, cx + mov bp, di + add bp, cx + repz; cmpsb + pop di; pop si; pop cx (* pop was wrong order *) + lea bp, [bp][-frame] (* build return link, preserve flags!!*) + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + mov ax,0 + jnz $not_equal + mov al, 1 +$not_equal: + ret near 0 + +segment _TEXT(CODE,28H); + +public N$NotEquByte : Data = frame+2; Count = frame +(* result in flags and ax *) + push bp + mov bp, sp + push cx; push si; push di + mov cx, [bp][Count] + lea si, [bp][Data] + mov di, si + add di, cx + mov bp, di + add bp, cx + repz; cmpsb + pop di; pop si; pop cx (* pop was wrong order *) + lea bp, [bp][-frame] (* build return link, preserve flags!!*) + pop [bp] + pop [bp][2] + mov sp, bp + pop bp + mov ax,0 + jz $equal + inc ax +$equal: + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$HugeSub : p = frame+4; q = frame + push bp + mov bp, sp + push bx; push cx + mov ax, [bp][p] + mov dx, [bp][p][2] + mov bx, [bp][q][2] + mov cx, DOSHUGESHIFT + shr bx, cl + shr dx, cl + sub ax, [bp][q] + sbb dx, bx + pop cx; pop bx + pop bp + ret near 8 + +section +segment _TEXT(CODE,28H); + +public N$LngRol : + push bx + and cx, 31 + cmp cx, 16 + jb $1 + sub cx, 16 + xchg ax,dx +$1: + rol ax, cl + rol dx, cl + mov bx, 1 + rol bx, cl + dec bx + mov cx, ax + xor cx, dx + and cx, bx + xor ax, cx + xor dx, cx + pop bx + ret near 0 + +section +segment _TEXT(CODE,28H); + +public N$SetRng : Start = frame+4; Stop = frame+2; Count = frame + push bp + mov bp, sp + sub sp, [bp][Count] + push [bp][2] (* return ip *) + push ax; push bx; push cx; push dx; push si; push di + mov bx, [bp][Count] + mov si, [bp][Start] + mov dx, [bp][Stop] + mov bp, [bp] + + mov di, sp; add di, frame+frame+18 + + add bx, di (*End*) + mov ax, si (*Start*) + cmp ax, dx (*Stop*) + ja $lastpart + + mov cx, ax + shr cx, 1; shr cx, 1; shr cx, 1 + sub al, al + rep; stosb + + mov cl, si (*Start*) + and cl, 7 + mov al, 0FFH + shl al, cl + stosb + + mov cx, dx (*Stop*) + shr cx, 1; shr cx, 1; shr cx, 1 + mov ax, si (*Start*) + shr ax, 1; shr ax, 1; shr ax, 1 + sub cx, ax + jz $one_byte_non_zero + dec cx + mov al, 0FFH + rep; stosb +$done_all_ones: + mov cl, 7 + sub cl, dl (*Stop*) + and cl, 7 + mov al, 0FFH + shr al, cl + stosb + +$lastpart: + mov cx, bx (*End*) + sub cx, di + sub al,al + rep; stosb + + pop di; pop si; pop dx; pop cx; pop bx; pop ax; + ret near frame+6 + +$one_byte_non_zero: + mov cl, 7 + sub cl, dl (*Stop*) + and cl, 7 + mov al, 0FFH + shr al, cl + and es:[di][-1], al + jmp $lastpart + +section +segment _TEXT(CODE,28H); + +extrn __FatalError +extrn __stk_base + +IPVar = 0 + +public N$StkChk : + + add bp, 100H + cmp sp, bp + jb stackError + ret 0 +stackError: + mov bx, sp + mov ax, ss:[bx][IPVar] + mov bx, FatalStackCheck + jmp __FatalError + +section +segment _TEXT(CODE,28H); + +extrn __FatalError +extrn CoreSig@CnsHandler + +IPVar = 8 + +public N$CnsStk : push ax; mov ax, 1 ; jmp N$cns +public N$CnsPtr : push ax; mov ax, 2 ; jmp N$cns +public N$CnsIdx : push ax; mov ax, 9 ; jmp N$cns +public N$CnsOvr : push ax; mov ax, 4 ; jmp N$cns +public N$CnsRng : push ax; mov ax, 5 ; jmp N$cns +public N$CnsRet : push ax; mov ax, 6 ; jmp N$cns +public N$CnsCase : push ax; mov ax, 7 ; jmp N$cns +public N$CnsDiv : push ax; mov ax, 8 ; jmp N$cns +public N$CnsPVC : push ax; mov ax, 0AH + +N$cns: + push bx + push cx + push dx + mov cx, ax + mov bx, sp + mov ax, ss:[bx][IPVar] + mov bx, cx + cmp word ss:[CoreSig@CnsHandler], 0 + je noHandler + call near ss:[CoreSig@CnsHandler] + or al, al + jz noHandler + pop dx + pop cx + pop bx + pop ax + ret 0 +noHandler: + jmp __FatalError + +end + diff --git a/code/SIBOSDK/src/coresig.a b/code/SIBOSDK/src/coresig.a new file mode 100644 index 0000000..6bcd10a --- /dev/null +++ b/code/SIBOSDK/src/coresig.a @@ -0,0 +1,525 @@ +(* Release 3.00 *) + +(* c_signal - signal module *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Modified by NSM.*) + +include "corelib.inc" +include "epocdefs.inc" + +module csignal + +(***************************************************************************) +segment _BSS(BSS, 28H) + +public CoreSig@CnsHandler : org CodePtrSize + +segment _BSS(BSS, 28H) + +public __sigTable : org 46 + +segment _BSS(BSS, 28H) + +public @RecursiveExit : org 2 + +segment _BSS(BSS, 28H) + +public _errno : org 2 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn _errno + +select _TEXT + +public __seterrno : + + mov [_errno], ax + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn _errno + +select _TEXT + +public __errno__ : + + mov ax, _errno + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +extrn _errno +extrn __doserrno + +validError: + db 0, -1, -2, -5, -6, -7, -9 + db -10,-15,-16,-18,-32,-33,-36 + db -37,-39,-40,-41,-42,-66, 1 + +select _TEXT + +public __ioerr : + + cbw + mov [__doserrno], ax + push bx + cmp ax, -128 + jl invalid + cmp ax, 0 + jg invalid + mov bx, validError +locateLoop: + cmp [bx], al + je errorOk + inc bx + cmp byte [bx], 1 + jne locateLoop +invalid: + mov ax, EFAULT +errorOk: + pop bx + mov [_errno], ax + ret 0 + + dw __doserrno + + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA, 28H) + +select _TEXT (* must be in TEXT *) + +extrn __FloatJmpSave +extrn __FloatJmpRestore +extrn _DatClassHandle +extrn _DatClassPtr +extrn _DatEnterFramePtr +extrn _DatOsFramePtr + +public _setjmp : +public __setjmp : +(* +int setjmp(jmp_buf task_state) +Saves current task state and returns 0. +*) + push bp + mov bp, sp + push di + mov di, ax + call __FloatJmpSave + pushf + pop ax + stosw + mov ax, [bp][2] + stosw + lea ax, [bp][4] + stosw + mov ax, [bp] + stosw + mov ax, si + stosw + mov ax, [bp][-2] + stosw + mov ax, dx + stosw + mov ax, cx + stosw + mov ax, bx + stosw + mov ax,[_DatClassHandle] + stosw + mov ax,[_DatClassPtr] + stosw + mov ax,[_DatEnterFramePtr] + stosw + mov ax,[_DatOsFramePtr] + stosw + sub ax, ax + pop di + pop bp + ret 0 + +(* _setjmp ENDP *) + +public _longjmp : +(* +void longjmp ( task_state, val); +Restores task state and jumps to landing_zone. +Returns val. (If val == 0, val++) +*) + + mov si, ax + cmp bx, 1 (* generates carry if BX = 0 *) + adc bx, 0 (* (val) BX = (BX) ? BX : 1; *) + call __FloatJmpRestore + mov di, [si][_j_di] + mov dx, [si][_j_dx] + mov cx, [si][_j_cx] + mov ax, [si][_j_classHandle] + mov [_DatClassHandle], ax + mov ax, [si][_j_classPtr] + mov [_DatClassPtr], ax + mov ax, [si][_j_enterFrame] + mov [_DatEnterFramePtr], ax + cli + mov sp, [si][_j_sp] + mov bp, [si][_j_bp] + mov ax, [si][_j_osFrame] + mov [_DatOsFramePtr], ax + push [si][_j_flag] + popf + push [si][_j_ip] + mov ax, bx + mov bx, [si][_j_bx] + mov si, [si][_j_si] + ret 0 + +(* _longjmp ENDP *) + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +select _DATA + +HeadMsg : db 'Process Terminated', 0 + +select _TEXT + +public __sysmsg : + mov bx, HeadMsg + mov cx, ax + sub dx, dx + mov di, dx + mov si, dx + mov ah, NmGenNotify + int GenManager + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _INIT(DATA,28H) +segment _DATA(DATA,28H) + +extrn __initsig +extrn __InitLoop + +select _TEXT + +do_initsig : (* defined later on ! *) + +select _INIT +initsig : dw MAGIC + db PR3 + dw do_initsig + +select _DATA +public __NSIG : dw 22, initsig + +select _TEXT + + call __initsig + jmp __InitLoop + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _BSS(BSS,28H) + +extrn __FatalError +extrn __FatalErrorPos +extrn __table_raise + +select _BSS + +extrn __sigTable + SIGINT = 2 + SIGILL = 8 + SIGFPE = 16 + SIGSEGV = 22 + SIGTERM = 30 + SIGUSR1 = 32 + SIGUSR2 = 34 + SIGUSR3 = 40 + SIGABRT = 44 + +select _DATA + +DefMsg : db 'By Signal', 0 +FpeMsg : db 'By Floating Point Exception', 0 +Usr1Msg : db 'By User 1 Signal', 0 +Usr2Msg : db 'By User 2 Signal', 0 +Usr3Msg : db 'By User 3 Signal', 0 +AbrtMsg : db 'By Abort', 0 + +extrn __sigsetup +extrn __exitsig +extrn __sysmsg +extrn __FloatMathExcepDos +extrn __NSIG +extrn __SH_sword +extrn __exc_addr + +select _TEXT + +SIG_ERR = -1 +SIG_DFL = 0 +SIG_IGN = 1 + +__do_exitsig : + + ret 0 + +public __initsig : + + (* set up handler table *) + cmp word [__sigsetup], 0 + jnz near noInit + not word [__sigsetup] + mov bx, __sigTable + mov word [__exitsig], __do_exitsig + mov ax, SIG_DFL + mov [bx][SIGABRT], ax (* SIGABRT *) + mov [bx][SIGILL], ax (* SIGILL *) + mov [bx][SIGSEGV], ax (* SIGSEGV *) + mov [bx][SIGINT], ax (* SIGINT *) + mov [bx][SIGFPE], ax (* SIGFPE *) + mov [bx][SIGTERM], ax (* SIGTERM *) + mov [bx][SIGUSR1], ax (* SIGUSR1 *) + mov [bx][SIGUSR2], ax (* SIGUSR2 *) + mov [bx][SIGUSR3], ax (* SIGUSR3 *) + +noInit: + ret 0 + +public __sigIgnore : + +(* A signal is ignored by doing nothing. *) + + ret 0 + +public __sigDefault : + +(* Default action when a signal occurs is to exit the program. *) + + push ax + cmp ax, 8 + je typeFPE + cmp ax, 16 + je typeUsr1 + cmp ax, 17 + je typeUsr2 + cmp ax, 20 + je typeUsr3 + cmp ax, 22 + je typeABRT +typeDEFAULT: + mov ax, DefMsg + jmp sendMessage +typeFPE: + mov ax, FpeMsg + jmp sendMessage +typeUsr1: + mov ax, Usr1Msg + jmp sendMessage +typeUsr2: + mov ax, Usr2Msg + jmp sendMessage +typeUsr3: + mov ax, Usr3Msg + jmp sendMessage +typeABRT: + mov ax, AbrtMsg + +sendMessage: + call __sysmsg + call __FatalErrorPos + pop cx + mov bx, FatalSignal + cmp cx, 8 + jne notFP + mov ax, [__exc_addr] +notFP: + jmp __FatalError + +public __sigFp : + call __FloatMathExcepDos + push ax + push bx + push cx + push dx + push di + push si + mov bx, SIGFPE + mov ax, [__SH_sword] + mov cx, 8 +transLoop: + shr ax, 1 + jc foundBit + loop transLoop +foundBit: + mov ax, 89H + sub ax, cx + call __table_raise + pop si + pop di + pop dx + pop cx + pop bx + pop ax + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _BSS(BSS,28H) + +extrn __NSIG +extrn __sigTable +extrn __sigIgnore +extrn __sigDefault +extrn __seterrno + +select _TEXT + +public _signal : +(* +void ( *signal(int sig, void ( * func)()))(); +sets signal handler to func. +Returns old function pointer. +*) + +EINVAL = 19 + + push bx + push cx + + mov cx, bx + mov bx, ax + or bx, bx + je sigErr + cmp bx, [__NSIG] + ja sigErr + shl bx, 1 (* calculate table index *) + add bx, __sigTable + mov ax, [bx] + mov [bx], cx (* store new function pointer *) +sigDone: + pop cx + pop bx + ret 0 +sigErr: + mov ax, EINVAL + call __seterrno + mov ax, -1 + jmp sigDone + +public _raise : +(* +int raise(sig); +raises signal. +*) + + push bx + push cx + mov cx, bx + mov bx, ax + or bx, bx + je raiseErr + cmp bx, [__NSIG] + ja raiseErr + shl bx, 1 (* calculate table index *) + mov ax, cx + call __table_raise + sub ax, ax +raiseDone: + pop cx + pop bx + ret 0 +raiseErr: (* return -1 *) + mov ax, -1 + jmp raiseDone + +SIG_DFL = 0 +SIG_IGN = 1 + +SIGINT = 2 +SIGILL = 8 +SIGFPE = 16 +SIGSEGV = 22 +SIGTERM = 30 +SIGUSR1 = 32 +SIGUSR2 = 34 +SIGUSR3 = 40 +SIGABRT = 44 + +public __table_raise : (* bx = sig num offset, ax = arg *) + + push bx + push cx + push dx + mov dx, ax + mov ax, bx + shr ax, 1 + mov cx, [bx][__sigTable] + cmp bx, SIGTERM + je doDFL + cmp bx, SIGABRT + je doDFL + cmp bx, SIGILL + je doDFL + cmp bx, SIGSEGV + je doDFL + cmp bx, SIGINT + je doDFL + cmp bx, SIGFPE + je doDFL + cmp bx, SIGUSR1 + je doDFL + cmp bx, SIGUSR2 + je doDFL + cmp bx, SIGUSR3 + jne dontSet +doDFL: + mov word [bx][__sigTable], SIG_DFL +dontSet: + cmp cx, 1 + jbe defRaise + mov bx, dx + call cx +trDone: + pop dx + pop cx + pop bx + ret 0 + +defRaise: + jcxz callDefault + call __sigIgnore + jmp trDone +callDefault: + call __sigDefault + jmp trDone + +end diff --git a/code/SIBOSDK/src/cpplow.a b/code/SIBOSDK/src/cpplow.a new file mode 100644 index 0000000..cc29ce4 --- /dev/null +++ b/code/SIBOSDK/src/cpplow.a @@ -0,0 +1,159 @@ +(* Release 3.10 *) +(*-------------------------------------------------------------------------* +* * +* CPPLOW.A - C++ assembler implementations * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*) + +include "corelib.inc" + +module cpplow + +(******************************************************************************) +section + +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _INIT(DATA,28H) + +extrn __init_standard + +select _TEXT + +do_initstandard : (* defined later on ! *) + +select _INIT +initio : dw MAGIC + db PRL + dw do_initstandard + +select _DATA +public __assign_init_magic : dw 0, initio + +select _TEXT + + call __init_standard + ret 0 + +(******************************************************************************) +section + +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) +segment _INIT(DATA,28H) + +extrn __init_con + +select _TEXT + +do_initcon : (* defined later on ! *) + +select _INIT +initcon : dw MAGIC + db PRL + dw do_initcon + +select _DATA +public __flush_init_magic : dw 0, initcon + +select _TEXT + call __init_con + ret 0 + +(***************************************************************************) +section +segment _DATA(DATA,28H) +segment _TEXT(CODE,28H) + +(* +void _call_ctors(void *(*ctor)(void *), char *obj_ptr, int vbnum, int n, int siz); +void _call_dtors(void (*dtor)(void *), char *obj_ptr, int vbnum, int n, int siz); +*) +sframe = 4 +tor = sframe +objptr = 2+sframe +vbnum = 4+sframe +n = 6+sframe +siz = 8+sframe + + +public __call_ctors : + + push bp + mov bp, sp + push di + push si + sub di, di +ctorsCommon: + mov cx, [bp][n] + jcxz ctDone +ctLoop: + push cx + or di, di + jz noDec + mov cx, [bp][siz] + sub [bp][objptr], cx +noDec: + mov si, 3 + mov ax, [bp][objptr] + mov bx, di + mov cx, [bp][vbnum] + mov dx, di + sub cx, si + jle ctCallConst +ctPushLoop: + push dx + loop ctPushLoop +ctCallConst: + mov cx, di + call word [bp][tor] + or di, di + jnz noInc + mov cx, [bp][siz] + add [bp][objptr], cx +noInc: + pop cx + loop ctLoop +ctDone: + pop si + pop di + pop bp + ret 0 + +public __call_dtors : + + push bp + mov bp, sp + push di + push si + mov di, 1 + jmp ctorsCommon + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +extrn __bcd + +public __cvt_bcd : + + xchg ax, bx + fbld st(0), ss:[bx] + fstp st(1), st(0) + xchg ax, bx + ret 0 + +public __real_to_dec : + + push bp + mov bp, sp + mov bx, ax + fld st(0), st(0) + fistp qword [bx], st(0) + pop bp + ret 0 + +end diff --git a/code/SIBOSDK/src/cstr.a b/code/SIBOSDK/src/cstr.a new file mode 100644 index 0000000..66288ae --- /dev/null +++ b/code/SIBOSDK/src/cstr.a @@ -0,0 +1,1272 @@ +(* Release 3.00 *) + +(* c_str - common string functions *) + +(* Copyright (C) 1989 Jensen and Partners. All Rights Reserved*) +(* Written by Simon Knight.*) + +(* Copyright (C) 1991 Psion PLC. All Rights Reserved*) +(* Modified by NSM.*) + +include "corelib.inc" + +module cstr + +segment _TEXT(CODE,28H) + +(* string - string manipulation routines for signed character srtings *) + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strcpy : + +(* strcpy *) + + push cx + push dx + push di + push si + mov di, bx + mov si, bx + mov dx, ax + mov cx, -1 + sub al, al +repne ; scasb + not cx + mov di, dx + shr cx, 1 +rep; movsw + adc cx, cx +rep; movsb + mov ax, dx (* return destination address *) + pop si + pop di + pop dx + pop cx + ret 0 + + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strcat : + +(* +char *strcat(char *dest, const char *source) + +Appends source to dest. +returns destination address. +*) + + push cx + push dx + push di + push si + mov si, bx + mov di, ax + mov dx, ax + mov cx, 0FFFFH + mov al, 0 +repne ; scasb (* find end of destination string *) + dec di +catLoop: + lodsw + or al, al + jz endOfString + stosw + or ah, ah + loopne catLoop + jmp catDone +endOfString: + stosb +catDone: + mov ax, dx (* return destination address *) + pop si + pop di + pop dx + pop cx + ret 0 + +(*************************************************************************) +section +segment _TEXT(CODE,28H) + +public _stpcpy : + +(* +char *stpcpy(char *dest, const char *source) + +Appends string source to string dest. +Returns destination address + strlen +. +*) + + push cx + push di + push si + mov si, bx + mov di, ax + mov cx, 0FFFFH +pcpyLoop: + lodsw + or al, al + jz endOfString + stosw + or ah, ah + loopne pcpyLoop + jmp pcpyDone +endOfString: + stosb +pcpyDone: + mov ax, di (* return address of terminating zero *) + dec ax + pop si + pop di + pop cx + ret 0 + +(**************************************************************************) + +section +segment _TEXT(CODE,28H) + +public _strchr : + + push cx + push dx + push di + mov di, ax + mov dx, ax + mov cx, -1 + sub al, al +repne ; scasb + not cx + mov di, dx + mov al, bl +repne; scasb + jnz notFound + dec di (* return address of target *) + mov ax, di +chrDone: + pop di + pop dx + pop cx + ret 0 +notFound: + sub ax, ax + jmp chrDone + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strcmp : +public _strcoll : + +(* strcmp *) + + push cx + push di + push si + mov si, ax + mov di, bx + mov cx, -1 + sub ax, ax +repne ; scasb + not cx + mov di, bx +repe; cmpsb + jz ncmpDone + jb ncmpLess +ncmpMore: + inc ax + jmp ncmpDone +ncmpLess: + dec ax +ncmpDone: + pop si + pop di + pop cx + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strcspn : + +(* +int strcspn(const char *s1, const char *s2) + +Returns length of initial segment of s1 not containing characters from s2. +*) + + push cx + push di + push si + mov si, ax + mov cx, 0FFFFH +cspnLoop: + lodsb + or al, al (* end of string ? *) + je cspnDone + mov di, bx +ctLoop: (* search second string *) + mov ah, [di] + cmp al, ah + je cspnDone (* Found Matching character - get out *) + inc di + or ah, ah + jne ctLoop (* repeat compare loop *) + loop cspnLoop (* do next charcter in target string *) +cspnDone: + not cx (* return length to Matching character *) + mov ax, cx + pop si + pop di + pop cx + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + + +extrn _malloc (* used to allocate memory for new string in strdup *) + + +public _strdup : + +(* +char *strdup(const char *s) + +Allocates memory with malloc and copies string s to that address. +Returns pointer to new copy or NULL if call to malloc failed. +*) + + push bx + push cx + push di + push si + mov si, ax + mov di, ax + mov cx, 0FFFFH + sub ax, ax +repne ; scasb (* get length of string plus terminator 0 *) + not cx + push cx + mov ax, cx + call _malloc + pop cx + or ax, ax + je dupnocopy + mov di, ax +rep ; movsb (* copy string *) +dupnocopy: + pop si + pop di + pop cx + pop bx + ret 0 + + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _stricmp : + +(* +int stricmp(const char *s1, const char *s2) + +Unsigned case insensitive comparison of s1 and s2. +Returns -1 if s1 s2. +*) + + push cx + push dx + push di + push si + mov si, ax + mov di, bx + mov cx, 0FFFFH + sub ax, ax +icmpLoop: + lodsb + cmp al, 'z' (* convert to upper if lower *) + ja inotlowa + cmp al, 'a' + jb inotlowa + sub al, 20H +inotlowa: + mov bl, [di] + inc di + cmp bl, 'z' (* convert to upper if lower *) + ja inotlowb + cmp bl, 'a' + jb inotlowb + sub bl, 20H +inotlowb: + cmp al, bl + jb iLessThan + ja iGreaterThan + or al, al + loopnz icmpLoop +icmpSame: + sub ax, ax (* return 0 *) + jmp icmpDone +iLessThan: + mov ax, -1 (* return -1 *) + jmp icmpDone +iGreaterThan: + mov ax, 1 +icmpDone: + pop si + pop di + pop dx + pop cx + ret 0 + + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strlen : + +(* +size_t strlen(const char *s) + +Returns length of s excluding terminating zero. +*) + + + push cx + push di + mov di, ax + mov cx, 0FFFFH + sub al, al +repne ; scasb (* get length of string *) + not cx + mov ax, cx + dec ax (* return value is length of string *) + pop di + pop cx + ret 0 + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strlwr : + +(* +char *strlwr(char *s) + +Converts string s to lower case. +returns s. +*) + + push bx + push cx + push di + push si + mov si, ax + mov di, ax + mov bx, ax + mov cx, 0FFFFH +lwrLoop: + lodsb (* load *) + or al, al + je lwrDone (* end of string *) + cmp al, 'Z' + ja lwrNoChange + cmp al, 'A' + jb lwrNoChange + add al, 20H (* convert *) +lwrNoChange: + stosb (* store *) + loop lwrLoop +lwrDone: + mov ax, bx (* return string address *) + pop si + pop di + pop cx + pop bx + ret 0 + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strncat : + +(* +char *strncat(char *dest, const char *source, int num) + +Concatenates dest and upto num characters from source. +returns destination address. +*) + + push dx + push di + push si + mov si, bx + mov di, ax + mov dx, ax + mov bx, cx + mov cx, 0FFFFH + sub al, al +repne ; scasb (* find end of destination string *) + dec di + mov cx, bx (* count *) + jcxz ncatDone +ncatLoop: + lodsb (* use lodsb/stosb to avoid mem/immed compare *) + stosb + or al, al + je ncatDone + loop ncatLoop + mov byte [di], 0 (* terminate new string *) +ncatDone: + mov ax, dx (* return destination address *) + pop si + pop di + pop dx + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strncmp : + +(* strncmp *) + + push dx + push di + push si + mov si, ax + mov di, bx + mov dx, bx + mov bx, cx + sub ax, ax +repne ; scasb + jcxz stringLong + sub bx, cx +stringLong: + mov cx, bx + mov di, dx +repe; cmpsb + jz ncmpDone + jl ncmpLess +ncmpMore: + inc ax + jmp ncmpDone +ncmpLess: + dec ax +ncmpDone: + pop si + pop di + pop dx + ret 0 + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strncpy : + +(* +char *strcpy(char *dest, const char *source, int num) + +copies up to num characters to dest. +returns destination address. +*) + + push dx + push di + push si + mov si, bx + mov di, ax + mov dx, ax + jcxz ncpyDone +ncpyLoop: + lodsb (* avoids mem/immed compare *) + stosb + or al, al + loopne ncpyLoop +ncpyDone: +rep ; stosb + mov ax, dx (* return destination address *) + pop si + pop di + pop dx + ret 0 + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strxfrm : + + push dx + push di + push si + mov si, bx + mov di, ax + mov dx, cx + jcxz ncpyDone +ncpyLoop: + lodsb (* avoids mem/immed compare *) + stosb + or al, al + je ncpyDone + loop ncpyLoop + sub al, al + stosb +ncpyDone: + mov ax, dx + inc ax + pop si + pop di + pop dx + ret 0 + + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _mbstowcs : +public _wcstombs : + + push dx + push di + push si + mov si, bx + mov di, ax + mov bx, cx + jcxz ncpyDone +ncpyLoop: + lodsb (* avoids mem/immed compare *) + stosb + or al, al + je ncpyDone + loop ncpyLoop +ncpyDone: + mov ax, bx + sub ax, cx + pop si + pop di + pop dx + ret 0 + + +(**************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strnicmp : + +(* +int strnicmp(const char *s1, const char *s2, int num) + + +Compares up to num characters. +Returns < 0 if s1 0 if s1 > s2. +*) + + push dx + push di + push si + mov si, ax + mov di, bx + sub ax, ax + jcxz nicmpDone +nicmpLoop: + lodsb + cmp al, 'z' (* convert to upper if lower *) + ja notlowa + cmp al, 'a' + jb notlowa + sub al, 20H +notlowa: + mov bl, [di] + inc di (* convert to upper if lower *) + cmp bl, 'z' + ja notlowb + cmp bl, 'a' + jb notlowb + sub bl, 20H +notlowb: + cmp al, bl + jl nicmpLessThan + jg nicmpGreaterThan + or al, al + loopne nicmpLoop +nicmpSame: + sub ax, ax (* return 0 *) + jmp nicmpDone +nicmpLessThan: + mov ax, -1 (* return -1 *) + jmp nicmpDone +nicmpGreaterThan: + mov ax, 1 (* return 1 *) +nicmpDone: + pop si + pop di + pop dx + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strnset : + +(* +char *strnset(char *s, char c, unsigned num) + +sets up to num characters to c +returns s. +*) + + push di + mov di, ax + push ax + mov al, bl + jcxz nsetDone +nsetLoop: + cmp byte [di], 0 + je nsetDone + stosb + loop nsetLoop +nsetDone: + pop ax (* return string address *) + pop di + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strpbrk : + +(* +int strpbrk(const char *s1, const char *s2) + +returns address of first occurrence of any character from s2. +*) + + push cx + push di + push si + mov si, ax + mov cx, 0FFFFH +pbrkLoop: + lodsb + or al, al (* end of string ? *) + je pbrkDone + mov di, bx +ktLoop: (* search in second string *) + mov ah, [di] + cmp al, ah + je pbrkFound (* Found Matching character *) + inc di + or ah, ah + jne ktLoop (* repeat *) + loop pbrkLoop (* do next character in target string *) +pbrkDone: + sub ax, ax + jmp pbrkFinish +pbrkFound: + dec si (* return address of first Match *) + mov ax, si +pbrkFinish: + pop si + pop di + pop cx + ret 0 + +(*******************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strrchr : + +(* +char *strrchr(const char *s, int c) + +searches string for last occurrence c. +returns address of target byte if Found. +*) + + push cx + push dx + push di + mov di, ax + mov dx, ax + mov cx, 0FFFFH + sub al, al +repne ; scasb (* find end of string *) + dec di + std + mov al, bl + not cx +repne ; scasb (* search *) + je rchrFound +rchrnotFound: + sub ax, ax (* return NULL *) + jmp rchrDone +rchrFound: + inc di (* return address of Matching character *) + mov ax, di +rchrDone: + cld + pop di + pop dx + pop cx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strrev : + +(* +char *strrev(char *s) + +reverses s. +*) + + push cx + push dx + push di + push si + mov si, ax + mov di, ax + mov dx, ax + sub al, al + mov cx, 0FFFFH +repne ; scasb + cmp cx, 0FFFDH (* find end of string *) + jae revDone + sub di, 2 + mov cx, 0FFFFH +revLoop: + mov al, [di] (* get end character *) + movsb (* move beginning to end *) + sub di, 2 + mov [si][-1], al (* store end character *) + cmp si, di + jae revDone (* exit at crossover *) + loop revLoop +revDone: + mov ax, dx (* return address of string *) + pop si + pop di + pop dx + pop cx + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strset : + +(* +char *strset(char *s, int c) + +sets characters to c +returns s. +*) + + push cx + push dx + push di + mov di, ax + mov dx, ax + mov cx, -1 + sub al, al +repne ; scasb + not cx + dec cx + mov al, bl + mov ah, al + mov di, dx + shr cx, 1 +rep; stosw + adc cx, cx +rep; stosb + mov ax, dx (* return address of string *) + pop di + pop dx + pop cx + ret 0 + +(********************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strspn : + +(* +int strspn(const char *s1, const char *s2) + +returns length of initial segment of s1 containing characters from s2. +*) + + push cx + push dx + push di + push si + mov si, ax + mov dx, bx + mov cx, 0FFFFH +spnLoop: + lodsb + or al, al (* end of string ? *) + je spnDone + mov di, dx + +stLoop: (* search second string *) + mov ah, [di] + cmp al, ah + je spnMatch (* Found Matching character *) + inc di + or ah, ah + jne stLoop (* repeat *) + jmp spnDone (* no Match Found *) +spnMatch: + loop spnLoop (* do next charcter in target string *) +spnDone: + not cx (* return length to non Matching character *) + mov ax, cx + pop si + pop di + pop dx + pop cx + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strstr : + +(* +char *strstr(const char *s1, const char *s2) + +returns address of first occurrence of s2 in s1, or NULL if not Found. +*) + + +s1 = -4 +s2 = -8 +len1 = -10 +len2 = -12 +locals = 12 + + push bp + mov bp, sp + sub sp, locals + push cx + push dx + push di + push si + mov di, bx + mov [bp][s2], bx + mov [bp][s1], ax + mov cx, 0FFFFH (* get length of s2 - saves time in loop *) + sub al, al +repne ; scasb + not cx + dec cx + jcxz s2Null + mov [bp][len2], cx + mov di, [bp][s1] + mov dx, di + mov cx, 0FFFFH (* get length of s2 - saves time in loop *) +repne ; scasb + not cx + dec cx + mov si, [bp][s2] + mov di, dx + mov dx, si + mov al, [si] +strLoop: +repne ; scasb + jnz strNotFound + push cx + push di + dec di + mov cx, [bp][len2] +repe ; cmpsb + pop di + pop cx + je strFound + mov si, dx + jmp strLoop +strNotFound: + sub ax, ax + jmp strFinish +strFound: + mov ax, di + dec ax +strFinish: + pop si + pop di + pop dx + pop cx + mov sp, bp + pop bp + ret 0 + +s2Null: + mov ax, [bp][s1] + jmp strFinish + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _strupr : + +(* +char *strupr(char *s) + +converts lower case characters to upper case. +returns s. +*) + + push bx + push cx + push di + push si + mov si, ax + mov di, ax + mov bx, ax + mov cx, 0FFFFH +uprLoop: + lodsb + or al, al + je uprDone (* end of string Found *) + cmp al, 'z' (* change if lower *) + ja uprNoChange + cmp al, 'a' + jb uprNoChange + sub al, 20H (* convert to upper *) +uprNoChange: + stosb + loop uprLoop +uprDone: (* return address of string *) + mov ax, bx + pop si + pop di + pop cx + pop bx + ret 0 + +(***************************************************************************) + +section + +segment _TEXT(CODE,28H) + + +public _memcpy : + +(* +void *memcpy(void *dest, void *source, unsigned num) + +Copies num bytes from source to dest (Does not handle any overlap). +Returns destination address. +*) + + push di + push si + mov si, bx + mov di, ax + jcxz noMove + test al, 1 + jz evenAdd (* word align *) + movsb + dec cx +evenAdd: + shr cx, 1 +rep ; movsw (* move words *) + adc cx, cx +rep ; movsb (* move odd byte *) +noMove: + pop si + pop di + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memccpy : + +(* +void *memccpy(void *dest, void *source, unsigned char c, unsigned num) + +Copying stops after copying c or after num bytes. +returns destination address. +*) + + push dx + push di + push si + mov si, bx + mov di, ax + xchg cx, dx + jcxz ccpyDone +ccpyLoop: + lodsb (* use lods/stos to get byte in al for compare *) + stosb + cmp al, dl (* faster than movs + reg/mem cmp *) + je ccpyDone + loop ccpyLoop + sub ax, ax + jmp ccopyExit +ccpyDone: + mov ax, di +ccopyExit: + pop si + pop di + pop dx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memchr : + +(* +void *memchr(void *s, char c, unsigned num) + +searches num bytes for c. +returns source address. +*) + + + push di + mov di, ax + mov al, bl + jcxz chrFound +repne ; scasb + je chrFound + sub ax, ax (* not found - return value NULL *) + jmp chrDone +chrFound: + dec di (* found - return address. *) + mov ax, di +chrDone: + pop di + ret 0 + + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memset : + +(* +void *memset(void *s, char c, unsigned num) + +Sets num bytes to c. +Returns buffer address. +*) + + push dx + push di + mov di, ax + mov dx, ax + mov al, bl + jcxz noMove + mov ah, al + test di, 1 + jz evenAdd + stosb (* word align *) + dec cx +evenAdd: + shr cx, 1 +rep ; stosw (* move words *) + adc cx, cx +rep ; stosb (* move odd byte *) +noMove: + mov ax, dx + pop di + pop dx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memcmp : +(* +int memcmp(void *s1, void *s2, unsigned num) + +Performs unsigned comparison of s1 and s2 and returns < 0 if s1 0 if s1 > s2. +*) + + push di + push si + mov si, ax + mov di, bx + sub ax, ax (* same - return value is 0 *) + jcxz cmpDone +repe ; cmpsb (* compare *) + jz cmpDone + sbb ax, ax + sbb ax, -1 +cmpDone: + pop si + pop di + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memicmp : + +(* +int memicmp(void *s1, void *s2, unsigned num) + +Performs case insensitive comparison of s1 and s2, returning < 0 if s1 0 if s1 > s2. +*) + + push di + push si + mov si, ax + mov di, bx + sub ax, ax + jcxz icmpSame +icmpLoop: + lodsb + cmp al, 'z' (* if lower convert to upper *) + ja inotlowa + cmp al, 'a' + jb inotlowa + sub al, 20H +inotlowa: + mov bl, [di] + inc di + cmp bl, 'z' (* if lower convert to upper *) + ja inotlowb + cmp bl, 'a' + jb inotlowb + sub bl, 20H +inotlowb: + sub al, bl + jne icmpDifferent + loop icmpLoop + sub ax, ax + jmp icmpSame +icmpDifferent: + mov al, 0 + sbb al, al + sbb al, -1 + cbw +icmpSame: + pop si + pop di + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memwset : + +(* +void *memwset(void *s, char c, unsigned num) + +Sets num words to c. +Returns buffer address. +*) + + push dx + push di + mov di, ax + mov ax, bx + mov dx, di +rep ; stosw + mov ax, dx + pop di + pop dx + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _memwcpy : + +(* +void *memwcpy(void *dest, void *source, unsigned num) + +Copies num words form source to dest (Does not handle overlap). +Returns destination address. +*) + + push di + push si + mov si, bx + mov di, ax +rep ; movsw + pop si + pop di + ret 0 + +(*****************************************************************************) +section +segment _TEXT(CODE,28H) + +public _setmem : + +(* +void setmem(void *s, unsigned num, char c) + +ets num bytes to c. +Returns nothing. +*) + + + push di + mov di, ax + mov al, cl + mov cx, bx +(*%E *) + jcxz noMove + mov ah, al + test di, 1 + jz evenAdd + stosb + dec cx (* word align *) +evenAdd: + shr cx, 1 +rep ; stosw (* move words *) + adc cx, cx +rep ; stosb (* move odd byte *) +noMove: + pop di + ret 0 + +end + + + diff --git a/code/SIBOSDK/src/csys.c b/code/SIBOSDK/src/csys.c new file mode 100644 index 0000000..373029b --- /dev/null +++ b/code/SIBOSDK/src/csys.c @@ -0,0 +1,437 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* csys.c - common system functions. * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* Written by Simon Knight. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Modified by NSM. * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_CONIO +#define _USE_TIME +#include + +/*-------------------------------------------------------------------------* +* exit functions - terminate process after closing open files. * +*--------------------------------------------------------------------------*/ + +void _exit1(void) +{ + int n; + + _flushall(); + n=0; + while(n < _open_max) + { + if(_openfd[n]) + close(n); + n++; + } + return; +} + +void _exit2(void) +{ + int n; + char *tmp; + + n=0; + while (n < _open_max) + { + if ((tmp=_tmpfiles[n])!=NULL) + { + if(_openfd[n]) + close(n); + unlink(tmp); + } + n++; + } + return; +} + +/*-------------------------------------------------------------------------* +* abort - print message and raise ABORT signal. * +*--------------------------------------------------------------------------*/ + +void abort(void) +{ + fputs("Abnormal Program Termination\n", stderr); + raise(SIGABRT); + return; +} + +/*-------------------------------------------------------------------------* +* atexit - put function pointer on stack to be called by exit. * +*--------------------------------------------------------------------------*/ + +int atexit(void (* func)(void)) +{ + int ret; + + if(_exit_ptr != _exit_stk) /* return if stack full */ + { + *(--_exit_ptr)=func; /* push func */ + ret=0; + } + else + ret=-1; + return(ret); +} + +/*-------------------------------------------------------------------------* +* onexit - put function pointer on stack to be called by exit. * +*--------------------------------------------------------------------------*/ + +void (* onexit(void (* func)(void)))() +{ + void (* ret)(void); + + if(_exit_ptr != _exit_stk) /* return if stack full */ + { + *(--_exit_ptr)=func; /* push func */ + ret=func; + } + else + ret=NULL; + return(ret); +} + +/*-------------------------------------------------------------------------* +* system - execute command.com. * +*--------------------------------------------------------------------------*/ + +int system(const char *command) +{ + char *compath; + + compath=getenv("COMSPEC"); /* use COMSPEC to find command.com */ + if(compath == NULL) + compath="ROM::SYS$SHLL"; + if(command == NULL) + { + if(!_exists(compath)) /* does file exist ? */ + { + errno=ENOENT; + return(0); + } + return(1); + } + flushall(); /* flush open streams */ + return(spawnl(P_WAIT,compath,"",command,NULL)); +} + +/*-------------------------------------------------------------------------* +* exec?? - execute child process. * +*--------------------------------------------------------------------------*/ + +#pragma warn(wpnu => off) + +int execl(const char *path, char *arg0, ...) +{ + va_list argptr; + + va_start(argptr, path); + return(_execc(path, (char **) argptr, _E_EXEC)); +} + +int execlp(const char *path, char *arg0, ...) +{ + va_list argptr; + + va_start(argptr, path); + return(_execc(path, (char **) argptr, _E_EXEC|_E_SEARCH)); +} + +int execv(const char *path, char *argv[]) +{ + return(_execc(path, argv, _E_EXEC)); +} + +int execvp(const char *path, char *argv[]) +{ + return(_execc(path, argv, _E_EXEC|_E_SEARCH)); +} + +/*-------------------------------------------------------------------------* +* spawn?? - spawn child process. * +*--------------------------------------------------------------------------*/ + +int spawnl(int mode, const char *path, char *arg0, ...) +{ + va_list argptr; + + va_start(argptr, path); + return(_execc(path, (char **) argptr, mode)); +} + +int spawnlp(int mode, const char *path, char *arg0, ...) +{ + va_list argptr; + + va_start(argptr, path); + return(_execc(path, (char **) argptr, mode|_E_SEARCH)); +} + +int spawnv(int mode, const char *path, char *argv[]) + +{ + return(_execc(path, argv, mode)); +} + +#pragma warn(wpnu => on) + +int spawnvp(int mode, const char *path, char *argv[]) +{ + return(_execc(path, argv, mode|_E_SEARCH)); +} + +/*-------------------------------------------------------------------------* +* searchenv - find file using environment string * +*--------------------------------------------------------------------------*/ + +void _searchenv(const char *name, const char *env, char *path) +{ + char *envpath; + int n, p, c; + int length; + + if((envpath=getenv(env)) == NULL) + { + path[0]=0; + return; + } + length=strlen(name)+1; + getcwd(path, 0x80); /* try current directory */ + n=strlen(path); + path[n++]='\\'; + memcpy(&path[n], name, length); + if(_exists(path)) + { + return; /* found it already */ + } + n=0; + p=0; + do /* search each path */ + { + while((c=envpath[n++]) && (c != ';')) + { + path[p++]= (char) c; + } + if(path[p-1] != '\\') + path[p++]='\\'; + memcpy(&path[p], name, length); + if(_exists(path)) + { + return; /* found it */ + } + p=0; + } while (envpath[n-1]); + path[0]=0; /* couldn't find file */ + return; +} + +void sleep(unsigned seconds) +{ + _sleepTenths(seconds*10l); +} + +static void call_test1(void) +{ + calloc(0, 0); + free(NULL); + malloc(0); + realloc(NULL, 0); + _ncalloc(0, 0); + _nfree(NULL); + _nmalloc(0); + _nrealloc(NULL, 0); + + _msize(NULL); + _memmax(); + _memavl(); + _heapchk(); + _heapset(0); + _heapwalk(NULL); + coreleft(); + _freect(0); + + _nheapchk(); + _nheapset(0); + _nheapwalk(NULL); + _nmsize(NULL); + nearcoreleft(); +} + +static void call_test3(void) +{ + cgets(NULL); + cputs(NULL); + getch(); + getche(); + kbhit(); + putch(0); + ungetch(0); +} + +static void call_test4(void) +{ + chdir(NULL); + getcurdir(0, NULL); + getcwd(NULL, 0); + _getdrive(); + mkdir(NULL); + rmdir(NULL); + + getdisk(); + searchpath(NULL); + setdisk(0); +} + +static void call_test6(void) +{ + access(NULL, 0); + chmod(NULL, 0); + chsize(0, 0L); +} + +static void call_test7(void) +{ + abs(0); + acos(0.0); + asin(0.0); + atan(0.0); + atan2(0.0, 0.0); + atof(NULL); + ceil(0.0); + cos(0.0); + cosh(0.0); + exp(0.0); + fabs(0.0); + floor(0.0); + fmod(0.0, 0.0); + frexp(0.0, NULL); + labs(0L); + ldexp(0.0, 0); + log(0.0); + log10(0.0); + modf(0.0, NULL); + poly(0.0, 0, NULL); + pow(0.0, 0.0); + sin(0.0); + sinh(0.0); + sqrt(0.0); + strtod(NULL, NULL); + tan(0.0); + tanh(0.0); + matherr(NULL); + hypot(0.0, 0.0); + pow10(0); + _fpreset(); +} + +static void call_test8(void) +{ + void *ptr=NULL; + + memccpy(ptr, ptr, 0, 0); + memchr(ptr, 0, 0); + memcmp(ptr, ptr, 0); + memcpy(ptr, ptr, 0); + memicmp(ptr, ptr, 0); + memmove(ptr, ptr, 0); + memset(ptr, 0, 0); + movmem(ptr, ptr, 0); + setmem(ptr, 0, 0); + + memwmove(ptr, ptr, 0); + memwset(ptr, 0, 0); + memwcpy(ptr, ptr, 0); +} + +static void call_test9(void) +{ + signal(0, NULL); + raise(0); +} + +static void call_test10(void) +{ + fgetc(NULL); + fputc(0, NULL); + rename(NULL, NULL); + unlink(NULL); +} + +static void call_test11(void) +{ + delay(0); + getenv(NULL); + mblen(NULL, 0); + mbtowc(NULL, NULL, 0); + wctomb(NULL, 0); + mbstowcs(NULL, NULL, 0); + wcstombs(NULL, NULL, 0); + ecvt(0.0, 0, NULL, NULL); + _exit(0); + fcvt(0.0, 0, NULL, NULL); + gcvt(0.0, 0, NULL); + itoa(0, NULL, 0); + _lrotl(0L, 0); + _lrotr(0L, 0); + ltoa(0L, NULL, 0); + _searchenv(NULL, NULL, NULL); + _rotl(0, 0); + _rotr(0, 0); + swab(NULL, NULL, 0); + ultoa(0L, NULL, 0); +} + +static void call_test12(void) +{ + void *ptr=NULL; + + strcat(ptr, ptr); + strcmp(ptr, ptr); + strcpy(ptr, ptr); + strlen(ptr); + strset(ptr, 0); + stpcpy(ptr, ptr); + strchr(ptr, 0); + strcoll(ptr, ptr); + strxfrm(ptr, ptr, 0); + strcspn(ptr, ptr); + strdup(ptr); + strerror(0); + stricmp(ptr, ptr); + strlwr(ptr); + strncat(ptr, ptr, 0); + strncmp(ptr, ptr, 0); + strncpy(ptr, ptr, 0); + strnicmp(ptr, ptr, 0); + strnset(ptr, 0, 0); + strpbrk(ptr, ptr); + strrchr(ptr, 0); + strrev(ptr); + strspn(ptr, ptr); + strstr(ptr, ptr); + strtok(ptr, ptr); + strupr(ptr); +} + +static void call_test13(void) +{ + settime(NULL); + gettime(NULL); + setdate(NULL); + getdate(NULL); + utime(NULL, NULL); + get_utime(0); + _filetime(0, NULL); +} + + \ No newline at end of file diff --git a/code/SIBOSDK/src/epoc.a b/code/SIBOSDK/src/epoc.a new file mode 100644 index 0000000..6485729 --- /dev/null +++ b/code/SIBOSDK/src/epoc.a @@ -0,0 +1,751 @@ +(* *) +(* Release 3.00 *) +(* *) +(* Epoc/Os - Interface routines *) +(* *) +(* Copyright (C) 1991 Psion PLC. All Rights Reserved *) +(* Written by NSM. *) +(* *) +(************************************************************************) + +include "corelib.inc" +include "epocdefs.inc" + +module Epoc + +(***************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +__ServerName: db "SYS$FSRV.*",0 +__FileDevName: db "FIL",0 + +segment _BSS(BSS,28H) + +public __FServerPid : org 2 (* File server process id *) +public __FilDeviceHandle : org 2 (* File device driver handle *) + +select _TEXT + +public __EpocInit : + + sub al, al + mov ah, NmFilConnect + int FilManager + sub bx, bx + sub sp, MaxNameESize + 2 + mov si, sp + mov di, __ServerName + mov ah, NmProcFind + int ProcManager + mov [__FServerPid], ax + sub bx, bx + mov dx, LDDSignature + mov di, __FileDevName + mov si, sp + mov ah, NmDevFind + int DevManager + mov [__FilDeviceHandle], ax + add sp, MaxNameESize + 2 + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public __allocInfo : + + push ax + push bx + push di + push si + mov si, ax (* Arg 1 *) + mov ah, NmProcId + int ProcManager + mov di, ax + int GenDataSegment + and di, PidMask + mov ax, es:[di][ProcMemBasePtr] + test ax, ax + je infoExit + mov [bx], ax + add ax, MemEnt + mov [si], ax +infoExit: + pushf + cli + mov bx, ss + mov es, bx + popf + pop si + pop di + pop bx + pop ax + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +select _TEXT + + +public __heapTop : + + push bx + mov ah, NmProcId + int ProcManager + mov bx, ax + and bx, PidMask + int GenDataSegment + mov bx, es:[bx][ProcDataSeg] + pushf + cli + mov ax, es:[bx][SegEnt][SegBase] + sub ax, es:[bx][SegBase] + mov bx, ss + mov es, bx + popf + shl ax, 1 + shl ax, 1 + shl ax, 1 + shl ax, 1 + pop bx + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public _getpid : + + mov ah, NmProcId + int ProcManager + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public __getDateAndTime : + + pop ax + sub sp, DateEnt + mov si, sp + sub sp, DyScEnt + mov di, sp + push ax + push bx + mov ah, NmTimGetSystemTime + int TimManager + push cx + push dx + mov cx, ax + mov dx, bx + mov ah, NmTimSystemTimeToDaySeconds + int TimManager + pop dx + pop cx + xchg di, si + mov ah, NmTimDaySecondsToDate + int TimManager + pop bx + ret 0 + +(***************************************************************************) +section +segment _TEXT(CODE,28H) + +public __setDateAndTime : + + lea si, [di][-DyScEnt] + xchg si, di + mov ah, NmTimDateToDaySeconds + int TimManager + xchg si, di + mov ah, NmTimDaySecondsToSystemTime + int TimManager + push bx + push cx + push dx + mov cx, ax + mov dx, bx + mov ah, NmTimSetSystemTime + int TimManager + pop dx + pop cx + pop bx + ret 0 + +(****************************************************************************) +section +segment _TEXT(CODE,28H) + +(* WORDREGS Structure *) + +_ax = 0 +_bx = 2 +_cx = 4 +_dx = 6 +_si = 8 +_di = 10 +_cflag = 12 +_flags = 14 + +extrn __ioerr + +public _int86x : +public _int86 : +(* +int int86(int intnum, union REGS *inregs, union REGS *outregs) +loads 086 registers and executes interrupt. AX value is returned. If the +carry flag is set cflag is !=0 and _doserrno is set to the error code. +*) + + push di + push si + mov si, bx + mov di, cx + int GenIntByNumber + mov [di][_flags], ax + mov word [di][_cflag], 0 + jnc noCarry + inc word [di][_cflag] + mov ax, [di][_ax] + call __ioerr +noCarry: + mov ax, [di][_ax] + pop si + pop di + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public _intr : + +(* REGPACK Structure *) + +r_ax = 0 +r_bx = 2 +r_cx = 4 +r_dx = 6 +r_bp = 8 +r_si = 10 +r_di = 12 +r_ds = 14 +r_es = 16 +r_flags = 18 + + push ax + push bx + push di + push si + mov si, bx + mov di, bx + mov bx, [si][r_si] + xchg bx, [si][r_bp] + xchg bx, [si][r_di] + mov [si][r_di], bx + int GenIntByNumber + mov [di][r_flags], ax + mov ax, [di][r_di] + xchg ax, [di][r_bp] + xchg ax, [di][r_si] + mov [di][r_di], bx + pop si + pop di + pop bx + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __iopen : + + push dx + push di + mov di, ax + sub dx, dx + mov ah, NmIoOpen + int DevManager + jc openFailed + mov [di], ax + sub al, al +openFailed: + cbw + pop di + pop dx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __iow2 : +public __iow3 : +public __iow4 : + + xchg ax, bx + mov ah, NmIoWithWait + int IoManager + jnc iowOk + cbw +iowOk: + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __parse : + + push di + push si + mov si, dx + mov di, cx + mov cx, bx + mov bx, ax + sub al, al + mov ah, NmFilParse + int FilManager + jc parseFailed + sub al, al +parseFailed: + cbw + pop si + pop di + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +DaySeconds = -DyScEnt +DateF = -(DyScEnt+DateEnt) +locals = (DyScEnt+DateEnt) + +public __convTimeToDos : + + push di + push si + push dx + push cx + push bp + mov bp, sp + sub sp, locals + mov cx, bx + mov dx, ax + mov ax, cx + cmp dh, 0A6H + sbb ax, 012CEH + jnc timeOk + mov cx, 012CEH + mov dx, 0A600H +timeOk: + lea di, [bp][DaySeconds] + mov ah, NmTimSystemTimeToDaySeconds + int TimManager + mov si, di + lea di, [bp][DateF] + mov ah, NmTimDaySecondsToDate + int TimManager + xor ah, ah + mov al, [di][DateHour] + mov cx, 6 + shl ax, cl + or al, [di][DateMinute] + dec cx + shl ax, cl + mov bl, [di][DateSecond] + shr bl, 1 + or al, bl + xor dh, dh + mov dl, [di][DateYear] + sub dl, 80 + mov cx, 4 + shl dx, cl + or dl, [di][DateMonth] + inc dx + inc cx + shl dx, cl + or dl, [di][DateDay] + inc dx + add sp, locals + pop bp + pop cx + mov di, cx + mov [di], dx + pop dx + mov di, dx + mov [di], ax + pop si + pop di + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __FServerPid +extrn __FilDeviceHandle + +select _TEXT + +public __FsChanToName : + + push ax + push bx + push cx + push di + push si + push bx + push si + mov di, sp + mov si, ax + mov ax, [__FilDeviceHandle] + cmp [si][ChanLibHandle], ax + je isAFileHandle + pop si + pop di + and byte [di], 0 + jmp chanExit +isAFileHandle: + mov si, [si][FilHandle] + add si, FsyFileName + mov bx, [__FServerPid] + mov cx, 2 + int ProcCopyFromById + pop si + pop di + mov cx, MaxPathSize + int ProcCopyFromById +chanExit: + pop si + pop di + pop cx + pop bx + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +extrn __FServerPid +extrn __FilDeviceHandle + +select _TEXT + +public __FsChanToMode : + + push bx + push cx + push di + push si + mov di, sp + mov si, ax + mov ax, [__FilDeviceHandle] + cmp [si][ChanLibHandle], ax + mov ax, -1 + jne modeExit + push ax + mov di, sp + mov si, [si][FilHandle] + add si, FsyFileMode + mov bx, [__FServerPid] + mov cx, 2 + int ProcCopyFromById + pop ax +modeExit: + pop si + pop di + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __systemTimeToDaySeconds : + + push ax + push cx + push dx + push di + mov di, cx + mov dx, ax + mov cx, bx + mov ah, NmTimSystemTimeToDaySeconds + int TimManager + pop di + pop dx + pop cx + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __daySecondsToSystemTime : + + push bx + push si + mov si, ax + mov ah, NmTimDaySecondsToSystemTime + int TimManager + mov dx, ax + mov ax, bx + pop si + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __daySecondsToDate : + + push ax + push di + push si + mov si, ax + mov di, bx + mov ah, NmTimDaySecondsToDate + int TimManager + pop si + pop di + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __dateToDaySeconds : + + push di + push si + mov si, ax + mov di, bx + mov ah, NmTimDateToDaySeconds + int TimManager + mov ax, 0 + jnc convOk + dec ax +convOk: + pop si + pop di + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __date : + + push bx + mov ah, NmTimGetSystemTime + int TimManager + mov dx, ax + mov ax, bx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __fileInfo : + + push bx + push cx + mov cx, bx + mov bx, ax + sub al, al + mov ah, NmFilStatusGet + int FilManager + jc gotFailed + sub al, al +gotFailed: + cbw + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __fileSetModTime : + + push bx + push cx + push di + mov di, cx + mov cx, bx + mov bx, ax + sub al, al + mov ah, NmFilSetFileDate + int FilManager + jc setFailed + sub al, al +setFailed: + cbw + pop di + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __getPath : + + push ax + push bx + mov bx, ax + sub al, al + mov ah, NmFilPathGet + int FilManager + pop bx + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __setPath : + + push ax + push bx + mov bx, ax + sub al, al + mov ah, NmFilPathSet + int FilManager + jc setFailed + sub al, al +setFailed: + cbw + pop bx + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __sleepTenths : + + push ax + push cx + push dx + mov dx, ax + mov cx, bx + mov ah, NmTimSleepForTenths + int TimManager + pop dx + pop cx + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public ___execc : + + push bx + push cx + push di + push ax + mov di, sp + mov cx, bx + mov bx, ax + sub al, al + mov ah, NmFilExecute + int FilManager + jnc gotHandle + cbw + mov [di], ax +gotHandle: + pop ax + pop di + pop cx + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __logon : + + push bx + push di + mov di, bx + mov bx, ax + mov ah, NmIoSignalKillAsynchronous + int IoManager + jc logonFailed + sub al, al +logonFailed: + cbw + pop di + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __waitStat : + + push ax + push di + mov di, ax + mov ah, NmIoWaitForStatus + int IoManager + pop di + pop ax + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __resume : + + push bx + mov bx, ax + mov ah, NmProcResume + int ProcManager + jc resFailed + sub al, al +resFailed: + cbw + pop bx + ret 0 + +(******************************************************************************) +section +segment _TEXT(CODE,28H) + +public __getErrorText : + + mov ah, NmGenGetErrorText + int GenManager + mov ax, bx + ret 0 + +end diff --git a/code/SIBOSDK/src/epoc1.c b/code/SIBOSDK/src/epoc1.c new file mode 100644 index 0000000..dbb11b3 --- /dev/null +++ b/code/SIBOSDK/src/epoc1.c @@ -0,0 +1,744 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* Epoc1.c - Epoc/Os interface routines * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Written by NSM. * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_CONIO +#define _USE_TIME +#include + +#define SZMBLK sizeof(_MBLOCK) /* size of free cell header */ +#define SZHD sizeof(unsigned int) /* size of allocated cell header */ + +extern char DatHeapLocked; + +int _nheapwalk(struct _nheapinfo *pE) +/* +Walks through every cell in the heap (whether allocated +or free) from low to high address. Also checks the heap +for consistency and returns an error if something is wrong. +*/ + { + int ret; + _MBLOCK *p1,*p2; + + ret=_HEAPOK; + DatHeapLocked++; + if (pE->_pentry==NULL) + { + if (_allocInfo(&p1,&p2)==0) + { + ret=_HEAPEMPTY; + goto walkExit; + } + goto advanceFreePtr; + } + else + { + if (pE->_useflag) /* Was allocated */ + { + p1=(_MBLOCK *)(((char *)pE->_pentry)-SZHD); + p2=pE->_secret; + } + else /* Was free */ + { + p2=(_MBLOCK *)(((char *)pE->_pentry)-SZMBLK); + p1=pE->_secret; + } + if (p1mlen); + else /* Free cell is before allocated cell */ + { +advanceFreePtr: + p2=p2->mnext; /* Points to first free cell */ + if (p2!=NULL && + ((((int)p2)&1) || (p2>_heapTop()-1) || + (p2->mnext && p2->mnextmlenmlen&1) || + p1->mlen>((char *)p2-(char *)p1)) + { +badNode: + ret=_HEAPBADNODE; + } + pE->_pentry=(int *)(((char *)p1)+SZHD); + pE->_size=p1->mlen-SZHD; + pE->_secret=p2; + pE->_useflag=1; + } + else if (p2) + { + p1=(_MBLOCK *)(((char *)p2)+p2->mlen); /* next allocated cell */ +returnFree: + pE->_pentry=(int *)(((char *)p2)+SZMBLK); + pE->_size=p2->mlen-SZMBLK; + pE->_secret=p1; + pE->_useflag=0; + } + else if (_heapTop()!=p1) + goto badNode; + else + ret=_HEAPEND; +walkExit: + DatHeapLocked--; + return(ret); + } + +static int heapDoIt(int flag,int fill) +/* +Actually does _nheapchk() and _nheapset(). +*/ + { + int ret; + struct _nheapinfo hi; + + hi._pentry=NULL; + while ((ret=_nheapwalk(&hi))==_HEAPOK) + { + if (flag && hi._useflag==0) + memset(hi._pentry,(char)fill,hi._size); + } + if (ret==_HEAPEND) + ret=_HEAPOK; + return(ret); + } + +int _nheapchk(void) +/* +Check the entire heap for consistency. +*/ + { + + return(heapDoIt(0,0)); + } + +int _nheapset(int fill) +/* +Check the entire heap for consistency and fill all +free cells with fill as we go along. +*/ + { + + return(heapDoIt(1,fill)); + } + +size_t _memmax(void) +/* +Returns the size of the biggest free cell. +*/ + { + size_t ret,i; + _MBLOCK *p1,*p2; + + ret=0; + DatHeapLocked++; + if (_allocInfo(&p1,&p2)==0) + goto memExit; + while ((p2=p2->mnext)!=NULL) /* Scan free cells */ + { + i=p2->mlen-sizeof(unsigned int); + if (i>ret) + ret=i; + } + i=(unsigned int)0xfe00-(unsigned int)_heapTop()-sizeof(unsigned int); + if (i>ret) + ret=i; +memExit: + DatHeapLocked--; + return(ret); + } + +static unsigned int memCalc(unsigned int num,unsigned int den) +/* +Works out how many times den will fit into num, where num is +the size of a free block in the heap. +*/ + { + unsigned int ret; + + num-=sizeof(unsigned int); + ret=num/den; + if (ret && (num%den)mnext)!=NULL) /* Scan free cells */ + ret+=memCalc(p2->mlen,_size); + ret+=memCalc((unsigned int)0xfe00-(unsigned int)_heapTop(),_size); +freeExit: + DatHeapLocked--; + return(ret); + } + +char *_d_cgets(char *s) +/* +Read a string of characters directly from the console. +*/ + { + int i,c,maxLen,ql; + char *p,*q; + static char _b1[] = {'\b',' ','\b'}; + static char _b2[] = {'\b','\b',' ',' ','\b','\b'}; + static char _cr[] = {'\r'}; + + maxLen=(s[0]&0xff); + p=(&s[2]); + i=0; + while ((c=getch())!='\r') + { + if (c=='\b') + { + if (i) + { + i--; + if (p[i]<' ') + { + q=(&_b2[0]); + ql=sizeof(_b2); + } + else + { + q=(&_b1[0]); + ql=sizeof(_b1); + } + _iow4(winHandle,P_FWRITE,q,&ql); + } + } + else if (iff_reserved[0]; + r->handle=h; + r->ctl=_dNext; + r->magic=_dctl[_dNext].magic; + r->attrib=(attrib&0xff); + r->first=ENOENT; + _dctl[_dNext++].handle=h; + if (_dNext>=MAXD) + _dNext=0; + return(findnext(b)); +} + +int findnext(struct ffblk *b) +/* +Find the next directory entry. +*/ + { + int a; + _DRES *r; + P_INFO f; + + r=(_DRES *)&b->ff_reserved[0]; + if (_dctl[r->ctl].magic!=r->magic) + { +failed: + errno=(r->first ? ENOENT : ENMFILE); + return(-1); + } + do + { + if ((a=_iow4(r->handle,P_FREAD,&b->ff_name[0],&f))<0) + { + _iow2(r->handle,P_FCLOSE); + _dctl[r->ctl].handle=0; + _dctl[r->ctl].magic++; + _ioerr(a); + return(-1); + } + a=f.status&(FA_HIDDEN|FA_SYSTEM|FA_LABEL|FA_DIREC); + } while (a && (a&r->attrib)==0); + b->ff_attrib=(f.status&0xff)^1; + b->ff_fsize=f.size; + _convTimeToDos(f.modst,&b->ff_fdate,&b->ff_ftime); + return(0); + } + +int utime(char *path,struct utm *ftime) +/* +Set the modification time of a file. +*/ + { + INT ret; + P_DATE dt; + P_DAYSEC ds; + time_t t; + + if (ftime) + { + dt.year=ftime->u_year+80; + dt.month=ftime->u_mon-1; + dt.day=ftime->u_day-1; + dt.hour=ftime->u_hour; + dt.minute=ftime->u_min; + dt.second=ftime->u_sec; + _dateToDaySeconds(&dt,&ds); + t=_daySecondsToSystemTime(&ds); + } + else + t=_date(); + if ((ret=_fileSetModTime(path,t))<0) + { + _ioerr(ret); + return(-1); + } + return(0); + } + +int _filetime(int handle,struct utm *ftime) +/* +Get the modified time of the file open on handle. +*/ + { + int ret; + char name[P_FNAMESIZE]; + P_DAYSEC ds; + P_DATE dt; + P_INFO pI; + + _FsChanToName(getRealHandle(handle),&name[0]); + if (name[0]) + { + if ((ret=_fileInfo(&name[0],&pI))<0) + { + _ioerr(ret); + return(-1); + } + _systemTimeToDaySeconds((time_t)pI.modst,&ds); + _daySecondsToDate(&ds,&dt); + if (dt.year<80) + goto baseDate; + } + else + { +baseDate: + memset(&dt,0,sizeof(dt)); + dt.year=80; + } + ftime->u_year=dt.year-80; + ftime->u_mon=dt.month+1; + ftime->u_day=dt.day+1; + ftime->u_hour=dt.hour; + ftime->u_min=dt.minute; + ftime->u_sec=dt.second; + return(0); + } + +int _filedrive(int handle) +/* +Return the drive letter if on LOC:: file system. +*/ + { + char name[P_FNAMESIZE]; + + _FsChanToName(getRealHandle(handle),&name[0]); + if (name[0] && memcmp("LOC",&_pname[0],3)==0) + return(name[5]-'A'); + return(0); + } + +int _execc(const char *path, char **argv, int mode) +/* +Generalised exec call. +*/ + { + int pid; + WORD stat; + char *p,*pe,*s,name[P_FNAMESIZE],command[0x80]; + + if (mode&_E_SEARCH) + { + mode&=(~_E_SEARCH); + if (_parse(path,".img",&_pname[0],&_pinfo)<0) + { + errno=EINVAL; + return(-1); + } + _searchenv(&_pname[_pinfo.system+_pinfo.device+_pinfo.path],"PATH",&name[0]); + if (name[0]==0) + { + errno=ENOENT; + return(-1); + } + } + else + strcpy(&name[0],path); + argv++; + p=(&command[0]); + pe=p+0x7f; + while (*argv) + { + *p++=' '; + s=(*argv++); + while (p=pe) + { + errno=E2BIG; + return(-1); + } + } + *p++=0; + command[0]=p-(&command[1]); + if ((pid=__execc(&name[0],&command[0]))<0) + { + _ioerr(pid); + return(-1); + } + if (mode&_E_EXEC || mode==P_OVERLAY) + { + _resume(pid); + exit(0); + } + if (mode==P_NOWAIT) + { + _resume(pid); + return(pid); + } + _logon(pid,&stat); + _resume(pid); + _waitStat(&stat); + return(stat); + } + +int getdisk(void) +/* +Get the current disk. +*/ + { + + _getPath(&_pname[0]); + if (!_isloc(&_pname[0])) + return(0); + return(_pname[5]-'A'); + } + +int setdisk(int drive) +/* +Set the current disk. +*/ + { + void *h; + + _getPath(&_pname[0]); + if (!_isloc(&_pname[0])) + return(0); + _pname[5]='A'+drive; + _setPath(&_pname[0]); + _iopen(&h,"LOC::",P_FDEVICE); + drive=0; + while (_iow3(h,P_FREAD,&_pname[0])>=0) + drive++; + _iow2(h,P_FCLOSE); + return(drive); + } + +int getftime(int handle,struct ftime *f) +/* +Get the file time from and open file. +*/ + { + int ret; + struct utm ftime; + + if ((ret=_filetime(handle, &ftime))<0) + return(ret); + f->ft_tsec = (unsigned) (ftime.u_sec>>1); + f->ft_min = (unsigned) ftime.u_min; + f->ft_hour= (unsigned) ftime.u_hour; + f->ft_day= (unsigned) ftime.u_day; + f->ft_month= (unsigned) ftime.u_mon; + f->ft_year=ftime.u_year+1980; + return(0); + } + +long _lseek(void *handle, long offset, int where) +/* +Seek on a file by handle. +*/ + { + int ret,mode; + long endPos,newPos; + + switch (where) + { + case SEEK_CUR: + mode=P_FCUR; + goto doSeek; + case SEEK_END: + mode=P_FEND; +doSeek: + newPos=0l; + _iow4(handle,P_FSEEK,&mode,&newPos); + newPos+=offset; + break; + case SEEK_SET: + newPos=offset; + } + if (newPos<0) + newPos=0; + endPos=newPos; + mode=P_FABS; + if ((ret=_iow4(handle,P_FSEEK,&mode,&newPos))<0) + goto failed; + if (newPos!=endPos) + { + newPos=endPos; + if (_FsChanToMode(handle)&P_FUPDATE) + { + if ((ret=_iow3(handle,P_FSETEOF,&newPos))<0) + goto failed; + if ((ret=_iow4(handle,P_FSEEK,&mode,&newPos))<0) + { +failed: + _ioerr(ret); + return(-1); + } + } + } + return(newPos); + } + +void gotoxy(int x, int y) +/* +Position the consol channel. +*/ + { + UWORD mode; + P_POINT p; + + p.x=x-1; + p.y=y-1; + mode=P_SCR_POSA; + _iow4(winHandle,P_FSET,&mode,&p); + } + +int wherex(void) +/* +Return the X cursor position. +*/ + { + P_RECTP rp; + + _iow3(winHandle,P_FSENSE,&rp); + return(rp.p.x+1); + } + +int wherey(void) +/* +Return the Y cursor position. +*/ + { + P_RECTP rp; + + _iow3(winHandle,P_FSENSE,&rp); + return(rp.p.y+1); + } + +void clrscr(void) +/* +Clear the screen. +*/ + { + UWORD mode; + P_RECTP rp; + + _iow3(winHandle,P_FSENSE,&rp); + mode=P_SCR_CLR; + _iow4(winHandle,P_FSET,&mode,&rp.r); + gotoxy(1,1); + } + +void cursoron(void) +/* +Switch the cursor on. +*/ + { + UWORD mode,flag; + + flag=TRUE; + mode=P_SCR_CURSOR; + _iow4(winHandle,P_FSET,&mode,&flag); + } + +void cursoroff(void) +/* +Switch the cursor off. +*/ + { + UWORD mode,flag; + + flag=FALSE; + mode=P_SCR_CURSOR; + _iow4(winHandle,P_FSET,&mode,&flag); + } + +void setwrap(int flag) +/* +Switch the wrap mode. +*/ + { + UWORD mode; + + flag=(flag ? 1 : 0); + mode=P_SCR_WLOCK; + _iow4(winHandle,P_FSET,&mode,&flag); + } + +static void xLine(int flag) +/* +Insert or delete the line containg the cursor. +*/ + { + UWORD mode; + P_RECTP rp; + + _iow3(winHandle,P_FSENSE,&rp); + rp.r.tl.x=0; + rp.r.tl.y=rp.p.y; + rp.p.x=0; + rp.p.y=flag; + mode=P_SCR_SCROLL; + _iow4(winHandle,P_FSET,&mode,&rp); + } + +void insline(void) +/* +Insert a line. +*/ + { + + xLine(1); + } + +void delline(void) +/* +Delete a line. +*/ + { + + xLine(-1); + } + +void clreol(void) +/* +Clear to the end of line. +*/ + { + UWORD mode; + P_RECTP rp; + + _iow3(winHandle,P_FSENSE,&rp); + rp.r.tl=rp.p; + rp.r.br.y=rp.p.y+1; + mode=P_SCR_CLR; + _iow4(winHandle,P_FSET,&mode,&rp.r); + } + diff --git a/code/SIBOSDK/src/fstream.cpp b/code/SIBOSDK/src/fstream.cpp new file mode 100644 index 0000000..d22f2b7 --- /dev/null +++ b/code/SIBOSDK/src/fstream.cpp @@ -0,0 +1,468 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* FSTREAM.CPP - 2.1 file stream class implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include + +#pragma module(init_prio=>22) + +_STATIC int get_mode(int h); + +//************************************************************************** +// fstream implementation +//************************************************************************** + +const int filebuf::openprot = S_IREAD|S_IWRITE; + + +filebuf::filebuf() { + + xfd=EOF; + opened=0; + mode=0; + last_seek=0; + in_start=NULL; + setp(base(), ebuf()); + setg(base(), ebuf(), ebuf()); +} + +filebuf::filebuf(int h) { + + xfd=h; + if(h != -1) { + opened=1; + mode=get_mode(h); + } + else + opened=0; + last_seek=0; + in_start=NULL; + setp(base(), ebuf()); + setg(base(), ebuf(), ebuf()); +} + +filebuf::filebuf(int h, char *s, int sz) : streambuf(s, sz) { + + xfd=h; + if(h != -1) { + opened=1; + mode=get_mode(h); + } + else + opened=0; + last_seek=0; + in_start=NULL; + if(unbuffered()) { + setb(lahead, &lahead[1], 0); + setp(base(), base()); + unbuffered(1); + } + else + setp(base(), ebuf()); + setg(base(), ebuf(), ebuf()); +} + +filebuf::~filebuf() { + + if(xfd != EOF) + close(); +} + +filebuf* filebuf::open(const char *path, int fmode, int permission) + { + unsigned om; + + if(opened) + close(); + if(fmode&ios::binary) + om=O_BINARY; + else + om=O_TEXT; + if((fmode&(ios::in|ios::out)) == (ios::in|ios::out)) + om|=O_RDWR; + else if(fmode&ios::in) + om|=O_RDONLY; + else if(fmode&ios::out) + om|=O_WRONLY; + if(om&(O_WRONLY|O_RDWR)) + { + if(fmode&ios::app) + om|=O_APPEND; + if(fmode&ios::trunc) + om|=O_TRUNC; + if(!(fmode&ios::nocreate)) + om|=O_CREAT; + } + if((fmode&ios::noreplace) && (_exists(path))) + xfd=EOF; + else + xfd=::open(path, om, permission); // translate fmode + if(xfd != EOF) + { + opened=1; + mode =fmode; + if(fmode&(ios::ate|ios::app)) + last_seek=lseek(xfd, 0L, SEEK_END); + else + last_seek=0; + return this; + } + else + { + opened=0; + return NULL; + } + } + +filebuf* filebuf::close() { + + if(opened) { + sync(); + ::close(xfd); + } + return this; +} + +filebuf* filebuf::attach(int h) { + + if(opened) + return 0; + xfd=h; + if(h != EOF) { + opened=1; + mode=get_mode(h); + } + else + opened=0; + return this; +} + +_STATIC int get_mode(int h) { + + int mode; + + if(h >= _open_max) + return (ios::in|ios::out); + if(_openfd[h]&O_BINARY) + mode=ios::binary; + else + mode=0; + if(_openfd[h]&O_RDWR) + mode |= ios::in|ios::out; + else if(_openfd[h]&O_WRONLY) + mode |= ios::out; + else + mode |= ios::in; + if(_openfd[h]&O_APPEND) + mode |= ios::app; + return mode; +} + +_STATIC int translate(char *buf, int num, int h) { + + int ip, op, c; + + ip=0; + op=0; + while(ip < num) { + c=buf[ip]; + if(c != 0xD) { + buf[op++]=c; + } + ++ip; + } + if((buf[ip-1] == 0xD) && (num > 1)) + ::lseek(h, -1L, SEEK_CUR); + return op; +} + +_STATIC int real_off(char *buf, int num) { + + int p, n; + + p=0; + n=0; + if(num > 0) { + while(p < num) { + if(buf[p++] == 0xA) + n+=2; + else + ++n; + } + return n; + } + while(p >= num) { + if(buf[--p] == 0xA) + n+=2; + else + ++n; + } + return -n; +} + +int filebuf::last_op() { + + int ret; + + if(pptr() > pbase()) + ret= ios::out; + else if(in_start) + ret= ios::in; + else + ret = 0; + return ret; +} + +int filebuf::overflow(int c) { + + int nw; + + if(unbuffered()) { + if((c == EOF) || (::write(xfd, &c, sizeof(char)) == -1)) + return EOF; + nw=1; + } + else { + nw=pptr()-pbase(); + if(nw) { + if(::write(xfd, pbase(), nw) == -1) + return EOF; + } + } + last_seek+=nw; + setp(pbase(), epptr()); + if((c != EOF) && (!unbuffered())) + sputc(c); + return c; +} + +int filebuf::underflow() { + + int nr; + + if(unbuffered()) + in_start=eback(); + else + in_start=eback()+4; + nr=ebuf()-in_start; + last_seek=tell(xfd); + if((nr=::_read(xfd, in_start, nr)) <= 0) + return EOF; + if(!(mode&ios::binary)) + nr=translate(in_start, nr, xfd); + setg(eback(), in_start, in_start+nr); + return (unsigned char) *gptr(); +} + +int filebuf::sync() { + + streampos pos; + int lo; + + if(!opened) + return EOF; + lo=last_op(); + if(lo == ios::out) + overflow(); + else if(lo == ios::in) { + if(mode&ios::binary) + pos = gptr()-in_start + last_seek; + else + pos = real_off(in_start, gptr()-in_start) + last_seek; + last_seek = ::lseek(xfd, pos, SEEK_SET); + } + else + return 0; + setp(pbase(), epptr()); + setg(base(), ebuf(), ebuf()); + in_start=NULL; + return 0; +} + +streampos filebuf::seekoff(streamoff off, ios::seek_dir d, int ) { + + streampos p; + ios::seek_dir dir; + int lo; + + if(opened) { + if((!unbuffered()) && (d == ios::cur)) { + lo=last_op(); + if(lo == ios::out) { + if(mode&ios::binary) + p = pptr()-pbase(); + else + p = real_off(pbase(), pptr()-pbase()); + } + else if(lo == ios::in) { + if(mode&ios::binary) + p = gptr()-in_start; + else + p = real_off(eback(), gptr()-in_start); + } + else + p=0; + p += last_seek + off; + dir=ios::beg; + } + else { + p=off; + dir=d; + } + sync(); + last_seek = ::lseek(xfd, p, dir); + setp(pbase(), epptr()); + setg(base(), ebuf(), ebuf()); + return last_seek; + } + return (streampos) -1; +} + +streambuf* filebuf::setbuf(char *s, int sz) { + + if(opened || (base() && (!unbuffered()))) + return NULL; + setb(s, s+sz, 0); + if(s) { + setp(s, s+sz); + setg(s, s+sz, s+sz); + } + else { + setp(NULL, NULL); + setg(NULL, NULL, NULL); + } + return this; +} + +//**************************************************************************//************************************************************************** +// fstreambase implementation +//************************************************************************** + +fstreambase::fstreambase() { + +} + +fstreambase::fstreambase(int h) : buf(h) { + +} + + +fstreambase::fstreambase(int h, char *s, int sz) : buf(h, s, sz) { + +} + +fstreambase::fstreambase(const char *path, int mode, int permission) { + + buf.open(path, mode, permission); + if(!buf.is_open()) + setstate(failbit); +} + + +fstreambase::~fstreambase() { + +} + +void fstreambase::open(const char *path, int mode, int permission) { + + buf.open(path, mode, permission); + if(!buf.is_open()) + state|=failbit; +} + +void fstreambase::attach(int h) { + + if(buf.attach(h) == NULL) + state|=failbit; +} + +void fstreambase::close() { + + buf.close(); +} + +void fstreambase::setbuf(char *b, int sz) { + + buf.setbuf(b, sz); +} + +//**************************************************************************//************************************************************************** +// ifstream implementation +//************************************************************************** + +ifstream::ifstream() : istream(rdbuf()) { + +} + +ifstream::ifstream(const char* path, int mode, int prot) : istream(rdbuf()) { + + if(rdbuf()->open(path, mode, prot) == NULL) + setstate(badbit); +} + +ifstream::ifstream(int h) : istream(rdbuf()), + fstreambase(h) { + +} + +ifstream::ifstream(int h, char* b, int sz) : istream(rdbuf()), + fstreambase(h, b, sz) { +} + +ifstream::~ifstream() { + +} + +ofstream::ofstream() : ostream(rdbuf()) { + +} + +ofstream::ofstream(const char* path, int mode, int prot) : ostream(rdbuf()) { + + if(rdbuf()->open(path, mode, prot) == NULL) + setstate(badbit); +} + +ofstream::ofstream(int h) : ostream(rdbuf()), + fstreambase(h) { + +} + +ofstream::ofstream(int h, char* b, int sz) : ostream(rdbuf()), + fstreambase(h, b, sz) { +} + +ofstream::~ofstream() { + +} + +fstream::fstream() : iostream(rdbuf()) { + +} + +fstream::fstream(const char* path, int mode, int prot) : iostream(rdbuf()) { + + if(rdbuf()->open(path, mode, prot) == NULL) + setstate(badbit); +} + +fstream::fstream(int h) : iostream(rdbuf()), + fstreambase(h) { + +} + +fstream::fstream(int h, char* b, int sz) : iostream(rdbuf()), + fstreambase(h, b, sz) { +} + +fstream::~fstream() { + +} + \ No newline at end of file diff --git a/code/SIBOSDK/src/iclib.a b/code/SIBOSDK/src/iclib.a new file mode 100644 index 0000000..cede6f7 --- /dev/null +++ b/code/SIBOSDK/src/iclib.a @@ -0,0 +1,9 @@ +(* 8K Epoc C header for use with CLIB *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +StackSize = 2000H + +include "iclib.inc" + + diff --git a/code/SIBOSDK/src/iclib.inc b/code/SIBOSDK/src/iclib.inc new file mode 100644 index 0000000..7d33eca --- /dev/null +++ b/code/SIBOSDK/src/iclib.inc @@ -0,0 +1,103 @@ +(* Epoc C header for use with CLIB include file *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +include "epocdefs.inc" + +module iclib + +section + +segment _TEXT(CODE,68H) + +segment STACK(STACK,74H) +public __stack_start: + +segment _MAGIC(MAGIC,68H) +public _DatWordDead: dw 0 +public _DatHandNext: dw 0 +public _DatHandPrev: dw 0 +public _DatCountrySeg: dw 0 +public _DatClassHandle: dw 0 +public _DatClassPtr: dw 0 +public _DatEClassHandle: dw 0 +public _DatEClassPtr: dw 0 +public _DatEnterFramePtr: dw 0 +public _w_ws: dw 0 +public _w_am: dw 0 +public _wClientData: dw 0 +public _wserv_channel: dw 0 +public _T: dw 0 +public _r: dw 0 +public _DatOsFramePtr: dw 0 +public _DatATFlag: db 0 +public _DatHeapLocked: db 0 +public _DatProcessNamePtr: dw 0 +public _DatCommandPtr: dw 0 +public _DatTest: dw 0 +public _DatApp1: dw 0 +public _DatApp2: dw 0 +public _DatApp3: dw 0 +public _DatApp4: dw 0 +public _DatApp5: dw 0 +public _DatApp6: dw 0 +public _DatApp7: dw 0 +public _DatDialogPtr: dw 0 +public _DatGate: dw 0 +public _DatLocked: dw 0 +public _DatStatusNamePtr: dw 0 +public _DatUsedPathNamePtr: dw 0 +org StackSize-40H + +segment _INIT(DATA,48H) +public __init_start: + +segment _CONST(DATA,48H) +public __const_start: + dw 0 + +segment _DATA(DATA,68H) +public __data_start: + +segment _BSS(BSS,68H) +public __bss_start: + +segment _BSS_END(BSS,68H) +public __bss_end: + +group DGROUP(_MAGIC,_INIT,_CONST,_DATA,_BSS,_BSS_END) + +select _TEXT + +extrn __startup +extrn _exit +extrn _ExtCatTable +extrn _ClassTable + +public __begin : + + call __startup + ret far 0 + + dw __bss_start + dw _ExtCatTable + dw _ClassTable + dw _DatWordDead + dw __bss_end + +public _p_leave: + int LibLeave + int LibSendExit + + dw __init_start + dw __const_start + +public _p_exit: + mov ax, bx + jmp _exit + +public _p_abort: + mov ax, FailedToStartErr + jmp _exit + +end * diff --git a/code/SIBOSDK/src/iclib2.a b/code/SIBOSDK/src/iclib2.a new file mode 100644 index 0000000..5d632be --- /dev/null +++ b/code/SIBOSDK/src/iclib2.a @@ -0,0 +1,8 @@ +(* 2K stack Epoc C header for use with CLIB *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +StackSize = 800H + +include "iclib.inc" + diff --git a/code/SIBOSDK/src/iclib4.a b/code/SIBOSDK/src/iclib4.a new file mode 100644 index 0000000..678005f --- /dev/null +++ b/code/SIBOSDK/src/iclib4.a @@ -0,0 +1,8 @@ +(* 4K stack Epoc C header for use with CLIB *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +StackSize = 1000H + +include "iclib.inc" + diff --git a/code/SIBOSDK/src/inst.bat b/code/SIBOSDK/src/inst.bat new file mode 100644 index 0000000..54e8558 --- /dev/null +++ b/code/SIBOSDK/src/inst.bat @@ -0,0 +1,9 @@ +copy iclib*.obj ..\lib +copy iplib*.obj ..\lib +copy icat.obj ..\lib +copy r_emul.obj ..\lib +copy nofloat.obj ..\lib +copy rlib.lib ..\lib +copy clib.lib ..\lib +copy sys$8087.ldd ..\lib + diff --git a/code/SIBOSDK/src/ioinline.cpp b/code/SIBOSDK/src/ioinline.cpp new file mode 100644 index 0000000..13afed0 --- /dev/null +++ b/code/SIBOSDK/src/ioinline.cpp @@ -0,0 +1,332 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* IOINLINE.CPP - 2.0 stream class small inline implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#undef _SMALL_INLINE +#include +#include + +streambuf* ios::rdbuf() { + return _bp; +} +ostream* ios::tie() { + return x_tie; +} + +char ios::fill() { + return x_fill; +} + +int ios::precision() { + return x_precision; +} + +int ios::rdstate() { + return state; +} + +int ios::eof() { + return (state&eofbit); +} + +int ios::fail() { + return (state&(failbit|badbit|hardfail)); +} + +int ios::bad() { + return (state&(badbit|hardfail)); +} + +int ios::good() { + return (state == 0); +} + +long ios::flags() { + return x_flags; +} + +int ios::width() { + return x_width; +} + +int ios::width(int _w) { + int _temp = x_width; + x_width = _w; + return _temp; +} + +char ios::fill(char _w) { + char _temp = x_fill; + x_fill = _w; + return _temp; +} + +int ios::precision(int _w) { + int _temp = x_precision; + x_precision = _w; + return _temp; +} + +ios::operator void* () { + return (fail()|eof()) ? 0 : this; +} + +ios::operator! () { + return (fail()|eof()); +} + +char * streambuf::base() { + return _base; +} + +char * streambuf::pbase() { + return _pbase; +} + +char * streambuf::pptr() { + return _pptr; +} + +char * streambuf::epptr() { + return _epptr; +} + +char * streambuf::gptr() { + return _gptr; +} + +char * streambuf::egptr() { + return _egptr; +} + +char * streambuf::eback() { + return _eback; +} + +char * streambuf::ebuf() { + return _ebuf; +} + +int streambuf::unbuffered() { + return _unbuf; +} + +int streambuf::blen() { + return (int) (_ebuf - _base); +} + +void streambuf::pbump(int _n) { + _pptr += _n; +} + +void streambuf::gbump(int _n) { + _gptr += _n; +} + +void streambuf::unbuffered(int _ub) { + _unbuf = (_ub != 0); +} + +int streambuf::in_avail() { + return (_egptr > _gptr) ? (int)(_egptr - _gptr): 0; +} + +int streambuf::out_waiting() { + return _pptr ? (int)(_pptr - _pbase): 0; +} + +int streambuf::allocate() { + return((_base || _unbuf) ? 0 : doallocate()); +} + +int streambuf::sgetc() { + return ((_gptr >= _egptr) ? underflow() : (unsigned char) *_gptr); +} + +int streambuf::snextc() { + return ((++_gptr >= _egptr) ? do_snextc() : (unsigned char) *_gptr); +} + +int streambuf::sbumpc() { + return ((_gptr >= _egptr) && (underflow() == EOF) ? EOF : (unsigned char) *_gptr++); +} + +void streambuf::stossc() { + if (_gptr >= _egptr) + underflow(); + else + ++_gptr; +} + +int streambuf::sputbackc(char _c) { + return (_gptr > _eback) ? *--_gptr = _c : pbackfail(_c) ; +} + +int streambuf::sputc(int _c) { + return (_pptr >= _epptr) ? overflow(_c) : (*_pptr++=_c); +} + + +int istream::gcount() { + return _gcount; +} + +int istream::ipfx(int _need) { + if( _need ? (ispecial&~skipping) : ispecial) + return do_ipfx(_need); + return 1; +} + +int istream::ipfx0() { + return ispecial ? do_ipfx(0) : 1; +} + +int istream::ipfx1() { + return (ispecial&~skipping) ? do_ipfx(1) : 1; +} + +istream& istream::operator>>(unsigned char& _c) { + if(ipfx0()) { + if(_bp->in_avail()) + _c = _bp->sbumpc(); + else + _c = do_get(); + } + return *this; +} + +istream& istream::operator>>(signed char& _c) { + if(ipfx0()) { + if(_bp->in_avail()) + _c = _bp->sbumpc(); + else + _c = do_get(); + } + return *this; +} + +istream& istream::operator>>(char& _c) { + if(ipfx0()) { + if(_bp->in_avail()) + _c = _bp->sbumpc(); + else + _c = do_get(); + } + return *this; +} + +istream& istream::operator>>(unsigned char* _s) { + return *this>>(signed char *) _s; +} + +istream& istream::operator>>(char* _s) { + return *this>>(signed char *) _s; +} + +istream& istream::get(unsigned char* _s, int _l, char _t) { + return get((signed char *)_s, _l, _t); +} + +istream& istream::get(char* _s, int _l, char _t) { + return get((signed char *)_s, _l, _t); +} + +istream& istream::read(unsigned char* _s, int _l) { + return read((signed char *)_s, _l); +} + +istream& istream::read(char* _s, int _l) { + return read((signed char *)_s, _l); +} + +istream& istream::getline(unsigned char* _s, int _l, char _t) { + return getline((signed char *)_s, _l, _t); +} + +istream& istream::getline(char* _s, int _l, char _t) { + return getline((signed char *)_s, _l, _t); +} + +int istream::sync() { + return _bp->sync(); +} + +istream& istream::operator>> (istream& (*_f)(istream&)) { + return (*_f)(*this); +} + +int istream::peek() { + return ipfx1() ? _bp->sgetc() : EOF; +} + +int ostream::opfx() { + return ospecial ? do_opfx() : 1; +} + +void ostream::osfx() { + if((x_flags&(stdio|unitbuf)) || (ospecial)) do_osfx(); +} + +ostream& ostream::operator<<(unsigned char _c) { + return *this <<(signed char ) _c; +} + +ostream& ostream::operator<<(char _c) { + return *this <<(signed char ) _c; +} + +ostream& ostream::operator<<(short _i) { + return *this<<(long)_i; +} + +ostream& ostream::operator<<(unsigned short _i) { + return *this<<(unsigned long)_i; +} + +ostream& ostream::operator<<(int _i) { + return *this<<(long)_i; +} + +ostream& ostream::operator<<(unsigned int _i) { + return *this<<(unsigned long)_i; +} + +ostream& ostream::operator<<(float _f) { + return *this<<(long double)_f; +} + +ostream& ostream::operator<<(double _f) { + return *this<<(long double)_f; +} + +ostream& ostream::operator<<(ostream& (*_f)(ostream&)) { + return (*_f)(*this); +} + +ostream& ostream::write(const signed char *_s, int _n) { + return write((const char *)_s, _n); +} + +ostream& ostream::write(const unsigned char *_s, int _n) { + return write((const char *)_s, _n); +} + +ostream& ostream::put(char _c) { + if(_bp->sputc(_c) == EOF) + setstate(badbit); + return *this; +} + +ostream& ostream::operator<<(const signed char *_s) { + return *this<<(const char *) _s; +} +ostream& ostream::operator<<(const unsigned char *_s) { + return *this<<(const char *) _s; +} + \ No newline at end of file diff --git a/code/SIBOSDK/src/iostream.cpp b/code/SIBOSDK/src/iostream.cpp new file mode 100644 index 0000000..d02b518 --- /dev/null +++ b/code/SIBOSDK/src/iostream.cpp @@ -0,0 +1,1693 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* IOSTREAM.CPP - 2.1 stream class implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +extern "C" char *_ld_format(char *_fmt_buf, LONGDOUBLE num, int flag, int prec); +extern "C" char *_v_format(unsigned long, char *s); + +#pragma module(init_prio=>22) + +//************************************************************************** +// ios implementation +//************************************************************************** + +const long ios::basefield = dec|oct|hex; +const long ios::adjustfield = left|right|internal; +const long ios::floatfield = scientific|fixed; +void (*ios::stdioflush)() = NULL; +long ios::nextbit = 10; +int ios::usercount = 0; + +long ios::flags(long f) { + + long t; + + t=x_flags; + x_flags=f; + return t; +} + +long ios::setf(long sbits,long fld) + { + long t; + + t=x_flags&fld; + x_flags&=~fld; + sbits&=fld; + x_flags|=sbits; + return t; + } + +long ios::setf(long sbits) { + + long t; + + t=x_flags; + x_flags|=sbits; + return t; +} + +long ios::unsetf(long sbits) { + + long t; + + t=x_flags; + x_flags&=~sbits; + return t; +} + + +ostream* ios::tie(ostream* ost) { + + ostream* t; + + t=x_tie; + x_tie=ost; + return t; +} + +ios::ios(streambuf *sb) { + + init(sb); +} + +void ios::init(streambuf *sb) { + + _bp=sb; + x_tie=NULL; + state=0; + ispecial=skipping; + ospecial=0; + x_flags=skipws|right|scientific; + x_precision=6; + x_width=0; + x_fill=' '; + userwords=NULL; + nwords=0; + delbuf=0; +} + +ios::ios() { + +} + +ios::~ios() { + +} + +int ios::skip(int sk) { + + int t; + + t=((x_flags&skipws) != 0); + if(sk) { + x_flags|=skipws; + ispecial|=skipping; + } + else { + x_flags&=~skipws; + ispecial&= (~skipping); + } + return(t); +} + +long ios::bitalloc() { + + if(nextbit >= 31) + return 0; + return 1<<++nextbit; +} + +int ios::xalloc() { + + return usercount++; +} + + +_STATIC long err_ret=0; +_STATIC void * err_ret_ptr=NULL; + +long& ios::iword(int n) { + + if((n >= 0) && (n < usercount)) { + if(n >= nwords) + uresize(n); + if(userwords) + return userwords[n].x; + } + setstate(failbit); + return err_ret; +} + + +void* & ios::pword(int n) { + + if((n >= 0) && (n < usercount)) { + if(n >= nwords) + uresize(n); + if(userwords) + return userwords[n].p; + } + setstate(failbit); + return err_ret_ptr; +} + +void ios::uresize(int n) { + + nwords=n+1; + userwords=(ios::ios_user_union *) realloc(userwords, nwords); +} + + +#ifndef _WINDOWS +_STATIC stdiobuf cin_sb (stdin); +_STATIC stdiobuf cout_sb(stdout); +_STATIC stdiobuf cerr_sb(stderr); +_STATIC stdiobuf clog_sb(stderr); + + +void ios::sync_with_stdio() { + + static done=0; + + if(!done) { + done=1; + cin=(streambuf *) &cin_sb; + cout=(streambuf *) &cout_sb; + cerr=(streambuf *) &cerr_sb; + clog=(streambuf *) &clog_sb; + cin.setf(ios::unitbuf|stdio); + cout.setf(ios::unitbuf|stdio); + clog.setf(ios::unitbuf|stdio); + } +} +#endif + +void ios::setstate(int st) { + + state|=st; +} + +void ios::clear(int st) { + + state=st; +} + +//************************************************************************** +// streambuf implementation +//************************************************************************** + + +streambuf::streambuf() { + + char *b=new char[512]; + + _base=NULL; + setbuf(b, 512); + _alloc=1; +} + +streambuf::streambuf(char *s, int sz) { + + _base=NULL; + setbuf(s, sz); + _alloc=0; +} + +streambuf::~streambuf() { + + if(_alloc && _base) + delete _base; +} + + +streambuf * streambuf::setbuf(char *s, int sz, int pos) { + + if(_base) + return NULL; + setb(s, s+sz); + if(s && sz) { + setp(s+pos, s+sz/2); + setg(s+sz/2, s+sz/2+pos, s+sz); + } + else { + setp(NULL, NULL); + setg(NULL, NULL, NULL); + } + return this; +} + +streambuf* streambuf::setbuf(char *s, int sz) { + + if(_base) + return NULL; + setb(s, s+sz); + if(s && sz) { + setp(s, s+sz/2); + setg(s+sz/2, s+sz, s+sz); + } + else { + setp(NULL, NULL); + setg(NULL, NULL, NULL); + } + return this; +} + +int streambuf::sputn(const char *_s, int _n) { + + if(_n <= (_epptr - _pptr)) { + memcpy(_pptr, _s, _n); + pbump(_n); + return _n; + } + return do_sputn(_s, _n); +} + +int streambuf::do_sputn(const char *_s, int _n) { + + int t, nw; + + nw=0; + while(nw < _n) { + if(_pptr >= _epptr) + overflow(_s[nw++]); + t = _epptr - _pptr; + if(t) { // special case for unbuffered + memcpy(_pptr, &_s[nw], t); + nw+=t; + pbump(t); + } + } + return nw; +} + +int streambuf::overflow(int) { + + return EOF; +} + +int streambuf::sgetn(char *_s, int _n) { + + if(_n <= (_egptr - _gptr)) { + memcpy(_s, _gptr, _n); + gbump(_n); + return _n; + } + return do_sgetn(_s, _n); +} + + +int streambuf::do_sgetn(char *_s, int _n) { + + int t, nr; + + nr=0; + while(nr < _n) { + if(_gptr >= _egptr) { + if(underflow() == EOF) + break; + } + t = _egptr - _gptr; + memcpy(&_s[nr], _gptr, t); + nr+=t; + gbump(t); + } + return nr; +} + +int streambuf::underflow() { + + return EOF; +} + +int streambuf::pbackfail(int) { + + return EOF; +} + +streampos streambuf::seekoff(streamoff, ios::seek_dir, int) { + + return EOF; +} + +streampos streambuf::seekpos(streamoff off, int mode) { + + streampos pos; + + if((pos=seekoff(off, ios::beg, mode)) == EOF) + return EOF; + return pos; +} + +int streambuf::sync() { + + if(_gptr == _egptr) + return 0; + return EOF; +} + +int streambuf::dbp() { + +#ifndef _WINDOWS + printf("base = %p, ebuf = %p, pbase = %p\n", _base, _ebuf, _pbase); + printf("pptr = %p, epptr = %p\n", _pptr, _epptr); + printf("gptr = %p, egptr = %p, eback = %p\n", _gptr, _egptr, _eback); +#endif + return 1; +} +void streambuf::setp(char *p, char *ep) { + + _pbase=p; + _pptr=p; + _epptr=ep; +} + +void streambuf::setg(char *eb, char *g, char *eg) { + + _eback=eb; + _gptr=g; + _egptr=eg; +} + +void streambuf::setb(char *b, char *eb, int i) { + + if(_base && _alloc) + delete _base; + _base=b; + _ebuf=eb; + _alloc=i; + _unbuf=((!b) && (!eb)); +} + +int streambuf::doallocate() { + + char *b; + + b=new char[512]; + if(b == NULL) + return EOF; + _alloc=1; + setbuf(b, 512); + return 1; +} + +int streambuf::do_snextc() { + + int na; + + na=_gptr-_egptr; + underflow(); + if(na > 0) + _gptr+=na; + return *_gptr; +} + +//************************************************************************** +// istream implementation +//************************************************************************** + +istream::istream(streambuf *sb) { + + ios::init(sb); + _gcount=0; +} + +istream::~istream() { + if(delbuf) + delete _bp; +} + +istream::istream() { + + _gcount=0; +} + +istream::istream(streambuf *sb, int sk, ostream* tie) { + + ios::init(sb); + x_tie=tie; + skip(sk); + _gcount=0; +} + + +istream::istream(int sz, char* b, int sk) : ios() { + + streambuf *p; + + p=new streambuf(b, sz); + ios::init(p); + skip(sk); + _gcount=0; + delbuf=1; +} + +istream::istream(int fd, int sk, ostream* tie) : ios() { + + filebuf *f; + + f=new filebuf(fd); + ios::init(f); + x_tie=tie; + skip(sk); + _gcount=0; + delbuf=1; +} + +istream& istream::seekg(streampos p) { + + state &= ~(failbit|eofbit); + if(state == goodbit) + _bp->seekoff(p, ios::beg, ios::in); + return *this; +} + +istream& istream::seekg(streamoff p, ios::seek_dir d) { + + state &= ~(failbit|eofbit); + if(state == goodbit) + _bp->seekoff(p, d, ios::in); + return *this; +} + +streampos istream::tellg() { + + if(state == goodbit) + return _bp->seekoff(0L, ios::cur, ios::in); + return (streampos) -1; +} + +istream& istream::ignore(int n, int delim) { + + int c, cnt; + + cnt=0; + while(cnt++ < n) { + if(((c=_bp->sbumpc()) == delim) && (delim != EOF)) { + _bp->sputbackc(c); + break; + } + if(c == EOF) { + setstate(failbit|eofbit); + break; + } + } + return *this; +} + +istream& istream::read(signed char* s, int n) { + + int cnt, c; + + _gcount=0; + if(state == goodbit) { + cnt=0; + while(cnt < n) { + c=_bp->sbumpc(); + if(c == EOF) { + setstate(eofbit|failbit); + break; + } + s[cnt++]=c; + ++_gcount; + } + } + return *this; +} + +istream& istream::putback(char c) { + + if(state == goodbit) { + if(_bp->sputbackc(c) == EOF) + setstate(eofbit|failbit); + } + return *this; +} + +istream& istream::getline(signed char* s, int n, char t) { + + int c, p=0; + + if(ipfx1()) { + while(p < n-1) { + c=_bp->sbumpc(); + if(c == t) { + break; + } + if(c == EOF) { + setstate(eofbit); + if(p == 0) + setstate(failbit); + break; + } + s[p++]=c; + } + } + s[p]='\0'; + return *this; +} + +istream& istream::operator>>(signed char *s) { + + int lim, c, p=0; + + if(x_width) { + lim=x_width-1; + x_width=0; + } + else + lim = INT_MAX; + _gcount=0; + if(ipfx0()) { + while(p < lim) { + c=_bp->sbumpc(); + if(c == EOF) { + setstate(failbit|eofbit); + break; + } + if(isspace(c)) { + _bp->sputbackc(c); + break; + } + s[p++]=c; + ++_gcount; + } + } + s[p]='\0'; + return *this; +} + +istream& istream::get(signed char *s, int len, char delim) { + + int c, p=0; + + _gcount=0; + if(ipfx1()) { + while(p < len-1) { + c=_bp->sbumpc(); + if(c == delim) { + _bp->sputbackc(c); + break; + } + if(c == EOF) { + setstate(eofbit); + if(p == 0) + setstate(failbit); + break; + } + s[p++]=c; + ++_gcount; + } + } + s[p]='\0'; + return *this; +} + +istream& istream::get(unsigned char& _c) { + + if( ipfx1() ) { + if( _bp->in_avail() ) { + _gcount = 1; + _c = _bp->sbumpc(); + } + else + _c = do_get(); + } + return *this; +} + +istream& istream::get(signed char& _c) { + + if( ipfx1() ) { + if( _bp->in_avail()) { + _gcount = 1; + _c = _bp->sbumpc(); + } + else + _c = do_get(); + } + return *this; +} + +istream& istream::get( char& _c) { + + if( ipfx1() ) { + if( _bp->in_avail()) { + _gcount = 1; + _c = _bp->sbumpc(); + } + else + _c = do_get(); + } + return *this; +} + + +int istream::get() { + + if( ipfx1() ) { + int _c = _bp->sbumpc(); + if( _c == EOF ) + setstate(eofbit); + else + _gcount = 1; + return _c; + } + return EOF; +} + + +istream& istream::get(streambuf& s, char t) { + + int c, lim; + + if(x_width) { + lim=x_width; + x_width=0; + } + else + lim=INT_MAX; + _gcount=0; + if(state == goodbit) { + while(lim--) { + c=_bp->sbumpc(); + if(c == EOF) { + setstate(eofbit); + break; + } + if(c == t) { + _bp->sputbackc(c); + break; + } + if(s.sputc(c) == EOF) { + setstate(failbit); + break; + } + ++_gcount; + } + } + return *this; +} + +istream& istream::operator>>(ios& (*f)(ios &)) { + + f(*this); // NB !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + return *this; +} + +_STATIC long double getreal(istream& is, int& pass) { + + int n=0; + char c; + char _fmt_buf[64]; + int good_scan=0; + + is >> c; + while(is.good()) + { + if((c == '+') || (c == '-')) { /* leading sign */ + good_scan=1; + _fmt_buf[n++]= (char) c; + c= is.get(); + if(!is.good()) + break; + } + for(int q=0; q<2; q++) { + while(isdigit(c)) { /* get digits */ + good_scan=1; + _fmt_buf[n++]= (char) c; + c= is.get(); + if(!is.good()) + break; + } + if((c == DEC_POINT) && (q == 0)) { /* decimal point */ + _fmt_buf[n++]= (char) c; + c= is.get(); + if(!is.good()) + break; + } + else if(q == 0) + break; + } /* go back for more digits if first iteration */ + if((c == 'E') || (c == 'D') || (c == 'e') || (c == 'd')) { + _fmt_buf[n++]= (char) c; + c= is.get(); + if(!is.good()) + break; + } + else + break; + if((c == '+') || (c == '-')) { + _fmt_buf[n++]= (char) c; + c= is.get(); + if(!is.good()) + break; + } /* exponent digits */ + while(isdigit(c)) { + good_scan=1; + _fmt_buf[n++]= (char) c; + c= is.get(); + if(!is.good()) + break; + } + break; + } + _fmt_buf[n]=0; /* terminate string */ + if(is.good()) + is.putback(c); + pass=good_scan; + return atofl(_fmt_buf); /* convert and assign if not suppressed */ +} + +_STATIC long getlong(istream& is, int us, int& pass) { + + int negative=0, flag=0; + long temp=0; + int good_scan=0; + char c; + + is >> c; + if(!is.good()) + goto error; + if(c == '+') { + good_scan=1; + c= is.get(); + if(!is.good()) + goto error; + } + else if(c == '-') { /* number is negative */ + good_scan=1; + negative=1; + c= is.get(); + if(!is.good()) + goto error; + else if(us) + return(0); + } + if(c =='0') { + good_scan=1; + flag=_OCT; + c= is.get(); + if(!is.good()) + goto error; + c=tolower(c); + if(c == 'x') { + flag=_HEX; + c= is.get(); + if(!is.good()) + goto error; + } + } + if(is.flags()&ios::dec) { + if(flag == _HEX) + c='x'; + flag=0; + } + switch(flag) { + case _HEX : + while(isxdigit(c=tolower(c))) { + temp*=16; + if(!isdigit(c)) + c-=87; + else + c-='0'; + temp+=c; + c= is.get(); + if(!is.good()) + goto error; + } + break; + case _OCT : + while((c >= '0') && (c <= '7')) { + temp*=8; + temp+=c-'0'; + c= is.get(); + if(!is.good()) + goto error; + } + break; + default : + while(isdigit(c)) { + good_scan=1; + temp*=10; + temp+=c-'0'; + c= is.get(); + if(!is.good()) + goto error; + } + break; + } + c=tolower(c); + if((c != 'u') && (c != 'l')) + is.putback(c); +error: + if(negative) + return -temp; + pass=good_scan; + return temp; +} + +istream& istream::operator>>(short& s) { + + short t; + int pass; + + t=getlong(*this, 0, pass); + if(pass) + s=(short) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(int& i) { + + int t; + int pass; + + t=(int)getlong(*this, 0, pass); + if(pass) + i=(int) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(long& l) { + + long t; + int pass; + + t=getlong(*this, 0, pass); + if(pass) + l= t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(unsigned short& s) { + + unsigned short t; + int pass; + + t=getlong(*this, 1, pass); + if(pass) + s=(unsigned short) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(unsigned int& i) { + + unsigned int t; + int pass; + + t=(unsigned)getlong(*this, 1, pass); + if(pass) + i=(unsigned int) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(unsigned long& l) { + + unsigned long t; + int pass; + + t=getlong(*this, 1, pass); + if(pass) + l= (unsigned long) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(long double& ld) { + + long double t; + int pass; + + t=getreal(*this, pass); + if(pass) + ld= t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(double& d) { + + long double t; + int pass; + + t=getreal(*this, pass); + if(pass) + d= (double) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(float& f) { + + long double t; + int pass; + + t=getreal(*this, pass); + if(pass) + f= (float) t; + else + setstate(failbit); + return *this; +} + +istream& istream::operator>>(streambuf* sb) { + + + int c; + + if(state == goodbit) { + while(1) { + if(!ipfx0()) + break; + c=_bp->sbumpc(); + if(c == EOF) { + setstate(eofbit); + break; + } + if(sb->sputc(c) == EOF) { + putback(c); + break; + } + ++_gcount; + } + } + return *this; +} + +int istream::do_ipfx(int need) { + + if(state != goodbit) + return 0; + if((!need) || (need > _bp->in_avail())) { // skip and flush tie + if(x_tie) + x_tie->flush(); + if(ispecial&skipping) + eatwhite(); + } + return (state == goodbit); +} + +void istream::eatwhite() { + + int c; + + while(isspace(c=_bp->sgetc())) { + _bp->stossc(); + } + if(c == EOF) + setstate(failbit|eofbit); +} + + +int istream::do_get() { + + int t; + + if ((t=_bp->underflow()) == EOF) + setstate(eofbit); + else { + _bp->sbumpc(); + return t; + } +} + +//************************************************************************** +// ostream implementation +//************************************************************************** + +ostream::ostream(streambuf *sb) { + + ios::init(sb); + ospecial=translate; +} + +ostream::~ostream() { + if(delbuf) + delete _bp; +} + +ostream::ostream() { + + ospecial=translate; +} + + +ostream::ostream(int sz, char* b) { + + streambuf *p; + + p=new streambuf(b, sz); + ios::init(p); + delbuf=1; + ospecial=translate; +} + +ostream::ostream(int fd) { + + filebuf *f; + + f=new filebuf(fd); + ios::init(f); + delbuf=1; + ospecial=translate; +} + +ostream& ostream::seekp(streampos p) { + + state &= ~(failbit|eofbit); + if(state == goodbit) + _bp->seekoff(p, ios::beg, ios::out); + return *this; +} + +ostream& ostream::seekp(streamoff p, ios::seek_dir d) { + + if(state == goodbit) + _bp->seekoff(p, d, ios::out); + return *this; +} + +streampos ostream::tellp() { + + if(state == goodbit) + return _bp->seekoff(0L, ios::cur, ios::out); + return (streampos) -1; +} + +ostream& ostream::write(const char*s, int n) { + + int cnt; + + if(state == goodbit) { + if(ospecial) { + cnt=0; + while(cnt < n) { + if(_bp->sputc((unsigned char) s[cnt]) == EOF) { + setstate(failbit); + break; + } + ++cnt; + } + } + else { + if(_bp->sputn(s, n) != n) + setstate(failbit); + } + } + return *this; +} + + +_STATIC int pad_output(ostream& os, int l) { + int pw; + + pw=os.width(); + while(pw > l) { + if(os.rdbuf()->sputc(os.fill()) == EOF) { + return EOF; + } + --pw; + } + os.width(0); + return 0; +} + + +ostream& ostream::operator<<(signed char c) { + + if(opfx()) { + if(!(x_flags&left)) { + if(pad_output(*this, 1) == EOF) { + setstate(failbit); + return *this; + } + } + if(state == goodbit) { + if(_bp->sputc(c) == EOF) + setstate(failbit); + else { + if(x_flags&left) { + if(pad_output(*this, 1) == EOF) + setstate(failbit); + return *this; + } + } + } + osfx(); + } + return *this; +} + +void ostream::outlong(unsigned long l, int issigned) { + + int radix, np, len, signchar; + char fmt_buf[64]; + int c; + + if(x_flags&hex) + radix=16; + else if(x_flags&oct) + radix=8; + else + radix=10; + np=3; + if(issigned) + ltoa(l, &fmt_buf[np], radix); + else + ltoa(l, &fmt_buf[np], radix); + + if(x_flags&showbase) { + if(x_flags&hex) + fmt_buf[--np]='x'; + if(x_flags&(hex|oct)) + fmt_buf[--np]='0'; + } + if(x_flags&uppercase) + strupr(&fmt_buf[np]); + else + strlwr(&fmt_buf[np]); + if(((x_flags&showpos) && (!(x_flags&(hex|oct)))) || (l < 0)) { + if(l >= 0) + fmt_buf[--np]= '+'; + else + fmt_buf[--np]= ' '; + signchar=1; + } + else + signchar=0; + len=strlen(&fmt_buf[np]); + + if((x_flags&right) || (!(x_flags&adjustfield))) { + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return; + } + } + if(x_flags&internal) { + int dec=0; + if(signchar || (x_flags&showbase)) { + c=_bp->sputc(fmt_buf[np++]); + ++dec; + if((x_flags&hex) && (x_flags&showbase)) { + c=_bp->sputc(fmt_buf[np++]); + ++dec; + } + if(c == EOF) { + setstate(failbit); + return; + } + } + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return; + } + len-=dec; + } + int n=0; + while(n++ < len) { + if(_bp->sputc(fmt_buf[np++]) == EOF) { + setstate(failbit); + return; + } + } + if(x_flags&left) { + if(pad_output(*this, len) == EOF) + setstate(failbit); + } + return; +} + + +ostream& ostream::operator<<(long l) { + + if(opfx()) { + outlong((unsigned long) l, 1); + osfx(); + } + return *this; +} + +ostream& ostream::operator<<(unsigned long l) { + + if(opfx()) { + outlong(l, 0); + osfx(); + } + return *this; +} + +ostream& ostream::operator<<(long double ld) { + + unsigned flag, signchar, len; + char buf[64]; + char *res; + + if(opfx()) { + if(x_flags&scientific) + flag=(PF_EXP|PF_CPP); + else if(x_flags&fixed) + flag=PF_CPP; + else + flag=(PF_GTYPE|PF_CPP); + if(x_flags&showpoint) + flag|=PF_HASH; + if(x_flags&showpos) + flag|=PF_SIGN; + + res=_ld_format(buf, ld, flag, x_precision); + + signchar=((res[0] == '+') || (res[0] == '-')); + len=strlen(res); + + int p=0; + if(x_flags&right) { + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return *this; + } + } + if((x_flags&internal) && (signchar)){ + if(_bp->sputc(res[p++]) == EOF) { + setstate(failbit); + return *this; + } + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return *this; + } + --len; + } + int n=0; + while(n++ < len) { + if(_bp->sputc(res[p++]) == EOF) { + setstate(failbit); + return *this; + } + } + if(x_flags&left) { + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return *this; + } + } + osfx(); + } + return *this; +} + +void ostream::outstr(const char *s) { + + int len, p=0; + + len=strlen(s); + if((x_width) && (len > x_width)) + len=x_width; + if(!(x_flags&left)) { + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return; + } + } + while(p < len) { + if(_bp->sputc(s[p++]) == EOF) { + setstate(badbit); + return; + } + } + if(x_flags&left) { + if(pad_output(*this, len) == EOF) { + setstate(failbit); + return; + } + } + x_width=0; +} + +ostream& ostream::operator<<(void *p) { + + char buf[12]; + char *ob; + + if(opfx()) { + ob=&buf[2]; + _v_format((unsigned long) p, ob); + if(x_flags&ios::showbase) { + buf[0]='0'; + buf[0]='x'; + ob=buf; + } + outstr(ob); + osfx(); + } + return *this; +} + +ostream& ostream::operator<<(streambuf *sb) { + + int c, lim; + + if(opfx()) { + if(x_width) { + lim=x_width; + x_width=0; + } + else + lim=INT_MAX; + while((lim--) && ((c=sb->sbumpc()) != EOF)) { + if(_bp->sputc(c) == EOF) { + setstate(failbit); + break; + } + } + osfx(); + } + return *this; +} + +ostream& ostream::operator<<(ios& (*f)(ios &i)) { + + if(opfx()) { + f(*this); + osfx(); + } + return *this; +} + +ostream& ostream::operator<<(const char *s) { + + if(opfx()) { + outstr(s); + osfx(); + } + return *this; +} + + +int ostream::do_opfx() { + + if(state != goodbit) + return 0; + if(x_tie) + x_tie->flush(); + return 1; +} + + +int ostream::do_osfx() { + + if(x_flags&unitbuf) + flush(); +#ifndef _WINDOWS + if(x_flags&stdio) { + ::fflush(stdin); + ::fflush(stdout); + } +#endif + return good(); +} + +ostream& ostream::flush() { + + if(_bp->sync() == EOF) + setstate(failbit); + return(*this); +} + +//************************************************************************** +// iostream implementation +//************************************************************************** + + +iostream::iostream(streambuf *sb) : istream(sb), ostream(sb) { + +} + +iostream::iostream() { + +} + +iostream::~iostream() { + +} + +//************************************************************************** +// withassign stream implementation +//************************************************************************** + +ostream_withassign::ostream_withassign() { + + assign_const=_assign_init_magic; +} + +ostream_withassign::~ostream_withassign() { + +} + +istream_withassign::istream_withassign() { + + assign_const=_assign_init_magic; +} + +istream_withassign::~istream_withassign() { + +} + +iostream_withassign::iostream_withassign() { + + assign_const=_assign_init_magic; +} + +iostream_withassign::~iostream_withassign() { + +} + +istream_withassign& istream_withassign::operator=(istream& is) { + + ios::init(is.rdbuf()); + x_tie=is.tie(); + state=is.rdstate(); + x_flags=is.flags(); + x_precision=is.precision(); + x_width=is.width(); + x_fill=is.fill(); + return *this; +} + +istream_withassign& istream_withassign::operator=(streambuf* sb) { + + ios::init(sb); + return *this; +} + +ostream_withassign& ostream_withassign::operator=(ostream& os) { + + ios::init(os.rdbuf()); + x_tie=os.tie(); + state=os.rdstate(); + x_flags=os.flags(); + x_precision=os.precision(); + x_width=os.width(); + x_fill=os.fill(); + return *this; +} + +ostream_withassign& ostream_withassign::operator=(streambuf* sb) { + + ios::init(sb); + return *this; +} + +iostream_withassign& iostream_withassign::operator=(ios& iost) { + + ios::init(iost.rdbuf()); + x_tie=iost.tie(); + state=iost.rdstate(); + x_flags=iost.flags(); + x_precision=iost.precision(); + x_width=iost.width(); + x_fill=iost.fill(); + return *this; +} + +iostream_withassign& iostream_withassign::operator=(streambuf* sb) { + + ios::init(sb); + return *this; +} +ostream& endl(ostream& os) { + + os << "\n"; + return os; +} + +ostream& ends(ostream& os) { + + os.put('\0'); + return os; +} + +ostream& flush(ostream& os) { + + os.flush(); + return os; +} + +ios& dec(ios& i) { + + i.setf(ios::dec, ios::basefield); + return i; +} + +ios& hex(ios& i) { + + i.setf(ios::hex, ios::basefield); + return i; +} + +ios& oct(ios& i) { + + i.setf(ios::oct, ios::basefield); + return i; +} + +istream& ws(istream& is) { + + int c; + + while(isspace(c=is.get())); + if(c != EOF) + is.rdbuf()->sputbackc(c); + return is; +} + +_STATIC char _cin_buf[BUFSIZ]; +_STATIC char _cout_buf[BUFSIZ]; +_STATIC char _clog_buf[BUFSIZ]; + + +_STATIC filebuf cin_fb (0, _cin_buf, BUFSIZ); +_STATIC filebuf cout_fb(1, _cout_buf, BUFSIZ); +_STATIC filebuf cerr_fb(2, NULL, 0); +_STATIC filebuf clog_fb(2, _clog_buf, BUFSIZ); + +extern "C" void _init_standard() { + + cin=(streambuf *) &cin_fb; + cout=(streambuf *) &cout_fb; + cout.setf(ios::unitbuf); + cerr=(streambuf *) &cerr_fb; + clog=(streambuf *) &clog_fb; + clog.setf(ios::unitbuf); +} + +static ios& set_width(ios& iosc, int wid) { + + iosc.width(wid); + return iosc; +} + + +smanip_int setw(int _n) { + + return smanip_int(set_width, _n); +} + +static ios& set_base(ios& iosc, int bas) { + + iosc.setf(bas, ios::basefield); + return iosc; +} + + +smanip_int setbase(int _b) { + + return smanip_int(set_base, _b); +} + +static ios& reset_flags(ios& iosc, long f) { + + iosc.unsetf(f); + return iosc; +} + + +smanip_long resetiosflags(long _f) { + + return smanip_long(reset_flags, _f); +} + +static ios& set_flags(ios& iosc, long f) { + + iosc.flags(f); + return iosc; +} + +smanip_long setiosflags(long _f) { + + return smanip_long(set_flags, _f); +} + +static ios& set_fill(ios& iosc, int fl) { + + iosc.fill(fl); + return iosc; +} + + +smanip_int setfill(int _f) { + + return smanip_int(set_fill, _f); +} + +static ios& set_precision(ios& iosc, int pr) { + + iosc.precision(pr); + return iosc; +} + + +smanip_int setprecision(int _p) { + + return smanip_int(set_precision, _p); +} + + +istream_withassign cin; +ostream_withassign cout; +ostream_withassign cerr; +ostream_withassign clog; + +int genericerror(int code, char *m) { + + cerr << m; + exit(code); + return 0; +} + + \ No newline at end of file diff --git a/code/SIBOSDK/src/iplib.a b/code/SIBOSDK/src/iplib.a new file mode 100644 index 0000000..80ab344 --- /dev/null +++ b/code/SIBOSDK/src/iplib.a @@ -0,0 +1,9 @@ +(* 4K Epoc C header for use with PLIB *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +StackSize = 1000H + +include "iplib.inc" + + diff --git a/code/SIBOSDK/src/iplib.inc b/code/SIBOSDK/src/iplib.inc new file mode 100644 index 0000000..5453a77 --- /dev/null +++ b/code/SIBOSDK/src/iplib.inc @@ -0,0 +1,233 @@ +(* Epoc C header for use with PLIB include file *) +(* Release 1.10F NSM *) +(* Copyright (C) Psion PLC 1991-93 *) + +include "epocdefs.inc" + +Priority = 2 +ProcVar = 3 +InitSize = 5 +PRMAX = 32 + +module iplib + +section + +segment _TEXT(CODE,68H) + +segment STACK(STACK,74H) +public __stack_start: + +segment _MAGIC(MAGIC,68H) +public _DatWordDead: dw 0 +public _DatHandNext: dw 0 +public _DatHandPrev: dw 0 +public _DatCountrySeg: dw 0 +public _DatClassHandle: dw 0 +public _DatClassPtr: dw 0 +public _DatEClassHandle: dw 0 +public _DatEClassPtr: dw 0 +public _DatEnterFramePtr: dw 0 +public _w_ws: dw 0 +public _w_am: dw 0 +public _wClientData: dw 0 +public _wserv_channel: dw 0 +public _T: dw 0 +public _r: dw 0 +public _DatOsFramePtr: dw 0 +public _DatATFlag: db 0 +public _DatHeapLocked: db 0 +public _DatProcessNamePtr: dw 0 +public _DatCommandPtr: dw 0 +public _DatTest: dw 0 +public _DatApp1: dw 0 +public _DatApp2: dw 0 +public _DatApp3: dw 0 +public _DatApp4: dw 0 +public _DatApp5: dw 0 +public _DatApp6: dw 0 +public _DatApp7: dw 0 +public _DatDialogPtr: dw 0 +public _DatGate: dw 0 +public _DatLocked: dw 0 +public _DatStatusNamePtr: dw 0 +public _DatUsedPathNamePtr: dw 0 +org StackSize-40H + +segment _INIT(DATA,48H) +public __init_begin: + dw 0 +public __init_start: + +segment _CONST(DATA,48H) +public __const_start: + dw 0 + +segment _DATA(DATA,68H) +public __data_start: +public CoreSig@CnsHandler : dw 0 + +segment _BSS(BSS,68H) +public __bss_start: +public __SH_sword: + org 2 + +segment BSS_END(BSS,68H) +public __bss_end: + +select _DATA +extrn @InitPointer +extrn @InitPriority + +select _BSS +extrn @InitCount +extrn @InitEnd +extrn @InitDone +extrn @ExitCode +extrn @StackContextSP +extrn @StackContextBP + +group DGROUP(_MAGIC,_INIT,_CONST,_DATA,_BSS,BSS_END) + +select _TEXT +public __init0: + +extrn _main +extrn __FloatInit +extrn __FloatFinish +extrn __FloatMathExcepDos +extrn __FatalErrorPos +extrn __FatalError +extrn _ClassTable +extrn _ExtCatTable +extrn __InitSetup +extrn __InitLoop + + call __begin + ret far 0 + + dw __bss_start + dw _ExtCatTable + dw _ClassTable + dw _DatWordDead + dw __bss_end + +public _p_leave: + int LibLeave + int LibSendExit + + dw __init_start + dw __const_start + +public __begin: + sub al, al + mov ah, NmFilConnect + int FilManager + jc _p_abort + call __FloatInit + call __InitSetup + call __InitLoop +doExit: + call __FloatFinish + mov ah, NmProcId + int ProcManager + mov bx, ax + mov ax, [@ExitCode] + mov ah, NmProcKill + int ProcManager + +public _p_abort: + mov al, FailedToStartErr + mov [@ExitCode], ax + jmp doExit + +public __fp_0: + ret 0 + +public __fp_1: + ret 0 + +public __sigFp: + jmp __FloatMathExcepDos + +public __math_excep: + call __FatalErrorPos + mov bx, FatalMathException + jmp __FatalError + +public __InitSetup : + mov ax, __const_start + sub ax, __init_start + mov bl, InitSize + div bl + sub ah, ah + mov [@InitCount], ax + mul bl + add ax, __init_start + mov [@InitEnd], ax + and word [@InitDone], 0 + ret 0 + +public __InitLoop : + push di + push si + mov bx, [@InitPointer] + jmp traverseLoop +nextLoop: + add bx, InitSize +chainLoop: +traverseLoop: + cmp bx, [@InitEnd] + jae endOfArray + mov al, [@InitPriority] + cmp al, [bx][Priority] + jne nextLoop + lea ax, [bx][InitSize] + mov [@InitPointer], ax + dec word [@InitCount] + call [bx][ProcVar] + mov bx, [@InitPointer] + cmp word [@InitDone], 0 + je traverseLoop +initLoopRet: + pop si + pop di + ret 0 + +endOfArray: + cmp word [@InitCount], 0 + je stageComplete + +endOfList: + dec byte [@InitPriority] + js stageComplete + mov bx, __init_start + jmp chainLoop + +stageComplete: + inc word [@InitDone] + mov [@StackContextBP], bp + mov [@StackContextSP], sp + call _main + mov [@ExitCode], ax + jmp initLoopRet + +public _p_exit: + mov sp, [@StackContextSP] + mov bp, [@StackContextBP] + mov [@ExitCode], bx + jmp initLoopRet + +select _DATA +public @InitPointer : dw __init_start +public @InitPriority : db PRMAX + +select _BSS +public @InitCount : org 2 +public @InitEnd : org 2 +public @InitDone : org 2 +public @ExitCode : org 2 +public @StackContextSP : org 2 +public @StackContextBP : org 2 + +end * diff --git a/code/SIBOSDK/src/iplib2.a b/code/SIBOSDK/src/iplib2.a new file mode 100644 index 0000000..15b0e34 --- /dev/null +++ b/code/SIBOSDK/src/iplib2.a @@ -0,0 +1,9 @@ +(* 2K Epoc C header for use with PLIB *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +StackSize = 800H + +include "iplib.inc" + + diff --git a/code/SIBOSDK/src/iplib8.a b/code/SIBOSDK/src/iplib8.a new file mode 100644 index 0000000..273ccd8 --- /dev/null +++ b/code/SIBOSDK/src/iplib8.a @@ -0,0 +1,9 @@ +(* 8K Epoc C header for use with PLIB *) +(* Release 1.00F NSM *) +(* Copyright (C) Psion PLC 1991 *) + +StackSize = 2000H + +include "iplib.inc" + + diff --git a/code/SIBOSDK/src/new.cpp b/code/SIBOSDK/src/new.cpp new file mode 100644 index 0000000..3e3d176 --- /dev/null +++ b/code/SIBOSDK/src/new.cpp @@ -0,0 +1,90 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* NEW.CPP - new implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include + +#pragma module(init_prio=>22) + +_STATIC void (*new_handler)(void); + +#pragma save, call(reg_return=>(ax,bx)) +void* operator new(unsigned size) { + + void *b; + + b=p_alloc(size); + if((b == NULL) && (new_handler) && (size)) + new_handler(); + return b; +} +#pragma restore + +void* operator new(unsigned, void *place) { + + return place; +} + +void operator delete(void *p) { + + p_free(p); +} + +void (* set_new_handler(void(*nh)()))() { + + void (* ret)(); + + ret=new_handler; + new_handler=nh; + return ret; +} + +extern "C" void * _vec_new( char * obj_ptr, unsigned n, unsigned siz, ctor_t ctor, unsigned vbnum) { + + unsigned *h; + + if (! obj_ptr) { + h=(unsigned *)p_alloc(n * siz + sizeof(unsigned)); + if(h == NULL) { + if(new_handler) + new_handler(); + return NULL; + } + *h=n; + obj_ptr= (char *)(h + 1); + } + + if (ctor) + _call_ctors(ctor, (char *) obj_ptr, vbnum, n, siz); + + return obj_ptr; +} + +extern "C" void _vec_delete( char * obj_ptr, unsigned siz, dtor_t dtor, unsigned _free, unsigned vbnum, unsigned static_num) + { + unsigned n; + unsigned *tmp; + + if (obj_ptr) + { + tmp = (unsigned *)obj_ptr-1; + if(dtor) + { + if(_free) + n=*tmp; + else + n=static_num; + obj_ptr+=n*siz; + _call_dtors(dtor,obj_ptr,vbnum,n,siz); + } + if(_free) + p_free(tmp); + } + } diff --git a/code/SIBOSDK/src/nofloat.a b/code/SIBOSDK/src/nofloat.a new file mode 100644 index 0000000..df1fa60 --- /dev/null +++ b/code/SIBOSDK/src/nofloat.a @@ -0,0 +1,33 @@ +(* Release 3.00 *) + +module nofloat + +public FIDRQQ (* wait, esc*) = 0 +public FIARQQ (* wait, ds:*) = 0 +public FICRQQ (* wait, cs:*) = 0 +public FIERQQ (* wait, es:*) = 0 +public FISRQQ (* wait, ss:*) = 0 + +public FIWRQQ (* nop, wait*) = 0 + +public FJARQQ (* Esc nn -> ds:nn*) = 0 +public FJCRQQ (* Esc nn -> cs:nn*) = 0 +public FJSRQQ (* Esc nn -> es:nn*) = 0 +public FJERQQ (* ???????????????*) = 0 + +public FIXRQQ = 0 (* brings this module in - known to linker *) + +segment _TEXT(CODE,28H) + +extrn __fp_0 + +public __FloatInit : + jmp __fp_0 +public __FloatFinish: +public __FloatInitInstance: +public __FloatJmpSave : +public __FloatJmpRestore : +public __FloatMathExcepDos : + ret 0 + +end diff --git a/code/SIBOSDK/src/printf.c b/code/SIBOSDK/src/printf.c new file mode 100644 index 0000000..3e3091b --- /dev/null +++ b/code/SIBOSDK/src/printf.c @@ -0,0 +1,923 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* printf.c - formatted output module * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* Written by Simon Knight. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Modified by NSM. * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_CONIO +#include + +#define _VPUTC(c) _vputc(c) + +_STATIC int _insert_str(char *s, char c, int num); + +_STATIC int _con_flush(FILE *st); +_STATIC int _buf_flush(FILE *st); + +enum modifier { none, /* modifier prefixes */ + shortmod, /* short integer */ + longmod, /* long integer */ + ldmod }; /* LONGDOUBLE - syntax only */ + +_STATIC void _vprinter(const char *format, va_list _v_argptr) +{ + int n, p, c; + int np; + int pad; + int radix; + int pretemp; + int width, precision; + enum modifier mod; /* modifier type */ + int genflag; + long target; + char *in_str; + char _fmt_buf[64], *plist; + + n=0; + _vp_ret=0; + while((c=format[n++]) !=0) /* main loop to scan format string */ + { + switch(c) + { + case '%': + goto arg_eval; /* scan format spec */ +arg_eval_ret: +#pragma warn(wubd => off) + n+=p; +#pragma warn(wubd => on) + break; + default: /* output character */ + _VPUTC(c); + break; + } + } + return; + +arg_eval: + /* evaluate and output argument */ + plist=(char *) &format[n]; + p=0; /* set local format subscript */ + _upperHex='a'; /* default PF_HEX digit case */ + genflag=0; /* all flags to default */ + +/*************************************************************************** +* This paragraph reads any flags from the format string. The optimal * +* path is for no flags. Multiple flags are permitted. * +***************************************************************************/ + c=plist[p++]; + if(c == '%') + { + _VPUTC(c); + goto arg_eval_ret; + } + while(c != 0) + { + switch(c) + { + case '-': + genflag|=PF_LEFT; + goto cont; + case '+': + genflag|=PF_SIGN; + goto cont; + case '\ ': + genflag|=PF_SPACE; + goto cont; + case '#': + genflag|=PF_HASH; + goto cont; + case '0': + genflag|=PF_ZFLAG; + goto cont; + default: + goto noflag; + } +cont: + c=plist[p++]; + } +noflag: + if((genflag&PF_ZFLAG) && (genflag&PF_LEFT)) + genflag&=(~PF_ZFLAG); + if((genflag&PF_SIGN) && (genflag&PF_SPACE)) + genflag&=(~PF_SPACE); +/*************************************************************************** +* The next paragraph evaluates any width parameter if present. There is * +* no limit on field width apart from integer range. * +***************************************************************************/ + + width=0; + while (isdigit(c)) + { + width *= 10; + width += c- 0x30; + c=plist[p++]; + } + if(c == '*') /* _width is argument */ + { + width = va_arg(_v_argptr, int); + if(width < 0) + { + width*= -1; + genflag|=PF_LEFT; + genflag&=(~PF_ZFLAG); + } + c=plist[p++]; + } + +/*************************************************************************** +* The next paragraph evaluates any precision parameter if present. * +* Default precisions are set by the data type functions. PF_NOPOINT * +* if precision implicitly set to 0. Maximum precison is 32 digits. * +***************************************************************************/ + + precision=0; + pretemp=0; + if(c == '.') + { + while(isdigit(c=plist[p++])) + { + pretemp *= 10; + pretemp += c - 0x30; + } + if(c == '*') /* precision is argument */ + { + pretemp = va_arg(_v_argptr, int); + c=plist[p++]; + } + if(pretemp >= 0) + { + if(pretemp == 0) /* precision explicitly zero */ + genflag|=PF_NOPOINT; + else + { + precision=pretemp; /* precision non zero */ + if(precision > 32) + precision = 32; + } + genflag|=PF_PSET; + } + } + +/*************************************************************************** +* The next paragraph evaluates any type modifiers present. The optimal * +* path is for no modifiers * +***************************************************************************/ + + switch(c) + { + case 0 : /* incomplete spec - return for */ + case '\ ': /* literal output */ + _VPUTC('%'); + p=0; + goto arg_eval_ret; + case 'h': + mod=shortmod; /* short integer */ + goto modcont; + case 'l': + mod=longmod; /* long integer */ + goto modcont; + case 'L': + mod=ldmod; /* LONGDOUBLE ( no semantics) */ + goto modcont; + default: + mod=none; + break; +modcont: + c=plist[p++]; + break; + } + +/*************************************************************************** +* The next paragraph is the main switch for data types. Arguments are * +* fetched and evaluated by the appropriate conversion function with the * +* result in a buffer. The address of this buffer is passed to the * +* appropriate output section - _int_out, _real_out or _str_out. * +***************************************************************************/ + + switch(c) + { + case 'i': /* integer types */ + case 'd': + genflag|=PF_IS_SIGNED; + radix=10; + switch(mod) + { + case longmod: + target=va_arg(_v_argptr, long); + break; + case shortmod: + target= (long) va_arg(_v_argptr, short); + break; + default: + target= (long) va_arg(_v_argptr, int); + break; + } + goto int_out; + case 'u': /* unsigned */ + radix=10; + goto get_uns; + case 'o': /* octal */ + genflag|=PF_OCT; + radix=8; + goto get_uns; +do_nptr: + case 'X': /* PF_HEX */ + genflag|=PF_UPPER; + _upperHex= 'A'; + case 'x': + genflag|=PF_HEX; + radix=16; +get_uns: + switch(mod) + { + case longmod: + target=va_arg(_v_argptr, long); + break; + case shortmod: + target= (long) (unsigned) va_arg(_v_argptr, short); + break; + default: + target= (long) (unsigned) va_arg(_v_argptr, int); + break; + } + goto int_out; +int_ret: + break; + case 'E': /* reals */ + genflag|=PF_UPPER; /* exponent form */ + case 'e': + genflag|=PF_EXP; + case 'f': + goto do_real; + case 'G': + genflag|=PF_UPPER; + case 'g': + genflag|=PF_GTYPE; +do_real: + if(mod == ldmod) + genflag |= PF_LDMOD; + if((precision == 0) && ((genflag&PF_NOPOINT)==0)) + precision=6; + _v_argptr=_real_out(_v_argptr, genflag, width, precision); + break; + case 'c': /* character */ + if(!(genflag&PF_LEFT)) + { + while(width > 1) + { + _VPUTC(' '); + --width; + } + } + _VPUTC(va_arg(_v_argptr, int)); + while(width > 1) + { + _VPUTC(' '); + --width; + } + goto arg_eval_ret; + case 's': + genflag&= ~PF_ZFLAG; + precision=pretemp; + in_str= (char *)(va_arg(_v_argptr, char *)); + if(in_str) + _str_out(in_str, genflag, width, precision); + break; + case 'n': + switch(mod) + { + case longmod: + *(va_arg(_v_argptr, long *)) = _vp_ret; + break; + default : + *(va_arg(_v_argptr, int *)) = _vp_ret; + break; + } + goto arg_eval_ret; + case 'p': /* pointer */ + precision=4; + mod=none; + goto do_nptr; + default: /* invalid type - return for literal output */ + _VPUTC('%'); + p=0; + goto arg_eval_ret; + } + goto arg_eval_ret; + +/*************************************************************************** +* This paragraph handles precision and format for the integer value * +* now in the form of an ASCIIZ string. * +***************************************************************************/ + +int_out: + + np=50; + if(genflag&PF_IS_SIGNED) + ltoa(target, &_fmt_buf[50], radix); + else + ultoa(target, &_fmt_buf[50], radix); + if(precision == 0) /* set default precision */ + { + if((target == 0) && (genflag&PF_NOPOINT)) { + np=0; + if((genflag&PF_SPACE) && ((genflag&PF_IS_SIGNED))) + _fmt_buf[np++]='\ '; + _fmt_buf[np]='\0'; + _justify(_fmt_buf, genflag, width); /* and ouput */ + goto int_ret; + } + precision = 1; + } + + if((genflag&PF_ZFLAG) && (!(genflag&PF_PSET))) + { + precision=width; + width=0; + if(((target < 0) || (genflag&PF_SIGN)) && (precision > 0)) + --precision; + } + genflag&= ~PF_ZFLAG; + if((target < 0) && (genflag&PF_IS_SIGNED)) + np++; + pad = precision - strlen(&_fmt_buf[np]); /* pad with '0' to precision */ + while(pad > 0) + { + _fmt_buf[--np]='0'; + pad--; + } + if(genflag&(PF_HEX|PF_OCT)) /* PF_HEX and octal prefix */ + { + if((genflag&PF_HASH) && (target)) + { + if(genflag&PF_HEX) + { + if(genflag&PF_UPPER) + _fmt_buf[--np]='X'; + else + _fmt_buf[--np]='x'; + } + _fmt_buf[--np]= '0'; + } + } + if(genflag&PF_IS_SIGNED) + { /* set +/- */ + if(target >= 0) + { + if(genflag&PF_SIGN) /* leading + required */ + _fmt_buf[--np]= '+'; + else if(genflag&PF_SPACE) /* leading PF_SPACE required */ + _fmt_buf[--np]= ' '; + } + else + _fmt_buf[--np]='-'; /* copy existing PF_SIGN */ + } + _justify(&_fmt_buf[np], genflag, width); /* and ouput */ + goto int_ret; + + +} /* end of vprinter */ + + +/*************************************************************************** +* This next paragraph handles precision and format for the real value * +* now in the form of an ASCCIZ string. * +***************************************************************************/ + +va_list _rreal_out(va_list _v_argptr, int flag, int wid, int prec) +{ + char _fmt_buf[64]; + LONGDOUBLE ld; + + if(flag&PF_LDMOD) + ld=va_arg(_v_argptr, LONGDOUBLE); + else + ld=(LONGDOUBLE) va_arg(_v_argptr, double); + _f_fmt(_fmt_buf, ld, flag, prec); + _justify(_fmt_buf, flag, wid); + return(_v_argptr); +} + +_STATIC int _insert_str(char *s, char c, int num) +{ /* insert characters into string */ + movmem(s, s+num, strlen(s)+1); + setmem(s, num, c); + return(num); +} + +/*************************************************************************** +* This next function handles far pointer arguments. * +***************************************************************************/ + + +char *_fptoa(unsigned long ptr, char *s) + { + int pad; + unsigned off; + + _upperHex='A'; + ultoa(ptr>>16, s, 16); + s[4]=0; + pad=4-strlen(s); + if(pad > 0) + _insert_str(s, '0', pad); + s[4]=':'; + off=(unsigned) ptr; + ultoa((unsigned long) off, &s[5], 16); + pad=4-strlen(&s[5]); + s[9]=0; + if(pad > 0) + _insert_str(&s[5], '0', pad); + _upperHex='a'; + return(s); + } + +char *_f_fmt(char *_fmt_buf, LONGDOUBLE num, int flag, int prec) +{ + int np, nq; + char extemp[18], out_str[64]; + int dec, csign; + int fd; + int r, t; + int round, noround, tzeros; + + np=0; + nq=0; + _cvt( num, 18, &dec, &csign, out_str); + if(abs(dec) > 30) /* default to exponential form */ + flag|=PF_EXP; + if(csign) /* set PF_SIGN */ + _fmt_buf[np++]='-'; + else if(flag&PF_SIGN) + _fmt_buf[np++]= '+'; /* leading + */ + else if(flag&PF_SPACE) + _fmt_buf[np++]= ' '; /* leading space */ + if(flag&PF_HASH) + flag&=~PF_NOPOINT; /* force decimal point */ + fd=np; + +/*************************************************************************** +* This paragraph evaluates whether the exponential form is required and * +* copies the first digit of the mantissa and inserts the decimal point * +* If the exponent form is not being used, the position of the decimal * +* point is calulated and 0s are inserted if necessary. * +***************************************************************************/ + + if( ((flag&PF_GTYPE) && ((dec > (prec)) || (dec < -4))) || (flag&PF_EXP)) + { + flag|=PF_EXP; /* get first digit and decimal point */ + _fmt_buf[np++]=out_str[nq++]; + if(flag&PF_GTYPE) + --prec; + if(!(flag&PF_NOPOINT)) + _fmt_buf[np++]=DEC_POINT; + } + else + { + flag&=~PF_EXP; + if(dec <= 0) /* if negative exponent pad */ + { + _fmt_buf[np++]='0'; + if(!(flag&PF_NOPOINT)) + { + r=dec; + _fmt_buf[np++]=DEC_POINT; + while(r++ < 0) + { + if(--prec < 0) { + nq=-1; /* dont round */ + break; + } + _fmt_buf[np++]='0'; + } + } + else + nq=-1; + } + else /* positive exponent */ + { + r=dec; + while(r-- > 0) + { + t=out_str[nq++]; + if(nq > 17) + t='0'; + _fmt_buf[np++]= (char) t; + if(flag&PF_GTYPE) + { + if(prec-- == 0) + break; + } + } + if(!(flag&PF_NOPOINT)) + _fmt_buf[np++]=DEC_POINT; + } + } + +/*************************************************************************** +* This paragraph copies the digits to the right of the decimal point * +* to the limit of precison, padding with 0s if necessary. * +***************************************************************************/ + + noround=FALSE; + tzeros=FALSE; + if(!(flag&PF_NOPOINT)) /* copy digits to precision */ + { + tzeros=TRUE; + while(prec > 0) + { + if(nq > 17) + { + noround=TRUE; + break; + } + _fmt_buf[np++]=out_str[nq++]; + prec--; + } + if (prec > 0) + { /* pad to precision if necessary */ + noround=TRUE; + if((!(flag&PF_GTYPE)) || (flag&PF_HASH)) + { + while(prec-- > 0) + { + _fmt_buf[np++]='0'; + } + } + } + } + _fmt_buf[np]=0; + +/*************************************************************************** +* This paragraph rounds the copied number if any digits remain unused. * +***************************************************************************/ + + if(nq != -1) { + round=out_str[nq]; + if((!noround) && (isdigit(round))) /* round if any digits remain */ + { + r=np-1; + if(round >= '5') + { + while(r >= fd-1) + { + if(_fmt_buf[r] == DEC_POINT) /* skip decimal point */ + r--; + if(++_fmt_buf[r] > '9') + _fmt_buf[r--]='0'; + else + break; /* no carry */ + if(r < fd) + { + if(flag&PF_EXP) /* handle high order carry */ + { + _fmt_buf[r+1]='1'; + ++dec; + } + else + { + _insert_str(&_fmt_buf[fd], '1', 1); + np++; + } + break; + } + } + } + } + } + + if((tzeros) && (flag&(PF_GTYPE|PF_CPP)) && (!(flag&PF_HASH))) + { + while(_fmt_buf[--np] == '0') + { + _fmt_buf[np]=0; + } + ++np; + } + +/*************************************************************************** +* If required, this paragraph converts the exponent to ASCII string and * +* copies it to the target buffer. * +***************************************************************************/ + + if((_fmt_buf[np-1] == DEC_POINT) && (!(flag&PF_HASH))) + --np; + if((flag&PF_EXP) && ((dec != 1) || (!(flag&PF_GTYPE)))) + { + if(flag&PF_UPPER) + _fmt_buf[np++]='E'; + else + _fmt_buf[np++]='e'; + if(--dec < 0) + { + _fmt_buf[np++]='-'; + dec=abs(dec); + } + else + _fmt_buf[np++]='+'; + itoa(dec, extemp, 10); + t=strlen(extemp); + r=2-t; + if(r < 0 ) + r=0; + while(r--) + { /* insert leading 0s */ + _fmt_buf[np++]='0'; + } + r=0; + while(r < t) + { + _fmt_buf[np++]=extemp[r++]; + } + } + +/*************************************************************************** +* This paragraph terminates the string and calls the function which * +* justifies the number within its field width and outputs it. * +***************************************************************************/ + _fmt_buf[np]=0; + return(_fmt_buf); +} + +void _vp_setbuf(FILE *st, char *buffer) +{ + st->_base=buffer; + st->_ptr=buffer; + st->_size=PF_TEMP_BUF; + st->_cnt=PF_TEMP_BUF; + st->_flag|=_F_UBUF; + st->_flag&=(~_F_RST); + return; +} + +void _vp_freebuf(FILE *st) +{ + st->_size=0; + st->_cnt=0; + st->_flag&=(~_F_UBUF); + return; +} + +/*-------------------------------------------------------------------------* +* printf.c - formatted output to stdout * +* This function provides formatted output to stdout for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int printf(const char *format, ...) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if(stdout->_size == 0) + { + char buffer[PF_TEMP_BUF]; + + stdout->_flag|=_F_RST; + _vp_setbuf(stdout, buffer); + temp_buf=1; + } + _vp_flush=_flusher; /* set output flusher */ + _stream=stdout; + va_start(_v_argptr, format); /* initialise argument pointer */ + _vprinter(format, _v_argptr); /* do it */ + if(temp_buf) + { + _flusher(stdout); + stdout->_flag|=_F_RST; + _vp_freebuf(stdout); + } + else if(stdout->_flag&_F_DEV) + _flusher(stdout); + ret=_vp_ret; + return(ret); /* return number of characters output */ +} + +/*-------------------------------------------------------------------------* +* cprintf.c - formatted output to console * +* This function provides formatted output to console for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int _con_flush(FILE *st) +{ + int n, num; + char *buf; + + n=0; + buf=st->_base; + num=st->_cnt; + if(num < 0) + num=0; + num=st->_size-num; + while(num-- > 0) + { + putch(buf[n++]); + } + st->_cnt=st->_size; + st->_ptr=st->_base; + return(0); +} + +int cprintf(const char *format, ...) +{ + + va_list _v_argptr; + FILE cst; + char cbuf[PF_VBSIZE]; + int ret; + + _vp_flush=_con_flush; /* set output function */ + cst._cnt=PF_VBSIZE; + cst._size=PF_VBSIZE; + cst._base=cbuf; + cst._ptr=cbuf; + _stream=&cst; + va_start(_v_argptr, format); /* initialise argument pointer */ + _vprinter(format, _v_argptr); /* do it */ + _con_flush(&cst); + ret=_vp_ret; + return(ret); /* return number of characters output */ +} + +/*-------------------------------------------------------------------------* +* sprintf.c - formatted output to buffer * +* This function provides formatted output to a character buffer for a * +* variable number of arguments. * +*--------------------------------------------------------------------------*/ + +int _buf_flush(FILE *st) +{ + st->_cnt=st->_size; + st->_ptr=st->_base; + return(0); +} + +int sprintf(char *s, const char *format, ...) +{ + va_list _v_argptr; + FILE sst; + int ret; + + _vp_flush=_buf_flush; /* set output function */ + sst._base=s; + sst._ptr=s; + sst._cnt=INT_MAX-1; + sst._size=INT_MAX-1; + sst._flag=_F_BIN; + _stream=&sst; + va_start(_v_argptr, format); /* initialise argument pointer */ + _vprinter(format, _v_argptr); /* do it */ + *sst._ptr=0; + ret=_vp_ret; + return(ret); /* return number of characters output */ +} + +/*-------------------------------------------------------------------------* +* fprintf.c - formatted output to stream * +* This function provides formatted output to stream for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int fprintf(FILE *st, const char *format, ...) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if((st->_flag&_F_IN) || (!(st->_flag&_F_WRIT))) + return(-1); + if(st->_size == 0) + { + char buffer[PF_TEMP_BUF]; + + st->_flag|=_F_RST; + _vp_setbuf(st, buffer); + temp_buf=1; + } + _vp_flush=_flusher; /* set output function */ + _stream=st; /* initialise file pointer */ + va_start(_v_argptr, format); /* initialise argument pointer */ + _vprinter(format, _v_argptr); /* do it */ + if(temp_buf) + { + _flusher(st); + st->_flag|=_F_RST; + _vp_freebuf(st); + } + else if(st->_flag&_F_DEV) + _flusher(st); + ret=_vp_ret; + return(ret); /* return number of characters output */ +} + +/*-------------------------------------------------------------------------* +* vprintf.c - formatted output to stdout * +* This function provides formatted output to stdout for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int vprintf(const char *format, va_list param) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if(stdout->_size == 0) + { + char buffer[PF_TEMP_BUF]; + + stdout->_flag|=_F_RST; + _vp_setbuf(stdout, buffer); + temp_buf=1; + } + _vp_flush=_flusher; /* set output function */ + _v_argptr= param; /* initialise argument pointer */ + _stream=stdout; + _vprinter(format, _v_argptr); /* do it */ + if(temp_buf) + { + _flusher(stdout); + stdout->_flag|=_F_RST; + _vp_freebuf(stdout); + } + else if(stdout->_flag&_F_DEV) + _flusher(stdout); + ret=_vp_ret; + return(ret); /* return number of characters output */ +} + +/*-------------------------------------------------------------------------* +* vsprintf.c - formatted output to buffer * +* This function provides formatted output to a character buffer for a * +* variable number of arguments. * +*--------------------------------------------------------------------------*/ + +int vsprintf(char *s, const char *format, va_list param) +{ + va_list _v_argptr; + FILE sst; + int ret; + + _vp_flush=_buf_flush; /* set output function */ + sst._base=s; + sst._ptr=s; + sst._cnt=INT_MAX-1; + sst._size=INT_MAX-1; + sst._flag=_F_BIN; + _stream=&sst; + _v_argptr= param; /* initialise argument pointer */ + _vprinter(format, _v_argptr); /* do it */ + *sst._ptr=0; /* terminator for output string */ + ret=_vp_ret; + return(ret); /* return number of characters output */ +} + +/*-------------------------------------------------------------------------* +* vfprintf.c - formatted output to stream * +* This function provides formatted output to stream for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int vfprintf(FILE *st, const char *format, va_list param) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if((st->_flag&_F_IN) || (!(st->_flag&_F_WRIT))) + return(-1); + if(st->_size == 0) + { + char buffer[PF_TEMP_BUF]; + + st->_flag|=_F_RST; + _vp_setbuf(st, buffer); + temp_buf=1; + } + _vp_flush=_flusher; /* set output function */ + _stream=st; /* set file pointer */ + _v_argptr=param; /* initialise argument pointer */ + _vprinter(format, _v_argptr); /* do it */ + if(temp_buf) + { + char buffer[PF_TEMP_BUF]; + + _flusher(st); + st->_flag|=_F_RST; + _vp_setbuf(st, buffer); + } + else if(st->_flag&_F_DEV) + _flusher(st); + ret=_vp_ret; + return(ret); /* return number of characters output */ +} diff --git a/code/SIBOSDK/src/r_emul.a b/code/SIBOSDK/src/r_emul.a new file mode 100644 index 0000000..057c087 --- /dev/null +++ b/code/SIBOSDK/src/r_emul.a @@ -0,0 +1,136 @@ +(* Release 3.00 *) + +module r_emul + +include "corelib.inc" +include "epocdefs.inc" + +public FIDRQQ = 05C32H +public FIWRQQ = 0A23DH + +public FIERQQ = 01632H +public FIARQQ = 0FE32H +public FISRQQ = 00632H +public FICRQQ = 00E32H + +public FJERQQ = 00000H +public FJARQQ = 04000H +public FJSRQQ = 08000H +public FJCRQQ = 0C000H + +public FIXRQQ = 0 + +segment _TEXT(CODE,28H) +segment _DATA(DATA,28H) + +__emName: db 'SYS$8087.LDD',0 +__lddName: db 'EM$:',0 +__lddNameX: db 'EM$',0 + +extrn __SH_sword +extrn _DatCommandPtr + +segment _DATA(DATA,28H) + +__FChan: dw 0 + +select _TEXT + +extrn __fp_1 +extrn __sigFp +extrn __math_excep +extrn __FatalErrorPos +extrn __FatalError + +xEnv = -256 +xBuf = xEnv-MaxPathSize + +public __FloatInit: + + push bp + mov bp, sp + add sp, xBuf +; + sub dx, dx + mov cx, [_DatCommandPtr] + jcxz noCommandLine +tryAgain: + mov bx, __emName + lea di, [bp][xBuf] + sub si, si + sub al, al + mov ah, NmFilParse + int FilManager + jc noCommandLine + mov bx, di + xor al, al + mov ah, NmDevLoadLDD + int DevManager + jnc loadedLdd + cmp al, ExistsErr + je loadedLdd + test dx, dx + jne openFailed +noCommandLine: + inc dx + lea si, [bp][xEnv] + mov di, __lddNameX + mov ah, NmGenEnvStringGet + int GenManager + jc openFailed + mov cx, si + jmp tryAgain +loadedLdd: + mov dx, __sigFp + mov cx, -1 + mov bx, __lddName + mov ah, NmIoOpen + int DevManager + jc openFailed + mov [__FChan], ax +; + mov sp, bp + pop bp + jmp __fp_1 +; +openFailed: + call __FatalErrorPos + mov bx, 0FFFFH + jmp __FatalError + +public __FloatFinish: + + mov bx, [__FChan] + test bx, bx + je skipClose + mov ah, NmIoClose + int IoManager + mov bx, __lddNameX + mov dx, LDDSignature + mov ah, NmDevDelete + int DevManager +skipClose: + ret 0 + +public __FloatMathExcepDos : + fstsw [__SH_sword] + fclex + jmp near __math_excep + +public __FloatJmpSave : + + fld st(0), st(1) + fstp tbyte [di][_j_st1], st(0) + fld st(0), st(2) + fstp tbyte [di][_j_st2], st(0) + ret 0 + +public __FloatJmpRestore : + + fld tbyte st(0), [si][_j_st1] + fstp st(2), st(0) + fld tbyte st(0), [si][_j_st2] + fstp st(3), st(0) + ret 0 + +end diff --git a/code/SIBOSDK/src/scanf.c b/code/SIBOSDK/src/scanf.c new file mode 100644 index 0000000..3129409 --- /dev/null +++ b/code/SIBOSDK/src/scanf.c @@ -0,0 +1,899 @@ +/* Release 3.00 */ + +/*-------------------------------------------------------------------------* +* * +* r_scanf.c - MSDOS formatted input module * +* * +* COPYRIGHT (C) 1989 Jensen and Partners. All Rights Reserved * +* Written by Simon Knight. * +* * +* COPYRIGHT (C) 1991 Psion PLC. All Rights Reserved * +* Modified by NSM. * +* * +*--------------------------------------------------------------------------*/ + +#define _USE_CONIO +#include + +_STATIC void _vscanner(const char *param_list, va_list _v_argptr); +_STATIC va_list _get_int(int pmod, int smod, unsigned flag, int width, va_list _v_argptr); +_STATIC va_list _get_char(int pmod, unsigned flag, int width, int setwidth, va_list _v_argptr); +_STATIC va_list _get_str(int pmod, unsigned flag, int width, va_list _v_argptr); +_STATIC va_list _get_str_delim(char *s, int pmod, unsigned flag, int width, va_list _v_argptr); +_STATIC va_list _get_pointer(int pmod, unsigned flag, va_list _v_argptr); +_STATIC int _skip_space(void); +_STATIC int _scan_input(int scan_state); +_STATIC int _isterm(char *s, char tc); +_STATIC int _buf_fil(FILE *st); +_STATIC int _con_fil(FILE *st); + +int _vgetc(void); +int _vungetc(int c); + +enum modifier { none, /* modifier prefixes */ + shortmod, /* short integer */ + longmod, /* long integer */ + ldmod }; /* LONGDOUBLE */ + +#define _VGETC() _vgetc() +#define _VUNGETC(c) _vungetc(c) +#define _SKIP_SPACE() _skip_space() +#define _SCAN_INPUT(scan_state) _scan_input(scan_state) + +/**************************************************************************** +* this function scans the format string. * +****************************************************************************/ + +_STATIC void _vscanner(const char *plist, va_list _v_argptr) +{ + int n; + int c, i; + int p, f; + int pmod, smod; + int width, setwidth; + unsigned flag; + char *tlist; + + n=0; + _s_args=0; + _vs_count=0; /* zero counts */ + while((c=plist[n++]) != 0) /* scan format string */ + { + if(_v_argptr == NULL) + break; + if(isspace(c)) /* skip white space characters */ + { /* between input data */ + while(isspace(i=_VGETC())); /* force end of file */ + if(i > 0) + { + _VUNGETC(i); + continue; + } + else + return; + } + if(c == '%') /* evaluate format spec */ + { + tlist=(char *) &plist[n]; + goto _fmt_eval; +_fmt_eval_ret: +#pragma warn(wubd => off) + if(p) + { + n+=p; +#pragma warn(wubd => on) + continue; + } + else /* format spec error */ + { /* get next character and */ + if((c=plist[n++]) == 0) /* check against input */ + break; + } + } + if(c != (i =_VGETC())) /* if input char doesn't match - */ + { + _VUNGETC(c); + break; /* terminate */ + } + } + _vs_count++; + return; + +/**************************************************************************** +* This routine evaluates the format spec. * +****************************************************************************/ + +_fmt_eval: + + p=0; + flag=0; + f=tlist[0]; + if(f == '*') + { + flag|=SF_SUPRESS; /* suppress asignment */ + p++; + } + +/*************************************************************************** +* The next paragraph evaluates any width parameter if present. There is * +* no limit on field width apart from integer range. * +***************************************************************************/ + + width=0; + f=tlist[p++]; + while (isdigit(f)) + { + width *= 10; + width += f- 0x30; + f=tlist[p++]; + } + if(!width) + { + setwidth=0; /* width explicitly 0 */ + width=SHRT_MAX; + } + else + setwidth=width; + +/*************************************************************************** +* This paragraph evaluates any pointer modifiers present. The optimal * +* path is for no modifiers * +***************************************************************************/ + + pmod=none; + +/*************************************************************************** +* This paragraph evaluates any size modifiers present. The optimal * +* path is for no modifiers * +***************************************************************************/ + + switch(f) + { + case 0 : /* incomplete spec - return */ + case '\ ': + p=0; + goto _fmt_eval_ret; + case 'h': + smod=shortmod; /* short integer */ + f=tlist[p++]; + break; + case 'L': + smod=ldmod; /* LONGDOUBLE */ + f=tlist[p++]; + break; + case 'l': + smod=longmod; /* long integer */ + f=tlist[p++]; + break; + default: + smod=none; + break; + } + +/*************************************************************************** +* This paragraph is the main type switch. The argument pointer is taken * +* from the argument list and input and conversion functions called, where* +* if not disabled, an assignment is made. * +***************************************************************************/ + + switch(f) + { + case 'i': + flag|=SF_WILD; + goto _do_int; + break; + case 'd': + goto _do_int; + break; + case 'o': + flag|=SF_OCT; + goto _do_int; + break; + case 'X': + case 'x': + flag|=SF_HEX; + goto _do_int; + break; + case 'U': + flag|=SF_UPPER; + case 'u': + flag|=SF_NSIGNED; +_do_int: + _v_argptr=_get_int(pmod, smod, flag, width, _v_argptr); + break; + case 'E': /* real types */ + case 'e': + case 'f': + case 'G': + case 'g': + _v_argptr=_real_in(pmod, smod, flag, width, _v_argptr); + break; + case 'c': /* character */ + _v_argptr=_get_char(pmod, flag, width, setwidth, _v_argptr); + break; + case 's': /* string */ + _v_argptr=_get_str(pmod, flag, width, _v_argptr); + break; + case '[': /* deliminated string */ + _v_argptr=_get_str_delim(&tlist[p], pmod, flag, width, _v_argptr); + while((tlist[p++] != ']') && (p-1)); + break; + case 'n': /* character count */ + if(smod == longmod) + *(va_arg(_v_argptr, long *)) = _vs_count; + else + *(va_arg(_v_argptr, int *)) = _vs_count; + break; + case 'p': /* pointer */ + flag|=(SF_HEX); + pmod=none; + goto _do_int; + default: + p=0; + goto _fmt_eval_ret; + } + goto _fmt_eval_ret; /* return */ +} + +_STATIC int _skip_space() +{ + int i; + + while(isspace(i=_VGETC())); /* skip white space in stream */ + if(i >= 0) + { + _VUNGETC(i); + return(0); + } + else if(_s_args == 0) + longjmp(_EOFhandler, 1); + return(-1); +} + +_STATIC int _scan_input(int scan_state) +{ + int c; + + c=_VGETC(); + if(c != -1) + return(c); + if((_s_args == 0) && (scan_state == 0)) + longjmp(_EOFhandler, 1); + return(-1); +} + +/**************************************************************************** +* This function scans the input stream and converts to an integer. * +****************************************************************************/ + +_STATIC va_list _get_int(int pmod, int smod, unsigned flag, int width, va_list _v_argptr) +{ + unsigned long temp; + int c, good_scan; + int negative; + void *iptr; + + temp=0; + good_scan=0; + negative=FALSE; + if(_SKIP_SPACE() == -1) + return(_v_argptr); + c=_SCAN_INPUT(good_scan); + if((c == '+') && (width)) + { + if((c=_SCAN_INPUT(good_scan)) == -1) + return(_v_argptr); + --width; + } + else if((c == '-') && (width)) + { /* number is negative */ + negative=TRUE; + if((c=_SCAN_INPUT(good_scan)) == -1) + return(_v_argptr); + --width; + } + if(flag&SF_WILD) + { /* get dec oct or hex */ + if((c =='0') && (width)) + { + flag|=SF_OCT; + --width; + good_scan=1; + c=_SCAN_INPUT(good_scan); + c=tolower(c); + if(c == 'x') + { + flag|=SF_HEX; + if((c=_SCAN_INPUT(good_scan)) == -1) + return(_v_argptr); + --width; + } + } + } + if(flag&SF_HEX) /* convert hex */ + { + if((c =='0') && (width)) + { + --width; + good_scan=1; + c=_SCAN_INPUT(good_scan); + c=tolower(c); + if(c == 'x') + { + if((c=_SCAN_INPUT(good_scan)) == -1) + return(_v_argptr); + --width; + } + } + while((isxdigit(c=tolower(c))) && (width >0)) + { + good_scan=1; + temp*=16; + if(!isdigit(c)) + c-=87; + else + c-='0'; + temp+=c; + c=_SCAN_INPUT(good_scan); + --width; + } + } + else if(flag&SF_OCT) /* convert octal */ + { + while((c >= '0') && (c <= '7') && (width>0)) + { + good_scan=1; + temp*=8; + temp+=c-'0'; + c=_SCAN_INPUT(good_scan); + --width; + } + } + else /* convert decimal */ + { + while((isdigit(c)) && (width>0)) + { + good_scan=1; + temp*=10; + temp+=c-'0'; + c=_SCAN_INPUT(good_scan); + --width; + } + } + _VUNGETC(c); + if((!(flag&SF_NSIGNED)) && (negative)) /* ignore '-' if unsigned */ + temp*= -1; + if(!good_scan) + return(NULL); + if(!(flag&SF_SUPRESS)) /* assign field unless suppressed */ + { + if(flag&SF_UPPER) + smod=longmod; + iptr = (va_arg(_v_argptr, void *)); + switch(smod) + { + case shortmod: + *((short *) iptr) = (short) temp; + break; + case longmod: + *((long *) iptr) = (long) temp; + break; + default: + *((int *) iptr) = (int) temp; + break; + } + _s_args++; /* inc argument counter */ + } + return(_v_argptr); +} + +/**************************************************************************** +* This function scans the input stream and converts to real. * +****************************************************************************/ + +#pragma warn(wall => off) + +va_list _rreal_in(int pmod, int smod, unsigned flag, int width, va_list _v_argptr) +{ + int n, q, c, good_scan; + LONGDOUBLE volatile dtemp; + char _fmt_buf[64]; /* buffer for formatted number */ + void *dptr; + + n=0; + good_scan=0; + if(_SKIP_SPACE() == -1) + return(_v_argptr); + c=_SCAN_INPUT(good_scan); + while(1) + { + if((c == '+') || (c == '-')) /* leading sign */ + { + _fmt_buf[n++]= (char) c; + if((c=_SCAN_INPUT(good_scan)) == -1) + return(_v_argptr); + --width; + } /* width check always after _VGETC */ + for(q=0; q<2; q++) + { + while((isdigit(c)) && (width)) /* get digits */ + { + good_scan=1; + _fmt_buf[n++]= (char) c; + c=_SCAN_INPUT(good_scan); + --width; + } + if((c == DEC_POINT) && (q == 0) && (width)) /* decimal point */ + { + _fmt_buf[n++]= (char) c; + if((c=_SCAN_INPUT(good_scan)) == -1) + break; + --width; + } + else if(q == 0) + break; + } /* go back for more digits if first iteration */ + if(!width) + break; /* exponent */ + if((c == 'E') || (c == 'e') || (c == 'D') || (c == 'd')) + { + _fmt_buf[n++]= (char) c; + c=_SCAN_INPUT(good_scan); + --width; + } + else + break; + if(!width) /* exponent leading sign */ + break; + if((c == '+') || (c == '-')) + { + _fmt_buf[n++]= (char) c; + c=_SCAN_INPUT(good_scan); + --width; + } /* exponent digits */ + while((isdigit(c)) && (width)) + { + _fmt_buf[n++]= (char) c; + c=_SCAN_INPUT(good_scan); + --width; + } + break; + } + _fmt_buf[n]=0; /* terminate string */ + _VUNGETC(c); + if(!good_scan) + return(NULL); + if(!(flag&SF_SUPRESS)) + { + dtemp=atofl(_fmt_buf); /* convert and assign if not suppressed */ + dptr = (va_arg(_v_argptr, void *)); + switch(smod) + { + case ldmod : + *((LONGDOUBLE *) dptr) = dtemp; + break; + case longmod : + *((double *) dptr) = (double) dtemp; + break; + default : + *((float *) dptr) = (float) dtemp; + break; + } + _s_args++; + } + return(_v_argptr); +} + +/**************************************************************************** +* This function scans the input stream for the next width characters even * +* if white space. * +****************************************************************************/ + +_STATIC va_list _get_char(int pmod, unsigned flag, int width, int setwidth, va_list _v_argptr) +{ + int c, n, good_scan; + char *array; + + n=0; + good_scan=0; + if(!setwidth) /* width = 1 if not set */ + width=1; + if(!(flag&SF_SUPRESS)) /* if not suppressed get char pointer */ + { + array=va_arg(_v_argptr, char *); + } + while(width) + { /* scan input */ + if((c=_SCAN_INPUT(good_scan)) == -1) + break; + --width; + good_scan=1; + if(!(flag&SF_SUPRESS)) /* assign if not suppressed */ + { + array[n++]=(char) c; /* terminate string if not suppressed */ + } + } + if(good_scan) + ++_s_args; + else + return(NULL); + return(_v_argptr); +} + +/**************************************************************************** +* This function scans the input stream for the next width characters * +* until it finds a white space character. * +****************************************************************************/ + +_STATIC va_list _get_str(int pmod, unsigned flag, int width, va_list _v_argptr) +{ + int c, n, good_scan; + char *array; + + n=0; + good_scan=0; + if(_SKIP_SPACE() == -1) + return(_v_argptr); + c=_SCAN_INPUT(good_scan); + if(!(flag&SF_SUPRESS)) /* get char pointer if not suppressed */ + { + array=va_arg(_v_argptr, char *); + } + while (width) + { + if(isspace(c)) /* terminate if white-space or EOF */ + break; + good_scan=1; + if(!(flag&SF_SUPRESS)) /* assign if not suppressed */ + { + array[n++]=(char) c; + } + if((c=_SCAN_INPUT(good_scan)) == -1) + break; + --width; + } + _VUNGETC(c); + if(!(flag&SF_SUPRESS)) /* terminate string if not suppressed */ + { + array[n]='\0'; /* terminate string if not suppressed */ + } + if(good_scan) + ++_s_args; + else + return(NULL); + return(_v_argptr); +} + +/**************************************************************************** +* This function scans the input stream for the next width characters * +* until it finds a white space character. * +****************************************************************************/ + +_STATIC va_list _get_str_delim(char *s, int pmod, unsigned flag , int width, va_list _v_argptr) +{ + int c, n, good_scan; + char *array; + + n=0; + good_scan=0; + if((c=_SCAN_INPUT(good_scan)) == -1) + return(_v_argptr); + if(!(flag&SF_SUPRESS)) /* get char pointer unless suppressed */ + { + array=va_arg(_v_argptr, char *); + } + while(width) + { + if(_isterm(s, (char)c)) /* terminate if a deliminating character */ + break; + good_scan=1; + if(!(flag&SF_SUPRESS)) /* asign if not suppressed */ + { + array[n++]=(char) c; + } + if((c=_SCAN_INPUT(good_scan)) == -1) + break; + width--; + } + _VUNGETC(c); + if(!(flag&SF_SUPRESS)) + { + array[n]='\0'; /* terminate string if not suppressed */ + } + if(good_scan) + ++_s_args; + else + return(NULL); + return(_v_argptr); +} + +/**************************************************************************** +* This function scans the format string for deliminating characters. * +* It returns TRUE if the character is a deliminator. * +****************************************************************************/ + +_STATIC int _isterm(char *s, char tc) +{ + int n; + int first; + + n=0; + first=TRUE; + if(s[n] == '^') /* charcaters in set are deliminators */ + { + n++; + while(((s[n] != ']') || (first)) && (s[n])) + { + first=FALSE; + if(tc == s[n++]) + return(TRUE); + } + return(FALSE); + } /* characters not in set are deliminators */ + else + { + while(((s[n] != ']') || (first)) && (s[n])) + { + first=FALSE; + if(tc == s[n++]) + return(FALSE); + } + return(TRUE); + } +} + +#pragma warn(wall => on) +#pragma warn(wpnu => off) + +/*-------------------------------------------------------------------------* +* scanf.c - formatted input from stdin * +* This function provides formatted input from stdin for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int scanf(const char *format, ...) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if(stdin->_size == 0) + { + char buffer[PF_TEMP_BUF]; + stdin->_flag|=_F_RST; + _vp_setbuf(stdin, buffer); + stdin->_cnt=0; + temp_buf=1; + } + _vs_fill=_filler; /* set put_back function */ + _stream=stdin; + va_start(_v_argptr, format); /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF in input function arrives here */ + { + ret=-1; + goto sf_out; + } + _vscanner(format, _v_argptr); /* do it */ + ret=_s_args; +sf_out: + if(temp_buf) + { + fflush(stdin); + _vp_freebuf(stdin); + } + return(ret); /* return number of fields assigned */ +} + +/*-------------------------------------------------------------------------* +* cscanf.c - formatted input from console * +* This function provides formatted input from console for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int _con_fil(FILE *st) +{ + int c; + + st->_ptr=st->_base; + st->_cnt=st->_size; + c=getche(); + *st->_ptr= (char ) c; + if(c == 13) + ungetch(10); + if(c == _CTLZ) + return(EOF); + return(1); +} + +int cscanf(const char *format, ...) +{ + va_list _v_argptr; + FILE cst; + char cbuf[2]; + + cst._cnt=0; + cst._size=1; + cst._base=cbuf; + cst._ptr=cbuf; + _stream=&cst; + _vs_fill=_con_fil; /* set filler function */ + va_start(_v_argptr, format); /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF in input function arrives here */ + return(EOF); + _vscanner(format, _v_argptr); /* do it */ + return(_s_args); /* return number of fields assigned */ +} + +/*-------------------------------------------------------------------------* +* sscanf.c - formatted input from buffer * +* This function provides formatted input from a character buffer for a * +* variable number of arguments. * +*--------------------------------------------------------------------------*/ + +int _buf_fil(FILE *st) +{ + return(-1); +} + +int sscanf(const char *s, const char *format, ...) +{ + va_list _v_argptr; + FILE sst; + + _vs_fill=_buf_fil; /* set filler function */ + sst._cnt=strlen(s)+1; + sst._ptr=(char *) s; + sst._flag=_F_BIN; + _stream=&sst; + va_start(_v_argptr, format); /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF arrives here */ + return(EOF); + _vscanner(format, _v_argptr); /* do it */ + return(_s_args); /* return number of fields assigned */ +} + +/*-------------------------------------------------------------------------* +* fscanf.c - formatted input from stream * +* This function provides formatted input from stream for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int fscanf(FILE *st, const char *format, ...) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if((st->_flag&_F_OUT) || (!(st->_flag&_F_READ))) + return(-1); + if(st->_size == 0) + { + char buffer[PF_TEMP_BUF]; + st->_flag|=_F_RST; + _vp_setbuf(st, buffer); + st->_cnt=0; + temp_buf=1; + } + _vs_fill=_filler; /* set put_back function */ + _stream=st; + va_start(_v_argptr, format); /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF in input function arrives here */ + { + ret=-1; + goto fsf_out; + } + _vscanner(format, _v_argptr); /* do it */ + ret=_s_args; +fsf_out: + if(temp_buf) + { + fflush(st); + _vp_freebuf(st); + } + return(ret); /* return number of fields assigned */ +} + +/*-------------------------------------------------------------------------* +* vscanf.c - formatted input from stdin * +* This function provides formatted input from stdin for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int vscanf(const char *format, va_list argptr) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if(stdin->_size == 0) + { + char buffer[PF_TEMP_BUF]; + + stdin->_flag|=_F_RST; + _vp_setbuf(stdin, buffer); + stdin->_cnt=0; + temp_buf=1; + } + _vs_fill=_filler; /* set put_back function */ + _stream=stdin; + _v_argptr=argptr; /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF in input function arrives here */ + { + ret=-1; + goto vsf_out; + } + _vscanner(format, _v_argptr); /* do it */ + ret=_s_args; +vsf_out: + if(temp_buf) + { + fflush(stdin); + _vp_freebuf(stdin); + } + return(ret); /* return number of fields assigned */ +} + +/*-------------------------------------------------------------------------* +* vsscanf.c - formatted input from buffer * +* This function provides formatted input from a character buffer for a * +* variable number of arguments. * +*--------------------------------------------------------------------------*/ + +int vsscanf(const char *s, const char *format, va_list argptr) +{ + va_list _v_argptr; + FILE sst; + + _vs_fill=_buf_fil; /* set filler function */ + sst._cnt=strlen(s)+1; + sst._ptr=(char *) s; + sst._flag=_F_BIN; + _stream=&sst; + _v_argptr=argptr; /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF arrives here */ + return(EOF); + _vscanner(format, _v_argptr); /* do it */ + return(_s_args); /* return number of fields assigned */ +} + +/*-------------------------------------------------------------------------* +* vfscanf.c - formatted input from stream * +* This function provides formatted input from stream for a variable * +* number of arguments. * +*--------------------------------------------------------------------------*/ + +int vfscanf(FILE *st, const char *format, va_list argptr) +{ + va_list _v_argptr; + int temp_buf, ret; + + temp_buf=0; + if((st->_flag&_F_OUT) || (!(st->_flag&_F_READ))) + return(-1); + if(st->_size == 0) + { + char buffer[PF_TEMP_BUF]; + st->_flag|=_F_RST; + _vp_setbuf(st, buffer); + st->_cnt=0; + temp_buf=1; + } + _vs_fill=_filler; /* set put_back function */ + _stream=st; + _v_argptr=argptr; /* initialise argument pointer */ + if(setjmp(_EOFhandler)) /* EOF in input function arrives here */ + { + ret=-1; + goto vfsf_out; + } + _vscanner(format, _v_argptr); /* do it */ + ret=_s_args; +vfsf_out: + if(temp_buf) + { + fflush(st); + _vp_freebuf(st); + } + return(ret); /* return number of fields assigned */ +} + diff --git a/code/SIBOSDK/src/stdiostr.cpp b/code/SIBOSDK/src/stdiostr.cpp new file mode 100644 index 0000000..b60827c --- /dev/null +++ b/code/SIBOSDK/src/stdiostr.cpp @@ -0,0 +1,157 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* STDIOSTR.CPP - 2.0 stream class implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include + +#pragma module(init_prio=>22) + +stdiobuf::stdiobuf(FILE *f) : streambuf(NULL, 0) { + + if(unbuffered()) { + setb(lahead, &lahead[1], 0); + unbuffered(1); + } + setp(base(), base()); + setg(base(), ebuf(), ebuf()); + sio=f; + last_seek=0; + gs=0; + sync(); +} + +stdiobuf::~stdiobuf() { + +// fclose(f); +} + +int stdiobuf::overflow(int c) { + + int nw; + + if(unbuffered()) { + if((c == EOF) || (fputc(c, sio) == EOF)) + return EOF; + } + else { + nw=pptr()-pbase(); + if(nw) { + if(::fwrite(pbase(), sizeof(char), nw, sio) != nw) + return EOF; + } + } + last_seek=ftell(sio); + setp(pbase(), epptr()); + if((c != EOF) && (!unbuffered())) + sputc(c); + return c; +} + +int stdiobuf::last_op() { + + int ret; + + if(pptr() > pbase()) + ret= ios::out; + else if(gs) + ret= ios::in; + else + ret = 0; + return ret; +} + +int stdiobuf::pbackfail(int c) { + + if(!unbuffered()) + sync(); + return ungetc(c, sio); +} + +int stdiobuf::sync() { + + if(unbuffered()) { + setp(base(), base()); + setg(base(), ebuf(), ebuf()); + return fflush(sio); + } + if(last_op() == ios::out) + overflow(); + else if(last_op() == ios::in) { + last_seek+= gptr()-eback(); + ::fseek(sio, last_seek, SEEK_SET); + } + else + return 0; + setp(base(), ebuf()); + setg(base(), ebuf(), ebuf()); + gs=0; + return 0; +} + +int stdiobuf::underflow() { + + int nr, c; + + gs=1; + nr=ebuf()-eback(); + last_seek=ftell(sio); + if(nr == 1) { + c=fgetc(sio); + if(c == EOF) + return EOF; + *eback()=c; + } + else { + nr=fread(eback(), sizeof(char), nr, sio); + if(ferror(sio) || (nr == 0)) + return EOF; + } + setg(eback(), eback(), eback()+nr); + return *gptr(); +} + +streampos stdiobuf::seekoff(streamoff off, ios::seek_dir d, int) { + + streampos p; + ios::seek_dir dir; + + if(d == ios::cur) { + if(last_op() == ios::out) + p = pptr()-pbase(); + else if(last_op() == ios::in) + p = gptr()-eback(); + else + p=0; + p += last_seek + off; + dir=ios::beg; + } + else { + p=off; + dir=d; + } + sync(); + last_seek = p; + fseek(sio, p, dir); + setp(base(), epptr()); + setg(base(), ebuf(), ebuf()); + return last_seek; +} + + +stdiostream::stdiostream(FILE *f) : ios(&buf), + buf(f) { + +} + +stdiostream::~stdiostream() { + +} + + \ No newline at end of file diff --git a/code/SIBOSDK/src/stream.cpp b/code/SIBOSDK/src/stream.cpp new file mode 100644 index 0000000..5a1ecf4 --- /dev/null +++ b/code/SIBOSDK/src/stream.cpp @@ -0,0 +1,709 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* STREAM.CPP - 1.2 stream class implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#define _NO_IO +#include +#include + +#pragma module(init_prio=>22) + +struct whitespace WS; + +#define CIRC_BUF_SIZE 1024 +#define MAX_STRING 512 + +#pragma save +#pragma call(near_call=>on, reg_param=>(ax,bx,cx,dx), reg_saved=>(ax,bx,cx,dx,di,si,ds,st1,st2)) +static void outstr(ostream& st, char *s); +static char *doconv(long val, int width, int radix); +static char *getbuf(int sz); +#pragma restore + +int streambuf::allocate() { + + base=new char[BUFSIZ]; + if(base) { + didalloc=1; + setbuf(base, BUFSIZ, 0); + return(0); + } + return(-1); +} + +streambuf * streambuf::setbuf(char *b, int sz, unsigned pos) { + + if(didalloc && base) + delete base; + base=b; + if(base && pos < sz) { + eptr=b+sz; + pptr=b+pos; + gptr=b+pos; + return(this); + } + return(NULL); +} + +int streambuf::overflow(int) { + + return EOF; +} + +int streambuf::underflow() { + + return EOF; +} + +void streambuf::terminate() { + + if(pptr < eptr) + *pptr = '\0'; +} + +streambuf::~streambuf() { + + if(didalloc) + delete base; +} + +int streambuf::snextc() { + + if(pptr == eptr) + return underflow(); + return *pptr++; +} + +int streambuf::sputc(int c) { + + if(gptr == eptr) + return overflow(c); + *gptr++ = c; + return c; +} + +void streambuf::sputbackc(char c) { + + if((pptr != base) || (c != EOF)) + *--pptr = c; +} + +/****************************************************************************/ +// conversion fiunction implementation +/****************************************************************************/ + +static char *getbuf(int sz) { + + static char buffer[CIRC_BUF_SIZE]; + static char *curpos=buffer; + char *ret; + + if(curpos+sz < buffer+CIRC_BUF_SIZE) { + ret=curpos; + curpos+=sz; + } + else if(sz < CIRC_BUF_SIZE) { + ret=buffer; + curpos=buffer; + } + else + ret=NULL; + return ret; +} + + +static char *doconv(long val, int width, int radix) { + + char nbuf[32]; + char *obuf; + int l, pad; + + ltoa(val, nbuf, radix); + l=strlen(nbuf); + if(width > 0) { + if(l > width) { + l = width; + nbuf[l]='\0'; + } + pad = width-l; + if(pad+l > (MAX_STRING-1)) + pad=(MAX_STRING-1)-l; + } + else + pad=0; + obuf=getbuf(pad+l+1); + if(pad) + memset(obuf, ' ', pad); + strcpy(&obuf[pad], nbuf); + return(obuf); +} + +char *dec(long val, int width) { + + return(doconv(val, width, 10)); +} + +char *hex(long val, int width) { + + return(doconv(val, width, 16)); +} + +char *oct(long val, int width) { + + return(doconv(val, width, 8)); +} + +char *chr(int c, int width) { + + char *obuf; + + if(--width > 0) { + if(width > (MAX_STRING-2)) + width = (MAX_STRING-2); + } + else + width=0; + obuf=getbuf(width+2); + if(width) + memset(obuf, ' ', width); + obuf[width]=c; + obuf[width+1]='\0'; + return obuf; +} + +char *str(const char *s, int width) { + + int l, pad; + char *obuf; + + l=strlen(s); + if(width > 0) { + if(l > width) + l = width; + pad = width-l; + if(pad+l > (MAX_STRING-1)) + pad=(MAX_STRING-1)-l; + } + else + pad=0; + obuf=getbuf(pad+l+1); + if(pad) + memset(obuf, ' ', pad); + memcpy(&obuf[pad], s, l); + obuf[pad+l]='\0'; + return(obuf); +} + +char *form(char *format, ...) { + + va_list _v_argptr; + char nbuf[MAX_STRING]; + char *obuf; + + va_start(_v_argptr, format); + vsprintf(nbuf, format, _v_argptr); + obuf=getbuf(strlen(nbuf)+1); + strcpy(obuf, nbuf); + return obuf; +} + + +/****************************************************************************/ +// filebuf implementation +/****************************************************************************/ + +filebuf::filebuf(FILE *f) { + + file=f; + if(file) { + fd=fileno(f); + isopen=1; + didalloc=0; + } + else + isopen=0; +} + +filebuf::filebuf(int h) { + + file=::fdopen(h, "r+"); + if(file) { + fd=h; + isopen=1; + didalloc=0; + } + else + isopen=0; +} + +filebuf::filebuf(int h, char *buf, int sz) { + + file=::fdopen(h, "r+"); + if(file) { + fd=h; + isopen=1; + didalloc=0; + ::setvbuf(file, buf, _IOFBF, sz); + } + else + isopen=0; +} + +static char *modes[3]={"r", + "w", + "a" }; + +filebuf* filebuf::open(char *path, int open_mode) { + + if(file) + close(); + file=::fopen(path, modes[open_mode]); + if(file) { + fd=fileno(file); + isopen=1; + didalloc=0; + return(this); + } + isopen=0; + return(NULL); +} + +int filebuf::close() { + + isopen=0; + return ::fclose(file); +} + + +void filebuf::terminate() { + +} + + +/****************************************************************************/ +// ostream implementation +/****************************************************************************/ + +static void outstr(ostream& st, char *s) { + + int c, n=0; + + while((st.good()) && ((c=s[n++]) != '\0')) { + st.put(c); + } +} + +ostream::ostream(streambuf *sb) { + + stream=sb; + mystream=0; + state=_good; +} + +ostream::ostream(int h) { + + stream = new filebuf(h); + mystream=1; + state=_good; + +} + +ostream::ostream(int len, char *buf) { + + stream = new streambuf(buf, len); + mystream=1; + state=_good; +} + + +ostream& ostream::operator <<(int i) { + + char o[32]; + + ltoa((long) i, o, 10); + outstr(*this, o); + return *this; +} + +ostream& ostream::operator <<(long l) { + + char o[32]; + + ltoa(l, o, 10); + outstr(*this, o); + return *this; +} + +ostream& ostream::operator <<(unsigned long ul) { + + char o[32]; + + ultoa(ul, o, 10); + outstr(*this, o); + return *this; +} + +ostream& ostream::operator <<(const char *s) { + + outstr(*this, (char *)s); + return *this; +} + +ostream& ostream::operator <<(double d) { + + char o[32]; + + gcvtl((long double) d, 18, o); + outstr(*this, o); + return *this; +} + +ostream& ostream::operator <<(long double ld) { + + char o[32]; + + gcvtl(ld, 18, o); + outstr(*this, o); + return *this; +} + + +ostream& ostream::flush() { + + if(stream->file) + fflush(stream->file); + else { + stream->pptr=stream->base; + stream->gptr=stream->base; + } + state=_good; + return *this; +} + +/****************************************************************************/ +// istream implementation +/****************************************************************************/ + +long double istream::getreal() { + + int c, n=0; + char _fmt_buf[64]; + + if(tied_to) + tied_to->flush(); + if(skipping) + *this >> WS; + c=stream->snextc(); + while(c != EOF) + { + if((c == '+') || (c == '-')) { /* leading sign */ + _fmt_buf[n++]= (char) c; + c=stream->snextc(); + if(c == EOF) + break; + } + for(int q=0; q<2; q++) { + while(isdigit(c)) { /* get digits */ + _fmt_buf[n++]= (char) c; + c=stream->snextc(); + if(c == EOF) + break; + } + if((c == '.') && (q == 0)) { /* decimal point */ + _fmt_buf[n++]= (char) c; + c=stream->snextc(); + if(c == EOF) + break; + } + else if(q == 0) + break; + } /* go back for more digits if first iteration */ + c= toupper(c); + if((c == 'E') || (c == 'D')) { + _fmt_buf[n++]= (char) c; + c=stream->snextc(); + if(c == EOF) + break; + } + else + break; + if((c == '+') || (c == '-')) { + _fmt_buf[n++]= (char) c; + c=stream->snextc(); + if(c == EOF) + break; + } /* exponent digits */ + while(isdigit(c)) { + _fmt_buf[n++]= (char) c; + c=stream->snextc(); + if(c == EOF) + break; + } + break; + } + _fmt_buf[n]=0; /* terminate string */ + if(c != EOF) + stream->sputbackc(c); + else { + state = _fail|_eof; + if((stream->file) && (ferror(stream->file))) + state = _bad; + } + return atofl(_fmt_buf); /* convert and assign if not suppressed */ +} + +long istream::getlong(int us) { + + int c, negative=0, flag=0; + long temp=0; + int _goodscan=0; + + if(tied_to) + tied_to->flush(); + if(skipping) + *this >> WS; + c=stream->snextc(); + if(c == EOF) + goto error; + if(c == '+') { + _goodscan=1; + c=stream->snextc(); + if(c == EOF) + goto error; + } + else if(c == '-') { /* number is negative */ + _goodscan=1; + negative=1; + c=stream->snextc(); + if(c == EOF) + goto error; + else if(us) { + state = _fail; + return(0); + } + } + if(c =='0') { + _goodscan=1; + flag=_OCT; + c=stream->snextc(); + if(c == EOF) + goto error; + c=tolower(c); + if(c == 'x') { + flag=_HEX; + c=stream->snextc(); + if(c == EOF) + goto error; + } + } + if(flag == _HEX) { + while(isxdigit(c=tolower(c))) { + temp*=16; + if(!isdigit(c)) + c-=87; + else + c-='0'; + temp+=c; + c=stream->snextc(); + if(c == EOF) + goto error; + } + } + else if(flag == _OCT) { + while((c >= '0') && (c <= '7')) { + temp*=8; + temp+=c-'0'; + c=stream->snextc(); + if(c == EOF) + goto error; + } + } + else { + while(isdigit(c)) { + _goodscan=1; + temp*=10; + temp+=c-'0'; + c=stream->snextc(); + if(c == EOF) + goto error; + } + } +error: + if(!_goodscan) { + state = _fail|_eof; + if((stream->file) && (ferror(stream->file))) + state = _bad; + return(0); + } + c=tolower(c); + if((c != 'u') && (c != 'l')) + stream->sputbackc(c); + if(negative) + return -temp; + return temp; +} + +istream::istream(streambuf *st, int sk, ostream* tie) { + + tied_to=tie; + stream=st; + skipping=sk; + mystream=0; + if(st) + state=_good; +} + +istream::istream(int sz, char* buf, int sk) { + + tied_to=NULL; + stream= new streambuf(buf, sz); + skipping=sk; + mystream=1; + if(stream) + state=_good; +} + +istream::istream(int h, int sk, ostream* tie) { + + tied_to=tie; + stream= new filebuf(h); + skipping=sk; + mystream=1; + if(stream) + state=_good; +} + +istream& istream::operator>>(unsigned char& c) { + + int t; + + if(state == _good) { + if(tied_to) + tied_to->flush(); + do { + t=stream->snextc(); + } while ((skipping) && (isspace(t))); + if(t == EOF) { + state = _fail|_eof; + if((stream->file) && (ferror(stream->file))) + state = _bad; + } + else + c=t; + } + return *this; +} + +istream& istream::operator>>(float& f) { + + f=(float) getreal(); + return *this; +} + +istream& istream::operator>>(double& d) { + + d=(double) getreal(); + return *this; +} + +istream& istream::operator>>(long double& ld) { + + ld= getreal(); + return *this; +} + +istream& istream::operator>>(char *s) { + + int c, n=0; + + if(state == _good) { + if(tied_to) + tied_to->flush(); + do { + c=stream->snextc(); + } while ((skipping) && (isspace(c))); + while(!isspace(c)) { + if(c == EOF) { + state = _fail|_eof; + if((stream->file) && (ferror(stream->file))) + state = _bad; + break; + + } + s[n++]=c; + c=stream->snextc(); + } + s[n] = '\0'; + } + return *this; +} + +istream& istream::operator>>(whitespace& w) { + + if(state == _good) { + if(tied_to) + tied_to->flush(); + do { + w.x=stream->snextc(); + } while (isspace(w.x)); + stream->sputbackc(w.x); + } + return *this; + +} + +istream& istream::get(char& c) { + + int t; + + if(state == _good) { + t=stream->snextc(); + if(t == EOF) { + state = _fail|_eof; + if((stream->file) && (ferror(stream->file))) + state = _bad; + } + else + c=t; + } + return *this; +} + +istream& istream::get(char *s, int len, int term) { + + int c, n=0; + + if(state == _good) { + while(n < len) { + c=stream->snextc(); + if(c == EOF) { + state = _fail|_eof; + if((stream->file) && (ferror(stream->file))) + state = _bad; + break; + } + if(c == term) { + stream->sputbackc(c); + break; + } + s[n++]=c; + } + s[n] = '\0'; + } + return *this; +} + +static filebuf inbuf(&_iob[0]); +static filebuf outbuf(&_iob[1]); +static filebuf errbuf(&_iob[2]); + +istream cin(&inbuf, 1, &cout); +ostream cout(&outbuf); +ostream cerr(&errbuf); + \ No newline at end of file diff --git a/code/SIBOSDK/src/strstrea.cpp b/code/SIBOSDK/src/strstrea.cpp new file mode 100644 index 0000000..a212f36 --- /dev/null +++ b/code/SIBOSDK/src/strstrea.cpp @@ -0,0 +1,291 @@ +/* Release 3.10 */ +/*-------------------------------------------------------------------------* +* * +* STRSTREAM.CPP - 2.1 file stream class implementations. * +* * +* COPYRIGHT (C) 1989..1992 Clarion Software Corporation. * +* All Rights Reserved * +* * +*--------------------------------------------------------------------------*/ + +#include +#include + +#pragma module(init_prio=>22) + +//************************************************************************** +// strstreambuf implementation +//************************************************************************** + + +strstreambuf::strstreambuf() : streambuf(NULL, 0) { + + flags=dynamic; + allocf=NULL; + freef=NULL; + next_alloc=512; + init(NULL, 0, NULL); +} + +strstreambuf::strstreambuf(int n) : streambuf(NULL, 0) { + + flags=dynamic; + allocf=NULL; + freef=NULL; + next_alloc=n; + init(NULL, 0, NULL); +} +strstreambuf::strstreambuf(void * (*a)(long), void (*f)(void*)) : streambuf(NULL, 0) { + + flags=dynamic; + allocf=a; + freef=f; + next_alloc=512; + init(NULL, 0, NULL); +} + +strstreambuf::strstreambuf(char *ptr, int n, char *pstart) : streambuf(NULL, 0) { + + int len; + + if(n < 0) { + flags=unlimited; + len= INT_MAX; + } + else + flags=0; + if(n == 0) + len=strlen((char *)ptr); + else if(n > 0) + len=n; + next_alloc=0; + allocf=NULL; + freef=NULL; + init(ptr, len, pstart); +} + +strstreambuf::~strstreambuf() { + + if((flags&dynamic) && (!(flags&frozen))) { + if(freef) + freef(base()); + else + delete base(); + } +} + +void strstreambuf::freeze(int f) { + + flags |= frozen*(f == 1); +} + + +char *strstreambuf::str() { + + flags |= frozen; + return base(); +} + + +int strstreambuf::doallocate() { + + char *b; + + b=(char *) allocf(512); + if(b == NULL) + return EOF; + setb(b, b+512, 1); + setg(b, b, b+512); + setp(b, b+512); + return 1; +} + +int strstreambuf::overflow(int c) { + + char *nb, *ob; + int old_size, new_size, in_pbuf, in_gbuf; + + if(flags&frozen) + return EOF; + + old_size=ebuf()-base(); + new_size=old_size+next_alloc; + in_pbuf=pptr()-pbase(); + in_gbuf=gptr()-eback(); + ob=base(); + + if(allocf) + nb = (char *) allocf(new_size); + else + nb = new char[new_size]; + if(nb == NULL) + return EOF; + setb(nb, nb+new_size); + setg(nb, nb, nb+new_size); + setp(nb, nb+new_size); + if(ob) { + memcpy(nb, ob, old_size); + pbump(in_pbuf); + gbump(in_gbuf); + if(freef) + freef(ob); + else + delete ob; + } + if(c != EOF) + sputc(c); + return c; +} + +int strstreambuf::underflow() { + + return EOF; +} + + +streambuf *strstreambuf::setbuf(char *b, int n) { + + if(b == NULL) + next_alloc=n; + else { + setb(b, b+512, 0); + setg(b, b, b+512); + setp(b, b+512); + } + return this; +} + +streampos strstreambuf::seekoff(streamoff pos, ios::seek_dir d, int mode) { + + streampos ret; + + if(mode & ios::in) { + switch(d) { + case ios::beg : + setg(eback(), eback()+pos, egptr()); + break; + case ios::cur : + gbump((int)pos); + break; + case ios::end : + setg(eback(), egptr()+pos, egptr()); + break; + } + if((gptr() > egptr()) || (gptr() < eback())) + return -1L; + ret = gptr()-eback(); + } + + if(mode & ios::out) { + switch(d) { + case ios::beg : + setp(pbase(), epptr()); + pbump((int)pos); + break; + case ios::cur : + pbump((int)pos); + break; + case ios::end : + setp(pbase(), epptr()); + pbump((int)(epptr()-pbase()+pos)); + break; + } + if((pptr() > epptr()) || (pptr() < base())) + return -1L; + ret = pptr()-pbase(); + } + return ret; +} + + +void strstreambuf::init(char *ptr, int sz, char *pstart) { + + char *eg, *pp; + + setb(ptr, ptr+sz, 0); + + if(pstart == NULL) { + eg=ebuf(); + pp=ebuf(); + } + else { + eg=pstart; + pp=pstart; + } + setg(ptr, ptr, eg); + setp(pp, ebuf()); +} + +//************************************************************************** +// strstreambase implementation +//************************************************************************** + + +strstreambase::strstreambase(char *g, int n, char *p) : buf(g, n, p) { + + ios::init(&buf); + +} + +strstreambase::strstreambase() { + + ios::init(&buf); +} + +strstreambase::~strstreambase() { + +} + +//************************************************************************** +// istrstream implementation +//************************************************************************** + +istrstream::istrstream(char *s) : strstreambase(s, 0, NULL), + istream(rdbuf()) { + +} + +istrstream::istrstream(char *s, int n) : strstreambase(s, n, NULL), + istream(rdbuf()) { + +} + +istrstream::~istrstream() { + +} + +ostrstream::ostrstream() : ostream(rdbuf()) { + +} + +ostrstream::ostrstream(char *cp, int n, int mode) : strstreambase(cp, n, cp), + ostream(rdbuf()) { + if(mode&(ios::ate|ios::app)) + seekp(strlen(cp)); +} + +ostrstream::~ostrstream() { + +} + +//************************************************************************** +// istrstream implementation +//************************************************************************** + +strstream::strstream() : strstreambase(), + iostream(rdbuf()) { + +} + +strstream::strstream(char *cp, int n, int mode) : strstreambase(cp, n, cp), + iostream(rdbuf()) { + + if(mode&(ios::ate|ios::app)) + seekp(strlen(cp)); +} + +strstream::~strstream() { + +} + + \ No newline at end of file diff --git a/code/SIBOSDK/sys/ct.bat b/code/SIBOSDK/sys/ct.bat new file mode 100644 index 0000000..2b379f5 --- /dev/null +++ b/code/SIBOSDK/sys/ct.bat @@ -0,0 +1,6 @@ +@echo off +ctran %1 -e\sibosdk\include\ -x\sibosdk\include\ -g\sibosdk\include\ -c -l -s -v +if errorlevel 1 goto end +call cc %1 +ecobj %1 +:end diff --git a/code/SIBOSDK/sys/ctskel.bat b/code/SIBOSDK/sys/ctskel.bat new file mode 100644 index 0000000..8297906 --- /dev/null +++ b/code/SIBOSDK/sys/ctskel.bat @@ -0,0 +1,2 @@ +@echo off +ctran %1 -e\sibosdk\include\ -s -v -k diff --git a/code/SIBOSDK/sys/debug.app b/code/SIBOSDK/sys/debug.app new file mode 100644 index 0000000..5d197e5 Binary files /dev/null and b/code/SIBOSDK/sys/debug.app differ diff --git a/code/SIBOSDK/sys/flman.app b/code/SIBOSDK/sys/flman.app new file mode 100644 index 0000000..c5ecb83 Binary files /dev/null and b/code/SIBOSDK/sys/flman.app differ diff --git a/code/SIBOSDK/sys/rch.bat b/code/SIBOSDK/sys/rch.bat new file mode 100644 index 0000000..847ace9 --- /dev/null +++ b/code/SIBOSDK/sys/rch.bat @@ -0,0 +1,2 @@ +@echo off +rchuf hwim -v -i%1 diff --git a/code/SIBOSDK/sys/re.bat b/code/SIBOSDK/sys/re.bat new file mode 100644 index 0000000..00aefe9 --- /dev/null +++ b/code/SIBOSDK/sys/re.bat @@ -0,0 +1,7 @@ +@echo off +rgprep %1.re %1.rex +lprep -i\sibosdk\include\ -o%1.i %1.rex +del %1.rex +rgcomp.exe %1.i \sibosdk\include\%1 +del %1.i + diff --git a/code/SIBOSDK/sys/rs.bat b/code/SIBOSDK/sys/rs.bat new file mode 100644 index 0000000..393704e --- /dev/null +++ b/code/SIBOSDK/sys/rs.bat @@ -0,0 +1,2 @@ +@echo off +rcomp.exe -S%1 -O%1 -I\sibosdk\include\ -G\sibosdk\include\%1 diff --git a/code/SIBOSDK/sys/sdbg.cfg b/code/SIBOSDK/sys/sdbg.cfg new file mode 100644 index 0000000..161d716 --- /dev/null +++ b/code/SIBOSDK/sys/sdbg.cfg @@ -0,0 +1,39 @@ +! Sample configuration file for the Series-3 Debugger +! Consists of a set of keywords and values. + +! Specifies the paths to search for source level maps and tables +! in addition to the current directory +! (commented out) +! SOURCE_PATH=c:\sibosdk\hwdemo\ +! SOURCE_PATH=d:\dirname\ + +! Pass zero-length command line to load and run commands +! (commented out) +! NO_COMMAND_LINE + +! Turns beep that normally accompanies temporary display of +! error message off +! (commented out) +! BEEP_OFF + +! Specifies the tab stop width used when displaying source code +TAB_WIDTH=4 + +! Specifies breakpoints to set up +BREAKPOINT=p_panic + +! Specifies where the debugger will run the process to before it +! reports the loading of the process is complete. +INITIAL_IP=main + +! Specifies what accelerators function keys are to be assigned to +! F1 to F10 may be assigned to accelerators +F2=B +F3=X +F4=H +F5=M +F6=V +F7=T +F8=S +F9=R +F10=G diff --git a/code/SIBOSDK/sys/ts.red b/code/SIBOSDK/sys/ts.red new file mode 100644 index 0000000..0977de6 --- /dev/null +++ b/code/SIBOSDK/sys/ts.red @@ -0,0 +1,16 @@ +*.PR = .; C:\SIBOSDK\PR; +*.H = .; C:\SIBOSDK\INCLUDE; +*.HPP = .; C:\SIBOSDK\INCLUDE; +*.RH = .; C:\SIBOSDK\INCLUDE; +*.G = .; C:\SIBOSDK\INCLUDE; +*.RG = .; C:\SIBOSDK\INCLUDE; +*.XG = .; C:\SIBOSDK\INCLUDE; +*.RSG = .; C:\SIBOSDK\INCLUDE; +*.INC = .; C:\SIBOSDK\INCLUDE; +*.C = .; C:\SIBOSDK\SRC; +*.CPP = .; C:\SIBOSDK\SRC; +*.CAT = .; C:\SIBOSDK\SRC; +*.A = .; C:\SIBOSDK\SRC; +*.OBJ = .; C:\SIBOSDK\LIB; +*.LIB = .; C:\SIBOSDK\LIB; +*.HLP = C:\TS\DOC; diff --git a/code/SIBOSDK/sys/tsmain.txt b/code/SIBOSDK/sys/tsmain.txt new file mode 100644 index 0000000..71849d1 --- /dev/null +++ b/code/SIBOSDK/sys/tsmain.txt @@ -0,0 +1,875 @@ + +!!------- Menu definition for TS Environment ------------------ + +! LinePull | [ TopSpeed ] + + {F}iles | [Files] + + {L} - Load file | LoadFile + {V} - View file | LoadF RO + {P} - Pick file | PickFile + {S} - Save file | SaveFile + {A} - All save | SaveAllF + {C} - Change dir | ChangeDir + {F} - Files dir | Directory + {D} - DOS shell | DOSShell + {E} - Execute | Execute + {Q} - Quit | Quit + + {E}dit | Editor + + {C}ompile | Compiler + + {L}ink | Linker + + {M}ake | Make + + {R}un | Run program + + {P}roject | {ProjOptions} [Project Options] + {N} - New project : ________ | ProjNew + {E} - Edit project file | ProjEdit + + {S} - System : ________ | MakeOpt[S|auto|dos|os2|win|epoc] { SYSTEMFI } + {T} - Target type : ___ | MakeOpt[T|exe|lib|dll|img|app|dyl|ldd|pdd] { TARGETTY } + {M} - Memory model : ________ | { MEMORYMO } +!if smallmodel + {S} - Small | ModelOpt[small] +!end +!if compactmodel + {C} - Compact | ModelOpt[compact] +!end +!if mediummodel + {M} - Medium | ModelOpt[medium] +!end +!if largemodel + {L} - Large | ModelOpt[large] +!end +!if xlargemodel + {X} - XLarge | ModelOpt[xlarge] +!end +!if mthreadmodel + {T} - MThread | ModelOpt[mthread] +!end +!if overlaymodel + {O} - Overlay | ModelOpt[overlay] +!end +!if dynalinkmodel + {D} - Dynalink | ModelOpt[dynalink] +!end +!if extendedmodel + {E} - Extended | ModelOpt[extended] +!end +!if extendmtmodel + {F} - ExtendMT | ModelOpt[extendmt] +!end + {V} - VID : ____ | MakeOpt[debug|vid] { VID:off } + {C} - Runtime checks... | { Runtime checks... } + {N} - Nil pointer checks : ___ | MakeOpt [check|nil_ptr] { Nil pointer checks } + {A} - Array index checks : ___ | MakeOpt [check|index] { Array index checks } + {S} - Stack overflow checks : ___ | MakeOpt [check|stack] { Stack overflow checks } + {R} - Range checks : ___ | MakeOpt [check|range] { Range checks } + {O} - Overflow checks : ___ | MakeOpt [check|overflow] { Overflow checks } +!if pas|mod + {G} - Guard conversions (Pas/M2) : ___ | MakeOpt [check|guard] { Guard conversions (Pas/M2) } +!end +!if pas + {V} - Variant records (Pas) : ___ | MakeOpt [check|field] { Variant records (Pas) } +!end + {O} - Optimisation options... | [ Optimizations ] { Optimization options... } + {T} - Optimize for speed : _____ | MakeOpt [optimize|speed] { Optimize for speed } + {E} - Common subexpressions : ___ | MakeOpt [optimize|cse] { Common subexpressions } + {C} - Constant optimization : ___ | MakeOpt [optimize|const] { Constant optimization } + {H} - Peephole : ___ | MakeOpt [optimize|peep_hole] { Peephole } + {J} - Jump optimization : ___ | MakeOpt [optimize|jump] { Jump optimization } + {L} - Loop optimization : ___ | MakeOpt [optimize|loop] { Loop optimization } + {A} - Alias optimization : ___ | MakeOpt [optimize|alias] { Alias optimization } + {R} - Register usage : ___ | MakeOpt [optimize|regass] { Register usage } + {F} - Stack frame : ___ | MakeOpt [optimize|stk_frame] { Stack frame } + + {P} - Processor : ___ | MakeOpt [optimize|cpu] { Processor } + {Q} - Coprocessor : ___ | MakeOpt [optimize|copro] { Coprocessor } + {S} - Smart linking : ___ | MakeOpt [module|smart_link] { Smart linking } + {P} - Project options... | { Project options... } + {J} - Calling convention : _____ | MakeOpt[J|jpi|stack] { Calling convention } + {M} - Map file : ___ | MakeOpt [link_option|map] { Map file } + {C} - Case sensitive link : ___ | MakeOpt [link_option|case] { Case sensitive link } + {S} - SmartMethod linking : ___ | MakeOpt [link_option|smart_method] { SmartMethod linking } + {H} - Share identical constants : ___ | MakeOpt [link_option|share_const] { Share identical constants } + {L} - Linker warnings : ___ | EnvOpt [L] { Linker warnings } + {W} - Warnings limit : ___ | EnvOpt [W] { Warnings limit } + {E} - Errors limit : ___ | EnvOpt [E] { Errors limit } + {R} - Remake all : ___ | EnvOpt [R] { Remake all } + {L} - Language options... | { Language options... } +!if pas + {P} - Pascal auto syntax check : ___ | EnvOpt[V] { Pascal auto syntax check } + {I} - Strict ISO standard (Pascal) : ___ | MakeOpt[option|iso] { Strict ISO standard (Pascal) } +!end +!if mod + {M} - Modula-2 auto syntax check : ___ | EnvOpt[U] { Modula-2 auto syntax check } + {B} - Bitwise boolean operators (M2) : ___ | MakeOpt[option|bit_opr] { Bitwise boolean operators (M2) } +!end +!if c|cpp + {A} - ANSI keywords only (C/C++) : ___ | MakeOpt[option|ansi] { ANSI keywords only (C/C++) } + {E} - Language extensions (C/C++) : ___ | MakeOpt[option|lang_ext] { Language extensions (C/C++) } + {N} - Nested comments (C/C++) : ___ | MakeOpt[option|nest_cmt] { Nested comments (C/C++) } + {J} - Default char unsigned (C/C++) : ___ | MakeOpt[option|uns_char] { Default char unsigned (C/C++) } + {Z} - Generate prototypes (C only) : ___ | MakeOpt[option|prototypes] { Generate prototypes (C only) } + {O} - Preprocessor output... | { Preprocessor output... } + {P} - Preprocessor output only : ___ | MakeOpt[option|pre_proc] { Preprocessor output... } + {L} - Minimize blank lines : ___ | MakeOpt[option|min_line] { Preprocessor output... } + {C} - Preserve comments : ___ | MakeOpt[option|incl_cmt] { Preprocessor output... } + + {V} - ANSI Violation Warnings... | [ ANSI Violations ] { ANSI Violation Warnings... } + {A} - Pointer conversion : _____ | MakeOpt [warn|wpcv] { Pointer conversion } + {B} - Declaration has no effect : _____ | MakeOpt [warn|wdne] { Declaration has no effect } + {C} - Storage class redeclared in declaration : _____ | MakeOpt [warn|wsto] { Storage class redeclared in declaration } + {D} - Unexpected text in preprocessor command : _____ | MakeOpt [warn|wtxt] { Unexpected text in preprocessor command } + {E} - No expression in return statement : _____ | MakeOpt [warn|wnre] { No expression in return statement } + {F} - No value returned in function : _____ | MakeOpt [warn|wnrv] { No value returned in function } + {G} - Value of escape sequence is too big : _____ | MakeOpt [warn|wetb] { Value of escape sequence is too big } + {H} - Value of constant is out of range : _____ | MakeOpt [warn|wcor] { Value of constant is out of range } + {I} - Default type promotion on parameter : _____ | MakeOpt [warn|wpin] { Default type promotion on parameter } + {J} - Function redeclared with fixed parameters : _____ | MakeOpt [warn|wrfp] { Function redeclared with fixed parameters } + {K} - Constant expression overflows : _____ | MakeOpt [warn|wovr] { Constant expression overflows } + {L} - Parameter type incompatible with previous : _____ | MakeOpt [warn|wpic] { Parameter type incompatible with previous } + {T} - Type Check Warnings... | [ Type Checking ] { Type Check Warnings... } + {A} - Function not declared : _____ | MakeOpt [warn|wfnd] { Function not declared } + {B} - Function has no prototype : _____ | MakeOpt [warn|wpnd] { Function has no prototype } + {C} - Different 'const' attributes : _____ | MakeOpt [warn|watr] { Different 'const' attributes } + {D} - Far to near pointer conversion : _____ | MakeOpt [warn|wftn] { Far to near pointer conversion } + {E} - Near to far pointer conversion : _____ | MakeOpt [warn|wntf] { Near to far pointer conversion } + {F} - Conversion may lose significant digits : _____ | MakeOpt [warn|wcld] { Conversion may lose significant digits } + {G} - Constant is long : _____ | MakeOpt [warn|wclt] { Constant is long } + {X} - Possible errors... | [ Possible Errors ] { Possible errors... } + {A} - Code has no effect : _____ | MakeOpt [warn|wcne] { Code has no effect } + {B} - Assignment in test expression : _____ | MakeOpt [warn|wait] { Assignment in test expression } + {C} - Returns the address of a local variable : _____ | MakeOpt [warn|wral] { Returns the address of a local variable } + {D} - Variable declared but never used : _____ | MakeOpt [warn|wdnu] { Variable declared but never used } + {E} - Variable is assigned but never used : _____ | MakeOpt [warn|wvnu] { Variable is assigned but never used } + {F} - Possible use of variable before assignment : _____ | MakeOpt [warn|wubd] { Possible use of variable before assignment } + {G} - Parameter never used in function : _____ | MakeOpt [warn|wpnu] { Parameter never used in function } + {H} - Unknown pragma : _____ | MakeOpt [warn|wprg] { Unknown pragma } + {I} - Address for local variable not in DGROUP : _____ | MakeOpt [warn|wnid] { Address for local variable not in DGROUP } +!if cpp + {C} - C++ warnings... | [ C++ Warnings ] { C++ warnings... } + {A} - No access specifier for base class : _____ | MakeOpt [warn|wacc] { No access specifier for base class } + {B} - Obsolete 'overload' keyword : _____ | MakeOpt [warn|wovl] { Obsolete 'overload' keyword } + {C} - Obsolete expression in delete : _____ | MakeOpt [warn|wdel] { Obsolete expression in delete } + {D} - Object in code segment initialized : _____ | MakeOpt [warn|wcic] { Object in code segment initialized } + {E} - Class definition in function return type : _____ | MakeOpt [warn|wcrt] { Class definition in function return type } +!end +!end + {O}ptions | [ Options ] {Options} +!if os2 + {V} - VIO screen output : ___ | EnvOpt[S] { Snowcheck/VIO } +!end +!if dos + {V} - Snow check : ___ | EnvOpt[S] { Snowcheck/VIO } +!end + {D} - Delayed screen update : ___ | EnvOpt[D] { Delayed screen update } +!if dos + {H} - High background : ___ | EnvOpt[H] { High background } +!end + {C} - Solid cursor : ___ | EnvOpt[C] { Solid cursor } +!if dos + {X} - Use expanded memory : ___ | EnvOpt[M] { Use expanded memory } +!end + {N} - Enable mouse : ___ | EnvOpt[N] { Enable mouse } + {Q} - Help line : ___ | EnvOpt[Q] { Help line } + {R} - Run options... | { Run options... } + {C} - Command line | Command Line + {A} - Auto make : ___ | RunOpt[A] +!if os2 + {S} - Session run : ___ | RunOpt[S] +!end + {T} - Timed run : ___ | RunOpt[T] + {S} - Setup options... | [Setup] { Setup options... } + {A} - Auto save files : ___ | EdOpt[A] { Setup options... } + {F} - Default editor filenames... | Default Filenames + {X} - Default editor extensions... | Default Extensions + {N} - Number of backups : ___ | No Of Backups + {T} - Top editor scroll zone : ___ | Top Scroll Zone + {B} - Bottom editor scroll zone : ___ | Bottom Scroll Zone + + {R} - Load redirection file | Load Red File + {E} - Edit redirection file | Red Edit + {J} - Load keyboard macro file | Load Macs + {K} - Save keyboard macro file | Save Macs + {L} - Load option/window cfg file | Load Config File + {O} - Save option/window cfg file | Save Config File + {U}tilities | [Utilities] {Utilities} + {A} - ASCII table | Asciitab + {C} - Calculator | Calculator + {E} - Find run-time error | Find Error + {F} - File search | WildSearch + {S} - Search list | Search List + {L} - Locate file | Locate File + {K} - Keyboard codes | ScanCodes + {P} - Print file | Print + {Q} - Print settings | PrintSet + {R} - Review DOS screen | Review Screen + {V} - View file as data | View File + {H} - Help window | Help + {I} - System Info | Info + + {V}ID | {VID} Run program[VID] + +! key | Edit1 +! key | Edit2 +! key | Edit3 +! key | Edit4 +! key | Edit5 +! key | Edit6 +! key | Edit7 +! key | Edit8 +! key | Edit9 +! key | Edit0 +! key | Zoom Window +! key | Cycle Windows +! key | CutKey +! key | WinKey + + +!!----- Editor menus and keys - Active in editor windows ------ +! Editor +! Pop Up | [ Editor Menu ] {Edit1} + {L} - load new file | Ed Load File + {V} - view file read only | Ed Load F RO + {S} - save file | Save File + {W} - write to ... | Ed Write File + {Q} - quick commands | [ Quick Menu ] + {F} - find | Ed Find + {A} - replace | Ed Replace + {E} - top of window | Ed Start Screen + {X} - bottom of window | Ed End Screen + {R} - top of file | Ed Start File + {C} - bottom of file | Ed End File + {S} - start of line | Ed Start Line + {D} - end of line | Ed End Line + {B} - beginning of block | Ed Goto Begin Block + {K} - end of block | Ed Goto End Block + {P} - previous position | Ed Prev Position + {Y} - delete to end of line | Ed Del End Line + {L} - restore line | Ed Restore Line + {G} - goto line | Ed Goto Line + {1} - goto marker 1 | Ed Goto M1 + {2} - goto marker 2 | Ed Goto M2 + {K} - block commands | [ Block Menu ] + {D} - save file | Save File + {A} - all save | Save All Files + {B} - begin block | Ed Begin Block + {K} - end block | Ed End Block + {H} - hide block | Ed Hide Block + {T} - mark word | Ed Mark Word + {L} - mark line | Ed Mark Line + {C} - copy block | Ed Copy Block + {V} - move block | Ed Move Block + {Y} - delete block | Ed Del Block + {R} - read block | Ed Read Block + {W} - write block | Ed Write Block + {G} - get block | Ed Get Block + {P} - print block | Ed Print Block + {I} - indent block | Ed Indent Block + {U} - undo deletion | Ed Undo + {Q} - quit file | Ed Quit + {1} - set marker 1 | Ed Set M1 + {2} - set marker 2 | Ed Set M2 + + {O} - editor options | [ Options Menu ] + {V} - insert mode : ___ | EdOpt[V] + {I} - auto indent : ___ | EdOpt[I] + {T} - hard tabs : ___ | EdOpt[T] + {C} - control chars : ___ | EdOpt[C] + {R} - read only : ___ | Toggle RO + {W} - tab width : ___ | Ed Tab Width +!if mod + {U} - auto uppercase : ___ | EdOpt[U] +!end + +! key | Ed Word Left +! key | Ed Page Down +! key | Ed Move Right +! key | Ed Move Up +! key | Ed Word Right +! key | Ed Del Forward +! key | Ed Del Backward +! key | Ed Tab +! key | Ed Find Again +! key | Ed Ins Line +! key | Ed Ins Below +! key | Ed Prefix +! key | Ed Page Up +! key | Ed Move Left +! key | Ed Del Word +! key | Ed Upper Case +! key | Ed Scrl Down +! key | Ed Move Down +! key | Ed Del Line +! key | Ed Scrl Up +! key | Ed Next Error +! key | Ed Prev Error +! key | Ed Case Correct +! key | Ed Err Extension +! key | Paste + + +!! Text messages for TopSpeed environment +!! ====================================== + +! MsgText +001 7 +002 TopSpeed Release 3.10 +003 Clarion Software Corporation Copyright (C) 1992 +004 Multi-Language Programming Environment DOS Release 3.10 +!if os2 +005 Multi-Language Programming Environment OS/2 Release 3.10 +!end +!if xtd +005 Multi-Language Programming Environment XTD Release 3.10 +!end +006 Serial number: @ +007 Copyright (C) 1988-1992 +008 Release 3.10 +009 Clarion Software Corporation +010 Error: Menu text line @ +011 : " +012 " duplicate key +013 " not recognized +014 TS.MNU : Too many keys defined +015 Menu definition too large +016 Not Enough Memory +017 Date Not set +018 Not enough memory to run Help +019 Save file @ +020 Sharing @ +021 Change directory to @ +022 Load file +023 New file: @ +024 Window 1: |Window 2: |Window 3: |Window 4: |Window 5: |Window 6: |Window 7: |Window 8: |Window 9: @ +025 BAK +026 BKn +027 Saving @ +028 Write to file: @ +029 Writing @ +030 Write block to file: @ +031 Read block +032 File to read: @ +033 File not found. +034 PRN +035 Printing +036 \_!%$@? +037 Window to copy block from: @ +038 Block not defined in window. +039 Indent size: (+/-) +040 Search string not found. +041 Find: |Options: @ +042 Find: |Replace with: |Options: @ +043 {Esc}-cancel +044 Replace +045 Line length error +046 ^P +047 Insert @ +048 Overwrite +049 Line @ +050 Col @ +051 Total file size is too big! (>1MB) +052 File too big! (>500KB) +053 Warning, Disk almost full! +054 Failed to load file @ +055 File read failure on @ +056 Copy Data fail (source) +057 Load file +058 New file: @ +059 (Y/N): @ +060 {~17~217}-select {~25}-pick file {Tab}-history {Esc}-cancel +061 YN +062 Press Esc @ +063 {~17~217}-select {Tab}-history {Esc}-cancel +064 Recolor {~27~26}-background {~24~25}-foreground {PgUp}/{PgDn}/{*}-select area {Esc}-exit @ +065 Window @ +066 Write fail, Disk full? @ +067 Execute failure on @ +068 Error: @ +069 SYSTEM ERROR @ +070 File: @ +071 Terminate environment? +072 Abort or Retry? (A/R) +073 AR +074 Project name: @ +075 Run +076 Command line: @ +077 Change directory +078 New directory: @ +079 File directory +080 File mask: @ +081 pm +082 am +083 All : |Window 1: |Window 2: |Window 3: |Window 4: |Window 5: |Window 6: |Window 7: |Window 8: |Window 9: |Window 0: @ +!! 84-88 spare +089 Swapping out TopSpeed Environment +090 ..More: +091 View file (read only) +092 Filename: @ +093 File not found +094 Invalid CFG file +095 Too many lines in redirection file +096 OS Command Shell +097 Type EXIT to return to TopSpeed Environment +098 Program terminated +099 .EXE +100 on @ +101 off +102 Redirection filename: @ +103 Set High Background on exit from Environment? +104 Top scroll zone size: @ +105 Bottom scroll zone size: @ +106 No of backups: @ +107 Execute: @ +108 Goto line: @ +109 Tab width: @ +110 Searching @ +111 Block delete too big to be "undone" - Delete anyway? +!! 112-115 *spare* +116 {F1}-help {~24~25}-choose {~17~217}-select {CtrlY}-delete {Esc}-close +117 Pick file @ +!! 118 *spare* +119 {F1}-help {~27~26~24~25}-choose {~17~217}-select {Esc}-close +120 +121 Invalid directory: @ +122 Overwrite old @ +123 File " +124 " not found. +125 File: @ +126 Compile +127 Cut text {~27~26~24~25}-move {Ctrl~27~26}-fast move {B}-begin block {~17~217}-end block +128 ALL +129 Error: Unknown extension: @ +130 Search string: |Files to search: |Options: @ +131 Directories not allowed +132 No match found +133 Syntax Error +134 Project: @ +135 New limit: @ +!!136-138 spare +139 Sizes = Code: @ +140 Const: @ +141 Data: @ +142 PR +143 Copy project from: @ +144 Press {Esc} to abort +145 Press any key to continue +146 Project @ +147 Alt|Ctrl|Shift|UpArr|PgDn|DownArr|PgUp|Home|End|Del|Tab|Equal|LeftArr|RightArr|Ins|Enter|Esc|PageDown|PageUp|Space +148 Options: +149 {~17~217}-edit warnings/errors {Esc}-continue +150 Time taken (H:M:S:HS) = +151 File not found: @ +152 TopSpeed r3.5 +154 Save Macro File? +155 Read Only +156 Press {CtrlBreak} to abort +157 Made @ +158 Line +159 found +160 warning @ +161 warnings +162 error @ +163 errors @ +164 No +165 Make: @ +166 Link: @ +167 Run: @ +!!168 spare +169 Make completed +170 Press  to edit +171 Press key to continue +172 Compile completed +173 Make aborted +174 RED +175 TS.RED +176 CFG +177 TS.CFG +178 TS.SES +179 {U}-no case {W}-word {B}-back {G}-global {L}-local {R}-rest {N}-no ask {num}-repeat num +180 BUWGLNR* +181 {~27~26~24~25 Home End PgUp PgDn}-move @ +182 {Shift ~27~26~24~25}-resize @ +183 {~17~217}-recolor @ +184 Execute : unable to find @ +!! default filename +185 *.* +!! default extension +186 @ +187 Filename not found or extension not recognized: @ +188 C:\OSO001.MSG +189 TS.MAC +190 MAC +191 Press key to define +192 Too many errors/warnings +193 /C START "TS SHELL" /F/K @ +194 Compiler not installed for this language +195 {F1}-help {F10}-main menu {Esc}-close {Alt-X}-exit +196 {F1}-help {F5}-zoom {F6}-cycle {F9}-edit menu {F10}-main menu {Esc}-close {Alt-X}-exit +197 Recording macro for key: {} Press Alt= to End. +198 {ScrlLock}-exit @ +199 {AltW}-exit @ + +!! OS Errors +200 Out of memory +201 Dynamic pool limit exceeded +210 Invalid function number +211 File not found +212 Path not found +213 Too many open files (no handles left) +214 Access denied +215 Invalid handle +216 Memory control blocks destroyed +217 Insufficient memory +218 Invalid memory block address +219 Invalid environment +220 Invalid format +221 Invalid access code +222 Invalid data +223 DOS System Error: @ +224 Invalid drive was specified +225 Attempt to remove the current directory +226 Not same device +227 No more files +228 Attempt to write on write-protected diskette +229 Unknown unit +230 Drive not ready +231 Unknown command +232 Data error (CRC) +233 Bad request structure length +234 Seek error +235 Unknown media type +236 Sector not found +237 Printer out of paper +238 Write fault +239 Read fault +240 General failure +241 Sharing Violation +242 Lock Violation +243 Invalid disk change +244 FCB unavailable +245 File exists +246 Write failed (disk full?) + +300 Print File +301 Lines per page : |Page width : |Top margin : |Left margin : |Page heading : |Init string : | +302 Form Feed string : |Final string : |Output file/device : |Options : @ +303 Printer Options {H}-Heading {F}ile date {W}-Wrap {Esc}-Exit +305 Printing @ +306 Printer Settings +307 File to print: @ +308 Locate file: |Drives : @ +309 Files found: @ + + +310 Unexpected option: @ +311 Valid options are: +312 filename Edit filename. +313 /n filename Edit file in editor window n (1-9). +314 /L Set 43/50 line mode +315 /N New session (ignore TS.SES). +319 DLL load failed: @ +322 Total size loaded +323 Time|Date|Current Directory|#|Editor Windows|Size|Disk Free Space|Processor|Co-Processor|TopSpeed Version +325 Environment Information @ +331 Unknown|V20|V30|8088|8086|80188|80186|80286|80386|i486 +333 None|8087|80287|80387 + +340 TopSpeed Help System @ +341 {*}-wildcard search {U}-ignore case {1-9}-editor to load {R}-use redirection +342 *UR +349 Cannot find file ERRORINF.$$$ +350 ERRORINF.$$$ +351 Program : @ +352 Error : @ +353 at CS:IP : @ +354 Segment : @ +355 Source : @ +356 Near procedure : @ +357 Line @ +358 Col @ +359 Not enough information to find error +360 Remake program with debug information +361 DBD +362 EXE +363 MAP +364 Find error in source? +365 HLP +366 TSMAIN +367 $index +368 {F1}-index {~27~26~24~25}-choose {~17~217}-select topic {Esc}-close +369 {F1}-index {~27~26~24~25}-choose {~17~217}-select topic {PgDn}-next page {Esc}-close +370 {F1}-index {~27~26~24~25}-choose {~17~217}-select topic {PgUp}-prev page {Esc}-close +371 {F1}-index {~27~26~24~25}-choose {~17~217}-select topic {PgUp}-prev page {PgDn}-next page {Esc}-close +372 Help file " +373 " not found. +374 More.. +375 Keyboard codesDecHex +376 Keyboard character codes Press any key Press {Esc} twice to exit +377 Ascii code : @ +378 Extended code: @ +379 Key name : @ +380 DHChCtrlNmDHChCtrlNm +381 DHChDHChDHChDHCh +382 DHChDHChDHDisplayAttr +383 Ascii Table {PgUp}-prev page {PgDn}-next page {Esc}-Close +384 Black|Blue|Green|Cyan|Red|Magenta|Brown|Light Gray|Dark Gray|Light Blue|Light Green|Light Cyan|Light Red|Light Magenta|Yellow|White +385 View File {PgUp}-prev page {PgDn}-next page {Esc}-Close +386 File to view: @ +387 File: @ +390 ͻ +391 +392 ͼ +393 {d}ec {a}nd {+} {-} {s} {m+} {m-} +394 {h}ex {o}r {*} {/} {%} {m*} {m/} +395 {b}in {x}or {=} {c}lr {m=} {mr} {mc} +396 Dec|Hex|Bin|M +397 0123456789ABCDEF>dhbaox+-s*/%=cmr +398 Calculator + +400 UNNAMED +401 TEMPLATE +402 does not exist. Create? @ +403 Error in project file + +!! Help to extension mapping +450 TSMOD *.mod *.def +451 TSPAS *.pas *.itf +452 TSC *.c *.h +453 TSCPP *.cpp *.hpp +454 TSASM *.a *.inc + +!! Include file extensions (used by /ZI) +499 DEF ITF H HPP INC + +!! Overlay/DLL run-time errors (+500) +500 DLL error: @ +501 Loader cannot find entry point of main program. +502 Module count exceeded. +503 Wrong DLL version. +504 DLL corrupt. +505 Illegal fixup type found in imported module. +506 Imported module not found. +507 Relocation information corrupt. +508 Imported module not and .EXE or .DLL file. +509 Incorrect .DLL file format. +510 No memory available - load phase 1. +511 Module failed to initialize. +512 Error opening file. +513 No memory available - load phase 2. +514 Error reading file. +515 Error seeking file. +516 Internal error. + +!! Runtime errors (+600) +599 User error +600 Unknown type of error : +601 Stack overflow +602 Null pointer de-reference +603 Termination caused by signal. (User break or Floating point) +604 Arithmetic Overflow +605 Variable out of range +606 No return value from function +607 No matching Case Label +608 Long Integer Divide By Zero +609 Index out of range +610 Pure Virtual Function Called +616 Memory allocation initialisation (Out Of Memory) +617 I/O initialisation (Out Of Memory) +618 Invalid use of near heap in DLL +619 Complex Number Error +633 Dos Re-entered +634 NullProc Called +648 Invalid window +649 Use memory allocation +650 Settitle memory allocation +651 Initialisation error +652 new, Out Of Memory +653 dispose, Invalid Pointer +654 _wrint, Illegal Parameter +655 _wrint, Conversion Error +656 _wrchar, Illegal Parameter +657 _wrbool, Illegal Parameter +658 _wrastr, Illegal Parameter +659 _wrcstr, Illegal Parameter +660 _wrreal, Illegal Parameter +661 _wrreal, Conversion Error +662 _f_wrint, Illegal Parameter +663 _f_wrint, Conversion Error +664 Too many processes +665 New process memory allocation +666 Signal memory allocation +667 Scheduler memory allocation +668 Initialisation error +669 Stop process error +672 StopProcess - Corrupt Process +673 TRANSFER - Corrupt Process +674 ExecCmd, Memory Failure +675 ExecCmd, Command Line Too Long +676 ExecCmd, Command Processor Failed To Load +680 StartScheduler error +681 StopScheduler error +682 StartProcess error +683 SEND error +684 WAIT error +685 Notify error +686 Init error +687 Delay error +688 Illegal Assignment +696 Dos environment memory allocation +697 _f_wrchar, Illegal Parameter +698 _f_wrbool, Illegal Parameter +699 _f_wrastr, Illegal Parameter +700 _f_wrcstr, Illegal Parameter +701 _f_wrreal, Illegal Parameter +702 _f_wrreal, Conversion Error +703 _rdint, Invalid Integer +704 _rdreal, Invalid Real Number +705 _f_rdint, Invalid Integer +706 _f_rdreal, Invalid Real Number +707 assign, File Already Open +708 reset, No File Name +709 put, Invalid Mode +710 put, Write Error +711 put, Write Error +737 NearMakeHeap, Invalid Argument +738 NearHeapAllocate, Invalid Argument +739 NearHeapDeallocate, Invalid Argument +740 NearHeapAvail, Invalid Argument +741 NearHeapTotalAvail, Invalid Argument +742 NearHeapChangeSize, Invalid Argument +743 NearHeapChangeAlloc, Invalid Argument +744 FarHeapAllocate, Out Of Memory +745 FarHeapDeallocate, Invalid Argument +746 FarHeapDeallocate, Heap Corrupt +747 FarHeapChangeAlloc, Invalid Argument +748 FarAllocate, Out Of Memory +749 NearMakeHeap, Size Too Small +750 NearHeapAllocate, Out Of Memory +751 NearHeapDellocate, Invalid Argument +752 NearAllocate, Out Of Memory +753 Far Heap Call, Not Supported Under OS2 +754 ShtHeap.Initialize, Heap too small +755 ShtHeap.Increase, Not Enough Space +756 ShtHeap.Allocate, Size Error +757 ShtHeap.Allocate, Out Of Memory +758 ShtHeap.Free, Invalid Pointer +759 ShtHeap.Test, Heap Corruption +760 Close, Invalid Handle +762 Open, File Access Error +763 OpenRead, File Access Error +764 Append, File Access Error +765 Create, File Access Error +766 WrBin Error +767 RdBin Error +768 FIO Internal Error, Write Error Flushing File +769 GetPos, Write Seek Error +770 Seek, Write Seek Error +772 Truncate, File Write Error +774 Erase, File Name Error +775 Rename, File Name Error +776 ChDir, Directory Name Error +777 MkDir, Directory Name Error +778 RmDir, Directory Name Error +779 GetDir, Drive Number Error +780 ReadFirstEntry Error +781 ReadNextEntry Error +785 Assign Buffer, Invalid File Handle +786 Assign Buffer, Invalid Buffer Size +787 Assign Buffer, Stream Table Full +788 FIO Directory Call, Not Supported Under OS2 +790 IO.RedirectInput Error +791 IO.RedirectOutput Error +792 StartScheduler, System Error +793 StartProcess, System Error +794 StartProcess, SetPriority - System Error +795 StartProcess, SuspendThread - System Error +796 SEND, Semaphore System Error +797 WAIT, Semaphore System Error +798 Notify, Semaphore System Error +799 Init, Semaphore System Error +800 Delay, Sleep System Error +801 Launch, System Error +802 NewProcess, Too Many Threads +803 IOTRANSFER, Invalid Argument +809 Graphics Call, Not Supported Under OS2 +810 OSFatalError, Operating System Error +824 Undefined method called +825 get, Invalid Mode +826 get, End Of File +827 get, Read Error +828 close, Invalid Operation +829 eoln, End Of File +830 eoln, Invalid File +831 eoln, End Of File +832 eof, Invalid Operation +833 ln, Illegal Parameter +834 sqrt, Illegal Parameter +835 put, File Undefined +836 get, File Undefined +837 FlsBuf, Stream Not Buffered +838 FilBuf, Stream Not Buffered +840 BlockRead, I/O Error +841 GetMem, Out Of Memory +842 FilePos, Invalid File +843 FileSize, Invalid File +844 Seek, Invalid File +845 Rename, Invalid File +846 Append, File Not Assiged +847 MkDir, Invalid Path +848 RmDir, Invalid Path +849 ChDir, Invalid Path +850 OS2 Library, Function Not Supported +851 Windows Library, Function Not Supported +855 User Break + + +!! Batch introductory screen +!! ========================= + +940 ͻ +941 TopSpeed Release 3.10 Copyright (C) 1992 Clarion Software Corporation +942 +943 Usage: TSC filename(s) [options] Compile file(s) +944 TSC projectname /m [options] Make project +945 TSC projectname /l [options] Link project +946 Options Ķ +947 /v0 no VID information /v1 minimum VID information +948 /v2 full VID information /b generate line numbers +949 +950 /rs stack overflow checking /rn nil pointer checking +951 /ro overflow checking /rr range checking +952 /ri array index checking /cc const in code +953 /a+ Strict ANSI only /e- language extensions off +954 /j+ default char is unsigned /n+ allow nested comments +955 /dnnn define macro /unnn undefine predefined macro +956 /p preprocessor output /pc ... with comments +957 /pl ... minimize blank space /zg generate prototypes +958 /wxxx+ enable warning xxx /wxxx- disable warning xxx +959 /wxxx* treat warning as an error /w+ enable all warnings +960 /w- disable all warnings /w* turn warnings into errors +961 More.. +962 Model Options Ķ +963 /ms small model /mm medium model +964 /mc compact model /ml large model +965 /mx extra large model /mt multi thread model +966 /mo overlay model /md dynalink model +967 /me extended model /mf extended mthread model +968 Optimization Options Ķ +969 /ox- disable all optimizations +970 /ot- disable time optimization /oe- disable CSE optimization +971 /oc- disable constant optimization /oh- disable peep hole optim. +972 /oj- disable jump optimization /ol- disable loop optimization +973 /oa- disable alias optimization /or- disable register optim. +974 /of- disable stack frame optim. /opx select processor 80x86 +975 /oq0 select fp-emulator (default) /oqx select co-processor 80x87 +976 Misc. Options Ķ +977 /fpnnn define project file /y use DOS environment vars +978 /Iddd include files directory /zq quiet mode +979 /snnn=nnn set project system macro /r remake all +980 ͼ diff --git a/code/SIBOSDK/sys/tsprj.txt b/code/SIBOSDK/sys/tsprj.txt new file mode 100644 index 0000000..74c421d --- /dev/null +++ b/code/SIBOSDK/sys/tsprj.txt @@ -0,0 +1,617 @@ +! Project Predefined +!! predefine TopSpeed compilers +!if mod +#declare_compiler mod= +'#set make=%%remake_jpi + #if %%make #then #rundll TSMOD %%src %%obj #endif + #pragma link(%%obj) + #set tsm2=on' +!end +!if pas +#declare_compiler pas= +'#set make=%%remake_jpi + #if %%make #then #rundll TSPAS %%src %%obj #endif + #pragma link(%%obj) + #set tspas=on' +#declare_compiler plg= +'#set make=%%remake_jpi + #if %%make #then #rundll TSPAS_LG %%src %%obj #endif + #pragma link(%%obj) + #set tspas=on' +!end +!if cpp +#declare_compiler cpp= +'#set make=%%remake_jpi + #if %%make #then + #rundll TSCPP %%src %%obj + #if %%system=epoc #then + #run "ecppfx -s %%obj" no_window no_abort + #endif + #endif + #pragma link_option(decode=>on) + #pragma link(%%obj) + #set tsc=on #set tscpp=on' +!! This declaration is overriden by the one below if TopSpeed C is installed +#declare_compiler c= +'#set make=%%remake_jpi + #if %%make #then #rundll TSCPP %%src %%obj #endif + #pragma link(%%obj) + #set tsc=on' +!end +!if c +#declare_compiler c= +'#set make=%%remake_jpi + #if %%make #then #rundll TSC %%src %%obj #endif + #pragma link(%%obj) + #set tsc=on' +!end +!if asm +#declare_compiler a= +'#set make=%%remake_jpi + #if %%make #then #rundll TSASM %%src %%obj #endif + #pragma link(%%obj)' +!end +!if masm +#declare_compiler asm= +'#set make=%%remake + #if %%make #then + #edit save %%src + #run "masm %%src,%%obj; >masmtmp.$$$" no_window no_abort + #file adderrors masmtmp.$$$ + #file delete masmtmp.$$$ + #endif + #pragma link(%%obj)' +!end + +#declare_compiler rc= +'#split %%obj + #set obj = %%name.res + #set make=%%remake + #if %%make #then + #edit save %%src + #run "tsrc %%src >rctmp.$$$" no_window no_abort + #file adderrors rctmp.$$$ + #file delete rctmp.$$$ + #endif + #pragma link(%%obj)' + +#declare_compiler cat= +'#split %%src + #set make=%%remake + #if %%make #or %%name.g #older %%name.cat #then + #run "ctran %%name -c -s -v -l -e..\include\ -x..\include\ -g..\include\" no_window no_abort + #rundll TSC %%name.c %%name.obj + #run "ecobj %%name.obj" no_window no_abort + #endif + #pragma link(%%name.obj)' + +#if %action%=compile #then +!! declarations to allow compilation of include files +!if mod + #declare_compiler def='#rundll TSMOD %%src %%obj' +!end +!if cpp + #declare_compiler hpp='#rundll TSCPP %%src %%obj' + #declare_compiler h='#rundll TSCPP %%src %%obj' +!end +!if C + #declare_compiler h='#rundll TSC %%src %%obj' +!end +#endif + +!! End of compiler predefinition section +!! ========================================================================= +! Project Model +!! The following lines are executed whenever the #model command is used +!! in a project file. + +#pragma call(near_call=>on,same_ds=>on,ds_eq_ss=>on,overlay=>off) +#pragma data(far_ext=>off,near_ptr=>on,threshold=>65535,const_in_code=>off,ss_in_dgroup=>on,ds_dynamic=>off) +#pragma define(_fdata=>off,_fcall=>off,_fptr=>off,_mthread=>off) +#pragma link_option(map=>on,case=>on,pack=>on,oldexe=>off) +#pragma define(M_I86SM=>off,M_I86CM=>off,M_I86MM=>off,M_I86LM=>off,M_I86XM=>off,M_I86TM=>off,M_I86MTM=>off,M_I86OM=>off,M_I86DM=>off) + +!! PSION SIBO change +#pragma optimize(speed=>off) +#if %system=epoc #then + #if #not %model=small #then + #error "ERROR - must use small model for epoc" + #endif + #if #not %filetype=img #then + #if #not %filetype=dyl #then + #error "ERROR - illegal parameter in #system: %filetype" + #endif + #endif + #if "%epocinit"="" #then + #set epocinit=iclib + #endif +#endif +!! end of PSION SIBO change + +#if "%system"="" #then + #error "#model not preceded by #system" +!if smallmodel +#elsif %model=small #then + #set M=S + #pragma define(M_I86SM=>on) +!end +!if compactmodel +#elsif %model=compact #then + #set M=C + #pragma call(ds_eq_ss=>off) + #pragma data(near_ptr=>off,threshold=>32767,ss_in_dgroup=>off) + #pragma define(_fptr=>on) + #pragma define(M_I86CM=>on) +!end +!if mediummodel +#elsif %model=medium #then + #set M=M + #pragma call(near_call=>off) + #pragma define(_fcall=>on) + #pragma define(M_I86MM=>on) +!end +!if largemodel +#elsif %model=large #then + #set M=L + #pragma call(near_call=>off,ds_eq_ss=>off),data(near_ptr=>off,threshold=>32767,ss_in_dgroup=>off) + #pragma define(_fcall=>on,_fptr=>on) + #pragma define(M_I86LM=>on) +!end +!if xlargemodel +#elsif %model=xlarge #then + #if #not %system=win #then + #set M=X + #pragma call(near_call=>off,same_ds=>off,ds_eq_ss=>off),data(far_ext=>on,near_ptr=>off,const_in_code=>on,ss_in_dgroup=>off,ds_dynamic=>on) + #pragma define(_fcall=>on, _fdata=>on,_fptr=>on) + #pragma define(M_I86XM=>on) + #else + #error "Extra-large model not available for Windows programs" + #endif +!end +!if mthreadmodel +#elsif %model=mthread #then + #if #not %system=win #then + #set M=T + #pragma call(near_call=>off,same_ds=>off,ds_eq_ss=>off),data(far_ext=>on,near_ptr=>off,const_in_code=>on,ss_in_dgroup=>off,ds_dynamic=>on) + #pragma define(_fcall=>on, _fdata=>on,_fptr=>on,_mthread=>on) + #pragma define(M_I86TM=>on,M_I86MTM=>on) + #else + #error "Multi-thread model not available for Windows programs" + #endif +!end +!if overlaymodel +#elsif %model=overlay #then + #if %system=dos #then + #set M=O + #pragma call(near_call=>off,same_ds=>off,overlay=>on,ds_eq_ss=>off),data(far_ext=>on,near_ptr=>off,const_in_code=>off,ss_in_dgroup=>off,ds_dynamic=>on) + #pragma define(_fcall=>on,_fdata=>on,_fptr=>on,_mthread=>on) + #pragma define(M_I86OM=>on) + #else + #error "Overlay model not available for %system programs" + #endif +!end +!if dynalinkmodel +#elsif %model=dynalink #then + #if #not %system=win #then + #set M=D + #pragma call(near_call=>off,same_ds=>off,ds_eq_ss=>off),data(far_ext=>on,near_ptr=>off,ss_in_dgroup=>off,ds_dynamic=>on) + #if %system=dos #then + #pragma call(overlay=>on) + #else + #pragma data(const_in_code=>on) + #endif + #pragma define(_fcall=>on,_fdata=>on,_fptr=>on,_mthread=>on) + #pragma define(M_I86DM=>on) + #pragma link_option(smart_method=>off) + #else + #error "Dynalink model not available for Windows programs" + #endif +!end +#else + #error "Unrecognized argument %model" +#endif + +#if "%jpicall"="" #then #set jpicall=jpi #endif +#if %jpicall=jpi #then + #pragma call(reg_saved=>(ax,bx,cx,dx,si,di,ds,st1,st2)) + #pragma call(reg_param=>(ax,bx,cx,dx,st0,st6,st5,st4,st3)) + #pragma call(reg_return=>(ax,dx,st0)) + #pragma call(standard_conv=>off,standard_float=>off,opt_var_arg=>on) + #if %model=overlay #or (%model=dynalink #and %system=dos) #then + #pragma call(opt_var_arg=>off) + #endif + #set C=_ + #pragma define(_jpicall=>on) +#elsif %jpicall=stack #then + #pragma call(reg_saved=>(si,di,ds,st1,st2)) + #pragma call(reg_param=>()) + #pragma call(reg_return=>(ax,dx)) + #pragma call(standard_conv=>on,standard_float=>on,opt_var_arg=>off) + #set C=F + #pragma define(_jpicall=>off) +#else + #error "Unrecognized argument %jpicall" +#endif + +#if %system=win #then + #set O=W + #pragma link_option(pack=>off,windows=>on),call(windows=>on) +#elsif %system=dos #then + #set O=R + #pragma link_option(oldexe=>on,pack=>off),call(windows=>off) + #pragma optimize(cpu=>86) +#elsif %system=os2 #then + #set O=P + #pragma optimize(cpu=>286),call(windows=>off) +!! PSION SIBO change +#elsif %system=epoc #then + #set O=R + #pragma link_option(case=>on,oldexe=>on,pack=>off) + #pragma optimize(cpu=>86) + #pragma data(no_far_data=>on) + #pragma define(EPOC=>1) + #if "%epocinit"="iclib" #then + #pragma data(stack_size=>8192) + #elsif "%epocinit"="iclib4" #then + #pragma data(stack_size=>4096) + #elsif "%epocinit"="iclib2" #then + #pragma data(stack_size=>2048) + #elsif "%epocinit"="iplib8" #then + #pragma data(stack_size=>8192) + #elsif "%epocinit"="iplib" #then + #pragma data(stack_size=>4096) + #elsif "%epocinit"="iplib2" #then + #pragma data(stack_size=>2048) + #else + #error "Unknown epocinit: %epocinit" + #endif +!! end of PSION SIBO change +#else + #error "Unknown argument to #system: %system" +#endif + +!! defines used by library source files +!! you may wish to disable these in order to share OS2/DOS object files +!! _DLL may not be disabled +#pragma define(_ENV=>off,_WINDOWS=>off,_DLL=>off,_WINDLL=>off,_OVL=>off,_OS2=>off,__OS2__=>off,__MSDOS__=>off) +#if %system=os2 #then #pragma define(__OS2__=>on,_OS2=>on) #endif +#if %system=dos #then #pragma define(__MSDOS__=>on) #endif +#if %system=win #then #pragma define(_WINDOWS=>on) #endif +#if %model=overlay #then #pragma define(_OVL=>on) #endif +#if %model=dynalink #then #pragma define(_DLL=>on) #endif + +!! End of Project model section +!! ========================================================================= +! Project Link +!! The following lines are executed whenever a #link command is executed in +!! a project file + +#autocompile + +!! Calculate lfiletype - the type of file being made for this #link only +!! Default is the filetype specified by #system (%filetype) + +#if "%filetype"="" #then +!! PSION SIBO change + #if %system=epoc #then + #set filetype=img + #else + #set filetype=exe + #endif +!! end of PSION SIBO change +#endif + +#split %link_arg +#if "%ext"="" #then + #set lfiletype_=%filetype + #set ext=%filetype +#elsif (%ext=exe) #or (%ext=dll) #or (%ext=lib) #then + #set lfiletype_=%ext +#else + #set lfiletype_=%filetype +#endif + +!! PSION SIBO change +#if %system=epoc #then + #if %filetype=img #then + #set epoctype=t1 + #elsif %filetype=dyl #then + #set epoctype=t4 + #endif +#endif +!! end of PSION SIBO change + +!! Calculate any additional libraries or object files that need to be linked + +#if #not %lfiletype_=lib #then + #if %system=win #then + #if %lfiletype_=dll #then + #compile initwdll.a + #pragma linkfirst(initwdll.obj) + #elsif %filetype=exe #then + #if "%tsm2" #or "%tspas" #then + #compile initmwin.a + #pragma linkfirst(initmwin.obj) + #else + #compile initwin.a + #pragma linkfirst(initwin.obj) + #endif + #else + #error "Unknown argument to #system: %filetype" + #endif + #else + #if %lfiletype_=dll #then + #pragma linkfirst(initdll.obj) + #elsif %lfiletype_=exe #then + #if (#not ("%tsc" #or "%tscpp")) #and (%system = dos) + #and (("%model"=xlarge) #or ("%model"=mthread)) #then + #pragma linkfirst(initnew.obj) + #elsif "%pm_api" #and (%system=os2) #then + #pragma link_option(pm=>on,non_pm=>off) + #pragma linkfirst(initpm.obj) +!! PSION SIBO change + #elsif %system=epoc #then + #if %filetype=img #then + #pragma linkfirst(%epocinit.obj) + #else + #pragma linkfirst(icat.obj) + #endif +!! end of PSION SIBO change + #else + #pragma linkfirst(initexe.obj) + #endif + #if (%system=os2) #then + #if "%pm_compat" #then + #pragma link_option(pm=>on,non_pm=>on) + #elsif "%pm_noncompat" #then + #pragma link_option(pm=>off,non_pm=>on) + #endif + #endif + #else + !! PSION SIBO change + #if %system=epoc #then + #if %filetype=img #then + #pragma linkfirst(%epocinit.obj) + #else + #pragma linkfirst(icat.obj) + #endif + #else + #error "Unknown argument to #system: %filetype" + #endif +!! end of PSION SIBO change + #endif + #endif + +!! calculate jpilib_ + + #set prefix_="%O%%M%%C%" + #if (%lfiletype_=dll) #and (%system=win) #then + #set jpilib_="%prefix_%comd.lib" + #else + #set jpilib_="%prefix_%com.lib" + #endif + #if "%tsc" #then + #set jpilib_="%jpilib_,%prefix_%clib.lib" + #endif + + #if "%tscpp" #then + #if %model=dynalink #then + #set CPPprefix_="%O%%M%%C%" + #else + #set CPPprefix_="C%M%%C%" + #endif + #set jpilib_="%jpilib_,%CPPprefix_%slib.lib" + #if "%usertool" #then + #set jpilib_="%jpilib_,%CPPprefix_%rtool.lib" + #endif + #if "%usermath" #then + #set jpilib_="%jpilib_,%CPPprefix_%rmath.lib" + #endif + #endif + + #if "%tsm2" #then + #set jpilib_="%jpilib_,%prefix_%m2.lib" + #if "%tsc" #then + #set jpilib_="%jpilib_, %prefix_%mlibc.lib" + #if "%cwindow"=jpi #then + #set jpilib_="%jpilib_, %prefix_%wind.lib" + #endif + #else + #set jpilib_="%jpilib_, %prefix_%mlib.lib" + #endif + #endif + + #if "%tspas" #then + #if %model=dynalink #then + #if %tsc #then + #set jpilib_="%jpilib_,%prefix_%pasc.lib" + #elsif %tsm2 #then + #set jpilib_="%jpilib_,%prefix_%pasm.lib" + #else + #set jpilib_="%jpilib_,%prefix_%pas.lib" + #endif + #else + #set jpilib_="%jpilib_,%prefix_%pas.lib" + #endif + #if "%tsc" #then + #set jpilib_="%jpilib_,%prefix_%mlibc.lib" + #if "%cwindow"=jpi #then + #set jpilib_="%jpilib_,%prefix_%wind.lib" + #endif + #elsif "%tsm2" #then + #set jpilib_="%jpilib_,%prefix_%mlib.lib" + #else + #set jpilib_="%jpilib_,%prefix_%plib.lib" + #endif + #pragma link_option(case=>off) + #endif + + #if "%cgraph"=jpi #then + #set jpilib_="%jpilib_,%prefix_%graph.lib" + #elsif "%cgraph"=borland #then + #set jpilib_="%jpilib_,graphics.lib" + #endif + + #if ("%cwindow"=jpi) #and #not(("%tsm2") #or("%tspas")) #then + #set jpilib_="%jpilib_,%prefix_%wind.lib" + #elsif "%cwindow"=borland #then + #set jpilib_="%jpilib_,%prefix_%borw.lib" + #endif + + #if "%system"=os2 #then + #if "%pm_api" #then + #set jpilib_="%jpilib_,pmjpi.lib,os2jpi.lib" + #else + #set jpilib_="%jpilib_,os2jpi.lib" + #endif + #elsif (%model=overlay) #or (%model=dynalink) #then + #set jpilib_="%jpilib_,loader.lib" + #endif + +!! PSION SIBO change + #if %system=epoc #then + #if "%epocinit"="iclib" #or "%epocinit"="iclib4" #or "%epocinit"="iclib2" #then + #if %filetype=img #then + #pragma link(clib.lib) + #endif + #endif + #set jpilib_="plib.lib" + #endif +!! end of PSION SIBO change + + #pragma link(%jpilib_) +!! PSION SIBO change + #if %system=epoc #then + #pragma link(wlib.lib) + #pragma link(rlib.lib) + #endif +!! end of PSION SIBO change +#endif + +!! Now do the link +#if (%ext=dll) #then + #pragma link_option(smart_method=>off) + #if (%system=dos) #then + #if #not ((%model=overlay) #or (%model=dynalink)) #then + #error "DOS DLLs must use overlay or dynalink model" + #endif + #elsif (%system=os2) #then + #if #not ((%model=xlarge) #or (%model=mthread) #or (%model=dynalink)) #then + #error "OS2 DLLs must use xlarge, mthread or dynalink model" + #endif + #endif +#endif + +#if "%ext%"=lib #then + #dolink %name%.%ext% +#elsif ("%model"=overlay) #or ((%system=dos) #and ("%model"=dynalink)) #then + #if "%ext%"=dll #then + #if #not "%manual_export" #then + #if #exists %name%.exp #then + #implib %name%.lib %name%.exp + #else + #implib %name%.lib + #endif + #endif + #else + #pragma link_option(stub=>ovlload.exe) + #endif + #pragma link_option(map=>on,oldexe=>off,overlay=>on,pack=>off) + #dolink %name%.%ext% + #message "link complete" + #set ovrexe_=%name%.%ext% + #set ovrmap_=%name%.map + #if #exists %name%.exp #then + #set ovrexp_=%name%.exp + #else + #set ovrexp_=overlay.exp + #endif + #if %make #or %ovrexe_ #older %ovrexp_ #then + #message "Patching EXE header" + #exemod %ovrexe_ %ovrexp_ %ovrmap_ + #endif +#elsif (%system=os2) #and ("%ext%"=dll) #then + #if #not "%manual_export" #then + #if #exists %name%.exp #then + #implib %name%.lib %name%.exp + #else + #implib %name%.lib + #endif + #endif + #pragma link_option(map=>on,oldexe=>off) + #dolink %name%.%ext% + #message "link complete" +#elsif %system = win #then + #set link_arg=%name%.%ext% + #set winexp_=%name%.exp + #set winexe_=%name%.%ext% + #set winlib_=%name%.lib + #set winmap_=%name%.map + #implib %winlib_ %winexp_ + #pragma link_option(map=>on,oldexe=>off,windows=>on,export=>on) + #pragma link(windows.lib) + #if "%winmath" = chip #then + #pragma link(noemul.obj) + #elsif "%winmath" = emu #then + #pragma link(winfloat.obj) + #pragma link(win87em.lib) + #elsif "%winmath" = none #then + #pragma link(nofloat.obj) + #else + #error "Please set project system macro 'winmath' to 'chip', 'emu' or 'none'" + #endif + #dolink %link_arg + #message "link complete" + #if "%make" #then + #exemod %winexe_ %winexp_ %winmap_ + #endif +!! PSION SIBO change +#elsif %system=epoc #then + #dolink %name%.exe +!! end of PSION SIBO change +#else + #dolink %name%.%ext% +#endif + +!! PSION SIBO change +!! convert the .exe file to a .img or .dyl file +#if %system=epoc #then + #if %name%.%filetype% #older %name%.exe #then + #set afl="" + #set dfl="" + #if "%version"="" #then #set version=0x100f #endif + #message "Making %name%.%filetype%" + #if %filetype=img #then + #if #exists %name%.afl #then #set afl="-a%name%.afl" #endif + #if #exists %name%.dfl #then #set dfl="-d%name%.dfl" #endif + #if "%priority"="" #then #set priority=0x80 #endif + #if "%heapsize"="" #then #set heapsize=0x80 #endif + #else + #set priority="" + #set heapsize="" + #endif + #run "emake >make.$$$ -b %afl% %dfl% -o%name% -s -v%version% -p%priority% -h%heapsize% -%epoctype% %name%.exe" no_window no_abort + #file adderrors make.$$$ + #file delete make.$$$ + #endif +#endif +!! #run "emake >make.$$$ -b -o%name% -s -v%version% -%epoctype% %name%" no_window no_abort +!! end of PSION SIBO change + +!! Reset macros indicating what libraries are required + +#set tsc=off +#set tscpp=off +#set tspas=off +#set tsm2=off +#set cwindow="" +#set cgraph="" +#set pm_api="" +#set pm_compat="" +#set pm_noncompat="" +#set manual_export="" + +!! End of Project Link section +! Project End +!! ========================================================================= + diff --git a/code/SIBOSDK/tprint/dedlg.c b/code/SIBOSDK/tprint/dedlg.c new file mode 100644 index 0000000..2f99e3b --- /dev/null +++ b/code/SIBOSDK/tprint/dedlg.c @@ -0,0 +1,17 @@ +/* DEDLG.C */ + +#include +#include + +#pragma METHOD_CALL + +METHOD INT dedlg_dl_key(PR_DLGBOX *self) + { + RBUF_LP *prbuf; + + prbuf=self->dlgbox.rbuf; + prbuf->dayno=hDlgSenseDtedit(1); + prbuf->ndays=hDlgSenseNcedit(2); + prbuf->gap=hDlgSenseChlist(3); + return(WN_KEY_CHANGED); + } diff --git a/code/SIBOSDK/tprint/delp.c b/code/SIBOSDK/tprint/delp.c new file mode 100644 index 0000000..5c16996 --- /dev/null +++ b/code/SIBOSDK/tprint/delp.c @@ -0,0 +1,105 @@ +/* DELP.C */ + +#include +#include +#include + +#define TIME_FMT_FLAGS (PR_TIME_MONTH_NAME|PR_TIME_SUFFIX_NAME) + +LOCAL_C VOID InitTimeObject(PR_DELP *self) + { + P_DAYSEC ds; + SE_TIME_FORMAT fmt; + + ds.day=self->delp.rbuf.dayno; + ds.sec=0; + self->delp.time=f_new(CAT_DEMO_OLIB,C_TIME); + p_send4(self->delp.time,O_TO_SET,SET_TIME_DAYSEC,&ds); + fmt.flags=TIME_FMT_FLAGS; + p_send4(self->delp.time,O_TO_SET_FORMAT,&fmt,TIME_FMT_FLAGS); + } + +LOCAL_C UINT SenseBufWidth(PR_DELP *self,TEXT *pb) + { + return(p_send4(self,O_LPR_SENSE_BUF_WIDTH,pb,p_slen(pb))); + } + +LOCAL_C VOID FindWidthFirstColumn(PR_DELP *self) + { + INT i; + TEXT buf[E_MAX_DAY_NAME]; + UWORD wid; + + for (i=0; i<7; i++) + { + p_nmday(&buf[0],i); + wid=SenseBufWidth(self,&buf[0]); + if (wid>self->delp.colwid) + self->delp.colwid=wid; + } + self->delp.colwid+=SenseBufWidth(self," "); /* two spaces */ + if (self->delp.colwid>(3*self->lprinter.width/4)) + { + hInfoPrint(DELP_PAPER_NARROW); + p_sleep(20); + p_leave(RUN_ACTIVE_CLEANUP_NONOTIFY); + } + self->lprinter.subsqind=self->delp.colwid; + } + +#pragma METHOD_CALL + +METHOD VOID delp_lpr_init(PR_DELP *self,RBUF_LP *prbuf) + { + self->delp.rbuf=(*prbuf); + p_supersend2(self,O_LPR_INIT); + } + +METHOD INT delp_lpr_sense_text(PR_DELP *self,WDR_PRINT *pr) + { + P_DATE dt; + P_DAYSEC ds; + + if (!self->delp.time) + { + InitTimeObject(self); + FindWidthFirstColumn(self); + } + else if (!self->delp.rbuf.ndays) + return(FALSE); + switch (self->delp.state++) + { + case DELP_STATE_COL1: + if (self->delp.rbuf.gap) + { + p_send4(self->delp.time,O_TO_SENSE,SENSE_TIME_DATE,&dt); + if (!dt.day) + { + pr->down=pr->height; + if (self->delp.rbuf.gap==1) + pr->down>>=1; + } + } + p_send4(self->delp.time,O_TO_SENSE,SENSE_TIME_DAYSEC,&ds); + p_nmday(&self->delp.dname[0],P_WEEK(ds.day)); + self->delp.right=self->delp.colwid + -SenseBufWidth(self,&self->delp.dname[0]); + pr->buf=(&self->delp.dname[0]); + break; + case DELP_STATE_COL2: + pr->flags&=(~(WDR_PRINT_LINE|WDR_PRINT_TEXT)); + pr->flags|=WDR_PRINT_RIGHT; + pr->right=self->delp.right; + return(TRUE); + case DELP_STATE_COL3: + p_send4(self->delp.time,O_TO_SENSE,SENSE_TIME_DATESTR,&self->delp.buf[0]); + pr->buf=(&self->delp.buf[0]); + pr->flags&=(~WDR_PRINT_LINE); + pr->indent=self->delp.colwid; + self->delp.rbuf.ndays--; + p_send4(self->delp.time,O_TO_ADD_DAYS,1,0); + self->delp.state=DELP_STATE_COL1; + } + pr->blen=p_slen(pr->buf); + return(TRUE); + } diff --git a/code/SIBOSDK/tprint/demain.c b/code/SIBOSDK/tprint/demain.c new file mode 100644 index 0000000..3ab9cf7 --- /dev/null +++ b/code/SIBOSDK/tprint/demain.c @@ -0,0 +1,17 @@ +/* DEMAIN.C */ + +#include + +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|FLG_APPMAN_FULLSCREEN; + app.wserv_cat=p_getlibh(CAT_DEMO_DEMO); + app.wserv_class=C_DEWSERV; + wserv.com_cat=p_getlibh(CAT_DEMO_HWIM); + wserv.com_class=C_COMMAN; + p_send4(p_new(CAT_DEMO_HWIM,C_HWIMMAN),O_AM_INIT,&app,&wserv); + } diff --git a/code/SIBOSDK/tprint/demo.cat b/code/SIBOSDK/tprint/demo.cat new file mode 100644 index 0000000..e8f5520 --- /dev/null +++ b/code/SIBOSDK/tprint/demo.cat @@ -0,0 +1,51 @@ +IMAGE demo + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE hwimman.g +INCLUDE dlgbox.g +INCLUDE lprinter.g +INCLUDE time.g +INCLUDE epoc.h + +CLASS dewserv wserv + { + REPLACE ws_dyn_init + } + +CLASS dedlg dlgbox + { + REPLACE dl_key + TYPES + { + typedef struct + { + UWORD dayno; + UWORD ndays; + UWORD gap; + } RBUF_LP; + } + } + +CLASS delp lprinter + { + REPLACE lpr_init + REPLACE lpr_sense_text + CONSTANTS + { + DELP_STATE_COL1 0 + DELP_STATE_COL2 1 + DELP_STATE_COL3 2 + } + PROPERTY 1 + { + VOID *time; + UWORD colwid; + UWORD right; + UWORD state; + RBUF_LP rbuf; + TEXT dname[E_MAX_DAY_NAME]; + TEXT buf[LN_TIME_DATE_STR]; + } + } diff --git a/code/SIBOSDK/tprint/demo.pic b/code/SIBOSDK/tprint/demo.pic new file mode 100644 index 0000000..d980c34 Binary files /dev/null and b/code/SIBOSDK/tprint/demo.pic differ diff --git a/code/SIBOSDK/tprint/demo.rss b/code/SIBOSDK/tprint/demo.rss new file mode 100644 index 0000000..b4ff082 --- /dev/null +++ b/code/SIBOSDK/tprint/demo.rss @@ -0,0 +1,55 @@ +/* DEMO.RSS */ + +#include +#include + +RESOURCE WSERV_INFO demo_accs + { + menbar_id=0; + first_com=0; + accel={'x'}; + } + +RESOURCE MENU delp_gap_chlist + { + items = + { + CHOICE_ITEM { str="No gap";}, + CHOICE_ITEM { str="Half a line";}, + CHOICE_ITEM { str="Complete line";} + }; + } + +RESOURCE DIALOG delp_dlg + { + title="Print list of days"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_DTEDIT; + prompt="Start date"; + info=DTEDIT { flags=IN_DTEDIT_DDMMYYYY;}; + }, + CONTROL + { + class=C_NCEDIT; + prompt="Number of days to print"; + info=NCEDIT + { + low=10; + current=20; + high=200; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Space between months"; + info=CHLIST { rid=delp_gap_chlist; }; + } + }; + } + +RESOURCE STRING delp_paper_narrow { str="Paper size too narrow"; } diff --git a/code/SIBOSDK/tprint/dewserv.c b/code/SIBOSDK/tprint/dewserv.c new file mode 100644 index 0000000..dd67cfe --- /dev/null +++ b/code/SIBOSDK/tprint/dewserv.c @@ -0,0 +1,29 @@ +/* DEWSERV.C */ + +#include +#include +#include + +LOCAL_C INT LaunchDialog(INT class,INT resid,VOID *rbuf) + { + DL_DATA dld; + + dld.id=resid; + dld.rbuf=rbuf; + dld.pdlg=NULL; + return hLaunchDial(CAT_DEMO_DEMO,class,&dld); + } + +#pragma METHOD_CALL + +METHOD VOID dewserv_ws_dyn_init(PR_DEWSERV *self) + { + RBUF_LP rbuf; + + if (LaunchDialog(C_DEDLG,DELP_DLG,&rbuf)) + { + p_send2(self,O_WS_EDIT_PRINT_CONTEXT); + hDestroy(f_newsend(CAT_DEMO_DEMO,C_DELP,O_LPR_INIT,&rbuf)); + } + p_exit(0); + } diff --git a/code/SIBOSDK/tprint/make.bat b/code/SIBOSDK/tprint/make.bat new file mode 100644 index 0000000..158073b --- /dev/null +++ b/code/SIBOSDK/tprint/make.bat @@ -0,0 +1,3 @@ +@echo off +tscx /m tprint +tscx /m tprint diff --git a/code/SIBOSDK/tprint/tprint.afl b/code/SIBOSDK/tprint/tprint.afl new file mode 100644 index 0000000..88c6f9b --- /dev/null +++ b/code/SIBOSDK/tprint/tprint.afl @@ -0,0 +1,2 @@ +demo.pic +demo.rzc diff --git a/code/SIBOSDK/tprint/tprint.pr b/code/SIBOSDK/tprint/tprint.pr new file mode 100644 index 0000000..31f72af --- /dev/null +++ b/code/SIBOSDK/tprint/tprint.pr @@ -0,0 +1,31 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#compile demo.cat + +#if %remake #or (demo.rsg #older demo.rss) #then + #file delete demo.rsg + #run "rs demo" no_window no_abort +#endif + +#if demo.rzc #older demo.rsg #then + #run "rch demo" no_window no_abort + #file delete tprint.img +#endif + +#compile delp.c +#compile dedlg.c +#compile demain.c +#compile dewserv.c + +#if (tprint.img #older tprint.afl) #or (tprint.img #older demo.pic) #then + #file delete tprint.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link tprint.img diff --git a/code/SIBOSDK/tprint/tprrel.prj b/code/SIBOSDK/tprint/tprrel.prj new file mode 100644 index 0000000..51cfa87 --- /dev/null +++ b/code/SIBOSDK/tprint/tprrel.prj @@ -0,0 +1,14 @@ +tprrel.prj ! releases source files +tprint.pr ! TS project file +make.bat ! makes TPRINT.IMG +! +demo.cat ! category file +demo.rss ! resource script +! +delp.c ! line printer +dedlg.c ! dialog +demain.c ! main +dewserv.c ! window server subclass +! +tprint.afl ! add file list +demo.pic ! icon diff --git a/code/SIBOSDK/wd/bj.wd b/code/SIBOSDK/wd/bj.wd new file mode 100644 index 0000000..bb1ad74 --- /dev/null +++ b/code/SIBOSDK/wd/bj.wd @@ -0,0 +1,206 @@ +! BJ.WD +! Printer driver file for Cannon BJ series printers + +COMMANDS +!<27>[K<4><0><0><36><1><65> +! <4><0> - 4 bytes remaining +! <0> - init to user-defined settings +! <36> - ID for BJ-10e +! <1> - Character set 2 +! <65> - Multiligual 850 (64) + Auto Sheet Feeder (1) + RESET "<27>[K<4><0><0><36><1><65>" + FORM_LENGTH "<27>C%c" +!<27>A<1> - set line spacing to 1/72 inch +!<27>2 - enable the above + PREAMBLE "<27>A<1><27>2" +!<27>[K<1><0><0> +! <4><0> - 1 bytes remaining +! <0> - init to user-defined settings + POSTAMBLE "<27>[K<1><0><0>" + BOLD_ON "<27>E" + BOLD_OFF "<27>F" + ITALIC_ON "<27>-<1>" + ITALIC_OFF "<27>-<0>" + UNDERLINE_ON "<27>-<1>" + UNDERLINE_OFF "<27>-<0>" + SUBSCRIPT_ON "<27>S<1>" + SUBSCRIPT_OFF "<27>T" + SUPERSCRIPT_ON "<27>S<0>" + SUPERSCRIPT_OFF "<27>T" + NEW_PAGE "<12>" + CARRIAGE_RETURN "<13>" + MOVE_DOWN "*<10>" + MOVE_RIGHT_PREFIX "" + MOVE_RIGHT "<27>d%w" + MOVE_RIGHT_SUFFIX "" +END_COMMANDS + +TRANSLATES telephone + 5:35 +END_TRANSLATES + +WIDTHS wid_prop12 + 0:10 1:10 2:10 3:10 4:10 + 5:10 ! telephone character must be the same as # (35) + 6:10 + 7:10 ! non-breaking hyphen must be the same as hyphen (45) + 8:10 + 9:10 ! tab must be the same as space (32) + 10:10 11:10 12:10 13:10 + 14:10 ! potential hyphen must be the same as hyphen (45) + 15:10 ! non-breaking space must be the same as space (32) + 16:10 + 17:10 18:10 19:10 20:10 21:10 22:10 23:10 24:10 + 25:10 26:10 27:10 28:10 29:10 30:10 31:14 32:10 + 33:10 34:10 35:10 36:10 37:10 38:12 39:6 40:10 + 41:10 42:10 43:10 44:10 45:10 46:10 47:10 48:10 + 49:10 50:10 51:10 52:10 53:10 54:10 55:10 56:10 + 57:10 58:10 59:10 60:10 61:10 62:10 63:10 64:10 + 65:14 66:14 67:14 68:14 69:12 70:12 71:14 72:14 + 73:8 74:10 75:14 76:12 77:14 78:14 79:14 80:12 + 81:14 82:14 83:12 84:14 85:14 86:14 87:14 88:14 + 89:14 90:12 91:10 92:10 93:10 94:10 95:10 96:10 + 97:10 98:12 99:10 100:12 101:10 102:8 103:12 104:12 + 105:6 106:6 107:12 108:6 109:14 110:12 111:10 112:12 + 113:12 114:10 115:10 116:8 117:12 118:12 119:14 120:12 + 121:12 122:10 123:10 124:10 125:10 126:10 127:10 128:14 + 129:12 130:10 131:10 132:10 133:10 134:10 135:10 136:10 + 137:10 138:10 139:6 140:6 141:6 142:14 143:14 144:12 + 145:14 146:14 147:10 148:10 149:10 150:12 151:12 152:12 + 153:14 154:14 155:10 156:10 157:14 158:10 159:10 160:10 + 161:6 162:10 163:12 164:12 165:14 166:10 167:10 168:10 + 169:10 170:10 171:10 172:10 173:10 174:14 175:14 176:10 + 177:10 178:10 179:10 180:10 181:14 182:14 183:14 184:10 + 185:10 186:10 187:10 188:10 189:10 190:10 191:10 192:10 + 193:10 194:10 195:10 196:10 197:10 198:10 199:14 200:10 + 201:10 202:10 203:10 204:10 205:10 206:10 207:10 208:12 + 209:14 210:12 211:12 212:12 213:6 214:8 215:8 216:8 + 217:10 218:10 219:10 220:10 221:10 222:8 223:10 224:14 + 225:12 226:14 227:14 228:10 229:14 230:10 231:12 232:14 + 233:14 234:14 235:14 236:12 237:14 238:10 239:10 240:10 + 241:10 242:10 243:10 244:10 245:10 246:10 247:10 248:10 + 249:10 250:10 251:10 252:10 253:10 254:10 255:10 +END_WIDTHS + +TYPEFACE pica + NAME "Pica" + SERIF + TYPE COURIER + TRANSLATE telephone + FONT + HEIGHT 200 ! 10 point + WIDTH 7 ! 17 cpi + WIDTH_BOLD 12 ! 10 cpi + WIDTH_ITALIC 7 + WIDTH_BOLD_ITALIC 12 + ! I<18> 17 cpi [@400<17><1> single height and width + COMMAND "<27>I<18><27>[@<4><0><0><0><17><1>" + FONT + HEIGHT 240 ! 12 point + WIDTH 12 ! 10 cpi + ! I<2> 10 cpi [@400<17><1> single height and width + COMMAND "<27>I<2><27>[@<4><0><0><0><17><1>" + FONT + HEIGHT 260 ! 13 point + WIDTH 14 ! 8.5 cpi + WIDTH_BOLD 24 ! 5 cpi + WIDTH_ITALIC 14 + WIDTH_BOLD_ITALIC 24 + ! I<18> 17 cpi [@400<17><2> single height and double width + COMMAND "<27>I<18><27>[@<4><0><0><0><17><2>" + FONT + HEIGHT 320 ! 16 point + WIDTH 24 ! 5 cpi + ! I<2> 10 cpi [@400<17><2> single height and double width + COMMAND "<27>I<2><27>[@<4><0><0><0><17><2>" + FONT + HEIGHT 440 ! 22 point + WIDTH 12 ! 10 cpi + ! I<2> 10 cpi [@400<18><1> double height and single width + COMMAND "<27>I<2><27>[@<4><0><0><0><18><1>" + FONT + HEIGHT 480 ! 24 point + WIDTH 24 ! 5 cpi + ! I<2> 10 cpi [@400<18><2> double height and double width + COMMAND "<27>I<2><27>[@<4><0><0><0><18><2>" + END_FONT +END_TYPEFACE + +TYPEFACE elite + NAME "Elite" + SERIF + TYPE ELITE + TRANSLATE telephone + FONT + HEIGHT 200 ! 10 point + WIDTH 10 + ! I<10> 12 cpi [@400<17><1> single height and width + COMMAND "<27>I<10><27>[@<4><0><0><0><17><1>" + FONT + HEIGHT 280 + WIDTH 20 + ! I<10> 12 cpi [@400<17><2> single height and double width + COMMAND "<27>I<10><27>[@<4><0><0><0><17><2>" + FONT + HEIGHT 360 + WIDTH 10 + ! I<10> 12 cpi [@400<18><1> double height and single width + COMMAND "<27>I<10><27>[@<4><0><0><0><18><1>" + FONT + HEIGHT 400 + WIDTH 20 + ! I<10> 12 cpi [@400<18><2> double height and double width + COMMAND "<27>I<10><27>[@<4><0><0><0><18><2>" + END_FONT +END_TYPEFACE + +TYPEFACE proportional + NAME "Proportional" + MULTIPLE_WIDTH_TABLES + PROPORTIONAL + SERIF + TYPE TIMES_ROMAN + TRANSLATE telephone + FONT + HEIGHT 240 + WIDTH wid_prop12 + ! P<1> proportional [@400<17><1> single height and width + COMMAND "<27>P<1><27>[@<4><0><0><0><17><1>" + FONT + HEIGHT 320 + WIDTH_SCALE 2 + WIDTH wid_prop12 + ! P<1> proportional [@400<17><2> single height and double width + COMMAND "<27>P<1><27>[@<4><0><0><0><17><2>" + FONT + HEIGHT 440 + WIDTH wid_prop12 + ! P<1> proportional [@400<18><1> double height and single width + COMMAND "<27>P<1><27>[@<4><0><0><0><18><1>" + FONT + HEIGHT 480 + WIDTH_SCALE 2 + WIDTH wid_prop12 + ! P<1> proportional [@400<18><2> double height and double width + COMMAND "<27>P<1><27>[@<4><0><0><0><18><2>" + END_FONT +END_TYPEFACE + +MODEL + NAME "Canon BJ-10e" + NAME "IBM Proprinter X24E" + MIN_X 12 ! 12 twips = 1/120 inch + MIN_Y 20 ! 20 twips = 1/72 inch + SKIP_X 8 ! 1/15 inch + SKIP_Y 18 ! 1/4 inch + TYPEFACE pica,elite,proportional +END_MODEL + +MODEL + NAME "Canon BJ-30" + MIN_X 12 ! 12 twips = 1/120 in + MIN_Y 20 ! 20 twips = 1/72 in + SKIP_X 8 ! skipx 1/15 inch + SKIP_Y 18 ! skipy 1/4 + TYPEFACE pica,proportional +END_MODEL diff --git a/code/SIBOSDK/wd/epson.wd b/code/SIBOSDK/wd/epson.wd new file mode 100644 index 0000000..6871417 --- /dev/null +++ b/code/SIBOSDK/wd/epson.wd @@ -0,0 +1,252 @@ +! EPSON.WD +! Printer driver file for EPSON RX & LQ printers + +COMMANDS + RESET "<27>@" + FORM_LENGTH "<27>C%c" +! <27>A<1> 1/60 inch line spacing or 1/72 for RX +! <27>l<0> left margin to zero +! <27>N<0> no bottom margin + PREAMBLE "<27>A<1><27>l<0><27>N<0>" + POSTAMBLE "<13><27>@" + BOLD_ON "<27>G" + BOLD_OFF "<27>H" + ITALIC_ON "<27>4" + ITALIC_OFF "<27>5" + UNDERLINE_ON "<27>-<1>" + UNDERLINE_OFF "<27>-<0>" + SUBSCRIPT_ON "<27>S<1>" + SUBSCRIPT_OFF "<27>T" + SUPERSCRIPT_ON "<27>S<0>" + SUPERSCRIPT_OFF "<27>T" + NEW_PAGE "<12>" + CARRIAGE_RETURN "<13>" + MOVE_DOWN "*<10>" + MOVE_RIGHT_PREFIX "<27>Y%w" ! number of bit image data + MOVE_RIGHT "*<0>" ! zero bit image + MOVE_RIGHT_SUFFIX "" +END_COMMANDS + +TRANSLATES translate + 5:35 +END_TRANSLATES + +WIDTHS prop + 0:5 1:5 2:5 3:5 4:5 + 5:5 ! telephone character must be the same as # (35) + 6:5 + 7:5 ! non-breaking hyphen must be the same as hyphen (45) + 8:5 + 9:5 ! tab must be the same as space (32) + 10:5 11:5 12:5 13:5 + 14:5 ! potential hyphen must be the same as hyphen (45) + 15:5 ! non-breaking space must be the same as space (32) + 16:5 + 17:5 18:5 19:5 20:5 21:5 22:5 23:5 24:5 + 25:5 26:5 27:5 28:5 29:5 30:5 31:5 32:5 + 33:3 34:5 35:5 36:5 37:6 38:6 39:3 40:4 + 41:4 42:5 43:5 44:3 45:5 46:3 47:5 48:5 + 49:5 50:5 51:5 52:5 53:5 54:5 55:5 56:5 + 57:5 58:3 59:3 60:5 61:5 62:5 63:5 64:6 + 65:6 66:6 67:6 68:6 69:6 70:6 71:6 72:6 + 73:4 74:5 75:6 76:6 77:7 78:6 79:6 80:6 + 81:6 82:6 83:6 84:6 85:7 86:6 87:7 88:6 + 89:6 90:5 91:4 92:5 93:4 94:5 95:5 96:3 + 97:5 98:6 99:5 100:6 101:5 102:4 103:6 104:6 + 105:3 106:4 107:6 108:3 109:7 110:6 111:5 112:6 + 113:6 114:5 115:5 116:4 117:6 118:6 119:7 120:5 + 121:6 122:5 123:4 124:3 125:4 126:5 127:6 + 128:6 + 129:6 130:5 131:5 132:5 133:5 134:5 135:5 136:5 + 137:5 138:5 139:3 140:3 141:3 142:6 143:6 144:6 + 145:7 146:7 147:5 148:5 149:5 150:6 151:6 152:6 + 153:6 154:7 155:5 156:5 157:6 158:5 159:5 160:5 + 161:3 162:5 163:6 164:6 165:6 166:5 167:5 168:5 + 169:6 170:5 171:5 172:5 173:5 174:5 175:5 176:5 + 177:5 178:5 179:5 180:5 181:6 182:6 183:6 184:6 + 185:5 186:5 187:5 188:5 189:5 190:6 191:5 192:5 + 193:5 194:5 195:5 196:5 197:5 198:5 199:6 200:5 + 201:5 202:5 203:5 204:5 205:5 206:5 207:5 208:6 + 209:6 210:6 211:6 212:6 213:3 214:4 215:4 216:4 + 217:5 218:5 219:5 220:5 221:3 222:4 223:5 224:6 + 225:5 226:6 227:6 228:5 229:6 230:5 231:6 232:6 + 233:7 234:7 235:7 236:6 237:6 238:5 239:3 240:5 + 241:5 242:5 243:5 244:5 245:5 246:5 247:5 248:5 + 249:5 250:5 251:4 252:4 253:5 254:5 255:5 +END_WIDTHS + +TYPEFACE pica_rx + NAME "Pica" + TYPE COURIER + TRANSLATE translate +! rx_pica_cond="<27>p<0><27>P<27><15><27>W<0>" +! rx_pica_cond_enlg="<27>p<0><27>P<27><15><27>W<1>" + FONT + HEIGHT 240 ! 12 point + WIDTH 12 ! 10 cpi + ! rx_pica + COMMAND "<27>p<0><27>P<27><18><27>W<0>" + END_FONT + FONT + HEIGHT 320 ! 16 point + WIDTH 24 ! 5 cpi + ! rx_pica_enlg + COMMAND "<27>p<0><27>P<27><18><27>W<1>" + END_FONT +END_TYPEFACE + +TYPEFACE elite_rx + NAME "Elite" + TYPE ELITE + TRANSLATE translate + FONT + HEIGHT 200 ! 10 point + WIDTH 10 ! 12 cpi + ! rx_elite + COMMAND "<27>p<0><27>M<27><18><27>W<0>" + END_FONT + FONT + HEIGHT 280 ! 14 point + WIDTH 20 ! 6 cpi + ! rx_elite_enlg + COMMAND "<27>p<0><27>M<27><18><27>W<1>" + END_FONT +END_TYPEFACE + +TYPEFACE pica + NAME "Pica" + TYPE COURIER + TRANSLATE translate +! pica_cond_enlg_doub="<27>w<1><27>k<2><27>!<36>" + FONT + HEIGHT 200 ! 10 point + WIDTH 7 ! 17 cpi + ! pica_cond + COMMAND "<27>w<0><27>k<2><27>!<4>" + FONT + HEIGHT 240 ! 12 point + WIDTH 12 ! 10 cpi + ! pica + COMMAND "<27>w<0><27>k<2><27>!<0>" + FONT + HEIGHT 260 ! 13 point + WIDTH 14 ! 8.5 cpi + ! pica_cond_enlg + COMMAND "<27>w<0><27>k<2><27>!<36>" + FONT + HEIGHT 320 ! 16 cpi + WIDTH 24 ! 5 cpi + ! pica_enlg + COMMAND "<27>w<0><27>k<2><27>!<32>" + FONT + HEIGHT 440 ! 22 point + WIDTH 12 ! 10 cpi + ! pica_doub + COMMAND "<27>w<1><27>k<2><27>!<0>" + FONT + HEIGHT 480 ! 24 point + WIDTH 24 ! 5 cpi + ! pica_enlg_doub + COMMAND "<27>w<1><27>k<2><27>!<32>" + END_FONT +END_TYPEFACE + +TYPEFACE elite + NAME "Elite" + TYPE ELITE + TRANSLATE translate +! elite_enlg="<27>w<0><27>k<2><27>!<33>" +! elite_doub="<27>w<1><27>k<2><27>!<1>" + FONT + HEIGHT 180 ! 9 point + WIDTH 6 + ! elite_cond + COMMAND "<27>w<0><27>k<2><27>!<5>" + FONT + HEIGHT 200 + WIDTH 10 + ! elite + COMMAND "<27>w<0><27>k<2><27>!<1>" + FONT + HEIGHT 240 + WIDTH 12 + ! elite_cond_enlg + COMMAND "<27>w<0><27>k<2><27>!<37>" + FONT + HEIGHT 380 + WIDTH 12 + ! elite_cond_enlg_doub + COMMAND "<27>w<1><27>k<2><27>!<37>" + FONT + HEIGHT 400 + WIDTH 20 + ! elite_enlg_doub + COMMAND "<27>w<1><27>k<2><27>!<33>" + END_FONT +END_TYPEFACE + +TYPEFACE times + NAME "Times" + PROPORTIONAL + SERIF + TYPE TIMES_ROMAN + TRANSLATE translate + FONT + HEIGHT 200 + WIDTH prop + ! times_cond + COMMAND "<27>w<0><27>k<0><27>!<6>" + END_FONT + FONT + HEIGHT 240 + WIDTH_SCALE 2 + WIDTH prop + ! times + COMMAND "<27>w<0><27>k<0><27>!<2>" + END_FONT + FONT + HEIGHT 320 + WIDTH_SCALE 4 + WIDTH prop + ! times_enlg + COMMAND "<27>w<0><27>k<0><27>!<34>" + END_FONT + FONT + HEIGHT 440 + WIDTH_SCALE 2 + WIDTH prop + ! times_doub + COMMAND "<27>w<1><27>k<0><27>!<2>" + END_FONT + FONT + HEIGHT 480 + WIDTH_SCALE 4 + WIDTH prop + ! times_enlg_doub + COMMAND "<27>w<1><27>k<0><27>!<34>" + END_FONT +END_TYPEFACE + +! helvetica="<27>w<0><27>k<2><27>!<2>" +! helvetica_cond="<27>w<0><27>k<2><27>!<6>" +! helvetica_enlg="<27>w<0><27>k<2><27>!<34>" +! helvetica_doub="<27>w<1><27>k<2><27>!<2>" +! helvetica_enlg_doub="<27>w<1><27>k<2><27>!<34>" + +MODEL + NAME "Epson RX" + MIN_X 12 ! 12 TWIPS 1/120 in + MIN_Y 20 ! 20 TWIPS 1/72 in + SKIP_X 15 ! SKIPX 1/8 INCH + SKIP_Y 30 ! SKIPY 1/2 INCH + TYPEFACE pica_rx,elite_rx +END_MODEL + +MODEL + NAME "Epson LQ" + MIN_X 12 ! 12 TWIPS 1/120 in + MIN_Y 24 ! 24 TWIPS 1/60 in + SKIP_X 15 ! SKIPX 1/8 INCH + SKIP_Y 30 ! SKIPY 1/2 INCH + TYPEFACE pica,elite,times +END_MODEL diff --git a/code/SIBOSDK/wd/general.wd b/code/SIBOSDK/wd/general.wd new file mode 100644 index 0000000..dcc5f68 --- /dev/null +++ b/code/SIBOSDK/wd/general.wd @@ -0,0 +1,49 @@ +! GENERAL.WD +! General printer driver file, supports minimal TTY functionality + +COMMANDS + RESET "" + FORM_LENGTH "" + PREAMBLE "" + POSTAMBLE "" + BOLD_ON "" + BOLD_OFF "" + ITALIC_ON "" + ITALIC_OFF "" + UNDERLINE_ON "" + UNDERLINE_OFF "" + SUBSCRIPT_ON "" + SUBSCRIPT_OFF "" + SUPERSCRIPT_ON "" + SUPERSCRIPT_OFF "" + MOVE_DOWN "*<10>" + MOVE_RIGHT_PREFIX "" + MOVE_RIGHT "*<32>" + MOVE_RIGHT_SUFFIX "" + NEW_PAGE "<12>" + CARRIAGE_RETURN "<13>" +END_COMMANDS + +TRANSLATES telephone + 5:35 +END_TRANSLATES + +TYPEFACE courier + NAME "Mono" + TYPE COURIER + TRANSLATE telephone + FONT + HEIGHT 240 + WIDTH 1 + COMMAND "" + END_FONT +END_TYPEFACE + +MODEL + NAME "$" + MIN_X 144 ! 144 twips = 1/10 in, one character + MIN_Y 240 ! 240 twips = 1/6 in, one line + SKIP_X 0 + SKIP_Y 0 + TYPEFACE courier +END_MODEL diff --git a/code/SIBOSDK/wd/hp2.wd b/code/SIBOSDK/wd/hp2.wd new file mode 100644 index 0000000..b863983 --- /dev/null +++ b/code/SIBOSDK/wd/hp2.wd @@ -0,0 +1,166 @@ +! HP2.WD +! Printer driver file for HP II laser printers + +COMMANDS + HP_PCL_COMPATIBLE + RESET "<27>E" + FORM_LENGTH "<27>&l%dP" +!<27>&l +! 0o - Portrait +! 0e - top margin to zero +! 0C - VMI to zero +!<27>9 - clear horizontal margins +!<27>(8U - ASCII Roman-8 symbol set + PREAMBLE "<27>&l0o0e0C<27>9<27>(8U" + POSTAMBLE "<27>E" + BOLD_ON "<27>(s3B" + BOLD_OFF "<27>(s0B" + ITALIC_ON "<27>(s1S" + ITALIC_OFF "<27>(s0S" + UNDERLINE_ON "<27>&dD" + UNDERLINE_OFF "<27>&d@" + SUPERSCRIPT_ON "<27>&a-60V" + SUPERSCRIPT_OFF "<27>&a+60V" + SUBSCRIPT_ON "<27>&a+60V" + SUBSCRIPT_OFF "<27>&a-60V" + NEW_PAGE "<12>" + CARRIAGE_RETURN "<13>" + MOVE_DOWN "<27>&a+%dV" + MOVE_RIGHT_PREFIX "" + MOVE_RIGHT "<27>&a+%dH" + MOVE_RIGHT_SUFFIX "" + LANDSCAPE "<27>&l1o0E<27>9" +END_COMMANDS + +TRANSLATES roman8 + 5:35 + 128:180 + 129:207 + 130:197 + 131:192 + 132:204 + 133:200 + 134:212 + 135:181 + 136:193 + 137:205 + 138:201 + 139:221 + 140:209 + 141:217 + 142:216 + 143:208 + 144:220 + 145:215 + 146:211 + 147:194 + 148:206 + 149:202 + 150:195 + 151:203 + 152:239 + 153:218 + 154:219 + 155:214 + 156:187 + 157:210 + 158:120 + 159:190 + 160:196 + 161:213 + 162:198 + 163:199 + 164:183 + 165:182 + 166:249 + 167:250 + 168:185 + 169:82 + 171:248 + 172:247 + 173:184 + 174:251 + 175:253 + 181:224 + 182:162 + 183:161 + 184:67 + 189:191 + 190:188 + 198:226 + 199:225 + 207:186 + 208:228 + 209:227 + 210:164 + 211:165 + 212:163 + 213:108 + 214:229 + 215:166 + 216:167 + 219:252 + 221:124 + 222:230 + 224:231 + 225:222 + 226:223 + 227:232 + 228:234 + 229:233 + 230:243 + 231:241 + 232:240 + 233:237 + 234:174 + 235:173 + 236:178 + 237:177 + 238:176 + 239:168 + 240:45 + 241:254 + 242:61 + 243:245 + 245:189 + 248:179 + 249:171 + 250:242 + 251:49 + 252:51 + 253:50 + 254:242 +END_TRANSLATES + +TYPEFACE lineprinter + NAME "Lineprinter" + TYPE LINEPRINTER + TRANSLATE roman8 + FONT + HEIGHT 170 + WIDTH 43 + COMMAND "<27>(s0p16.67h8.5v0T" + END_FONT +END_TYPEFACE + +TYPEFACE courier + NAME "Courier" + SERIF + TYPE COURIER + TRANSLATE roman8 + FONT + HEIGHT 240 + WIDTH 72 + COMMAND "<27>(s0p10h12v3T" + END_FONT +END_TYPEFACE + +MODEL + NAME "HP LaserJet series II" + LANDSCAPE_AVAILABLE + MIN_X 2 ! twips + MIN_Y 2 ! twips + SKIP_X 180 + SKIP_Y 0 + TYPEFACE courier,lineprinter +END_MODEL diff --git a/code/SIBOSDK/wd/hp2p.wd b/code/SIBOSDK/wd/hp2p.wd new file mode 100644 index 0000000..6ec762a --- /dev/null +++ b/code/SIBOSDK/wd/hp2p.wd @@ -0,0 +1,75 @@ +! HP2P.WD +! Printer driver file for HP IIP and IID laser printers + +COMMANDS + HP_PCL_COMPATIBLE + RESET "<27>E" + FORM_LENGTH "<27>&l%dP" +!<27>&l +! 0o - Portrait +! 0e - top margin to zero +! 0C - VMI to zero +!<27>9 - clear horizontal margins +!<27>(12U - code page 850 character set + PREAMBLE "<27>&l0o0e0C<27>9<27>(12U" + POSTAMBLE "<27>E" + BOLD_ON "<27>(s3B" + BOLD_OFF "<27>(s0B" + ITALIC_ON "<27>(s1S" + ITALIC_OFF "<27>(s0S" + UNDERLINE_ON "<27>&dD" + UNDERLINE_OFF "<27>&d@" + SUPERSCRIPT_ON "<27>&a-60V" + SUPERSCRIPT_OFF "<27>&a+60V" + SUBSCRIPT_ON "<27>&a+60V" + SUBSCRIPT_OFF "<27>&a-60V" + NEW_PAGE "<12>" + CARRIAGE_RETURN "<13>" + MOVE_DOWN "<27>&a+%dV" + MOVE_RIGHT_PREFIX "" + MOVE_RIGHT "<27>&a+%dH" + MOVE_RIGHT_SUFFIX "" + LANDSCAPE "<27>&l1o0E<27>9" +END_COMMANDS + +TRANSLATES telephone + 5:35 +END_TRANSLATES + +TYPEFACE lineprinter + NAME "Lineprinter" + TYPE LINEPRINTER + TRANSLATE telephone + FONT + HEIGHT 170 + WIDTH 43 + COMMAND "<27>(s0p16.67h8.5v0T" + END_FONT +END_TYPEFACE + +TYPEFACE courier + NAME "Courier" + SERIF + TYPE COURIER + TRANSLATE telephone + FONT + HEIGHT 200 + WIDTH 60 + COMMAND "<27>(s0p12h10v3T" + FONT + HEIGHT 240 + WIDTH 72 + COMMAND "<27>(s0p10h12v3T" + END_FONT +END_TYPEFACE + +MODEL + NAME "HP LaserJet IID" + NAME "HP LaserJet IIP" + LANDSCAPE_AVAILABLE + MIN_X 2 ! twips + MIN_Y 2 ! twips + SKIP_X 180 + SKIP_Y 0 + TYPEFACE courier,lineprinter +END_MODEL diff --git a/code/SIBOSDK/wd/hp3.wd b/code/SIBOSDK/wd/hp3.wd new file mode 100644 index 0000000..7609ead --- /dev/null +++ b/code/SIBOSDK/wd/hp3.wd @@ -0,0 +1,470 @@ +! HP3.WD +! Printer driver file for HP laser printers + +COMMANDS commands + HP_PCL_COMPATIBLE + RESET "<27>E" + FORM_LENGTH "<27>&l%dP" +!<27>&l +! 0o - Portrait +! 0e - top margin to zero +! 0C - VMI to zero +!<27>9 - clear horizontal margins +!<27>(12U - code page 850 character set + PREAMBLE "<27>&l0o0e0C<27>9<27>(12U" + POSTAMBLE "<27>E" + BOLD_ON "<27>(s3B" + BOLD_OFF "<27>(s0B" + ITALIC_ON "<27>(s1S" + ITALIC_OFF "<27>(s0S" + UNDERLINE_ON "<27>&d0D" + UNDERLINE_OFF "<27>&d@" + SUPERSCRIPT_ON "<27>&a-60V" + SUPERSCRIPT_OFF "<27>&a+60V" + SUBSCRIPT_ON "<27>&a+60V" + SUBSCRIPT_OFF "<27>&a-60V" + NEW_PAGE "<12>" + CARRIAGE_RETURN "<13>" + MOVE_DOWN "<27>&a+%dV" + MOVE_RIGHT_PREFIX "" + MOVE_RIGHT "<27>*p+%dX" + MOVE_RIGHT_SUFFIX "" + LANDSCAPE "<27>&l1o0E<27>9" +END_COMMANDS + +TRANSLATES telephone + 5:35 ! must ensure width of 5 = width of 35 +END_TRANSLATES + +WIDTHS cgtimes_std + 0:207 1:207 2:207 3:207 4:207 + 5:104 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:61 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:61 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:108 20:104 21:104 22:207 23:150 24:150 + 25:150 26:150 27:150 28:184 29:150 30:150 31:150 32:61 + 33:69 34:96 35:104 36:104 37:184 38:161 39:69 40:69 + 41:69 42:104 43:184 44:69 45:69 46:69 47:69 48:104 + 49:104 50:104 51:104 52:104 53:104 54:104 55:104 56:104 + 57:104 58:69 59:69 60:207 61:184 62:207 63:92 64:184 +! A B C D E F G H + 65:150 66:131 67:142 68:154 69:131 70:123 71:150 72:154 +! I J K L M N O P + 73:69 74:81 75:146 76:131 77:188 78:154 79:150 80:119 +! Q R S T U V W X + 81:150 82:138 83:111 84:131 85:154 86:150 87:196 88:150 +! Y Z + 89:150 90:134 91:69 92:69 93:69 94:104 95:104 96:104 +! a b c d e f g h + 97:92 98:104 99:92 100:104 101:92 102:69 103:104 104:104 +! i j k l m n o p + 105:58 106:58 107:104 108:58 109:161 110:104 111:104 112:104 +! q r s t u v w x + 113:104 114:77 115:81 116:58 117:104 118:104 119:150 120:104 +! y z + 121:104 122:92 123:92 124:104 125:92 126:104 127:207 128:142 + 129:104 130:92 131:92 132:92 133:92 134:92 135:92 136:92 + 137:92 138:92 139:58 140:58 141:58 142:150 143:150 144:131 + 145:138 146:184 147:104 148:104 149:104 150:104 151:104 152:104 + 153:150 154:154 155:104 156:104 157:154 158:182 159:104 160:92 + 161:58 162:104 163:104 164:104 165:154 166:104 167:104 168:92 + 169:104 170:184 171:184 172:184 173:69 174:85 175:85 176:207 + 177:207 178:207 179:207 180:207 181:150 182:150 183:150 184:105 + 185:207 186:207 187:207 188:207 189:105 190:104 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:92 199:150 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:104 208:104 + 209:154 210:129 211:129 212:129 213:58 214:70 215:70 216:70 + 217:207 218:207 219:207 220:207 221:104 222:70 223:207 224:152 + 225:104 226:152 227:152 228:104 229:152 230:115 231:106 232:122 + 233:154 234:154 235:154 236:104 237:150 238:105 239:104 240:72 + 241:184 242:104 243:183 244:104 245:104 246:184 247:104 248:104 + 249:104 250:1 251:73 252:73 253:73 254:104 255:104 +END_WIDTHS + +WIDTHS cgtimes_italic + 0:207 + 1:207 2:207 3:207 4:207 + 5:104 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:61 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:61 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:103 20:104 21:104 22:207 23:150 24:150 + 25:150 26:150 27:150 28:184 29:150 30:150 31:150 32:61 + 33:69 34:100 35:104 36:104 37:184 38:161 39:69 40:69 + 41:69 42:104 43:184 44:69 45:69 46:69 47:69 48:104 + 49:104 50:104 51:104 52:104 53:104 54:104 55:104 56:104 + 57:104 58:69 59:69 60:207 61:184 62:207 63:104 64:184 + 65:127 66:127 67:138 68:150 69:127 70:119 71:150 72:150 + 73:69 74:92 75:138 76:115 77:170 78:138 79:150 80:127 + 81:150 82:127 83:104 84:115 85:150 86:127 87:170 88:127 + 89:115 90:115 91:69 92:69 93:69 94:104 95:104 96:104 + 97:104 98:104 99:92 100:104 101:92 102:58 103:104 104:104 + 105:58 106:58 107:92 108:58 109:150 110:104 111:104 112:104 + 113:104 114:81 115:81 116:58 117:104 118:92 119:138 120:92 + 121:92 122:81 123:92 124:104 125:92 126:104 127:207 128:138 + 129:104 130:92 131:104 132:104 133:104 134:104 135:92 136:92 + 137:92 138:92 139:58 140:58 141:58 142:127 143:127 144:127 + 145:138 146:184 147:104 148:104 149:104 150:104 151:104 152:92 + 153:150 154:150 155:104 156:104 157:151 158:183 159:104 160:104 + 161:58 162:104 163:104 164:104 165:138 166:104 167:104 168:104 + 169:104 170:184 171:184 172:184 173:69 174:96 175:96 176:207 + 177:207 178:207 179:207 180:207 181:127 182:127 183:127 184:105 + 185:207 186:207 187:207 188:207 189:105 190:105 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:104 199:127 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:104 208:104 + 209:148 210:127 211:127 212:127 213:58 214:70 215:70 216:70 + 217:207 218:207 219:207 220:207 221:104 222:70 223:207 224:152 + 225:104 226:152 227:152 228:104 229:152 230:115 231:106 232:126 + 233:150 234:150 235:150 236:92 237:115 238:105 239:104 240:72 + 241:184 242:104 243:182 244:104 245:104 246:184 247:104 248:104 + 249:104 250:2 251:73 252:73 253:73 254:104 255:104 +END_WIDTHS + +WIDTHS cgtimes_bold + 0:207 + 1:207 2:207 3:207 4:207 + 5:104 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:61 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:61 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:119 20:104 21:104 22:207 23:150 24:150 + 25:150 26:150 27:150 28:184 29:150 30:150 31:150 32:61 + 33:69 34:96 35:104 36:104 37:184 38:169 39:69 40:69 + 41:69 42:104 43:184 44:69 45:69 46:69 47:69 48:104 + 49:104 50:104 51:104 52:104 53:104 54:104 55:104 56:104 + 57:104 58:69 59:69 60:207 61:184 62:207 63:104 64:184 + 65:150 66:138 67:150 68:150 69:138 70:127 71:161 72:161 + 73:81 74:100 75:161 76:138 77:196 78:150 79:161 80:127 + 81:161 82:150 83:115 84:138 85:150 86:150 87:207 88:150 + 89:150 90:138 91:69 92:69 93:69 94:104 95:104 96:104 + 97:104 98:115 99:92 100:115 101:92 102:73 103:104 104:115 + 105:58 106:69 107:115 108:58 109:171 110:115 111:104 112:115 + 113:115 114:92 115:81 116:69 117:115 118:104 119:150 120:104 + 121:104 122:92 123:104 124:104 125:104 126:104 127:207 128:150 + 129:115 130:92 131:104 132:104 133:104 134:104 135:92 136:92 + 137:92 138:92 139:58 140:58 141:58 142:150 143:150 144:138 + 145:150 146:215 147:104 148:104 149:104 150:115 151:115 152:104 + 153:161 154:150 155:104 156:104 157:163 158:182 159:104 160:104 + 161:58 162:104 163:115 164:115 165:150 166:104 167:104 168:104 + 169:104 170:184 171:184 172:184 173:69 174:88 175:88 176:207 + 177:207 178:207 179:207 180:207 181:150 182:150 183:150 184:105 + 185:207 186:207 187:207 188:207 189:105 190:104 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:104 199:150 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:104 208:104 + 209:148 210:137 211:137 212:137 213:58 214:80 215:80 216:80 + 217:207 218:207 219:207 220:207 221:104 222:80 223:207 224:162 + 225:115 226:162 227:162 228:104 229:162 230:115 231:116 232:126 + 233:150 234:150 235:150 236:104 237:150 238:105 239:104 240:72 + 241:184 242:104 243:183 244:104 245:104 246:184 247:104 248:104 + 249:104 250:23 251:73 252:73 253:73 254:104 255:104 +END_WIDTHS + +WIDTHS cgtimes_bold_italic + 0:207 + 1:207 2:207 3:207 4:207 + 5:104 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:61 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:61 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:131 20:104 21:104 22:207 23:150 24:150 + 25:150 26:150 27:150 28:184 29:150 30:150 31:150 32:61 + 33:81 34:108 35:104 36:104 37:184 38:161 39:69 40:69 + 41:69 42:104 43:184 44:69 45:69 46:69 47:69 48:104 + 49:104 50:104 51:104 52:104 53:104 54:104 55:104 56:104 + 57:104 58:69 59:69 60:207 61:184 62:207 63:104 64:184 + 65:138 66:138 67:138 68:150 69:138 70:127 71:150 72:161 + 73:81 74:104 75:138 76:127 77:184 78:150 79:150 80:127 + 81:146 82:138 83:115 84:127 85:150 86:138 87:184 88:138 + 89:127 90:127 91:69 92:69 93:69 94:104 95:104 96:104 + 97:104 98:104 99:92 100:104 101:92 102:73 103:104 104:115 + 105:58 106:58 107:104 108:58 109:161 110:115 111:104 112:104 + 113:104 114:81 115:81 116:58 117:115 118:92 119:138 120:104 + 121:92 122:81 123:104 124:104 125:104 126:104 127:207 128:138 + 129:115 130:92 131:104 132:104 133:104 134:104 135:92 136:92 + 137:92 138:92 139:58 140:58 141:58 142:138 143:138 144:138 + 145:146 146:192 147:104 148:104 149:104 150:115 151:115 152:92 + 153:150 154:150 155:104 156:104 157:151 158:184 159:104 160:104 + 161:58 162:104 163:115 164:115 165:150 166:104 167:104 168:104 + 169:104 170:184 171:184 172:184 173:81 174:92 175:92 176:207 + 177:207 178:207 179:207 180:207 181:138 182:138 183:138 184:105 + 185:207 186:207 187:207 188:207 189:105 190:105 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:104 199:138 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:104 208:104 + 209:148 210:137 211:137 212:137 213:58 214:80 215:80 216:80 + 217:207 218:207 219:207 220:207 221:104 222:80 223:207 224:152 + 225:104 226:152 227:152 228:104 229:152 230:115 231:106 232:126 + 233:150 234:150 235:150 236:90 237:127 238:105 239:104 240:72 + 241:184 242:104 243:183 244:104 245:104 246:184 247:104 248:104 + 249:104 250:18 251:69 252:69 253:69 254:104 255:104 +END_WIDTHS + +WIDTHS univers_std + 0:207 1:207 2:207 3:207 4:207 + 5:131 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:69 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:69 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:110 20:131 21:131 22:207 23:150 24:150 + 25:150 26:150 27:150 28:207 29:150 30:150 31:150 32:69 + 33:69 34:104 35:131 36:131 37:207 38:158 39:69 40:69 + 41:69 42:131 43:207 44:69 45:69 46:69 47:69 48:131 + 49:131 50:131 51:131 52:131 53:131 54:131 55:131 56:131 + 57:131 58:69 59:69 60:207 61:207 62:207 63:108 64:207 + 65:154 66:131 67:146 68:150 69:119 70:115 71:154 72:150 + 73:58 74:115 75:138 76:111 77:188 78:150 79:158 80:123 + 81:161 82:134 83:134 84:131 85:150 86:150 87:207 88:150 + 89:142 90:127 91:69 92:69 93:69 94:131 95:104 96:131 + 97:111 98:119 99:111 100:119 101:111 102:77 103:119 104:119 + 105:50 106:50 107:111 108:50 109:181 110:119 111:119 112:119 + 113:119 114:73 115:104 116:77 117:119 118:115 119:181 120:115 + 121:115 122:100 123:92 124:104 125:92 126:131 127:207 128:146 + 129:119 130:111 131:111 132:111 133:111 134:111 135:111 136:111 + 137:111 138:111 139:50 140:50 141:50 142:154 143:154 144:119 + 145:177 146:204 147:119 148:119 149:119 150:119 151:119 152:115 + 153:158 154:150 155:122 156:131 157:160 158:207 159:131 160:111 + 161:50 162:119 163:119 164:119 165:150 166:85 167:85 168:108 + 169:104 170:207 171:207 172:207 173:69 174:115 175:115 176:207 + 177:207 178:207 179:207 180:207 181:154 182:154 183:154 184:105 + 185:207 186:207 187:207 188:207 189:129 190:129 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:114 199:154 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:128 208:121 + 209:150 210:119 211:119 212:119 213:51 214:58 215:58 216:58 + 217:207 218:207 219:207 220:207 221:105 222:58 223:207 224:158 + 225:127 226:158 227:158 228:119 229:158 230:115 231:119 232:126 + 233:150 234:150 235:150 236:118 237:141 238:129 239:129 240:72 + 241:207 242:106 243:207 244:130 245:130 246:207 247:129 248:131 + 249:129 250:25 251:81 252:81 253:81 254:104 255:104 +END_WIDTHS + +WIDTHS univers_italic + 0:207 + 1:207 2:207 3:207 4:207 + 5:131 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:69 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:69 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:114 20:131 21:131 22:207 23:150 24:150 + 25:150 26:150 27:150 28:207 29:150 30:150 31:150 32:69 + 33:69 34:104 35:131 36:131 37:207 38:158 39:69 40:69 + 41:69 42:131 43:207 44:69 45:69 46:69 47:69 48:131 + 49:131 50:131 51:131 52:131 53:131 54:131 55:131 56:131 + 57:131 58:69 59:69 60:207 61:207 62:207 63:108 64:207 + 65:154 66:131 67:146 68:150 69:119 70:115 71:154 72:150 + 73:58 74:115 75:138 76:111 77:188 78:150 79:158 80:123 + 81:161 82:134 83:134 84:131 85:150 86:150 87:207 88:150 + 89:142 90:127 91:69 92:69 93:69 94:131 95:104 96:131 + 97:111 98:119 99:111 100:119 101:111 102:77 103:119 104:119 + 105:50 106:50 107:111 108:50 109:181 110:119 111:119 112:119 + 113:119 114:73 115:104 116:77 117:119 118:115 119:181 120:115 + 121:115 122:100 123:92 124:104 125:92 126:131 127:207 128:146 + 129:119 130:111 131:111 132:111 133:111 134:111 135:111 136:111 + 137:111 138:111 139:50 140:50 141:50 142:154 143:154 144:119 + 145:177 146:204 147:119 148:119 149:119 150:119 151:119 152:115 + 153:158 154:150 155:122 156:131 157:160 158:207 159:131 160:111 + 161:50 162:119 163:119 164:119 165:150 166:85 167:85 168:108 + 169:104 170:207 171:207 172:207 173:69 174:115 175:115 176:207 + 177:207 178:207 179:207 180:207 181:154 182:154 183:154 184:105 + 185:207 186:207 187:207 188:207 189:129 190:129 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:111 199:154 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:128 208:121 + 209:150 210:119 211:119 212:119 213:51 214:58 215:58 216:58 + 217:207 218:207 219:207 220:207 221:105 222:58 223:207 224:158 + 225:127 226:158 227:158 228:119 229:158 230:115 231:119 232:126 + 233:150 234:150 235:150 236:115 237:142 238:129 239:129 240:72 + 241:207 242:106 243:207 244:130 245:130 246:207 247:129 248:131 + 249:129 250:16 251:81 252:81 253:81 254:104 255:104 +END_WIDTHS + +WIDTHS univers_bold + 0:207 + 1:207 2:207 3:207 4:207 + 5:131 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:69 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:69 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:115 20:131 21:131 22:207 23:150 24:150 + 25:150 26:150 27:150 28:207 29:150 30:150 31:150 32:69 + 33:69 34:108 35:131 36:131 37:207 38:158 39:69 40:69 + 41:69 42:131 43:207 44:69 45:69 46:69 47:69 48:131 + 49:131 50:131 51:131 52:131 53:131 54:131 55:131 56:131 + 57:131 58:69 59:69 60:207 61:207 62:207 63:108 64:207 + 65:154 66:131 67:146 68:150 69:119 70:115 71:154 72:150 + 73:58 74:115 75:138 76:111 77:188 78:150 79:158 80:123 + 81:161 82:134 83:134 84:131 85:150 86:150 87:207 88:150 + 89:142 90:127 91:69 92:69 93:69 94:131 95:104 96:131 + 97:111 98:119 99:111 100:119 101:111 102:77 103:119 104:119 + 105:50 106:50 107:111 108:50 109:181 110:119 111:119 112:119 + 113:119 114:73 115:104 116:77 117:119 118:115 119:181 120:115 + 121:115 122:100 123:104 124:104 125:104 126:131 127:207 128:146 + 129:119 130:111 131:111 132:111 133:111 134:111 135:111 136:111 + 137:111 138:111 139:50 140:50 141:50 142:154 143:154 144:119 + 145:177 146:204 147:119 148:119 149:119 150:119 151:119 152:115 + 153:158 154:150 155:122 156:131 157:160 158:207 159:131 160:111 + 161:50 162:119 163:119 164:119 165:150 166:85 167:85 168:108 + 169:104 170:207 171:207 172:207 173:69 174:115 175:115 176:207 + 177:207 178:207 179:207 180:207 181:154 182:154 183:154 184:105 + 185:207 186:207 187:207 188:207 189:129 190:129 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:111 199:154 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:128 208:121 + 209:150 210:119 211:119 212:119 213:51 214:58 215:58 216:58 + 217:207 218:207 219:207 220:207 221:105 222:58 223:207 224:158 + 225:127 226:158 227:158 228:119 229:158 230:123 231:119 232:126 + 233:150 234:150 235:150 236:115 237:142 238:129 239:129 240:72 + 241:207 242:106 243:207 244:130 245:130 246:207 247:129 248:131 + 249:129 250:33 251:81 252:81 253:81 254:104 255:104 +END_WIDTHS + +WIDTHS univers_bold_italic + 0:207 + 1:207 2:207 3:207 4:207 + 5:131 ! telephone character must be the same as # (35) + 6:207 + 7:69 ! non-breaking hyphen must be the same as hyphen (45) + 8:207 + 9:69 ! tab must be the same as space (32) + 10:207 11:150 12:150 13:104 + 14:69 ! potential hyphen must be the same as hyphen (45) + 15:69 ! non-breaking space must be the same as space (32) + 16:150 + 17:150 18:150 19:125 20:131 21:131 22:207 23:150 24:150 + 25:150 26:150 27:150 28:207 29:150 30:150 31:150 32:69 + 33:69 34:111 35:131 36:131 37:207 38:158 39:69 40:69 + 41:69 42:131 43:207 44:69 45:69 46:69 47:69 48:131 + 49:131 50:131 51:131 52:131 53:131 54:131 55:131 56:131 + 57:131 58:69 59:69 60:207 61:207 62:207 63:108 64:207 + 65:154 66:131 67:146 68:150 69:119 70:115 71:154 72:150 + 73:58 74:115 75:138 76:111 77:188 78:150 79:158 80:123 + 81:161 82:134 83:134 84:131 85:150 86:150 87:207 88:150 + 89:142 90:127 91:69 92:69 93:69 94:131 95:104 96:131 + 97:111 98:119 99:111 100:119 101:111 102:77 103:119 104:119 + 105:50 106:50 107:111 108:50 109:181 110:119 111:119 112:119 + 113:119 114:73 115:104 116:77 117:119 118:115 119:181 120:115 + 121:115 122:100 123:104 124:104 125:104 126:131 127:207 128:146 + 129:119 130:111 131:111 132:111 133:111 134:111 135:111 136:111 + 137:111 138:111 139:50 140:50 141:50 142:154 143:154 144:119 + 145:177 146:204 147:119 148:119 149:119 150:119 151:119 152:115 + 153:158 154:150 155:122 156:131 157:160 158:207 159:131 160:111 + 161:50 162:119 163:119 164:119 165:150 166:85 167:85 168:108 + 169:104 170:207 171:207 172:207 173:69 174:115 175:115 176:207 + 177:207 178:207 179:207 180:207 181:154 182:154 183:154 184:105 + 185:207 186:207 187:207 188:207 189:129 190:129 191:207 192:207 + 193:207 194:207 195:207 196:207 197:207 198:111 199:154 200:207 + 201:207 202:207 203:207 204:207 205:207 206:207 207:128 208:121 + 209:150 210:119 211:119 212:119 213:51 214:58 215:58 216:58 + 217:207 218:207 219:207 220:207 221:105 222:58 223:207 224:158 + 225:127 226:158 227:158 228:119 229:158 230:123 231:119 232:126 + 233:150 234:150 235:150 236:115 237:142 238:129 239:129 240:72 + 241:207 242:106 243:207 244:130 245:130 246:207 247:129 248:131 + 249:129 250:37 251:81 252:81 253:81 254:104 255:104 +END_WIDTHS + +TYPEFACE courier + NAME "Courier" + TYPE COURIER + SERIF + TRANSLATE telephone + FONT + HEIGHT 200 + WIDTH 25 + COMMAND "<27>(s0p12h10v3T" + FONT + HEIGHT 240 + WIDTH 30 + COMMAND "<27>(s0p10h12v3T" + END_FONT +END_TYPEFACE + +TYPEFACE lineprinter + NAME "Lineprinter" + TYPE LINEPRINTER + TRANSLATE telephone + FONT + HEIGHT 170 + WIDTH 18 + COMMAND "<27>(s0p16.67h8.5v0T" + END_FONT +END_TYPEFACE + +TYPEFACE cgtimes + NAME "CG Times" + PROPORTIONAL + SCALED + SERIF + TYPE TIMES_ROMAN + TRANSLATE telephone + FONT + HEIGHT 80 ! min font height 80 twips = 4 point + HEIGHT_MAX 1200 ! max font height 1200 twips ( = 60 point) + HEIGHT_DELTA 20 ! delta font height 20 twips = 1 point + WIDTH cgtimes_std + WIDTH_BOLD cgtimes_bold + WIDTH_ITALIC cgtimes_italic + WIDTH_BOLD_ITALIC cgtimes_bold_italic + COMMAND "<27>(s1p%dv4101T" + END_FONT +END_TYPEFACE + +TYPEFACE univers + NAME "Univers" + PROPORTIONAL + SCALED + TYPE HELVETICA + TRANSLATE telephone + FONT + HEIGHT 80 ! min font height 80 twips = 4 point + HEIGHT_MAX 1200 ! max font height 1200 twips ( = 60 point) + HEIGHT_DELTA 20 ! delta font height 20 twips = 1 point + WIDTH univers_std + WIDTH_BOLD univers_bold + WIDTH_ITALIC univers_italic + WIDTH_BOLD_ITALIC univers_bold_italic + COMMAND "<27>(s1p%dv4148T" + END_FONT +END_TYPEFACE + +MODEL + NAME "HP LaserJet III" + LANDSCAPE_AVAILABLE + MIN_X_IS_DOTS_PER_INCH + MIN_X 300 ! minx = 1/300 inch + MIN_Y 2 ! twips + SKIP_X 75 + SKIP_Y 0 + TYPEFACE courier,lineprinter,cgtimes,univers +END_MODEL diff --git a/code/SIBOSDK/wdrprint/decomman.c b/code/SIBOSDK/wdrprint/decomman.c new file mode 100644 index 0000000..3b699ce --- /dev/null +++ b/code/SIBOSDK/wdrprint/decomman.c @@ -0,0 +1,139 @@ +/* DECOMMAN.C */ + +#include +#include +#include +#include + +GLREF_D PR_WSERV *w_ws; +GLREF_D PR_DECOMMAN *DatApp2; + +#define SAVED_FILE_NAME "LOC::M:\\WDRPRINT.CFG" + +LOCAL_C VOID TryLoadPrintContext(VOID) + { + P_INFO junk; + VOID *fcb; + VOID *printer; + UBYTE buf[512]; + INT blen; + INT ind; + UBYTE *p1,*p2,*p3,*p4; + + if (p_finfo(SAVED_FILE_NAME,&junk)) + return; /* eg file does not exist */ + f_open(&fcb,SAVED_FILE_NAME,P_FOPEN|P_FSTREAM|P_FSHARE); + blen=f_read(fcb,&buf[0],512); + p_close(fcb); + if (blen<=sizeof(PRINTER_PARAMS)+2) + goto file_corrupt; + p1=(&buf[0]); + blen-=sizeof(PRINTER_PARAMS); + p2=p1+sizeof(PRINTER_PARAMS); + ind=p_bloc(p2+1,blen-1,0); + if (ind<0) + goto file_corrupt; + p3=p2+1+ind+1; + blen-=1+ind+1; + if (blen<=0) + goto file_corrupt; + ind=p_bloc(p3,blen,0); + if (ind<0) + goto file_corrupt; + p4=p3+ind+1; + blen-=ind+1; + if (blen<=0) + goto file_corrupt; + ind=p_bloc(p4,blen,0); + if (ind!=blen-1) + { + file_corrupt: + hInfoPrint(DELETING_CORRUPT_FILE); + p_delete(SAVED_FILE_NAME); + return; + } + p_send2(w_ws,O_WS_ENS_PRINT_CONTEXT); + printer=w_ws->wserv.printer; + p_bcpy((VOID *)p_send2(printer,O_PR_GET_PARAMS),p1,sizeof(PRINTER_PARAMS)); + p_send5(printer,O_PR_SET_MODEL,FALSE,p2+1,*p2); + p_send4(printer,O_PR_SET_HD,PRINTER_HDR_TOP,p3); + p_send4(printer,O_PR_SET_HD,PRINTER_HDR_BOT,p4); + } + +#pragma save,ENTER_CALL + +LOCAL_C INT SavePrintContext(VOID) + { + VOID *fcb; + VOID *printer; + TEXT *p; + struct + { + UBYTE model; + TEXT name[P_FNAMESIZE+1]; + } m; + + printer=w_ws->wserv.printer; + if (!printer) + return(0); + f_open(&fcb,SAVED_FILE_NAME,P_FREPLACE|P_FSTREAM|P_FUPDATE); + p=(TEXT *)p_send2(printer,O_PR_GET_PARAMS); + f_write(fcb,p,sizeof(PRINTER_PARAMS)); + m.model=p_send3(printer,O_PR_SENSE_MODEL,&m.name[0]); + f_write(fcb,&m.model,1+p_slen(&m.name[0])+1); + p=(TEXT *)p_send3(printer,O_PR_GET_HD,PRINTER_HDR_TOP); + f_write(fcb,p,p_slen(p)+1); + p=(TEXT *)p_send3(printer,O_PR_GET_HD,PRINTER_HDR_BOT); + f_write(fcb,p,p_slen(p)+1); + p_close(fcb); + return(0); + } + +#pragma restore + +LOCAL_C INT LaunchDialog(INT class,INT resid,VOID *rbuf) + { + DL_DATA dld; + + dld.id=resid; + dld.rbuf=rbuf; + dld.pdlg=NULL; + return hLaunchDial(CAT_DEMO_DEMO,class,&dld); + } + +LOCAL_C VOID PrintOrPreview(INT commid) + { + commid=(commid==O_DEC_PREVIEW? O_DEC_PRINT_DIRECT: 0); + hDestroy(f_newsend(CAT_DEMO_DEMO,C_DELP,O_LPR_INIT,commid)); + } + +#pragma METHOD_CALL + +METHOD VOID decomman_com_init(PR_DECOMMAN *self) + { + DatApp2=self; + TryLoadPrintContext(); + } + +METHOD VOID decomman_com_exit(PR_DECOMMAN *self) + { + if (p_enter1(SavePrintContext)) + p_delete(SAVED_FILE_NAME); + p_exit(0); + } + +METHOD VOID decomman_dec_psetup(VOID) + { + p_send2(w_ws,O_WS_EDIT_PRINT_CONTEXT); + } + +METHOD VOID decomman_dec_preview(PR_DECOMMAN *self,INT commid) + { + if (LaunchDialog(C_DEDLG,DELP_DLG,&commid)) + PrintOrPreview(commid); + } + +METHOD VOID decomman_dec_print_direct(VOID) + { + PrintOrPreview(O_DEC_PRINT); + } diff --git a/code/SIBOSDK/wdrprint/dedlg.c b/code/SIBOSDK/wdrprint/dedlg.c new file mode 100644 index 0000000..6125139 --- /dev/null +++ b/code/SIBOSDK/wdrprint/dedlg.c @@ -0,0 +1,31 @@ +/* DEDLG.C */ + +#include +#include +#include + +GLREF_D PR_DECOMMAN *DatApp2; + +#pragma METHOD_CALL + +METHOD VOID dedlg_dl_dyn_init(PR_DLGBOX *self) + { + INT commid; + + commid=(*(INT *)self->dlgbox.rbuf); + if (commid==O_DEC_PREVIEW) + hDlgSetTitleByRid(DELP_PREVIEW_TITLE); + if (!DatApp2->decomman.dets.dayno) + return; + hDlgSetDtedit(1,DatApp2->decomman.dets.dayno); + hDlgSetNcedit(2,DatApp2->decomman.dets.ndays); + hDlgSetChlist(3,DatApp2->decomman.dets.gap); + } + +METHOD INT dedlg_dl_key(PR_DLGBOX *self) + { + DatApp2->decomman.dets.dayno=hDlgSenseDtedit(1); + DatApp2->decomman.dets.ndays=hDlgSenseNcedit(2); + DatApp2->decomman.dets.gap=hDlgSenseChlist(3); + return(WN_KEY_CHANGED); + } diff --git a/code/SIBOSDK/wdrprint/delp.c b/code/SIBOSDK/wdrprint/delp.c new file mode 100644 index 0000000..58bfc19 --- /dev/null +++ b/code/SIBOSDK/wdrprint/delp.c @@ -0,0 +1,111 @@ +/* DELP.C */ + +#include +#include +#include + +GLREF_D PR_DECOMMAN *DatApp2; + +#define TIME_FMT_FLAGS (PR_TIME_MONTH_NAME|PR_TIME_SUFFIX_NAME) + +LOCAL_C VOID InitTimeObject(PR_DELP *self) + { + P_DAYSEC ds; + SE_TIME_FORMAT fmt; + + ds.day=DatApp2->decomman.dets.dayno; + ds.sec=0; + self->delp.time=f_new(CAT_DEMO_OLIB,C_TIME); + p_send4(self->delp.time,O_TO_SET,SET_TIME_DAYSEC,&ds); + fmt.flags=TIME_FMT_FLAGS; + p_send4(self->delp.time,O_TO_SET_FORMAT,&fmt,TIME_FMT_FLAGS); + } + +LOCAL_C UINT SenseBufWidth(PR_DELP *self,TEXT *pb) + { + return(p_send5(self->lprinter.wdr,O_WDR_SENSE_WIDTH, + self->delp.wtab,pb,p_slen(pb))); + } + +LOCAL_C VOID FindWidthFirstColumn(PR_DELP *self) + { + INT i; + TEXT buf[E_MAX_DAY_NAME]; + UWORD wid; + + for (i=0; i<7; i++) + { + p_nmday(&buf[0],i); + wid=SenseBufWidth(self,&buf[0]); + if (wid>self->delp.colwid) + self->delp.colwid=wid; + } + self->delp.colwid+=SenseBufWidth(self," "); /* two spaces */ + if (self->delp.colwid>(3*self->lprinter.width/4)) + { + hInfoPrint(DELP_PAPER_NARROW); + p_leave(RUN_ACTIVE_CLEANUP_NONOTIFY); + } + self->lprinter.subsqind=self->delp.colwid; + } + +LOCAL_C VOID InitWidthTable(PR_DELP *self) + { + self->delp.wtab=(VOID *)p_send5(self->lprinter.wdr,O_WDR_GET_WIDTH_TABLE, + self->lprinter.f.fid,self->lprinter.f.height, + self->lprinter.f.style|WDR_STYLE_BOLD); + } + +#pragma METHOD_CALL + +METHOD INT delp_lpr_sense_text(PR_DELP *self,WDR_PRINT *pr) + { + P_DATE dt; + P_DAYSEC ds; + + if (!self->delp.time) + { + self->delp.ndays=DatApp2->decomman.dets.ndays; + InitTimeObject(self); + InitWidthTable(self); + FindWidthFirstColumn(self); + } + else if (!self->delp.ndays) + return(FALSE); + switch (self->delp.state++) + { + case DELP_STATE_COL1: + if (DatApp2->decomman.dets.gap) + { + p_send4(self->delp.time,O_TO_SENSE,SENSE_TIME_DATE,&dt); + if (!dt.day) + { + pr->down=pr->height; + if (DatApp2->decomman.dets.gap==1) + pr->down>>=1; + } + } + p_send4(self->delp.time,O_TO_SENSE,SENSE_TIME_DAYSEC,&ds); + p_nmday(&self->delp.dname[0],P_WEEK(ds.day)); + self->delp.right=self->delp.colwid + -SenseBufWidth(self,&self->delp.dname[0]); + pr->buf=(&self->delp.dname[0]); + pr->style|=WDR_STYLE_BOLD; + break; + case DELP_STATE_COL2: + pr->flags&=(~(WDR_PRINT_LINE|WDR_PRINT_TEXT)); + pr->flags|=WDR_PRINT_RIGHT; + pr->right=self->delp.right; + return(TRUE); + case DELP_STATE_COL3: + p_send4(self->delp.time,O_TO_SENSE,SENSE_TIME_DATESTR,&self->delp.buf[0]); + pr->buf=(&self->delp.buf[0]); + pr->flags&=(~WDR_PRINT_LINE); + pr->indent=self->delp.colwid; + self->delp.ndays--; + p_send4(self->delp.time,O_TO_ADD_DAYS,1,0); + self->delp.state=DELP_STATE_COL1; + } + pr->blen=p_slen(pr->buf); + return(TRUE); + } diff --git a/code/SIBOSDK/wdrprint/demain.c b/code/SIBOSDK/wdrprint/demain.c new file mode 100644 index 0000000..d85a73d --- /dev/null +++ b/code/SIBOSDK/wdrprint/demain.c @@ -0,0 +1,17 @@ +/* DEMAIN.C */ + +#include + +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|FLG_APPMAN_FULLSCREEN; + wserv.com_cat=app.wserv_cat=p_getlibh(CAT_DEMO_DEMO); + app.wserv_class=C_DEWSERV; + wserv.com_class=C_DECOMMAN; + p_send4(p_new(CAT_DEMO_HWIM,C_HWIMMAN),O_AM_INIT,&app,&wserv); + } diff --git a/code/SIBOSDK/wdrprint/demo.cat b/code/SIBOSDK/wdrprint/demo.cat new file mode 100644 index 0000000..9a524a6 --- /dev/null +++ b/code/SIBOSDK/wdrprint/demo.cat @@ -0,0 +1,67 @@ +IMAGE demo + +EXTERNAL olib +EXTERNAL hwim +EXTERNAL xadd + +INCLUDE hwimman.g +INCLUDE dlgbox.g +INCLUDE xprinter.g +INCLUDE time.g +INCLUDE epoc.h + +CLASS dewserv wserv + { + REPLACE ws_dyn_init + } + +CLASS decomman comman + { + REPLACE com_init + REPLACE com_exit + ADD dec_psetup + ADD dec_preview + ADD dec_print=decomman_dec_preview + ADD dec_print_direct + TYPES + { + typedef struct + { + UWORD dayno; + UWORD ndays; + UWORD gap; + } DE_PRINT_DETAILS; + } + PROPERTY + { + DE_PRINT_DETAILS dets; + } + } + +CLASS dedlg dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } + +CLASS delp xprinter + { + REPLACE lpr_sense_text + CONSTANTS + { + DELP_STATE_COL1 0 + DELP_STATE_COL2 1 + DELP_STATE_COL3 2 + } + PROPERTY 1 + { + VOID *time; + VOID *wtab; + UWORD colwid; + UWORD right; + UWORD state; + UWORD ndays; + TEXT dname[E_MAX_DAY_NAME]; + TEXT buf[LN_TIME_DATE_STR]; + } + } diff --git a/code/SIBOSDK/wdrprint/demo.pic b/code/SIBOSDK/wdrprint/demo.pic new file mode 100644 index 0000000..d980c34 Binary files /dev/null and b/code/SIBOSDK/wdrprint/demo.pic differ diff --git a/code/SIBOSDK/wdrprint/demo.re b/code/SIBOSDK/wdrprint/demo.re new file mode 100644 index 0000000..c6ea162 --- /dev/null +++ b/code/SIBOSDK/wdrprint/demo.re @@ -0,0 +1,6 @@ +#include + +_O_COM_EXIT +_O_DEC_PSETUP +_O_DEC_PREVIEW +_O_DEC_PRINT diff --git a/code/SIBOSDK/wdrprint/demo.rss b/code/SIBOSDK/wdrprint/demo.rss new file mode 100644 index 0000000..c89f52f --- /dev/null +++ b/code/SIBOSDK/wdrprint/demo.rss @@ -0,0 +1,98 @@ +/* DEMO.RSS */ + +#include +#include +#include + +RESOURCE WSERV_INFO demo_accs + { + menbar_id=demo_menubar; + first_com=O_COM_EXIT; + accel={'x', + 'y','*','p'}; + } + +RESOURCE MENU_BAR demo_menubar + { + items = + { + MENU_BAR_ITEM + { + menu_id=special_menu; + mb_item="Demo"; + } + }; + } + +RESOURCE MENU special_menu + { + items = + { + MENU_ITEM + { + com_id=O_DEC_PSETUP; + mn_item="Print setup"; + }, + MENU_ITEM + { + com_id=O_DEC_PREVIEW; + mn_item="Preview"; + }, + MENU_ITEM + { + com_id=O_DEC_PRINT|BREAK_LINE_FOLLOWS; + mn_item="Print"; + }, + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +RESOURCE MENU delp_gap_chlist + { + items = + { + CHOICE_ITEM { str="No gap";}, + CHOICE_ITEM { str="Half a line";}, + CHOICE_ITEM { str="Complete line";} + }; + } + +RESOURCE DIALOG delp_dlg + { + title="Print list of days"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_DTEDIT; + prompt="Start date"; + info=DTEDIT { flags=IN_DTEDIT_DDMMYYYY;}; + }, + CONTROL + { + class=C_NCEDIT; + prompt="Number of days to print"; + info=NCEDIT + { + low=10; + current=20; + high=200; + }; + }, + CONTROL + { + class=C_CHLIST; + prompt="Space between months"; + info=CHLIST { rid=delp_gap_chlist; }; + } + }; + } + +RESOURCE STRING delp_paper_narrow { str="Paper size too narrow"; } +RESOURCE STRING delp_preview_title { str="Preview list of days"; } +RESOURCE STRING deleting_corrupt_file { str="Deleting corrupt file"; } diff --git a/code/SIBOSDK/wdrprint/dewserv.c b/code/SIBOSDK/wdrprint/dewserv.c new file mode 100644 index 0000000..95ce6c3 --- /dev/null +++ b/code/SIBOSDK/wdrprint/dewserv.c @@ -0,0 +1,38 @@ +/* DEWSERV.C */ + +#include +#include + +GLREF_D WSERV_SPEC *wserv_channel; + +LOCAL_C INT StatusWindowWidth(VOID) + { + P_EXTENT ext; + + wInquireStatusWindow(-1,&ext); + return(ext.width); + } + +LOCAL_C VOID InitClientWindow(PR_DEWSERV *self) + { + W_WINDATA wd; + PR_WIN *cliwin; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.height=wserv_channel->conn.info.pixels.y; + wd.extent.width=wserv_channel->conn.info.pixels.x-StatusWindowWidth(); + cliwin=f_newsend(CAT_DEMO_HWIM,C_BWIN,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd); + self->wserv.cli=cliwin; + cliwin->win.flags=PR_BWIN_CORNER_4|PR_BWIN_SHADOW_1; + p_send3(cliwin,O_WN_EMPHASISE,TRUE); + hInitVis(cliwin); + } + +#pragma METHOD_CALL + +METHOD VOID dewserv_ws_dyn_init(PR_DEWSERV *self) + { + wsSetList(W_STATUS_WINDOW_ICON,NULL,0); + wStatusWindow(W_STATUS_WINDOW_BIG); + InitClientWindow(self); + } diff --git a/code/SIBOSDK/wdrprint/make.bat b/code/SIBOSDK/wdrprint/make.bat new file mode 100644 index 0000000..e28ef10 --- /dev/null +++ b/code/SIBOSDK/wdrprint/make.bat @@ -0,0 +1,3 @@ +@echo off +tscx /m wdrprint +tscx /m wdrprint diff --git a/code/SIBOSDK/wdrprint/wdrprint.afl b/code/SIBOSDK/wdrprint/wdrprint.afl new file mode 100644 index 0000000..88c6f9b --- /dev/null +++ b/code/SIBOSDK/wdrprint/wdrprint.afl @@ -0,0 +1,2 @@ +demo.pic +demo.rzc diff --git a/code/SIBOSDK/wdrprint/wdrprint.pr b/code/SIBOSDK/wdrprint/wdrprint.pr new file mode 100644 index 0000000..65e2af2 --- /dev/null +++ b/code/SIBOSDK/wdrprint/wdrprint.pr @@ -0,0 +1,34 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile demo.cat + +#if %remake #or (demo.rg #older demo.re) #or (demo.rg #older demo.g) #then + #run "re demo" no_window no_abort +#endif + +#if (demo.rsg #older demo.rss) #or (demo.rsg #older demo.rg) #then + #file delete demo.rsg + #run "rs demo" no_window no_abort +#endif + +#if demo.rzc #older demo.rsg #then + #run "rch demo" no_window no_abort + #file delete wdrprint.img +#endif + +#compile decomman.c +#compile delp.c +#compile dedlg.c +#compile demain.c +#compile dewserv.c + +#if (wdrprint.img #older wdrprint.afl) #or (wdrprint.img #older demo.pic) #then + #file delete wdrprint.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link wdrprint.img diff --git a/code/SIBOSDK/wdrprint/wdrprrel.prj b/code/SIBOSDK/wdrprint/wdrprrel.prj new file mode 100644 index 0000000..71b7561 --- /dev/null +++ b/code/SIBOSDK/wdrprint/wdrprrel.prj @@ -0,0 +1,16 @@ +wdrprrel.prj ! releases source files +wdrprint.pr ! TS project file +make.bat ! makes WDRPRINT.IMG +! +demo.cat ! category file +demo.re ! resource externals +demo.rss ! resource script +! +decomman.c ! command manager +delp.c ! line printer subclass +dedlg.c ! dialog +demain.c ! main +dewserv.c ! window server subclass +! +wdrprint.afl ! add file list +demo.pic ! icon diff --git a/code/SIBOSDK/wkdemo/charger.c b/code/SIBOSDK/wkdemo/charger.c new file mode 100644 index 0000000..f1fef28 --- /dev/null +++ b/code/SIBOSDK/wkdemo/charger.c @@ -0,0 +1,212 @@ +/* Fastcharger for Workabout */ +/* Example application */ +/* (C) Copyright Psion Software PLC 1997 */ +#include +#include +#include +#include +#include +#include "fcharge.h" +GLREF_D VOID *winHandle; +LOCAL_C VOID State(WORD Val) + { + switch (Val) + { + case 0: + p_printf(" Unknown"); + break; + case 1: + p_printf(" Not Charging"); + break; + case 2: + p_printf(" Fast Charging"); + break; + case 3: + p_printf(" Topping Off"); + break; + default: + p_printf(" Trickle"); + } + } +GLDEF_C VOID main(VOID) + { + VOID *pcb; + WORD One,OldOne; + WORD Two,OldTwo; + WORD KStat,Disch; + WORD LogOne[100]; + WORD LogTwo[100]; + WORD P1=0,P2=0,Temp; + ULONG TTime; + P_CON_KBREC Key; + TEXT X1Str[11]; + WORD X1=0; + ULONG XE=0,DischTime; + TEXT *X1Ptr; + INT Item; + for(Item=0;Item<100;Item++) + { + LogOne[Item]=0; + LogTwo[Item]=0; + } + + p_devdel("FCG",E_LDD); + p_printf("Loading"); + if(p_loadldd("m:\\sys$fchg.ldd")<0) + p_panic(0); + p_printf("Opening test"); + if(p_open(&pcb,"FCG:A",-1)<0) + p_panic(1); + p_printf("Closing test"); + if(p_close(pcb)<0) + p_panic(2); + p_printf("Opening test part II"); + if(p_open(&pcb,"FCG:A",-1)<0) + p_panic(3); + p_printf("Cant remove test"); + if(p_devdel("FCG:",E_LDD)>=0) + p_panic(4); + p_printf("Setting the charge Mode"); + p_iow(pcb,P_FCHG_READCHARGEMODE,&One); + if (One!=(P_FCHG_DEFAULTCC | P_FCHG_CTIME1C)) + p_panic(5); + p_printf("Test the charge Mode"); + if (p_iow(pcb,P_FCHG_SETCHARGEMODE,&One)!=0) + p_panic(6); + p_printf("Set Rubbish charge Mode"); + One=-1; + if (p_iow(pcb,P_FCHG_SETCHARGEMODE,&One)==0) + p_panic(7); + p_iow(pcb,P_FCHG_READSTATUS,&One,&Two); + p_print("Battery one:"); + State(One); + p_print("Battery two:"); + State(Two); +/* p_printf("Asynch test1"); + p_iow(pcb,P_FCHG_ASYNCHREAD,&One,&Two); + p_print("Battery one:"); + State(One); + p_print("Battery two:"); + State(Two); + p_printf("Asynch test2"); + p_iow(pcb,P_FCHG_ASYNCHREAD,&One,&Two); + p_print("Battery one:"); + State(One); + p_print("Battery two:"); + State(Two);*/ + p_ioc4(winHandle,P_FREAD,&KStat,&Key); + TTime=p_date(); + Disch=0; + DischTime=0; + FOREVER + { + if (KStat!=E_FILE_PENDING) /* Was it the keyboard */ + { + p_iowait(); /* not really the way to do this -oh well */ + if (Key.keycode=='Q' || Key.keycode=='q' || Key.keycode==27) + p_exit(0); + else if (Key.keycode=='D' || Key.keycode=='d') + { + p_printf("Start discharge"); + TTime=p_date(); + if (p_iow(pcb,P_FCHG_DISCHARGE)) + p_panic(8); + Disch=1; + } + else if (Key.keycode=='F' || Key.keycode=='f') + { + p_printf("Start Fastcharge1"); + TTime=p_date(); + if (p_iow(pcb,P_FCHG_FASTCHARGE1)) + p_panic(9); + } + else if (Key.keycode=='G' || Key.keycode=='g') + { + p_printf("Start Fastcharge2"); + TTime=p_date(); + if (p_iow(pcb,P_FCHG_FASTCHARGE2)) + p_panic(9); + } + else if (Key.keycode=='C' || Key.keycode=='c') + { + p_getl("Current: ",&X1Str[0],10); + X1Ptr=&X1Str[0]; + p_stoi(&X1Ptr,&X1); + } + else if (Key.keycode=='/' || Key.keycode=='?') + { + if (Disch==1) + p_printf("Discharging: %d",(p_date()-TTime)); + else + { + p_printf("Discharge Time: %dl",DischTime); + if (X1>0 && DischTime>0) + { + XE=(850*60*60*10)/X1; + XE=(DischTime*100*10)/XE; + p_printf("Capacity (Cell) %d%%",(UWORD)(XE)); + } + } + } + else if (Key.keycode=='1') + { + p_printf("Battery one Log"); + Temp=0; + while (Temp0) + State(LogOne[Temp-1]); + } + else if (Key.keycode=='2') + { + p_printf("Battery two Log"); + Temp=0; + while (Temp0) + State(LogTwo[Temp-1]); + } + else if (Key.keycode=='H' || Key.keycode=='h' || Key.keycode==290 || Key.keycode==291) + { + p_printf(""); + p_printf("C...Enter Discharge current"); + p_printf("D...Start Discharge"); + p_printf("F...Fastcharge Battery1"); + p_printf("G...Fastcharge Battery2"); + p_printf("?...Show Discharge time"); + p_printf("1...Show Battery1 Log"); + p_printf("2...Show Battery2 Log"); + p_printf("Q...Quit"); + p_printf(""); + } + p_ioc4(winHandle,P_FREAD,&KStat,&Key); + } + OldOne=One; + OldTwo=Two; + p_iow(pcb,P_FCHG_READSTATUS,&One,&Two); + if (OldOne!=One || OldTwo!=Two) + { + if (OldOne==1 && Disch==1 && One!=1) + { + Disch=0; + DischTime=(p_date()-TTime); + p_printf("Discharge Time: %d",DischTime); + } + p_printf("Time: %d",(p_date()-TTime)); + if (One!=OldOne) + { + if (P1>50) + P1=0; + LogOne[P1++]=One; + } + if (Two!=OldTwo) + { + if (P2>50) + P2=0; + LogTwo[P2++]=Two; + } + p_print("Battery one:"); + State(One); + p_print("Battery two:"); + State(Two); + } + } +} diff --git a/code/SIBOSDK/wkdemo/charger.pr b/code/SIBOSDK/wkdemo/charger.pr new file mode 100644 index 0000000..998a9e7 --- /dev/null +++ b/code/SIBOSDK/wkdemo/charger.pr @@ -0,0 +1,8 @@ +#system epoc img +#model small jpi +#pragma define(EPOC=>1,JPIC=>1) + +#compile %main +#link %prjname + + diff --git a/code/SIBOSDK/wkdemo/checkvid.bat b/code/SIBOSDK/wkdemo/checkvid.bat new file mode 100644 index 0000000..5c6199f --- /dev/null +++ b/code/SIBOSDK/wkdemo/checkvid.bat @@ -0,0 +1,2 @@ +@if not "%jpivid%"=="v2" set jpivid=v0 + diff --git a/code/SIBOSDK/wkdemo/dummy.pic b/code/SIBOSDK/wkdemo/dummy.pic new file mode 100644 index 0000000..e69de29 diff --git a/code/SIBOSDK/wkdemo/lcdcomm.c b/code/SIBOSDK/wkdemo/lcdcomm.c new file mode 100644 index 0000000..1296e62 --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdcomm.c @@ -0,0 +1,62 @@ +/* +File: LCDCOMM.C + +Methods for Class: lcdcomm (Superclass: comman). +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GLREF_D PR_LCDCOMM *DatApp2; /* Command Manager */ +GLREF_D PR_LCDVIEW *DatApp3; /* Main Client Window */ + +LOCAL_C INT lLaunchDlg(P_CATID cat,UINT class,UINT id,VOID *prbuf) + { + DL_DATA dl_data; + + dl_data.id = id; + dl_data.rbuf = prbuf; + dl_data.pdlg = NULL; + return(hLaunchDial(cat,class,&dl_data)); + } + +LOCAL_C INT lLaunchDlgLcdtest(UINT class,UINT id,VOID *prbuf) + { /* Launches an LCDTEST category dialog. */ + return(lLaunchDlg(CAT_LCDTEST_LCDTEST,class,id,prbuf)); + } + +LOCAL_C INT lLaunchDlgLcdtestNull(UINT class,UINT id) + { /* Launches a LCDTEST category dialog with rbuf set to NULL. */ + return(lLaunchDlgLcdtest(class,id,NULL)); + } + +#pragma METHOD_CALL + +METHOD VOID lcdcomm_com_init(PR_LCDCOMM *self) + { + DatApp2 = self; + self->lcdcomm.sound.duration = 5; + self->lcdcomm.sound.pitch = 320; + } + +METHOD VOID lcdcomm_com_exit(PR_LCDCOMM *self) + { /* Exit application. */ + p_supersend2(self,O_COM_EXIT); + } + +METHOD VOID lcdcomm_cm_backlight(PR_LCDCOMM *self) + { /* Switch backlight on/off. */ + lLaunchDlgLcdtestNull(C_LCD_BACKLIGHT,D_BACKLIGHT); + } + +METHOD VOID lcdcomm_cm_sound(PR_LCDCOMM *self) + { /* Make a beep by calling p_sound() */ + lLaunchDlgLcdtest(C_LCD_SOUND,D_SOUND,&self->lcdcomm.sound); + } diff --git a/code/SIBOSDK/wkdemo/lcdcomm.cl b/code/SIBOSDK/wkdemo/lcdcomm.cl new file mode 100644 index 0000000..bc7afe7 --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdcomm.cl @@ -0,0 +1,30 @@ +NAME lcdcomm + +INCLUDE p_std.h +INCLUDE p_object.h +INCLUDE olib.g +INCLUDE comman.g + +CLASS lcdcomm comman +LCD Test command manager + { + REPLACE com_init ! + REPLACE com_exit ! Exit application + ADD cm_backlight ! Turn backlight on/off + ADD cm_sound ! Make a beep by calling p_sound() + TYPES + { + typedef struct + { + INT duration; ticks + INT pitch; frequency = 512/pitch kHz + } LCDCOMM_SOUND_INFO; + } + PROPERTY + { + UBYTE Status; + UBYTE Prefs; + LCDCOMM_SOUND_INFO sound; + } + } + diff --git a/code/SIBOSDK/wkdemo/lcddlgs.c b/code/SIBOSDK/wkdemo/lcddlgs.c new file mode 100644 index 0000000..c8f2a3d --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcddlgs.c @@ -0,0 +1,60 @@ +/* +File: LCDDLGS.C + +Methods for dialogs +*/ +#include +#include +#include +#include +#include +#include +#include + +#define RBUFLEN 50 /* Buffer length for resource strings */ + +/* Set backlight & time dialog: position/index values */ +#define BACKLIGHT_OFFON 1 + +/* Sound test dialog: position/index values */ +#define SOUND_DURATION 1 +#define SOUND_PITCH 2 + +#pragma METHOD_CALL + +METHOD VOID lcd_backlight_dl_dyn_init(PR_DLGBOX *self) + { + if(p_backlight(E_BACKLIGHT_QUERY)) + hDlgSetChlistOn(BACKLIGHT_OFFON); + } + +METHOD VOID lcd_backlight_dl_changed(PR_DLGBOX *self, INT pos) + { + p_backlight(hDlgSenseChlist(BACKLIGHT_OFFON)? + E_BACKLIGHT_ON: E_BACKLIGHT_OFF); + } + +METHOD INT lcd_backlight_dl_key(PR_DLGBOX *self, INT pos, INT keycode) + { + lcd_backlight_dl_changed(self,pos); + return WN_KEY_CHANGED; + } + + +METHOD VOID lcd_sound_dl_dyn_init(PR_DLGBOX *self) + { + LCDCOMM_SOUND_INFO *const pInfo = self->dlgbox.rbuf; + + hDlgSetNcedit(SOUND_DURATION,pInfo->duration); + hDlgSetNcedit(SOUND_PITCH,pInfo->pitch); + } + +METHOD INT lcd_sound_dl_key(PR_DLGBOX *self, INT pos, INT keycode) + { + LCDCOMM_SOUND_INFO *const pInfo = self->dlgbox.rbuf; + + pInfo->duration = hDlgSenseNcedit(SOUND_DURATION); + pInfo->pitch = hDlgSenseNcedit(SOUND_PITCH); + p_sound(pInfo->duration,pInfo->pitch); + return WN_KEY_CHANGED; + } diff --git a/code/SIBOSDK/wkdemo/lcddlgs.cl b/code/SIBOSDK/wkdemo/lcddlgs.cl new file mode 100644 index 0000000..a1581fe --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcddlgs.cl @@ -0,0 +1,21 @@ +NAME lcddlgs + +INCLUDE p_std.h +INCLUDE p_object.h +INCLUDE olib.g +INCLUDE hwim.g +INCLUDE dlgbox.g + + +CLASS lcd_backlight dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_changed + REPLACE dl_key + } + +CLASS lcd_sound dlgbox + { + REPLACE dl_dyn_init + REPLACE dl_key + } diff --git a/code/SIBOSDK/wkdemo/lcdmain.c b/code/SIBOSDK/wkdemo/lcdmain.c new file mode 100644 index 0000000..3d76fdd --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdmain.c @@ -0,0 +1,28 @@ +/* +File: LCDMAIN.C +*/ + +#include +#include +#include +#include +#include + +#pragma METHOD_CALL + +GLDEF_C VOID main(VOID) + { + IN_HWIMMAN app; + IN_WSERV wserv; + + p_linklib(0); + app.flags = FLG_APPMAN_RSCFILE + | FLG_APPMAN_CLEAN + | FLG_APPMAN_SRSCFILE + | FLG_APPMAN_FULLSCREEN + | FLG_APPMAN_ONLYONE; + app.wserv_cat = wserv.com_cat = p_getlibh(CAT_LCDTEST_LCDTEST); + app.wserv_class = C_LCDWSERV; + wserv.com_class = C_LCDCOMM; + p_send4(p_new(CAT_LCDTEST_HWIM,C_HWIMMAN),O_AM_INIT,&app,&wserv); + } /* never returns */ diff --git a/code/SIBOSDK/wkdemo/lcdtest.afl b/code/SIBOSDK/wkdemo/lcdtest.afl new file mode 100644 index 0000000..284bca9 --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdtest.afl @@ -0,0 +1,2 @@ +dummy.pic +lcdtest.rzc diff --git a/code/SIBOSDK/wkdemo/lcdtest.cat b/code/SIBOSDK/wkdemo/lcdtest.cat new file mode 100644 index 0000000..9cfc758 --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdtest.cat @@ -0,0 +1,13 @@ +IMAGE lcdtest + +EXTERNAL olib +EXTERNAL hwim + +INCLUDE p_std.h +INCLUDE p_object.h + +REQUIRE lcdwserv +REQUIRE lcdcomm +REQUIRE lcdview +REQUIRE lcddlgs + diff --git a/code/SIBOSDK/wkdemo/lcdtest.pr b/code/SIBOSDK/wkdemo/lcdtest.pr new file mode 100644 index 0000000..f92dd87 --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdtest.pr @@ -0,0 +1,40 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#abort on + +#set version=0x100F +#set priority=0x80 +#set heapsize=0x80 + +#compile %main.cat + +#if %remake #or (%main.rg #older %main.re) #or (%main.rg #older %main.g) #then + #run "re %main" no_window no_abort +#endif + +#if (%main.rsg #older %main.rss) #or (%main.rsg #older %main.rg) #then + #file delete %main.rsg + #run "rs %main" no_window no_abort +#endif + +#if %main.rzc #older %main.rsg #then + #run "rch %main" no_window no_abort +#endif + +#compile lcdmain.c +#compile lcdwserv.c +#compile lcdcomm.c +#compile lcdview.c +#compile lcddlgs.c + +#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then + #file delete %main.img +#endif + +#pragma link(olib.lib) +#pragma link(hwim.lib) + +#link %main + diff --git a/code/SIBOSDK/wkdemo/lcdtest.re b/code/SIBOSDK/wkdemo/lcdtest.re new file mode 100644 index 0000000..6594e2b --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdtest.re @@ -0,0 +1,7 @@ +/* LCDTEST.RE */ + +#include + +_O_COM_EXIT +_O_CM_BACKLIGHT +_O_CM_SOUND diff --git a/code/SIBOSDK/wkdemo/lcdtest.rss b/code/SIBOSDK/wkdemo/lcdtest.rss new file mode 100644 index 0000000..26967cf --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdtest.rss @@ -0,0 +1,156 @@ +/* +LCDTEST.RSS +*/ + +#include +#include +#include +#include +#include + +/* accelerators, menu bar and menu */ +RESOURCE WSERV_INFO accs_lcdview + { + menbar_id=menubar_lcdview; + first_com=O_COM_EXIT; +/* FT: following are accelerators for the main menu items. + Comments by each show which main menu tile it belongs to */ + accel={'x', /* Exit */ + 'b', /* Backlight */ + 's' /* Sound */ + }; + } + +RESOURCE MENU_BAR menubar_lcdview + { + items = + { + MENU_BAR_ITEM + { + menu_id=menu_control; + mb_item="Control"; + }, + MENU_BAR_ITEM + { + menu_id=menu_special; + mb_item="Special"; + } + }; + } + +RESOURCE MENU menu_control + { + items = + { + MENU_ITEM + { + com_id=O_CM_BACKLIGHT; + mn_item="Backlight"; + }, + MENU_ITEM + { + com_id=O_CM_SOUND; + mn_item="Sound"; + } + }; + } + +RESOURCE MENU menu_special + { + items = + { + MENU_ITEM + { + com_id=O_COM_EXIT; + mn_item="Exit"; + } + }; + } + +/* String resources */ +RESOURCE STRING s_copyright + {str=" Copyright Psion PLC 1994";} + +/* Dialog resources */ + +RESOURCE DIALOG d_backlight + { + title="Set backlight"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_CHLIST; + flags=DLGBOX_ITEM_NOTIFY_CHANGED; + prompt="Backlight"; + info=CHLIST {rid=-SYS_OFFON_MENU;}; + } + }; + } + +RESOURCE DIALOG d_sound + { + title="Make test sound"; + flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED; + controls= + { + CONTROL + { + class=C_NCEDIT; + prompt="Duration (ticks)"; + info=NCEDIT {}; + }, + CONTROL + { + class=C_NCEDIT; + prompt="Pitch (512/kHz)"; + info=NCEDIT {}; + } + }; + } + +/* Help resources */ +RESOURCE HELP_ARRAY h_help +{ +topic="Lcdtest: 1.23w"; /* place holder for version number */ +topic_id=h_help_index; +} + +RESOURCE TOPIC_ARRAY h_help_index +{ +id_lst= +{ +h_numkeys, +h_arrows +}; +} + +RESOURCE HELP_ARRAY h_numkeys +{ +topic="Numeric keys"; +strlst= +{ +STRING {str="0. Reverse video";}, +STRING {str="1. `HHH' pattern";}, +STRING {str="2. ON/OFF pattern";}, +STRING {str="3. All ON pattern";}, +STRING {str="4. All OFF pattern";}, +STRING {str="5. Grey pattern";}, +STRING {str="6. Random chars?";} +}; +} + +RESOURCE HELP_ARRAY h_arrows +{ +topic="Arrow keys"; +strlst= +{ +STRING {str="These move the grey";}, +STRING {str="pattern up or down";}, +STRING {str="& vary the start of";}, +STRING {str="the letter pattern.";}, +STRING {str="They do not affect";}, +STRING {str="any other pattern.";} +}; +} diff --git a/code/SIBOSDK/wkdemo/lcdview.c b/code/SIBOSDK/wkdemo/lcdview.c new file mode 100644 index 0000000..83fe93a --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdview.c @@ -0,0 +1,240 @@ +/* +File: LCDVIEW.C + +Methods for Class: cpview (Superclass: win). + +Main client window +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FONT_DEF FONT_ID_MONO_8x8 +#define CHARBUFFSIZE 64 + +GLREF_D PR_GATE *DatGate; +GLREF_D WSERV_SPEC *wserv_channel; +GLREF_D PR_LCDVIEW *DatApp3; /* Main Client Window */ + +LOCAL_C VOID lSetDisplayInfo(LCD_DISP_INFO * pLinfo) + { + G_FONT_INFO finfo; + + gFontInfo(pLinfo->textfont,G_STY_MONO,&finfo); + pLinfo->numwidth = finfo.numeric_width; + pLinfo->textheight = finfo.height; + pLinfo->textascent = finfo.ascent; + pLinfo->lineheight = finfo.height + 2; + pLinfo->lineascent = finfo.ascent + 2; + pLinfo->scrlines = wserv_channel->conn.info.pixels.y + /pLinfo->lineheight; + pLinfo->scrwidth = wserv_channel->conn.info.pixels.x; + } + +LOCAL_C VOID lSetGCTemp(UWORD fid, UWORD style) +/* Sets font and style */ + { + G_GC g_gc; + + g_gc.font = fid; + g_gc.style = (BYTE)style; + gSetGC(WS_TEMPORARY_GC,G_GC_MASK_FONT|G_GC_MASK_STYLE,&g_gc); + } + +LOCAL_C VOID lFillCharBuff(PR_LCDVIEW *const self, TEXT *pTxt, INT size) + { + INT jj; + + for(jj = 0; jj < size; ++jj, ++pTxt) + { + *pTxt = self->lcdview.letter; + ++self->lcdview.letter; + if(self->lcdview.letter > 'Z') + self->lcdview.letter = 'A'; + } + } + +LOCAL_C VOID lDrawPatternHHH(PR_LCDVIEW *const self) + { + P_RECT rect0; + P_RECT rect1; + TEXT xBuff[CHARBUFFSIZE]; + INT row; + INT chars; + UINT width; + + p_bfil(&xBuff[0],sizeof(xBuff),'H'); + + /* Set font and style */ + lSetGCTemp(self->lcdview.dinfo.textfont,G_STY_MONO); + rect1 = rect0 = *((P_RECT*)&self->lcdview.extent); + gClrRect(&rect1,G_TRMODE_CLR); + width = self->lcdview.dinfo.scrwidth; + chars = gTextCount(self->lcdview.dinfo.textfont,G_STY_MONO, + &xBuff[0],sizeof(xBuff),&width); + + rect0.tl.y = 25; + ++rect0.tl.x; + --rect0.br.x; + for(row = 0; row < 5; ++row) + { + rect0.br.y = rect0.tl.y + self->lcdview.dinfo.lineheight; + gPrintBoxText(&rect0,self->lcdview.dinfo.lineascent, + G_TEXT_ALIGN_LEFT,0,&xBuff[0],chars); + rect0.tl.y += 10; + } + + gDrawBox(&rect1); + } + +LOCAL_C VOID lDrawPatternOnOff(PR_LCDVIEW *const self) + { /* Alternate pixels On/Off */ + gFillPattern((P_RECT*)&self->lcdview.extent, + WS_BITMAP_GREY,G_TRMODE_REPL); + } + +LOCAL_C VOID lDrawPatternON(PR_LCDVIEW *const self) + { /* All pixels ON */ + gClrRect((P_RECT*)&self->lcdview.extent,G_TRMODE_SET); + } + +LOCAL_C VOID lDrawPatternOFF(PR_LCDVIEW *const self) + { /* All pixels OFF */ + gClrRect((P_RECT*)&self->lcdview.extent,G_TRMODE_CLR); + } + +LOCAL_C VOID lDrawPatternGrey(PR_LCDVIEW *const self) + { + INT row; + P_RECT rect0; + G_GC g_gc; + + gClrRect((P_RECT*)&self->lcdview.extent,G_TRMODE_CLR); + g_gc.flags = G_GC_FLAG_GREY_PLANE; + gSetGC(WS_TEMPORARY_GC,G_GC_MASK_GREY,&g_gc); + rect0 = *((P_RECT*)&self->lcdview.extent); + rect0.tl.y = self->lcdview.offset % (self->lcdview.dinfo.lineheight+1); + for(row = 0; row < self->lcdview.dinfo.scrlines; ++row) + { + rect0.br.y = rect0.tl.y + self->lcdview.dinfo.lineheight; + gClrRect(&rect0,row%2? G_TRMODE_SET: G_TRMODE_CLR); + rect0.tl.y += self->lcdview.dinfo.lineheight; + } + gClrRect(&rect0,G_TRMODE_CLR); + g_gc.flags = 0; + gSetGC(WS_TEMPORARY_GC,G_GC_MASK_GREY,&g_gc); + } + +LOCAL_C VOID lDrawPatternChars(PR_LCDVIEW *const self) + { + P_RECT rect0; + TEXT xBuff[CHARBUFFSIZE]; + INT row; + INT chars; + UINT width; + + /* Set font and style */ + lSetGCTemp(self->lcdview.dinfo.textfont,G_STY_MONO); + p_bcpy(&rect0,&self->lcdview.extent,sizeof(rect0)); + gClrRect(&rect0,G_TRMODE_CLR); + for(row = 0; row < self->lcdview.dinfo.scrlines; ++row) + { + rect0.br.y = rect0.tl.y + self->lcdview.dinfo.lineheight; + lFillCharBuff(self,&xBuff[0],sizeof(xBuff)); + width = self->lcdview.dinfo.scrwidth; + chars = gTextCount(self->lcdview.dinfo.textfont,G_STY_MONO, + &xBuff[0],sizeof(xBuff),&width); + self->lcdview.letter = xBuff[chars]; + gPrintBoxText(&rect0,self->lcdview.dinfo.lineascent, + G_TEXT_ALIGN_LEFT,0,&xBuff[0],chars); + rect0.tl.y += self->lcdview.dinfo.lineheight; + } + } + +LOCAL_C VOID SetPattern(PR_LCDVIEW *const self, VOID(*func)(PR_LCDVIEW *)) + { + self->lcdview.funct = (VOID(*)(VOID*))func; + } + +#pragma METHOD_CALL + +METHOD VOID lcdview_wn_init(PR_LCDVIEW *const self) + { + W_WINDATA wd; + + wd.background = W_WIN_BACK_CLR|W_WIN_BACK_GREY_CLR; + wd.flags = 0; + wd.extent.tl.x = wd.extent.tl.y = 0; + wd.extent.width = wserv_channel->conn.info.pixels.x; + wd.extent.height = wserv_channel->conn.info.pixels.y; + self->lcdview.extent = wd.extent; + p_send5(self,O_WN_CONNECT,NULL_D,W_WIN_ALL_FLAGS|W_WIN_EXTENT|W_WIN_BACKGROUND,&wd); + wStatusWindow(W_STATUS_WINDOW_OFF); + wsSetList(W_STATUS_WINDOW_ICON,NULL_D,0); + + self->lcdview.letter = 'A'; + self->lcdview.dinfo.textfont = FONT_DEF; + lSetDisplayInfo(&self->lcdview.dinfo); + SetPattern(self,lDrawPatternHHH); + } + +METHOD VOID lcdview_wn_draw(PR_LCDVIEW *const self) + { + (*self->lcdview.funct)(self); + if(self->lcdview.status & LCD_STAT_INVERSE) + gInvObloid(&self->lcdview.extent); + } + +METHOD INT lcdview_wn_key(PR_LCDVIEW *const self,UINT key,UINT mod) + { + switch(key) + { + case '0': + gCreateTempGC0(self->win.id); + gInvObloid(&self->lcdview.extent); + self->lcdview.status ^= LCD_STAT_INVERSE; + gFreeTempGC(); + return WN_KEY_NO_CHANGE; + case '1': + SetPattern(self,lDrawPatternHHH); + break; /* to WN_DODRAW */ + case '2': + SetPattern(self,lDrawPatternOnOff); + break; /* to WN_DODRAW */ + case '3': + SetPattern(self,lDrawPatternON); + break; /* to WN_DODRAW */ + case '4': + SetPattern(self,lDrawPatternOFF); + break; /* to WN_DODRAW */ + case '5': + SetPattern(self,lDrawPatternGrey); + break; /* to WN_DODRAW */ + case '6': + SetPattern(self,lDrawPatternChars); + break; /* to WN_DODRAW */ + case W_KEY_UP: + ++self->lcdview.offset; + break; /* to WN_DODRAW */ + case W_KEY_DOWN: + --self->lcdview.offset; + break; /* to WN_DODRAW */ + case W_KEY_HOME: + self->lcdview.offset = 0; + break; /* to WN_DODRAW */ + case W_KEY_END: + self->lcdview.offset = self->lcdview.dinfo.lineheight; + break; /* to WN_DODRAW */ + default: + return WN_KEY_NO_CHANGE; + } /* End switch() */ + p_send2(self,O_WN_DODRAW); + return WN_KEY_NO_CHANGE; + } diff --git a/code/SIBOSDK/wkdemo/lcdview.cl b/code/SIBOSDK/wkdemo/lcdview.cl new file mode 100644 index 0000000..489730a --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdview.cl @@ -0,0 +1,45 @@ +NAME lcdview + +INCLUDE p_std.h +INCLUDE p_object.h +INCLUDE olib.g +INCLUDE hwim.g +INCLUDE hwimman.g +INCLUDE edwin.g + +CLASS lcdview win +Command Processor client window + { + REPLACE wn_init Initialise client window + REPLACE wn_draw + REPLACE wn_key + CONSTANTS + { + LCD_STAT_INVERSE 0x0001 Set if video reversed + } + TYPES + { + typedef struct + { + UWORD textfont; text font ID + UBYTE numwidth; max font numeric_width + UBYTE textheight; text font height + UBYTE textascent; text font ascent + UBYTE lineheight; max font height plus 1/2 pixels + UBYTE lineascent; max font ascent plus 1/2 pixels + UBYTE scrlines; lines on screen + INT scrwidth; screen width + } LCD_DISP_INFO; display line info. + } + PROPERTY + { + UWORD status; flags + BYTE letter; for random letters on screen + UBYTE offset; to top of grey pattern + P_EXTENT extent; view extent + VOID (*funct)(VOID *self); pattern function + LCD_DISP_INFO dinfo; output display info (based on current font) + } + } + + diff --git a/code/SIBOSDK/wkdemo/lcdwserv.c b/code/SIBOSDK/wkdemo/lcdwserv.c new file mode 100644 index 0000000..43fce0b --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdwserv.c @@ -0,0 +1,59 @@ +/* +File: LCDWSERV.C + +Methods for Class: lcdwserv (Superclass: wserv). +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GLREF_D PR_HWIMMAN *w_am; +GLREF_D UBYTE *DatUsedPathNamePtr; +GLREF_D UBYTE *DatCommandPtr; +GLREF_D PR_LCDVIEW *DatApp3; /* Main Client Window */ + +LOCAL_C VOID lLoadOwnVersionText(TEXT *pb) + { + ImgHeader head; + VOID *pcb; + INT val; + + f_open(&pcb,(TEXT *)DatCommandPtr,P_FOPEN|P_FSHARE|P_FSTREAM); + val = p_read(pcb,&head,sizeof(head)); + p_close(pcb); + if(val != sizeof(head)) + p_leave(E_FILE_INVALID); + p_atos(pb,"%u.%03x",head.CodeVersion>>12,head.CodeVersion&0xfff); + } + +#pragma METHOD_CALL + +METHOD VOID lcdwserv_ws_dyn_init(PR_LCDWSERV *self) + { + /* create and initialise the client window */ + p_send2(DatApp3=(PR_LCDVIEW *)f_new(CAT_LCDTEST_LCDTEST,C_LCDVIEW),O_WN_INIT); + self->wserv.cli =(PR_WIN *)DatApp3; + + self->wserv.help_index_id = H_HELP; + hInitVis(self->wserv.cli); + hInfoPrint(S_COPYRIGHT); + } + +METHOD VOID lcdwserv_ws_do_help(PR_LCDWSERV *self,INT start_id) + { + TEXT *pTxt; /* points into Help screen title buffer */ + + p_supersend3(self,O_WS_DO_HELP,start_id); + if (start_id!=H_HELP) + return; + pTxt=(&((PR_HELPDLG *)self->wserv.dial)->helpdlg.listbox->helplist.title[0]); + pTxt += p_slen(pTxt)-5; /* position back before 1.23w */ + lLoadOwnVersionText(pTxt); + } diff --git a/code/SIBOSDK/wkdemo/lcdwserv.cl b/code/SIBOSDK/wkdemo/lcdwserv.cl new file mode 100644 index 0000000..4c60c02 --- /dev/null +++ b/code/SIBOSDK/wkdemo/lcdwserv.cl @@ -0,0 +1,14 @@ +NAME lcdwserv + +INCLUDE p_std.h +INCLUDE p_object.h +INCLUDE olib.g +INCLUDE hwim.g +INCLUDE hwimman.g + +CLASS lcdwserv wserv + { + REPLACE ws_dyn_init Startup code + REPLACE ws_do_help Set application version number + } + diff --git a/code/SIBOSDK/wkdemo/make.bat b/code/SIBOSDK/wkdemo/make.bat new file mode 100644 index 0000000..319ca30 --- /dev/null +++ b/code/SIBOSDK/wkdemo/make.bat @@ -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 diff --git a/code/SIBOSDK/wkdemo/tables.c b/code/SIBOSDK/wkdemo/tables.c new file mode 100644 index 0000000..43e16c4 --- /dev/null +++ b/code/SIBOSDK/wkdemo/tables.c @@ -0,0 +1,629 @@ +/* + + TABLES.C + +*/ + +#include +#include +#include +#include +#include + + +GLREF_D UWORD DatLocked; + +LOCAL_D TEXT *cmds[]= + { + "rReset score", + "lLimits", + "mMode", + "tTiming", + "xExit", + NULL + }; + +#define TABLES_ITEMS 5 + +LOCAL_D H_MENU_DATA mdata[]= + { + "Tables",TABLES_ITEMS, + NULL + }; + +GLDEF_D TEXT ** _cmds=(&cmds[0]); +GLDEF_D H_MENU_DATA * _mdata=(&mdata[0]); + + +LOCAL_D UINT MainWid; + +typedef struct + { + UWORD TableEnd; + UWORD MaxTable; + UWORD Tested; + UWORD Correct; + UWORD Timing; + UWORD Mode; + } TSTATE; + +LOCAL_D TSTATE state={12,12,0,0,5,1}; + +LOCAL_D TEXT *EnvName="TABLES"; +#define ENV_NAME_LEN 6 + +LOCAL_D ULONG seed; + +LOCAL_D VOID *timH; +LOCAL_D WORD timactive; +LOCAL_D WORD timstat; +LOCAL_D ULONG timint; +LOCAL_D WORD timcount; +LOCAL_D WORD timtotcnt; + + +LOCAL_C VOID DrawLine(INT j,TEXT *pb) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+13*j; + box.br.y=box.tl.y+13; + gPrintBoxText(&box,11,G_TEXT_ALIGN_CENTRE,0,pb,p_slen(pb)); + } + +LOCAL_C VOID DisplayScores(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"Score: %u correct out of %u",state.Correct,state.Tested); + DrawLine(0,&buf[0]); + } + +LOCAL_C VOID DisplayMode(VOID) + { + TEXT *pb; + TEXT buf[40]; + + if (state.Mode==1) + pb="Testing all tables"; + else + { + p_atos(&buf[0],"Testing %d times table",state.Mode); + pb=(&buf[0]); + } + DrawLine(1,pb); + } + +LOCAL_C VOID DisplayLimits(VOID) + { + TEXT buf[40]; + + p_atos(&buf[0],"(up to %d times %d)", + (state.Mode==1? state.MaxTable: state.Mode),state.TableEnd); + DrawLine(2,&buf[0]); + } + +LOCAL_C VOID DrawButton(INT state) + { + P_RECT box; + + box.tl.x=34+38; + box.br.x=34+38+38; + box.tl.y=57; + box.br.y=57+14; + wDrawButton(&box,"Enter",state); + } + +LOCAL_C VOID DisplayPressButton(VOID) + { + gPrintText(34,66,"Press",5); + DrawButton(FALSE); + gPrintText(34+38+38+4,66,"to test",7); + } + +LOCAL_C VOID Display(VOID) + { + DisplayScores(); + DisplayMode(); + DisplayLimits(); + DisplayPressButton(); + } + +LOCAL_C VOID ResetScore(VOID) + { + if (!state.Tested) + { + wInfoMsg("No score to reset"); + return; + } + if (uOpenDialog("Reset score to zero")) + return; + if (uAddButtonList("No",-'n',"Yes",'y',NULL)) + return; + if (uRunDialog()=='y') + { + state.Tested=0; + state.Correct=0; + DisplayScores(); + } + } + +LOCAL_C VOID ChangeLimits(VOID) + { + LONG lTableEnd; + LONG lMaxTable; + H_DI_NUMBER end; + H_DI_NUMBER last; + + lTableEnd=state.TableEnd; + lMaxTable=state.MaxTable; + if (uOpenDialog("Limits for testing")) + return; + end.value=(&lTableEnd); + end.low=10; + end.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Tables end at",&end)) + return; + last.value=(&lMaxTable); + last.low=2; + last.high=99; + if (uAddDialogItem(H_DIALOG_NUMBER,"Highest table",&last)) + return; + if (uRunDialog()<=0) + return; + state.TableEnd=lTableEnd; + state.MaxTable=lMaxTable; + if (state.Mode>state.MaxTable) + state.Mode=state.MaxTable; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ChangeTiming(VOID) + { + LONG lTiming; + H_DI_NUMBER tim; + + lTiming=state.Timing; + if (uOpenDialog("Timing")) + return; + tim.value=(&lTiming); + tim.low=1; + tim.high=20; + if (uAddDialogItem(H_DIALOG_NUMBER,"Number of seconds allowed",&tim)) + return; + if (uRunDialog()<=0) + return; + state.Timing=lTiming; + } + +GLREF_D UWORD _SmallFontDialog; + +LOCAL_C VOID ChangeMode(VOID) + { + H_DI_CHOICE ch; + INT j; + TEXT buf[20]; + + _SmallFontDialog=TRUE; + if (uOpenDialog("Mode")) + return; + if (uBeginDCL(&ch)) + return; + if (uGrowDCL(&ch,"All tables")) + return; + for (j=2; j<=state.MaxTable; j++) + { + p_atos(&buf[0],"%d times table",j); + if (uGrowDCL(&ch,&buf[0])) + return; + } + if (uAddDCL("Test which tables",&state.Mode,&ch)) + return; + if (uRunDialog()<=0) + return; + DisplayMode(); + DisplayLimits(); + } + +LOCAL_C VOID ExitApplication(VOID) + { + uErrorValue(p_setenviron(EnvName,ENV_NAME_LEN,&state,sizeof(TSTATE))); + p_exit(0); + } + +LOCAL_C VOID ManageCommand(INT index) + { + switch (index) + { + case 0: + ResetScore(); + break; + case 1: + ChangeLimits(); + break; + case 2: + ChangeMode(); + break; + case 3: + ChangeTiming(); + break; + case 4: + ExitApplication(); + } + } + +LOCAL_C VOID TryExecuteCommand(INT keycode) + { + keycode=uLocateCommand(keycode); + if (keycode>=0) + ManageCommand(keycode); + } + +LOCAL_C INT FindRandom(INT low,INT high) + { + INT range; + + range=high-low+1; + return(low+(INT)(p_randl(&seed)%range)); + } + +LOCAL_C VOID FindFactors(WORD *pa,WORD *pb) + { + *pa=(state.Mode==1? FindRandom(2,state.MaxTable): state.Mode); + *pb=FindRandom(2,state.TableEnd); + } + +LOCAL_C VOID SwitchStyle(INT style) + { + G_GC gc; + + gc.style=style; + gSetGC(0,G_GC_MASK_STYLE,&gc); + } + +LOCAL_C VOID *CreateEditor(VOID) + { + H_EDIT_BOX heb; + + heb.maxchars=4; + heb.vulen=30; + heb.pos.x=113; + heb.pos.y=53; + heb.win=MainWid; + heb.font=WS_FONT_BASE+9; + heb.style=G_STY_DOUBLE; + return(hEBOpen(H_EDIT_BOX_FONT,&heb)); + } + +LOCAL_C VOID ClearBottomArea(VOID) + { + P_RECT box; + + box.tl.x=4; + box.br.x=189-4; + box.tl.y=4+3*13; + box.br.y=100-4; + gClrRect(&box,G_TRMODE_CLR); + } + +LOCAL_C VOID Beep(VOID) + { + p_sound(-5,320); + } + +LOCAL_C VOID SelectAll(VOID *ebH) + { + hEBSetSelect(ebH,0,p_slen(hEBSenseText(ebH))); + } + +LOCAL_C INT SenseNumberTyped(VOID *ebH) + { + TEXT *pb; + WORD num; + + pb=hEBSenseText(ebH); + if (!*pb) + return(0); + p_stoi(&pb,&num); + return(num); + } + +LOCAL_C INT AddTextItem(TEXT *pmt,TEXT *pbod) + { + H_DI_TEXT txt; + TEXT buf[20]; + + txt.type=H_DTEXT_ALIGN_CENTRE; + uZTStoBCS(txt.str=(&buf[0]),pbod); + return(uAddDialogItem(H_DIALOG_TEXT,pmt,&txt)); + } + +LOCAL_C INT Complain(INT a,INT b,INT c) + { + TEXT buf[20]; + + if (uOpenDialog("Incorrect")) + return(-1); + p_atos(&buf[0],"%d \236 %d",a,b); + if (AddTextItem("The question",&buf[0])) + return(-1); + buf[p_itob(&buf[0],c)]=0; + if (AddTextItem("Your answer",&buf[0])) + return(-1); + if (uAddButtonList("Help",W_KEY_ESCAPE,"Retry",W_KEY_RETURN,NULL)) + return(-1); + if (uRunDialog()==W_KEY_RETURN) + return(0); + p_atos(&buf[0],"%d \236 %d = %d",a,b,a*b); + if (uOpenDialog(&buf[0])) + return(-1); + if (uAddButtonList("Continue",W_KEY_RETURN,NULL)) + return(-1); + uRunDialog(); + return(-1); + } + +LOCAL_C INT BadKey(INT k) + { + return(k<256 && p_isprint(k) && !p_isdigit(k)); + } + +LOCAL_C VOID CancelTimer(VOID) + { + if (timactive) + { + p_iow2(timH,P_FCANCEL); + p_waitstat(&timstat); + } + timactive=FALSE; + } + +LOCAL_C VOID QueueTimer(VOID) + { + CancelTimer(); + p_ioa4(timH,P_FRELATIVE,&timstat,&timint); + timactive=TRUE; + } + +LOCAL_C VOID InitialiseTimer(VOID) + { + if (state.Timing<=4) + { + timint=5; + timcount=2*state.Timing; + } + else + { + timint=10; + timcount=state.Timing; + } + timtotcnt=timcount; + QueueTimer(); + } + +LOCAL_C VOID GetBarChartRect(P_RECT *pbox) + { + pbox->tl.x=9; + pbox->br.x=180; + pbox->tl.y=82; + pbox->br.y=88; + } + +LOCAL_C VOID IncrementBarChart(VOID) + { + P_RECT box; + + timcount--; + GetBarChartRect(&box); + box.br.x=9+171*(timtotcnt-timcount)/timtotcnt; + gFillPattern(&box,WS_BITMAP_GREY,G_TRMODE_REPL); + } + +LOCAL_C VOID ClearBarChart(VOID) + { + P_RECT box; + + GetBarChartRect(&box); + gClrRect(&box,G_TRMODE_CLR); + } + +LOCAL_C VOID DisplayQuestion(VOID) + { + TEXT buf[30]; + WMSG_KEY key; + WORD keyactive; + WORD keystat; + P_RECT box; + VOID *ebH; + WORD a; + WORD b; + WORD c; + WORD ans; + + ebH=CreateEditor(); + if (!ebH) + return; + ClearBottomArea(); + hEBEmphasise(ebH,TRUE); + FindFactors(&a,&b); + ans=a*b; + p_atos(&buf[0],"%d \236 %d = ",a,b); + box.tl.x=53; + box.br.x=113; + box.tl.y=52; + box.br.y=52+22; + SwitchStyle(G_STY_DOUBLE); + gPrintBoxText(&box,20,G_TEXT_ALIGN_RIGHT,0,&buf[0],p_slen(&buf[0])); + SwitchStyle(G_STY_NORMAL); + box.tl.x=8; + box.br.x=189-8; + box.tl.y=81; + box.br.y=81+8; + gBorderRect(&box,W_BORD_CORNER_1); + DatLocked=TRUE; + state.Tested++; + keyactive=FALSE; + InitialiseTimer(); + FOREVER + { + if (keyactive) + wFlush(); + else + { + uGetKeyA(&keystat,&key); + keyactive=TRUE; + } + p_iowait(); + if (keystat==E_FILE_PENDING) + { + timactive=FALSE; + IncrementBarChart(); + if (!timcount) + { + wFlush(); + p_sleep(2); + goto CheckAnswer; + } + QueueTimer(); + continue; + } + keyactive=FALSE; + if (BadKey(key.keycode)) + Beep(); + else if (key.keycode!=W_KEY_RETURN) + hEBHandleKey(ebH,key.keycode,key.modifiers); + else + { + CheckAnswer: + c=SenseNumberTyped(ebH); + if (c==ans) + { + state.Correct++; + break; + } + Beep(); + hEBEmphasise(ebH,FALSE); + if (Complain(a,b,c)) + break; + DisplayScores(); + state.Tested++; + hEBEmphasise(ebH,TRUE); + SelectAll(ebH); + ClearBarChart(); + InitialiseTimer(); + } + } + DatLocked=FALSE; + hEBClose(ebH); + ClearBottomArea(); + DisplayPressButton(); + CancelTimer(); + } + +LOCAL_C VOID MakeButtonDance(VOID) + { + DrawButton(TRUE); + wFlush(); + p_sleep(2); + DrawButton(FALSE); + wFlush(); + p_sleep(2); + } + +LOCAL_C VOID DoTest(VOID) + { + MakeButtonDance(); + DisplayQuestion(); + DisplayScores(); + } + +LOCAL_C VOID MainLoop(VOID) + { + INT ret; + WMSG_KEY key; + + FOREVER + { + uGetKey(&key); + if (key.keycode&W_EVENT_KEY) + { + if (key.keycode==CONS_EVENT_COMMAND) + ExitApplication(); + } + else if (key.keycode&W_SPECIAL_KEY) + TryExecuteCommand(key.keycode&(~W_SPECIAL_KEY)); + else if (key.keycode==W_KEY_MENU && !(key.modifiers&W_CTRL_MODIFIER)) + { + ret=uPresentMenus(); + if (ret>0) + TryExecuteCommand(ret); + } + else if (key.keycode==W_KEY_RETURN) + DoTest(); + } + } + +LOCAL_C VOID ReadState(VOID) + { + INT len; + UBYTE buf[P_ENVMAX]; + + len=p_getenviron(EnvName,ENV_NAME_LEN,&buf[0]); + if (len<0 || len!=sizeof(TSTATE)) + return; + p_bcpy(&state,&buf[0],sizeof(TSTATE)); + } + +LOCAL_C VOID InitSeed(VOID) + { + seed=p_date(); + } + +LOCAL_C VOID ReduceScreenSize(VOID) + { + W_WINDATA wd; + + wd.extent.tl.x=wd.extent.tl.y=0; + wd.extent.width=189; + wd.extent.height=100; + wSetWindow(MainWid,W_WIN_EXTENT,&wd); + if (uErrorValue(wCheckPoint())) + p_exit(0); + } + +LOCAL_C VOID CreateGC(VOID) + { + INT hgc; + + hgc=gCreateGC0(uFindMainWid()); + if (hgc<0) + p_exit(hgc); + } + +LOCAL_C VOID SpecificInit(VOID) + { + uEscape(FALSE); + hCrackCommandLine(); + MainWid=uFindMainWid(); + ReduceScreenSize(); + CreateGC(); + gBorder(W_BORD_CORNER_4); + wsEnable(); + ReadState(); + Display(); + InitSeed(); + p_open(&timH,"TIM:",-1); + } + +GLREF_D UWORD _UseFullScreen; + +GLDEF_C VOID main(VOID) + { + _UseFullScreen=TRUE; + uCommonInit(); + SpecificInit(); + MainLoop(); + } diff --git a/code/SIBOSDK/wkdemo/tables.pr b/code/SIBOSDK/wkdemo/tables.pr new file mode 100644 index 0000000..408c49b --- /dev/null +++ b/code/SIBOSDK/wkdemo/tables.pr @@ -0,0 +1,6 @@ +#system epoc img +#set epocinit=iplib +#model small jpi +#compile %main +#pragma link(hwif.lib) +#link %main diff --git a/code/SIBOSDK/wkdemo/vid.bat b/code/SIBOSDK/wkdemo/vid.bat new file mode 100644 index 0000000..4ccb4d5 --- /dev/null +++ b/code/SIBOSDK/wkdemo/vid.bat @@ -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 + diff --git a/code/inventory/CONTINUATION.md b/code/inventory/CONTINUATION.md new file mode 100644 index 0000000..22d8d64 --- /dev/null +++ b/code/inventory/CONTINUATION.md @@ -0,0 +1,144 @@ +# Finishing the Workabout MX scanner — on-device continuation guide + +This document describes exactly how to continue from the current findings to a +fully working scanner client, using on-device debugging. Read `SCANNER-API.md` +first for the findings this builds on. + +## Where we are + +Established (see `SCANNER-API.md` for detail): +- The integral laser is driven as an **OO library object** in `SCANNER.DYL` + (category token seen in ROM: **`oscanner`**), *not* by raw device I/O. +- The app path is the standard OLIB one: `p_getlibh` → `p_newsend`/`f_newsend` + (create + init) → `p_send` (configure / trigger / read). +- Internals confirmed: `WL2:D` is the driver's channel; control ops **6** then + **7** (`p_iow(chan,6)`, `p_iow(chan,7)`) fire the laser to a good decode + (green LED) on the physical device. +- The decompiled read (`FUN_858d`) creates the object via `LIBMANAGER` + (`NMLIBCREATE`/`NMLIBCREATEBYHANDLE`), sets up a buffer, then reads; the + decode lands CR/LF-terminated (default Symbol2 postamble). + +Missing, and why on-device: the **message ordinals** and **parameter structs** +for the scanner's methods. OLIB assigns ordinals dynamically from the whole +class hierarchy (including base classes in `olib`/`hwim`), so they cannot be +read reliably from a static dump — but they resolve at runtime, where the +debugger can capture them. MAME cannot inject a barcode, so validation must be +on hardware anyway. + +## What to capture + +For a working client you need five things: +1. The scanner **category** (confirm the name/id for `p_getlibh` — candidate + `oscanner`). +2. The scanner **class** created by the app. +3. The **message ordinals** for: init, set-parameters, enable/trigger, read. +4. The **parameter/result structs** each message takes (esp. the read result + buffer and its length). +5. The exact **call sequence** the working app uses. + +## Tooling: the SIBO Debugger + +The SIBO Debugger (see manual `2-03`/`2-04`, "The SIBO Debugger") supports: +- **Remote debugging**: development PC connected to the Workabout by a serial + cable; debug up to 8 processes. +- **Breakpoints in dynamic libraries / shared code** — required to break inside + `SCANNER.DYL`. +- Single-step, trace, register and memory display. + +Build your own code for source-level debugging with: +``` +#pragma debug(vid=>full) /* in the .pr / source */ +``` +and produce the `.sym`/`.dbd` symbol files with EMAKE. + +### Set-up + +1. Connect the PC to the Workabout with a serial cable (PC serial ↔ Workabout + RS-232 port — note this is a *different* port from the barcode `TTY:D`). +2. Start the debugger on the PC and connect to the remote (Workabout) target + (Local/Remote CPU menu → Connect to Remote). +3. Have the Workabout ready to run either the ROM `DEMMAN.APP`/`SCANAPP` (for + Procedure A) or your test harness (Procedure B). + +## Procedure A — trace the working ROM app (recommended first) + +Goal: watch `DEMMAN`/`SCANAPP` drive the real scanner and record the ordinals. + +1. On the Workabout, start `DEMMAN` and enter its Scanner (Barcode) demo. +2. From the debugger, attach to that process and set breakpoints on the OLIB + dispatch path so you catch the object creation and messages: + - `LIBMANAGER` (`INT 0x84`) — sub-functions `NMLIBCREATE` (`AH=5`), + `NMLIBCREATEBYHANDLE` (`AH=6`): captures the category/class and the object + handle. + - `MESSMANAGER` (`INT 0x83`) — `NMMESSSEND` and the send/receive variants: + captures each message ordinal and its argument pointer. + - Optionally the `SCANNER.DYL` method handlers we identified (init dispatch, + trigger) as cross-checks. +3. For each captured call record: `AH`, the category/class in registers, the + message **ordinal**, and the pointed-to **argument struct** (dump memory at + the pointer). For the read, note where the decoded bytes land and the + returned length. +4. Trigger a real scan and record the read message and its result buffer. + +Result: the exact category, class, ordinals, param structs, and sequence. + +## Procedure B — iterate a C test harness + +Once Procedure A gives the ordinals (or to trial them), build a small OO client: + +```c +#include +#include + +/* Fill these from Procedure A (placeholders until captured): */ +#define SCAN_CATEGORY /* category id/handle for "oscanner" via p_getcat/p_getlibh */ +#define C_SCANNER /* the scanner class */ +#define O_SCAN_INIT /* init message ordinal */ +#define O_SCAN_PARAMS /* set-parameters ordinal */ +#define O_SCAN_READ /* read-a-barcode ordinal */ + +GLDEF_C INT main(VOID) +{ + VOID *lib, *scanner; + /* result/param structs per Procedure A */ + lib = p_getlibh(SCAN_CATEGORY); + scanner = p_newsend(SCAN_CATEGORY, C_SCANNER, O_SCAN_INIT, /*&initargs*/ 0); + /* configure Symbol2 + the default 11-byte param block: + 04 3f 01 15 06 04 1e 80 0d 0a 06 (CR/LF postamble) */ + p_send3(scanner, O_SCAN_PARAMS, /*¶ms*/ 0); + for (;;) { + /* send the read message; result is the decoded barcode, CR/LF-terminated */ + p_send3(scanner, O_SCAN_READ, /*&result*/ 0); + /* display result ... */ + } +} +``` + +Build with `#pragma debug(vid=>full)`, run under the debugger, single-step the +sends, and inspect return values / the result buffer. Adjust ordinals/structs +until a real scan returns the UPC. + +## Turning captures into the shipped reader + +- Replace `code/inventory/bcode.c` with the OO client: `bcodeOpen` does + `p_getlibh` + `p_newsend`(init) + params; `bcodeRead` does `p_send`(read) and + returns the decoded string (strip the CR/LF postamble; strip any preamble byte + `0x80` if present). +- `upc.c` (UPC-A check-digit validation) is unchanged and already correct. +- Cross-check the captured ordinals against the decompiled handlers in + `SCANNER-API.md` (`FUN_7ae3` init dispatch — decoder type at `[channel+10]`, + case 4 = Symbol; `FUN_7aa4` trigger = the `6`/`7` ops). + +## Validation + +- A valid UPC-A scan should return 12 digits (plus any pre/postamble), and + `upcIsValid` should pass. The default postamble is CR LF (`0x0d 0x0a`). +- Confirm repeated scans and clean shutdown (`p_send` a destroy/close message, + then `p_close` any channel). + +## Reproduce the RE environment (for further static/dynamic work) + +See `../mx-re/toolchain-and-plan.md`: MAME `psionwamx` (live trace/dasm), +radare2 (static), and Ghidra headless (decompilation of the DYLs). These remain +useful for reading further `SCANNER.DYL` methods, but the ordinals themselves +come from the on-device debugger as above. diff --git a/code/inventory/README.md b/code/inventory/README.md new file mode 100644 index 0000000..7404c2d --- /dev/null +++ b/code/inventory/README.md @@ -0,0 +1,63 @@ +# inventory + +A demo inventory application for the Psion Workabout MX: scan UPC barcodes, and +(Phase 2) keep stock counts in a database file, adding stock or consuming it by +scanning. + +Written in PLIB C, built with the TopSpeed compiler (`tsc /m scan`). + +## Phases + +- **Phase 1 (current): scan and validate.** Read UPC barcodes from the integral + laser and display them. + Modules: `upc` (validation), `bcode` (scanner input), `scan` (the demo). +- **Phase 2 (next): inventory database.** A DBF file keyed on UPC holding a + quantity and a name. Scan to add stock, scan to consume by a quantity unit. + Built on the SIBO `Dbf*` API (`p_dbf.h`). + +## Build + +``` +tsc /m scan +``` + +Produces `scan.img`. `scan.pr` compiles `upc.c`, `bcode.c`, `scan.c` and links +`scan.img`. + +## How the scanner is read (important) + +The Workabout MX integral laser is an **undecoded (HHLC)** scanner: it emits a +raw bar/space signal, not decoded ASCII. The hardware serial decoder in the +RS232/Barcode module handles only wands and wand-emulation scanners — the HC +guide explicitly lists "Undecoded Laser Scanner (HHLC)" as **unsupported** there. +That is why reading `TTY:D` directly returned nothing even though the laser's +own good-read LED lit. + +The decode is done in **software** by a barcode decoder LDD. The SDK ships +several in `\SIBOSDK\LIB`; each registers the device `BAR:`: + +| LDD | Symbology | +| --- | --- | +| `BAREAN.LDD` | EAN / **UPC** | +| `BARC39.LDD` | Code 39 | +| `BAR128.LDD` | Code 128 | +| `BARITF.LDD` | Interleaved 2 of 5 | +| `BARMPLES.LDD` | MSI Plessey | +| `BARRAW.LDD` | raw / undecoded | + +So the flow is: `p_loadldd("BAREAN")` → `p_open("BAR:")` → read decoded +barcodes. **`BAREAN.LDD` must be present on the device** for `p_loadldd` to find +it (copy it from `\SIBOSDK\LIB`, or load it via the system config). + +The current build is a **diagnostic**: it dumps every byte of each read +(`n=: ""`) so the exact decoded format — length, +any type/prefix byte, terminator — can be confirmed before the reader and the +Phase 2 database key are finalised. + +## The `BAR:` read protocol + +The precise read semantics of `BAR:` (data format, any symbology configuration +via escape sequences) live in the I/O Devices Reference manual, which is not +among the committed docs. The diagnostic build exists to establish that format +empirically. Once a scan prints, the reader (terminator handling, UPC +validation via `upc.c`) and Phase 2 follow. diff --git a/code/inventory/SCANNER-API.md b/code/inventory/SCANNER-API.md new file mode 100644 index 0000000..c9f21f2 --- /dev/null +++ b/code/inventory/SCANNER-API.md @@ -0,0 +1,263 @@ +# Workabout MX barcode scanner — API notes (reverse-engineered) + +There is no official SDK documentation for the Workabout MX integral laser scanner. +The Psion SIBO C SDK and I/O Devices Reference predate the MX and describe only the +older *external* barcode modules (wands / wand-emulation), not the integral laser. +These notes are reverse-engineered from device behaviour and from the Workabout MX +ROM `w2mx_v7.20f_eng.bin` (strings), so treat unconfirmed items as such. + +## Hardware + +- Integral **laser** scanner, Symbol engine. The demo (`DEMMAN.APP`) reports + `Type: Laser 1223` (some units `1222`). +- It is a **decoded** scanner: it decodes in hardware and lights a green good-read + LED. It does **not** emit an undecoded (HHLC) signal. +- Trigger: the keyboard **scan key**, which the Window Server reports as key + code **368**. The key alone does not fire the laser from an arbitrary app; the + scanner software arms/reads the engine. + +## Device driver and ports + +`LLDEV` on the device lists a logical driver **`wl2`** (`units=1`). The scanner is +reached through this driver. The demo's "Select Scanner" screen lets you pick both +a **decoder type** and a **port** (device driver + unit letter): + +- Port device drivers offered: **`TTY`**, **`WLS`**, **`WL2`**. + The MX integral laser uses **`WL2`**. +- Units seen in the ROM: **`WL2:A`** and **`WL2:D`**. + +Decoder types (from the demo, "chosen from those used in standard Workabout +products"): + +| Decoder | Meaning | +| --- | --- | +| `Generic` | External non-configurable reader | +| `Symbol1` | Workabout standard scanner | +| `Datalogic` | Workabout CCD | +| `HP` | Workabout Wand | +| **`Symbol2`** | **Workabout MX scanner (the integral laser)** | + +## Opening the device + +```c +VOID *h; +INT err = p_open(&h, "WL2:D", (UINT)-1); +``` + +Observed results: + +| Call | Result | Meaning | +| --- | --- | --- | +| `p_open("WL2:D", -1)` | `0` | **opens** — this is the integral-laser unit | +| `p_open("WL2:A", -1)` | `-9` (`E_GEN_INUSE`) | in use — held by the resident scanner software | +| `p_open("WL2:B" / ":C")` | (untested) | — | + +`WL2` has a single unit, so only one process may hold it. `WL2:A` is permanently +`-9` even with the demo closed, indicating a resident holder; `WL2:D` is the unit +an application opens. + +## The 11-byte parameter block + +The scanner is configured by an **eleven-byte parameter block**. The application +interprets these bytes and converts them into commands for the selected decoder +(so the same block means different wire commands for `Symbol2` vs `HP`, etc.): + +| Byte | Parameter | +| --- | --- | +| Param0 | Decode security | +| Param1 | Code type (symbology select) | +| Param2 | Decode options A | +| Param3 | Decode options B | +| Param4 | General parameters | +| Param5 | ITF length 1 | +| Param6 | ITF length 2 | +| Param7 | Preamble | +| Param8 | Postamble byte 1 | +| Param9 | Postamble byte 2 | +| Param10 | General decode options | + +The preamble/postamble bytes mean decoded output may carry configurable leading / +trailing characters — parsing code must account for them. + +## Access model + +Applications do not drive `WL2` byte-by-byte themselves; they use the ROM library +**`SCANNER.DYL`** (used by `SCANAPP.APP` and `DEMMAN.APP`). That library opens the +port, converts the 11-byte block to decoder commands, configures and enables the +engine, and returns decoded scans. + +## Paths that do NOT work for the integral laser + +Recorded so they are not retried: + +- **`bar*.ldd` decoders (`BAREAN`, `BARC39`, …) + `BAR:` device.** These are + software decoders for the *external* wand modules. Loading `BAREAN.LDD` and + opening `BAR:A`/`BAR:B` returns `-41` (`E_FILE_DEVICE`, "no interface found in + slot") — the integral laser is not a `BAR:` expansion interface. `BAR:D`/`BAR:E` + return `-38` (`E_FILE_NAME`, invalid unit). +- **`TTY:D` serial reads.** Opening `TTY:D` powers the laser (it fires briefly), + but no decoded bytes ever arrive on the serial channel — not with default + config, not after `P_FSET` to 9600/8/1, not with `P_OBEY_DSR` cleared, not with + the intelligent-reader escape commands (`-y1J` / `-y1K`), not reading + one byte at a time. The integral laser's decoded data is not on `TTY:D`. + +## Initialisation sequence (reverse-engineered from the ROM) + +Opening `WL2:D` is not enough — the scanner must be configured and enabled first. +The sequence was recovered by disassembling `SCANNER.DYL` in the v7.20f ROM +(around file offset `0xD7AA4`). It uses the SIBO I/O executive **`int 0xCF`**, +whose convention here is: **`CL` = I/O function code, `BX` = channel handle, +`DX` = argument (by value)**, result in `AX`. From C this is the `p_iow(chan, +func, ...)` layer. + +Function codes observed on the `WL2` channel (from `p_file.h`, plus WL2-specific +ones above the standard range): + +| CL | Meaning | +| --- | --- | +| 6 | (`P_FDETACH` slot) used as a scanner enable/control op | +| 7 | (`P_FSET`) used as a scanner enable/control op | +| 8 | `P_FSENSE` | +| 9 | `P_FFLUSH` | +| 0x0C (12) | **WL2-specific: write a config/command byte** (byte passed in `DX`) | + +The driver keeps a per-channel structure; the param block sits at **channel+4**, +with the **decoder type at offset +6** (dispatch values 1..4) and the **11-byte +parameter block at +8..+0x12**. Configuration is pushed to the engine as a series +of `cl=0x0C` writes (one command byte per call in `DX`), then enable ops +(`cl=6`, `cl=7`). + +### Default Symbol2 parameter block (from the ROM) + +The routine at `0xD7AB3` fills the 11-byte block with these defaults for the +Workabout MX (Symbol2) scanner: + +| Byte | Param | Value | +| --- | --- | --- | +| +8 | Param0 Decode security | `0x04` | +| +9 | Param1 Code type | `0x3F` (all symbologies) | +| +0xA| Param2 Decode options A | `0x01` | +| +0xB| Param3 Decode options B | `0x15` | +| +0xC| Param4 General params | `0x06` | +| +0xD| Param5 ITF length 1 | `0x04` | +| +0xE| Param6 ITF length 2 | `0x1E` | +| +0xF| Param7 Preamble | `0x80` | +| +0x10| Param8 Postamble 1 | `0x0D` (CR) | +| +0x11| Param9 Postamble 2 | `0x0A` (LF) | +| +0x12| Param10 General decode | `0x06` | + +So **decoded output is terminated by CR LF** (`0x0D 0x0A`), and Code type `0x3F` +enables all symbologies (UPC included). A reader should assemble bytes until +CR/LF and strip the preamble/postamble. + +### Confirmed on-device + +- `p_open(&h, "WL2:D", -1)` returns `0`. +- Issuing control ops **6 then 7** on the channel (`p_iow(h, 6)`, `p_iow(h, 7)`) + **triggers a scan**: the laser fires and decodes (green good-read LED). This is + reproducible. The trigger is one-shot — it must be re-issued for each scan. + +### NOT yet solved: retrieving the decoded data + +After a confirmed good read, the decoded barcode could **not** be retrieved from +the `WL2:D` channel by any tried method: + +- `p_iow(h, P_FREAD, buf)` (count-in-`buf[0]` style) — no data. +- `p_read(h, buf, len)` (synchronous, with length) — no data. +- `p_ioc(h, P_FREAD, &stat, buf, &len)` + trigger + `p_iowait()` (async) — no data. + +The retrieval logic in `SCANNER.DYL`/`SCANAPP` fetches the decoded data on a +**separate handle** (a driver global, e.g. `[0x13b5]`) obtained through +**OS-service stubs** of the form `mov ah,N; int 0x84/0x85/0x86/0x87; ret` — not a +plain `P_FREAD` on the `WL2:D` control channel. This resolves an earlier puzzle: +the SIBO executive uses **different register conventions per interrupt vector** — +the `int 0x84` service family passes the function in `AH`, whereas the `int 0xCF` +I/O executive uses `CL`. + +`SCANNER.DYL` is an **object-oriented ROM library (a DYL)**. This strongly +suggests the scanner is driven by **creating a scanner object and sending it +messages** (the OLIB/OO model), not by raw device I/O on `WL2:D`. That would +explain why every raw `WL2:D` read returned no data — wrong paradigm. + +**Confirmed working on device:** `p_open("WL2:D")` + control ops `6` then `7` +trigger the laser and a good decode (green LED). Only *retrieving* the decoded +bytes is unsolved. + +### Decompilation (Ghidra) — the read path + +`SCANNER.DYL`/`SCANAPP` decompile cleanly in Ghidra (16-bit real-mode x86). The +app-level read routine (`FUN_858d`) is: + +```c +obj->flags |= 8; +obj->[0x190] = 0; +FUN_8ce8(); FUN_8cd3(); FUN_8cd3(); // pre-read setup +obj->[0x194] = FUN_8d8e(); // acquire a read handle (int 0x84) +obj->[0x192] = FUN_8c8b(0,2,1,obj); // set up the read buffer (int 0x84; int 0xd2) +swi(0xcf)(); swi(0xcf)(); // config / enable ops on the channel +if (obj->[0x196] == 0) + obj->[0x196] = swi(0xcf)(); // P_FREAD -> decoded result stored at +0x196 +else + swi(0xcf)(); // P_FCANCEL +``` + +The decoder-side helpers also decompile clearly: `FUN_7ae3` is the per-decoder +init (dispatch on `[channel+10]`; case 4 = the Symbol path, which calls +`FUN_6dc4` to build the `0xff 0xee …` command frame and writes the 11-byte param +block); `FUN_7aa4` is the trigger (two `int 0xCF` ops = the `6`/`7` we use). + +### The scanner is an OO library object (paradigm correction) + +The System Services vector table names the services: **`int 0x84` = `LIBMANAGER`** +(the Library Manager) and **`int 0x83` = `MESSMANAGER`** (object messaging). +`LIBMANAGER` sub-functions (in `AH`) are `NMLIBLOAD=0, UNLOAD=1, LINK, FIND, +HANDLE, CREATE(=5), CREATEBYHANDLE(=6), …`. So the read's `FUN_8d8e`/`FUN_8c8b` +call **`NMLIBCREATE` / `NMLIBCREATEBYHANDLE`** — they *create a scanner library +object*. + +**Therefore the scanner is driven as an object-oriented library object, not by +device I/O.** `WL2:D` is what `SCANNER.DYL` opens and reads *internally*; an +application never `p_open`/`p_read`s it. Every earlier raw-device attempt was the +wrong paradigm — which is why they returned nothing. + +The correct C approach uses the standard OO API (the same one the SDK's +`growbar.c` demo uses): +- `p_getlibh(category)` — get the library handle for a category. +- `p_newsend` / `f_newsend(category, class, O_..._INIT, &args)` — create the + scanner object and send its init message. +- `p_send2` / `p_send3(obj, O_...)` — send it messages (configure, trigger, read). + +These C wrappers sit over `LIBMANAGER` (create/handle) and `MESSMANAGER` (send). + +**Next RE target (well-defined):** extract from `SCANNER.DYL` its **category id** +(candidate token in ROM: **`oscanner`**), **class**, and the **message ordinals** +(`O_...`) for init / set-params / trigger / read, plus their parameter structs. +OLIB assigns ordinals dynamically from the whole class hierarchy (base classes in +`olib`/`hwim`), so they resolve at runtime rather than in a static dump — capture +them with the **SIBO Debugger**, which supports remote debugging (PC↔device over +serial) and **breakpoints inside dynamic libraries**. With those, a C client can +create the scanner object and message it. Validation requires the physical device +(MAME cannot inject a scan). + +**See [`CONTINUATION.md`](CONTINUATION.md)** for the full on-device debugging +procedure (capture the category/ordinals/params via `LIBMANAGER`/`MESSMANAGER` +breakpoints), a C test-harness template, and how to turn the captures into the +shipped reader. + +To close it, one of: +1. The **Workabout MX C SDK** `SCANNER.DYL` header / OO category definition (what + `SCANAPP` was built against) — the clean answer, and likely the only practical + one, because the interface is object-oriented. +2. A deep RE effort under MAME (`psionwamx`): automate the UI to launch `SCANAPP`, + breakpoint the read routine, and trace it. Caveats: MAME cannot inject a real + barcode (no laser input), so only the read *setup* is observable in emulation; + the reconstructed sequence must still be validated on the physical device. + +## Error codes seen (from `epocdefs.h`) + +| Value | Name | Meaning | +| --- | --- | --- | +| `-9` | `E_GEN_INUSE` | device already open / in use | +| `-32` | `E_FILE_EXIST` | (LDD) already loaded | +| `-38` | `E_FILE_NAME` | invalid device name / unit | +| `-41` | `E_FILE_DEVICE` | device / interface not present | diff --git a/code/inventory/bcode.c b/code/inventory/bcode.c new file mode 100644 index 0000000..d03c254 --- /dev/null +++ b/code/inventory/bcode.c @@ -0,0 +1,30 @@ +/* + * bcode.c - barcode scanner input via the software decoder LDD (see bcode.h). + */ +#include "bcode.h" + +GLDEF_C INT bcodeLoad(VOID) +{ + /* + * Load the EAN/UPC decoder LDD. p_loadldd assumes a .LDD extension, and + * looks along the current path if no full path is given, so BAREAN.LDD + * must be present on the device. If the system already loaded it (e.g. via + * config), this returns E_FILE_EXIST, which the caller treats as success. + */ + return p_loadldd(BCODE_LDD); +} + +GLDEF_C INT bcodeOpen(VOID **pChan) +{ + /* + * Open the decoder device. Opening it powers and enables the scanner; the + * LDD decodes the raw laser signal and delivers decoded barcodes on reads. + */ + return p_open(pChan, BCODE_DEV, (UINT)-1); +} + +GLDEF_C VOID bcodeClose(VOID *chan) +{ + if (chan != NULL) + p_close(chan); +} diff --git a/code/inventory/bcode.h b/code/inventory/bcode.h new file mode 100644 index 0000000..057841f --- /dev/null +++ b/code/inventory/bcode.h @@ -0,0 +1,48 @@ +/* + * bcode.h - barcode scanner input on the Workabout MX (integral laser). + * + * The Workabout MX integral laser is an UNDECODED (HHLC) scanner: it emits a + * raw bar/space signal, not decoded ASCII. The hardware serial decoder in the + * RS232/Barcode module only handles wands and wand-emulation scanners (the HC + * guide lists "Undecoded Laser Scanner (HHLC)" as unsupported there), which is + * why reading TTY:D directly yielded nothing even though the laser's own + * good-read LED lit. + * + * The decode is instead done in software by a barcode decoder LDD. The SDK + * ships several (\SIBOSDK\LIB): BAREAN (EAN/UPC), BARC39, BAR128, BARITF, + * BARMPLES, BARRAW. Each registers the device "BAR:". For UPC we load BAREAN. + * + * Usage: bcodeLoad() once, then bcodeOpen() to get a channel, then read it. + * The BAREAN.LDD file must be present on the device so p_loadldd can find it. + */ +#ifndef BCODE_H +#define BCODE_H + +#include + +/* Decoder LDD to load (BAREAN.LDD = EAN/UPC) and the device it registers. + Full path: p_loadldd searches only the current path for a bare name, and the + System screen's current path is not necessarily where SCAN.IMG lives. The + .LDD extension is appended automatically. Change this if you move the file. */ +#define BCODE_LDD "M:\\IMG\\BAREAN" +#define BCODE_DEV "BAR:" + +/* Longest decoded barcode we handle (UPC-A is 12; headroom for EAN/supplements). */ +#define BCODE_MAXLEN 24 + +/* + * Load the UPC/EAN decoder LDD. Returns 0 if loaded, or a negative PLIB error. + * E_FILE_EXIST (already loaded) is treated as success by callers. + */ +GLREF_C INT bcodeLoad(VOID); + +/* + * Open a channel to the barcode decoder device (BAR:). Stores it in *pChan. + * Returns 0 on success or a negative PLIB error. + */ +GLREF_C INT bcodeOpen(VOID **pChan); + +/* Close a channel opened by bcodeOpen. Safe to call with NULL. */ +GLREF_C VOID bcodeClose(VOID *chan); + +#endif /* BCODE_H */ diff --git a/code/inventory/scan.c b/code/inventory/scan.c new file mode 100644 index 0000000..c7b6a92 --- /dev/null +++ b/code/inventory/scan.c @@ -0,0 +1,60 @@ +/* + * scan.c - Phase 1: WL2:D scanner, asynchronous read (reverse-engineered). + * + * Confirmed: opening WL2:D and issuing control ops 6/7 triggers a scan (laser + * fires, green LED). Neither synchronous read form returned data, and SCANAPP + * in the ROM uses an async pattern (post read -> P_FREAD -> P_FCANCEL). So this + * posts an asynchronous read (p_ioc), triggers the scan (ops 6/7), then waits + * for completion (p_iowait). Decoded output is CR/LF-terminated. + */ +#include + +#define WL2_TRIG1 6 +#define WL2_TRIG2 7 + +GLDEF_C INT main(VOID) +{ + VOID *chan; + UBYTE buf[256]; + WORD stat; + UWORD len; + INT err, i; + + err = p_open(&chan, "WL2:D", (UINT)-1); + p_printf("open WL2:D: %d\n", err); + if (err < 0) { + p_printf("Press a key to exit.\n"); + p_getch(); + return 1; + } + + p_printf("Present a barcode under the laser. Async reads:\n\n"); + + for (;;) { + len = sizeof(buf); + stat = E_FILE_PENDING; + p_ioc(chan, P_FREAD, &stat, buf, &len); /* post async read */ + + p_iow(chan, WL2_TRIG1); /* trigger the scan */ + p_iow(chan, WL2_TRIG2); + + p_iowait(); /* wait for a completion */ + + if (stat == E_FILE_PENDING) { /* our read didn't finish */ + p_iow(chan, P_FCANCEL); + p_waitstat(&stat); + continue; + } + if (stat < 0) { + p_printf("stat %d\n", stat); + continue; + } + p_printf("len=%d:", len); + for (i = 0; i < 40 && i < 256; i++) + p_printf(" %d", buf[i]); + p_printf(" \""); + for (i = 0; i < 40 && i < 256; i++) + p_putch(buf[i] >= ' ' ? buf[i] : '.'); + p_printf("\"\n"); + } +} diff --git a/code/inventory/scan.pr b/code/inventory/scan.pr new file mode 100644 index 0000000..e01c5cb --- /dev/null +++ b/code/inventory/scan.pr @@ -0,0 +1,8 @@ +#system epoc img +#set epocinit=iplib +#model small jpi + +#compile upc +#compile bcode +#compile scan +#link scan diff --git a/code/inventory/upc.c b/code/inventory/upc.c new file mode 100644 index 0000000..fb922e5 --- /dev/null +++ b/code/inventory/upc.c @@ -0,0 +1,54 @@ +/* + * upc.c - UPC-A validation. + * + * A UPC-A barcode is 12 digits. The last digit is a mod-10 checksum over the + * first 11: digits in odd positions (1,3,5,7,9,11) are weighted x3 and digits + * in even positions (2,4,6,8,10) x1; the check digit is whatever makes the + * weighted total a multiple of 10. + */ +#include "upc.h" + +static int allDigits(const char *s, int n) +{ + int i; + for (i = 0; i < n; i++) { + if (s[i] < '0' || s[i] > '9') + return 0; + } + return 1; +} + +int upcCheckDigit(const char *s) +{ + int i, sum = 0; + + if (!allDigits(s, 11)) + return -1; + + for (i = 0; i < 11; i++) { + int d = s[i] - '0'; + if ((i % 2) == 0) /* 0-based even index = 1st,3rd,... digit: weight 3 */ + sum += 3 * d; + else + sum += d; + } + return (10 - (sum % 10)) % 10; +} + +int upcIsValid(const char *s) +{ + int n = 0; + int check; + + while (s[n] != '\0') + n++; + if (n != UPC_A_LEN) + return 0; + if (!allDigits(s, UPC_A_LEN)) + return 0; + + check = upcCheckDigit(s); + if (check < 0) + return 0; + return (s[11] - '0') == check; +} diff --git a/code/inventory/upc.h b/code/inventory/upc.h new file mode 100644 index 0000000..c215276 --- /dev/null +++ b/code/inventory/upc.h @@ -0,0 +1,24 @@ +/* + * upc.h - UPC-A barcode validation. + * + * Pure C, no SIBO/PLIB dependencies, so it can be unit-tested on any host + * compiler as well as built for the Workabout. + */ +#ifndef UPC_H +#define UPC_H + +#define UPC_A_LEN 12 + +/* + * Returns 1 if s is a valid 12-digit UPC-A (all digits and a correct + * check digit), 0 otherwise. s must be NUL-terminated. + */ +int upcIsValid(const char *s); + +/* + * Returns the UPC-A check digit (0-9) computed from the first 11 digits + * of s, or -1 if those 11 characters are not all digits. + */ +int upcCheckDigit(const char *s); + +#endif /* UPC_H */ diff --git a/docs/2-01 PLIB Reference 2.30_djvu.txt b/docs/2-01 PLIB Reference 2.30_djvu.txt new file mode 100755 index 0000000..143c93d --- /dev/null +++ b/docs/2-01 PLIB Reference 2.30_djvu.txt @@ -0,0 +1,24890 @@ +SIBO 'C' Software Development Kit + + +PLIB REFERENCE + + +Version 2.30 + + +March 1, 1999 + + +(C) Copyright Psion PLC 1990-98 + + +All rights reserved. This manual and the programs referred to herein are copyrighted works of Psion PLC, +London, England. Reproduction in whole or in part, including utilization in machines capable of +reproduction or retrieval, without express written permission of Psion PLC, is prohibited. Reverse +engineering is also prohibited. + + +The information in this document is subject to change without notice. + + +Psion and the Psion logo are registered trademarks, and Psion, Psion MC, Psion HC, Psion Series 3, Psion +Series 3a, Psion Series 3c, Psion Siena and Psion Workabout are trademarks of Psion PLC. + + +TopSpeed is a registered trademark of Clarion Software Corporation. Intel 8086 and 80286 are registered +trademarks of Intel Corporation. IBM, IBM XT and IBM AT are registered trademarks of International +Business Machines Corp. Microsoft and MS-DOS are registered trademarks of Microsoft Corporation. +Apple and Macintosh are registered trademarks of Apple Computer Inc. VAX and VMS are registered +trademarks of Digital Equipment Corporation. Brief is a registered trademark of Underware Inc. Psion +PLC acknowledges that some other names referred to are registered trademarks. + + +Contents + + +1 Introduction...............scccscscssscrsscrsceseserseesessessseesssesseeeseesseesseesseesseesseessesscsesceessesscesscessessaeeseees 1-1 +PLIB, SIBO and: EPO eihcne sca .ansaunedehsanuedons aoaddthecaaltineehe 1-1 +The SIBO architecture::.:2.: sts2iess a Aleit: eters ede keene kt 1-1 +The: BPOG ‘operating: systerin.s..cescr)iccstasstisastesicctapatasscanddsisteanassicuss gauss agagenstiauaens 1-2 +The EPOC programming CnvirOnMent .......... ce eeeesceceseeceseeeeseeesseecsaeecseecseecesaeeesaeeesaeers 1-2 +Small: programming Model s,s. i255: 3eshesscstiessdacieas asides, dapbestoussbers esdisi aspen Aeedios Ad 1-2 +Hardware protect oni.ssii.sis: cessing ies Pexvs Poss tavshea avis est Seevased stung sas ideosdea deehe reel devsceupabesee dey 1-3 +More about memory moving and the 8086 segment registers...........eeeeeeeeeeneeeeeees 1-3 +The Clarion TopSpeed C compiler ...........cecceesccesseeceseeesseecesaeeesseecsaeecseeesneesssaeeesaes 1-4 +SYSLEM:SELVICES ssshe18 ccd Soap esidephie Asphials todos etiesieioindarhadietiadaehatddeisdaehis: 1-4 +PLIB Header! files s2i sss es covstaess oa ius foistness Oasis cote teossids Ban peetaess Ts hia Aateestos Rana ave 1-4 +PSU Biz: scasss cic vetoes csuczeiovstas vet aueahvovasiassc ssaginneeanaavee cane sisaeanaanas shagsuseeanaceageasasuigestases’ 1-5 +Callins conventions scs.s:ic15: Sstiothascii eet iotiows Sibi sthctosss oa ieiaciossesehilaedieseniieres 1-6 +Small proprawms sss vs.ssss lapivossesdbeed seabed sesh dacs sesesees ovsa sees sesv sues sustoese deavoassouatbase nesweeee AS 1-7 +The PLIB C startup modules 20.0.0... ceececesecsseeceseeeesaeecseecseeceseeessseessaeersneeesseeeesaes 1-7 +Related -teference: marital §:1s..s:::sccsndasstesssccassatlavetesbeceassnndauteestea ansendaicasteieatendaneestea isin: 1-8 +TopSpeed C library reference ........ eee eeeeeeceesseecsseecsseecsseecesceeesaeecsacecsseessseeeesaeeesaeers 1-8 +Window server reference :.:/:s.0 hahaha siderite ii 1-9 +W/O devices teferen Ce: 25.5 cis: eotstevss st: Find eotstavss batyek ets thors baths beiateese ds hibsaiteesiatsiredetes 1-9 +EPOC O/S System Services reference Manual...........eeeeeseeesseeceseeeesteeeseessneeeeteeeesaes 1-9 +Object dynamiclibraries y..:2.:) Asch elcid es aed ee eg eed a Love 1-10 +2 Characters, Strings and Buffers ................ccsssccssssssccsscsscssscscesssscesssscssesssscssessssessesssssessssees 2-1 +General string and buffer fUNCtIONS 00.0.0... ee eee eeseeceneeeeteecesaeeesaeecsaeecsseeseeecesaeeesaeeesaeers 2-1 +Copy memory to Memory (P_DCPY)..........eeeceeeesseecesseeeceeseeesessseeeseseeeeseseeesesseeeees 2-1 +Return string length (p_slen)............ccscccecsssscceeeecceeeesneeceeseaeeeceseaeeeeeeeaeeeeesneeeeeeneeeees 2-1 +Copy a: Stlin' © (Pe2SCpy,) cu. sess scagsset tea pbeouetey oes seca detboeg sdauevey bet hte ocaneyh pact ide poteaenbepeteeyy 2-1 +Copy multiple strings (P_SCPyM) ...........:ceseccseseecsseecsseeesseecesseeesaeecsaeecseeesseeeesaeessaeees 2-2 +Concatenate two Strings (P_SCat) .......eeeeeeeeesneessneeceseeesseeceseeeesseecseecseeceseeeesaeessaeers 2-2 +Concatenate many strings (P_SCAtM) ......... sees eeeseecsseeesseeeeseeeesneecsaeecsseeesseeeesaeersaeers 2-2 +Replicate a buffer (p_brep) .0..........ccceeeeecceeesneceeeseneeeessneeeeeeaeeeeesnaeeeceeneeeeessneeeeeeeeeeess 2-2 +Replicate a string (p2srep) se.vsieccaece.ciesyseeecaigtesecovsees Digi desovdevsgapdeb begaeoeebidepeel beanies 2-3 +Swap two buffers (p_Ds wap) ..........s:ccsssccssecsscecsseeceseeeesaeecsseecseeesseecssaeeesaeesseesseeeses 2-3 +Fill a buffer with a value (p_Dfil) 0.0.00... eeeccccceeencceeesneeeeeeeeeeeceseaeeeeesneeeeeesneeeessnaeeeess 2-3 +Ali gtisbutter: (psjtob) ssn: seccscocscevssce cou pbeesetey ote cue suet btes adthaveg beep sdhy oannest poekt ede podeaeeopanthees 2-3 +Generate the CRC number (p_crc)..........ccsssccccessnceecesnceeeeeeeeeeessneeeeseneeeeessneeeeseeeeeess 2-4 +Character classification and COMVELSION...........::cescccesceecesseecssceceseeeesaeecsaeecsaeecsseeeesaeeeeaeers 2-4 +Test for upper case character (P_iSUPPeT)...........ceeeeseeesseceseeeesseecseecsneeceseeeesaeessaeers 2-5 +Test for lower case character (p_1slOWeL) ............::ccceseeeceeeeeneeeeeeeeeeceeneeeecesteeeeesneeeess 2-5 +Test for alphabetic character (p_isalpha) ...........ceseeseeeeseeceseceseeceeeceseeceseeeesaeeesaeers 2-6 +Test for numeric digit (p_isdigit)....... eels eesecsseecsseeesseeceseeeesseecsseecseeseseeeesaeessaeers 2-6 +Test for alphanumeric character (p_isalnUmM).............c:eeeeeeeseeeeseecsneecsseeeeseeeesaeessneers 2-6 +Test for hexadecimal digit (p_isxdiQit) 0.0.0... eee eeseeeseeceseeceseeeseecseessseessseeeesaeessneers 2-6 +Test for whitespace character (Pp_1SSPace) .........eeseeeseeeeseecesseeeseecsaceceeeseseeeesaeessaeers 2-6 +Test for control character (p_iscntr]) ..........c:ccceeesceceeseceeeeesneeeeeesaceeeeeneeeeeneneeeeeeneeeees 2-6 +Test for punctuation character (p_iSpUNCt)..........eseeeseeesseeceseeeseecseecseeeeseeeesaeersaeers 2-6 +Test for printable graphic character (p_isgraph) .............s:cessseesseecsseeceseeceseeeesaeereaeers 2-6 +Test for printable character (P_iSPrint) .0....... ee eeseeeseceseeceseeeesaeecseecseeesseeeesaeessaeers 2-6 +Skip whitespace characters (p_Skipwh) ......cccccccccsscecsssecsscecesseeesseecsneessseeceseeeesaeeesneess 2-7 +Skip non-whitespace characters (p_Skipch)............sscsessecsseecsseeeeseeceseeeesseesseessneeeees 2-7 +Fold a character (p_tofld) ..0.......:.:cceesscceesescceeeeeneeeceeneeeeeseaeeeceseneeeesenneeeeseneeeesseneeeess 2-7 +Copy string with fold (p_Scpyf) ........eeeeeseessneeesseecsseecsseecesaeeesseecsaeecseeceseeeesaeeesaeers 2-7 +Fold ‘string (p USCOnf): 2. ssc. tt en oan eiet dees bithak eid cecal acckaeeeidide cucaeshoweeitibede tact sae 2-7 +Convert character to upper Case (P_tOUPPeP)......... eee ee eeeeeeceeseeeeeeeseeeeeeseeeeeenaeeeees 2-7 + + +Convert character to lower case (p_tolOWe?) ...........ceeeeesseeeeceeeeeesenneeeeceeeeeessneeeeeeeeeees 2-8 + + +PLIB REFERENCE + + +Capitalise string (P_SCap) .......eeseescecssceceseeeesseecsseecescecsseecesaecesseecsseecseessseeeesaeeesaeers 2-8 +SPINS COMMParISON Ger scse2.cesen gst ook, hot Shea etek Uoeist one sig oa Yaeek shes ited Taest oae Oe tant canes ak 2-8 +Compare two buffers (p_DCMp)..........cscceseecssseessseecsneeceseecesaeeesseecsaeecseessseeeesaeeesaeers 2-8 +Compare two Strings (P_SCMP) ........:eeseceeseecesseessseeceseecsseecesaeeesaeecsaeecseeceseeeesaeeeeaeers 2-9 +Case independent buffer compare (p_DCMP Ii) ...........eeeeeeeeceesecesseeceneeeseeseseeeesaeersaeers 2-9 +Case independent string compare (P_SCMP1)............esecesseccesseeeseecsneecsteeeeseeeesaeeesaeers 2-9 +String Searchin .sisi.sai sek dise tetera nl soared ates wei nel anavainbi autagineta. 2-10 +Locate byte in buffer (pP_DIOC) ...... eee eeeeeeesneeceneecsseeceseeceseecesaeecsaeecseecesaeeesaeessaeers 2-10 +Locate character in string (P_SIOC).........eeecceesseeeseecsseeeeseecesseeesaeecsaeecseeesseeeesaeeesaeers 2-10 +Case independent locate character in buffer (p_bIOCi) ....... eee eee eeeeeeeseeeeseeeeeeeeneers 2-10 +Case independent locate character in string (P_S]OC1).........eeeeeeseeeseeeseeeeseeeeeeeeeeneers 2-10 +Locate last matching character in a string (P_SIOCT) ............::cceeeeseeeeeeeeeeeeeneeeeeseeeeees 2-11 +Locate last matching folded character in a string (p_SIOCT1) ............cceeesceeeeeeeeeeeteeeees 2-11 +Locate sub-buffer in buffer (p_bsub) ...............cceeecsceeeesceeeeeeeeeeeesneeeeeeeaeeecseneeeesseeeeees 2-11 +Locate substring in string (P_SSUD) ...........ccesccecceesenseceeeneceeeeeneeeceseneeecseeeeeeseaseeeesaees 2-11 +Case independent locate sub-buffer in buffer (p_bsubi) ........... eee eeeeeeseeeeneeeeeeeeeeeee 2-11 +Case independent locate substring in string (P_SSUD1) 00.0... eeeeeeseeeeeseeeeeeeeeeeteneers 2-12 +Pattern match a buffer (p_bmatch).............cccccceeesseceeeenceeceeeneeecesneeeeeeeaeeecseneeeeeseeeeess 2-12 +Pattern match a buffer, case independent (p_bmatch1) ..............c:::ceesesseeeeeseeeeeeeneeeees 2-12 +Pattern match a string (p_smmatch) ............ceeccceeeeeeceeeeeeceeeenseeceeeceeeeseaeeeceenneeeeseeeeess 2-12 +Pattern match a string, case independent (p_smatchi)..............:cccccesesseeeeeseeeeeeeteeeees 2-12 +3 ATTAYS ANd QUEUES ............sccscesscssccseccsscscecssccseessscseesssscceessscesesssseseesesssccsesssscesesssscseesssccseeeees 3-1 +ATTAYSssiscisabsssorehhsiaidaaspsshasshessaciassostasibespigahaeakdsids sandals coatgsiar aids Mooedg secede Gecatdsieuuls hens 3-1 +Binary search an array of records (p_Dsrch) .........eesceeseeeeseessseeceseeeeseeeesaeerseeesseeeesaee 3-1 +Sort anarray of records: (PAqsOrt) si Jccbsss-esesests apie Aaadess Lap dedi Aesvdeadseedeh Aesvteas eeeaieh ees 3-2 +Doubly linked. ques’ #0. :s2s205cossvinsboedyosi ots keueubs these Sacks sodsthess Mh bseetstievsus Raeebeiess ts Beas 3-3 +Add entry to queue (p_CNqQue)........ eee eesecesecsseeesseeeesseecsseecsscecsseeeesaeecsaeecsaeeeseeesaes 3-4 +Remove entry from queue (p_Geque).......... eee eeeeesssecesseeceseessseeceseeeesseecsaeecseeesseeeesaes 3-5 +Delta: QUeCUGS: 53 is52css sor asians Aistdiee pcascass cus vaess Ase cass osst beds sua stissoustbans det duss sent dussseasduascunaiteaays 3-5 +Add entry to delta queule (p_emqued) 0.0... eeeeeesseceeseeceneesseeceseeeesseessaeesseeesseeeesaes 3-5 +Remove entry from delta queue (p_dequed) ........ eee eeseeeseecesceceseeeeseeecseecseeeeneeensaes 3-6 +4 Integer Conversion and Rectangle Functions ................ssccccssscssssssccsssssecssscseecssscseessscesessssees 4-1 +CORVETTE ANTE SETS LOTER Eases co, sede ecg shee Mnsedseseesseh sWastes sees ansheateeteesdupbuehest vant sees eebeats east ex 4-1 +Convert an INT to decimal buffer (p_i1tob) ..............ceeeesceceescceecesneeeeeeeeeecesneeeeeeeneeeees 4-1 +Convert a LONG to decimal buffer (p_Itob) 00.0.0... eeeecceeeescceeeeneeeeeeeeeeeeeeneeeeeseeeeees 4-2 +Convert a UINT to buffer any radix (p_gtOb) 0... eee eesecsseeceseeesseeessseecseeeeseeeesaes 4-2 +Convert a ULONG to buffer any radix (p_gltob) ...... eee eeeeeceseeeeeeeeseeseeeseseeeesaes 4-2 +Convert multiple arguments to buffer (P_atob)......... eee eeeeeeseeceseeeeeeeeeseeceeeeeteeeesaes 4-2 +Convert multiple arguments to string (P_AtOS) ........eeeeeeseeesseeceseeeeeeeeesseessaeeseteeeesaes 4-4 +Converting text to INtEQeLS ..... eee eee eeeeeceseeeesseecseecsseecsseecesaeeesaeecsaeecseeseneeeesaeessaeessneeeses 4-4 +Convert a signed decimal string to a WORD (p_StOi).........eeeeeeeeeeeneeeeneeseneeeeneeeeseee 4-4 +Convert a signed decimal string to a LONG (p_stol)....... cee eeeeeseeeeeseeeeneeesneeeeneeeesaes 4-4 +Convert an unsigned number in any radix toa UWORD (p_st0g)..........eceeeeeeeeeeeeeee 4-5 +Convert an unsigned number in any radix to a ULONG (p_stogl)...... eee eeeeeeeeeeeee 4-5 +Convert a string to arguments (P_StOd) ........eceeseeseeeesseeceneecseeceseeessaeecsaeersaeessneeeesaes 4-5 +Rectangle function ses esses tah ccccetaekcsceacieheseva gee seeid tebe cues deea uneesda deus cusadynetavadyen Gevsbyedeeda duke delts 4-7 +Offset:a rectangle: QP sOfirec) + a.25sss2ssseztdesetas ess canes iovadiass Sasagstaaeanasts cabigieszeaneaes Sausegansess 4-7 +Inset a rectangle (po Insrec): oc. ied lakh eG itiedegiciel nee Pandas 4-8 +Union of two rectangles (P_UMILCC)........ ee eeeeeeseeeeseeesseecsseeeseeceseeeesaeessaeersaeessseeeesaes 4-8 +Intersection of two rectangles (P_iMtreC) ....... eee eeeeeeesseeesneeesseeceseeeesaeecsaeessaeessseeeesaes 4-8 +Test if a point is inside a rectangle (P_PINTEC)........ eee eeseeeeseeeeseeeeseeeesaeerseeeeteeeesaee 4-9 +Test if a rectangle is empty (P_CMPTe€C) ....... eee eeeeeeeseeeeseeceseeceeeeeesaeetsaeerseeesteeeesaes 4-9 +Convert to an absolute rectangle (p_aDsrec) ........eeseesceceseessseeceseeeeseeeesseerseeesseeeesaes 4-9 + + +CONTENTS + + +5 FlOating: PONE .cc.ccsssacecessssvecensoovessassasennasoeceneasssdenendeosunansessusacdsodesasdssiesesdeosanassossaiosdensesoasensenee 5-1 +PlOatinie! POM tC oso, seses ceysditseantaced sensed stutievbcepseea sunpeecpoaete eee staeaate beste ceevatetpaeeth epee tease 5-1 +The: 8087 emulators: ais nice cesta hese ee eA SAG a A AE ay 5-1 +Avoiding the 8087 emulator .......... cee eeeceesseccssneecseecseecsseecesaeeesaeecsaeecseecsseesesaeessaeers 5-2 +MAaCTOS s:Aieitsevtesis ties ioti nse Re ad ee ed ee 5-3 +Converting doubles to and from text... eee eee esseeseeceeeeeeceeeseesseesseesseeseesseeseeeags 5-3 +Double. to.string: (pu dtob)sz.e.ss:.c.c cscs sesteieeeieeeeeib capt tedeydevbede poe besidebbezeneesbeeaeaes 5-3 +String to double (p_StOd) .........eeccceeesscceessceeeesneeeeeseeeeeceseeeeeeeeeeeceseaeeeeeenaeeecseneeeeeeees 5-4 +Get number representation preferences (p_getctd) ........eeeeeseesseeceseeceneeeeseeeesneessneers 5-5 +LON INtE Ber MIN CHUONS 2. sede leseleecsecusees secesbensctesesesesdeard oars sausvens sadesarvsadebars seudbanveatabereyegs 5-6 +Long random number (p_rand]) .00......ececeeesccceeeseceecesnceeeeeenceeeeseaeecesenneeeensneeeeesneeeees 5-6 +SCIEN AG TUNCHONS 55. 122. fs ses ook saet ee eaaes cet bea tese chit castes bce daunt ots duerees Sauet one beeeecaesineote 5-6 +Sime (PSI) x. scvvdsscesveisdaceee shaves pacdaceeedeceevcedesensced aves vesdaveancauaessscedacvat cesdevacccdesvarceaeates 5-6 +COSING: (PD =COS) os csce ced ce. g tis reneececetsteceenscecededs bedivesetadegetasedesndace ceded tedevsdnsadeisteseteatcatates 5-7 +‘Lancent, (potan)nivsicetst ste nvtisrisr tert rata eahiaeen sens pesiahesyen ened he bheveddu ayo ouss 5-7 +ATCSINE! (ASIN) 3d seh eskstue ooh aiden aye deh GUM eek Aiea aoe Au deh GoM otek de au obedient Hee 5-7 +AT CEOS. (Pp: 2aCOS) cs tscaecesseestceaa ces eenvavat cana cevvensvaeetcaancusudsanecst casereavdvaeas censsenvdtantabecetes 5-7 +ALCLANPSNE:(PAltAN):vsss0s dapsew cede gs lou ee siacetees sah pesos svdyedes aN pecedeedfeveuhety sveteetpedaseedpeincoregess 5-7 +Natural logarithm (p_In) .0..... eee eeeeeescecsseeceseeeesseecsseecsseecesaeeesaeecsaeecseeceseeeesaeessaeers 5-7 +Exponential (p2exp) cece bt ee eA RR Re A ee a 5-7 +Logarithm: (p::108) 2.02) savei heehee av hil arene hi ei ih ell eed ees 5-8 +SQUAT: TOOL (PASE). 25. discsatseedeces edusacessvevecesevepaceteenyetatsdusouetscsbedegstapedebsnnvedesosupaeebeaty 5-8 +Raise to the power (P_POW) .........cesccessceceseceeseeeesseecseecsseecesaeeesaeecsaeecseecsseeeesaeessaeers 5-8 +Double random number (long seed) (p_rand)...........eeeeceeeeessceeeeeeeeeeeeeeeeeesneeeeeenneeeees 5-8 +Double random number (p_frand) ...........cceccceeeesceeeeseceeeeeseeeeeseaeeeeeeneeeeessneeeeeseeeeess 5-8 +Floating point arithmetic without the 8087 emulator ........ eee ee ee eee ees eeseeeeeeeseeteeeeees 5-8 +Assignment: (pfld) ss: cs:c..ccaseestespiesdeoeekieegie des bebediyieel hye dvlal haben ane 5-8 +AG (ot fad) a cco sev ieetese ceed eas ebtee eh Gave enable ak Veh vada vite WVedcl ces esetecundersstieedaee eh 5-9 +Subtract: (p= fsub) si cc. ses. ccseseanceeeccaaceesceaaceescodaceescedescavecda seaucdueecsucedacvat ceudevanceseevancesendea 5-9 +Multiply (p7tmull) s.0 cece iecescedestecitbcstecavese tect acotechesda tue bestecugecetestbaeetecevetetesiprentedy 5-9 +Divide (Pp: f01V). i sccccc. cede ciescaciissceaeideesardes sess viesvesanieseeserdcseisardeveiderd covasardessitandeneacandens 5-9 +Compare-(p-ACMp)) 5.62 ccksttee cet eaiet eas teel aha eos thatch ait teeta aie ae a aie eaten 5-9 +Neate: (p: Mee) .3.ssciasiiatisivevaiiaten carga esisavaisel astvainelamginnieines 5-10 +Modiilus (pin) wiecccscaiee focaceteveducavedecatadedelasich Goiatededelace dagninteds dedsededncnsededadaeredaaneeey 5-10 +Integer part (pant): 5 2eescp.cenyazsdeghs testes ees etig tes eee apa eee aad eee est 5-10 +Convert double to integer (P_inti)...... eee eeeeceseecsneeceseecesaeeesaeecsaeecseecsseeeesaeessaeers 5-10 +Convert double to long (P_int])...... eee eeeeesseeesneecsneeceseecesaeeesaeecseecsseeesseeeesaeessaeers 5-10 +Convert integer to double (p_itof) 0... eee eeseeeeseecneecsseeeesseeesseecsacecseecsseeesseeessaeeesaes 5-10 +Convert long to double (p_longtof) ........ eee eeeeeeseceseecsseeceseeeesseecseesseeesseeeesaeessaeers 5-10 +OG Error Handling .icis.ciscccsiesscessecsvussccsvadeoctavssccvetedeccveassecevesedeocseasiseutadsdeerdacsseessededeactooedenssstoaes 6-1 +Process teriminatiOn:.c:istsisoutislarss dation tialineaids ica tia docauisties Mathoauethon Maer des Mate iad 6-1 +‘TLermifiatin e this: process: f.5.56$:sciesesccuectehsdetevsa cg vbevsiedehestnoyntevsbcschqueadyes enubedeleces yeaewuncd 6-1 +‘Terminating another process 24. :.i:0.d..0i.isstedistdaciestticeiish daciestdsedib ischial ons halen 6-1 +Finding out when other processes terminate ............ceeeeesseecsseeesneeeceseeeesaeersaeessneeeees 6-2 +The process termination WOId...........cccccesecssecssceeseceeesseecsaeecseeceseeeesaeeesaeesseeesneeeesaes 6-2 +PAIS his oh otafh ish scebsc chads ostocseuitevaoes saghe Sete eu boc edna tus Saestocnsiane Sui geigonsibabeoesseiedbiabesueags 6-2 +System: PANIC NUMDELS ssc. sssisessvesiees des dees ves does aves seessees does sves dues svapbues svasdabaovapbibesvasdues 6-3 +Terminate this process (P_€Xit).........ceesseesecssseecsseecsneecsseecssaeeesaeecsaeecseecsseeeesaeeesaeers 6-5 +Terminate after an unrecoverable error (P_PAaniC) ..........eseeeeeeesseeseneecsseeeeseeeesaeeesaeers 6-5 +Unilaterally terminate a process (p_pKill) 0.0... eee eeseceeseeceseeeeeeceeecsneeceseeeesaeeesaeers 6-5 +Terminate a process (p_ptermimate).........eeeeseesseceseceeseeeeseeeesaeecsacecseeeeseeeesaeessaeers 6-6 +Elect to receive termination message (p_onterminate) 0.0.0.0... ceseeeseeeeseeeseeeeeeeeeneers 6-6 +Panic a process by id (P_PPanic).........eeceeeeccssseeesseecsseecsseeeeseeeesaeecsaeecseeceseeeesaeeesaeers 6-6 +Request notification of process termination (p_logona)...........eseeeseeesseeeeeeeeseeesneees 6-6 +Cancel notification of process termination (p_logoffa) ...........eeeeeeseeeeseeeeseeeeeeeeneees 6-7 +Request message on process termination (P_lOQON)............essceesseeesseeceneeeeeeeeeeeeeeaeers 6-7 +Cancel message on process termination (p_logoff)...........eeseeeseeeesecsseeeeseeeesaeeeeaeees 6-8 +Cancel message of specific type on process termination (p_logoffx)..........eeeeeeeees 6-8 +Watching:all-exaits: (p“watchall) - 2.5. cis.ctcsastesidsepbssdspscdnsscespdticonssddasceapdescoverdedevapoeye 6-8 + + +ill + + +PLIB REFERENCE + + +Error Tetum: a.iestawest eis t at iste inte tia GS a A Ena eet 6-8 +Convert error number to string (P_errs)........cesccesssecesseessseeesseeceseeeesseecsaeecseeesteeeesaes 6-9 +Notifierservices isi iiiseiesictsea sated aia avei nied dohavhs edvuh ai asinr abate eae 6-9 +Present the user with a message and get response (p_Mnotify) .......... ee seeeseeeeseeeeseeeeeeee 6-9 +Notify user of error and get response (p_notifyerr)..........eeeesccceseeeesseeesneeteteeeeseeeesaes 6-10 +Setnotify. state:(pSemotity) :e: be seviee ons .e el ied eat itn abe eS ale eM 6-10 +Get notify state (p_getnotifY) 0.0... eee eeeeeesceceseeceseeeesseecseesseecesaeeesseessaeesseeesteeeesaes 6-10 +Hook the notifier interface (p_notifyhOOk) ......... eee eeseeeseeeeseeceseeeeseeessaeecseeesseeeesaes 6-11 +Unhook the notifier interface (p_notifyunhook) ............ceseeseeceseeeesneeesneeseneeeeseeeesaee 6-11 +Bnterand leaves: i.cicitssaceucatsccesis its. ossiasineectas seaste saves leaseanblaissetdaseen ladveetiaseeunlaecetast 6-11 +Enter a function (p_enter)............cccccceeeesccceesnececeeneeeeeeeaceecesnaeeeceseeeeeenaeeeeesaeeeeeseneeeees 6-12 +Unwind stack and return from last p_enter (p_leave) 0.0... eeeeeeeeeeseeeeeneeteneeeeseeeesaee 6-13 +Unwind stack and return from last p_enter if error (f_leave)............ceesseeeessteeeeeeeees 6-13 +7 Memory Allocation. .............cccscccsscssscssscssecssssseesscsscsscsssscscesssssesssscseesssscsesssscssesssscssesssccsessees 7-1 +Overview of systeM MEMOTY USAGE ......... ce eeeeseseecsseessseecsseeeesaeeesaeecsaeesseessseecesaeeesaeessaeers 7-1 +Memory Seaments..2.ccciiishs otictovesdbehdeacned cova deeladuneais ceesguube doteweh eqveqate dea couh Suesduvacsedees 7-2 +OEPMENE NAMES isc sssiisis esos dissdsetseandesk Aissdekd aseesh Aapoestousecisbovsecasteenpass daxsiasddexdeseets 7-2 +Segment handle, address and SiZe...........eeescceeseceesecesseeeseeesseeceseecesaeecsaeessneeesneeeesaes 7-3 +Process: data Segments’, .:siccsissctes.scisagaliass iat sassgatioes ise tavteanaeteapensasicasigaasgeasaaycaaiass 7-3 +Phe Heap: allocatOrs. sce cis.k oeloeeses sida dhecbeseeaanhdeet bietoess cei teed aehoasbensd obeedevsodyemebouva gueyodenecebed 74 +Heap Structure: ii.c.dctesec avbisefcnadesscvsvassdvandessovevioss doandvasdvacbest sostdassapbacesvataesioastaseoes 7-4 +Growing and shrinking the heap... eeeeseseecsseeseseeceseeeesaeeesseecsaeecsaeessseeessaeensaes 7-4 +AllOC- DEAVEn fetiehvis eA Ree wale ila ie inhi in ial eats. 7-5 +Internal fragmentation .......... eee eeeeeeseecsseecsseeceseeceseeeesseecsscecscecsseesesaeeesaeecsaeeseneeeses 7-5 +Allocate a memory Cell (p_allOc) ...... ieee ee eeeseceeeseeccesaeeecessaeeecesaeeecesaaeesesseeeess 7-5 +Free an allocated cell (p_firee)..........ccececccceesncceeeeseeceeseeeeeeenneeecesneeeeeseaeeeeesneeeeeseeeeees 7-6 +Change cell size (p_realloc) sic. scvccesicvsscus ces veguetesi cesta nceuneesieceesvanegseevevocas dan evsicesbeds 7-6 +Insert or delete data in cell (pP_adjust) ...... eee ee eeeeeeecesseecsneeesseeceseeeesseeesaeesseessseeeesaes 7-6 +Getcell length: (pialen) ssi eat tpint itsdeiyied Gist testes ates benvieh iii bearietene 7-7 +Set heap granularity (pP_hgran) ..0...... ees seeesseeesseecsneeceseeceseeeesaeecseessseeseseeeesaeeesaeers 7-7 +Visit all:cells’ (pvallwalk)s:. .c..ccacseccdiecseccavevancedscvas ccaendercedescetccavscne consacencesvedaecesecte ees 7-7 +Check heap integrity (p_allchk)...... eee eesecceseceseeeeseecsaeecseecsseesesaeessaeessaeesseesees 7-8 +Get heap address and potential free space (p_allspc)..........ceseeeseceesseeesneersneeeeseeeeeaes 7-8 +SYSLEM: MEMONY USAGE so. cee. s cass Miveas auacees unt Seen atn, css alba subalta casateeses sabdesdstaebsds sabebonebee 7-9 +Get addressable system RAM size (p_getram) .........eeseeeseeesseeceseeeesseeeseesseeesteeeesaee 7-9 +Get total system RAM size (p_totalK) 0.0... eeeeeseecesseeesseeesseeceseeeesseecsaeessaeessseeeesaes 7-9 +Get size of available segmented memory (p_Sgfree) ......... ee eeeeeeeeeeesreeeeteeeeneeeeneeeesaes 7-9 +Get memory used by internal RAM disk (p_sgramdisk)...........escceeeseeesseeseneeeeneeeeeees 7-9 +Memory segments: 33:2 sesinciasi sas thous eat hinds ee atin ene ee Rv oe 7-9 +Create memory segment (P_SQcreate) 0... ee ee eeeeeceeeeeeeesseeeceesseeeceseeeseesaeeeens 7-10 +Delete memory segment (p_Sgdelete)..............cceeeccecesesceeeeeeeeeesneeeeeeeaeeeceeneeeeeseeeeees 7-11 +Open memory segment (P_SQOPeN).......... eee eeseeeeeesseeeceeseeeeeeseeecessseeesesseeeceeseeeees 7-11 +Copy to memory segment (P_SQCOPYtO)........e ee eeeeeceesseeeceesceceeseeectesseeeseseeeeeeseeeees 7-11 +Copy from a memory segment (P_SQCOPYAT)........eeeeeseceseessteeceseeeeseeecsseecseeesseeeesaes 7-11 +Get size of memory Segment (P_SQSIZC) ....... see seeeeeeeesseeesneeteseeseseeeesaeeesaeesseessteeeesaes 7-12 +Adjust the size of a memory segment (p_Sgadjust) ...........ccscceceesseceeeeeneeeceeteeeeeseneeeees 7-12 +Find segments by name (p_sgfind) ...........eecccceeesceceeeenceeceeeeeeeceseeeeeesaeeeceeneeeeesneeeess 7-12 +Close memory segment (P_SQClOSE) 0.0... eee ee eeseeeceesseeeceeseeeeeeseeeceesaeeeceseeeceeseeeess 7-12 +Increment segment usage count (Pp_S]OCK)........ ec eeeeeesecsseessneeceseeeseeeessaeesseeesseeeesaes 7-13 +Decrement segment usage count (p_SgUNIOCK).........eeeeeeseeesseeceseeeeeeeecsseersaeeesteeeesaee 7-13 +Environment variables: cecctsesey a eetesteceine reeset teed sta nebsdeesteaissiabeger vier aeeenebeenseleee 7-13 +Get environment variable value (p_QeteNv).........eeeesecsseeesseeceseeeesseeesseecseeenseeeesaes 7-14 +Get environment variable value (p_getenViTON) ........... se eeseeeeseeceseeeeseeeeseeteeeeeseeeesae 7-14 +Set environment variable value (p_setenv)..........:::cceeseeceeeeenceeceeeeeeeeeneeeeeseneeeeeseeeeees 7-14 +Set environment variable value (p_setenVirOn)............::cceeeesceeeeeenceeeeeneeeeeeeneeeeesnaeeeees 7-14 +Delete environment variable (p_delenv)..............ccccccesesscceeeeeeeceeneeeeeeeeeeeseneeeeeseneeeees 7-15 +Delete environment variable (p_delemviron) .............cc:cccceeeseeeeeseeeeeeeeeeeeeneeeeeeeeeeees 7-15 +Find environment variables (p_findenv) ............ccecccceeesccceeeeeeeeeeneeeceeeaeeeeeeneeeeeseeeeees 7-15 +Find environment variables (p_fimdenvirom).............cc:cccceseeceeeeeeeceeeeeeeecesnneeeeseaeeeees 7-15 + + +CONTENTS + + +8 Asynchronous Requests and Semaphore ..............cssscccssscssscsscsseccsscseecssssesssscsscsssscseesssesees 8-1 +DEMAPNOLES 2 aie ssassutss causes saepe dea suuseveyssuteveyssucedey saute dey stuteddysuute des stucedssndutedvestute Merdetavevsteaates 8-1 +Process; scheduling 3:ia.tincaniienriseniiiagis aniiia cis ii avin ain pin ie 8-1 +SHared:access uti asain Sod we Ae ee Rad ae ot et ae ot a Bl a hk, al 8-2 +Supphier-consumer vii) cveieecii aie all i navel a iene 8-2 +ASYNCHTONOUS TEQUESIS :..s205 dee scapsessedepsdpesebsubtedes onus scebsunsedebontpageroutaedetouspraubenagedebonepsantensy 8-2 +Ihe l/O: sémaphote.sicea tics arti nied ara esha egret getneeeey 8-2 +StAtUs: WOLdS: ei ie Seed ete ctet otitis Stati eal etet tal aie Aa Ai tt on 8-3 +Cancelling an asynchronous request ............scceseccesseeeseecseecssceceseeeesseecsaeesseeesseeeesaes 8-4 +Waiting for a particular Completion ........... ee eeeeeeseeceneeceseeeesceessaeecsseecseeesseeeesaeeesneees 8-4 +Constructing synchronous fUNCTIONS 2.0... eee eeeeeeeseeeesseecsseecseeceseeeesaeeesaeesseeesseeensaes 8-5 +Wearthhandlerss.. sti: sicch ccecstat oR slide cues ois sant ato Bact stna been ater ed ted ot cevadietah oat eet, 8-5 +Polling rather than Waiting... eee eeeecesseecsneecsseesscecsseeeesaeeesaeecsaeecseessneesenaeeesaes 8-6 +Attached W/O devices sox... ieeccees. (ban edie sessedey bashedvesvetecagudas step aveesdepsdehontpesebededadehontpeanbadeg 8-6 +Primitive semaphore fUNctions ............seeeeeeeseeesseeeeseeceeecscecesaeeesseecsaeecseessteesesseeeeeeeeses 8-6 +Create a semaphore (Pp_SCMCIt).........ece ce eeeseeceesneeecesseeeceesseeecessseeeseseeeeeeseeesesseeeees 8-6 +Delete a semaphore (p_semdel) .0....... cee eeseceesseessseeceseecsseeceseeeesaeecsaeecseecesaeeesaeessaeers 8-6 +Wait on a semaphore (p_Wait) ..........eceeseceseceseeeeseeeesseecsaeecseeceseeeesaeessaeessneeesseeensaes 8-7 +Signal a semaphore (p_sigmal)......... ces eeesecsscecsseeceseeeeseecsaeeceeeesseeeesaeeeseesseessneeenes 8-7 +Signal a semaphore n times (p_signaln) ......... eee eeeeeeeseeesseeceneeeeseeeeseeeesaeesseeseeeeee 8-7 +Signal a semaphore with no re-schedule (p_signalnr) ...........esceeseeeeseeeeneeeeneeteneeeees 8-7 +DHE TAO Seta ph Ores sc:5, si /ocatservevetsss cecebsvs, odes sunp eden savy sgesschyass bouts deetocey edetoaspraubonagstebouepsasbensy 8-7 +Signal the IO semaphore (p_iosignal)..........eecesecssseeesseecsseecsneeceseecesaeeesaeessaeesseeeens 8-7 +Signal the IO semaphore of another process (p_iosignalbypid) ...........:eeseeeeseeeeseeeeee 8-8 +Wait on the IO semaphore (p_10Walt) ........ cee eesceesseeesseeesneesseeceseeeesaeecsaeessaeessneeeesaes 8-8 +Allow any wait handlers to run (p_loyield) ..........eseeseeeesecceseeeesneecseeceseeesseeeesaeessneers 8-8 +Wait for a particular request to complete (p_waitstat) 0.0... ee eeeeeeseeesneeteneeeeneeeeeaes 8-8 +Woatt anidlers x. toe. a, Sug sogstede opes sia conte ones ales ente fs ove ts Uaoans Dace veaud otnabhbess atest scerbunteanteestotensts 8-9 +Add a wait handler function (p_svecadd)...........ccccccecssscceeeeeeeeeeeeeeeceseeeeeessneeeeessaeeeess 8-9 +Activate/deactivate a wait handler (p_sveccall).............:ccessccceesenceeeeeeeeeeeeeteeeeeeseeeees 8-10 +Remove a wait handler (p_Svecrem) ...........:::cccssesceeeeseceeeeeeceeeeesaeeeceeeeeeesseneeeeesneeeees 8-10 +QD. TO SYStEM sscsciscscscessoessnviscevevedssedevsssecdecedsocdonssssevosescocbasdesvenedsogeansdoscvensdeonbaosseentadedceeseatsenseso’ 9-1 +VO; Device Drivers .sitiscesslatie tise tatctieoktateentis entation dateactialleataticasttaiss 9-1 +LDDs :atid. PODS es. seienet Sous cosh Sioa grads eub gosh Sais thee dutewes Sesecoens dunes ceuscnes sdutgout covsaven sgt oes 9-1 +Extermal device drivers'::s.4.csst2,.nisnisdiedinsacnsihode Mindi stonsth Miia A 9-2 +Opening a channel to a deVICC oes eeeeceseecsnecesseeeesseecsseecsaceceeeeesseecsaeesseessneeeesaes 9-2 +Operations on an open I/O channel..........eeseesecesssecesseesseesseeceseeeesaeecsaeesseeesseeeesaes 9-2 +The file Server sisc.fo a sieties ihe dine shite ioievaeteesersiohntoes bavi Miedo aot haba 9-3 +Attached: drivers: jiis.:hstosss | iiiosscsetis hs sohassaetiest Asioesstentiess casidevarbiseAssetisscouedone soeepaeed 9-4 +Channel-based I/O functions .0....... eee eeececeseeceseeceseeesseecseecssceceseaeecsaeecsaeesseesesaeeesatessaeers 9-4 +Open a channel to a device (P_OPeM) .........seeesceeeseeesseeesseeeeseeeesaeecseecsneeseseeeesaeeesaeers 9-4 +Start an I/O operation (Pp_10)........sceeseeesecsseecssceceseeeesseecsaeecsneecsseecesaeeesaeesseeeeneeenes 9-5 +Start an I/O operation with guaranteed completion (P_i10C)........eeeceeseesseeeeneeeeneeeee 9-6 +Start an I/O operation and wait for completion (P_iOW) .........seceseeesreeeeneeeeneeteneeeeee 9-8 +Close:an:I/O:channel (p- ClOSe)i.c.35;scesncsiisassassecectesuaneetlaneteatadaabeysacatosniaeseeasenaseunansss 9-8 +Read from an I/O channel (p_read) ...........cescceeeescceeesecceeeeeeeeceseaeecceeneeeeenseeeeeeeaeeeess 9-9 +Write to an I/O channel (p_Write)............ccececccccessceceeeeneeeeeenneeeseeeeceeeeaeeeesenneeesseeeeess 9-9 +Cancel requests on an I/O channel (p_iow(P_FCANCEL))............ccssesceeeeseeeeeeeneeeees 9-9 +Device dfiver futict Ons: ssc..26sss2c.sscchoteilshtesteniaes ches Woaekdaeaceeddates sate oteendaieatesiateandiisoes Bees 9-10 +Load a logical device driver (p_load]dd) ........ eee eeseeeseeesseecesseceseecseecsseeceseeeesaeessaeers 9-10 +Load a physical device driver (p_loadpdd).......... eee eeeeeseeeesceessneeceneeceseeeeseeeesaeeesaeers 9-10 +Delete a device driver (p_devdel)............cceessccessesceeeesneeeeeeeeeeeesnaeeccsseeeeeeneneeeeeseeeeess 9-10 +Query the number of units supported by a device (p_devqu).........eseeseeeseeeeeneeeeneees 9-11 +Find all devices (p_devfind) ............cceeeecccessscceeeeseeeeeesneeeeeseaceecesnaeeeeesnaeeeeneneeeesenneeeess 9-11 +Simple; console O's. sss jets esicaseoeasdestoust csssass nethses Asseeisssestieeg ous tbass cent dose suesvaae Sorostedobi ons 9-11 +Redirecting COnSOle WIites ...........cceseceseccesnceeseecsseecsseeeceseecssceceeecesseeesaeecsaeecsseeeesas 9-12 +Changing the size of the console WiINdOW ............secseseceseeesteeeeseeeesaeessaeerseeesseeeesae 9-12 +Changing the console Window MOde.............essseseseecsseeesseecesseeesaeecsaeecseecsseeeesaeeesaeers 9-12 +Write a character to the console (p_pUtch).........eeseeeseecsseesssceceseeeesaeecsaeecsaeessteeensaes 9-13 +Write a string to the console (P_puts) 0.0... .e se eeeeessecesseecsneeesneeesseeeesseeesseerseeesseeeesaee 9-13 + + +PLIB REFERENCE + + +Convert arguments and write line to console (p_printf).......... ce eeesecesseeeeeeeeeeneeeeneers 9-13 + +Convert arguments and write to console (P_Print).........e ee eeeeesseeceseecsseeeeseeeesaeeseaeers 9-13 + +Get a character from the console (p_getch)...........seesscesseccessecesneecsseecseecsseeeesaeeesaeers 9-13 + +Get a string from the console (p_gets) ..........eeseeeseecesseecsneecssceceseeeesaeecsaeesseessteeeesaes 9-13 + +Get a string with prompt from the console (p_getl) ..........eeceeeeeesecceeseeeeneeeeneeeeneeeeeaee 9-13 + +10 Time, Timers and Dates ..............ccccccccccsssssssssssssssssssssssssssssssssssssssssssssscssssscccccssssccccscsccsssssssess 10-1 + +SYStEMM tM, 22.453 ciss is Movethsiicds iatcessas hoeatatiesatielsaaeits Mrestieieduls teas detioss sta ielelincestetioatia 10-1 + +Return the system time (p_date) oe. cece seceseeceseeeeseecseesseeceseeeesaeecsaeecseeseseeeesaes 10-1 + +Set:the- system: time: (Psdate) a .ssp.set. Ass testesaphesssatiapeeedads Ash bekse sodas: Aapdeadesedshecs 10-1 + +Absolute: and relative timers: s:.2..600i55c2.us seus cava teag eens coveeesciva seyaeuva cows dev see dune davesduchus eva sevedued 10-1 + +Suspend process for n tenths of a second (p_sleep) ..........:eeseeeseecsseecsseeeeseeeeseeeesaeers 10-2 + +Suspend process for n system ticks (p_Sleept) .........eseeseceesseeeseeecsneecseeeseseeeesaeeesaeers 10-2 + +Suspend process until absolute time (p_sleepa) ........... eee eee eeeeseeeeeeeeeetseeeseetseeeaes 10-3 + +ASYNChronOus tUMers's..53<.8sceseecsstevstes schvocsadteysceh acevseehatevscedscevecgestevscevscevacebaceyscebsdevsegestevsdd 10-3 + +Start an absolute timer (p_ioc(P_FABSOLUTE)).............cc::cccsssseceeeeeeeeeeeneeeeeseneeeees 10-4 + +Cancel a timer (p_iow(P_FCANCEL)) ...........ccccsscsceeeesseeeeeeneeecesneeeeeesaeeecnsneeeeeseneeeess 10-4 + +Close a timer channel (p_clOSe) ............cccceeeessceeesseeeeeeeeeeceenseeecsseeeceesaeeesseneeeeeseeeeess 10-4 + +Converting between binary representations Of tiMe......... cee eeseeeseeceseeeeseeeesecesaeeesaeereaeers 10-4 + +Convert system time to P-DAYSEC time (p_sttods) .00........eccceeessceceeeeeeeeeeteeeeeeeeeeees 10-5 + +Convert P_DAYSEC time to system time (p_Cstost) ...........c:cceesesecceeeseeeeceeeeeeeeeeeeeees 10-5 + +Convert P_DAYSEC time to P_DATE time (p_dstodt)........0.eceecceeesseeeeeseeeeeeeneeeees 10-5 + +Convert P_DATE time to PLDAYSEC time (p_dttods)..........ceecceeeeeseeeeeeeeeeeeneeeees 10-6 + +Find the number of days in the specified month (p_dayinm)............seeseeeeseeeeseeeeeeee 10-6 + +Convert day since 1900 to day in week (p_Wkday)..........eseeseceseecesseeeeneessneeesneeeesae 10-6 + +Calculate week number in year (pP_Weekn0)...........c:ceesceseseessseeceseeeesseeeseesseessseeessaes 10-6 + +Time and date components in text fOr ......... eles eeeeeceseeeseeesseeeneeceaeesseeceseeeesaeenaeeesaeers 10-7 + +Get the day name (p_nmday)........ eee eeseeeseecsseceesceeesseecsseecseeceseeeesseecsaeesseeesneeeesaes 10-8 + +Get the day name abbreviation (p_nmdaya) ............:eesscssseecsseeceseeeesseeesseesseeesseeeesaes 10-8 + +Get the month name (P_NMMON)......... ccc eeeeessssneeeeceeeeeeeenneeeceeeeeseeenaeeeeeeeeeeeeenaeeeeees 10-8 + +Get the month name abbreviation (p_NMMoma) ..............cccssccceeeseceeeeeneeeceeseeeeeseeeeees 10-8 + +Get the day-in-month suffixes (p_getsuffixes) 0.0... eeceeseeesseceseeeeeeeeeseecseeseneeeesaes 10-8 + +Get the am and pm suffixes (p_getampmtext)......... eee eeseeesseeceseeeesseecsseecsaeeesteeeesaee 10-8 + +Get time representation preferences (p_getctd) ........eeeeeeeseeesseeceseeeeseeeeseeceeeeeseeeesaes 10-9 +Generating time and/or date StringS............ceeeeeesecsseeceseeseeeceseeeesseecsaeecseecneecssaeeesaeersaeers 10-10 +Date and time format Strings 0.0.0.0... eeeeessseeesseeceecseecscecscecsaeeesecesaeeesaeesseesseeese 10-10 +Convert a P_DATE time to a string (p_dt2str) oo... eee eeseeeseeceseeeeseeesseesseeeeseeeesaes 10-13 +Convert a PDAYSEC time to a string (p_ds2str) oo... ee eeeeeeeseeceeneeeeeeseneeeeseeeesaes 10-13 +Convert a system time to a string (P_St2Str) 0... eee eeeeceseeesseeceseeeseneeesaeerseessteeeesaes 10-13 +Convert the current time to a string (P_NOW2SUL)........ eee eeeeesseeceseeeeeeeeesseeceaeeseneeeesaee 10-13 + + +11 Files 11-1 + + +vi + + +VEST POC ao aerate cedseen sirecattldstet sahlpeestl ts deies sles iat Sidi cokes Satis shat els tat he Sa lilo set iat 11-1 +The file server scs3.cicee teeing oaey bei aagiesd iv aid eng ne ea ae 11-1 +File: SYStems's... 32.8 2s te A Rea oe ek Qa Bek A ie a ak 11-1 +SSD drives. sibs ienyiethd aah ee a ee vd i ee 11-2 +Unattended applications 2.0.00... eeeeesecceseeceseecseecsscecsseecseecesaeessaeecsaeecsaeesseeesenaeensaes 11-3 +RAM SS Ds:z.t.cstiaistisd Slee eeste eden ahaa ape ae eee Gani eee eae ets 11-3 +Blash SSDS sss01 seis on GN lat Ao Maat sh Ge eit ah AGA eects gO AGN ute ae BON Ss 11-3 +File-specificati Ons .vessvccsescvcess sextcces sens cons ceaveeavacds ceanccavecancevvecaeseavesadccseeuaacevnuassccveenanes 11-4 +Detault:path: 2:03 /5:0..cissed test ctsss Maetest eniehs Aosdin A aeiehieetedciehs hardin Antes Anes 11-5 +Charinél-based Services's. is: szcsseees dies sch tuys sets bes tsteuscevsaubessh stexs cus sebesvelvevesvbateaetnivevest 11-5 +Non-channel-based: Services 1: ..235isccsaiedosetis ec seadanaoeetaa seca wdativeahaguacaesbiaaveandaaousdaiaes. 11-6 +Asynchronous file Operations...........:ccesscecesseeesseecsseecsceceseeessaeeesaeecsaeessaeesseeessaeeesaes 11-6 + +Manipulating file specifications............cccseccceseseceeesenceeceeeeeeecesceceeseaeeeeeeeneeeceeseeeeeeneaeeeess 11-7 +Parse a file specification (p_fparse)..........ccccssccccssececeeeeseceeeseneeecesneeecessaeeeceenneeeeseeeeees 11-7 +Using p_fparse across filing SYSteMS..........ceceeseesseeesseeessceeeseeeesaeecsaeerseeesneeesseeensaes 11-8 +Change the directory in a file specification (P_Chdir) 0.0.0... cee eeeeeeseeeeeseeteneeeeseeeesees 11-9 + +The default node, device and directOry ..........eeeeeseseecesseeceseeeseecseecseecsseeeesaeessaeesseeeses 11-10 +Set the system-wide default path (p_setdefaultpath) ......... ee eeeeeeseecsseeeeeeeeeeeeneers 11-10 + + +CONTENTS + + +Set the default path of this process (p_setpth) ..........eeeeeeecsseeessneessseeesneessseeeeteeeesaes 11-10 +Get the default path of this process (p_getpth) .........eeceeeeeeseeesseeesseeceneeeeseeeesaeersneers 11-11 +Get the default path by process id (p_getpthbyid)........ ee eee eesecsseecsneeeeseeeeseeeesneers 11-11 +Operations on, nodes and devicesieissc..cs.55 Sas destneceeissesobissseap des naubiasnipdest Sasssespdensneitaaedes 11-11 +Get node information (p_minfO) .............cceeesccceeseeceeeesnceeeeeeseeeeeseaeeeeeeneeeeeeseeeeeseseeees 11-12 +Check if LOC:: has changed (p_locchg) .........eceeseeeseeeeseceseeeseecseecsneeesseeeesaeessaeers 11-12 +Get a list of devices (p_open(P_FDEVICE))............:cccccccesesseceeeeneeeeeeneeeeeesneeeeeseneeeees 11-13 +Get device information (p_dinfO).............cccsccccesssceecesnceceeeeneeeceseneeceeeneeeeseeneeeeeeneeeess 11-13 +Read media information of a local device (p_locdevice).............e:ccceeeeeceeeeeseeeeeeneeeees 11-17 +Direct read of local SSD (p_locreadpdd)...... eee eee eeeseceeseeceseeeeseeceaeecsseeesseeeesaeeesaeers 11-17 +Operations on directories and files 1.0.0... eeeeeseeceseeesneeesseecececeseeeesaeecsaeecsaeecsteeeeseeeesaes 11-18 +Get a directory list (p_open(P_FDIR)) .............cceccccesseccceesenceeeeeseeeceeneeeeseeneeeeeseaeeeees 11-18 +Return file information (p_fimf0) ............cccccccceesesceeeeseceeeeeeeeeeeseaeeeeeeeeeeeseeeeeeeseeeeees 11-20 +Test for the existence of a directory (p_testpth) 0.0.0... ceeeeeescesseeseseeceseeeeseeeeseeeesaeers 11-20 +Rename a file or directory (P_renaMe)......... eee eeesecsseeeeseecesceeesseecsaeecseeceseeeesaeeesaeers 11-20 +Delete a file or directory (p_delete).............ccccceeeesseceeseeceeeeeneeeceseneeeceeneeeeeeeneeeeseeneeess 11-21 +Make a new directory (pP_MKdIL).............eeeeccccesseceeeesnceeeeeseeeeeseaeeecesneeeeeesneeeeeseeeeees 11-22 +Set file attributes or label medium (p_sfstat) .............::ccesesceceeseeeeeeeneeeeeeeeeeesesneeeeeeees 11-22 +Set file creation date (p_fdate) .............ceeeccccesssscceeseneeeeeseneeceesneeeeeseaeeeeeesaeeeeeeneeeeeeeas 11-23 +Binary. file:access\..2: ai acich devieichaccin dieses bantu dante Bani daar 11-24 +SAE ACCESS 25 5253 aoe use Us Heandhedi wack Seaaeeb abe eS e Saau vs cueady wb cada den Sues By eke Ta ayaeeTe Tyee eee 11-24 +Exammple‘of binary file-access szt25..cc.:ciussetialcesddcissandaistesiesisaeataslscesdesiapeatea.cesbaaianess 11-25 +Close a binary file channel (p_ClOS€) ........e ec eeseeeseceseeesseeeeseeeesseecseecseecesaeeesaeessaeers 11-27 +Read from a binary file channel (p_read)......... ees eeseeesseeeeseeeseeecsaeecseeeeseeeesaeessaeers 11-28 +Write to a binary file channel (Pp_WIrite) 0.0.0... eeeeesseeceseecsneeeeseeeesaeecsaeesseessseeessaes 11-28 +Position a binary file channel (p_seek) 00.0.0... eee eeeseeeseeesseeeeseeeesseecseecseeseseeeesaeeesaeers 11-29 +Cancel an asynchronous file channel request (p_iow(P_FCANCEL)) .............:::::08 11-30 +Stream: text Mle:ACceSsi a. -5.5..visscesebicteaseisbscassdevecaaws das daswisng cavsoeea Sosa edegcventics suvavaassvancigesvaanics 11-30 +Open a stream text file (p_open(P_FSTREAM_TEXT))............c::cceeeesseeeeeseeeeesetseeees 11-31 +THOXt TIE ACCESS: tacsiacstadsacancs sezesties exGeahesaece teats onde ist «anand saeateeeasagteauacaueaataseeetacnegaeesaas 11-31 +Open a text file (p_open(P_FTEXT))...........ccccecesceceessceeeeseneeecesnaeeecesneeeeeseneeeeesneeeess 11-32 +Close a text file channel (p_ClOse) ............eeesscceessneeeeesnceeeeeeaeeecessneeeceeneeeesseneeeessnseeees 11-32 +Read from a text file channel (p_read)............ceeeeecccesescceeeeneeeeeeeneeeeeeneeeeessneeeeesneeeees 11-33 +Write to a text file channel (P_WTite) ............cccceeeeecceseneeeeeeeeeeeceeeeeeeeeaeeeessneeeeeseeeeess 11-33 +Position a text file channel (p_seek) .00.........cccceeesceceesecceeeesceeeeeeneeeeeeneeeesssneeeeeeneeeees 11-34 +Flush internal file buffers (p_iow(P_FFLUSH)).............cccsscceeesssseeceeseeeeeeseeeeeseeeeees 11-34 +Set end of text file (p_iow(P_FSETEOP))..............ccccccceessseeceesneeeeeeeeeeeesseeeeessneeeeenees 11-34 +Cancel an asynchronous file channel request (p_iow(P_FCANCEL)) ..............::::008 11-34 +12 Processes and Inter-Process Messaging ..............scccsssssscssssssccsscssccssscseecssscsesssscssesssscseesssocsors 12-1 +PLOCESSES - snc oe isbadtpoast tee deveganspadeeededetehnuses cots vebetvennton cot deletuborie coho tela Tntoutel coaeteaaueerees oontedy 12-1 +SYSLEtM PLOCESSES sci sesstis laste asdebresindess tiptesbesaedesdapheansydncepha iasbhies Mish Geile 12-2 +Process ID and process control DIOCK ...........::cccesecceceeeeceeeeeeeeeeeeeaeeeeeenneeesseneeeesenneeeess 12-2 +PROCESS: SLALES we. y sas tstavccitens Velie teeteeeetstesis cevvdepei ar aaaceveeni nei eae ba vauiecaanecuiseavdsaseateceteey 12-4 +PHOGCESS: QUEUES frdac ised evsn sie oadatecs ¢ edsns ve poang eles auenach godecotesoDtgarn (bceteten eVatbengteeteds eadttecegbec envy 12-4 +PLOCESS: PTIOTItIOS 2 si ccieieseedandesbeseniesecdardeveedendcaeidandcvuidenta devise tecopicas cdesdeadedevadaecdeveceoees 12-4 +Preemptive Scheduling: : 05, .:.c¢...s0ies ek vavsd saeeshgscun cee va tedestiaast ots satniesh caesbecesduce sshavestonesats 12-5 +PFOCESS NAMES we ses se ceveedvevaeeci acess ebeavauadsaceseesusees deste verhnceet diay evens ouat ea ae uh Taree aS 12-5 +Reserved statics (Magic StatiCs).........:cesccesssscceeeeseeeeeeeneeeceseceeseaeeeceeneeeeeseeeeeeseeeseaees 12-6 +Shared Code:sepmients::, s1.5g.c2...egeysgidesspbestegeyhaibesrdesbgiyiesden reece duyoedesenebdieyoebeanaees 12-8 +Tra esl eS: se, Ses sod sane ted oer tcict seh Sioe coun test oak og caartaiec eh eal satan cee hides Western dlceaatt eet eee ts 12-8 +ProGess: terMinatiOM .cseevccsescsieeae ceveesanccaievcas cevedcatccesicna covvccancessccaa dus vecdaseaucdaaceauceseevseceseevanees 12-10 +Cr@atitiS asprocess ia... vess ta fedat eves tat hfs sdetcengyotetedadet tts ciutetesotes terppdase elas oveendauythdevecidpeiteth ets 12-10 +Load san: image:(p exec) s.2..5checyeet ey aekbedi gigs ceeedes dada piaed deeebeabegs pas edesbesbeepae eae 12-10 +Load an image asynchronously (p_eXeCCASyMC)..........eeccceeeeseceeeeeceeceeeeeeeeeeseeeeeeneeeees 12-12 +Create:a procéss (p= peréale).cctccii i atankt ined a iis 12-12 +Operations on the CULTeNt PLOCESS........ eee eeseceseecesceeeseeceseeessaeecsseecesaeeesaeecsaeecseeseteeeesaes 12-14 +Get this process ID (p_getpid) 0.0... eee eeseeeeseecsseecsneecsseecesaeeesseecsaeecseeesneesesaeeesaeers 12-14 +Mark this process as non-active (p_Ummarka)...........c:cccceeesscceeesneeeceeeeeeeseeneeeeeseneeeess 12-14 +Register activity (p_tickle)........ceeceeessccceesnceeeeseeeeeeseeeeceenneeecseeeeeeseaeeeeneneeeeeseeeeees 12-14 +Mark this process as active (pP_marka)..........cseeseccesseeseeceseeeesseeceaeecsseeceseesseesenaeeesaes 12-15 + + +vii + + +PLIB REFERENCE + + +Operations ON ANY PLOCESS 0.0... eeeeeeeessneeesseecsseecssceceseeeesseeesacecsaeecseecssaeeesaeeessneeeeseeeesaes 12-15 +Get a process priority (P_Qetpri) ....... eee eee seeeseecsseeeeseecseecseeceseeeesseecsaeesseessneeeesaes 12-15 +Set a process priority (P_SCtpTi) ........eeeeeeeecesseecsneecsseeceseeceseeeesseecsaeecseeessseeeesaeeseaeers 12-15 +Resume a process (P_PreSUME) ....... eee eeeeeeceeseeeeeeseeeceeseeeesesseeeceesseeeseseeeceesaeeeees 12-15 +Suspend a process (p_PSUSPeNd)...........seeeeeesseeesseecsseecsseeceseeeesseecsaeecseeseseeeesaeeesaeers 12-15 +Get a process name by ID (p_pname)............eesceessecesseecsseeceseeceseeeesaeecsaeesseeseneeeesaes 12-16 +Rename a process (P_PreMaMe) 200.0... eee eee eeeeseeeceesceecessececceseeecessseeecesseeeceeseeeess 12-16 +Get a process ID by name (p_pidfind)...... eee eeeeceneeceneessseeceseeeeseeecsaeesseeesteeeesaes 12-16 +Find all processes (p_pfind).......... cc eeceeeseceseecsseeceseeeesseecseecseeceseeeesseeesaeesseeesneeensaes 12-16 +Determine the owner of a process (P_gQetOWNET)...........::cceeeesceeeesseeeeeeeeeeeeeeneeeeseeeeees 12-17 +Accessing a process data SCgMent.............::cccesessceeeeeneeeceeeneeeeeeeeceeecesseeeeesnaeeeeesneeeeeseeeeess 12-17 +Copy data froma process (p=pCpyft) uc. sseccissd-ssiesedeas dseteestbedacsspdsicvesplaasdoapdossoeseeaabers 12-17 +Indirected string copy from a process (P_PISCPYfT) ..........:ccssccceeeseceeeeeeeeeeeeeeeeeeseeeeees 12-17 +Copy data to a process (P_PCPYtO).........eseeesccssseeceseeceseecseecsseeceseeeesseeesseecseeesseeeesas 12-18 +Titer process:messa gin gyi iesioc5ise nasa desi oteh Sek Seok donk Seehcbekbies Sock cdondeed Like on feud Waadasheaabee 12-18 +Message: slots:ssi ss s:cssissssustiess datbsie ostions Gapees avbins Aaadies assess Asians austen Asides nantes os 12-18 +What the:Server does. .2.s5 sci seus eszsths fet steyestasvis sel scveseusssube ful cevuscayssbes sd cavuscuvestbeavisveyest 12-19 +What: the CHent dOeS ¥:s.s.i:.4setesieccetlanissotgaletestdasbeentasiecestSawsvosteaiacs tlavivestastarent ladoeenace 12-19 +Atv example Of a SEL VEL if oct Seosccc) bach Schl coueess Sock bouie ceveoehcccaaed caveneus ohevedsaubbeguscven serene 12-20 +Corresponding client code example ...........cescceeseeesseecsseeceseeeeseeeesaeecsaeecsaeessneeesseeeesaes 12-21 +ASYNCHTONOUS: MESSAGING c s2.. 6225 cewek cea syea cadet eee ovs dank Sobtah we cov aaekg FuvTa estas Sea ndeVta seek eae 12-21 +Message processing OFeL ...........sseccccesscceeessceeceencecesseeeceesnneeeseeeeeeeeeaeeeeseneeeeeseseeess 12-22 +SERVED TUNCHONS 23 vose se oes26i Saf oak sslat es eeaaeuabaessckibe caged saubceeis lon Sedensoersyoseneodeduneeesentodougs fy 12-23 +Initialise for message reception (P_MIMIt) ...... eee eee ceseeesneeceneeeeeeeeesaeerseeesteeeesaes 12-23 +Wait for message reception (P_MIeCC1VEW).........-eeseceeseceeseeeseeessaeecseesseecsneeeeseeeesaes 12-23 +Asynchronous message reception (P_MIreCelVe) ..........::ccceeeesceeeeseeeeeeeeneeeeeeeeeeeeseeeeees 12-24 +Cancel a message receive request (p_Mcancel) ........ eee eeseeeseeceseeeeeseeesaeesseeesteeeesaes 12-24 +Freeda messagé-(p: mire): -i i ccssssbesed cedeaccvisdusecedesieacvtedusteoteasch dons vencsesege da Svansastoeseca tees 12-24 +Chent fun CH OSs syc0i. seus sdsiiecsets hesfiovtuesvevs Geis Goth Sd eedviiersts dase tees ea eases hase 12-25 +Senda. message’ (p mSend)ssc2.ics.sccsueissscennsseatesteasaceabsdesganhe sant sanoeaoebieaeoeetieenseahaase Ss 12-25 +Send a message and wait for a reply (p_msendreceivew)............:ceseceeseeceseeeesneeeeneers 12-25 +Asynchronous send message and get reply (p_msendreceivea)............eseeeseeeeseeeeeeee 12-25 + +13 General System Services ..............ssccsscscscssscssecssscecsscsccsssccessssescescssesssscssessssessesssscsssscsseessseees 13-1 + +SyStemn- in fOrMalOn ss si. ssestewes hos Abst ss cach shes pbsDeves cet dies Avs TG sous thug baDUS. cous hess TE cast heeds 13-1 + +Get the operating system Version (Pp_VeTSiON)..........::cescceesessseeceseeeesseeesseersneeesneeeesaee 13-1 + +Get the ROM version (P_romVversiOn)...........::ccccesccceeseeceeeeeeeeeeeesneeeeeseaeeeceeneeeeeseaeeeees 13-1 + +Get the cause of the last system shut-down (p_getres) .........eseceeseeseseeesneeesneeeeneeeesaes 13-1 + +Get operating system data (p_getosd)..........eseeseesseecesneessseesseeceseeeesaeecsaeesseeesseeeesaes 13-2 + +Get power supply type (p_QetPSu) ........ ee eee ec eeseeeceesseeeeeeseeeeceseeesessaeeeseeseeeceesaeeeees 13-2 + +Wan Sua Se AN" COUNTY 12 555 Sica Seok sheesh ok bees ek het Shek eebge sh Sues eoabe solwead yaebvil coleneh een eoid ewiete 13-3 + +Get the language code (p_getlanguage)...........eseeeseesseecsseessseeceneeeesaeessaeesseeesneeeesaes 13-3 + +Get operating system text (P_QetteXt).... eee eeeeesseecesneecsneecsseeceseeessaeeesaeecseeseteeeesaes 13-3 + +Get country-dependent data (p_getctd) 0.0... eee eeeeeessseecsseessseeceseeeesseeeseecsaeessseeeesaes 13-4 + +Set country-dependent data (p_setctd)...... 0. ee eeeseeesseecsseeceseeeesseecseecsseeceseeeesaeeesaeers 13-4 + +Switching on and off.s.e55s:3 iets teres Hides ede Penance diet aa meie alban demyinbe eaned ae 13-5 + +Switch-off: (Pp: Off): sees sec Gotia viet dette enti ee kaa ek Ae AN ae es 13-5 + +Get the auto-switch-off period (p_getauto) 00.0... eeeeseesseessseeceseeesseeessaeecseeeeseeeesaes 13-5 + +Set the auto-switch-off period (p_Setauto) 00... eee eeeceeeseecesneeeseecseecseecsseeeesseessaeers 13-5 + +Get switch-off state when mains is present (p_getautomaiNs)............:eeseeeseeeeseeeeeee 13-5 + +Disable/enable switch-off if mains is present (p_setautoMaiNS) ...........eeeeeeeeeeeeeeeeee 13-6 + +Allow auto switch off (p_allowoff)............cccecsceceesncceeeeeeeeseeeeeeeseeeeeeeneeensaeeeseeneeeeeeees 13-6 + +Enable/disable the ON key event (p_SetoneVent)...........eeeeeseeceseeeeeeesseesseeeeteeeesaes 13-6 + +Power SUPPLY ss. itccei ets oite Moiese eee Se tei nea ee eae 13-6 + +Get power supply status (p_SUPPLY)........0. eee eeeeeeceesseeeceeseeeeeesaeeeceesaeeesesseeeceesaeeeees 13-7 + +Get additional power supply data (p_supplyinfo) ..0...... eee eeeeeceseeeeeneeeeneeseneeesseeeesaee 13-7 + +Get battery warning and maximum levels (p_WSUPpLY)...........-.esecseseeeseeeeneeeeneeeeseee 13-9 + +Get the battery type (p_getbat) 0.0... eee eesecsseceseeeesseecseecsseeceseeeesaeessaeerseeesteeeesaes 13-9 + +Set the battery type (pi setbat)iaicc heli at ail etteelon ail iti hai Alaris 13-9 + +Keyboard yi.2325) aiteeiseseneidiveibaeyssyideoes esta iis ser egieiest Randy eines ieeeneai asi cetcenese eae don 13-9 + +Get the state of all keys (p_getscancodes) .0.........esseeeesecsseeesseeceseeeesseeesaeecseeeeneeeesaes 13-9 + + +viii + + +CONTENTS + + +Display iesesissaeusrestecei bess 2eveptazebs feistebesia loves paubteestna stvke eb tveslov dies Fevadhestoasieks seadvslovsenaeeedy 13-10 +Get the system display type (p_getled) oe. ee eeeeesseeceseeceseeeeseecsaeecseeeeseeeesaeersaeers 13-10 +Change the LCD contrast (p_Icdcontrastdelta)...........seeeeeeesecesseecsneeeeseeceseeeesaeersaeers 13-10 +Get the current LCD contrast (p_gethcdcontrast)..........ceecceeseesseeeeseeceneeeeseeeesaeeesaeers 13-11 +Switch the backlight on or off (p_backlight) ........ ee eeeeeeseeceseeeeseeeeeeeeesseessaeeseeeenes 13-11 +Set the backlight control value (p_setbacklight) 0.0.0... eecceeseeeseeeeseeceseeeeeeeeaeessneeenee 13-11 +Get the backlight enablement (p_getbacklight) ........ ee eeeeeeceesseeesseeeeseeceseeeesaeersneers 13-11 + +DOUMG aces satiets ibs. ee lrevsess deaesvisugedues Aavesesadsdouakach stbece Ausudeed evsbens sesmries susasdesheaatiesouaeeersaaaeaes 13-12 +Make a sound with the piezo (p_SOUNG)........... se eeseeeseeesseeceseeeesseecsacecseeessaeeesaeessaeers 13-12 +Get the:sounid flags (p~Setsnid )isvicic ascetic asesndausesenas aosendassceebaccaosondauseeeigacassendaseasieaiss 13-12 +Set the sound flags (p_setsnd)..........ceeseesceeesecsseeeeseeeesseecsaeecseeseseeceeaeeesaeesseeseeeese 13-12 + +SOuMGON the Series: Bais. ee sas sess baehiatesodses Aas dda ceagedads Sass deudcavedeua csnvseacouse cues cvsasiasoesecuessvaarces 13-13 +SOUMG: PCG 5 08 cece sek cteveznks Heekendedeesesha deesessadeecsseadies cubadu ys tadaduwasevgduncteds dyveceds tunesessdunssebane’ 13-13 +The A-Law-encodine Schemes. ic..i:ic-arisuiseuntaistanssoanaiianpadaiaiaieaniaiciet 13-13 + +Series 3a sound SySteM SELVICES..............::esececsoresesscrensetensnesnonersssevenseneneeesnenestosenenseteneeees 13-17 +Record a sound asynchronously (p_recordsounda) ...........::esecesesecsseecsseeeeseeeeseeesaeers 13-17 +Cancel sound recording (p_recordsoundcancel) ...........ceseceesseesseecsseecsseeeeseeeesaeersaeers 13-17 +Record a sound synchronously (p_recordsOundw)...........::ccsssccesseeesseeceseeeeseeeeseeesaeers 13-18 +Play back a sound asynchronously (p_playsounda)............ssseesseseseeeeseeeeeeeeeseeeesaeers 13-18 +Cancel sound playback (p_playsoundcancel)..........eeseeescceeseeeeeseeceseeesneeseseeeesaeessaeers 13-18 +Play back a sound synchronously (p_playsoundW) ...........:eesceeesecsseessseeeeseeeesaeeseaeers 13-19 + +Miscellaneous s..:is..ecstdsssecadeascest sssaacataateeatesssacateaustes teat beateaieceasodeipeubacntdonseuaeextanteaaneantss 13-19 +Exit t6:DOS:i(p Dwexit isi ocecissek deka oak cack aa hodee eae Pek elt HOLL Coheed Perel ote 13-19 +Null: action) (pdummy).sscc.2hse¢ssties, ccssdeas sosnbess diastase hethess Aanlanenerdass Aactasomarissnattass 13-19 + +14 Database Files............sccsssssscssscssscsssessscsssesssssssessscsssssssessssessssesssesssessscssscssscssscssscessesssessoeees 14-1 + +Overview of database files ............cccccceeesscceesseceecssnececeesnececeesneeeessaeeecsecaeeeessneeceesaeeessenees 14-1 +The file header ic.23 cc. cssccissctaecevvcuac deve stan devedansceseduvandeaesaceseiuarceneivan cons denecesecae ce seenvens 14-2 +ROCOLAS 3, fecsecth code ete doduaies Pout eteastuei ee deat edepetat eva vantedegeletecsertatedseslesedenransedevslehervaadteccey 14-2 +Strin Hels: .3:25 seysessegipassd abe dephaes aeseedaad ei gages ewes aivlshe hal aayoen iene: 14-3 +Number Of TECOrd S's. soitess ciecd oaks ice ah aed ca ae at ck Goenka ieee Uaehe ee eset cada een atid eae tient bec’ 14-3 +End. of file T6COrd sce. ceiscisvcestadeceuas seve evans cveiasaceae saute eeu ceaaceesceauceeycdda vescddaecsecddacvanceseeees 14-3 +Database files and OPL ............cceeccccessscceeeeseeeceeeceeeeeeeeeceenaeeecsseeeesenaeeecneneeeessneeeess 14-4 + +DBF fUnCtiOns y: s.ciscticcsisatcciviuek jevndsatecspasstecsvduetcdevdcedecus dene cevvacee cdevdeancdevecsoeds vacee ceeuecsbeseslade 14-4 +Open a database file (DbfOpen).......... eee eeeeeeseecsseeeeseecsscecssceceseeeesaeecsaeersaeessteeeesaes 14-4 +Open a database file (DbfQuickOpen).............ecceeeessseceeeeesreeesseecsaeesseeceeesneeesseeeesaes 14-6 +Close a database file (DDfCIOSE) ..........eccccccccccesessseeceececeeseesnseeeeeceessesseeeeeeceessesssaeeeees 14-6 +Flush a database file (DDfFIUSH) .............c cc ccceesssccceeccesssssseeeeeceeessesneeeeeeeeessesseeeeees 14-6 +Notify that the DBF buffer has been overwritten (DbfTrash)..............::cceessceeeeetteeees 14-6 +Copy down a DBF record (DbfCopyDown)........ eee eeeeeseecseceeeseessceceeeeeseeeesaeessaeers 14-6 +Compress a database file (DbfCompress) .............s:ceeseeesseeeeseeeeesececsseeceseeeenaeeeseeesaes 14-7 +Copy a database file (DbfCopyFile) 0.00.0... eee eeeeeceseeceeeeseeesseeceaeessseeceseeseeeesaeeesaes 14-7 +Find the size of a database file (DbfFileSize) ............cccccecssseceessessneeeeeeeeeseesseeeeeees 14-8 +Read a DBF extended header (DbfExtHeaderRead) ..............cccccccssscecceeeesessteeeeeeeeees 14-8 +Write a DBF extended header (DbfExtHeaderWrite) ..............ccccccccesssccceceeeesteceeeeeeees 14-9 +Read a DBF descriptive record (DbfDescRecordRead) ............::scccceseeceeeeteeeeeeneeeeeeee 14-9 +Write a DBF descriptive record (DbfDescRecord Write) ............ccsecceeeeeseeeeeeeeeesteeeees 14-9 +Get the DBF version number (DbfVersion)............ccccccccssccccccsssesseeeeeceeesssseeeeeeseseeaaee 14-10 +Read a specific DBF record (DbfAbsRead) ............ceeeecceeeeeeeeeeeeeeceeeneeeeesneeeeeeneeeess 14-10 +Read and sense a specific DBF record (DbfAbsReadSense)............:ccccccesssceeeeeseeeeeeeee 14-10 +Read the next DBF record (DbfNextRead) ..........ccccccsssscccceeesessneeeeeeeeeesessneeeeeeeeenes 14-10 +Read the previous DBF record (DbfBackRead) .............ccescccceeeseceeeeeeeeeeeneeeeeeeneeeeeees 14-11 +Read the first DBF record (DbfFirstRead)............000cccccccccccccscececceeeeeeeeessssssssessseseessees 14-11 +Read the last DBF record (DbfLastRead) 0.0.0.0... ccc ccscccccccccccccceeceeeceeeeeeeeceeeeeeeeeeeees 14-11 +Append a DBF record (DbfAppend) ..............ccceeeececeeseeceeeeeceeeeeeaeeeeeeneeeesseeeeeesnneeeess 14-12 +Erase a DBF record (DbfEraseRead)................ccccccccccsscscccccceeesesseeesestseeesessssstssseeeseees 14-12 +Update a DBF record (DbfUpdate)........ eee eeeeeeseeceseeceseesssececeseeeesseessaeessaeeesseeeesaes 14-13 +Find a DBF record (DbfFindReadField)..............:cccccccssssscccceeeeessesseeeeeesessessseeeeeeeeeees 14-13 +Find a DBF record (DbfFindRead)..............cccccccccccecccecceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeees 14-14 +Sense the current DBF record number (DbfSense) ............:ccccccccsssscececeesesssssteeeeeeeeees 14-16 +Count the number of DBF records (DbfCOUNE)............ceeeceeccccccessessneeeeeeeeessesessstseeeeees 14-16 + + +PLIB REFERENCE + + +15 Object Oriented Programming ...............cccsscccsscssscssscssccssscsesssscsessssccessssesesssscsessssesesssssesoes 15-1 +CHASSES + + +at the beginning of your C source file. + + +3The code, written in 8086 assembler, that provides a C function interface to a ROM-based service is +sometimes called a C shell. + + +1-4 + + +1 INTRODUCTION + + +The plib.h header file collects a default set of header files that are sufficient for the functions described in +this manual. + + +For most source files, plib.h will include more than you actually need. Once you are familiar with PLIB +and if you can be bothered, you may wish to browse around the header files in the \sibosdk\include +directory to work out which files you need to include in a particular source file. + + +In all the structs in the PLIB headers, we have been careful to organise the members so that 16-bit (or +wider) variables are on even address boundaries - since the 8086 processor can fetch a 16-bit word in a +single cycle rather than two if the word is at an even address. + + +p_std.h + + +Because Psion has had ten years of working with C using tens of different C compilers to develop for tens +of different target computers, we have of necessity developed a fairly defensive approach to our C sources. +Rather than using the C variable types and declarations directly, we define our own to give us the +opportunity of re-defining their meaning, depending on the compiler. All these definitions are in p_std.h +that is included first by plib.h. + + +The following extract from the Clarion version of p_std.h is for declaring functions and data: + + +#define GLREF_D extern +#define GLDEF_D +#define LOCAL_D static +#define GLREF_C extern +#define LOCAL_C static +#define GLDEF_C + + +where the _c and _p refer to code and data respectively and where: + + +LOCAL_C are used to declare local functions and local static variables +LOCAL_D + +GLDEF_C are used to declare global functions and global variables + +GLDEF_D + +GLREF_C are used to declare function prototypes and external global variables +GLREF_D + + +The following extract from p_std.h declares operand types: + + +#define VOID void + + +typedef int INT,HANDLE;_ + +typedef unsigned int UINT;_ +typedef char BYTE;_ + +typedef unsigned char UBYTE;_ +typedef short int WORD;_ + +typedef unsigned short int UWORD;_ +typedef long int LONG;_ + +typedef unsigned long int ULONG;_ +typedef double DOUBLE; _ + +typedef char TEXT; + + +where the meanings of BYTE, UBYTE, WORD, UWORD, INT, UINT, LONG, ULONG and DouBLE are as suggested by +their names (and where a leading u means unsigned). + + +By convention, we favour the signed variant in cases where it does not matter whether the signed or the +unsigned variant is used. + + +The Text type is used to indicate character data as in, for example: +TEXT *str; +where str points to a character string. + + +The HanbLe typedef is used to refer to an instance of something - such as a process or a memory segment. +In many cases, a HANDLE is actually the offset into the operating system's data space. + + +1-5 + + +PLIB REFERENCE + + +This manual uses the above declarations in function descriptions and examples so you do need to know +about them to be able to understand this manual. + + +However, this does not mean that you have to use our declarations. For example, using our declarations, +you can write: + + +#include + + +GLDEF_C INT main(VOID) +{ +p_printf ("Hello world"); +p_getch (); +return (0); + + +} +or, not using our declarations, you can write: + + +#include + + +int main (void) +{ +p_printf ("Hello world"); +p_getch (); +return (0); + + +} +It is entirely up to you. +Calling conventions +The content of this section is quite technical. Provided you: +e include plib.h +e declare local functions before calling them +¢ use prototypes when calling your own global functions + + +you don't need to be particularly aware of the calling convention used and you don't have to understand +this section (although you may feel more comfortable if you do). + + +The only exception is for functions which take as a parameter the address of (and subsequently call) a +second function. In such a case you must declare an explicit calling convention for the second function. In +PLIB this occurs when using p_enter, used to handle errors, or when using an object-oriented +programming message-sending function such as p_send. In these two cases the descriptions of the +relevant functions include full guidance. + + +For a greater understanding of calling conventions and the #pragma cali declaration, refer to the +TopSpeed documentation. + + +With the TopSpeed C compiler you can change the calling convention using: + + +#pragma save to save the current calling convention + +#pragma call to set a new current calling convention as defined by parameters that follow +call + +#pragma restore to restore a previously saved calling convention + + +You can also declare functions to use a stack-based calling convention using CDECL. + + +The C header files containing the prototypes for the PLIB functions (and automatically included when you +include plib.h) also contain #pragma statements that declare calling conventions on a function by function +basis. + + +For example, the prototype for p_bcpy is effectively: + + +#pragma save + +#pragma call(reg_param =>(di,si,cx),reg_saved =>(bx,cx,dx,si,di,ds,st1,st2) ) +GLREF_C UBYTE *p_bcpy(VOID *,VOID *,UINT); + +#pragma restore + + +where the three parameters to p_bcpy are passed in the registers DI SI and CX as required by the +BufferCopy interrupt (described in the EPOC O/S System Services reference manual). + + +1-6 + + +1 INTRODUCTION + + +When defining a sequence of prototypes, you only need to bracket the sequence with #pragma save and +#pragma restore - not each individual prototype. + + +Prototypes for PLIB functions that take a variable number of parameters must use a stack-based calling +convention and are declared using cpEct as in, for example: + + +GLREF_C INT CDECL p_iow(VOID *,INT,...); + + +In many cases (where there is a limit to the number of parameters), the same function is also offered in +fixed parameter versions as in, for example: + + +INT p_iow2(VOID *pcb, UINT func); +INT p_iow3(VOID *pcb, UINT func, VOID *al); +INT p_iow4(VOID *pcb, UINT func, VOID *al, VOID *a2); + + +where you can use the appropriate fixed parameter variant to take advantage of a more efficient register +calling convention. + + +When calling your own functions, you don't need to worry about setting a calling convention since the +default calling convention will apply. The default (register) calling convention is: + + +#pragma call(reg_saved =>(ax,bx,cx,dx,di,si,ds,stl,st2),reg_param +=> (ax, bx, cx, dx) ,c_conv=>off) + + +When the compiler comes across a function that is declared as taking a variable number of arguments, +such as: + + +LOCAL_C VOID PrintToLog(TEXT *str, ...) +it ignores the current calling convention and uses a stack-based calling convention. +Small programs + + +Because the body of nearly all PLIB functions is provided by code in the ROM, C programs built for +EPOC are typically significantly smaller than, say, the standard C library on a PC. + + +The difference is at its most extreme when there is such a small amount of program-specific code that the +size of the program is dominated by the code that is brought in from the library. For example, the +following program: + + +#include + + +GLDEF_C INT main(VOID) +{ +p_printf ("Hello world"); +p_getch (); +return (0); + + +} + + +when compiled and linked for EPOC produces a program that contains fewer than 500 bytes of code. +Depending on the compiler, upwards of 10K is typical on a PC. + + +The amount of memory required to run an EPOC program (sometimes called the "working set") typically +ranges from 10K to 100K bytes. For example, when using the Spreadsheet on the MC400 (a large +program by any standard), you can load about 70K of code and open and manipulate a 10K spreadsheet +with less than 100K of free system memory. + + +In practice, it is quite possible to take advantage of the multi-tasking and run several programs at the +same time and especially (given that the code is only loaded once) to run more than one process of the +same program. + + +The PLIB C startup modules + + +When producing an executable using the linker, a C startup module is automatically linked in before the +program-specific modules and the libraries. + + +A number of C startup modules is supplied with PLIB where each module sets set up a different stack size +(typically ranging from 2K to 8K). Except for the different stack size, the different PLIB startup modules +are identical - they all declare the same basic structure for the process data segment - as described in the +chapter Memory Allocation. + + +The code in the PLIB startup modules is minimal - it just connects to the file server (using a Filconnect +interrupt) before jumping to main (most applications need the services of the file server and the overhead +to connecting to the file server is modest). + + +PLIB REFERENCE + + +Note that the PLIB startup modules do not set up the standard argv, argc parameters to main because +PLIB is not particularly designed for command line user interfaces (although there is a mechanism for +passing parameters when starting a process - see the chapter Processes and Inter-Process Messaging). + + +Not all the stack that is declared in the PLIB startup module may be used by the program and you should +subtract: + + +0x100 for any program + + +0x300 for programs that use the floating point emulator (as described in the Floating +Point chapter) + + +Related reference manuals + + +The ROM contains more system code than is directly accessed by the functions described in this manual. +In addition, a standard C library (CLIB) is provided. + + +TopSpeed C library reference + + +CLIB is a version of the TopSpeed C library for the EPOC operating system. The functions in CLIB are +described in the TopSpeed C Library Reference manual. Additional notes, including a list of the +TopSpeed C library functions that are not implemented, may be found in \sibosdk\doc\clib.doc. + + +The EPOC version of the TopSpeed C library supports the ANSI functions and most of the portable +functions that are commonly supported by MSDOS C libraries such as Microsoft C and Borland's +Turbo C. The less portable functions such as those that access the BIOS and graphics functions are not +included. + + +The benefits of using CLIB are: +e portability (existing C programs may easily be converted) +e less to learn for programmers already familiar with standard C libraries + + +Although the EPOC system services (and hence PLIB) has comprehensive support for floating point +operations, it does not provide this support in a way that supports the floating point C as generated by the +TopSpeed C compiler. This is described more fully in the chapter Floating Point in this manual. + + +As you might expect, using CLIB in place of PLIB makes less efficient use of the SIBO architecture. In +particular: + + +e many of the EPOC system services are not available from CLIB (eg asynchronous I/O, inter- +process messaging, the window server graphics functions) + + +e executables are larger and the process takes a larger data segment + + +The executables are larger because, although CLIB uses the ROM-based system services wherever +possible and fares better than the PC library, it is still a much "thicker" library than PLIB. The data +segments also tend to be larger because the various CLIB subsystems typically require large static buffers +and tables. + + +For example, the following CLIB program: + + +#include + + +int main (void) +{ +printf ("Hello world"); +getchar(); +return (0); + + +} + + +when compiled and linked for EPOC produces a program that contains 6K bytes of code (as compared +with 0.5K for the equivalent PLIB program). + + +Unless you are using the in-built user interface object dynamic libraries (accessed using object-oriented +programming) described below, you can freely mix PLIB calls with CLIB. We expect most experienced C +programmers to use CLIB and regard PLIB and WLIB (the window server library, described below) as +they would regard non-portable components of any C library. + + +1-8 + + +1 INTRODUCTION + + +It is worth converting completely to PLIB and WLIB when the desirability of making efficient use of +memory outweighs the benefits of portability and familiarity. + + +Window server reference + + +The window server is a system process that provides shared access to the screen and keyboard (and also a +pointing device, if present). + + +The PLIB library contains only primitive console functions to input typed lines (with simple backspace +editing) and to output lines of mono-spaced characters. The con: device driver provides row and column +positioning and printing of mono-spaced characters. + + +Although the PLIB console functions and the con: device driver ultimately call on the window server for +both user input and screen drawing, the window server is capable of far more than can be accessed via +these interfaces. In particular, the window server can be used to implement graphical user interfaces and +to display bitmap images such as maps and diagrams. The WLIB library contains a set of C functions that +can access all the services of the window server. These functions are described in the Window Server +Reference manual. + + +The window server supports the following features: +e =ahierarchical system of overlapping windows where all drawing is clipped to visible areas + + +e redraw events informing the client of areas of windows that need to be redrawn, with redrawing +clipped to the invalid areas + + +e =multi-font (proportional and mono-spaced) pixel addressable text drawing in a variety of text +modes and styles + + +e fast bitmap operations +e drawing of lines, boxes and pattern-filled areas in a variety of modes + + +¢ optional double drawing to a background bitmap as well as the window such that the window +server automatically redraws windows as necessary + + +Like PLIB, the WLIB library is a library of thin C shell functions that contain software interrupts to +ROM-based code. + + +I/O devices reference + + +This /O System chapter in this manual describes the EPOC I/O system in general and the PLIB C +functions that are used to access I/O devices. + + +A device driver may be built into the ROM or it may be loaded from an external source (such as an SSD). +To use a particular device you need to read a description of the device driver. + + +The files device driver and the asynchronous timer device driver are described in this manual - in the +chapters Files and Time, Timers and Dates respectively. All other device drivers are described in the /O +Devices Reference manual. + + +The I/O Devices Reference manual describes device drivers that have been written by Psion - many of +which are commonly supplied in the ROM. The device drivers described include the following: + + +e Parallel port (PAR:) + +e = Serial port (TTY:) + +e Console device (CON:) +e Sound driver (SND:) + + +Descriptions of additional device drivers will be added to the I/O Devices Reference manual from time to +time. + + +EPOC O/S System Services reference manual + + +The EPOC O/S System Services reference manual describes the software interrupt interface to the ROM- +based system services. + + +Nearly all of the services are available from C using the functions in PLIB. The CLIB library also uses the +system services where possible (the source for CLIB may be found in \sibosdk\src). + + +PLIB REFERENCE + + +Because the EPOC O/S System Services reference manual is intended to be used in conjunction with the +PLIB Reference manual, the descriptions in the EPOC O/S System Services reference manual are +comparatively brief. + + +You would refer to the EPOC O/S System Services reference manual if you were writing in 8086 +assembler or accessing a system service from OPL. In this case, you should refer to the corresponding +function in the PLIB manual for a fuller description of the service (there is a list of the corresponding +PLIB functions in an appendix of the EPOC O/S System Services reference manual). Being able to refer to +the description of a software interrupt can be useful when debugging C programs. + + +The EPOC O/S System Services reference manual also contains information on: +e writing device drivers +e writing an installable file system +e hardware interfacing + + +Object dynamic libraries + + +The Object-Oriented Programming chapter of this manual describes a set of functions that provide run- +time support for object-oriented programming where object classes are constructed by: + + +e using a proprietary tool to define class property structures and to declare methods +e using regular TopSpeed C to implement the declared method functions for each class + + +Object-oriented programming techniques are well-suited to implementation of graphic user interfaces and +multi-threaded application control. + + +The object dynamic libraries (DYLs) contain classes that may be used and/or subclassed to construct +applications with a consistent graphical user interface. The classes supplied in the libraries include the +following: + + +e dynamic variable length arrays and large character buffers for building complex in-memory data +structures + + +e active objects that represent a variety of event sources for controlling multi-threaded programs + + +e an extensive window class tree supporting such graphics user interface components as menus, +dialog boxes and edit boxes + + +The classes that are used to build user interfaces may vary for different SIBO machines. At the time of +writing, a user interface object library had not been constructed for the HC range (since there is no +requirement for a consistent user interface on a machine of this type). + + +The object classes are organised into dynamic libraries (DYLs) in the ROM. For example, the MC400 +has: + + +OLIB.DYL containing classes that are independent of the user interface +WIMP .DYL containing classes that implement the graphical user interface + + +The object-oriented message passing mechanism also serves as a means of calling far code (such as the +code in ROM-based DYLs). Large applications may be split into multiple DYLs to reduce their working +set and to overcome the 64K code segment limit. + + +The object classes are described in a manual per DYL. For example, the OLIB Reference Manual +describes variable arrays and active objects. + + +1-10 + + +CHAPTER 2 + + +CHARACTERS, STRINGS AND BUFFERS + + +General string and buffer functions + + +PLIB contains the following general string and buffer functions: + + +p_bcpy to copy a buffer + +p_slen returns the length of a string + +p_scpy, p_scpym to copy a string or multiple strings + +p_scat, p_scatm to concatenate a string or multiple strings + +p_brep, p_srep to fill a buffer or string with a repeated sequence + +p_bswap to swap the contents of two buffers + +p_bfil to fill a buffer with a repeated character + +p_jtob to left, right or centre align a buffer in a (normally wider) buffer with a fill +character + +p_ere to generate the CRC number of a buffer + +p_bcpy Copy memory to memory + + +UBYTE *p_bcpy(VOID *target, VOID *source, UINT len); + + +Copy len bytes of data from source to target and return the address following the last byte written (ie +targettlen). + + +The data is copied correctly when source and target overlap. +For example: + + +p_bcpy (str+1,str,p_slen(str)+1); +*str='A'; + + +inserts 'A’ at the beginning of str. + + +p_slen Return string length +UINT p_slen(TEXT *str); + + +Return the length of the zero terminated string str, not including the terminating zero. + + +p_scpy Copy a string +TEXT *p_scpy(TEXT *target, TEXT *source); + + +Copy the zero terminated string source, producing a zero terminated string at target and return the +address of the terminating zero of target. + + +The strings should not overlap. +For example: +p_scpy (buf, "hello"); + + +writes "hello" to buf. + + +PLIB REFERENCE + + +p_scpym Copy multiple strings +TEXT *p_scpym(TEXT *target, ...); + + +Copy and concatenate a list of zero terminated strings to target creating a zero terminated string at +target. + + +Returns the address of the zero that terminates the string at target. + + +The first string is copied to target and the following strings are concatenated to it. The list of strings +should be terminated by a NULL argument. + + +For example: +p_scpym(buf,"The cat"," jumped", NULL) ; + + +writes "The cat jumped" to buf. + + +p_scat Concatenate two strings + + +TEXT *p_scat (TEXT *lstr, TEXT *rstr); + + +Concatenate the zero terminated string rst r to the zero terminated string 1str and return the address of +the zero that terminates the new string at 1str. + + +For example: + + +p_scpy (buf, "hello"); +p_scat (buf," fred"); + + +writes "hello fred" to buf. + + +p_scatm Concatenate many strings +TEXT *p_scatm(TEXT *lstr, ...); + +Concatenate a list of zero terminated strings to the zero terminated string 1str. + +Returns the address of the zero that terminates the new string at 1str. + +The list of strings should be terminated by a NULL argument. + +For example: + + +p_scpy (buf, "The"); +p_scatm(buf," cat"," jumped", NULL) ; + + +writes "The cat jumped" to buf. + + +p_brep Replicate a buffer +UBYTE *p_brep(VOID *buf, INT buf_len, VOID *pattern, INT pat_len); + + +Replicate pattern as many times as necessary to exactly fill the buffer but of length buf_1en and return +the address of the byte following the last byte written (ie buf+buf_len). + + +If buf_1lenrbuf then return is greater than 0 +If lbuf==rbuf then return equals 0 + + +2-8 + + +2 CHARACTERS, STRINGS AND BUFFERS + + +The result of the comparison is based on the difference of the first two unsigned bytes to disagree. The +strings are equal if they have the same length and content. Where two strings have different lengths and +the shorter string matches the first part of the longer string, the shorter string is considered to be less than +the longer string. + + +For example: + + +p_bemp ("abc", 3, "abcd", 4) returns less than 0 +p_bemp ("abcd", 4, "abc", 3) returns greater than 0 +p_bemp ("abc", 3, "abc", 3) returns 0. + + +p_scmp Compare two strings + + +INT p_scmp(TEXT *lstr, TEXT *rstr); + + +Compare two zero terminated strings by comparing corresponding characters, returning 1str-rstr, +that is: + + +If 1strrstr then return is greater than 0 +If 1str==rstr then return equals 0 + + +The result of the comparison is based on the difference between the first two characters to disagree. The +strings are equal if they have the same length and content. + + +For example: + + +p_scmp ("abc", "abcd") returns less than 0 +p_scmp ("abcd", "abc") returns greater than 0 +p_scmp ("abc", "abc") returns 0 + + +p_bcmpi Case independent buffer compare + + +INT p_bcempi(TEXT *lbuf, INT lbuf_len, TEXT *rbuf, INT rbuf_len); + + +Performs a case independent comparison of the two buffers by effectively folding the characters in both +buffers before comparing them using p_bcmp. Returns as for p_bcmp, described above. + + +For example: + + +p_bempi ("abc", 3, "abcd", 4) returns less than 0 +p_bempi ("abcd", 4, "abc", 3) returns greater than 0 +p_bempi ("ABC", 3, "abc", 3) returns 0 + + +p_scmpi Case independent string compare + + +INT p_scmpi(TEXT *lstr, TEXT *rstr); + + +Performs a case independent comparison of the two zero terminated strings 1str and rstr by effectively +folding the characters in each string before comparing them using p_scmp. Returns as for p_scmp, +described above. + + +For example: + + +p_scmpi("abc", "abcd") returns less than 0 +p_scmpi ("abcd", "abc") returns greater than 0 +p_scmpi("ABC", "abc") returns 0 + + +2-9 + + +PLIB REFERENCE + + +String searching + + +The PLIB string searching functions are: + + +p_bloc, p_sloc, to search for a character +p_bloci, p_sloci, +p_slocr, p_slocri + + +p_bsub, p_ssub, to search for a sequence of characters +p_bsubi, p_ssubi + + +p_bmatch, p_smatch, to search for a sequence of characters that matches a wildcard specification +p_bmatchi, p_smatchi + + +p_bloc Locate byte in buffer +INT p_bloc(VOID *buf, INT buf_len, INT ch); + + +Locate the byte ch in the buffer at buf of length buf_1en returning the index of the first matching byte or +-1 if ch is not in the buffer. + + +For example: + + +p_bloc("abcde",5,'£') returns -1 +p_bloc("abcde",5,'a') returns 0 +p_bloc("abcde",5,'c') returns 2 + + +p_sloc Locate character in string + + +INT p_sloc(TEXT *str, INT ch); + + +Locate the first occurrence of the character ch in the zero terminated string str, returning the index of the +first matching character or -1 if ch is not in str. + + +For example: + + +p_sloc("abcde", '£') returns -1 +p_sloc("abcde", 'a') returns 0 +p_sloc("abcde",'c') returns 2 + + +p_bloci Case independent locate character in buffer +INT p_bloci(TEXT *buf, INT buf_len, INT ch); + + +Perform a case independent locate of ch in the buffer buf by effectively folding ch and the characters in +buf before using p_bloc to locate the folded character. Returns as for p_bloc, described above. + + +For example: + + +p_bloci ("abcde",5,'f£') returns -1 +p_bloci ("abcde",5,'A') returns 0 +p_bloci ("abcde",5,'c') returns 2 + + +p_sloci Case independent locate character in string + + +INT p_sloci(TEXT *str, INT ch); + + +Perform a case independent locate of ch in the zero terminated string str by effectively folding ch and the +characters in str before using p_sloc to locate the folded character. Returns as for p_sloc, described +above. + + +For example: + + +p_sloci ("abcde", '£') returns -1 +p_sloci ("abcde", 'a') returns 0 +p_sloci ("abcde", 'c') returns 2 + + +2-10 + + +2 CHARACTERS, STRINGS AND BUFFERS + + +p_slocr Locate last matching character in a string + + +INT p_slocr(TEXT *str, INT ch); + + +Locate the last occurrence of the character ch in the zero terminated string str, returning the index of the +matching character or -1 if ch is not in str. + + +For example: + + +p_slocr("abcabc", 'A') returns -1 +p_slocr ("abcabc", 'a') returns 3 + + +p_slocri Locate last matching folded character in a string + + +INT p_slocri(TEXT *str, INT ch); + + +Locate the last occurrence of ch in the zero terminated string str by effectively folding ch and the +characters in str before using p_slocr to locate the folded character. Returns as for p_siocr, described +above. + + +For example: + + +p_slocri("abcde", 'f£') returns -1 +p_slocri("abcabc", 'A') returns 3 + + +p_bsub Locate sub-buffer in buffer + + +INT p_bsub(VOID *buf, INT buf_len, VOID *sbuf, INT sbuf_len); + + +Locate sub-buffer sbuf, sbuf_len In buf, buf_len returning the index of the start of sbuf in buf or -1 if +sbuf does not exist in but (which must be the case if buf_len0 *pmatch belongs after record number *pmid + + +If two or more array elements exactly match the record at pmatch, the return value will be zero and *pmia +will contain the index of any one of the matching elements. + + +Each time p_bsrch needs to compare a record with the record at pmatch it calls: +compf (n, pmatch) ; + + +where n is the index of the record to be compared. This user-supplied comparison routine should return: + + +0 *pmatch 1s equal to record number n +<0 *pmatch is before record number n +>0 *pmatch is after record number n + + +As with any binary search, the array must be ordered. For p_bsrch, it should be ordered with respect to +compf, the user-supplied comparison routine. + + +In most cases the set of records will be a fixed array, but any arrangement which allows the routine to +identify a record by index (e.g. hashing) will be suitable. Likewise, pmatch may be any address suitable for +interpretation by compf, since pmatch is not used inside p_bsrch, other than being passed to compf. This +allows code using p_bsrch to be re-entrant. + + +If the whole table is created before being searched it is, in general, quicker to build the table unordered +and then sort it (see p_qsort) than to build the table in sequence by insertion. + + +3-1 + + +PLIB REFERENCE + + +Example + + +LOCAL_D INT array[]={5,8,13,19,25,30,41,48,51, 62,70, 76, 80, 90, 98}; + + +LOCAL_C intcompare (INT n,INT *pmatch) + + +{ +INT f£,m; + + +f=array[n]; +m=*pmatch; +if (f==m) + +return (0); +return (m>f£?1:-1); + + +} + + +VOID find(INT match) +{ +INT nrec; /* number of INTs in the array */ +INT result; +INT mid; +TEXT *pstr; + + +nrec=sizeof (array) /sizeof (INT) + + +, +result=p_bsrch(nrec, (INT (*) ()) intcompare, &mid, &match) ; +if (!result) + +p_printf("sd matches record number %d",match,mid) ; +else + +{ + +pstr=result<0?"before": "after"; + + +p_printf("%d belongs %s %d",match,pstr,array[mid]); + + +} + + +p_qsort Sort an array of records + +INT p_qsort (INT nrec, INT (*ordf)(), VOID (*excf) (), UBYTE *base) + +Sort a set of records into ascending order, using the quicksort algorithm. + +There are nrec records to sort. Each time the routine needs to compare two of these records it calls: +(*ordf) (n,m,base) ; + + +where n and mare the indexes of the two records to compare (starting at zero), and base is a parameter +that may be used or ignored by the ordering function. + + +The ordering function, ordf, should return: + + +0 record number n is equal to record number m +<0 record number n is less than record number m +>0 record number n is greater than record number m + + +Each time the routine needs to exchange two records it calls: +(*excf) (n,m, base) ; + + +where n and mare the indexes (starting at zero) of the two records to exchange. The user-supplied +exchange routine should exchange the records indexed by n and m. Again, the user-supplied exchange +function is free to use or ignore base, but its use should be consistent between the ordering and exchange +functions. + + +Normally, base will represent the address of a fixed length array, but any method of storing records may +be used, as long as the records can be accessed using the indices. The value of base is not used inside +p_gqsort, but is passed down to both the ordering and exchange functions to enable the writing of re- +entrant code that uses p_qsort. + + +The routine uses its own stack, declared locally, to avoid the need to be called recursively. This stack is +150*sizeof (INT) in length and, as such, could cause the main stack to overflow if the routine is called +from too deep inside a program. + + +The function p_gsort returns zero if successful, else a negative error. + + +3-2 + + +3 ARRAYS AND QUEUES + + +An error return value of £_GEN_FaIL is returned if the internal stack overflows. This is, however, unlikely +as an experiment to sort 50000 elements used only 80 stack elements. If this error is returned, the routine +can be called again, as it is likely that the array has been rearranged enough to permit the successful +completion of a second attempt. + + +Example + + +LOCAL _D INT array[]={98,90,80,76,70,62,51,48,41,30,25,19,13,8,5}; + + +LOCAL_C intcompare(INT first,INI second, INT *array) + + +{ +INT £,s; + + +f=* (array+first); +s=* (array+second) ; +if (s==f) + +return (0); + +return (f>s?1:-1); + + +} + + +LOCAL_C VOID intexchange(INT first,INT second, INT *array) + + +{ +INT r; + + +r=* (arrayt+first) ; +* (array+first) =* (array+second) ; +* (array+second) =r; + + +} + + +LOCAL_C VOID sort (VOID) + + +{ +INT n; /* number of INTs in the array */ + + +n=sizeof (array) /sizeof (INT); +if (p_qsort (n,intcompare, intexchange, &array[0]) ) +p_panic("Too many partitions"); + + +Doubly linked queues + + +This section describes functions for inserting and deleting entries from doubly linked queues. Each entry +in the queue contains a P_guz structure, defined in p_que.h as: + + +typedef struct p_que +{ +struct p_que *next; /* pointer to next item */ +struct p_que *prev; /* pointer to previous item */ +} P_QUE; + + +A special header entry consisting only of a p_ouz data structure provides a single address by which the +queue may be accessed. The empty queue consists only of the p_quz header with both next and prev +pointing to itself. A queue with n entries contains n+1 P_que structures - one for the header and one for +each entry. The queue is built such that the next pointer of the last entry points to the header and the prev +pointer of the header points to the last entry such that the n+1 p_oue structures form a doubly linked +circular queue. + + +The following extract from p_que.h: + + +#define P_INITQ(q) (q)-—>next=(q) ->prev=(q) +#define P_DECLAREQ(q) P_QUE q = {&q,&q} +#define P_ISEMPTYQ(q) ((q)==(q) ->next) + + +defines 3 macros where: + + +P_INITO may be used to initialise a header that represents an empty queue +P_DECLAREQ may be used to declare a header that represents an empty queue +P_ISEMPTYQ evaluates to TRUE if the queue header represents an empty queue + + +3-3 + + +PLIB REFERENCE + + +Entries are inserted into a queue using p_enque and removed using p_deque. Neither of these functions set +aside memory for entries or free memory - they merely make and break the links between entries. + + +The following example illustrates the use of p_enque and p_deque to set up a queue of zero terminated +strings that are allocated and freed from the heap (see the chapter Memory Allocation for a description of +f_alloc and p_free). + + +#include +#include + + +typedef struct +P_QUE pid; +TEXT name[1]; +} QUEUE_ENTRY; + + +LOCAL_D P_DECLAREQ (headq) ; + + +GLDEF_C VOID AddNameToEnd (TEXT *name) + + +QUEUE_ENTRY *p; + + +p=f_alloc(p_slen (name) +sizeof (QUEUE_ENTRY) ) ; +p_scpy (&p->name[0],name) ; + +p_enque (&p->piq, &headq) ; + +} + + +GLDEF_C TEXT *FirstName (VOID) + + +{ +TEXT *name; + + +name=é& (((QUEUE_ENTRY *)headq.next)—->name[0]); +if (P_ISEMPTYQ (&headq) ) + +name=NULL; +return (name) ; + + +} + + +GLDEF_C VOID DeleteFirstName (VOID) + + +{ +QUEUE_ENTRY *p; + + +p=(QUEUE_ENTRY *) headq.next; +p_deque (&p->pig) ; + +p_free(p); + +} + + +Names are allocated and added to the end of the queue using AddNameToEnd. The code that processes the +items in the queue uses FirstName to get the first item in the queue (which returns NuLt if the queue is +empty). After processing the first name, calling DeleterirstName removes it from the queue and frees the +memory used by it. + + +p_enque Add entry to queue + + +VOID p_enque(P_QUE *pNew, P_QUE *pEntry) ; + + +Insert entry pNew before pEnt ry (ie between pEnt ry->prev and pEnt ry) into the doubly linked queue that +contains pEntry. + + +If P_QUE hdq is the queue header: + + +p_enque (pNew, &hdq) adds pNew to the end of the queue (since queues are circular the previous +entry to the header is the entry at the end of the queue) + + +p_enque (pNew,hdq.next) adds pNew to the start of the queue + + +3 ARRAYS AND QUEUES + + +p_deque Remove entry from queue + + +VOID p_deque(P_QUE *pEntry); + + +Remove queue entry pEnt ry by linking the entries on either side of pEntry to each other, excluding +pEntry from the queue. + + +If P_QUE hdg is the queue header: +p_deque (hdq.next) removes the first entry from the queue + + +p_deque (hdq. prev) removes the last entry from the queue (since queues are circular the previous +entry to the header is the entry at the end of the queue) + + +If hdg is empty then p_deque (&hdq) will have no effect. Calling p_deque (ahdq) of a non-empty queue is +not a good idea as there will then be no way to get into the queue. + + +EEE +Delta queues + + +A delta queue builds on doubly linked queues, described in the previous section, to store entries ordered on +a tone key. + + +A delta queue consists of a p_oquz header and doubly linked entries, each containing a p_pELTA structure, +defined in p_que.h as: + + +typedef struct +{ +P_QUE q; +LONG key; /* Delta key */ +} P_DELTA; + + +where (except for the first entry in the queue) key contains the offset relative to the previous entry (the +delta). The value of an entry's key is determined by accumulating the deltas of its predecessors. For the +first entry, the key is just the delta. + + +The EPOC operating system uses a delta queue to implement timers. Each entry represents a timer where +the key is the relative time in system ticks to the expiry of that timer and the delta is then the number of +system ticks after its predecessor. This design minimises the system effort to maintain the timers - on each +tick the system only has to decrement the head of the queue. See the chapters Asynchronous Requests and +Semaphores and Time, Timers and Dates for more about the time delta queue and timers. + + +A delta list is set up much as a regular queue. A header is declared and initialised using (p_1INTTQ or +P_DECLAREQ) giving an empty queue. Entries containing a p_pELTAa structure are added to the delta queue +using p_enqued and are removed using p_dequed. + + +Neither function allocates or frees memory for entries - all they do is maintain the links and calculate the +deltas. + + +p_enqued Add entry to delta queue +P_DELTA *p_enqued(P_QUE *pHead, P_DELTA *pEntry, LONG key); + + +Inserts entry pEnt ry into the delta queue headed by pHeaa according to the key key and returns the +address of the first entry in the queue. + + +The queue is scanned, accumulating the key from the deltas, until an entry is found with a key that is +greater than key. The new entry pEntry is inserted (with an appropriate delta) before that entry and the +delta of that entry is recalculated. + + +3-5 + + +PLIB REFERENCE + + +p_dequed Remove entry from delta queue +P_DELTA *p_dequed(P_QUE *pHead, P_DELTA *pEntry); + + +Remove pEnt ry from the delta queue headed by pHead and return the address of the first entry or NULL if +p_dequed leaves the queue empty. + + +The delta of any following entry is updated to keep the accumulated key of each remaining entry constant. +If P_QUE hdgq is the queue header: +p_dequed(&hdq, (P_DELTA *)hdq.next); + + +removes the first entry from the queue. + + +CHAPTER 4 + + +INTEGER CONVERSION AND RECTANGLE + + +FUNCTIONS + + +This chapter describes functions for converting integer numbers to a textual representation (eg to print a +number) and vice versa (eg to input a number). + + +The chapter ends with a section that describes a set of functions that operate on rectangle data structures. +These are useful, for example, when organizing a screen display. + + +Converting integers to text + + +PLIB contains the following functions to convert various types of integers to a textual representation: + + +p_itob to convert an INT to a signed decimal number + +p_ltob to convert a Lonc to a signed decimal number + +p_gtob to convert a UINT to an unsigned number in any radix + +p_gltob to convert a ULONG to an unsigned number in any radix + +p_atob, p_atos for general purpose conversion and formatting of multiple arguments + + +The functions that handle "any radix" are typically used to handle a radix of 2 (binary), 8 (octal), 10 +(decimal) or 16 (hexadecimal). + + +Note that it is up to the caller to ensure that there is sufficient space in the target buffers for the output of +the conversion. + + +p_itob Convert an INT to decimal buffer +UINT p_itob(TEXT *buf, INT value); +Write a signed decimal representation of value to buf and return the number of characters written. +If value is negative, a leading '-' is written. +For example: +buf [p_itob (&buf[0],-24) ]="\0"'; + + +writes "-24" to buf. + + +PLIB REFERENCE + + +p_ltob Convert a LONG to decimal buffer +INT p_ltob(TEXT *buf, LONG value); + + +Write a signed decimal representation of the LoNG value to buf and return the number of characters +written. + + +If value is negative, a leading '-' is written. +For example: +buf [p_ltob (&buf[0],-240000L) ]="\0'; + + +writes "-240000" to buf. + + +p_gtob Convert a UINT to buffer any radix +INT p_gtob(TEXT *buf, UINT value, INT radix); +Write an unsigned base radix representation of value to buf and return the number of characters written. +For example: + +buf [p_gtob (buf, 0xaa55,16) ]='"\0'; + + +writes "AA55" to buf. + + +p_gltob Convert a ULONG to buffer any radix +INT p_gltob(TEXT *buf, ULONG value, INT radix); + + +Write an unsigned base radix representation of the ULONG value to buf and return the number of +characters written. + + +For example: +buf [p_gltob (buf, 0xaa5577,16)]='\0'; + + +writes "AA5577" to buf. + + +p_atob Convert multiple arguments to buffer + + +INT p_atob(TEXT *buf, TEXT *fstr, VOID *parg); + + +Write formatted text to buf as controlled by the format zero terminated string fstr and the argument list +parg and return the number of characters written. + + +The format string fstr contains literal text, embedded with commands for converting the arguments at +parg. The embedded commands are prefixed with the '%' character (two successive '%' characters count as +one literal '%'). The literal text is simply copied to buf and the % commands convert successive +arguments (which may be integers, longs or strings) at parg. + + +An embedded command takes one of the following forms: + + +3 for output (with no padding) of the converted data type that is one of b, +c, d, f, m, 0, s, u, w or x (as described below). Where appropriate, the type may +be widened to a long by preceding the type letter with an | or an L or by +providing the type letter in upper case. + + +% for right-aligned space-filled output in width where is either a +positive decimal number or a * to take the width as a u1nt from the argument +list. If more than characters is generated by the conversion, the output +is truncated. + + +%0 for right-aligned zero-filled output in width . + + +% for left, right or centre aligned output in width with fill character <£> +where is either -, + or =. If <£> is a *, the code of the fill character is taken +as a UINT from the argument list. (If you want to fill with «'s, you have to +supply it through the argument list). + + +4-2 + + +4 INTEGER CONVERSION AND RECTANGLE FUNCTIONS + + +A common requirement is for space-filled output. It is therefore worth enumerating special cases, using +the last of the above four forms of embedded command. Note that, in all cases, there is a space (the fill +character) immediately preceding . + + +%- for left-aligned space-filled output in width +%+ for right-aligned space-filled output in width +%= for centre-aligned space-filled output in width + + +The specifies the type of argument conversion to be performed, as follows: +b convert the urnt to a binary text representation +c convert the urnt to a single character corresponding to its code +d convert the mnt to a signed decimal text representation +f just output fill characters (does not use up an argument) + + +m_ convert the urnt to a two byte binary numeric representation, with the most significant byte first +(only available in EPOC version 2.17 or later) + + +o convert the urnT to an octal text representation +s copy the TExT * zero terminated string to the output, excluding the terminating zero. +u convert the urnT to an unsigned decimal text representation + + +w_ convert the urnt to a two byte binary numeric representation, with the least significant byte first +(only available in EPOC version 2.17 or later) + + +xX convert the urnT to a hexadecimal text representation + + +The type may be widened to a long by preceding the type letter with an | or an L or by providing the type +letter in upper case (ignored if is s or f). Output for types m and w will then occupy four bytes. + + +This function is normally used indirectly by the more immediately useful p_atos, described below. +However, p_atob is useful for constructing p_print£-like text output functions (p_print¢é itself is +described in the chapter I/O System). + + +For example, if file is static variable that contains the channel of an opened text file, the following +function behaves like p_printéf. + + +GLDEF_C CDECL VOID PrintToFile (TEXT *fmt,UINT arg,...) +{ +UINT len; +UBYTE buf[256]; + + +len=p_atob (&buf[0],fmt,&arg); +p_write (file, &buf[0],len); +} + + +If the int variable a contains 65: + +PrintToFile("[%b %c $d %o %u %x]",a,a,a,a,a,a) writes [1000001 A 65 101 65 41] +PrintToFile("[%04x]",a) Writes [0041] + +PrintToFile("[%*x]",3,a) Writes [ 41] + + +PrintToFile("[%+$4d.00 %s]",a,"over") writes [$$65.00 over] + + +PrintToFile("[%0*s]",10,"fred") writes [0O00000fred] +PrintToFile("[%=*4x]",'*',a) writes [*41*] + + +PrintToFile("[%—-**d]",'.',10,a) writes [S564 s es ee ] + + +PrintToFile("[%-A4f]",a) writes [AaaAA] and makes no use of the value of a. + + +4-3 + + +PLIB REFERENCE + + +p_atos Convert multiple arguments to string + + +VOID p_atos(TEXT *str, TEXT *fstr, ...); + +Convert multiple arguments to a zero terminated string at str under control of the format string fstr. +The content of fstr is described under p_atob, above. + +For example, if the variable a is a urnT that contains 65: + +p_atos(str,"%b %c %d %o %u %x",a,a,a,a,a,a) Writes "1000001 A 65 101 65 41"tostr +p_atos(str,"%04x",a) writes "0041" to str + + +p_atos(str,"%*x",2,a) writes "41" to str + + +Converting text to integers + + +PLIB contains the following functions to convert text to various types of numbers: + + +p_stoi to convert a signed decimal number string to a worD + +p_stol to convert a signed decimal number string to a LoNG + +p_stog to convert an unsigned number in any radix to a UwoRD + +p_stogl to convert an unsigned number in any radix to a ULONG + +p_stoa to convert multiple fields in a string to a series of arguments + +p_stoi Convert a signed decimal string to a WORD + + +INT p_stoi(TEXT **pstr, WORD *pval); + + +.Attempt to convert the signed decimal string at *pstr to a 16 bit number and, if a valid number is +recognised, write the number to pval, update *pstr to point to the terminating character and return zero. +Otherwise, neither *pstr nor *pval is written to and the function returns one of the following negative +error numbers (defined in p_gen.h): + + +E_GEN_OVER the number is too large (greater than 32767 or less than -32768) +E_GEN_FAIL the text could not be recognised as a number + + +Conversion continues until a non-decimal digit is found in the string, or the number overflows. For a +number to be recognised, the string must contain at least one decimal digit. + + +The string may be preceded by a '-' or a '+' (whitespace is significant and will terminate the conversion but +leading zeros are ignored). To convert unsigned data up to 65535, use p_stog. + + +For example, after: + + +INT ret; + +WORD val; + +TEXT *ptr="-123abc"; +ret=p_stoi(&ptr, &val) ; + + +val contains -123, ptr points to the 'a' and ret is zero. + + +p_stol Convert a signed decimal string to a LONG + + +INT p_stol(TEXT **pstr, LONG *pval); + + +Converts the signed decimal string at *pstr to write a 32 bit number to pval. Behaves and returns as for +p_stoi above except that it can handle decimal numbers in the range -2147483648 to 2147483647 +inclusive. To convert unsigned data up to 4294967295, use p_stogl + + +For example, after: + + +INT ret; +LONG val; +TEXT *ptr="-123456abc"; +ret=p_stol (&ptr, &val) ; + + +val contains -123456, ptr points to the 'a' and ret is zero. + + +4-4 + + +4 INTEGER CONVERSION AND RECTANGLE FUNCTIONS + + +p_stog Convert an unsigned number in any radix to a UWORD + + +INT p_stog(TEXT **pstr, UWORD *pval, INT radix); + + +Attempt to convert the unsigned number base radix (typically 2, 8, 10 or 16) at *pstr to a 16 bit number +and, if a valid number is recognised, write the number to pval, update *pstr to point to the terminating +character and return zero. Otherwise, neither *pstr nor *pval is written to and the function returns one of +the following negative error numbers (defined in p_gen.h): + + +E_GEN_OVER the number is too large (greater than 65535) +E_GEN_FAIL the text could not be recognised as a number + + +Conversion continues until a character that is invalid for the radix is found in the string or the number +overflows. For a number to be recognised, the string must contain at least one digit in the radix. +Whitespace is significant and will terminate the conversion but leading zeros are ignored. + + +For example, given: + + +UWORD val +TEXT *ptr="f£123"; + + +p_stog(&ptr,&val,10) returns E_GEN_FAIL + + +p_stog(&ptr, &val,16) returns O and writes Oxf123 to va1 + + +p_stogl Convert an unsigned number in any radix to a ULONG + + +INT p_stogl (TEXT **pstr, ULONG *pval, INT radix); + + +Converts the unsigned decimal number base radix at *pstr to write a 32 bit number to pvai. Behaves and +returns as for p_stog above except that it can handle numbers up to 4294967295. + + +For example, after: + + +INT ret; + +ULONG val; + +TEXT *ptr="f£123abz"; +ret=p_stogl (&ptr, &val,16); + + +val contains Oxf123ab, ptr points to the 'z' and ret is zero. + + +p_stoa Convert a string to arguments + + +INT p_stoa(TEXT **pstr, TEXT *fstr, ...) + + +Convert multiple fields within the zero terminated string *pstr to a series of arguments ... as controlled +by the format zero terminated string fstr. + + +Returns zero if successful and the text pointer *pstr is updated to point to the terminating character of +the last field converted. If an error occurred, *pstr points to the start of the field that caused the error and +one of the following negative error numbers is returned: + + +E_GEN_OVER the result is too large +E_GEN_FAIL fails to recognise a number +E_GEN_ARG the supplied buffer does not contain enough items + + +The format string fstr contains literal text, embedded with commands for converting the fields in *pstr +to the passed arguments. Any excess leading whitespace (as defined by p_iswhite) before a field in *pstr +is automatically skipped. + + +The embedded commands in fstr are prefixed with the 's' character (two successive 's' characters +count as one literal ''). Any non whitespace literal text causes characters in the *pstr to be scanned +until a match is made or until the end of the string is encountered (any whitespace characters in fstr are +discarded). If a match is not found in *pstr, the function returns. + + +4-5 + + +PLIB REFERENCE + + +The general form of an embedded command is: +%&[*] [] [] +:=a positive decimal number +:1|L +:=(B|b|c|c|D|d|N|n]|o]olalq|s|s|u]ulx|x) +where the square brackets indicate optional fields and '|' separates choices. + + +The mandatory parameter (optionally qualified by <1ong>) indicates the data type to be converted. + + +If the asterisk is present, conversion is performed but the result is not be stored. There should be no +corresponding value pointer in the argument list for a suppressed conversion. + + +The parameter is a positive decimal number that specifies the maximum input field width when + is s or q (in either upper or lower case) - if is other than s or q, it is ignored. Note that the +corresponding storage buffer must be large enough to hold characters plus | more for the +terminating zero (eg %19s requires a buffer of 20 bytes). + + +The specifies the type of argument conversion to be performed, as follows: +b convert an unsigned binary number to the uworp +c convert a character to its code, written to the uworD +d convert a signed decimal number (optionally preceded by a '-' or a '+') to the worp +n write the number of characters consumed so far to the uworD +oO convert an unsigned octal number to the uworp + + +q convert quote delimited text, copying the data in between the quotes (the delimiting quotes are +discarded) to produce a zero terminated string at the TExt * buffer. Although often used to +convert text delimited by quote (") characters, the first non whitespace character encountered is +taken to be the delimiter. + + +Ss convert contiguous non whitespace text to a zero terminated string at the Text * buffer. The +string is determined from the first non whitespace character to the first whitespace character (or a +zero terminator). + + +u convert an unsigned decimal number to the uworp +X convert an unsigned hexadecimal number to the uworp + + +When performing a numeric conversion, for a number to be recognised the string must contain at least +one digit in the radix. + + +If <1ong> is present, it should be L or | to specify that the corresponding argument address points to either +a LONG or a ULONG (ignored if is s, f or q). A long parameter can also be indicated by specifying the +conversion type in upper case. + + +For example, after: + + +INT ret; + +WORD dl1,d2; + +TEXT *ptr="111,-33"; +ret=p_stoa(&ptr,"%b, 3d", &d1, &d2) ; + + +di is 7 and d2 is -33, ptr points to the terminating zero, ret is zero. After: + + +INT ret; + +WORD dl,d2; + +TEXT buf[16] + +ptr="xxx @a “def ghi®* #44a"; + +ret=p_stoa(ptr,"@ Sc %15q # %d",&d1,buf, &d2) ; + + +di contains 'a', "def ghi" is written to buf and d2 is 44, ptr points to 'a' and ret is zero. + + +4-6 + + +4 INTEGER CONVERSION AND RECTANGLE FUNCTIONS + + +——————————————————————————————————————————————————————————————————————————————————————— +Rectangle functions + + +This section describes a set of functions that operate on p_reEct structs. A p_recT struct describes a +rectangle in terms of its: + + +e top left coordinates (internal) +e bottom right coordinates (external) + + +where the units of the coordinates depend upon the application. Typically, the coordinates count pixels +(for graphics displays) or monospaced character columns and rows (for character-oriented displays). + + +For example, a character display would normally be mapped to an (x,y) coordinate system as follows: +e corresponds to the character in the top left corner +e x increases to the right and counts the character columns +e yincreases downwards and counts character rows + +Using the above coordinates, the rectangle of as in the following character display: + + ++++++4+4+ +++AAA+++ +++AAA+++ ++4+4+4+4+Z4+ + + +is described by the coordinates of the top left a (internal) and the bottom right z (external) - that is, (2,1) +and (5,3). Subtracting corresponding coordinates gives the correct dimensions of the rectangle - (3,2). + + +The p_rect struct is defined in terms of two p_potnt structs. The definitions, in p_graf-h, are: + + +typedef struct +{ +WORD x; /* Horizontal coordinate */ +WORD y; /* Vertical coordinate */ +} P_POINT;. + + +typedef struct +{ +P_POINT tl; /* Top left point (internal) */ +P_POINT br; /* Bottom right point (external) */ +} P_RECT;. + + +An empty rectangle is a rectangle that has one or both of its sides zero or negative. + + +The rectangle functions are as follows: + + +p_offrec moves a rectangle by an offset + +p_insrec shrinks or expands a rectangle about its centre + +p_unirec calculates the union of two rectangles (the smallest rectangle that encloses both +of them) + +p_intrec calculates the intersection of two rectangles + +p_pinrec determines whether a point is inside a rectangle + +p_emprec determines whether a rectangle is empty + +p_absrec converts any negative sides of a rectangle to their positive equivalents + +p_offrec Offset a rectangle + + +VOID p_offrec(P_RECT *rect, INT xoffset, INT yoffset); + + +Displace rect by (xoffset, yoffset), without changing its size. + + +PLIB REFERENCE + + +p_insrec Inset a rectangle + + +VOID p_insrec(P_RECT *rect, INT xinset, INT yinset) ; + + +Adjust the width and height of rect by xinset and yinset respectively, in such a way as to produce a +rectangle concentric with the original. + + +A negative inset makes the rectangle bigger. +For example: +p_insrec(&rect,2,-1); + + +decrease the width of rect by 4 and increases the height by 2. + + +p_unirec Union of two rectangles + + +VOID p_unirec(P_RECT *rectl, P_RECT *rect2, P_RECT *result); + + +Write the union of the two rectangles rect1 and rect 2 (the smallest rectangle that encloses both of them) +to result - as illustrated by the following diagram: + + +Result + + +The parameter result may point to the same address as either rect 1 or rect 2. + + +For example: + + +LOCAL_D P_RECT rect1={{10,20},{30,40}}; +LOCAL_D P_RECT rect2={ {50,50}, {100,120}}; +LOCAL_D P_RECT result; + + +p_unirec(&rectl, &rect2, &result) ; + + +writes {{10,20},{100,120}} to result. + + +p_intrec Intersection of two rectangles + + +INT p_intrec(P_RECT *rectl, P_RECT *rect2, P_RECT *result); + + +Write the intersection of the two rectangles rect 1 and rect2 (the largest rectangle that is contained in +both of them) to result. + + +Rect 1 + + +Rect 2 + + +Intersection + + +If the rectangles do not intersect or if either rectangle is empty, the result is an empty rectangle. +The parameter result may point to the same address as either rect 1 or rect 2. + + +Returns TRUE if the rectangles intersect, raLsE if the rectangles do not intersect (or if either rectangle is +empty). + + +4-8 + + +4 INTEGER CONVERSION AND RECTANGLE FUNCTIONS + + +For example, after: +LOCAL_D P_RECT rect1={{0,0},{7,20}}; +LOCAL_D P_RECT rect2={{4,4},{100,120}}; +LOCAL_D P_RECT result; + + +ret=p_unirec (&rectl, &rect2,é&result) ; + + +ret 1S TRUE and result contains {{4,4},{7,20}}. + + +p_pinrec Test if a point is inside a rectangle + + +INT p_pinrec(P_POINT *point, P_RECT *rect); + +Return true if the point point is within the rectangle rect or FALSE if point is outside rect (or if rect is +empty). + +p_emprec Test if a rectangle is empty + + +INT p_emprec(P_RECT *rect); + + +Return True if the rectangle rect is empty (that is, if it has zero or negative width or height). + + +p_absrec Convert to an absolute rectangle + + +VOID p_absrec(P_RECT *rect, P_RECT *result); + + +Write the absolute of the rectangle rect (where any negative sides are converted to their positive +equivalents) to result. + + +The parameters rect and result may point to the same address. +For example: + + +LOCAL_D P_RECT rect={{7,20},{4,4}}; +LOCAL_D P_RECT result; + + +p_absrec(&rect, &result) ; + + +writes {{4,4},{7,20}} tO result. + + +4-9 + + +CHAPTER 5 + + +FLOATING POINT + + +Floating point C +The 8087 emulator + + +The code that is generated from floating point C requires that the 8087 floating point coprocessor +emulator be present and loaded. The 8087 emulator is implemented as an external logical device driver +(LDD), loaded from sys$8087.ldd. The PLIB (or CLIB) startup module (that is, the code which calls main) +automatically loads sys$8087./dd if the application program contains any floating point code. + + +The startup module searches for sys$8087.ldd in the following directories (in order of precedence): + + +e as specified by the zero terminated string in the environment variable with name "Ems" (if such +an environment variable exists) + + +e in the same directory that contained the program being executed + + +The startup module will fail with panic 80 the search for sys$8087.1dd fails. See the chapter on Error +Handling for an explanation of the panic mechanism. + + +The Ems environment variable may be set using p_setenv - as described in the chapter Memory +Allocation. For example, the following installation program causes the startup module to look for +sys$8087.ldd in the a:\sys\ directory: + + +#include + + +GLDEF_C main(VOID) +{ +p_setenv ("EMS", "A:\\SYS\\") ; +} + + +Note that environment variables names are case-sensitive - setting up (say) "ems" will not have the desired +effect. + + +Only one copy of sys$8087.ldd is loaded however many floating point processes are started. The LDD is +deleted (freeing the memory) when the last floating point process exits gracefully. If the last process +panics or is stopped by another process, the LDD will remain loaded - but it will be deleted by a +subsequent normal exit of a floating point process. The LDD has the device name Ems, so you can find +out if the device is loaded using: + + +LOCAL_C INT Is8087Loaded (VOID) + + +{ +TEXT bb [E_MAX_NAME+2]; + + +return (p_devfnd(0, "EM$",E_LDD, &bb[0])>0); +} + + +which returns TRUE if the LDD is loaded. If required, a clean-up program can delete the loaded LDD with: +p_devdel ("EM$",E_LDD) ; + + +which will only successfully delete the LDD if there are no floating point processes using it. The functions +p_devfnd and p_devdel are described along with LDDs in the //O System chapter. + + +PLIB REFERENCE + + +If sys$8087.ldd is not present in the ROM, it must be loaded into RAM at a cost of approximately 8K +bytes (but this does not detract from the code segment limit of the application). + + +If the LDD is present in the ROM, it still has to be loaded but at a reduced cost of RAM. You can find out +if sys$8087.1dd is present in the ROM using: + + +LOCAL_C INT Is8087InROM (VOID) + + +{ +P_INFO info; + + +return (p_finfo("ROM: :SYS$8087.LDD", &info) >=0) ; +} + + +which returns TRUE if sys$8087./dd is present in the ROM. +Avoiding the 8087 emulator + + +It is possible to perform floating point operations without using floating point C and without loading the +emulator. For example, a program that contains the following function (to evaluate sin(x)/x): + + +LOCAL_C INT Sinc(DOUBLE *pret,DOUBLE *parg) +{ +if (*parg==0.0) +{ +*pret=1.0; +return (0); +} +if ((ret=p_sin(pret,parg) ) <0) +return (ret); +*pret=*pret/*parg; +return (0); + + +} + + +will load the emulator because the expressions *parg==0.0, *pret=1.0 and *pret=*pret/*parg all +generate calls to the emulator. + + +However, if the function is implemented without using floating point C as in: + + +LOCAL_C INT Sinc(DOUBLE *pret,DOUBLE *parg) +{ +WORD x; +DOUBLE zero; + + +x=0; +p_itof (&zero, &x) ; +if (!p_fcmp(&zero,parg) ) +{ +x=1; +p_itof (pret, &x); +return(0); +} +if ((ret=p_sin(pret,parg) ) <0) +return (ret); +p_fdiv(pret,parg) ; +return (0); + + +} +then sys$8087./dd is not loaded. Furthermore, the code that is generated is smaller and runs faster. +The benefits of avoiding the emulator are: +¢ you do not need to worry about the presence of sys$8087.ldd +e the program is smaller and runs faster +The benefits of using the emulator are: +e you can use floating point C and use 32-bit float variables (as well as 64-bit doubles) + + +e the emulator works with 80-bit numbers internally and therefore gives more precise results + + +5-2 + + +5 FLOATING POINT + + +Macros + + +The following macros, defined in p_math.h + + +#define ABS(x) ((x)<0O ? -(x) : (x)) +#define MAX(a,b) ((a)>(b) ? (a) : (b)) +#define MIN(a,b) ((a)<(b) ? (a) : (b)) + + +can be used with integer or floating point expressions (although the code that is generated might be quite +lengthy). Using any of these macros with a floating point expression will cause the 8087 emulator to be +loaded. + + +The remaining functions in this chapter, with the exception of p_rand and p_randl, are implemented +independently of the emulator. Using them will not cause the emulator to be loaded. If the emulator is +loaded, they may still be used. + + +Converting doubles to and from text + + +p_dtob Double to string + + +INT p_dtob(TEXT *pbuf, DOUBLE *pval, P_DTOB *pformat) ; + + +Convert the double floating point number *pvai to text at pbuf using the pformat format specification. +This text is not zero terminated. + + +The p_pros structure is defined in p_math.h as: + + +typedef structure +{ +UBYTE type; /* conversion type */ +UBYTE width; /* width of representation in characters */ +UBYTE ndec; /* number of decimal places */ +TEXT point; /* decimal point character */ +TEXT triad; /* triad separator character */ +UBYTE trilen; /* threshold for triad character use */ +} P_DTOB;. + + +where: + + +type specifies the numeric format as being fixed, scientific or general. (Integer +format is obtained as a special case of fixed point format where the number of +decimal places ndec is zero.) + + +width specifies the maximum number of characters allowed to represent the number +(it must be in the range 1 to 255 inclusive). You must reserve width bytes at +pbuf. If the formatted string would be wider than width then =_GEN_FAIL Is +returned. (If you want the output aligned and filled, post-process pbuf with +p_jtob). + + +ndec specifies the number of digits following the decimal point when type is +P_DTOB_FIXED Of P_DTOB_EXPONENT where ndec must be in the range zero to +P_FLT_PREC (15) inclusive. + + +point specifies the character used for the decimal point. It would normally be either +""(dot) or ','(comma). + + +triad specifies the triad separator character used to delimit groups of 3 digits in the +integer part of a fixed point number. It would normally be one of '.'(dot) or +(comma) or ' '(space). + + +trilen is either zero to disable triad insertion, or a threshold number of digits above +which triad insertion takes place. In practice, trilen is set to 1 for normal +conventions and 4 to conform to the French convention. + + +PLIB REFERENCE + + +In all cases, negative numbers are represented by the insertion of a leading '-' sign (positive numbers do +not have a leading '+' sign). To obtain a bracketed representation of negative numbers you must post- +process the output string. + + +There can never be more than p_FLT_pRECc(15) significant digits. Where there are less than P_FLT_PREC +significant digits, the number is rounded to the number of significant digits displayed. + + +The detailed formatting details as a function of type is as follows: + + +P_DTOB_FIXED the number is represented with ndec decimal places, where ndec may be zero to +represent an integer (in which case no decimal point character is displayed). If +the ASCII form exceeds width (usually due to the number being large and +having too many digits before the decimal point), =_GEN_FAIL is returned. A +zero is displayed in the form "0.000" where there are ndec zeros following the +decimal point or as just "0" if ndec is zero. + + +P_DTOB_EXPONENT the number is represented in scientific notation with one non-zero digit before +the decimal point and ndec digits beyond the decimal point followed by 'E', a +sign ('+' or '-') and the exponent as two digits (with leading zero if necessary). +If ndec is zero, the number is rounded to one digit of precision and no decimal +point is displayed. A zero is displayed in the form "0.000E+00" where there are +ndec zeros following the decimal point or as "0E+00" if ndec is zero. Triad +separation is not available and triad separation parameters are ignored. + + +P_DTOB_GENERAL converts either as fixed format (with no triad separator) or scientific format, +making best use of width. Here, "making best use" is defined as showing the +greater number of significant digits and preferring fixed format when the +number of significant digits shown is the same. The number of decimal places +displayed depends on width (ndec is ignored). A zero is displayed as just "0". +Triad separation is not available and triad separation parameters are ignored. + + +P_DTOB_GEN_LIM as for P_DTOB_GENERAL, except that output is limited to not exceed 12 +significant digits. + + +Returns the number of characters written to pbuf if successful, or one of the following negative error +numbers: + + +E_GEN_UNDER the number is too small to represent (less than approximately 1E-99). If you +would prefer not to fail in this case, you can always write your own zero or re- +call p_dtob with a zero double. + + +E_GEN_OVER the number is too large to represent (greater than approximately 1 E99). +E_GEN_FAIL the representation exceeds width characters. +E_GEN_ARG either the double is illegal, or type is not one of P_DTOB_FIXED, + + +P_DTOB_EXPONENT Of P_DTOB_GENERAL. + + +p_stod String to double + + +INT p_stod(TEXT **pstr, DOUBLE *pval, INT point); + + +Scan the zero terminated string *pstr for a floating point number where point is the code of the decimal +point character (normally either '.' or ',') and write the value as a double float to *pval. + + +For a number to be recognised, the string must contain at least one decimal digit. + + +If p_stod is successful, it updates *pstr to point to the terminating character and returns zero. If it fails, +*pstr is not changed and it returns one of the following negative error numbers: + + +E_GEN_UNDER the number is too small (less than approximately 1E-99). The value zero is +written to *pval. + + +E_GEN_OVER the number is too large (greater than approximately 1E99). + + +E_GEN_FAIL fails to recognise a number. + + +5-4 + + +The supplied string at *pstr should take the form: + + +[+|-].[E|e] [+|-] + + +where: + + +the leading '+' sign may be omitted for positive numbers + and are optional but at least one should be present +leading zeros in are legal but have no effect + + +trailing zeros in are legal but have no effect + + +5 FLOATING POINT + + +there is no reasonable limit to the number of significant digits, but digits that are beyond the +precision of the floating point representation will not be reflected in the mantissa of the number +which is produced + + +the exponent field (which starts with 'E' or 'e') is optional + + +the leading '+' sign in the exponent field may be omitted for positive exponents + + +the resulting number should be in the range approximately 1E-99 to approximately 1E+99 + + +Example + + +LOCAL_D TEXT buf []="-134.43735abc"; +FAST INT ret; +DOUBLE val; + + +TEXT *ptr; + + +ptr=é&buf [0]; + + +After + + +ret=p_stod(&ptr,é&val,'.'); + + +val will be -134.43735, ptr will be pointing to 'a' and ret will be zero. + + +p_getctd + + +VOID p_getctd(E_CONFIG *pcfg); + + +Write a copy of the system &_conFTI¢ struct to pcfg. + + +Get number representation preferences + + +The =_conric struct is defined in p_config.h as: + + +typedef struct + + +{ + + +UBYT + + +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT + + +UBYT +} EL + + +UWORD countryCode; +WORD gmtOffset; + +UBYTE +UBYTE +UBYTE +UBYTE +UBYTE +UBYTE +UBYTE +UBYTE +UBYTE +UBYTE +TE +E +E +E +E +E +E +E +E +E + + +dateType; + +timeType; +currencySymbolPosition; +currencySpaceRequired; +currencyDecimalPlaces; +currencyNegativelInBrackets; +currencyTriadsAllowed; +thousandsSeparator; +decimalSeparator; +dateSeparator; +timeSeparator; +currencySymbol [9]; +startOfWeek; +summerTime; + +clockType; +dayAbbreviation; +monthAbbreviation; +workDays; + +units; + +spare[9]; + + +CONFIG; . + + +5-5 + + +PLIB REFERENCE + + +In the context of this chapter we are interested in: + + +currencySymbol a zero terminated string containing the currency symbol +currencySymbolPosition which should contain either E_cURRENCY_BEFORE Of E_CURRENCY_AFTER +currencySpaceRequired which should contain either E_NosPACE_BETWEEN or E_SPACE_BETWEEN +currencyDecimalPlaces the number of decimal places for displaying currency figures +currency- TRUE if a negative currency should be displayed in brackets rather than +NegativeInBrackets with a minus sign + +currencyTriadsAllowed zero to disable triad separator insertion, or a threshold number of digits + + +above which triad separator insertion takes place. In practice a value of 1 is +used for normal conventions and 4 for the French convention. Note that, +despite the name of this element, triad separators are not restricted to +currency fields; they may be inserted in any numeric field. + + +thousandsSeparator the character code of the triad (thousands) separator + +decimalSeparator the character code of the decimal separator (normally either ',' or '.') + +units either E_IMPERIAL or E_METRIC to indicate a preference for imperial +or metric units (for example, to show page dimensions in inches or +centimetres) + + +IN NN +Long integer functions + + +p_randl Long random number + + +ULONG p_rand1l(ULONG *pseed) ; +Return the next pseudo random number and updates *pseed. + + +Used to generate a sequence of pseudo random numbers from an initial value of *pseed. Any given seed +will always produce the same sequence of random numbers. + + +The numbers generated may be any value between 0 and 4294967295 (oxffffffFfFf) or, if considered as a +signed result, between -2147483648 (0x80000000) and +2147483647 +(0x7ffffffF). + + +For example, to print reproducibly 100 random longs: + + +ULONG seed; +UINT i; + + +seed=01; +for (i=0;i<100;i++) +p_printf("%1ld",p_randl (&seed) ); + + +To generate a different set of numbers each time, seed the number with the system time, as in: + + +seed=p_date(); + + +Scientific functions + + +For all floating point functions that transform a single input parameter it is permissible to use the same +address for both parg and pret. + + +All trigonometric functions assume angles are measured in radians. + + +p_sin Sine +INT p_sin(DOUBLE *pret, DOUBLE *parg); +Write the sine of *parg to *pret. + + +Returns zero if successful or E_GEN_ARG if *parg was an invalid double. + + +5-6 + + +5 FLOATING POINT + + +p_cos Cosine +INT p_cos (DOUBLE *pret, DOUBLE *parg); +Write the cosine of *parg to *pret. + + +Returns zero if successful or E_GEN_arRG if *parg was an invalid double. + + +p_tan Tangent +INT p_tan(DOUBLE *pret, DOUBLE *parg); +Write the tangent of a *parg to *pret. + + +Returns zero if successful or =_cEN_arc if *parg was an invalid double or if it was greater than +149078413. + + +p_asin Arcsine +INT p_asin(DOUBLE *pret, DOUBLE *parg) ; +Write the angle whose sine is *parg to *pret. + + +Returns zero if successful or zE_GeN_arG if *parg was an invalid double or aps (*parg) >1. + + +p_acos Arccos +INT p_acos (DOUBLE *pret, DOUBLE *parg) ; +Write the angle whose cosine is *parg tO *pret. + + +Returns zero if successful or z_GEN_aARG if *parg was an invalid double or aps (*parg) >1. + + +p_atan Arctangent +INT p_atan(DOUBLE *pret, DOUBLE *parg) ; +Write the angle whose tangent is *parg to *pret. + + +Returns zero if successful or z_GEN_aRG if *parg was an invalid double. + + +p_In Natural logarithm +INT p_ln(DOUBLE *pret, DOUBLE *parg); +Write the natural (base e) logarithm of *parg to *pret. + + +Returns zero if successful or z_GEN_aRc if *parg was less than or equal to zero or if *parg was an invalid +double. + + +p_exp Exponential +INT p_exp(DOUBLE *pret, DOUBLE *parg); + +Write the value of the arithmetic constant e (2.71828...) raised to the power of *parg to *pret. + +Returns zero if successful or one of the following negative error numbers: + +E_GEN_ARG *parg 1s not a valid double. + + +E_GEN_UNDER underflow has occurred (the magnitude of the result is less than 1E-307), zero +is written to *pret. + + +E_GEN_OVER overflow has occurred (the magnitude of the result is greater than 1E307). + + +5-7 + + +PLIB REFERENCE + + +p_log Logarithm +INT p_log(DOUBLE *pret, DOUBLE *parg); +Write the base 10 logarithm of *parg to *pret. + + +Returns zero if successful or E_GEN_aRG if *parg was less than or equal to zero or if *parg was an invalid +double. + + +p_sqrt Square root +INT p_sqrt (DOUBLE *pret, DOUBLE *parg ); +Write the square root of *parg to *pret. + + +Returns zero if successful or E_cEN_aRc if *parg was negative or an invalid double. + + +p_pow Raise to the power +INT p_pow(DOUBLE *pret, DOUBLE *pargl, DOUBLE *parg2); +Write *pargi raised to the power of *parg2 to *pret. + + +Returns zero if successful or one of the following negative error numbers: + + +E_GEN_ARG the arguments are invalid (if *parg1<0, *parg2 must be integral), or at least +one argument is not a valid double. + +E_GEN_UNDER underflow has occurred (the magnitude of the result is less than 1E-307), zero +is written to *pret. + +E_GEN_OVER overflow has occurred (the magnitude of the result is greater than 1E307). + +p_rand Double random number (long seed) + + +DOUBLE p_rand(ULONG *pseed) ; + + +Return a DouBLE random number in the range zero (inclusive) to one (exclusive). As in the case of +p_rand1, the value pointed to by pseed is used to seed the random number generation and is updated for +the next call of p_rand. + + +This function requires the 8087 floating point emulator. + + +p_frand Double random number +VOID p_frand(DOUBLE *pret, DOUBLE *pseed) ; + + +Write a random number in the range zero (inclusive) to one (exclusive) to *pret. As in the case of +p_rand1, the value pointed to by pseed is used to seed the random number generation and is updated for +the next call of p_frand. + + +Floating point arithmetic without the 8087 emulator + + +This section describes the PLIB functions that would normally be used to perform floating point +arithmetic without having to load the 8087 floating point emulator sys$8087.ldd. + + +For all floating point functions with one parameter it is permissible to use the same address for both parg +and pret. + + +p_fid Assignment + + +INT p_fld(DOUBLE *pret, DOUBLE *parg) ; +Write the value of *parg to *pret (the 'Id' stands for load). + + +Returns zero if successful or E_GEN_ARG if *parg was an invalid double. + + +5-8 + + +5 FLOATING POINT + + +p_fadd Add + + +INT p_fadd(DOUBLE *pret, DOUBLE *parg) ; + +Write the sum of *parg and «pret to *pret. + +Returns zero if successful or one of the following negative error numbers: +E_GEN_ARG *pret OF *parg was not a valid double. + + +E_GEN_OVER overflow has occurred (the magnitude of the result is greater than 1E307). + + +p_fsub Subtract +INT p_fsub(DOUBLE *pret, DOUBLE *parg) ; + +Write *pret minus *parg tO *pret. + +Returns zero if successful or one of the following negative error numbers: + +E_GEN_ARG *pret OF *parg was not a valid double. + + +E_GEN_OVER overflow has occurred (the magnitude of the result is greater than 1E307). + + +p_fmul Multiply +INT p_fmul (DOUBLE *pret, DOUBLE *parg) ; + +Write the product of *parg and *pret to *pret. + +Returns zero if successful or one of the following negative error numbers: + +E_GEN_ARG *pret OF *parg was not a valid double. + + +E_GEN_UNDER underflow has occurred (the magnitude of the result is less than 1E-307), zero +is written to *pret. + + +E_GEN_OVER overflow has occurred (the magnitude of the result is greater than 1E307). + + +p_fdiv Divide +INT p_fdiv(DOUBLE *pret, DOUBLE *parg) ; + +Write *pret divided by *parg to *pret. + +Returns zero if successful or one of the following negative error numbers: + +E_GEN_ARG *pret OF *parg was not a valid double. + + +E_GEN_UNDER underflow has occurred (the magnitude of the result is less than 1E-307), zero +is written to *pret. + + +E_GEN_OVER overflow has occurred (the magnitude of the result is greater than 1E307). + + +p_fcmp Compare +INT p_fcmp (DOUBLE *pargl, DOUBLE *parg2) ; +Compare *pargi to *parg2, returning: + +1 if *pargl > *parg2 + +0) if *pargl == *parg2 + +-l if *pargl < *parg2 + + +The function only returns zero if *pargi and *parg2 are strictly equal. In some cases it may be more +appropriate to test for equality by evaluating the difference using p_fsub and then comparing the +difference with a suitably small number (such as, for example, 1E-10). + + +5-9 + + +PLIB REFERENCE + + +The return value is undefined if either *pargi1 or *parg2 is not a valid double. + + +Note that it is bad practice to compare floating point numbers for equality, since rounding errors may +make the result meaningless. + + +p_fneg Negate +INT p_fneg(DOUBLE *parg) ; +Negate *parg. + + +Returns zero if successful, or E_GEN_ARG if *parg was an invalid double. + + +p_mod Modulus +INT p_mod(DOUBLE *pret, DOUBLE *pargl, DOUBLE *parg2)j; +Write the remainder of *parg1 divided by *parg2 to *pret. + + +Returns zero if successful, or E_GEN_aRG if either *parg1 or *parg2 was an invalid double. + + +p_int Integer part +INT p_int (DOUBLE *pret, DOUBLE *parg); +Write the integer part of *parg to *pret. Negative numbers are rounded towards zero. + + +Returns zero if successful or E_GEN_ARG if *parg was an invalid double. + + +p_inti Convert double to integer +INT p_inti(WORD *pret, DOUBLE *parg) ; + + +Write the integer part of *parg to *pret if *parg is in the range -32768 to +32767 inclusive. Negative +numbers are rounded towards zero. + + +Returns zero if successful or one of the following negative error numbers: + + +E_GEN_ARG *parg is not a valid double +E_GEN_OVER *parg 1s outside the range -32768 to +32767 +p_intl Convert double to long + + +INT p_int1l(LONG *pret, DOUBLE *parg); + + +Write the integer part of *parg to *pret, if it is in the range -2147483648 (0x80000000) to +2147483647 +(0x7££fffff) inclusive. Negative numbers are rounded towards zero. + + +Returns zero if successful, or one of the following negative error numbers: + + +E_GEN_ARG *parg is not a valid double +E_GEN_OVER *parg is outside the range -2147483648 to +2147483647 +p_itof Convert integer to double + + +VOID p_itof (DOUBLE *pret, WORD *parg); + + +Convert *parg to a double and write it to *pret. + + +p_longtof Convert long to double +VOID p_longtof (DOUBLE *pret, LONG *parg); + + +Convert *parg to a double and write it to *pret. + + +5-10 + + +CHAPTER 6 + + +ERROR HANDLING + + +[a =I] +Process termination + + +A process can terminate itself or it can be terminated by another process. By whatever means a process +terminates, one or more other processes may be interested in being notified that a process has terminated. + + +Terminating this process. + + +A process terminates itself by calling: + +p_exit for normal graceful termination + +p_panic for abnormal termination, normally as a result of defective code + +C programs that fall off the end of main effectively call p_exit with the return from main. That is: + + +GLDEF_C INT main(VOID) +{ +p_printf ("Hello world"); +p_sleep (501); /* wait 5 seconds */ +return (0); + + +} +is equivalent to: + + +GLDEF_C VOID main(VOID) +{ +p_printf("Hello world"); +p_sleep (501); /* wait 5 seconds */ +p_exit (0); +} + + +It is poor practice to fall off the end of a voID main since this is equivalent to calling p_exit with a +random number (whatever happens to be in the ax register at the time). If there is a system component +(such as the shell) reporting process terminations to the user, it will give a misleading report. + + +Terminating another process + + +A process can terminate another process by calling: + + +p_pterminate or to terminate another process (typically in response to a user request) +p_pkill +p_ppanic to panic another process (normally following unreasonable behaviour from the + + +process being terminated) + + +To terminate a process, it is recommended that p_pterminate is used in preference to p_pkili as the +former allows the process being terminated to run any cleanup code before exiting gracefully. +Applications wishing to run cleanup code call p_onterminate to elect to be sent an inter-process message +in response to the p_pterminate request. + + +6-1 + + +PLIB REFERENCE + + +Finding out when other processes terminate + + +A process can request to be notified of the termination of another process by calling: +p_logona to be signalled when the specified process terminates + + +p_logon to receive an inter-process message when the specified process terminates +(convenient for server processes to keep track of their clients) + + +p_watchall to receive an inter-process message when any process terminates (normally +used by the Shell to monitor the termination of all processes) + + +See the chapter Asynchronous Requests and Semaphores for the meaning of the term "signalled". See the +chapter Processes and Inter-Process Messaging for more about inter-process messaging and servers. + + +The process termination word + + +Regardless of which one of p_logona, p_logon or p_watcha1l is used, the system delivers a single 16-bit +process termination word giving information on how the process terminated. The most significant byte of +the process termination word is one of the following (defined in epoc.h) + + +E_NORMAL_EXIT the process terminated itself by calling p_exit or it was terminated by another +process calling p_pterminate or p_pkill. The least significant byte of the +process termination word contains the nReason parameter to p_exit, +p_pterminate Or p_pkill. By convention, an nReason of zero indicates a +normal error-free graceful termination. + + +E_PANIC_EXIT the process terminated itself by calling p_panic or it was terminated by another +process calling p_ppanic. The least significant byte contains the nPanic ("panic +number") parameter to p_panic or p_ppanic. + + +E_TASK_PANIC_EXIT the process terminated because it owned a task that terminated with +E_PANIC_EXIT (tasks are lightweight processes and are described in the chapter +Processes and Inter-Process Messaging). + + +Panics + + +When the system detects a condition that it believes could only arise from a bug in a the application +program, the system terminates the process with a "panic number" in the range 0 to 255 inclusive (where +the system is said to "panic the process"). A panic is a fatal exception that causes the process to terminate +immediately. There is no way for applications to avoid being terminated when a panic has been started +(cf p_leave, described later in this chapter). + + +Panicking a process is more economical in the use of system code and application code than returning an +error, since the latter relies on application code to properly process the error return. As well as protecting +the system from defective applications, the panic system enforces a greater discipline on application code +by terminating a process as soon as the condition is detected. + + +This does not mean that the system always prefers to use panics rather than error returns. Error returns +are still used where appropriate; the system certainly never panics a process on a condition that could arise +from user action. For example, the p_alloc function to allocate a memory cell returns nutt if there is +insufficient free system memory to satisfy the request, but calls p_panic if it detects that the heap has been +corrupted. In the majority of cases, such as in the above example, it is quite clear where a panic or an +error return is appropriate, but occasionally it is not so clear. From the point of view of an application +programmer, however, it is clear that panic conditions should be avoided. In consequence the function +descriptions in this manual include any conditions that result in the caller being panicked. + + +If the panic condition is detected within the code of a system function, the function calls p_panic as in the +example above. If the condition is detected in a system process (for example, the supervisor or the file +server) the application process is terminated by the system process calling p_ppanic. + + +Application programmers can include their own calls to p_panic to catch conditions indicating a bug in +their program which might otherwise go unnoticed (until the software is used by a customer!). A common +example would be to put a call to p_panic on the default case of a switch statement, to catch an invalid +parameter. + + +6-2 + + +6 ERROR HANDLING + + +System panic numbers + + +The following lists the panic numbersthat are used by the operating system: + + +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +10 +11 +12 + + +13 +14 +15 +16 +17 +18 +19 + + +20 +21 +22 +23 +24 +25 + + +26 +27 + + +28 +29 +30 +31 +32 +33 + + +Used by test code when a test fails + +Invalid function number (semaphore manager) +Invalid semaphore handle + +Semaphore not allocated + +Initial semaphore count is negative + +Signal count is negative + +Invalid function number for process manager +Invalid process ID + +Task tried to create a task + +Invalid function number for time manager +Invalid function number for segment manager +Segment size was negative + + +Type was not one of E_SEGMENT LOW, E_SEGMENT_HIGH, E_SEGMENT_DEVICE OF +E_SEGMENT_LOCKED + + +Invalid segment handle + +Segment copy is out of range + +Invalid function number for heap manager + +Heap not initialised + +A heap cell is being reduced by more than its size +Attempt to set heap granularity greater than z_max_GRowByY + + +A heap cell address is outside the boundaries of the heap (the heap has probably been +corrupted - try calling p_alichk to catch the corruption sooner) + + +Invalid function number for inter-process message manager + +Inter-process messaging has already been initialised (ie p_minit has been called twice) +Inter-process messaging has not been initialised (ie p_minit has not been called) +Cannot initialise with zero messages in the queue + +Invalid function number for I/O manager + + +Invalid I/O channel (possibly because you did not test that the previous p_open succeeded or +you have closed the channel or you overwrote the variable containing the channel) + + +Device requested panic + + +Invalid wait handler handle (possibly nothing to do with wait handlers and just indicative of +a low address overwrite of the 4 bytes at address 2, as a result of an uninitialised pointer) + + +Key and pointing device already hooked + +Key and pointing device requesting process is not a task +Invalid function number for device manager + +Invalid device handle + +Invalid function number for file manager + + +Process already connected to file server + + +PLIB REFERENCE + + +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 + + +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 + + +61 +62 +63 +64 +65 +66 +67 +68 + + +Reserved for future use + +Invalid function number for library manager +Invalid library handle + +Invalid function number for library + +Invalid LIB file channel + +Invalid DYL index number + +Invalid message to file server + +Process has not connected to file server + +Invalid function number for conversion manager +Invalid function number for general manager +Attempt to unhook from notify when not already hooked +Invalid revector address + +Invalid function number for conversion manager + + +Leave called before a call to enter (possibly because you were unaware that the function you +were calling could call p_leave) + + +No method available to handle message (OOP) +Invalid reclass attempted (OOP) + +Unknown category in LibHandle (OOP) +Unknown class in LibCreate (OOP) + +Supersend called from outside a method (OOP) +Attempt to get a handle before being linked (OOP) +Missing external categories in LibLink (OOP) +Object does not point to a valid class (OOP) +Invalid link layer completion code + +Invalid function number for window server +Invalid function number for hardware manager +Unexpected interrupt + + +Attempted to write outside of process data segment (possibly because of an uninitialised +pointer or a corrupted data structure) + + +Interrupts have been disabled for too long +Reserved for future use + +Divide by zero interrupt + +Overflow interrupt + +Invalid function number for Dbf manager +Invalid DBF I/O channel + +Invalid parameter for DBF function + + +Address zero overwrite (possibly because of an uninitialised pointer) + + +6 ERROR HANDLING + + +69 The operating system detected less than 0x100 bytes of remaining stack (this amount is +reserved for hardware interrupts to run). You probably have declared large data structures as +automatics. Consider making them static variables or allocate them from the heap. + + +70 Environment name size > EnvMaxNameSize +71 Single step interrupt (INT 1) +72 Break point interrupt (INT 3) + + +73 A request was made while an asynchronous request of the same type and on the same +channel was already pending + + +74 Invalid function number for serial I/O manager + +75 Call to an ASIC1 function on an ASIC9 machine + +76 Attempt to find a DYL not in a visible bank + +77 Floating point emulator exception + +78 Semaphore count exceeds Ox7fff + +80. Library fatal error, preceded by a notification of the specific error +255 The function p_ailchk detected a corrupted heap + + +Some of the panics, especially those described by "Invalid function number for ...", are unlikely to indicate +a specific bug; it is almost impossible to create code that would produce such a panic by a coding error. +This type of panic could, however, easily arise from trashing a return address on the stack, with the +instruction pointer wandering into arbitrary code. In the above list, those panics that are likely to indicate +a specific coding problem are described more fully. + + +If you get a panic 79, or a panic in the range 81 to 254, it may be due to some other system component. +See the Window Server manual for panics in the range 81-110 and, when using object oriented +programming, see the OLJB manual for panics in the range 130-158. + + +p_exit Terminate this process +VOID p_exit (INT nReason) ; + +Terminate this process with reason nReason in the range -127 to 128 without returning to the caller. +Applications that exit normally should terminate with nreason equal to zero. + + +Applications that fail during their initialisation may wish to pass on the error number (in the range -127 +to -1 inclusive) that caused the initialisation to fail. + + +Programs that are run as subprocesses can use a positive nReason to pass back an exit status to their parent +process. + + +p_panic Terminate after an unrecoverable error +VOID p_panic(INT nPanic); +Terminate this process with panic number nPanic in the range 0 to 255 without returning to the caller. + + +To avoid system panic numbers, application specific panic numbers should start from 254 downwards. + + +p_pkill Unilaterally terminate a process + + +INT p_pkill (HANDLE pId, INT nReason) ; + + +Terminate process pra for reason nReason (in the range -127 to 128 inclusive) without giving the process +being terminated an opportunity to run any cleanup code before exiting. + + +It is recommended that p_pterminate (described below) is used in preference to p_pkill as it gives the +process being terminated a chance to run any cleanup code. + + +PLIB REFERENCE + + +Returns zero if successful or one of the following negative error numbers: + + +E_FILE_NXIST the process does not exist +E_GEN_FAIL pid is the null process, the supervisor or the file server +p_pterminate Terminate a process + + +INT p_pterminate (HANDLE pid, INT nReason) ; +Terminate process p1d for reason nReason in the range -127 to 128 inclusive. + + +If process prd has called p_onterminate (described next) the call to p_pterminate will simply send the +specified message number to process pid. Otherwise the effect is the same as with p_pki1l. It is +recommended that p_pterminate is used in preference to p_pkill. + + +Returns zero if successful or one of the following negative error numbers: + + +E_FILE_NXIST the process does not exist +E_GEN_FAIL pid is the null process, the supervisor or the file server +p_onterminate Elect to receive termination message + + +VOID p_onterminate (INT nMessage) ; + + +Elect to receive (non-zero) message number nMessage, rather than being summarily terminated, when +another process requests termination by calling p_pterminate. + + +On receipt of the termination message a process should execute its cleanup code and must then terminate +itself, normally by calling p_exit. + + +The process calling p_onterminate must guarantee to respond promptly when the termination message is +sent to it. It should not perform any lengthy, uninterrupted, processing. A process which calls +p_onterminate and then (presumably in error) enters an infinite loop will not be terminated by a call to +p_terminate. It is recommended that a process should not call p_onterminate unless there is an explicit +reason for it to do so. + + +The election may be cancelled by calling p_onterminate (0). + + +Messaging must have been initialised with p_minit prior to the call to p_onterminate, otherwise p_panic +will be called. + + +p_ppanic Panic a process by id + + +INT p_ppanic(HANDLE pId, INT nPanic); + + +Terminate process p1d with panic number nPanic in the range 0 to 255 (used for example by server +processes that receive a garbage message from a client process to panic the client). + + +Returns zero if successful or one of the following negative error numbers: + + +E_FILE_NXIST the process does not exist +E_GEN_FAIL pid is the null process, the supervisor or the file server +p_logona Request notification of process termination + + +INT p_logona (HANDLE pId, WORD *pStatus) ; + + +Make an asynchronous request to be notified of the termination of process pid by having this process I/O +semaphore signalled when pid terminates. See the chapter Asynchronous Requests and Semaphores for a +description of asynchronous requests and the I/O semaphore. + + +Returns zero if successful or E_FILE_NXIST if pId does not exist. + + +After a successful request and before pid has terminated, *pstatus contains E_FILE_PENDING. When pid +has terminated, *pstatus contains the (non-negative) process termination word (as described under the +heading The Process Termination Word at the beginning of this chapter). + + +The caller can cancel the asynchronous request by calling p_logoffa. + + +6-6 + + +6 ERROR HANDLING + + +A server process that responds to inter-process messages from client processes will probably find it more +convenient to use p_logon, described below. + + +For example, the following function: + + +GLDEF_C INT RunSubProcessWait (TEXT *name, BYTE *pReason) + + +{ +HANDLE pid; +WORD stat; + + +if ((pid=p_execc (name, NULL, 0) ) <0) +return (pid); + +p_logona (pid, &stat) ; + +p_presume (pid) ; + +p_waitstat (&stat); + +*pReason=(BYTE) stat; + +return (stat>>8) ; + + +} + + +loads the executable name, resumes the process, waits for it to terminate, writes the p_exit to *pReason +and returns &£_NORMAL_ExIT. It returns a negative error number if it fails to load name and £_paNIc_Ex1T if +the sub-process panics. + + +p_logoffa Cancel notification of process termination + + +INT p_logoffa(HANDLE plId)j; + + +Cancel a previously requested notification of the termination of process pra (as passed to the p_logona +being cancelled). + + +Returns zero if successful or —_FILE_NxIsT if no request is pending. + + +If the cancel gets through before pid terminates, *pstatus will contain z_F1LE_caNcEL. In either case, the +process I/O semaphore is signalled and p_1ogoffa would normally be followed by a call to +p_waitstat (pStatus). + + +p_logon Request message on process termination + + +INT p_logon(HANDLE pId, INT mType); + + +Request to be notified of the termination of process pia by receiving an inter-process message of type +mType when pid terminates. See the chapter Processes and Inter-Process Messaging for a description of +inter-process messaging. + + +Returns zero if successful or E_FILE_nxist if pra does not exist. + + +When process pid terminates the Supervisor process sends the caller a message of type mtype and whose +first word in the message buffer is the pa of the terminating process and whose second word is the +process termination word giving information on how that process terminated (as described under the +heading The Process Termination Word at the beginning of this chapter). + + +The caller can cancel the request by calling p_logoff or p_logoffx. + + +The process must have messages initialised by calling p_minit - the function calls p_ panic if messages +have not been initialised. + + +The p_logon, p_logoff and p_logoffx services were designed for server processes that respond to inter- +process messages from client processes to clean up client specific resources should a client process +terminate without disconnecting from the server. Processes that are not server process and that do not +normally respond to inter-process messages will probably find it more convenient to use p_logona, +described above. + + +PLIB REFERENCE + + +p_logoff Cancel message on process termination +INT p_logoff (HANDLE pId, INT mType); +Cancel a previous p_logon request to be sent an inter-process message when process pId terminates. + + +The value of pta should be as passed to p_logon, and mType is ignored. This form is suitable for +applications that do not make no more than one p_logon request to any particular process. + + +Applications that make two or more p_logon requests with the same value of pra (but, presumably, +different values of mtype) should cancel them by means of p_logoffx, described below. + + +Returns zero if successful or E_FILE_NXIST if pId does not exist. + + +The function calls p_panic if messages have not been initialised. + + +p_logoffx Cancel message of specific type on process termination +INT p_logoffx (HANDLE pId, INT mType); +This function is only available in EPOC version 3.18 or later. + + +Cancel a previous p_logon request to be sent an inter-process message of type mrype when pid terminates +(p1d and mType should be the values that were passed to the p_logon request that is being cancelled). + + +This function must be used in preference to p_logoff in cases where two or more p_logon requests are +made with the same value of pid. + + +Returns zero if successful or E_FILE_NXIST if pId does not exist. + + +The function calls p_panic if messages have not been initialised. + + +p_watchall Watching all exits + + +INT p_watchall(UINT mType) ; + + +Request to be notified of the termination of any process by receiving an inter-process message of type +mType when a process terminates. See the chapter Processes and Inter-Process Messaging for a +description of inter-process messaging. + + +Only one process at a time can request this service and it is usually reserved for use by a system process +(normally the Shell process) to monitor the termination of all processes. + + +The function returns zero if successful or E_GEN_FAIt if a watch is already active. +The format of the received message is as for p_logon, described above. +Calling p_watchall with an mType of zero cancels the request. + + +The process must have messages initialised by calling p_minit - the function calls p_panic if messages +have not been initialised. + + +[ce re FF +Error returns + + +System functions that can fail must somehow indicate success or failure and, where appropriate, elaborate +on the failure. + + +Where there is no elaboration of the error: + + +e Functions that return an address typically return a NULL (zero) address to indicate failure (this is +often used when a function can fail to allocate memory). + + +¢ Otherwise functions return zero or positive to indicate success and -1 to indicate failure (the +constant E_GEN_FAIL is defined as -1 although you can just test for the sign of the returned value). + + +6-8 + + +6 ERROR HANDLING + + +Where the error is elaborated, the system function returns a system error number in the range -1 to -128, +allocated as follows: + + +-1 to-31 Reserved for general errors of the form &_GEN_xxx; (defined in pp_gen.h) +-32 to -63 Reserved for I/O device errors of the form &_FILE_xxx (defined in p_file.h) +-64 to -95 Reserved for future use + +-96 to -128 Reserved for OPL run-time errors + + +The system errors include both generic error numbers (eg =_GEN_NoMEMory) and specific error numbers +(eg E_FILE_PARITY indicating a parity error in a byte received via a serial port). Application programmers +may wish to use the generic error numbers in their own code - see the contents of p_gen.h and p_file.h. + + +The system stores a language dependent description for each of the system error numbers that may be +retrieved by calling p_errs. + + +p_errs Convert error number to string + + +VOID p_errs(TEXT *str, INT errno); + + +Convert a system error number to a language dependent zero terminated text string in str. There should +be at least z_MAx_ERROR_TEXT_S1ZE (64) bytes at address str. + + +If the error is an unknown error the string "Unknown error [xx]" (or a suitable translation if not an +English ROM) is returned, where xx is the value of errno. + + +————————— SS ————>>E~— ——>E>E>>—e~—L_——_ << s +Notifier services + + +The notifier services are used to inform the user of a condition - particularly an error condition - and to +present the user with up to three options on how to proceed. There are two variants of the notify service: + + +p_notifyerr which presents the user with a system error message (converted to text from the +error number using p_errs) and a contextual message + + +p_notify which presents the user with two messages + + +These services can be used by any application and are particularly useful for processes that do not +otherwise have a user interface (for example, the file server). Investigative calls to p_notify may be +temporarily inserted into code when debugging programs. + + +At the level of the services described in this manual and except for the simple console functions such as +p_printf, the operating system does not define any user interface components and the notifier services +rely on a higher level system process! (the "notifier") taking responsibility for implementing a user +interface. The notifier "hooks" the user interface (normally at system start up) by calling p_notifyhook. +The notifier should pre-allocate any memory it requires so that the call will not fail. + + +The notifier service is used by the file server process to give the user the opportunity to rectify a problem +that would otherwise result in a file service request failing (eg to replace an SSD pack that has +inadvertently been removed). This scheme works well when the requesting process is an interactive +application but poorly if the requesting process is designed to run unattended (eg a communications +program) or is itself a server process (eg the window server trying to read a font file). Such processes can +use p_setnotify (FALSE) to stop servers such as the file server from using the notify service to give the +user the opportunity to rectify an error condition. + + +p_notify Present the user with a message and get response +INT p_notify(TEXT *pT1l, TEXT *pT2, TEXT *pOl, TEXT *pO2, TEXT *p0O3); + + +Present the two zero terminated messages pt1 and pt2 to the user, where poi, po2 and po3 are either NULL +or zero terminated strings, offering up to three options for the user to select. The function waits for the +user to select an option and returns zero if the po1 option was chosen, | if the po2 option was chosen and +2 if the po3 option was chosen. + + +'When a specialised process hooks the notifier, it is, by convention, called syssntFy. + + +6-9 + + +PLIB REFERENCE + + +The message pT1 is presented before pt2. So pt1 would typically contain a contextual message (eg "Failed +to save notes.tpd") with ptT2 containing a more detailed message (eg "Disk full"). + + +If pt2 is NULL the second message line is blank. +To offer the user 2 options rather than 3, pass po3 as NULL. + + +To offer the user no option (that is, just to wait until the user has acknowledged the message) pass both +p02 and po3 as NuLL. Alternatively, pass all 3 as NULL as in: + + +p_notify (msgl,msg2,NULL, NULL, NULL) ; +which is equivalent (on an English machine) to: +p_notify (msgl,msg2, "CONTINUE", NULL, NULL) ; + + +Each message string pT1 and pt2 can be up to E_MAX_NOTIFY_TEXT_SIZE (64) in length including the zero +terminator. Each option string po1, po2 and po3 can be up to E_MAX_OPTION_TEXT_S1ZE (16) in length +including the zero terminator. + + +This function sends an inter-process message to the process that has "hooked" the notify interface and +thereby has taken on the responsibility of presenting the error notification user interface. If no process has +hooked the notifier, or if the notifier process has terminated, p_notify returns E_GEN_FAIL. + + +The notifier process may, in some environments, take special action if any of the strings passed to +p_notify contain a leading zero. Programmers should therefore ensure that such a string is not passed as +a parameter to p_notify. Either pass an explicit NULL (as in the above examples) or intercept the string, as +in the following example, where it is assumed that only msg2 may contain a leading zero: +LOCAL_C INT NotifyError(TEXT *msgl,TEXT *msg2) +{ +if (msg2 && !*msg2) +msg2=NULL; +return (p_notify (msgl,msg2,NULL, NULL, NULL) ) ; +} + + +p_notifyerr Notify user of error and get response + + +INT p_notifyerr(INT nError, TEXT *pT2, TEXT *pO1, TEXT *pO02, TEXT *p0O3); + + +Equivalent to calling p_errs (nError) followed by calling p_notify with the resulting error string as the +second parameter and with pt2 as the first parameter (ie the first two parameters are the other way around +compared to p_not ify) with the three option parameters being passed on to p_notify. + + +The message pT2 is presented before the error text corresponding to nError and pt2 would typically +contain a contextual message. + + +Only system error numbers (which include all errors returned by the functions described in this manual) +should be notified using this service. + + +p_setnotify Set notify state +VOID p_setnotify(UINT nState) ; +Set the notify state of this process. + + +If nstate is FALSE, the system will not automatically present the notifier as a result of an error in a service +requested by this process (the error will be returned directly). + + +If nstate is TRUE (the default state after process creation) the notifier may be called. + + +p_getnotify Get notify state +INT p_getnotify (VOID) ; + + +Return the notify state for this process. + + +6-10 + + +6 ERROR HANDLING + + +p_notifyhook Hook the notifier interface + + +INT p_notifyhook (INT mType) ; + + +-Hook the notifier interface such that this process will get an inter-process message from the notifying +process of type mType as a result of the notifying process calling p_notify Of p_notifyerr. + + +Returns zero if successful or z_ceN_ratt if the notify interface has already been hooked. + + +The mtype message contains an array of 5 string pointers into the notifying process data space +corresponding to the parameters to p_notify in the order pT1, ptT2, pol, po2 and po3. A process that hooks +the notify interface should initialise messaging using p_minit with a value of at least 10 for the message +size. + + +The text strings pointed to by the 5 parameters can be fetched from the notifying process using p_pcpyfr +(say using the maximum sizes E_MAX_NOTIFY_TEXT_SIZE and E_MAX_OPTION_TEXT_SIzE). The parameter +to p_mfree gives the result of the notification. + + +A process that has hooked the notify interface should not call either p_notify of p_notifyerr as it would +then try and send itself a message, resulting in deadlock. + + +If the process that has hooked the notify interface terminates, the system automatically frees the notify +interface so that another process can hook the interface. + + +p_notifyunhook Unhook the notifier interface +VOID p_notifyunhook (VOID) ; +Release the notify interface. + + +Calls p_panic if the caller does not have the notifier interface hooked. + + +SS —————————————————————————————————————————————————————————————] +Enter and leave + + +The functions p_enter and p_leave work together. You use p_enter to call or "enter" a function. If +p_leave(err) is called before the entered function returns, the stack is unwound and the call to p_enter +returns err. By convention, a negative value of err indicates an error and a zero (or positive) value +signifies an error-free exit. + + +The call to p_leave (or to a variant such as £_leave) may occur in the entered function or in a sub- +function and so on. + + +The p_leave performs what is sometimes called a "non-local goto" where the address of the goto is +defined by the last call to p_enter. + + +The enter and leave mechanism is commonly used in medium to large interactive applications to +implement structured error recovery. When an error occurs, the application has to do the following to +recover: + + +e free any dangling resources (eg free memory cells, close open channels, close screen windows) +e inform the user of the error +¢ continue + + +Handling all this with ad hoc conditionals in the code can double the size of a program and makes the +code hard to follow. An alternative is to set error state variables, driving centralised clean-up code that is +invoked by a negative return from a call to p_enter on an error condition. + + +The call to p_enter is placed at an appropriate place to continue after the error. The return value indicates +the nature of the error (eg no system memory) and a state variable could give a contextual message (eg +"while attempting to open file xxx"). Other error state variables would give the handles of resources that +should be freed. + + +6-11 + + +PLIB REFERENCE + + +p_enter Enter a function + + +INT p_enter(VOID *pfunc,...); + +INT p_enterl(VOID *pfunc) ; + +INT p_enter2(VOID *pfunc, VOID *al); + +INT p_enter3(VOID *pfunc, VOID *al, VOID *a2); + +INT p_enter4(VOID *pfunc, VOID *al, VOID *a2, VOID *a3); + +INT p_enter5(VOID *pfunc, VOID *al, VOID *a2, VOID *a3, VOID *a4); + +INT p_enter6(VOID *pfunc, VOID *al, VOID *a2, VOID *a3, VOID *a4, VOID *a6é); + + +Call function *pfunc where the remaining (up to 5) arguments to p_enter are passed as arguments to +*pfunc. + + +You can either use p_enter, which presents the cpEct calling convention, or one of the p_enter? +variants, which use a more efficient register calling convention. + + +Once a function has been called using p_enter, that function (or any function that is called before *pfunc +returns) may call p_leave (ret) to unwind the stack and return prematurely from the call to p_enter with +the return value of ret. If p_leave is not called, p_enter returns the value returned by *pfunc. + + +Functions called with p_enter should return an INT or a UINT (since this is assumed by p_leave). A zero +or positive return value is normally taken to indicate that the function completed successfully. + + +Calls to p_enter may be nested, in which case p_leave returns from the last active p_enter on the stack. + + +When p_enter calls *pfunc, it passes parameters to it both on the stack and in registers. Neither calling +convention? is compatible with the default calling convention (which passes parameters in registers) as +specified in p_std.def. + + +Because of the above, the target of a p_enter must declare the function as using one of the following +calling conventions: + + +CDECL where the generated code will take the parameters off the stack + + +ENTER_CALL where the generated code will take the parameters from the registers (which is +more efficient) + + +If you also call the entered function directly (without a p_enter) you must ensure that the prototype for the +function declares the calling convention consistently. + + +For example, to declare the target for a p_enter using CDECL: + + +LOCAL_C INT CDECL RunTestProgram(TEXT *name) +{ + + +..return(0); + + +} +or, more efficiently, using ENTER_CALL: + + +#pragma save, ENTER_CALL + + +LOCAL_C INT RunTestProgram(TEXT *name) +{ + + +..return (0); + + +} + + +#pragma restore +where, in either case, you would enter the function using, say: +ret=p_enter((VOID *)RunTestProgram, "fred") ; +or, more efficiently: +ret=p_enter2 (RunTestProgram, "fred") ; + + +where ret contains zero if RunTest Program returned or the parameter passed to p_leave, if p_leave was +called. + + +2Note that the calling convention applied to the function called by p_enter has nothing to do with the +calling convention of p_enter (or p_enter1 etc) as discussed above. + + +6-12 + + +6 ERROR HANDLING + + +Since it is impossible to construct a general prototype to cover all cases, pfunc is prototyped as a vorpD *. +As in the above example, you have to cast the first parameter to p_enter toa (vorp *) to avoid +compilation warnings. The header files are organised in such a way that the cast is automatically done +when you use one of the fixed parameter p_enter? variants. + + +Note that the requirement for the target of a p_enter to have one of the two special calling conventions +described above means that no PLIB or WLIB function may be the direct target of a p_enter. + + +p_leave Unwind stack and return from last p_enter +VOID p_leave (INT err); + + +Unwind the processor stack and return from the most recently called p_enter, returning the value err. +The function does not return to the caller. + + +Although in practice err is often a negative error number it need not be and p_teave can legitimately be +used to unwind the stack on any kind of condition. + + +The function calls p_panic if there is no call to p_enter on the stack. + + +f_leave Unwind stack and return from last p_enter if error +INT f_leave(INT err); +Similar to p_leave except that it simply returns err if err>=0. That is, it is equivalent to: + + +GLDEF_C INT f_leave(INT err) +{ +if (err<0) +p_leave(err); +return(err); + + +} + + +Although modest in its function, using f_1eave rather than p_leave produces smaller executables and +makes code more readable. For example, compare: + + +pid=f_leave (p_execc (name, NULL, 0) ); +with: + + +pid=p_execc (name, NULL, 0) ; +if (pid<0) +p_leave (pid); + + +You cannot use £_leave on functions that return an address and fail by returning nui. However, the +more commonly used functions of this type have corresponding f_ variants. For example, p_alloc and +p_realloc have the corresponding £_alloc and £_realloc which internally call + +p_leave (E_GEN_NOMEMoRY) rather than return NULL. + + +Example + + +LOCAL_C INT RunSubProcessWait (TEXT *name) +{ +HANDLE pid; +WORD stat; + + +pid=f_leave (p_execc (name, NULL, 0) ); + +p_logona (pid, &stat) + +p_presume (pid) ; + +p_waitstat (&stat); + +if ((stat>>8) !=E_NORMAL_EXIT) +p_panic(stat); + +return ( (INT) ( (BYTE) (stat&Oxff))); + +} + + +6-13 + + +PLIB REFERENCE + + +LOCAL_C INT CDECL RunTestProgram(TEXT *name) +{ +ret=RunSubProcessWait (name) ; +if (ret) +p_printf ("Program %s failed with reason %d",name,ret); +return (0); + + +} + + +LOCAL_C VOID RunTestPrograms (TEXT *list) +{ +TEXT *p; +INT ret; +TEXT name[32]; + + +p=p_scpy (&name [32], "testx")-1; +while (*p=*list++) + + +{ +ret=p_enter((VOID *)RunTestProgram, &name[0]); + + +if (ret<0) + + +{ +p_atos(é&msg[0],"Failed to run %s",&name[0]); +ret=p_notifyerr (ret, &msg[0], "CONTINUE", "ABANDON", NULL) ; + + +if (ret==2) +p_exit (0); + + +GLDEF_C INT main(VOID) +{ + + +RunTestPrograms ("abcd"); /* runs testa.img, testb.img, ... */ + + +return (0); + + +} + + +Note the use of cbEct in the declaration of RunTestProgram. + + +There are more examples of the use of p_enter and p_leave in the Files chapter. + + +6-14 + + +CHAPTER 7 + + +MEMORY ALLOCATION + + +Overview of system memory usage + + +The EPOC operating system runs on the 8086 processor (and also the 80286, 80386 or 80486) where up +to 1Mb of memory may be addressed. On SIBO machines and depending on the model, all or part of this +address range may be used where the available memory is allocated (from address zero to oxffffFf) as +follows: + + +e 1K bytes of interrupt vectors (required by the 8086 architecture) +e the screen bit-map (small display models) +e the operating system data space + + +e allocated memory segments (including application code segments, process data segments and +device driver segments) + + +e unallocated memory + +e the internal RAM drive (LOC::M:) + +¢ environment variables (up to 4K bytes) + +e any portion of the 1Mb that is not used + +e the screen bit-map (large display models) +e the system ROM (typically 256K bytes) + + +The contents of the internal RAM drive and the environment variables survive a system reset (unless the +ESC key is held down) and most system crashes. See p_get res in the chapter General System Services for +more on system resets. + + +If we consider only that (greater) part of memory that is dynamically allocated, it is organised into four +main sections: + + +Memory segments +Unallocated memory + + +RAM drive (M:) +Environment variables + + +The system maintains all the unallocated memory in a single chunk - between the allocated memory +segments and the memory used by LOC::M:. This means that memory segments have to be moved as a +result of other segments being created, deleted or having their size changed. + + +Although application code segments and process data segments can and do move at any time while an +application process is running, the operating system automatically adjusts the 8086 segment registers +(CS, DS, SS and ES) to follow any movement without explicit support from the application - as discussed +in the first chapter of this manual. + + +7-1 + + +PLIB REFERENCE + + +As well as giving some background on memory usage, this chapter describes functions that allocate and +access: + + +¢ memory cells from the heap in the process data segment (which is a dynamic segment) +e memory segments (either device or dynamic) +¢ environment variables + +Memory segments + +The allocated memory segments contain both device and dynamic memory segments. + + +Device segments are created when an external device is installed and are deleted when the device is +removed. Once created, a device segment does not normally change its size. The first two device segments +are special and are created at system startup for the process data segments of the first two processes to be +created - the null process (SYS$NULL) and the supervisor (SYS$MANG). Neither of these two process +data segments changes size. + + +Dynamic segments are much more volatile. Code and data segments are created and deleted as processes +are created and terminated. Process data segments change their size to accommodate heap allocations. + + +Device segments are allocated with a lower address than the dynamic segments so that they are not +disturbed by any activity with respect to the more volatile dynamic segments. A device driver normally +has to stop working while its segment is moving - which could lead to loss of data (say when receiving +data via the serial port). + + +Allocated memory segments are described by: +e asegment name +e asegment handle +e asegment size +e asegment address + + +Segment names + + +Segment names are zero terminated strings of up to eight characters followed by an optional period and +up to three further characters (the same rules as for file names). Examples of valid names are as follows: + + +NOTES +NUMBERS . DAT +DATASEG.01 + + +As with file names, the segment name extension normally indicates the usage of the segment. The system +has the following conventions: + + +-LDD and .PDD indicate device segments that contain a Logical Device Driver and a Physical +Device Driver respectively. Device drivers are normally written in 8086 +assembler. See the EPOC O/S System Services reference manual for more about +device drivers. + + +$SC indicates the primary shared code segment that is associated with one or more +processes. Running say myprog.img will cause the code to be loaded into a +segment called myprog.$sc (provided that myprog.$sc isn't already loaded). + + +.DYL indicates a dynamic library code segment (DYL) that is associated with one or +more processes. See the chapter Object-Oriented Programming for more about +DYLs. + +$nn indicate process data segments where nn consists of two decimal digits + + +(O1, 02, ...) according to the process number. + + +The name of a process data segment is normally the same as the process name although they are in fact +independently held (the process name can be changed using p_prename). The process data segment is +described further below. + + +7-2 + + +7 MEMORY ALLOCATION + + +Segment handle, address and size + + +The segment handle is actually the relative address of the segment table index entry in the operating +system data space. This 16-byte entry contains the address of the segment, the segment usage count and +the segment name. + + +The usage count normally indicates the number of processes that are using the segment - for example, +when there are 2 processes of the same application, the usage count of the application code segment is 2 +whereas the usage count of each process data segment is 1. When the usage count drops to zero, the +memory segment may be (and normally is) deleted. + + +The order of the segments follows the order of the segment table index entries and the segment size is +calculated by subtracting the start addresses of adjacent segments. + + +The segment index table has a fixed total capacity with fixed sub-capacities for device and dynamic +segments (typical limits are 96 total segments as 32 device segments and 64 dynamic segments). A +segment allocation will fail if one of these limits is reached (which is unlikely unless there is a bugged +application that fails to free segments). + + +Although the allocated segments themselves are contiguous, the segment index table may have "holes" in +it as a result of segment deletion. When a new segment is allocated, it will tend to fill any holes in the +index table first and, in this case, the created segment will be inserted before other segments causing them +to be moved. + + +The address and size of memory segments is expressed in 16-byte paragraphs (as used in setting the value +of the 8086 segment registers CS, DS, ES and SS). It follows that segments start on 16-byte boundaries +and are a multiple of 16 bytes long. From the point of view of the segment allocator, the maximum +segment size is 512K which makes it possible to specify a segment size (in 16-byte paragraphs) within a +signed 16-bit word. + + +Process data segments + + +When a process is created (normally by loading an image using p_execc Of p_execcasync), a process data +segment is also created. When that process is running application code, the 8086 DS, SS and ES registers +point to the start of the data segment which can not be greater than oxffe0! bytes long (this is called the +small model on PCs). + + +The data segment contains (from low to high address): + +e the reserved static variables (0x40 bytes) + +e the floating point emulator data space (0x200 bytes from offset 0x100) +e the processor stack + +e initialised static variables + +e uninitialised static variables + +e the process heap + + +The size of the processor stack depends upon the C startup module that is being used but is typically in the +range 2K to 8K. Note that the stack size declared by the startup module includes the 64 bytes of reserved +static variables and the floating point emulator data space. + + +The word at address zero is initialised to oxpEap and is otherwise unused. If it is not oxpzap, it is probably +because of a write using an uninitialised pointer that happened to have a zero in it. + + +In the absence of any further initialisation (such as the oxpEap above), the reserved statics variables are +initialised to zero. + + +The bytes in the stack area are initialised to oxe£. The number of oxf bytes from address 0x40 in the +process data segment measures the number of spare bytes on the stack provided the program is not using +the floating point emulator. If the program is using the floating point emulator, the lowest point the stack +should legitimately reach is 0x300. + + +!The segment size is limited to 32 bytes less than the maximum 64K so that a stack underflow will always +cause an address trap. + + +PLIB REFERENCE + + +Despite their name, the uninitialised static variables are all initialised to zero. + + +The process heap contains dynamic data structures that are created and destroyed within the lifetime of +the process. The heap is placed at the end of the process data segment so that it can be expanded by +expanding the process data segment. Since the data segment is limited to 0xffe0 bytes, the maximum +heap size is somewhat smaller than 64K, depending on the size of the stack and the space taken by the +static variables. The process heap and the allocator are described in detail next + + +The heap allocator + + +The allocator is used to allocate, resize and free variable length memory cells (which typically range from +10s of bytes to a few kilobytes in length) from the process heap. Allocated cells are referenced directly by +their address; they do not move to compact free space left by freed cells. + + +The allocator functions are: + +p_alloc, f_alloc allocates a cell, returning its address. + +p_free frees a cell, which is returned to the heap. + +p_realloc, f_realloc changes the size of the cell, returning its new address. + + +p_adjust opens or closes a gap in the middle of the cell (useful for deletion and insertion +of cell content), changing the size of the cell as appropriate. + + +p_alen returns the size of the cell. + +p_hgran sets the heap granularity. + +p_allwalk walks all cells in the heap calling a supplied function (used for heap diagnosis). +p_allchk uses p_allwalk to check the integrity of the heap. + +p_allspe gets the start address and free space in the heap. + + +The functions f_alloc and f_realloc are identical to p_alloc and p_realloc respectively except that +they call p_leave (E_GEN_NOMEMoRY) if the memory could not be found rather than returning a NULL +address. See the function p_leave for more details. + + +The allocator functions are used internally by many other PLIB functions. + + +Heap structure + + +After a number of allocate and free calls the heap typically consists of ranges of adjacent allocated cells +separated by single free cells (which are linked). Each cell (whether free or allocated) is prefixed by a +hidden 16-bit word that gives the size of the cell in bytes. This leading length word is hidden since the +address returned by p_alloc, p_realloc and p_adjust skips this header and the length returned by +p_alen does not include it. + + +Writing beyond a cell's limits will corrupt a cell length word (and possibly also a free space cell pointer) +which destroys the heap's integrity. Such errors are difficult to debug because there is no immediate effect +- the corruption is a "time bomb". It will eventually be detected (resulting in a call to p_panic) bya +subsequent allocator call (such as p_free). The p_alichk function is provided as a debugging tool to force +a call to p_panic sooner rather than later when it is suspected that the heap's integrity has been damaged. + + +Growing and shrinking the heap + + +In EPOC, a process heap is not fixed in size - the system can grow and shrink the heap (and the process +data segment that contains it). The heap is grown to satisfy allocation requests that would otherwise fail, +up to the 0xffe0 process data segment limit. The heap may be shrunk to release memory to the system +when it is required. When the heap is grown, it is normally grown by 2K bytes more than is strictly +needed to satisfy the request - see p_hgran for more details. When an application is executed to create a +process, the initial size of the heap is taken from a value that is stored in the executable (by default, 2K +bytes). This same value also specifies the minimum size of the heap. + + +Allocation is based on "walking" the free space list to find a free cell that is big enough to satisfy the +request (using the "first fit" algorithm). If no free cell is big enough, the system will attempt to grow the +data segment to add more free space at the end of the heap. + + +7 MEMORY ALLOCATION + + +If there is no memory in the system to accommodate growth or if the data segment has reached its +maximum oxffeo byte value, the allocate request fails. There are few circumstances when an allocate +request can be assumed to succeed and calls to p_alloc, p_realloc and p_adjust should have recovery +code to handle a failure to allocate. + + +From the point of view of the user of an application, the two causes of an allocation failure produce quite +different situations. If there is no memory left in the system, this can normally be remedied by the user +taking some action to release memory (such as exiting a task). If the 64K limit has been reached, this is +presumably as a result of a heap-based data structure reaching its design limit (rather than a bug as in, for +example, "alloc heaven", described below). + + +Applications that contain indefinitely growing heap-based data structures (as in, say, a spreadsheet) +should not allow the data structure to grow until the allocation fails when the oxffe0 data segment limit is +reached because, at this limit, there may not be sufficient memory in the free space list to perform other +tasks (such as saving the data to file!). The growth of such data structures should be monitored by the +application and limited to leave sufficient heap capacity for tasks that the user would reasonably expect to +be able to perform. + + +The segment allocator can reclaim excess space from a heap if the last cell in the heap is a free cell, +reducing the size of the last free cell to a small value. However, the heap is never shrunk below its initial +size (as specified by the value in the executable). + + +Alloc heaven + + +There are cases in which programs allocate a sequence of cells which must either exist as a whole or not +at all. If during the allocate sequence one of the later allocations fail, the previously allocated cells must be +freed. If this is not done, the heap will contain unreferenced cells that consume memory to no purpose. At +Psion we say that these cells have gone to "alloc heaven". + + +When designing how to physically organise data structures into alloc cells you should be mindful of the +recovery code that must be written to free partially built multi-cell structures. The fewer the cells in a +structure, the easier the recovery code. + + +Internal fragmentation + + +The free space in a heap is normally fragmented where the largest cell that may be allocated is +substantially smaller than the total free space. Excessive fragmentation, where the free space is +distributed over a large number of cells (and where by implication many of the free cells are small) +should be avoided because it results in an inefficient use of memory and reduces the speed with which +cells are allocated and freed. Practical design hints for limiting internal fragmentation are: + + +e Avoid using the heap for small highly transient data structures that can be placed on the stack (as +an automatic). High frequency cycling through allocate and free pairs "churns" the heap and +leads to a long free space list. + + +e When you have a large number of variable length data structures (particularly when they are +frequently resized), "granularise" them (i.e. round the allocate up to a multiple of some +reasonable value) so that you decrease the chance of leaving small unusable free space cells. + + +e Use heap analysis tools to give you a feel for what is going on. You may find that by changing +the way you do something you get a better heap and you may even discover some alloc heaven. +Don't go too far - there are diminishing returns to heap usage tuning. + + +p_alloc (or f_alloc) Allocate a memory cell + + +VOID *p_alloc(UINT size); +VOID *f_alloc(UINT size); + + +Allocate a memory cell of at least size bytes long from the heap and return the address of the allocated +cell or nuut if there is insufficient memory. + + +You should always test the result for nuLL and take recovery action. The size actually allocated may be a +few bytes more than that requested (see p_alen). The maximum size is 64K minus the combined size of +the machine stack and the space taken by static variables. + + +2Unfortunately, the system does not distinguish between the two causes of allocation failure. + + +7-5 + + +PLIB REFERENCE + + +If the heap is corrupt, calling p_alloc may or may not detect it - but if it does it will call p_panic. Use +p_allchk to check the integrity of the heap thoroughly. + + +The function £_alloc is identical except that it calls p_leave (E_GEN_NOMEMORY) rather than return NULL. + + +Example + + +GLDEF_C TEXT *AllocString(TEXT *str) +/* +Allocate and copy in a zero terminated string. +a7 +{ +TEXT *p; + + +if (p=p_alloc(p_slen(str)+1) ) +p_scpy(p,str); /* Copy in the string */ +return (p); + + +} + + +This example assumes that any more specific error recovery is handled by the caller. + + +p_free Free an allocated cell +VOID p_free(VOID *pcell); + + +Free the allocated memory cell at address pce11, returning the cell to the free memory list. Does nothing if +pcell is zero - this is sometimes useful in error clean-up situations. + + +If pcell is non-zero, it should contain the address of a cell as returned by, for example, p_alloc. Passing a +value that is not the address of an allocated cell (eg by freeing a cell twice) will corrupt the heap. There is +a chance that p_free will detect a bad address and call p_panic. + + +p_realloc (or f_realloc) Change cell size + + +VOID *p_realloc(VOID *pcell, UINT size); +VOID *f_realloc(VOID *pcell, UINT size); + + +Change the size of the allocated cell pce11 to be size bytes and return the address of the new cell or NuLL +if there was insufficient space for the size change. + + +If nuxt is returned, the original cell is unaffected. The limits on size are as for p_alloc. Calling +p_realloc(pcell,size) when pcell is zero is equivalent to calling p_alloc(size) - this can be useful in +start up situations. + + +The cell retains its original content which is truncated if the cell size is reduced. The cell start address +does not change when the cell size is reduced or stays the same. If the cell size is increased, p_realloc +will use any trailing free space of sufficient size but, more likely, it will allocate a new cell, copy the data +across and free the old cell where, in this case, the returned address is different from pce1l. If pcell is +neither zero nor the address of an allocated cell, the heap will either be corrupted or p_panic will be +called. + + +The function £_realloc is identical except that it calls p_leave (E_GEN_NOMEMoRY) rather than return +NULL. + + +p_adjust Insert or delete data in cell +VOID *p_adjust (VOID *pcell, UINT offset, INT amount); + + +Open or close a gap at offset offset within the allocated cell pce1l, using p_realloc to make the +appropriate change to the cell size. As for p_realloc, p_adjust returns the address of the new cell or +NULL if there was insufficient memory. If amount is positive, a gap of amount bytes is opened. If amount is +negative -amount bytes are deleted. If amount is zero, the function has no effect and returns pcell. + + +Unlike p_realloc, pcell may not be passed as NULL. If pce11 is not the address of an existing allocated +cell, the heap will either be corrupted or p_panic will be called. + + +If amount is negative, -amount bytes is deleted by shifting the trailing contents left, closing the gap. + + +7 MEMORY ALLOCATION + + +old cell XXXXXXXXXXKZZZZZZZZZZYYYVYVYYVYYVYY +< offset >< amount > + + +new cell XXXXXXXXXXYYVYVVVVVVVVYYVY +< old size - amount > + + +The cell size is decreased by the same amount. There is no data deletion if the offset is greater than or +equal to the original cell size. The minimum cell size actually allocated is as for p_alloc. If the new size +would be negative, p_panic is called. + + +If amount is positive, the cell size is increased and a gap is then inserted starting from the specified offset +by shifting the trailing contents right. + + +old cell XXXXXXXXXXYYYYVVVVVYVYVYYVY +< offset >< amount > + + +new cell XXXXXXXXXXKZZZZZZZZZZYVYYVVYVYYVYY +< old size + amount > + + +If offset is greater than or equal to the original cell size, no shifting takes place. + + +A typical use is to insert or delete a record (which may be of fixed or variable length) in a contiguous +sequence of records contained in an alloc cell. + + +p_alen Get cell length +UINT p_alen(VOID *pcell); +Return the length in bytes of the allocated cell pceil. + + +The returned cell length will be equal to or slightly larger than that requested using p_alloc Of p_realloc +because (1) sizes are rounded up to an even size, (2) there is a minimum cell size and (3) the allocation +can't leave a trailing free space cell below the minimum size. + + +If the passed address is not the address of a cell, there is a chance that p_alen will detect it and call + + +p_panic. + + +p_hgran Set heap granularity + + +VOID p_hgran(UINT nparas); +Set the heap granularity to nparas (measured in paragraphs where a paragraph is 16 bytes). + + +The maximum value for nparas i$ E_MAXx_GROWByY (16K bytes) - p_hgran calls p_panic if this is violated. +Processes are created with heap granularity =_GRowBy_DEFAULT (2K bytes). z_max_GRrowBy and +E_GROWBY_DEFAULT are defined in epoc.h. + + +The heap granularity controls the increment by which the heap grows to satisfy an allocation request that +cannot be met from the existing free space list. The granularity is added to the amount that is just +sufficient to satisfy the request. Growing the heap can be computationally expensive because many other +segments may have to be shifted by the growth of the process data segment. Applications that can rapidly +create large data structures (such as when loading a large file in the text processor) can improve their +performance by setting a larger heap granularity. Setting the heap granularity has no affect on the way the +system shrinks the heap to release memory. + + +p_allwalk Visit all cells + + +VOID p_allwalk(VOID (*fptr) (VOID *fpar,INT isalloc,UINT len), VOID *fpar); + + +Walk through every cell in the heap (whether allocated or free) in sequence from low to high address and, +if fptr is not nut, call fptr for each cell. The heap is checked for consistency and p_panic is called if an +inconsistency (for example an overlap between a free cell and an allocated cell) is detected. + + +In the call to fptr, the parameter isalloc 1s TRUE if the cell is an allocated cell and ratss if it is a free +cell. The parameter 1en is the total length of the cell in bytes (1en includes the size of cell header +information and is 2 greater than that returned by p_alen). + + +7-7 + + +PLIB REFERENCE + + +Cell addresses can be calculated from the cell lengths and the heap start address. The heap start address +may be found by calling p_allspce. + + +This function is provided for heap diagnosis and is called, for example, by p_allchk. +In the following example, NumallocCel1s returns the number of cells allocated: + + +LOCAL_C VOID CountIfAlloc(UINT *pn, INT isalloc,UINT len) +{ +if (isalloc) +*pnt=1; +} + + +GLDEF_C UINT NumAllocCells () + + +‘i +UINT n; + + +n=0; +p_allwalk((VOID (*) (VOID *,INT,UINT) )CountIfAlloc, &n); +return (n); + + +} + + +The call to p_allwalk calls back count If£A1lloc (which simply increments the allocated cell count if the +cell is an allocated cell) for each cell in the heap. + + +p_allchk Check heap integrity +VOID p_allchk (INT num); + + +Walk through all the allocated cells checking for consistency with the free space list. Call p_panic (0xff) +if there is something wrong. + + +Used as a debugging aid to detect errors from freeing a cell twice or overwriting the boundaries of an +allocated cell. Otherwise, such errors can remain undetected for some time. + + +If it does discover something wrong, and before calling p_panic, it writes 3 words of diagnostic +information to reserved statics, as follows: + + +DatApp1 (0x28) a reason code, described below +DatApp2 (0x2a) the address at which the corruption was discovered +DatApp3 (0x2c) the passed parameter nun, to enable identification of the offending call + + +The reason code is one of: + + +5 a free cell pointer was probably overwritten +6 a cell length is too small or odd (possibly because it was overwritten) +7 an allocated cell length is too large (possibly because it was overwritten) + + +This information is only useful in conjunction with a debugging tool that allows the process data segment +to be examined after a call to p_panic. + + +p_allspc Get heap address and potential free space +UINT p_allspc(VOID **pheap) ; +Return the potential free space in the heap in bytes and writes the start address of the heap to *pheap. + + +The potential free space is calculated as the sum of the free cells in a process data segment that has been +expanded to its full size of 0x££e0 bytes. In practice, the amount that can be allocated will certainly be less +than this and depends upon how fragmented the heap is and on the amount of free memory in the system. +This function should not be used to predict a successful allocation but it can be used to predict an +unsuccessful one. + + +The heap start address *pheap can be used to turn the cell lengths produced by p_allwa1k into addresses. + + +7-8 + + +7 MEMORY ALLOCATION + + +a aa +System memory usage + + +p_getram Get addressable system RAM size +UINT p_getram(VOID); +Return the size of the addressable system RAM in paragraph (16 byte) units. + + +Since the memory in machines containing more than 512 kilobytes of RAM is bank-switched, this +function will never return a value larger than 32768 (corresponding to 512 kilobytes of RAM). + + +p_totalK Get total system RAM size + + +UINT p_totalK (VOID); +This function is only available in EPOC version 3.50 or later. +Return the total amount of memory in the machine in kilobytes. + + +This function reports the total amount of RAM present in the machine, irrespective of bank-switching. +Thus, on a machine containing 1 megabyte of RAM, a call to p_totaix will return the value 1024, +whereas a call to p_getram on the same machine will return 32768 (corresponding to 512 kilobytes). + + +p_sgfree Get size of available segmented memory + + +UINT p_sgfree(VOID); + + +Returns the amount of available (i.e. currently unused) addressable segmented memory in paragraph (16 +byte) units. + +Since the memory in machines containing more than 512 kilobytes of RAM is bank-switched, this +function will never return a value larger than 32768 (corresponding to 512 kilobytes of RAM). + + +The value returned should be treated with some caution as the amount of available memory in a multi- +tasking environment is a dynamic function of the memory requests of all the currently running processes. + + +p_sgramdisk Get memory used by internal RAM disk + + +UINT p_sgramdisk (VOID) ; + + +-Returns the number of 16-byte paragraphs in the addressable RAM that are currently used by the internal +RAM disk (LOC::M:). + + +On machines containing more than 512 kilobytes of RAM, the RAM disk will be created in an upper +bank. In this case, unless the RAM disk overflows into the addressable RAM, p_sgramdisk will generally +return zero. + + +On machines containing not more than 512 kilobytes of RAM, the return value will be larger than that +obtained from p_dinfo, which measures storage capacity rather than the total number of bytes used. + + +EE +Memory segments + + +Applications that need more memory to store data, can allocate one or more external memory segments. +Each segment can be up to 512K bytes long, subject to the availability of free system memory. + + +The most common use of the functions described in this section is to implement a potentially large data +structure without being constrained by the 64K (or less) limit of the heap. To create and access a data +structure in an external data segment, you would use: + + +p_sgcreate to create an external data segment of a specified initial size + +p_sgcopyto to write to the external segment + +p_sgcopyfr to read from the external segment + +p_sgadjust to adjust the size of the data segment (say to increase its size to accommodate + + +additional content) + + +p_sgdelete to delete the data segment after it is no longer required + + +7-9 + + +PLIB REFERENCE + + +Memory segments can be used to implement a data structure that is accessed by more than one process. +For example, a "pipe" in which one process creates a data segment and writes to it and where a second +process reads from it. In this case, the second process would use: + + +p_sgfind to locate the pipe by its memory segment name +p_sgopen to open the segment + +p_sgcopyfr to read from the segment + +p_sgclose after finishing with the segment + + +You would need to use an associated semaphore to synchronise access to the segment (as described in the +chapter Asynchronous Requests and Semaphores). + + +If a memory segment is locked by a process calling p_sglock, the segment will survive the demise of the +creating process + + +p_sgcreate Create memory segment +HANDLE p_sgcreate(TEXT *pName, INT nParas, INT uMode) ; + + +Creates a memory segment with the zero terminated name pName and size nParas (in 16-byte paragraphs) +and, if successful, return the positive handle to the created segment. Otherwise, it returns one of the +following negative error numbers: + + +E_GEN_NOMEMORY Not enough memory to satisfy the request +E_GEN_NOSEGMENTS No memory segment handles are available +E_FILE_EXIST A memory segment of the requested name already exists +E_FILE_NAME The requested name is invalid + + +The memory segment created is not initialized in any way and will contain random data. The returned +handle allows access to the contents of the segment using p_sgcopyto and p_sgcopyfr. + + +After being created, the memory segment is automatically opened and given a usage count of 1. It should +be closed when no longer required by calling p_sgclose. + + +When a process terminates, any open memory segment is automatically closed, decrementing the segment +usage count. If the access count become zero or negative, the segment is deleted. + + +The initial size nParas (in 16-byte paragraphs) must be positive (so the maximum segment size is 512K + + +bytes). +The parameter uMode should be one of the following: +E_SEGMENT_HIGH to create a dynamic memory segment. + + +E_SEGMENT_LOW is provided for future expansion and currently has the same effect as +E_SEGMENT_HIGH. + + +E_SEGMENT_DEVICE to create a device segment. This will result in all devices being held while +memory is moved and then resumed. All dynamic segments will be moved up +in memory to make room. This service is called, for example, by the File Server +when loading external device drivers and should not be used by applications. + + +E_SEGMENT_LOCKED is the same as E_SEGMENT_HIGH except that no process owns the created +segment. Like E_SEGMENT_DEVICE this mode is used internally by the operating +system and should not be used by applications. + + +The function calls p_panic if the requested size was negative or if uMode was not one of E_SEGMENT_LOW, +E_SEGMENT_HIGH, E_SEGMENT_DEVICE Or E_SEGMENT_LOCKED. + + +7-10 + + +7 MEMORY ALLOCATION + + +p_sgdelete Delete memory segment + + +INT p_sgdelete (TEXT *pName) ; + + +Delete the memory segment identified by the zero terminated name pName. Returns zero if successful or +one of the following negative error numbers: + + +E_GEN_INUSE the segment usage count is greater than zero (eg because it is opened by another +process) + +E_FILE_NXIST the memory segment does not exist + +E_FILE_NAME the memory segment name is invalid + +p_sgopen Open memory segment + + +HANDLE p_sgopen(TEXT *pName) ; + + +Open the memory segment identified by the zero terminated name pName and, if successful, return the +handle to the opened memory segment. Otherwise, it returns one of the following error numbers: + + +E_FILE_NXIST the memory segment does not exist +E_GEN_OPEN the memory segment is already open to this process +E_FILE_NAME the memory segment name is invalid + + +The returned handle allows access to the contents of the segment using p_sgcpto and p_sgepfr. +Opening a segment increments the segment usage count. + + +When a process terminates, any open memory segment is automatically closed, decrementing the segment +usage count. If the access count becomes zero or negative, the segment is deleted. + + +There is no limit on the number of memory segments that may be opened by a process. + + +p_sgcopyto Copy to memory segment + + +INT p_sgcopyto(HANDLE nHandle, LONG pos, VOID *source, UINT len); + + +Copy len bytes from source in the current process data segment to offset pos in the open memory +segment nHandle (as returned from p_sgcreate OF p_sgopen). + + +The system ensures that the copy is not interrupted by another process. Address trapping is automatically +switched off for the duration of the copy. + + +The return value has no significance. + + +The function calls p_ panic if pos+ien is greater than the size of the memory segment or if nHandle is not +a valid memory segment handle. + + +A program can check that the segment is still in existence before a call to p_sgcopyto by calling +p_sgopen. + + +If you want to write to a process data segment, it is more convenient to use p_pcpyto, which takes a +process ID rather than a segment handle. + + +p_sgcopyfr Copy from a memory segment + + +INT p_sgcopyfr(HANDLE nHandle, LONG pos, VOID *target, UINT len); + + +Copy len bytes from offset pos in the open memory segment nHandle (as returned from p_sgcreate or +p_sgopen) tO target in the current process data segment. + + +The system ensures that the copy is not interrupted by another process. +The return value has no significance. +The function calls p_panic if pos+1en is greater than the size of the memory segment or if nHandle is not + + +a valid memory segment handle. + + +7-11 + + +PLIB REFERENCE + + +A program can check that the segment is still in existence before a call to p_sgcopyfr by calling +p_sgopen. + + +If you want to copy from a process data segment, it is more convenient to use p_pcpyfr, which takes a +process ID rather than a segment handle. + + +p_sgsize Get size of memory segment + + +UINT p_sgsize (HANDLE nHandle) ; + + +Returns the size (in 16-byte paragraphs) of the open memory segment nHandle (as returned from +p_sgcreate Or p_sgopen). + + +The function calls p_panic if nHandle is not a valid memory segment handle. + + +p_sgadjust Adjust the size of a memory segment + + +INT p_sgadjust (HANDLE nHandle, INT nParas); + + +Adjust the size of the open memory segment nHandle (as returned from p_sgcreate or p_sgopen) to +nParas 16-byte paragraphs. Return zero if successful or the negative E_GEN_NomEmory if there is not +enough memory to satisfy the request. + + +The new segment size nParas must be positive (it follows that the maximum segment size is 512K bytes). +Setting nParas to zero discards all the memory allocated to the memory segment but does not delete the +segment. + + +The function calls p_panic if nParas is negative or if nHandle is not a valid memory segment handle. + + +p_sgfind Find segments by name + + +HANDLE p_sgfind(HANDLE fHandle, TEXT *pMatch, TEXT *pName) ; + + +Write the next segment name that matches the zero terminated match string pMatch as a zero terminated +string to pName where fHandle is NULL for the first call and is subsequently the positive return value from +the previous call. When there are no further segments matching pMatch, it returns E_FILE_NXIST. + + +Used repeatedly to find all the segments that match the wild card string pointed to by pMat ch. The buffer +at pName should be big enough to receive E_MAX_NAME+2 bytes. The wild card string pMatch should remain +the same between successive calls. + + +No memory is used by this service and it can be abandoned at any time without taking any further action. +The function calls p_panic if fHandle is not a valid memory segment handle. +Example + + +GLDEF_C VOID ListCodeSegments (VOID) + + +{ +HANDLE fH; +TEXT buf [ + + +E_MAX_NAME+2]; + + +£H=NULL; +while ((fH=p_sgfind(fH,"*.$SC", &buf[0]))>0) +p_puts (&buf[0]); + + +p_sgclose Close memory segment + + +INT p_sgclose (HANDLE nHandle); + + +Close the open memory segment nHandle (as returned from p_sgcreate or p_sgopen) decrementing the +usage count. + + +Returns zero if successful or the negative E_GEN_NOTOPEN if the memory segment is not open to this +process. + + +Should the access count become zero or negative, the segment is deleted. + + +The function calls p_panic if nHandle is not a valid memory segment handle. + + +7-12 + + +7 MEMORY ALLOCATION + + +p_sglock Increment segment usage count + + +VOID p_sglock (HANDLE nHandle); + + +Lock the open memory segment nHand1le (as returned from p_sgcreate Of p_sgopen) by incrementing the +segment usage count. + + +If p_sglock is called after creating a segment, the segment will not be deleted when the process +terminates. + + +The function calls p_panic if nHandle is not a valid memory segment handle. + + +p_sgunlock Decrement segment usage count + + +VOID p_sgunlock (HANDLE nHandle) ; + + +Unlock the open memory segment nHandle (as returned from p_sgcreate Of p_sgopen) by decrementing +the segment usage count. + + +There is no harm in unlocking a segment that is already unlocked, although if this done inadvertently the +segment could be deleted by another process. + + +The function calls p_panic if nHandle is not a valid memory segment handle. + + +Environment variables + + +The system allocates up to 4K bytes for environment variables at the high address end of the system RAM. +Environment variables are a scarce resource and should be used sparingly. + + +An environment variable consists of: +a name of up to —_MAx_ENv_s1zkE (16) bytes containing any byte except '*' or '2! +a value of up to P_ENvmax-1 (256) bytes with no restriction on the content + + +Each environment variable is stored as two successive leading byte count strings (see the example in the +description of p_findenviron, below). + + +If you are dealing with environment variables where both the names and the values are character strings +you can use: + + +p_getenv to get the value of an environment variable + +p_setenv to replace the value of an existing environment variable or to create one if +necessary + +p_delenv to delete an environment variable + +p_fndenv to get a list of environment variables and their values + + +A more general but less convenient set of environment variable functions (which can be used, for +example, when the values are binary) are: + + +p_getenviron to get the value of an environment variable + +p_setenviron to replace the value of an existing environment variable or to create one if +necessary + +p_delenviron to delete an environment variable + +p_findenviron to get a list of environment variables and their values + + +7-13 + + +PLIB REFERENCE + + +p_getenv Get environment variable value + + +INT p_getenv(TEXT *pMatch, TEXT *pValue) ; + + +Copy the value of the environment variable that matches the zero terminated name pMatch to pValue and +add a zero terminator to the end of the copied value. The name pMatch may include the wild card +characters '?' and '*' in which case the value of the first matching name is copied. + + +Returns zero if successful or the negative E_FILE_NxIst if no matching environment variable exists. + + +The maximum length of an environment variable value is P_ENvMax-1 bytes so up to P_ENvmax bytes can +be written to pvalue (including the zero terminator). + + +p_getenviron Get environment variable value + + +INT p_getenviron(TEXT *pMatch, INT mLength, VOID *pValue); + + +Copy the value of the environment variable that matches the name pMatch of length mLength to pvalue +and return the number of bytes copied. + + +Return the negative E_FILE_Nx1st if no matching environment variable exists. + + +The name pMatch may include the wild card characters '?' and '*' in which case the value of the first +matching name is copied. + + +The maximum length of an environment variable value is P_ENvmMax-1 bytes. + + +p_setenv Set environment variable value + + +INT p_setenv (TEXT *pName, TEXT *pValue) ; + + +Copy the content of the zero terminated string pvalue (excluding the terminating zero) into the value of +the environment variable with the zero terminated name pName, replacing any previous value. If the +environment variable does not exist it is created with the specified name and value. + + +The name pName may not include wild cards and must not exceed E_MAX_ENV_s12E in length. The length +of pValue should not exceed P_ENvmax-1 (255) - any non-zero value in the high byte of the length of +pValue is ignored. + + +Returns zero if successful or one of the following negative error numbers: + + +E_GEN_NOMEMORY the system was unable to allocate room to store the environment variable and +its value either because there is not enough free system memory or because of +the 4K limit on the environment variable space + + +E_GEN_FAIL if pName contains a wild card character +The function calls p_panic if the length of pName exceeds E_MAX_ENV_SIZE. + + +Note that you can't delete an environment variable by giving it a null value - use either p_delenv or + + +p_delenviron. + + +p_setenviron Set environment variable value + + +INT p_setenviron(TEXT *pName, INT nLength, VOID *pValue, INT vLength) ; + + +Copy vLength bytes from pvalue into the value of the environment variable with name pName of length +nLength, replacing any previous value. If the environment variable does not exist it is created with the +specified name and value. + + +The name pName may not include wild cards, nuength must not exceed E_MAX_ENV_SIZE and vLength +should not exceed P_ENvMax-1 (255) - any non-zero value in the high byte of vLength is ignored. + + +Returns zero if successful or one of the following negative error numbers: + + +E_GEN_NOMEMORY the system was unable to allocate room to store the environment variable and +its value either because there is not enough free system memory or because of +the 4K limit on the environment variable space + + +E_GEN_FAIL if pName contains a wild card character + + +The function calls p_panic if nLength exceeds E_MAX_ENV_SIZE. + + +7-14 + + +7 MEMORY ALLOCATION + + +p_delenv Delete environment variable + + +INT p_delenv (TEXT *pMatch) ; + + +Delete the environment variable that matches the zero terminated name pMatch. The name pMatch may +include the wild card characters '?' and '*' in which case the first matching environment variable is +deleted. + + +Returns zero if successful or the negative =_rF1LE_nxist if no matching environment variable exists. + + +p_delenviron Delete environment variable + + +INT p_delenviron(TEXT *pMatch, INT mLength) ; + + +Delete the environment variable that matches name pmatch of length mLength. The name pMatch may +include the wild card characters '?' and '*' in which case the first matching environment variable is +deleted. + + +Returns zero if successful or the negative —_FILE_nxist if no matching environment variable exists. + + +p_fndenv Find environment variables + + +INT p_fndenv (TEXT *pMatch, TEXT *pName, TEXT *pValue, HANDLE *pHandle); + + +Called repeatedly to find the name and value of all environment variables that match the zero terminated +wild card name pMatch. + + +On the first call *pHandie should contain zero and subsequent calls pass the value that is written by the +previous call. The function returns zero if a matching environment variable was found or the negative +E_FILE_EOF when there are no more matching names. The wild card match string pMatch should remain +the same on successive calls. + + +Each successful call writes the name as a zero terminated string to pName (which should have room for +E_MAX_ENV_S1ZE+1 bytes) and its value followed by a zero terminator to pvalue (which should have room +for p_ENvMax bytes). + + +A wild card name of "*" will match all the environment variables. + + +p_findenviron Find environment variables + + +INT p_findenviron(TEXT *pMatch, INT mLength, UBYTE *pBuf, HANDLE *pHandle); + + +Called repeatedly to find the name and value of all environment variables that match the wild card name +pMatch of length mLength. + + +On the first call *pHandie should contain zero and subsequent calls pass the value that is written by the +previous call. The function returns zero if a matching environment variable was found or the negative +E_FILE_EOF when there are no more matching names. The wild card match string should remain the same +on successive calls. + + +Each successful call writes the name and value to pBuf as two successive leading byte count strings giving +the environment variable name followed by its value. The maximum length of an environment variable +name is E_MAX_ENV_s1zeE and the maximum length of a value is p_ENvmax-1 bytes so pBuf should have +room for E_MAX_ENV_SIZE+P_ENVMAXx+1 bytes. + + +A wild card name of "*" will match all the environment variables. + + +7-15 + + +PLIB REFERENCE + + +In the following example, PrintaAllEnv prints the name and (potentially binary) value of all the + + +environment variables: + + +LOCAL_C VOID PrintData(TEXT *p,UINT len) + + +{ +UBYTE *pe; + + +p_print ("sd [",len); + +for (pe=ptlen;p", *p) ; + + +GLDEF_C VOID PrintAllEnv (VOID) +{ +UBYTE *p; + + +HANDLE h; +UBYTE b[E_MAX_ENV_SIZE+P_ENVMAX+1]; + + +for (h=0;p_findenviron("*",1,&b[0],&h) >=0;) + + +{ +p=é&b[0]; +PrintData(pt1,*p); /* print name */ + + +pt=*pt+1; +PrintData(pt+l,*p); /* print value */ + + +} + + +7-16 + + +CHAPTER 8 + + +ASYNCHRONOUS REQUESTS AND SEMAPHORES + + +This chapter describes asynchronous requests, semaphores, the I/O semaphore and wait handlers. + + +Semaphores + + +Semaphores are provided to synchronise cooperating processes (where, in this context, a process includes +a hardware interrupt). There are three common uses: + + +e Synchronising access to a shared resource +e —Synchronising supplier-consumer relationships +e Synchronising the completion of asynchronous requests + + +The first two are described briefly in this section. The third use is far more important and is discussed +more extensively in the following section. + + +The semaphores in EPOC are counting semaphores, having a signed value that is incremented by calling +p_signal and decremented by calling p_wait. A semaphore with a negative value implies that a process +must wait for the completion of some other event, such as the freeing of a shared resource. + + +The mechanism by which a process waits on a semaphore is part of the overall management of process +scheduling. + + +Process scheduling +In EPOC, if a process is not the currently running process, it is either suspended or in a queue. + + +A process remains suspended until it is resumed by another process (typically its creator) by that process +calling p_presume. + + +If a process is not suspended, it is in one of the following three types of queues: + + +The ready queue The ready queue contains processes ordered by process priority. On a +reschedule, the process at the high priority end of the ready queue runs. If there +is more than one ready process at the highest priority, they take it in turns to +run every 4 system ticks. + + +The time delta queue There is a single (possibly empty) time delta queue, effectively containing both +processes and timer device entries. The processes are waiting for a relative or +an absolute time as a result of calling p_sleep, p_sleept or p_sleepa. The +timer device entries are associated with processes that have requested an +asynchronous timer. The head of the queue has its delta time decremented +every system tick and is removed when it reaches zero or negative. If it is a +process, it is inserted into the ready queue. If it is a timer device entry, the +associated process I/O semaphore is signalled. + + +The semaphore queues _ There is a (possibly empty) queue of processes for each created semaphore in +the system. If, on calling p_wait, the decremented semaphore is negative, the +calling process is placed at the end of the appropriate semaphore queue. When +that semaphore is subsequently incremented by a call to p_signal, the process +at the head of the semaphore queue is either made current (if it has the highest +priority) or it is inserted into the ready queue (after any processes of equal +priority). + + +8-1 + + +PLIB REFERENCE + + +See also the description of Preemptive scheduling in the chapter Processes and Inter-process Messaging. +Shared access + + +A mutual exclusion semaphore may be used to serialise access to a shared resource (for example, a shared +memory segment). + + +The creator of the shared resource uses p_semcrt to create an associated mutual exclusion semaphore with +an initial value of one. Any process wishing to access the resource first calls p_wait on the resource +semaphore and then calls p_signa1 after completing its access. Because the semaphore was created with +an initial value of one, the first process to call p_wait will return immediately but any other processes that +call p_wait will wait in the semaphore queue. Waiting processes are released on a first-in first-out basis +when the process currently accessing the resource calls p_signal. + + +The nature of the shared resource should be such that any access completes in a relatively short time so +that processes do not wait for extended periods on the mutual exclusion semaphore. Another consideration +is that whereas the resource may survive the demise of its creating process, semaphores are automatically +deleted when the creating process terminates. In many cases, you may find that EPOC is better suited to +supporting the use of server processes for serialising access to a shared resource (as in, for example, the +file server and the window server) rather than using a mutual exclusion semaphore. The design of EPOC's +inter process messaging was largely driven by the requirements of server processes and their clients. + + +Supplier-consumer + + +In this usage, the semaphore is associated with a pool of data (say a circular list in a shared data segment) +and is created with an initial value equal to the number of elements in the pool. The consumer calls +p_wait when it is ready to extract an item from the pool and the supplier calls p_signa1 after it inserted +an item into the pool. If there are one or more elements in the pool, the consumer's call to p_wait returns +immediately. Otherwise, the call to p_wait returns when the supplier inserts an element and calls +p_signal. + + +Asynchronous requests + + +Many system services are implemented in two steps: +e make the service request +e wait for the requested operation to complete + + +In most cases, as well as providing functions for each step, the system provides a function containing both +the above steps. Such functions are called synchronous because they automatically synchronise the +requesting process by waiting until the operation has completed. The internal function that makes the +request without waiting for completion is called an asynchronous function. + + +Examples of asynchronous request functions are: + + +p_ioa, p_ioc for requests on an open I/O channel +p_mreceive to receive an inter process message +p_execcasync for loading images + +p_logona for being informed of a process termination + + +There are also synchronous versions of all the above functions except p_logona (but see the example +below). + + +Applications use asynchronous requests in situations like the following: +e make request A +e make request B +e wait for either of the requested operations to complete + + +Processes wait for the completion of asynchronous requests by waiting on their //O semaphore where each +request is associated with a status word. + + +8-2 + + +8 ASYNCHRONOUS REQUESTS AND SEMAPHORES + + +The I/O semaphore + + +When a process is created, the system automatically creates an I/O semaphore on its behalf (a more +accurately descriptive name would have been the asynchronous request semaphore). After making one or +more asynchronous requests, a process calls p_iowait to wait on the I/O semaphore for one of the requests +to complete. A typical application process spends most of its time waiting on its I/O semaphore. For +example, an interactive application process that is waiting for user input from the window server is +waiting on the I/O semaphore. + + +The process or the hardware interrupt handler that implements the requested operation typically uses +p_iosignalbypid to indicate that the operation has completed. If one or more wait handlers have been +installed (wait handlers are described below), they may process the signal and re-signal using p_iosignal. +In some cases, it is convenient for the requestor to use p_iosignal to signal itself and to subsequently +process that signal in a central call to p_iowait. + + +Status words + + +Although the parameters to asynchronous request functions vary, they all take the address of a signed +16-bit status word which subsequently contains the status of the requested operation. + + +All asynchronous requests exhibit the following behaviour: + + +e While the request is pending, the status word contains the negative E_FILE_PENDING (defined +in p_file.h) + + +e When the operation has completed, a value other than =_rFILE_PENDING Is written to the status +word. This value should be zero or positive to indicate success or a negative error number to +indicate failure. + + +e The requesting process's I/O semaphore is signalled (after the status word has been written). + + +Making a request while a previous request on the same status word is still pending will normally result in +a call to p_panic. + + +When there are multiple requests, each request is associated with a different status word. After returning +from p_iowait, the caller typically polls each status word until one is found that contains other than +E_FILE_PENDING. That completion is then processed (which might include renewing the asynchronous +request) and p_iowait is called again to process the next completion. + + +Every p_iosignai should be matched by a call to p_iowait (or a function that calls p_iowait). The status +word associated with the p_iowait must have completed (ie must contain a value other than +E_FILE_PENDING) at the time that p_iosignal is called. A common programming error is to introduce a +p_iosignal without correctly associating it with a status word, such that the poll after the p_iowait +cannot find a completed status word. + + +At Psion this is known as a "stray signal" and programmers should detect this as early as possible by (say) +calling p_panic when the poll is unable to find a completed status word. + + +For Series 3, Series 3a and Workabout developers, using the Spy application supplied with this SDK may +help identify an accumulation of such unused signals. + + +In the following example, the opened asynchronous timer TimerChannel is used to construct a +synchronous function which attempts to write the passed string to the opened serial channel +SerialChannel. If it takes more that 5 seconds to complete the write, the function calls + +p_leave (SERIAL_TIMEOUT) . For simplicity it is assumed that there are no other outstanding events which +could complete. Thus it is certain that on return from the call to p_iowait, one of the two asynchronous +requests has completed. + + +8-3 + + +PLIB REFERENCE + + +LOCAL_C VOID StringToSerial (TEXT *str) +{ +UWORD len; +WORD TimerStatus; +WORD SerialStatus; +ULONG timeout; + + +len=p_slen(str); +p_ioc(SerialChannel, P_FWRITE, &éSerialStatus, str, &len) ; +timeout=50; /* 5 second timeout */ +p_ioc(TimerChannel, P_FRELATIVE, &TimerStatus, &timeout) ; +p_iowait (); +if (SerialStatus==E_FILE_PENDING) +{ /* must have timed out */ +p_iow(SerialChannel,P_FCANCEL) ; +p_waitstat (&SerialStatus) ; +p_leave (SERIAL_TIMEOUT); /* never returns */ +} +p_iow(TimerChannel, P_FCANCEL) ; +p_waitstat (&TimerStatus) ; +} + + +The functions p_ioc and p_iow are described in the next chapter: /O System. +Cancelling an asynchronous request + + +In the above example, the asynchronous request which does not complete is cancelled by making a +P_FCANCEL request using p_iow (the synchronous version of p_ioc or p_ioa). Most asynchronous request +functions have an associated cancel function; the P_FCcANCEL, to cancel I/O requests on a device channel, +is one example. Other examples are: + + +p_mcancel to cancel a call to p_mreceive to receive an inter process message +p_logoffa to cancel a call to p_logona for being informed of a process termination +The following general principles apply to all functions that cancel an asynchronous request: + + +e the cancel precipitates the completion of the operation (it does not stop the operation from +completing) + + +e the cancel may or not be effective (that is, the operation may complete naturally before the cancel +is processed) + + +e after a cancel, you must still process the completion of the asynchronous request (typically by +immediately calling p_waitstat to "use up" the signal) + + +Waiting for a particular completion + + +When waiting for the completion of a particular asynchronous request, the wait on the I/O semaphore +must be sure that it is not fooled into a premature return by the completion of any other pending +asynchronous request. This is done by calling p_waitstat which behaves in a similar way to p_iowait +except that it only returns when the associated status word is other than E_FILE_PENDING. + + +In general, p_waitstat is a safer option than p_iowait to "use up" the signal resulting from the cancelled +operation. If the cancel is not immediately effective and another completion causes p_iowait to return, the +program could continue and make another request before the cancelled operation completes (which would +result in p_panic being called). The above example illustrates the technique although, in this case, it is +not strictly necessary since there can be no confusion as to which event has completed. + + +8-4 + + +8 ASYNCHRONOUS REQUESTS AND SEMAPHORES + + +Constructing synchronous functions + + +General purpose functions that provide a synchronous interface must use p_waitstat rather than +p_iowait since they can not assume that there are no other pending asynchronous requests. + + +The use of p_waitstat Is illustrated by the following example of a synchronous function: + + +GLDEF_C INT ResumeWait (HANDLE pid) + + +{ +WORD stat; +INT ret; + + +if (!(ret=p_logona (pid, &stat) ) ) +{ +p_presume (pid) ; +p_waitstat (&stat); +ret=stat; +} + + +return (ret); + + +} + + +This is intended to be used in place of p_presume and behaves like p_presume except that it returns only +when the resumed process has terminated. It effectively implements a synchronous version of p_logona. + + +Wait handlers + + +Wait handlers are functions that handle the completion of asynchronous requests from within p_iowait +(or p_waitstat). Active wait handler functions are called just before p_iowait would have otherwise +returned. + + +Many I/O devices install a device wait handler when the device is opened (see the System Services +reference manual for information on writing device drivers and I/O device wait handlers). An application +can install any number of application wait handlers using p_svecadd (p_svecrem removes an application +wait handler). Before p_iowait will call an installed wait handler, it has to be activated using p_sveccall +(p_sveccali can also be used to deactivate a wait handler). An installed wait handler is automatically +deactivated when called (which stops it being called recursively since a wait handler often itself calls +p_iowait, directly or indirectly). + + +In the following example (which does not check for errors), setupHeapChecker installs the wait handler +CheckHeap which then calls p_alichk every 2 seconds or so without any cooperation from the rest of the +program. + + +typedef struct +{ +UBYTE *Channel; +WORD Status; +ULONG Timeout; +} HEAP_TIMER; + + +LOCAL_C INT CheckHeap(HEAP_TIMER *pTimer) +{ +if (pTimer->Status==E_FILE_PENDING) +return (P_SIGNAL_UNUSED) ; +p_allchk (0); +p_ioc(pTimer-—>Channel, P_FREAD, &épTimer->Status, &pTimer-—>Timeout) ; +return (P_SIGNAL_ENABLE) +} + + +GLDEF_C VOID SetupHeapChecker (VOID) + + +{ +HEAP_TIMER *pHeapTimer; + + +pHeapTimer=p_alloc(sizeof (HEAP_TIMER) ); + +p_open (&pHeapTimer->Channel,"TIM:",-1); +pHeapTimer->Status=0; + +pHeapTimer->Timeout=20; /* 2 second tick */ +p_sveccall (p_svecadd (CheckHeap, pHeapTimer) , TRUE) ; +} + + +Wait handlers are only called when the process calls p_iowait (or a function such as p_waitstat that +calls p_iowait). While an application performs a computationally intensive task that takes an extended +time, it should consider calling p_ioyieid (which effectively calls p_iosignal1 followed by p_iowait) to +allow any installed wait handlers to be called. Application programs must never assume that no wait +handlers have been installed. + + +PLIB REFERENCE + + +Installed device wait handlers and application wait handlers are represented as a doubly linked queue of +data structures allocated out of the process heap. The queue is built from a 4-byte queue header in a +reserved static at address 2 in the process data segment. If this reserved static is corrupted (say because of +a write using an uninitialised pointer that happens to have a low value), p_iowait will almost certainly +detect an invalid wait handler and call p_panic (27) although the cause of the panic may have nothing to +do with wait handlers. + + +Polling rather than waiting + + +In a multi-tasking operating system it is extremely anti-social to wait for an operation to complete by +polling the status word in a tight loop rather than call p_iowait (because the polling will "hog" the +processor to no benefit). However, when there is useful work to be done between each poll, it can be +appropriate to poll - for example, to check periodically for user input while performing an extended +calculation. + + +If this approach is used, you should be aware that in some cases asynchronous requests are completed by +a wait handler and it is necessary to call p_ioyield before each poll to give any wait handlers a chance +to run. + + +This case occurs when making requests on a device driver that services hardware interrupts. For example, +the serial port driver services the hardware interrupt generated by the receipt of a serial frame. A +hardware interrupt handler cannot write directly to the data segment of the requesting process because +that data segment may be moving when the interrupt occurs. Instead, the interrupt handler must write first +to a fixed memory location (either in the operating system variables if it is an in-built driver or in a device +segment if it is an external driver) and then signal the I/O semaphore of the requesting process. When the +requesting process next calls p_iowait (directly or indirectly through say p_ioyield), the device driver's +wait handler is called to copy the data safely to the process data segment. + + +Device drivers that are implemented by a server process (for example, the window server) do not require a +wait handler to complete operations. + + +When a poll detects a completed status word it is still obligatory to "use up" the signal by calling p_iowait +(otherwise you will get a "stray signal" later). + + +Attached I/O devices + + +Wait handlers are often used in attached I/O drivers that layer over an existing driver (which may be +another attached driver or a hardware device driver) to extend or modify its services. The attached driver +typically installs a wait handler to handle the completion of requests on the underlying driver. Although +attached drivers can be written in C, the interface between the I/O system and the functions that are called +requires some assembly language programming. See the //O System chapter for more information on +attached drivers. + + +EEE +Primitive semaphore functions + + +p_semcrt Create a semaphore +HANDLE p_semcrt (INT nCount) ; + + +Create a semaphore with an initial positive count ncount. Returns the handle of the semaphore if +successful, or E_GEN_NosEM if no semaphores are available. + + +The created semaphore is owned by the calling process and, in version 3 and later of EPOC, may be +deleted using p_semde1 before exiting. However, the semaphore will always be automatically deleted on +termination of the process. + + +Calls p_panic if ncount is negative. + + +p_semdel Delete a semaphore +VOID p_semdel (HANDLE sHandle); +Delete semaphore sHandle. Any processes waiting on the semaphore are automatically signalled. + + +Calls p_panic if sHand1e is not the handle of a previously created semaphore. + + +8-6 + + +8 ASYNCHRONOUS REQUESTS AND SEMAPHORES + + +Prior to version 3 of EPOC the recommended action is not to delete a semaphore, but to let the operating +system perform any necessary clean-up actions on termination of the application. This is an acceptable +solution for all versions of EPOC. Except in extreme cases, where large numbers of semaphores are +created, there is no need for an application ever to call p_semdel. + + +p_wait Wait on a semaphore + + +VOID p_wait (HANDLE sHandle) ; + + +Decrement semaphore sHand1e by one and return immediately if it is zero or positive. If sHandle is +negative after being decremented, it waits for semaphore sHandl1e to be signalled by another process or by +an interrupt handler (or for sHand1e to be deleted). + + +More than one process can be waiting on a particular semaphore at a time. When there are multiple +processes waiting on a semaphore, they are released on a first-in first-out basis. If a semaphore is deleted, +all processes waiting on that semaphore are released. + + +Calls p_panic if sHandle is not the handle of a previously created semaphore. + + +p_signal Signal a semaphore + + +VOID p_signal (HANDLE sHandle) ; + + +Signal semaphore sHandle, incrementing it by one. If sHandie was less than zero, the first process waiting +on it is released and a reschedule takes place (before p_signal returns). + + +Calls p_panic if sHandle is not the handle of a previously created semaphore. + + +p_signaln Signal a semaphore n times +VOID p_signaln(HANDLE sHandle, INT nTimes); +Equivalent to calling p_signal(sHandle) nTimes times. + + +Calls p_panic if sHand1e is not the handle of a previously created semaphore or if nTimes is not greater +than or equal to 1. + + +p_signalnr Signal a semaphore with no re-schedule +VOID p_signalnr (HANDLE sHandle) ; +Behaves as for p_signa1 except that the re-schedule does not take place. + + +In the absence of any other cause, a re-schedule will not occur until the next system tick. A re-schedule +can always be forced by calling p_sieept (OL). + + +Calls p_panic if sHand1e is not the handle of a previously created semaphore. + + +The I/O semaphore + + +Although the I/O semaphore is indeed associated with I/O operations, it is not used exclusively for I/O +operations. In retrospect, a more accurate name would have been the "asynchronous request semaphore". + + +p_iosignal Signal the 1|O semaphore +VOID p_iosignal (VOID) ; +Increment the process I/O semaphore. + + +Used in wait handlers to signal the completion of an asynchronous request after writing the completion +status to the associated status word. + + +It can also be used outside wait handlers to generate "internal events" where the call to p_iosignal +necessarily precedes the call to p_iowait. + + +8-7 + + +PLIB REFERENCE + + +p_iosignalbypid Signal the 1O semaphore of another process +VOID p_iosignalbypid (HANDLE pid); +Signal the I/O semaphore of process pid. + + +Used to signal the completion of a request from process pid (normally a different process but it still works +if it is the same process). Before calling p_iosignalbypid, the process should already have set the pia's +status word using say p_pepyto. + + +p_iowait Wait on the lO semaphore +VOID p_iowait (VOID) ; + + +Wait for the I/O semaphore to be signalled (of course, it returns immediately if the I/O semaphore has +already been signalled). + + +When the I/O semaphore is signalled, any active wait handlers are called. Only when all the active wait +handlers indicate that the signal has nothing to do with them (ie they all return P_stGNAL_uNUSED) will the +p_iowait call return. When it does return, the signal must be associated with an external (ie outside any +wait handler) status word. + + +The application should then poll the request status words to determine which operation has completed. + + +p_ioyield Allow any wait handlers to run +VOID p_ioyield(VOID) ; + + +Give an opportunity for any active wait handler to run. Equivalent to calling p_iosigna1 followed by a + + +p_iowait. + + +Any application that polls a status word for the completion of an I/O operation (presumably in between +performing chunks of a computationally intensive task) should call p_ioyieid before polling to give any +wait handlers (which are commonly required to complete an asynchronous request) a chance to run. + + +p_waitstat Wait for a particular request to complete +VOID p_waitstat (WORD *pstat); +Wait for the particular asynchronous request associated with *pstat to complete. + + +It is similar to p_iowait except that rather than just wait for the I/O semaphore to be signalled, it also +waits until *pstat is not E_FILE_PENDING. It correctly adjusts the I/O semaphore if any other I/O requests +completes in the meantime, as illustrated in the following code: + + +GLDEF_C VOID p_waitstat (WORD *pstat) + + +/* +Wait for *pstat!=E_FILE_PENDING +*/ + +{ + +INT i; + +i=(-1); + +do + + +p_iowait (); + +itt; + +} while (*pstat==E_FILE_PENDING) ; +while (i--) + +p_iosignal(); + + +} + + +8 ASYNCHRONOUS REQUESTS AND SEMAPHORES + + +The principle may be extended to wait for the completion of more than one asynchronous event. This is +illustrated in the following code, which waits until both of two status words are not equal to +E_FILE_PENDING: + + +GLDEF_C VOID waitstat2(WORD *pstat1,WORD *pstat2) + + +/* +Wait until both *pstat1l and *pstat2 are not E_FILE_PENDING +xf + +{ + +INT i; + +i=(-1); + +do + + +p_iowait (); + +Ltt; + +} while ((*pstat1==E_FILE_PENDING) && (*pstat2==E_FILE_PENDING) ); +if (*pstat2==E_FILE_PENDING) + +pstatl=pstat2; +p_waitstat (pstat1); +while (i--) + +p_iosignal(); + + +Wait handlers + + +p_svecadd Add a wait handler function + + +HANDLE p_svecadd(INT (*vec) (VOID *), VOID *pcb); + + +Add function vec to the I/O semaphore wait handler list and return the non-zero handle of the wait +handler if successful or zero if there is insufficient memory. + + +The returned handle is subsequently used to activate (by calling p_sveccaii) and remove the wait handler +(by calling p_svecrem). + + +Initially the wait handler is inactive. The installed wait handler is normally activated to process the +completion of one or more asynchronous requests. + + +When the wait handler is active, the wait handler function is called from within p_iowait when the I/O +semaphore is signalled. In the interests of efficiency, a wait handler should only be active while there is an +associated pending request. + + +The wait handler function should poll the one or more status words associated with the one or more +requests it is monitoring and return one of the following values: + + +P_SIGNAL_DISABLE the status word was other than &_FILE_PENDING and the completion has been +processed. There are no more requests to process and the wait handler can now +be deactivated. + + +P_SIGNAL_ENABLE a status word was other than &_FILE_PENDING and the completion has been +processed. However, there are still pending requests (either because the wait +handler is associated with more than one request or because another request +was queued) and the wait handler should remain active. + + +P_SIGNAL_UNUSED all status words contained &_FILE_PENDING and no processing took place. The +wait handler remains active. + + +In the first two cases, where the signal is consumed, p_iowait loops back and waits on the I/O semaphore +again. + + +If the wait handler does not detect the completion of an internal request and returns p_sIGNAL_UNUSED, +p_iowait will call any other active wait handlers and will only return to the caller when there are no +active wait handlers or when all the active wait handlers return p_s1GNAL_UNUSED. + + +If in the processing of the completion of one request the wait handler cancels another request, the wait +handler would normally use up the signal from the cancelled requests by calling p_waitstat. + + +8-9 + + +PLIB REFERENCE + + +An active wait handler is deactivated before being called and is only reactivated when it returns with the +value P_SIGNAL_ENABLE Or P_SIGNAL_UNUSED. This normally works such that any calls to p_iowait within +a wait handler will not cause the same wait handler to be called recursively. Other active wait handlers +may still be called within a p_iowait within the wait handler. + + +The wait handler function vec is called with pcb as its single parameter. Where re-entrant code is +required, pcb would normally be an address leading to the status word (or words) associated with the +requests the wait handler is interested in. In non re-entrant code, where static data is used, it may not be +necessary to use pcb. + + +p_sveccall Activate/deactivate a wait handler + + +VOID p_sveccall (HANDLE hand, INT isactive); + + +If isactive is TRUE activate wait handler hand (where hand was returned by p_svecada). If isactive is +FALSE deactivate wait handler nana. + + +In the interests of efficiency, wait handlers should be deactivated when they have no pending requests to +process. As well as being externally deactivated by calling p_svecca11, a wait handler can deactivate itself +by returning P_SIGNAL_DISABLE. + + +p_svecrem Remove a wait handler + + +VOID p_svecrem(HANDLE hand) ; + + +Remove wait handler hand (where hand was returned by p_svecadd) from the I/O semaphore wait handler +list. + + +8-10 + + +CHAPTER 9 + + +/O SYSTEM + + +This chapter describes the EPOC I/O system in general and the C functions used to access I/O devices. To +use a particular device you need (also) to read a description of the device driver. + + +The files device driver and the asynchronous timer device driver are described in this manual - in the +chapters Files and Time, Timers and Dates respectively. Other device drivers are described in the J/O +Devices manual. + + +The last section of this chapter describes a set of console services for constructing rudimentary user +interfaces with the minimum of effort. Worthier user interfaces may be implemented using the services +described in the Window Server reference manual. + + +I/O Device Drivers + + +The principal purpose of device drivers is to provide convenient software interfaces that hide the internal +details of the underlying hardware. For example, the software interface to the RS232 driver is independent +of the interface to the underlying hardware. The fact that the RS232 hardware is different between SIBO +machines and PCs is not apparent to the user of the RS232 driver. + + +Many device drivers do not themselves interface to hardware but layer over one or more other device +drivers that ultimately access the hardware. For example, the majority of the code in the RS232 driver is +independent of the hardware interface and the driver is implemented in 2 layers - an upper hardware- +independent layer and a lower hardware-dependent layer. + + +Some device drivers do not access hardware at all - even indirectly. In such cases, the device driver +mechanism is used to extend the services available to applications. For example, the C standard floating +point library is implemented as a device driver. + + +LDDs and PDDs + +In EPOC there are two types of device driver: +e physical device drivers (PDDs) which are hardware dependent +e logical device drivers (LDDs) which are hardware independent + + +Applications normally interface to LDDs only. An LDD may use one or more PDDs in its +implementation. For example, the RS232 driver is an LDD (the upper layer) using an appropriate PDD +(the lower layer) depending on the underlying hardware. PDDs are also used by the file server system +process to access different types of SSDs. + + +Some device drivers are built into the operating system where their code is in the ROM. For example, the +RS232 LDD and its PDD are normally built into the operating system whereas a bar code reader device +driver is normally external and has to be loaded. + + +PLIB REFERENCE + + +External device drivers + + +External device drivers are loaded from a device driver file into a device memory segment. The device +driver file has the file name extension .LDD or .PDD depending on whether it is an LDD or PDD +respectively. The device memory segment is allocated by the segment allocator as described in the chapter +Memory Allocation. + + +The ability to load and remove external device drivers without a system reset is a key feature of the EPOC +I/O system and contrasts with most other operating systems, which require a system reset to install a +device driver. On a SIBO machine you can physically attach a peripheral device (for example, a bar code +wand) and load a device driver without having to exit any application processes. The I/O system also +notifies devices when the machine switches off and on so that the driver can take appropriate device +specific action before losing power and to recover when the power is resumed. + + +The interface between the operating system and an LDD does not conform to a C calling convention. An +LDD may be written in C but some 8086 assembly language is required to provide the LDD interface. See +the System Services reference manual for more about device drivers. + + +Opening a channel to a device + + +The I/O device driver functions are accessed by opening a channel to the device by calling p_open and +passing it a name consisting of a 3 character device name and a terminating colon. Examples of device +names are: + + +FIL: for opening a file + +PAR: for opening a parallel port + +TTY: for opening an RS232 port + +TIM: for opening an asynchronous timer + + +Note that device names of external LDDs bear no relation to the file name from which they were loaded. + + +Depending on the nature of the device, the ':' may be followed by further text. Where the device driver +supports more than one unit, the device name may be followed by a unit letter. For example, "Try:a" is +used to open a channel to serial port A and "Par:B" is used to open a channel to parallel port B. + + +In the file system device r1u:, the qualifying text is normally a file name or full path name. Because the +file system has more p_open calls made to it than any other device, the p_open function effectively inserts +a "FIL:" before a device name if it fails to recognise a valid device name - making the leading "FIL:" +optional. For example, calling p_open with the name "c:\NOTES\NEW.TxT" has the same effect as the +name "FIL:C:\NOTES\NEW. TXT". Keeping the FIL: prefix removes any possibility of mistaking the file +specification for a device name - for example to open a file on the default directory with file name "TTv:". + + +The p_open function works such that a loaded device driver supersedes any existing device of the same +device name. + + +Operations on an open I/O channel + + +Once a channel has been opened on a device, the primitive p_ioa function is used (directly or indirectly) +to make an asynchronous I/O function request on the channel. Asynchronous requests are described in the +chapter Asynchronous Requests and Semaphores. + + +All I/O function requests are asynchronous in principle and the process I/O semaphore is always signalled +as a result of an I/O function request. In practice, many I/O functions are implemented synchronously, +which means that the I/O operation will have completed before p_ioa returns. A typical I/O device will +provide zero, one, two or three truly asynchronous functions (where the request will probably not have +completed before p_ioa returns) with the remaining functions provided synchronously. For example, the +I/O function that closes an I/O channel is always implemented synchronously, whereas the I/O function +that reads input from a device is commonly implemented asynchronously. + + +In practice, p_ioa is often called indirectly by: + + +p_ioc which makes an asynchronous I/O request in a way that simplifies the handling +of error returns - this should generally be used in preference to p_ioa + + +p_iow which makes the I/O request and then waits for the request to complete (by +calling p_waitstat) + + +9-2 + + +9 /O SYSTEM + + +The particular I/O function requested by a call to p_ioa, p_ioc Or p_iow is specified by a function number +parameter of the form p_Fxxx, defined in p_file.h. Some I/O functions are specific to a particular device +(for example p_rsEtTEor, which sets the end of file position on an open file channel). Some I/O functions +apply to more than one device, including: + + +P_FREAD to read data from a channel + +P_FWRITE to write data to a channel + +P_FCLOSE to close a channel + +P_FCANCEL to cancel outstanding asynchronous requests on a channel +P_FSENSE to sense channel characteristics + +P_FSET to set channel characteristics + +P_FFLUSH to flush out data held in buffers + + +This manual uses the notation p_ioa(P_Fxxx), p_ioc(P_Fxxx) and especially p_iow(P_Fxxx) to refer to +the corresponding function call with p_rxxx passed as the I/O function number. (In the descriptions of +p_ioa, p_ioc and p_iow later in this chapter the I/O function number has the parameter name func.) + + +The most commonly used I/O functions are supported by their own synchronous convenience functions as +follows: + + +p_close which calls p_iow (P_FCLOSE) +p_read which calls p_iow (P_FREAD) +p_write which calls p_iow(P_FWRITE) +p_seek which calls p_iow (P_FSEEK) + + +The functions p_close, p_read and p_write are used across many devices (p_close is applicable to all +devices) and are described in this chapter. The function p_seek applies to an open file channel only and is +described in the Files chapter. + + +The file server + + +The file server is a high priority system process (with process name SYS$FSRV) that performs all file +related operations. These include those that are accessed using the I/O channel services (the r1L: device) +and those that do not require a channel to be opened (eg deleting a file, making a directory). The file +server is also responsible for loading executables (see the chapter Processes and Inter-Process Messages) +and for loading external device drivers (described in this chapter). + + +The file server serialises access to shared file storage devices (eg SSD drives on a SIBO machine) which +may be local or remote. On SIBO machines, the file server uses PDDs extensively to access the many +different types of SSD (different configurations of FLASH, RAM, ROM). The file server also uses an +installable PDD to connect to remote devices via a remote file server. The file server is a process rather +than an LDD because, in a multi-tasking system, more than one process can be accessing a particular file +storage device at a time (at a lower level only the file server owns an SSD drive where it performs all +operations on the SSD on behalf of requesting processes). + + +Application processes that use the file server are called "clients". To become a client of the file server, a +process must connect to it. Because most applications need the file server, the normal code that precedes +main connects to the file server. + + +The client processes send the file server an inter-process message to request a file server service. If the +service accesses local devices, it is implemented synchronously since the file server runs at a higher +priority than any application process. If the service accesses remote devices, it may be implemented +asynchronously. + + +The application programmer does not program at the message passing level but uses the interfaces +provided by the ri: device and a number of ROM resident functions (most of which are described in the +Files chapter). Whether provided by a function or via the r1L: device, all access to the file server +ultimately involves the sending of an appropriate inter-process message. + + +9-3 + + +PLIB REFERENCE + + +Attached drivers + + +An attached driver is an LDD using the services of an another LDD to provide a different set of services to +its user. Some of the devices described in the J/O Devices manual are attached drivers. + + +For example, the PRD: device is an attached driver, layered over a suitable print output device to provide +primitive printer driver services (involving translates, preambles and postambles as driven from a .PRD +file). In this case a suitable print output device is any device that supports the normal P_rwRITE operation +as provided by the par:, TTY: and FIL: devices. + + +The user of the PRD: device does the following: +¢ open the print output device using p_open (eg PAR: Or TTY:) +e perform any initialisation on the channel (eg to set the Baud rate on a tty: channel) +¢ open the prp: device using p_open, attaching it to the opened print output device + + +Once the prp: device has been opened, it replaces the P_FWRITE, P_FCANCEL and P_FCLOSE functions of the +underlying device. + + +In general, an attached driver may completely replace the original driver's functions or it may augment +them (possibly also replacing or disabling some functions). It may also allow some functions through to +the underlying driver or beyond. + + +Like any other LDD, an attached driver may be written in C but some assembly language code is required +to provide the LDD vector interface. See the System Services reference manual for more about writing +attached device drivers. + + +Attached drivers that provide one or more of their services asynchronously make internal asynchronous +requests on the device they are attached to. Where this is the case, the attached driver processes the +completion of its internal requests in code that is entered via its wait handler vector. The attached device +installs its device wait handler when the channel is opened and the wait handler vector is subsequently +called from within the p_iowait of the process which opened the device whenever the process I/O +semaphore is signalled. Except for the way in which they are called, device wait handlers are the same as +application wait handlers as described in the chapter Asynchronous Requests and Semaphores. + + +Channel-based I/O functions + + +p_open (or f_open) Open a channel to a device + + +INT p_open(VOID **ppfcb, TEXT *name, UINT mode); +INT f_open(VOID **ppfcb, TEXT *name, UINT mode); + + +Open a channel to the device with the zero terminated device name name or attach driver name to an +existing channel. + + +The parameter name consists of a 3 character device name terminated by a':’ and optionally followed by +further data, depending on the device. + + +The interpretation of the mode parameter depends upon the device and some devices ignore mode. When a +device ignores mode, the caller should pass a mode of -1. + + +The files device (device name "F1L:") and the asynchronous timer device (device name "TIM:") are +described in the chapters Files and Time, Timers and Dates in this manual. These devices are also +described in the //O Devices manual along with many other devices. + + +If the device name is not an attached device and it is opened successfully, the address of the channel +control block is written to *ppfcb. If the open fails, *ppfcb is not written to - setting *ppfcb to zero before +calling p_open can simplify clean-up code since p_close(0) has no effect and p_close can subsequently +be called regardless of whether the open call was successful. + + +If device name is an attached device, the driver control block is attached to *ppfcb - the value in *ppfcb is +not changed. + + +9-4 + + +9 VO SYSTEM + + +Returns zero if successful or a negative error number if it failed. As well as device specific errors (as +described in the description of each device) the following error numbers may be returned: + + +E_FILE_ALLOC failed to allocate memory for the control block +E_FILE_DEVICE the device does not exist +E_GEN_ARG the value of the mode parameter was invalid (possibly as a result of falling + + +through to the rr: device, as described next) + + +The function £_open is identical to p_open except that it calls p_leave (passing the error number) rather +than return a negative error number. + + +If p_open fails to locate a device that matches name, then name is passed to the r1L: device driver (in +which case the process must be connected to the file server). To put it another way, the leading FrL: +device name is optional when opening files and, for example, calling p_open with a name of + +"LOC: :A:\DEF.EXT" is equivalent to a name Of "FIL: LOC: :A:\DEF.EXT" (the FIL: device is described in +more detail in the Files chapter). + + +This behaviour has an undesirable side effect: an attempt to open a device that does not exist does not give +the expected &_FILE_DEVICE error since name is passed on to the Fru: device with a result that depends +upon mode (with some values of mode the open might even be successful). Passing a mode of -1 is +guaranteed to cause the Fru: device driver open to fail - albeit with a misleading error number +(&_GEN_ARG). + + +p_ioa Start an I/O operation + + +INT p_ioa(VOID *pcb, INT func, WORD *pstat, ...); + +INT p_ioa3(VOID *pcb, INT func, WORD *pstat); + +INT p_ioa4(VOID *pcb, INT func, WORD *pstat, VOID *al); + +INT p_ioa5(VOID *pcb, INT func, WORD *pstat, VOID *al, VOID *a2); + + +Start the I/O operation func with zero, one or two parameters on the opened channel pcb and return +without waiting for the operation to complete. + + +You can either use p_ioa, which presents the cpzct calling convention, or one of the p_ioa? variants, +which uses a more efficient register calling convention. + + +Note that it is almost always preferable to use p_ioc in preference to p_ioa. + + +The legitimate values of func depends upon the device. The number of function parameters (zero to two) +and the interpretation of the function parameters (if any) depends on the function and the device. If a +function parameter exists, it is normally an address that may be used as input, output or both input and +output. + + +The function returns zero if the I/O request was started successfully or a negative error number. Returns +E_FILE_INv if func is not valid for this device. Other device specific errors may be returned. + + +When the successfully started operation completes, the process I/O semaphore is signalled and *pstat +contains the completion status. While the operation is pending (ie before the I/O semaphore has been +signalled), *pstat contains E_FILE_PENDING. Asynchronous requests in general are described in the +chapter Asynchronous Requests and Semaphores. + + +After the operation has completed, *pstat contains zero if the operation completed successfully or a +negative error number if the operation completed with an error. The possible error numbers depend upon +the device but any asynchronous operation that is successfully cancelled completes with *pstat containing +E_FILE_CANCEL. + + +Drivers normally only support one pending request per I/O operation per channel. For example, on the +TTy: (serial port) device you must wait for an asynchronous write request to complete before you can make +another write request on the same channel (the driver will call p_panic if this is attempted). However, it is +legitimate to have one read request and one write request simultaneously pending. + + +9-5 + + +PLIB REFERENCE + + +The storage pointed to by pstat must be retained for the duration of the operation. A common error, +which has disastrous results, is to allocate the status word on the stack and then to return from the +function before the operation has completed - as in the following example: + + +GLDEF_C INT DisastrousWrite(VOID *pcb, TEXT *buf) +{ +WORD stat; +UWORD len; + + +len=p_slen (buf) ; +return (p_ioa(pcb, P_FWRITE, &stat,buf, &len) ); +} + + +The following generic I/O functions (where a1 and a2 are further parameters to p_ioa) are commonly +(but not always) implemented asynchronously by device drivers: + + +P_FREAD request a read operation where a1 is the address of the buffer to take the data +and a2 is the address of a worp length to read (or the maximum length to read if +the device is record oriented). When the read completes, *pstat contains zero +if the read was successful or a negative error number if the read failed and «a2 +contains the number of bytes written to a1. + + +P_FWRITE request a write operation where a1 is the address of the data to write and a2 is +the address of a worp length to write. When the write completes, *pstat +contains zero if the write was successful or a negative error number if the write + + +failed. +p_ioc Start an I/O operation with guaranteed completion +VOID p_ioc(VOID *pcb, INT func, WORD *pstat, ...); + + +VOID p_ioc3(VOID *pcb, INT func, WORD *pstat); +VOID p_ioc4(VOID *pcb, INT func, WORD *pstat, VOID *al); +VOID p_ioc5(VOID *pcb, INT func, WORD *pstat, VOID *al, VOID *a2); + + +Behaves as for p_ioa except that if the I/O request func fails to start, the failure is reported as if it had +started successfully but completed with that error. + + +You can either use p_ioc, which presents the cbEct calling convention, or one of the p_ioc? variants, +which uses a more efficient register calling convention. + + +The implementation of p_ioc is effectively as follows: + + +GLDEF_C VOID p_ioc(VOID *pcb, INT func,WORD *pstat,VOID *al,VOID *a2) +{ +INT ret; + + +if (ret=p_ioa(pcb, func, pstat,al,a2) ) +{ +*pstat=ret; +p_iosignal(); +} +} + + +In most cases, p_ioc is preferred to p_ioa because there is only one place (*pstat) to check for an error +rather than two (the return from p_ioa and *pstat). It is rarely necessary to differentiate between a failure +to start the I/O operation and a failure in its completion. + + +In the following example, WriteTimeout writes the len bytes at buf to channel pcb and returns as for +p_write. However, if the write does not complete within secs seconds, the write operation is cancelled +and £_FILE_CANCEL is returned. + + +For simplicity, it assumes that completion of the write or expiry of the timer are the only two events that +are expected to cause a return from the call to p_iowait. This will be true if there is no other +asynchronous activity. + + +9-6 + + +LOCAL_C INT WriteTimeout (VOID *pcb, UBYTE *buf, UWORD len, + + +{ + +WORD tstat; +WORD wstat; +ULONG tval; + + +p_ioc (pcb, P_FWRITE, &wstat, buf, &len) ; +tval=10L*secs; +p_ioc(tcb,P_FRELATIVE, étstat, &tval) ; +p_iowait (); + +if (tstat!=E_FILE_PENDING) + +/* the timer expired */ +p_iow(pcb,P_FCANCEL); /* cancel write */ +p_waitstat (&wstat); + + +else if (wstat!=E_FILE_PENDING) + +/* the write completed */ +p_iow(tcb,P_FCANCEL); /* cancel timer */ +p_waitstat (&tstat); + + +else +p_panic(254); /* unexpected, unrecognised signal */ +return (wstat) ; + + +} + + +UINT secs) + + +9 VO SYSTEM + + +The call to p_iowait returns when either request completes. If the timer has completed, the write request +is cancelled. Otherwise, the timer request is cancelled. If both requests have completed by the time +p_iowait returns (quite possible if a higher priority process "hogged" the CPU), the cancel of the write +request will have no effect and wstat will contain the completion code of the write. + + +In the example, the static variable tcb is the channel of a previously opened asynchronous timer, as in: + + +p_open (&tcb, "TIM:",-1); + + +The following version of writeTimeout is more general, and caters for the presence of other asynchronous + + +activity. + + +LOCAL_C INT WriteTimeout (VOID *pcb, UBYTE *buf, UWORD len, + + +{ + +WORD tstat; +WORD wstat; +WORD count; +ULONG tval; + + +p_ioc (pcb, P_FWRITE, &wstat, buf, &len) ; +tval=10L*secs; +p_ioc(tcb, P_FRELATIVE, étstat, &tval) ; +count=0; +FOREVER +{ +p_iowait (); +if (tstat!=E_FILE_PENDING) +{ /* the timer expired */ +p_iow(pcb,P_FCANCEL); /* cancel write */ +p_waitstat (&wstat); +break; +} +else if (wstat!=E_FILE_PENDING) +{ /* the write completed */ +p_iow(tcb,P_FCANCEL); /* cancel timer */ +p_waitstat (&tstat); +break; +} +else +count+=1; /* count unrecognised signals */ +} +while (count--) +p_iosignal(); /* replace unrecognised signals */ +return (wstat) ; + + +} + + +UINT secs) + + +PLIB REFERENCE + + +In such a situation, with other asynchronous activity, it may be better to handle the expiry of the timer in +the main p_iowait loop. The wait for the write to complete could then be handled by: + + +p_waitstat (&wstat) ; +p_iow(tcb,P_FCANCEL); /* cancel timer */ +p_waitstat (&tstat); + + +p_iow Start an I/O operation and wait for completion + + +INT p_iow(VOID *pcb, INT func, ...); + +INT p_iow2(VOID *pcb, INT func); + +INT p_iow3(VOID *pcb, INT func, VOID *al); + +INT p_iow4(VOID *pcb, INT func, VOID *al, VOID *a2); + + +Behaves as for p_ioa except that it waits for operation func to complete and returns the completion status, +providing a synchronous (as opposed to an asynchronous) interface. + + +You can either use p_iow, which presents the cbEct calling convention, or one of the p_iow? variants, +which uses a more efficient register calling convention. + + +The code for p_iow is effectively: + + +GLDEF_C INT p_iow(VOID *pcb, INT func,VOID *al,VOID *a2) +{ +WORD stat; +INT ret; + + +if (!(ret=p_ioa (pcb, func, &stat,al,a2))) +{ +p_waitstat (&stat); +ret=stat; +} +return (ret); + + +} + + +Calling p_iow is simpler and requires one less parameter (since the status word is returned) than p_ioa or +p_ioc and should be used in preference to p_ioa or p_ioc unless there is a need for an asynchronous +request. + + +The following generic I/O functions are essentially synchronous and are normally requested using p_iow: + + +P_FCANCEL to cancel outstanding requests on a channel + +P_FSENSE to sense channel characteristics + +P_FSET to set channel characteristics + +P_FFLUSH to flush out data held in buffers + +p_close Close an I/O channel + + +INT p_close(VOID *pcb); +Close I/O channel pcb and return zero if successful. If pcb is NULL, just return zero. +The code for p_close is effectively: + + +GLDEF_C INT p_close(VOID *pcb) +{ +if (!pcb) +return (0); +return (p_iow(pcb, P_FCLOSE) ) ; +} + + +Although p_close can return an error, it will always succeed in closing the channel (and pcb should not +be used subsequently). + + +If the device buffers written data, the close operation may need to perform one or more write operations on +closing, in which case P_FCLOSE can return similar errors to P_FWRITE. However, the failure to flush the +data will not (assuming a competently written device driver) cause the close operation to be aborted +although the failure to flush will be reported. + + +Carefully written applications avoid this problem by using p_FFr1uss to flush the data (and taking +appropriate action if this fails) before closing the channel without risk of failure. + + +9-8 + + +9 1/0 SYSTEM + + +p_read (or f_read); Read from an I/O channel + + +INT p_read(VOID *pcb, VOID *buf, UINT len); +INT f_read(VOID *pcb, VOID *buf, UINT len); + + +Request a P_FREAD Of up to 1en bytes of data into bur from channel pcb, wait for the request to complete +and, if successful, return the number of bytes written to buf or a negative error number if the read failed. + + +The code for p_read is effectively: + + +GLDEF_C INT p_read(VOID *pcb, UBYTE *buf, UINT len) + + +{ +INT ret; +UWORD 1; + + +l=len; +ret=p_iow (pcb, P_FREAD, buf, &1); +if (!ret) + +ret=1; +return (ret); + + +} + + +The function £_read is identical to p_read except that, if there is an error, it calls p_leave (err) rather +than return the negative error number err. + + +p_write (or f_write); Write to an I/O channel + + +INT p_write(VOID *pcb, VOID *buf, UINT len); +INT f_write(VOID *pcb, VOID *buf, UINT len); + + +Request a P_FWRITE Of len bytes of data from buf to channel pcb, wait for the request to complete and, if +successful, return zero or a negative error number if the write failed. + + +The code for p_write is effectively: + + +GLDEF_C INT p_write(VOID *pcb, UBYTE *buf, UINT len) + + +{ +UWORD 1; + + +l=len; +return (p_iow(pcb, P_FWRITE, buf, &1)); +} + + +The function £_write is identical to p_write except that, if there is an error, it calls p_leave (err) rather +than return the negative error number err. + + +p_iow(P_FCANCEL) Cancel requests on an I/O channel + + +INT p_iow(VOID *pcb, P_FCANCEL) ; + + +Cancel any outstanding asynchronous requests on channel pcb and return zero. Harmless if there are no +pending requests. + + +Device drivers that support truly asynchronous services provide a cancel service. The detailed effect of +the cancel depends upon the device driver. However, the following general principles apply: + + +e the cancel precipitates the completion of the request (it does not stop the request from +completing) + + +e the cancel may or not be effective (that is, the request may complete naturally before the cancel is +processed) + + +e after a cancel, you must still process the completion of the asynchronous request (typically by +immediately calling p_waitstat to "use up" the signal) + + +The above principles actually apply to cancelling any asynchronous request (not just an asynchronous I/O +request). + + +Although legitimate, using p_ioa(P_FCANCEL) Of p_ioc(P_FCANCEL) (rather than p_iow(P_FCANCEL) ) is +somewhat perverse since you then have two signals to use up - one for the request being cancelled and one +for the cancel itself. + + +9-9 + + +PLIB REFERENCE + + +Device driver functions + + +p_loadidd Load a logical device driver +INT p_loadldd(TEXT *pName) ; + + +Load the logical device driver (LDD) from the zero terminated file name pName. If pName contains no +extension an extension of .LDD is assumed (an LDD file would normally have the extension .LDD). If +pName is not a full path name the current path is assumed. + + +Returns zero if successful or one of the following negative error numbers: + + +E_FILE_EXIST an LDD of the same file name has already been loaded +E_FILE_NXIST the LDD file does not exist + +E_FILE_DEVICE the supplied file name is that of a PDD + +E_GEN_IMAGE the LDD file does not have the correct format or has been corrupted +E_GEN_NOMEMORY Not enough memory to satisfy the request + +E_GEN_NOSEGMENTS No memory segment handles are available + + +After the LDD has been loaded, a channel may be opened to it by calling p_open. + + +Applications that rely on an external LDD should use p_1oadidd and not care if it fails with +E_FILE_EXIST. + + +p_loadpdd Load a physical device driver +INT p_loadpdd(TEXT *pName) ; + + +Load the physical device driver (PDD) from the zero terminated file name pName. If pName contains no +extension an extension of .PDD is assumed (an PDD file would normally have the extension .PDD). If +pName is not a full path name the current path is assumed. + + +Returns zero if successful or any of the same negative error numbers as for p_1oadidd above except that, +in this case, the error E_FILE_DEVICE is returned if the specified file name is that of an LDD. + + +p_devdel Delete a device driver +INT p_devdel (TEXT *pName, INT devType) ; + + +Delete the logical (devType is E_LDD) or physical (devType is E_PDD) device driver with the zero +terminated device name pName (as used in p_open but without a trailing ':'). + + +Only device drivers that have been loaded into RAM (and not those devices that are built into the ROM) +can be deleted by this service. + + +Returns zero if successful or one of the following negative error numbers: + + +E_FILE_DEVICE The device driver is not currently loaded. + +E_GEN_NSUP The device driver is a ROM device driver and cannot be deleted. +E_GEN_INUSE The device driver is currently open and cannot be deleted. + +A device dependent Returned by the device driver code. + + +error number + + +If you have loaded an external device driver and finished with it, it is good practice to attempt to delete it +by calling p_devdel and to ignore the return value. The call is harmless if the device is loaded by another +process or if the device is built into the ROM. + + +WARNING: If pname points to a null string, the first located unloadable device driver of the type specified +by devType will be deleted. + + +9-10 + + +9 1/0 SYSTEM + + +p_devqu Query the number of units supported by a device + + +INT p_devqu (TEXT *pName) ; + + +Returns the number of units supported by logical device driver with the zero terminated device name +pName (as used in p_open but without a trailing ':'). The function is not applicable to PDDs. + + +Returns a positive number if successful or one of the following negative error numbers: + + +E_GEN_FAIL Unlimited units (as returned by the r1L: device driver as it can support a large +number of files). + + +E_FILE_DEVICE Device driver not found. +For example: +p_devqu ("TTY"); + + +returns 2 if there are two serial expansion boards fitted. + + +p_devfnd Find all devices + + +HANDLE p_devfnd(HANDLE fHandle, TEXT *pMatch, INT devType, TEXT *pName) ; + + +Write the next device name (as used in p_open but without a trailing ':') of type devType (either z_ppp to +find PDD devices or z_upp to find LDD devices) that matches the zero terminated match string pMatch as +a zero terminated string to pName where fHand1e is zero for the first call and is subsequently the positive +return value from the previous call. When there are no further devices of type devType that match pmatch, +p_devfnd returns E_FILE_DEVICE. + + +Used repeatedly to find all the PDD or LDD devices that match the wild card string pointed to by pmatch. +The buffer at pName should be big enough to receive &_max_NamE+2 bytes. The wild card string pMatch +should remain the same between successive calls. + + +No memory is used by this service and it can be abandoned at any time without taking any further action. +Calls p_panic if fHandle is invalid. +Example + + +LOCAL_C VOID PrintDevices (VOID) +{ +HANDLE fh; +TEXT bb[E_MAX_NAME+2]; + + +fh=0; +FOREVER +{ +fh=p_devfnd(fh,"*",E_LDD, &bb[0]); +if (fh<0) +break; +p_puts (&bb[0]); +} + + +Simple console I/O + + +The simple console functions are provided for "quick and dirty" applications - for example test programs +and software tools. They are not suitable for constructing quality user interfaces. + + +The console functions use the services of the con: device driver to implement the following screen output +and keyboard input functions: + + +p_putch to write a character to the screen +p_puts to write a line of text to the screen and move to the beginning of the next line +p_printf£ to convert numbers to printable form and write them as a line of text to the + + +screen and then move to the beginning of the next line + + +p_print to convert numbers to printable form and write them to the screen + + +9-11 + + +PLIB REFERENCE + + +p_getch to get (without echo) a single character from the keyboard + +p_gets to input (with simple backspace editing) a line of text from the keyboard + +p_getl to display a prompt and then input (with simple backspace editing) text from +the keyboard + + +Redirecting console writes + + +These functions automatically open con: when they are first used. The open channel is stored in the +global static: + + +GLREF_D VOID *winHandle; + + +which is initialised to nuLL. You can open a suitable alternative device (eg a file or Try: ) before the first +usage of a console function to redirect the output functions p_putch, p_print and p_printf. For +example, to redirect to the file a.Jis in the current path, use: + + +p_open (&winHandle, "a.lis",P_FREPLACE |P_FUPDATE) ; +Note that if you do redirect the console to such a device, you should not use p_getch, p_gets or p_getl. +Changing the size of the console window + + +If you want to change the size of the console window, you can do this by declaring the global P_REcT +structure _DefScreenRect and initialising it to the required size before the first usage of a console +function. The P_REcT struct is defined in p_graf-h as: + + +typedef struct +{ +WORD x; /* Horizontal coordinate */ +WORD y; /* Vertical coordinate */ +} P_POINT;. + + +typedef struct +{ +P_POINT tl; /* Top left point */ +P_POINT br; /* Bottom right point */ +} P_RECT;. + + +where the top left coordinates should be (0,0) and the bottom right coordinates should reflect the required +dimensions in character columns and rows as in, for example: + + +GLDEF_D P_RECT _DefScreenRect={{0,0},{10,20}}; +for 10 columns by 20 rows, or: + + +GLDEF_D P_RECT _DefScreenRect; + + +_DefScreenRect.t1l.x=0; +_DefScreenRect.tl.y=0; +_DefScreenRect.br.x=columns; +_DefScreenRect.br.y=rows; + + +Changing the console window mode + + +By default the console starts up in the native mode of the machine. At the time of writing, all SIBO +machines default to single pixel (non-compatibility) mode, with no access to grey. If you want to change +the mode, you can do this by declaring the global variable _DefscreenMode and initialising it to the +required value before the first usage of a console function. The possible modes are: + + +use the native mode of the machine - this is the default value +compatibility mode, allowing Series 3 software to run on the Series 3a +non-compatibility mode, with grey enabled + +compatibility mode, but with grey enabled + + +WN FO + + +Thus, compatibility mode may be set on the Series 3a as follows: + + +GLDEF_D INT _DefScreenMode; + + +_DefScreenMode=1; + + +Values that are not relevant to a particular type of machine are simply ignored. + + +9-12 + + +9 1/0 SYSTEM + + +p_putch Write a character to the console + + +VOID p_putch(UINT c); + + +Write character c to the console, opening the console if necessary. + + +p_puts Write a string to the console + + +VOID p_puts(TEXT *str); + + +Write the zero terminated string str to the console and start a new line. The console is opened if +necessary. + + +p_printf Convert arguments and write line to console + + +VOID p-printé#(TEAT *fstry +44 )¥ + + +Converts multiple arguments to an internal buffer under control of the format string fstr, writes the +complete string to the console screen and then moves the print position to the beginning of the next line. +The console is opened if necessary. + + +The internal buffer is p_maxsysto (258) bytes long and the length of the output (which depends on the +arguments) must be limited to p_maxsys1o-2 (256) bytes per call of p_print£. + + +The format of ¢str is exactly the same as for p_atob, which is described in the chapter Integer +Conversion and Rectangle functions. + + +p_print Convert arguments and write to console + + +VOID p_print (TEXT *fstr, ...); + + +Behaves as for p_printf above except that the print position is not automatically moved to the beginning +of the next line after the write. + + +You can embed \r and \n characters in fstr to move to the beginning of the line and to move down a line +respectively. + + +p_getch Get a character from the console + + +INT p_getch(VOID); + + +Wait for a key to be pressed and return its character code. The console is opened if necessary. + + +p_gets Get a string from the console + + +INT p_gets(TEXT *str); + + +Input (with simple backspace editing) a line of up to p_maxsys1o-1 characters from the keyboard, creating +a zero terminated string at str. The input is terminated by the user pressing the Enter key. + + +Returns the length of the string at str. + + +There should be at least p_maxsyszio bytes at str. The console is opened if necessary. + + +p_getl Get a string with prompt from the console + + +INT p_get1l(TEXT *pmt, TEXT *str, INT len); + + +Write the zero terminated string pmt to the console and input (with simple backspace editing) up to 1en +characters from the keyboard, creating a zero terminated string at str. The input is terminated by the user +pressing the Enter key. + + +Returns the length of the string at str. + + +There should be at least 1en+1 bytes at str. The console is opened if necessary. + + +CHAPTER 10 + + +TIME, TIMERS AND DATES + + +System time + + +The system time is set and sensed as a ULONG, counting the number of seconds since 00:00:00, January 1, +1970 (compatible with UNIX system time). + + +The system time overflows approximately 136 years after 1970 (which is sometime in the year 2106). + + +p_date Return the system time +ULONG p_date (VOID) + + +Return the system time as the number of seconds since 00:00:00, January 1, 1970. + + +p_sdate Set the system time +VOID p_sdate(ULONG newTime) ; +Set the system time to newTime (the number of seconds since 00:00:00, January 1, 1970). + + +Note that setting the system time forward by an interval will cause any absolute timers due in that interval +to expire. + + +Absolute and relative timers + + +In the EPOC operating system a process can be waiting on a timer in two ways: +e The process is in the time delta queue as a result of calling p_sleep, p_sleept Of p_sleepa. + + +e The process is waiting for its I/O semaphore to be signalled by a timer device entry in the time +delta queue after making an asynchronous timer request by calling p_ioc(P_FRELATIVE) or +p_ioc(P_FABSOLUTE) on an open timer channel. + + +Each entry in the time delta queue contains the signed long delta time in system ticks relative to its +predecessor while the head of the queue contains the delta time relative the current system time (for more +on delta queues see the chapter Characters, Strings, Buffers and Queues). The head of the time delta +queue is decremented every system tick and the corresponding timer expires (and is removed from the +queue) when its delta time is zero or negative. If the entry is a process, the process will either run (if it has +the highest priority) or it will wait in the ready queue. If the entry is a timer device entry, the associated +process I/O semaphore is signalled. See the chapter Asynchronous Requests and Semaphores for +information on the I/O semaphore, asynchronous requests and the ready queue. + + +As well as being marked as processes or timer device entries, entries in the time delta queue are also +marked as being absolute or relative. + + +PLIB REFERENCE + + +Absolute timers + + +An absolute timer is characterised by the following: + + +e the timer expiry is set in terms of an absolute time (the number of seconds since 00:00:00, +January 1, 1970) + + +e SIBO machines (as opposed to a PC running EPOC) that have switched off will automatically +switch on when an absolute timer is due to expire + + +e setting the system time forward by an interval will cause any absolute timers due in that interval +to expire + + +Absolute timers are used to implement, for example, alarms for the Diary and Alarms applications on the +MC GI machines. You can set absolute timers to expire after a relative time interval (expressed in +seconds) by adding the required interval to the time returned by p_date. + + +Although absolute timers are converted to relative signed long delta time in the time delta queue, absolute +timer entries can re-launch themselves to cover ranges in excess of 0x7£ffffFfF ticks. + + +Relative timers +A relative timer is characterised by the following: + + +e the timer expiry is set as a time interval relative to the current system time (either as a number of +1/10ths of a second or as a number of system ticks) + + +e the timer stops running while SIBO machines are switched off and it follows that relative timers +do not wake up the operating system up + + +e changing the system time has no effect on relative timers + + +If a relative timer is set to expire after 5 seconds when the system time is advanced by | hour the timer +still expires after 5 seconds (provided the machine is not switched off). + + +If a relative timer is due to expire in 5 seconds when the machine switches off for | hour, the relative +timer actually expires after 1 hour plus 5 seconds. + + +SIBO machines are normally configured to switch off automatically after a period of inactivity (typically +5 minutes). A process that repeatedly waits on a relative timer with an interval shorter than the switch off +inactivity period (for example to implement a clock or a flashing cursor) would by default stop the +machine from ever switching off. Keeping a battery powered machine on indefinitely is normally +undesirable and, in this situation, the application should call p_unmarka (described in the chapter +Processes and Inter-Process Messaging) to stop such activity from keeping the machine on. + + +Relative timers are ultimately converted to system ticks in a signed long - giving them a range of +Ox7f£f£ffFFE ticks, or approximately 2.1 years, on a SIBO machine (which ticks 32 times a second). + + +p_sleep Suspend process for n tenths of a second +INT p_sleep(ULONG n); +Return zero after n 1/10ths of a second has elapsed. + + +Returns E_GEN_OVER immediately if the conversion from 1/10ths to ticks overflows (ie the number of ticks +is greater than 0x7fffffff). + + +This function uses a relative timer. If the machine switches off before the function returns, it will take +indefinitely longer than n tenths of a second to return. + + +p_sleept Suspend process for n system ticks +INT p_sleept (LONG nTicks) ; +Returns zero after ntTicks system ticks if successful or E_GEN_aRc if nTicks is negative. + + +On the SIBO hardware the system ticks 32 times a second. On IBM PCs and compatibles the system ticks +18.2 times a second. The constant E_TICKS_PER_SECOND in epoc.h contains the number of ticks per +second, to the nearest integer. + + +10-2 + + +10 TIME, TIMERS AND DATES + + +A request to sleep for zero ticks is valid and will just force a re-schedule, with the process calling this +service losing the remainder of its time slice if there are other processes at the same priority. + + +This function uses a relative timer. If the machine switches off while the process is suspended, it will take +indefinitely longer than nticks system ticks to return. In the absence of any switching off, the actual time +the process is suspended is greater than or equal to nticks and less than nTicks+1. + + +p_sleepa Suspend process until absolute time + + +INT p_sleepa(ULONG time) ; + + +Return when the system time is time (the number of seconds since 00:00:00, January 1, 1970). Returns +zero 1f successful or E_GEN_aRG if time is earlier than the current system time. + + +This uses an absolute timer which will wake the machine up if necessary when the timer expires. Another +process setting the system time past the expiry time (using p_sdate) will cause p_sleepa to return. + + +eee eee ——————EEEEEEEEeeeEeEeeseeee— +Asynchronous timers + + +The functions p_sleepa, p_sleep and p_sleept are synchronous functions in the sense that they return +only when the requested operation (in this case the expiry of a timer) has completed. With asynchronous +timers, the function call to start the timer returns immediately. This allows other processing to take place +before waiting for any one of a number of events (including the expiry of the timer) by calling p_iowait. +See the chapter Asynchronous Requests and Semaphores for an explanation of asynchronous requests in +general. + + +In EPOC, asynchronous timers are implemented as an I/O device with the device name "TIM:". To use an +asynchronous timer, you open a channel to "TIM:" and use: + + +p_ioc (P_FRELATIVE) to start a relative timer +p_ioc (P_FABSOLUTE) to start an absolute timer +p_iow (P_FCANCEL) to cancel a timer +p_close to close a timer channel + + +The constants p_FRELATIVE, P_FABSOLUTE and p_FcaANCcEL are defined in p_file.h. See the chapter //O +System for a description of the I/O system in general. + + +If you want to run multiple timers in parallel, you open a channel for each timer needed. + + +Although you can open a timer channel and use p_iow(P_FRELATIVE) Of p_iow(P_FABSOLUTE) (rather +than p_ioc) to the same effect as p_sleep Or p_sleepa respectively, the latter should be preferred for their +simplicity and efficiency. + + +p_open(“TIM:”) Open a timer channel + + +INT p_open(VOID **pptcb,TIM:,-1); + + +Open a timer channel and write the address of the timer control block to *ppt cb. Returns zero if +successful or the negative error number &_cEN_Nomemory if, for example, it failed to allocate memory for +the control block. + + +p_ioc(P_FRELATIVE) Start a relative timer + + +VOID p_ioc(VOID *ptcb, P_FRELATIVE, WORD *pstat, ULONG *pn); +Start a relative timer to expire after *pn tenths of a second. +Calls p_panic if a timer is already pending on channel ptcb. + + +While the timer is pending, *pstat contains E_FILE_PENDING. When the timer expires successfully, +*pstat is set to zero and the I/O semaphore is signalled. + + +The timer is not started and *pstat is set to E_GEN_OVER if the conversion from tenths of a second to ticks +overflows (ie the number of ticks is greater than ox7£f£ffFfF). + + +10-3 + + +PLIB REFERENCE + + +p_ioc(P_FABSOLUTE) Start an absolute timer + + +VOID p_ioc(VOID *ptcb, P_FABSOLUTE, WORD *pstat, ULONG *ptime) ; + + +Start an absolute timer to expire when the system time is *pt ime (the number of seconds since 00:00:00, +January 1, 1970). + + +Calls p_panic if a timer is already pending on channel pt cb. + + +While the timer is pending, *pstat contains E_FILE_PENDING. When the timer successfully expires, +*pstat is set to zero and the I/O semaphore is signalled. + + +The timer is not started and *pstat is set to E_GEN_aRG if *ptime is earlier than the current system time. + + +p_iow(P_FCANCEL) Cancel a timer + + +INT p_iow(VOID *ptcb, P_FCANCEL) ; +Cancel a timer on channel ptcb and return zero. + + +The operation is harmless if no timer is pending. This is important because there is always a chance that a +timer will expire before the cancel gets to it. If the cancel does get to the timer before it expires, the I/O +semaphore is still signalled but *pstat is set to E_FILE_CANCEL rather than zero. However, when +cancelling a timer, you don't normally care how the timer actually completed. It is common to call +p_waitstat immediately after the cancel to "use up" the signal. + + +To reset a timer, you first cancel the timer using p_iow(P_FCANCEL) followed by a call to p_waitstat and +then call p_ioc (P_FRELATIVE) to start the timer again. + + +p_close Close a timer channel +INT p_close(VOID *ptcb); +Close the timer channel ptcb and return zero. + + +You should close a timer channel when you no longer need it. + + +Converting between binary representations of time + + +The system time format sacrifices range to obtain high compression and is the most convenient and +efficient representation for adding and subtracting small time intervals such as seconds, minutes, hours +and days. + + +There are 86,400 seconds in a day (P_NseEcpay is defined as 86400L in p_date.h). +There are three different binary representations for time in PLIB: +e The number of seconds since 00:00:00, January 1, 1970 (system time format) +e Days since January 1, 1900 and seconds in day +e (Year since 1900,Month,Day) and (Hour, Minute,Second) + + +Note that the first representation works from a base year of 1970 while the second two representations +work from a base year of 1900. + + +PLIB contains conversion routines that convert both ways between adjacent representations in the above +list. By combining conversion functions, you can convert between the first and third representation. + + +The second format measures the days since January | 1900 (day=0 for Jan 1) and the seconds since +00:00:00 and is stored in a p_payszc struct, defined in p_date.h as follows: + + +typedef struct +{ +ULONG day; /* day number since Jan 1 1900 */ +ULONG sec; /* seconds in day, 0 to 86399 */ +} P_DAYSEC;. + + +10-4 + + +10 TIME, TIMERS AND DATES + + +The day number is useful for date calculations not involving time. Examples are to count the number of +days between two dates, or to calculate a new date from a base date and a number of days (positive or +negative). + + +The third format is closest to a human understandable representation of the date and time and is defined +by the p_pate struct in p_date.h: + + +typedef struct +{ +UBYTE year; /* Year since 1900 (0 is 1900) */ +UBYTE month; /* Month number in year, 0 to 11 */ +UBYTE day; /* Day number in month, 0 to 30 */ +UBYTE hour; /* Hour in day, 0 to 23 */ + +UBYTE minute; /* Minute in hour, 0 to 59 */ + +UBYTE second; /* Second in minute, 0 to 59 */ +UWORD yrday; /* Day in year */ + +} P_DATE;. + + +The last member, yrday is a function of year, month and day. It is provided when p_parte is generated +from p_pays«c but is ignored when converting from P_paTE. + + +p_sttods Convert system time to P_DAYSEC time + + +VOID p_sttods(ULONG *pstim, P_DAYSEC *pds) + + +Convert *pstim from system time format (the number of seconds since 00:00:00, January 1, 1970) to the +number of days since 1900 and the number of seconds in the day, both being written to pas. + + +p_dstost Convert P_DAYSEC time to system time + + +INT p_dstost (P_DAYSEC *pds, ULONG *pstim) ; + + +Convert pds from the number of days since 1900 and the number of seconds in the day to system time +format (the number of seconds since 00:00:00, January 1, 1970). The result is written to *pstim. + + +Returns zero if successful, or one of the following negative error numbers: + + +E_GEN_OVER date in pds is too late for system time +E_GEN_UNDER date in pds is too early for system time (ie before 1970) +E_GEN_ARG seconds is greater than seconds in day + + +p_dstodt Convert P_DAYSEC time to P_DATE time + + +INT p_dstodt (P_DAYSEC *pds, P_DATE *pdt); + + +Convert p_paysec time pds (days since 1900, seconds in day) to p_paTE time pdt (year, month, day, +hour, minute, second and day in year) and return zero if successful or one of the following negative error +numbers: + + +E_GEN_OVER the year is greater than 255 (year 2155) +E_GEN_ARG seconds is greater than seconds in day + + +As well as the date and time, this function calculates pdt->yrday (the day number of the year, where day +zero 1s January 1). Although you could calculate this yourself from the year, month and day it is not a +simple calculation since it involves adding the number of days in preceding months and thus depends on +leap years. + + +This function actually performs two independent calculations: +¢ converting the number of days since 1900 to year, month, day and day in year (date calculation) + + +¢ converting the number of seconds since 00:00:00 to hours, minutes and seconds (time of day +calculation) + + +Both calculations may be abandoned if either calculation fails. If you are only interested in one of the +calculations, set the other member of p_paysEc to zero (which is a legal input for both calculations). + + +10-5 + + +PLIB REFERENCE + + +p_dttods Convert P_DATE time to P_DAYSEC time + + +INT p_dttods(P_DATE *pdt, P_DAYSEC *pds); + + +Validate the p_DaTE format pdt and convert it to the p_payszEc format pds and return zero if successful or +the negative E_GEN_arc if the content of pdt is invalid (ie no such date or time exists). The value of +pdt->yrday is ignored. + + +The validation can fail for one or more of the following reasons: +@ pdt ->month is outside the range 0 to 11 + + +¢ pdt ->day is outside the range for the particular month taking into account leap years for +February + + +@ pdt ->hour is outside the range 0 to 23 +@ pdt->minute is outside the range 0 to 59 +@ pdt->second is outside the range 0 to 59 +This function actually performs two independent calculations: +e converting the year, month and day to the number of days since January 1 1900 (date calculation) + + +e converting the hours, minutes and seconds to the number of seconds since 00:00:00 (time of day +calculation) + + +Both calculations may be abandoned if either calculation fails. If you are only interested in one of the +calculations, set the members of P_DATE corresponding to the other calculation to zero (zero is a legal +input for all members in both calculations). + + +p_dayinm Find the number of days in the specified month +INT p_dayinm(INT year, INT month); + + +Return the number of days in month month of year year where year is the number of years since 1900 +(zero is 1900) and month is 0 to 11 inclusive. (Returns the negative E_GEN_aRc if month is greater than 11.) + + +The year is required because it affects the number of days in February. This may be used to test for a leap +year, for example: + + +if (p_dayinm(year,1)==29) + + +p_wkday Convert day since 1900 to day in week +INT p_wkday(ULONG nDay) ; + + +Returns the week day number given the number of days nDay since January 1 1900. The value returned is +in the range 0 to 6, with 0 being Monday and 6 being Sunday. + + +The day number since 1900 would normally come from a structuresP_DAYSECc struct. + + +p_weekno Calculate week number in year + + +INT p_weekno(ULONG nDay) ; + + +Return the week number, in the range | to 53 inclusive, of the week containing day nDay (the number of +days since January 1 1900). Returns zero if successful or E_GEN_aRG if nDay exceeds the year 2155. + + +The value returned is dependent on the value of the system structuresE_conrte structure field +startOfWeek (see p_getctd in this chapter). + + +10-6 + + +10 TIME, TIMERS AND DATES + + +Time and date components in text form + + +The functions in this section get a range of date and time components in text form. They constitute a +more primitive set of functions than those, described in the following section, that generate strings +containing full date and/or time representations. + + +These functions are based on language-dependent information that is built into the ROM. If you use these +functions, your code should automatically work on, for example, English, French and German machines. + + +The functions are: + + +p_nmday to get the day names (eg Monday, Tuesday) + +p_nmmon to get the month names (eg January, February) + +p_nmdaya to get the day name abbreviations (eg Mon, Tue) + +p_nmmona to get the month name abbreviations (eg Jan, Feb) + +p_getsuffixes to get the 31 day in month number suffixes (eg st, nd) + +p_getampmtext to get the am and pm suffixes + +p_getctd to get a copy of the setable country-dependent data and time preferences (such + + +as whether to use a 12 or 24 hour clock) +The following example displays the system time in the form: +Monday, 11th April 1988 11:03 +and uses many of the functions described in this chapter. + + +#include + + +GLDEF_C VOID PrintDateTime() +{ +ULONG st; +P_DAYSEC ds; +P_DATE dt; +E_CONFIG cfg; +TEXT DayName [32]; +TEXT MonthName [32]; +TEXT Suffix[31] [3]; + + +st=p_date(); +p_sttods (&st, &ds) ; +p_dstodt (&ds, &dt) ; +p_nmday (&DayName[0],p_wkday (ds.day) ); +p_nmmon (&MonthName[0],dt.month) ; +p_getsuffixes (&Suffix[0][0]); +p_getctd(&cfg) ; +p_printf("%s, Suss Ss Su SO2uscs02u", +&DayName[0],dt.day+1, &Suffix[dt.day] [0], +&MonthName[0],dt.year+1900, +dt .hour,cfg.timeSeparator,dt.minute) ; + + +} + + +This example is somewhat artificial since the same action can be performed more simply by the use of +p_nowtostr, described in the following section. + + +Object-oriented programmers may prefer to use the time class in OLIB (described in the OLIB Reference +manual of the SIBO SDK Object Oriented Extension) to produce textual representations of the date and +time. + + +10-7 + + +PLIB REFERENCE + + +p_nmday Get the day name + + +VOID p_nmday (TEXT *buf, INT daynum) ; + + +Write the language dependent name of day daynum as a zero terminated string to buf where daynum should +be in the range 0 to 6 inclusive and day 0 is Monday. + + +If you are working in a fixed language, you will know how long the longest day name is. If you are writing +a program that has to work with different language ROMs, you can use the fact that the tool that builds +the day name list for the ROM limits a particular day name to E_MAX_DAY_NAME (32), including the zero +terminator. + + +p_nmdaya Get the day name abbreviation +VOID p_nmdaya(TEXT *buf, INT daynum) ; +This function is only available in EPOC version 3.18 or later. + + +Write the language dependent abbreviation for the name of day daynum as a zero terminated string to buf +where daynum should be in the range 0 to 6 inclusive and day 0 is Monday + + +All day name abbreviations for a particular language are of the same length and could be one, two or three +characters. In no language will day name abbreviations exceed three characters. + + +p_nmmon Get the month name +VOID p_nmmon(TEXT *buf, INT monthnum) ; + + +Write the language dependent name of month monthnum as a zero terminated string to buf where +monthnum should be in the range 0 to 11 inclusive and month 0 is January. + + +If you are working in a fixed language, you will know how long the longest month name is. If you are +writing a program that has to work with different language ROMs, you can use the fact that the tool that +builds the month name list for the ROM limits a particular month name to E_Max_MONTH_NAME (32), +including the zero terminator. + + +p_nmmona Get the month name abbreviation +VOID p_nmmona(TEXT *buf, INT monthnum) ; +This function is only available in EPOC version 3.18 or later. + + +Write the language dependent abbreviation of the name of month monthnun as a zero terminated string to +buf where monthnum should be in the range 0 to 11 inclusive and month 0 is January. + + +All month name abbreviations for a particular language are of the same length and could be one, two or +three characters. In no language will month name abbreviations exceed three characters. + + +p_getsuffixes Get the day-in-month suffixes +VOID p_getsuffixes (TEXT *buf); +Write the language dependent array of the 31 day-in-month number suffixes to buf. + + +The suffixes are written as an array of 31 3-byte fixed length elements where each element contains 0, 1 +or 2 characters followed by a zero terminator (suffixes contain at most 2 characters in any language). +There must be at least 31*3 bytes of memory at buf. + + +Each element in the array contains the suffix for the corresponding day of the month. For example, in +English, the first element contains "st" and the second element contains "nd". + + +p_getampmtext Get the am and pm suffixes +VOID p_getampmtext (TEXT *buf, INT n); + + +Write the language dependent am or pm time suffix as a zero terminated string to buf. If n is 0, write the +am suffix. If n is 1, write the pm suffix. + + +The am and pm suffixes are limited to 2 characters in any language. + + +10-8 + + +p_getctd + + +VOID p_getctd(E_CONFIG *pcfg); + + +10 TIME, TIMERS AND DATES + + +Get time representation preferences + + +.Write a copy of the system structuresz_conFiIe struct to pcfg where the &_conFice struct is defined, in +p_config.h, as: + + +typedef struct + + +{ + + +UWORD countryCode; + +WORD gmtOffset; + +UBYTE dateType; + +UBYTE timeType; + +UBYTE currencySymbolPosition; +UBYTE currencySpaceRequired; +UBYTE currencyDecimalPlaces; +UBYTE currencyNegativelInBrackets; +UBYTE currencyTriadsAllowed; +UBYTE thousandsSeparator; +UBYTE decimalSeparator; +UBYTE dateSeparator; + +UBYTE timeSeparator; + +UBYTE currencySymbol [9]; +UBYTE startOfWeek; + +UBYTE summerTime; + +UBYTE clockType; + +UBYTE dayAbbreviation; + +UBYTE monthAbbreviation; +UBYTE workDays; + +UBYTE units; + +UBYTE spare[9]; + + +} E_CONFIG; + + +In the context of this chapter we are interested in the following items: + + +gmtOffset + + +dateType + + +timeType + + +dateSeparator + + +timeSeparator + + +startOfWeek + + +summerTime + + +cloc + + +dayA + + +mont + + +work + + +kType + + +bbreviation + + +hAbbreviation + + +Days + + +the offset in minutes of the local system time from Greenwich Mean Time. + + +one of &_pate_usa for MM/DD/YY, £_pate_euRopE for DD/MM/YY or +E_DATE_gapan for YY/MM/DD. + + +either =_Trme_12 for a 12 hour clock or E_tT1ime_24 for a 24 hour clock. +the character code of the date separator. For example, the character '/’. +the character code of the time separator. For example, the character ':'. + + +the day number (in the range 0 to 6 inclusive where day 0 is Monday) of the +first day in the week - as used by p_weekno. This is normally either Sunday +(day 6) or Monday (day 0). For example, it is normally Sunday for USA +machines and Monday for UK machines. + + +a bit pattern indicating summer time-zones as follows: E_pst_Home if the +system time should be adjusted for summer time; E_DsT_EUROPEAN if a +European time-zone should be adjusted for summer time; z_DsST_NORTHERN if a +non-European time-zone in the Northern hemisphere should be adjusted for +summer time; E_DST_SOUTHERN if a time-zone in the Southern hemisphere +should be adjusted for summer time. + + +either E_ANALOGUE_CLOCK to indicate a preference for an analogue clock +display or =_p1G1ITAL_cLock to indicate a preference for a digital clock display + + +how many leading characters to take from the day name (as returned by +p_nmday) to abbreviate the day name + + +how many leading characters to take from the month name (as returned by +p_nmmon) to abbreviate the month name + + +a bit mask of 7 bits indicating (by being set) which days are to be considered +work days where the least significant bit corresponds to Monday + + +The data may be set using p_setctd - as described in the chapter General System Services. + + +10-9 + + +PLIB REFERENCE + + +Generating time and/or date strings + + +The functions in this section construct text strings that represent the date and time in a range of formats. + + +The functions are based on language-dependent information that is built into the ROM, in particular, the +system E_CONFIG struct (see the description of p_getctd in the Language and country section of the +General System Services chapter). If you use these functions, your code should automatically work on, for +example, English, French and German machines. + + +Note that the implementation of these functions uses static data. In consequence they may not be used in +the code of a dynamic library (DYL). + + +Date and time format strings + + +The form of the output of the date and time conversion functions described below is controlled by a +format string, in a similar way to the format strings used by p_printf, p_atob and p_atos. + + +The format string consists of literal text intermixed with embedded commands. The literal text is simply +copied to the output and the embedded commands are replaced by the corresponding time or date element. + + +An embedded command is of the form %c or %*c, where c is one of the characters listed below, and * +indicates that the output should be in an abbreviated form. The abbreviated form can be specified for all +commands, but in some cases there is no difference between the full and abbreviated forms. + + +The available commands are as follows: +%% replaced by a single '%' character. Abbreviation has no effect. + + +%: replaced by the time separator character as specified by the timeSeparator +field of the system E_conFie struct. Abbreviation has no effect. + + +%/ replaced by the date separator character as specified by the dateSeparator field +of the system E_conrié struct. Abbreviation has no effect. + + +aN depending on the supplied time of day, this is replaced by the appropriate am or +pm text (as obtained by use of p_getampmt ext). Abbreviation supplies just the +first character of this text. Note that abbreviation may not be appropriate in +some languages. + + +&D replaced by the day-in-month number, in the range 01 to 31, as two digits with +a leading zero as necessary. Abbreviation suppresses any leading zero. + + +%E replaced by the day name, as supplied by p_nmday. Abbreviation causes the +name to be truncated to the number of characters specified in the +dayAbbreviation element of the system E_CONFIG struct. + + +3H replaced by two digits in the range 00 to 23 (24-hour format) corresponding to +the hours component of the supplied time of day. Abbreviation suppresses any +leading zero. + + +SI replaced by two digits in the range 01 to 12 (12-hour format) corresponding to +the hours component of the supplied time of day. Abbreviation suppresses any +leading zero. + + +oM replaced by two digits in the range 01 to 12 corresponding to the month number +for the supplied date. Abbreviation suppresses any leading zero. + + +3N replaced by the month name for the supplied date. Abbreviation causes the +name to be truncated to the number of characters specified in the +monthAbbreviation element of the system E_CONFIG struct. + + +%S replaced by two digits in the range 00 to 59 corresponding to the seconds +component of the supplied time of day. Abbreviation suppresses any leading +Zero. + + +ST replaced by two digits in the range 00 to 59 corresponding to the minutes +component of the supplied time of day. Abbreviation suppresses any leading +Zero. + + +ow replaced by two digits in the range 01 to 53 corresponding to the week number +for the supplied date, as provided by p_weekno. Abbreviation suppresses any +leading zero. + + +10-10 + + +ole +x + + +ole +iS) + + +ole +Ww + + +ole +& + + +oe +uo + + +\ +oO) + + +ole +a + + +10 TIME, TIMERS AND DATES + + +replaced by the suffix text corresponding to the (p) day number for the +supplied date. Abbreviation has no effect. + + +replaced by four digits, in the range 1900 to 2155, corresponding to the year +number for the supplied date. Abbreviation discards the first two digits (note +that, for example, both 1900 and 2000 will appear as 00). + + +replaced by three digits, in the range 001 to 366, corresponding to the day-of- +year number for the supplied date. Abbreviation discards any leading zeros. + + +replaced by the first component of a three-component (day, month and year) +date, where the order of the components is determined by the value of the +dateType component of the system &_conrie struct. Abbreviation has no effect, +but the form of the generated text is conditioned by the toggle commands +described below. In the absence of any toggles, %1 is equivalent to: + +sp if dateType 1S E_DATE_EUROPE + +gm if dateType iS E_DATE_USA + +sy if dateType iS E_DATE_JAPAN + + +replaced by the second component of a three-component (day, month and year) +date, where the order of the components is determined by the value of the +dateType component of the system &_conrie struct. Abbreviation has no effect, +but the form of the generated text is conditioned by the toggle commands +described below. In the absence of any toggles, ¢2 is equivalent to: + +gm if dateType 1S E_DATE_EUROPE + +zp if dateType iS E_DATE_USA + +gm if dateType iS E_DATE_JAPAN + + +replaced by the third component of a three-component (day, month and year) +date, where the order of the components is determined by the value of the +dateType component of the system &_conrie struct. Abbreviation has no effect, +but the form of the generated text is conditioned by the toggle commands +described below. In the absence of any toggles, s3 is equivalent to: + +sy if dateType iS E_DATE_EUROPE + +sy if dateType iS E_DATE_USA + +sp if dateType iS E_DATE_JAPAN + + +replaced by the first component of a two-component (day and month) date, +where the order of the components is determined by the value of the dateType +component of the system &_conFie struct. Abbreviation has no effect, but the +form of the generated text is conditioned by the toggle commands described +below. In the absence of any toggles, %4 is equivalent to: + +sp if dateType 1S E_DATE_EUROPE + +zm if dateType iS E_DATE_USA Of E_DATE_JAPAN + + +replaced by the second component of a two-component (day and month) date, +where the order of the components is determined by the value of the dateType +component of the system E_conFie struct. Abbreviation has no effect, but the +form of the generated text is conditioned by the toggle commands described +below. In the absence of any toggles, %5 is equivalent to: + +gm if dateType 1S E_DATE_EUROPE + +sp if dateType iS E_DATE_USA OF E_DATE_JAPAN + + +replaced by the hour in the format determined by the value of the timeType +component of the system &_conrte struct. Abbreviation discards any leading +zero. The action of 6 is equivalent to: + +3H if timeType 1S E_TIME_24 + +%1 if timeType 1S E_TIME_12 + + +replaced by the am/pm text (as for sa) if the timeType component of the system +E_CONFIG Struct has the value z_t1mz_12, otherwise produces no output. If +output is produced, abbreviation reduces the output to just the first character of +the text, as for za. + + +Note that format strings of the form "s1%/%2%/%3" and "4%/%5" respectively generate three- and two- +component dates that automatically conform to the system configuration dateType setting, and that a +format string of the form "%63:%T%:%s%7" generates a time that automatically conforms to the system +configuration timeType setting. + + +10-11 + + +PLIB REFERENCE + + +The commands 31, %2, %3, 4 and %5 are conditioned by the following toggles: + + +ole + + +F produces no output, but toggles the behaviour of subsequent day items between + +numeric (the default) and name generation. For example, if dateType is +E_DATE_EUROPE and the supplied date is 09/03/1993, the format string +"$1 %F%1 %F%1" will generate the (English) string "09 Tuesday 09". +Abbreviation has no meaning, and is ignored. The items conditioned by this +toggle depend on dateType as follows: + +%1 and %4 for E_LDATE EUROPE + +%2 and %5 for E_LDATE_USA + +%3 and %5 for E_DATE_JAPAN + + +ole +[e) + + +produces no output, but toggles the behaviour of subsequent month items +between numeric (the default) and name generation. For example, if dateType +iS E_LDATE_EUROPE and the supplied date is 09/03/1993, the format string +"$2 %0%2 %0%2" will generate the (English) string "03 March 03". +Abbreviation has no meaning, and is ignored. The items conditioned by this +toggle depend on dateType as follows: + +32 and %5 for E_DATE EUROPE + +%1 and 34 for E_LDATE_USA + +%2 and %4 for E_DATE_JAPAN + + +ole +(9) + + +produces no output, but toggles the behaviour of subsequent day items between +their full (the default) and their abbreviated forms. For example, if dateType is +E_DATE_EUROPE and the supplied date is 09/03/1993, the format string +"SF%1 %G%1 %G%1" will generate the (English) string "Tuesday Tue Tuesday". +Abbreviation has no meaning, and is ignored. The items conditioned by this +toggle depend on datetype as follows: + +%1 and %4 for E_LDATE EUROPE + +%2 and %5 for E_LDATE_USA + +%3 and %5 for E_DATE_JAPAN + + +ole +ae] + + +produces no output, but toggles the behaviour of subsequent month items +between their full (the default) and their abbreviated forms. For example, if +dateType 18 E_LDATE_EUROPE and the supplied date is 09/03/1993, the format +string "80%2 %P%2 %Pp%2" will generate the (English) string +"March Mar March". Abbreviation has no meaning, and is ignored. The items +conditioned by this toggle depend on dateType as follows: + +32 and %5 for E_DATE EUROPE + +%1 and %4 for E_LDATE_USA + +%2 and %4 for E_DATE_JAPAN + + +ole +aq + + +produces no output, but toggles the behaviour of subsequent year items between +their full (the default) and their abbreviated forms. For example, if dateType is +E_DATE_EUROPE and the supplied date is 09/03/1993, the format string +"$3 %U%3 %U%3" will generate the string "1993 93 1993". Abbreviation has no +meaning, and is ignored. The items conditioned by this toggle depend on +dateType as follows: + +33 for E_LDATE EUROPE + +%3 for E_DATE_USA + +%1 for E_DATE_JAPAN + + +ld +fed! + + +produces no output, but toggles between the absence (the default) and the +presence of a day number suffix following a day-in-month number (but not a +day name) generated by 1, 2 or 33. For example, if dateType is +E_DATE_EUROPE and the supplied date is 09/03/1993, the format string + +"$G%1 %L%1 %L%1" will generate the (English) string "9 9th 9", but +"SF%G%1 %L%1 %L%1" will generate the (English) string "Tue Tue Tue". +Abbreviation has no meaning, and is ignored. + + +10-12 + + +10 TIME, TIMERS AND DATES + + +Function return values + + +The Window Server animates time displays either by flashing the last time separator character in the text +or, if the text contains a seconds display, by updating the time every second. + + +All the functions described below return a value that indicates the form of animation required. The +possible return values are: + + +-2 The display does not show seconds and contains no time separators. The +display is not animated. + + +-1 The display shows seconds. Animation updates the display every second. + + +any other value The return value is the offset in the string to the last time separator character. +Animation flashes this character. + + +p_dt2str Convert a P_DATE time to a string +INT p_dt2str(TEXT *buf, TEXT *fstr, P_DATE *pdt); + + +Write a zero terminated string containing formatted date and time text to buf, controlled by the zero +terminated format string pointed to by fstr and the content of the p_paTE struct pointed to by pat. + + +The format string fstr contains literal text, embedded with commands, as described above. + + +p_ds2str Convert a P_DAYSEC time to a string + + +INT p_ds2str(TEXT *buf, TEXT *fstr,P_DAYSEC *pds); + + +Write a zero terminated string containing formatted date and time text to buf, controlled by the zero +terminated format string pointed to by fstr and the content of the p_payszc struct pointed to by pas. + + +The format string fstr contains literal text, embedded with commands, as described above. + + +p_st2str Convert a system time to a string + + +INT p_st2str(TEXT *buf, TEXT *fstr, ULONG *pst); + + +Write a zero terminated string containing formatted date and time text to buf, controlled by the zero +terminated format string pointed to by fstr and the system time (seconds since 00:00:00, January 1, +1970) pointed to by pst. + + +The format string fstr contains literal text, embedded with commands, as described above. + + +p_now2str Convert the current time to a string + + +INT p_now2str(TEXT *buf, TEXT *fmt); + + +Write a zero terminated string containing formatted date and time text to buf, controlled by the zero +terminated format string pointed to by fstr and the currently set time. + + +The format string fstr contains literal text, embedded with commands, as described above. + + +10-13 + + +CHAPTER 11 + + +FILES + + +Files in EPOC + + +The file server + + +The file server is a high priority system process (with process name SYS$FSRV) performing all file +related operations on behalf of "client" processes. + + +An application process must connect to the file server before using its services. However, this is normally +taken care of by the C startup module (the code that precedes main) and supplied as standard for use with +the PLIB library. (Most applications need the services of the file server and the overhead of connecting to +the file server is modest.) + + +A client process sends the file server an inter-process message to request a file server service. However, +the application programmer does not program at the message passing level but uses the interface provided +by the r1L: device (ie using p_open) together with the interface provided by a number of ROM resident +functions (eg p_delete to delete a file) as described in this chapter. + + +Any process that attempts to send a message to the file server without having connected is panicked with +panic number 41. + + +File systems + + +The file server supports multiple file systems (also called nodes). In principle, the file server supports any +number of file systems (p_open may be used to get a list of the file systems as described later in this +chapter). At the time of writing, three file systems have been implemented: + + +LOC: : The local filing system with devices M: (the RAM drive) and SSD drives A:, +B:, ...(where the quantity depends upon the hardware). + + +REM: : The remote filing system, available while the file server is connected to a +remote file server. The structure of the filing system depends upon what the +remote system is. If the remote system is a PC or another SIBO machine, the +structure is the same as for Loc: :. + + +ROM: : The ROM filing system, used to access ROM-based files. This filing system is +not normally visible to the user. The Rom: : file system does not support devices +or directories. + + +Within the toc: : file system (and where REM: : is connected to a PC or another SIBO machine), the +devices and directories structure is compatible with the MSDOS filing system. + + +File systems are implemented as PDDs (Physical Device Drivers) which are normally resident in the +ROM (PDDs are described in the chapter //O System). If you use (as described in I/O System): + + +GLDEF_C VOID PrintPDDs (VOID) +{ +HANDLE h; +TEXT b[E_MAX_NAME+2]; + + +for (h=0; (h=p_devfnd(h,"*",E_PDD, &b[0]))>=0;) + + +p_printf(" %s",&b[0]); +} + + +11-1 + + +PLIB REFERENCE + + +to get a list of PDDs, the list would include: + + +FSY.LOC the toc:: PDD +FSY.ROM the Rom:: PDD +FSY.REM the REM:: PDD +SSD drives + + +SIBO machines have 2 to 4 (depending on the machine) Solid State Disk (SSD) drives, taking SSDs of +various type and capacity (from 32K bytes to 8Mb and beyond). SSDs are so called because they are +based on silicon memory with no moving parts. The different types of SSD (in order of decreasing unit +cost) include: + + +e static RAM with integral Lithium battery +e Flash EPROM +¢ one-time-programmable ROM +e masked ROM +An SSD drive can physically and logically mount any type of SSD. + + +The physical interface between an SSD and the drive has only 6 connectors (4 for power, and 2 for data). +The 2 data connections are an instance of a high speed serial channel. This is a fundamental part of the +SIBO hardware architecture, implemented in custom chips. It can be used to communicate with other +peripherals. + + +The high speed serial channel is driven synchronously by a clock which normally runs at 3.84 MHz, +giving a data transfer speed comparable to the more expensive hard disks on PCs but, without any latency +for the drive head to position to the required track. Writing to a Flash SSD is slower because of the time +taken to program the EPROM and, in this case, the speed of writing is twice as fast as writing to a typical +floppy disk on a PC. + + +SSDs are driven by the Loc: : file system using a number of subsidiary PDDs (Physical Device Drivers) +handling the different SSD types and the internal m: device. The list of PDDs produced by calling +PrintPDDs (described above) would include: + + +LOC. TYO the RAM SSD PDD +LOC. TY1 the Flash SSD PDD +LOC.TYM the internal RAM (“:) PDD + + +Files are stored in a completely different way on RAM SSDs from Flash SSDs. + + +SSD drive doors have a switch that keeps the file server informed of possible SSD removals and +insertions. After an SSD drive door has been opened the file server checks each drive to see if it contains a +new SSD. When the file server detects a new SSD it automatically mounts the new SSD. + + +If a previous occupant of the SSD drive had one or more files open on it, the file server keeps a record of +the SSD. When access is subsequently attempted on a file channel on that SSD, the file server uses +p_notify (described in the chapter Error Handling) to request the user to replace the SSD and to retry or +to abandon the channel. If the user replaces the SSD and selects retry such that the operation completes +successfully, the application process is not made aware of any problem. If the user chooses to abandon the +channel, the operation completes with the error E_FILE_ABoRT. When this occurs, the channel is +disconnected from the file and put into an abort state where the only possible operation is to close the +channel (any operation other than p_close fails with the error E_FILE_ABORT). + + +An application that receives an E_FILE_ABORT error can either make do without the file (which probably +means having to exit) or to appeal yet again to the user to put the SSD back in the drive and, if the user +does put the SSD back, to locate and re-open the file and recover. The latter takes more code but is kinder +to the user. + + +11 FILES + + +Unattended applications + + +The file server will also normally call p_notify to give the user a chance to retry any file operation that +fails on a mounted medium. This kind of failure is rare on SSDs but is more common on magnetic media - +especially floppy disks. In some cases, the user may be able to correct the error (eg to close the door on a +floppy disk drive) and successfully retry. If the user abandons, the file operation completes with an error +other than £_FILE_ABORT (eg E_FILE_READ if a floppy disk read fails). + + +This scheme whereby the file server uses p_notify to give the user a chance to correct the problem and +retry works well when the client process is an interactive application but poorly if the requesting process is +designed to run unattended (eg a communications program) or is itself a server process (eg the window +server trying to read a font file). Such processes can use p_setnotify (FALSE), described in the chapter +Error Handling, to stop the file server from using the notify service. In this case all errors are returned +directly. + + +RAM SSDs + + +RAM SSDs use static RAM backed up by an integral Lithium battery. While the RAM SSD is inserted in +an SSD drive, it draws current from the SIBO machine. When the SSD is removed, it relies on its internal +battery to maintain its data. + + +The allocation of the space for directories and files on a RAM SSD is block structured - identical to that +which is used on PC hard disks and floppy disks. Just like floppy disks on a PC, there is a limit to the +number of files that may appear in the root directory (where this limit includes directory files). This root +directory limit does not limit the number of files that can be stored on a RAM SSD since any number of +files may be stored in subdirectories. + + +The format function (described below in this chapter) automatically allocates the capacity of the root +directory as a function of the capacity of the SSD. The dependence of the number of files that may appear +in the root directory on SSD size is as follows: + + +less than 128K +128K or greater but less than + + +256K or greater but less than + + +512K or greater but less than 1M +1M or greater but less than 2M +2M or greater but less than 4M +4M + +6M + +8M + + +The RAM SSD PDD on the toc: : file system on SIBO machines does not buffer written data. This +protects the integrity of the SSD contents from being corrupted by application process or system crashes +occurring while files are open, or by the removal of the SSD while files are open on it. + + +Flash SSDs + + +Flash SSDs use Flash EPROM chips in which all the data bits are initially set. A particular bit may be +cleared by programming but it can not be set again unless all the bits on the chip are set (by erasing the +chip). Unlike older generation EPROMs, Flash EPROMs are erased electrically (rather than by exposure +to UV light). The speed with which Flash can be programmed is also substantially faster than the old UV +erasable EPROMS. + + +A Flash SSDs may be erased in its SSD drive by formatting (formatting is described later in this chapter). + + +Since Flash memory does not require a battery to maintain it, the data on a Flash SSD is very secure - +more so than on RAM SSDs or magnetic media. Flash memory is also cheaper than RAM. + + +The Flash filing system is designed such that the logical interface to files on a Flash SSD (whether +reading or writing) is entirely equivalent to that on other devices (RAM SSD, hard disk etc). However, +when overwriting or when deleting a file, space is consumed and is not recovered until the SSD is next +formatted. Note also that renaming a file, setting the date and time or setting the file attributes all use up +additional space and can therefore fail through lack of remaining capacity (the function returns +E_FILE_FULL). However, deleting a file does not consume any further space. + + +11-3 + + +PLIB REFERENCE + + +You can randomly access a Flash file and overwrite sections of it in exactly the same way as for any +other file. However, in contrast to read/write block storage devices, overwriting incurs a storage +overhead. For example, the following code: + + +pos=0L; + + +do +{ +p_seek (chan, F_FABS, pos) ; +} while (!p_write(chan,"Pointless", 8) ); + + +continuously overwrites the first 8 bytes of the file on channel chan. On a RAM file, this would work +indefinitely and just exercise the hardware. On a Flash file, the code would work but each iteration would +use up space on the Flash SSD and the p_write would eventually fail and return E_FILE_FULL. + + +In practice, you should not worry about limited overwriting of file data - for example, to patch a program +file or to update a header. However, you cannot reasonably repeatedly and indefinitely overwrite a Flash +file and, for example, Flash SSDs are unsuitable for B-tree index files. + + +See the chapter Database Files for a description of a Flash-friendly set of functions allowing random +access to, and the deleting and updating of, variable length records. These functions take advantage of the +fact that a byte can be physically overwritten (with no storage penalty) provided that the overwrite is such +that each bit in the byte either stays the same or is cleared. + + +Flash SSDs are particularly attractive for storing program files, read-only data (say for data-referral +applications), for securely storing logged data in the field and for archiving data. + + +The storage of files on a Flash SSD is very different from that used on RAM SSDs. The scheme is not at +all block structured but is based on linked variable length records. All this is hidden from the caller and +the logical interface to a file on a Flash SSD is the same as for a file on a RAM SSD (or any other +medium). + + +The data in each write to a file on a Flash SSD is written straight to the SSD (ie it is not buffered)!. +However, in the interests of efficient storage, the record just written is kept open (with a oxtf££ length) +for as long as possible - until the file channel is closed or flushed using P_FFLus# or until a write to +another file on the same SSD occurs. The date and time stamp is also not written until the file channel is +flushed or closed. + + +If the SSD is removed or the machine resets while there is an open file channel with an outstanding write, +the record is closed when the file is next accessed (the file is then also stamped with the current date and +time). + + +On a Flash SSD, there is no limit on the number of files or directories in the root directory. You will also +find that it is possible to fit slightly more data on a freshly formatted Flash SSD than on a RAM SSD of +the same nominal capacity. This is due to the fact that files are allocated space in multiples of whole +blocks on a RAM SSD whereas Flash files are stored in exactly sized variable length records. + + +File specifications +A full file specification has the form: + + + +where the components are: + + + the file system node (eg Loc: :) + the device name (eg B:) + + the directory name (eg \NOTES\OLD\) + the file name (eg PLaNs). + + the extension name (eg .TPD) + + +!This may not be the case for text files, which are handled by a layer over the FL: device. The buffering +of such files is thus outside the file server's control. + + +11 FILES + + +An example of a full file specification is: +LOC: :B: \NOTES\OLD\PLANS . TPD + + +Although the file server assumes that a file specification may be decomposed into a , , +, and , it avoids any assumption of the detailed syntax of the , , +and components. This is left to the file system code that implements the file specification +manipulation functions p_fparse and p_chdir. + + +Leaving such detailed considerations to the file system is designed to allow the file stores of remote +foreign file systems to be mapped transparently to the file server model (which is compatible with the +MSDOS filing system). For example, in the VMS operating system, the above example of a file +specification might translate to: + + +REM: : USER: [NOTES.OLD]PLANS.TPD +and on an Apple Macintosh, it might be: +REM: :HD40:NOTES:OLD:PLANS.TPD + + +and on Unix, it might be: + + +REM: : USER: :NOTES/OLD/PLANS.TPD + + +To prepare for such foreign systems, applications should follow the example of the file server and avoid +making assumptions about the syntax of file specifications and use functions such as p_fparse and +p_chdir to manipulate file specifications. + + +File specifications satisfy the following rules: + + +e a file specification will not require more than p_FNamEs1zE (128) bytes, including a zero +terminator + + +e the component is always p_FsySNAMESIzE bytes long (excluding any zero terminator) + + +where P_FNaMESIzE and p_FsysNameEsi1zeE are defined in p_file.h. Except for and the p_FNAMESIZE +total, you should not make any assumptions about the maximum size of the components of a file +specification. + + +Default path + + +The file server stores a default node, device and directory, also called the default path, for each of its +clients. In addition, the file server stores a lower level default path, the system-wide default path. This is +the default path assigned to new clients when they connect to the file server. + + +A process that is a client of the file server uses: +p_setpth to set its default path +p_getpth to get a copy of its default path + + +A process (normally a system process such as the shell) can change the system-wide default path - the +path subsequently assigned to connecting clients - by calling p_setdefaultpath. + + +Channel-based services + + +A client of the file server can use p_open on the Fru: device with different values of mode to do the +following: + + +P_F STREAM, to open a file and manipulate it as a flat binary file +P_FSTREAM_TEXT + +P_FTEXT to open a file and manipulate it as a record-oriented text file +P_FDIR to get a list of the files and subdirectories in a directory +P_FDEVICE to get a list of the available devices + +P_FNODE to get a list of the available file systems + +P_F FORMAT to format a Loc: : device + + +11-5 + + +PLIB REFERENCE + + +Once a channel has been opened, one or more I/O functions (depending on mode) may be requested +synchronously using p_iow (or a convenience function such as p_read) or asynchronously using p_ioc or +p_ioa. + + +There is no practical limit to the number of file channels that may be opened in the system or by a +particular process. + + +Non-channel-based services + + +These are file operations not involving the F1L: device driver. They are requested by the following +function calls: + + +p_fparse, to parse a file specification +p_fparseasync + + +p_chdir, to change the directory component of a file specification +p_chdirasync + + +p_ninfo, to get file system node information +p_ninfoasync + + +p_dinfo, to get information on the medium in a device +p_dinfoasync + + +p_finfo, to get information on a file or a directory +p_finfoasync + + +p_rename, to rename a file or a directory + + +p_renameasync + + +p_delete, to delete a file or a directory +p_deleteasync + + +p_mkdir, to make a new directory +p_mkdirasync + + +p_sfstat, to set the attributes of a file (and to set the volume label of a medium) +p_sfstatasync + + +p_fdate, set the modification date and time of a file +p_fdateasync + + +The name of asynchronous equivalents are generated by appending async to the name of the +corresponding synchronous function. The asynchronous function takes the same parameters as the +synchronous function but with the addition of a status word parameter at the end of the parameter list. + + +Asynchronous file operations + + +The file server is essentially asynchronous in its operation and most functions are provided in both +asynchronous and synchronous forms. + + +Because the file server has a higher priority than any of its clients, any operation that does not wait for a +slow external device will have completed by the time an asynchronous request has returned. This includes +any operation on the Rom: : file system or where the toc: : file system accesses SSDs or the internal RAM +drive (M:). However, when accessing the REM: : file system where the connection is via an RS232 cable, +any asynchronous request is almost certain to return before the operation is complete. + + +Although, in practice, most file operations complete in a fraction of a second, a particular file request may +take an extended time. For example, a read of 8K bytes from a Rem: : file, connected over a 1200 baud +modem link, would take well over a minute. However, a request will never take an indefinite time to +complete (as, for example, a write to the parallel port can do when the printer is off line). + + +For these reasons, the file server does not actively support a cancel service. (Incidentally, it is also worth +considering the state in which a file would be left if a partially completed write operation were cancelled.) + + +A request on an open file channel may be cancelled using p_iow(P_FCANCEL) but the cancel will not cause +the operation to complete any sooner (and it will not complete with E_FILE_CANCEL). + + +In general, it is preferable to simulate a cancel by waiting for current service to complete and forcing the +status word to E_FILE_CANCEL, as illustrated below. + + +11-6 + + +11 FILES + + +The cancelling of an asynchronous request such as: +p_ioc (pcb, P_FREAD, &stat,buf,1len); +may be simulated by: + + +if (stat==E_FILE_PENDING) +{ +p_waitstat (&stat); /* wait for completion */ +stat=E_FILE_CANCEL; /* report a cancel */ +} + + +This will normally complete almost immediately. You should, however, be aware that in rare cases when +using the remote filing system (say, when the remote computer is re-booted and the communications link +is set up to have a long timeout period) it may take an extended time to complete. + + +Manipulating file specifications + + +p_fparse (or f_fparse) Parse a file specification + + +INT p_fparse(TEXT *name, TEXT *related, TEXT *full, P_FPARSE *pcrk); +INT f_fparse(TEXT *name, TEXT *related, TEXT *full, P_FPARSE *pcrk); +INT p_fparseasync(TEXT *name, TEXT *related, TEXT *full, P_FPARSE *pcrk, WORD *stat); + + +Builds a full file specification of the form: + + + +as a zero terminated string in fu11, where the components are: + + + the file system node (eg Loc: :) + the device name (eg B:) + + the directory name (eg \NoTES\OLD\) + the file name (eg PLans). + + the extension name (eg . TPD) + + +The parameters name and full may point to the same address, but related and ful should not have the +same address. + + +There should be at least p_rNamestze (128) bytes of memory reserved at fu11. Note that p_rNamEs1zE +bytes are always written to fu11 even when the generated file specification is shorter. If you have a name +produced by a previous call to p_fparse and you are calling p_fparse again to fill in the struct at pcrk, +you still need p_rnames1ze bytes at full. + + +Subject to the restrictions described below, under the heading Using p_fparse across filing systems, the +components making up the full file specification are taken from the following (in order of precedence): + + +e the zero terminated file specification name + + +e the zero terminated related file specification re1atea (the related file specification may be +omitted by passing nuLL). + + +e the default path (the node, device and directory as set by p_setpth) + + +Thus components are only taken from related if they are missing from name. If there are still missing +components, they are taken from the default path. Note that the and fields in name and +related may contain wildcard characters. + + +The output file specification in fu11 is converted to upper case characters. Prior to EPOC version 2.31, +conversion to upper case was performed by folding (as by using p_tofoid). From EPOC version 2.31 +onwards the conversion is by converting to upper case (as by using p_toupper). This has no significant +effect on UK applications, but improves the handling of file names containing, for example, accented +characters. + + +11-7 + + +PLIB REFERENCE + + +Further information on the content of £u11 is written to the P_FPARSE struct pcrk. If this information is +not required, pcrk may be passed as NULL. If perk is not NULL, it should be the address of a P_FPARSE +struct, defined in p_file.h as follows: + + +typedef struct +{ +UBYTE system; /* file system name length */ +UBYTE device; /* device name length */ + + +UBYTE path; /* path name length */ + +UBYTE name; /* name length */ + +UBYTE ext; /* extension length */ + +UBYTE flags; /* information on the presence of wildcards */ +} P_FPARSE;. + + +The members system, device, path, name and ext are set to the lengths of their corresponding fields in +full, including delimiters. The flags field contains information on the occurrence of wild card characters +in the extended specification according to the following masks: + + +P_PWILD_ANY if set, the file specification contains one or more wild card characters and at +least one of the following bits are set + + +P_PWILD_NAME if set, the name field contains one or more wild card characters +P_PWILD_EXT if set, the extension contains one or more wild card characters + + +The function returns zero if successful or one of the following negative error numbers: + + +E_FILE_NAME either name or related contains an invalid name + +E_FILE_DEVICE either name or related contains an invalid device name + +E_FILE_DIR either name or related contains an invalid directory name + +E_GEN_FSYS either name or related contains an invalid file system name or the file system + + +does not exist + + +The function f_fparse is identical to p_fparse except that it calls p_leave (passing the error number) +rather than return a negative error number. + + +As an example, if the current default path is "Loc: :a:\", then + +p_fparse ("FRED", "\\FILES\\DOCS\\JOE.DOC", buf, &crk) ; +writes the zero terminated string Loc: :A: \FILES\DOCS\FRED.DOC to buf and {5,2,12,4,4,0} tocrk. +The function is often used to change the extension of a file as, for example, in: + +p_fparse (".BCK", "\\FILES\\DOCS\\JOE.DOC", buf, &crk) ; + + +Using p_fparse across filing systems + + +Since the syntax of a file specification may differ between filing systems (see File specifications, earlier in +this chapter) the functions p_fparse and p_chdir are implemented in the code of each file system. The +function p_fparse builds a full file specification from up to three sources, which may therefore specify +two or more different filing system nodes. + + +This section describes the rules that determine which implementation performs the function p_fparse in +any particular case, and which of the three sources contribute towards the full file specification. The three +sources will be referred to as name, related and the default path, as in the description of p_fparse. + + +The node which performs the p_fparse is determined from name, related and the default path, according +to the following rules: + + +e If neither name nor related contain an explicit component, the node specified by the +default path is assumed (the default path always has an explicit component). + + +e If either name or related (but not both) contain an explicit component, this is taken to be +the node which performs the p_fparse. + + +e If both name and related contain explicit components, the specified in name is +taken to be the node which performs the p_fparse. + + +11-8 + + +11 FILES + + +If an explicit in related differs from that determined from the above rules, related is assumed +not to be valid for the specified node and is ignored by p_fparse. + + +If the in the default path differs from that determined from the above rules, the default path is +assumed not to be valid for the specified node and is ignored by p_fparse. + + +Thus, assuming that the default path is "Loc: :a:\", then +p_fparse ("PLIB.MAK", "REM: :HD40:SOURCE:",buf,NULL) ; + +is handled by the remote filing system and writes the string REM: :HD40:SOURCE:PLIB.MAK to buf, but +p_fparse ("LOC: : PLIB.MAK", "REM: : HD40: SOURCE: PLIB.MAKE", buf, NULL) ; + +is handled by the local filing system and writes the string Loc: :A:\PLIB.MAK tO buf (related is ignored). + + +All sources that are not ignored by p_fparse are checked as being valid for the specified node, even if +they do not contribute to final full file specification. Thus + + +p_fparse ("LOC::C:\\PLIB.MAK", "PLIB.MAKE", buf, NULL) ; + + +will fail with error =_F1LE_NamE because the in related is not valid for the Loc: : filing system, +even though all the components of a full file specification are present in name. This type of situation is +typically likely to occur when copying files between the rem:: and toc: : filing systems. + + +p_chdir Change the directory in a file specification + + +INT p_chdir (TEXT *src, TEXT *outp, INT mode, TEXT *subdir) ; +INT p_chdirasync(TEXT *src, TEXT *outp, INT mode, TEXT *subdir, WORD *stat); + + +Parse src with a nut related name and change its directory to produce a new file specification outp +according to mode, which should be one of: + + +P_CD_ROOT to move to the root directory +P_CD_PARENT to move to the parent directory +P_CD_SUBDIR to move to the zero terminated subdirectory subdir + + +The parameter subdir is ignored if mode is not P_CD_SUBDIR. + + +If src contains a file name then this name is retained and appended to the new directory specification +outp. + + +There should be at least p_rnames1zz (128) bytes of memory reserved at outp. Note that p_rNAMESIZE +bytes are always written to outp even when the generated file specification is shorter. + + +The parameters src and outp may point to the same address. + + +Note that p_chdir is just a means of setting up outp from mode, src and subdir with no consideration to +the existence of the directories in src and subdir. The operation is performed by the appropriate file +system (as specified by the component of the full file specification) allowing a file specification to +be manipulated without knowledge of the detailed structure (eg the delimiters used) of file specifications +on that . + + +When mode is P_cD_SUBDIR, subdir is just inserted into the full file specification at the appropriate +position. Except for checking that the resultant full file specification length does not exceed p_FNAMESIZE +bytes, the validity of outp is not checked. + + +The function returns zero if successful or a negative error number if it fails. As well as the errors that can +be returned by the internal parse of src, p_chdir can return: + + +E_FILE_NXIST mode Was P_CD_PARENT and src was already at the root directory + +E_FILE_DIR subdir contains an invalid directory name + +E_FILE_NAME inserting subdir would make the file specification length exceed p_FNAMESIZE +bytes + + +11-9 + + +PLIB REFERENCE + + +For example, if the current default path is "Loc: :a:\", then +p_chdir("\\fred\\*.c", buf, P_CD_SUBDIR, "bill") writes LOC: :A:\FRED\bill\*.C to buf +p_chdir ("\\fred\\aa.c",buf,P_CD_SUBDIR, "jim") writes LOC: :A:\FRED\jim\AA.C to buf + + +p_chdir("\\fred\\aa.c", buf, P_CD_SUBDIR, "bill\\jim") writes LOC: :A:\FRED\bill\jim\AA.C to buf +(although, depending on where bi11\4jim came from, this breaks the spirit of p_chdir by including a +delimiter in subdir) + + +p_chdir ("\\fred\\jim\\*", buf, P_CD_PARENT, NULL) writes LOC: :A:\FRED\* to buf +p_chdir("\\fred\\jim\\*", buf, P_CD_ROOT, NULL) writes LOC: :A:\* tO buf + + +p_chdir ("rem: :hd40:fred:aa.c",buf,P_CD_SUBDIR, "jim") writes REM: :HD40:FRED: jim:AA.C to buf + + +The default node, device and directory + + +p_setdefaultpath Set the system-wide default path +INT p_setdefaultpath(TEXT *name) ; + + +Set the file server system-wide default path to name. This is the default path that is assigned to a process +when it connects to the file server. + + +The parameter name is a zero terminated string of the form: + + + + + +where + + is the file system node (eg Loc: :) + is the device name (eg B:) + + is the directory name (eg \NOTES\OLD\) + + +The parameter name is parsed with a nut related file name and any file name and extension component is +discarded. + + +The function returns zero if successful or the same error numbers as for p_fparse if name failed to parse. + + +A successful call implies that file system exists at the time of the call (note that some file systems +such as REM: : are not permanently installed) and that and are valid for the file system. It +does not mean that contains a medium, or that exists. + + +For example, after: +p_setdefaultpath ("LOC::B:\\"); + + +all new file server clients will initially have the default path of Loc: :B:\. + + +p_setpth Set the default path of this process + + +INT p_setpth(TEXT *name) ; +INT p_setpthasync(TEXT *name, WORD *stat); + + +Set the default node, device and directory for this process to name where name is a zero terminated string +of the form: + + + + + +where + + is the file system node (eg Loc: :) + is the device name (eg B:) + + is the directory name (eg \NOTES\OLD\) + + +The parameter name is parsed with a nut related file name and any file name and extension component is +discarded. The specified directory must exist. + + +11-10 + + +11 FILES + + +The function returns zero if successful or a negative error from p_fparse if name failed to parse or: + + +E_FILE_DEVICE if the device does not exist +E_FILE_NOTREADY if the device does not contain a medium +E_FILE_DIR if the directory does not exist + + +When a process connects to the file server, it is assigned the file server system-wide default path, set by +the last call to p_setdefaultpath. + + +For example, if the current default path is Loc: :m:\, then: +p_setpth("B:"); + + +sets the default path to Loc: :B:\. + + +p_getpth Get the default path of this process +VOID p_getpth(TEXT *name) ; + + +Write the default node, device and directory for this process as a zero terminated string to name of the +form: + + + + + +where + + is the file system node (eg Loc: :) + is the device name (eg B:) + + is the directory name (eg \NOTES\OLD\) + + +There should be p_rnames1zeE bytes of memory reserved at name. + + +There is no asynchronous version of p_getpth because the process default node, device and directory is +stored by the file server without recourse to the appropriate file system (although the interpretation of + and may depend on ). + + +p_getpthbyid Get the default path by process id + + +INT p_getpthbyid(HANDLE pid, TEXT *name); + + +Write the default node, device and directory of process pia as a zero terminated string to name. The +content of name is as for p_getpth, described above. + + +Returns zero if successful or E_FILE_Nxist if pia is not a client of the file server. + + +Operations on nodes and devices + + +p_open(P_FNODE) Get a list of nodes + + +INT p_open(VOID **ppfcb, TEXT *name, UINT mode); + +INT p_iow(VOID *pfcb, INT func, TEXT *buf, P_NINFO *pinfo); +INT p_close(VOID *pfcb) ; + +To get a list of file system node names, you: + + +e = call p_open with a mode of P_FNoDE to open a node list channel + + +e repeatedly call p_iow with a func of p_rREap to read each node name (until it returns +E_FILE_EOF) + + +e = call p_close to close the node list channel + + +11-11 + + +PLIB REFERENCE + + +The name parameter to p_open may be "FIL:" or NULL. The mode parameter must be P_FNODE. + + +Each successful call to p_iow(P_FREAD) writes the next file system node name as a zero terminated string +to buf (buf should have a capacity of P_FSYSNAMESIZE+1 (6) bytes). The call to p_iow(P_FREAD) returns +E_FILE_EOF after all the node names have been read. + + +If the parameter pinfo is not NULL it is taken as the address of a P_NINFo struct which is filled with the +same node information as would be obtained by calling p_ninfo, described below. + + +For example: + + +LOCAL_C VOID ListNodes (VOID) + + +{ +VOID *ncb; +TEXT buf [P_FSYSNAMESIZE+1]; + + +p_open(&ncb, "FIL:",P_FNODE) ; + +while (!p_iow(ncb,P_FREAD, &buf[0],NULL) ) +p_puts (&buf[0]); + +p_close(ncb); + + +} + + +lists the current node names. + + +p_ninfo Get node information + + +INT p_ninfo(TEXT *node, P_NINFO *pninfo); +INT p_ninfoasync(TEXT *node, P_NINFO *pninfo, WORD *stat); + + +Write information on the zero terminated file system node to the P_NINFo structure at pninfo and return +zero if successful or the negative E_GEN_Fsys if node is invalid or does not exist. + + +The P_NrnFo struct is defined in p_file.h as: + + +typedef struct { +UWORD version; +UWORD type; +UWORD formattable; +UBYTE spare[26]; +} P_NINFO;. + + +where pninfo->type contains: +P_FSYSTYPE_FLAT if file system node does not support hierarchical directories +P_FSYSTYPE_HIER if file system node does support hierarchical directories + + +and pninfo->formattable is TRUE if file system node supports the formatting of its devices and FALSE +otherwise. + + +The version field pninfo->version is designed to allow future versions of p_ninfo (which would write +further information to pninfo->spare[]) to be identified by the caller. At the time of writing, +pninfo->version is Set to 2. + + +p_locchg Check if LOC:: has changed +INT p_locchg(INT mask) ; +This function is only available in EPOC version 2.16 or later. + + +Check if Loc: : has changed (for example, if the SSD door has been opened) since the last call to +p_locchg. The return value has the bits that were set in mask either set or cleared, depending on whether +or not LOC:: has changed. + + +The use of a mask allows multiple independent calls from within one application, with each caller +consistently using one specific bit of mask. Bit 15 is ignored, so as never to return a negative value (even +though the call can never fail). Bits 8 to 14 inclusive are reserved for system use. An application may +therefore make up to eight independent calls, using bits 0 to 7. + + +Typical calling code would make an initial call to p_locchg, to ensure that only subsequent changes are +detected. It would then poll for changes by calling p_locchg, say, every two seconds. + + +11-12 + + +11 FILES + + +p_open(P_FDEVICE) Get a list of devices + + +INT p_open(VOID **ppfcb, TEXT *name, UINT mode) ; +INT p_iow(VOID *pfcb, VOID *buf, NULL); +INT p_close(VOID *pfcb) ; + + +To get a list of device names for a particular file system you: +e call p_open with a mode of P_FDEVICE to open a device list channel + + +e repeatedly call p_iow with a func of p_FReEap to read each device name (until it returns +E_FILE_EOF) + + +e call p_close to close the device list channel + + +The name parameter to p_open should be a zero terminated node name (with or without a leading F1L:). +The parameter mode must be p_rpevice. If the node name is illegal or does not exists, p_open fails and +returns E_GEN_Fsys. If the node does not support devices (as is the case for Rom: :), p_open fails and +returns E_GEN_NSUP. + + +Each successful call to p_iow(P_FREAD) Writes the next device name as a zero terminated string to buf +(buf should have a capacity of p_rNames1zeE (128) bytes). The call to p_iow(P_FREAD) returns E_FILE_EOF +after all the device names have been read. The parameter following but in the call to p_iow (P_FREAD) +should be nut. + + +For example: + + +LOCAL_C VOID ListDevices (VOID) +{ +VOID *ncb, *dcb; +INT ret; +TEXT node[P_FSYSNAMESIZE+1]; +TEXT device [P_FNAMESIZE]; + + +p_open(&ncb, "FIL:",P_FNODE) ; +while (!p_iow(ncb,P_FREAD, &énode[0],NULL) ) +{ +p_puts (&node[0]); +if ((ret=p_open (&dcb, &node[0],P_FDEVICE) ) <0) +{ +p_puts("\tDevices not supported"); +continue; +} +while (!p_iow(dcb,P_FREAD, &édevice[0],NULL) ) +p_printf("\t%s",&device[0]); +p_close(dcb); +} +p_close(ncb); +} + + +lists the current node names with their devices. + + +p_dinfo Get device information + + +INT p_dinfo(TEXT *dname, P_DINFO *pdinfo) ; +INT p_dinfoasync(TEXT *dname, P_DINFO *pdinfo, WORD *stat); + + +Write information on the device with zero terminated name dname and on the medium (eg SSD or +diskette) that is mounted on device dname to the p_DINFo struct at pdinfo. Returns zero if successful or +one of the following negative error numbers: + + +E_FILE_DEVICE if an invalid or non-existent device is specified + +E_FILE_NOTREADY if the device does not contain a medium + +E_FILE_CORRUPT the Loc: : sub file system on a SIBO machine has recognised a RAM or Flash +SSD without a valid boot record (probably because the SSD is not formatted) + +E_FILE_UNKNOWN none of the file systems recognise this medium and formatting is unlikely to + + +make it readable + + +11-13 + + +PLIB REFERENCE + + +The P_p1nFo struct is defined in p_file.h as: + + +typedef struct { + +UWORD version; + +UWORD mediatype; + +UWORD removable; + +ULONG size; + +ULONG free; + +UBYTE name [P_VOLUMENAME] ; +WORD batterystate; + +UBYTE spare[16]; + +} P_DINFO;. + + +Except for pdinfo->removable, which is TRUE if the device has removable media, all information +describes the medium mounted on device dname. + + +The least significant byte of pdinfo->mediatype takes one of the following values: + + +P_FMEDIA_UNKNOWN unknown media type + +P_FMEDIA_FLOPPY drive takes 3.5 inch or 5.25 inch diskettes + +P_FMEDIA_HARDDISK drive contains a hard disk + +P_FMEDIA_RAM drive contains a RAM disk (read/write) + +P_FMEDIA_FLASH drive contains a Flash disk + +P_FMEDIA_ROM drive contains a ROM disk (read only) + +P_FMEDIA_WRITEPROTECTED drive contains a write protected medium + +The most significant byte of pdinfo->mediatype takes a combination of the following bit flags: +P_FMEDIA_COMPRESSIBLE it is worth compressing out logically deleted records from a file on this + + +medium to reduce both the file size and the storage consumed by the file +(not set for Flash SSDs) + + +P_FMEDIA_DYNAMIC the media capacity pdinfo->size can change over time + +P_FMEDIA_INTERNAL media is internal (implicitly not removable) + +P_FMEDIA_DUAL_DENSITY device drive is dual density (if this is set then p_open (P_FFORMAT) can take +the optional p_FLowpENsiTy for a low density format) + +P_FMEDIA_FORMATTABLE media is formattable + + +The members pdinfo->size and pdinfo->free give the total capacity of the medium in bytes and how +much of that capacity is free (also in bytes) respectively. If p_rMzDIA_DYNAMIC is set in +pdinfo->mediatype (as it is for the internal RAM device m:), pdinfo->size and pdinfo->free may +change over time. + + +The volume name, with a maximum of 12 characters (for example, "DISKNAME.DSK"), 1s written as a zero +terminated string to spdinfo->name [0]. + + +The system is designed to be able to take advantage of hardware which can detect a low battery voltage in +a RAM SSD. When this is not possible (either because the medium is not a RAM SSD or because the +hardware does not support it), pdinfo->batterystate contains E_GEN_NsupP. If the SSD does contain a +battery and the hardware to detect a low voltage, pdinfo->batterystate contains FALSE if the battery is +low or TRUE (more precisely, a non-zero value other than E_cEN_NsupP) if the battery voltage is acceptable. +The content of this field is undefined for values of pdinfo->version less than 3. + + +The version field pdinfo->version is designed to allow future versions of p_dinfo (which would write +further information to pdinfo->spare[] to be identified by the caller. + + +In the following example, ListDevices produces a device list with some device information, including the +devices on REM:: (if the file server is connected to a remote file server) as well as Loc: :. + + +11-14 + + +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 + + +p_printf ("====s======= =S==S=S=S=S==== S=S=SSS==5== SSS 555 + + +p_open(&ncb, "FIL:",P_FNODE) ; +while (!p_iow(ncb,P_FREAD, &device[0],NULL) ) +{ +if (p_open(&dcb, &device[0],P_FDEVICE) ) +continue; + + +while (!p_iow(dcb,P_FREAD, &édevice [P_FSYSNAMESIZE],NULL) ) + + +{ +if ((ret=p_dinfo(&device[0],&dinfo) ) <0) + + +{ +p_errs (&bb[0],ret + + +i +p_printf("%- 12s %- 12s<%s>", &device[0],"**Failed**", sbb[0]); + + +continue; + + +} +p printf ("S- 12s 4- 12sS- lis S7IdK >10, (dinfo.free+512)>>10); + + +} +p_close(dcb); +} +p_close(ncb); + + +} + + +p_open(P_FFORMAT) + + +INT p_open(VOID **ppfcb, TEXT *name, UINT mode) ; +INT p_read(VOID *pfcb, VOID *buf, UINT len); +INT p_close(VOID *pfcb); + + +To format a medium in a device you: + + +11 FILES + + +Format a device + + +e call p_open with a mode of p_FrormatT to open a device format channel + + +e call p_read to get the total format count (optional) +e repeatedly call p_reaa until it returns E_FILE_EOF + + +e call p_close to close the device format channel + + +11-15 + + +PLIB REFERENCE + + +The name parameter to p_open should be a zero terminated file specification with a root directory (name is +parsed with a nuut related name) of the form: + + +LOC: :\ + + +to format the medium in , giving it the volume name . The volume name may +subsequently be changed using p_sfstat, described later in this chapter. + + +The mode parameter to p_open must be Pp_Frormat. If the device supports dual density formatting (as may +be established by calling p_dinfo), P_LFLOWDENSITY may be or'ed into mode to format at the lower density. + + +The call to p_open returns zero if successful. As well as the error numbers that can be returned by +p_fparse, p_open(P_FFORMAT) can also return one of the following negative error numbers: + + +E_GEN_NSUP the file system, device or medium does not support formatting +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) + + +At the time of writing, formatting is only supported on the Loc: : system on a SIBO machine. You can tell +in advance if a file system supports formatting by calling p_ninfo (described above). If the file system +does support formatting, you can tell if a device contains a formattable medium by calling p_dinfo (also +described above). + + +The first call to p_read writes a uworD total count to buf and returns zero. This count represents the +number of subsequent p_read calls required to complete the format. The 1en parameter to p_read is +ignored in all cases. + + +A call count can be combined with the total format count to present a percentage done indication. When +the format is complete, p_read returns E_FILE_EoF; you should then call p_close. Abandoning the +format, by calling p_close prematurely, will leave the medium in a corrupted state. + + +For example, the following function: + + +LOCAL_C VOID FormatDevice (TEXT *name) +{ +INT err,i; +UWORD count; +VOID *chan; +TEXT bb[E_MAX_ERROR_TEXT_SIZE]; + + +chan=NULL; + +if ((err=p_open(&chan, name, P_FFORMAT) ) <0) +goto exit; + +if ((err=p_read(chan, &count, 0) ) <0) +goto exit; + +p_printf ("Formatting %s count=%d",name, count) ; + +i=1; + +while ((err=p_read (chan, &val,0) ) >=0) +ploprint ( \rse05u", 2 ++); + +if (err==E_FILE_EOF) +err=0; + +exit: + +p_close(chan); + +if (err<0) +{ +p_errs (&bb[0],err); +p_printf("\r\nFormat failed: %s",&bb[0]); +} + +else +p_printf("\r\nFormat complete") ; + +} + + +could be called with: +FormatDevice ("LOC: :A:\\BACKUP") ; + + +to format the SSD in drive a:, giving it the volume name BACKUP. + + +11-16 + + +11 FILES + + +p_locdevice Read media information of a local device +INT p_locdevice (INT aDevice, UWORD *pMedia) ; +This function is only available in EPOC version 3.18 or later. + + +Write, to *pMedia, the media type of the local device (that is, a device on the toc: : file system) specified +by aDevice. The value of aDevice must be one of: + + +@ = 'M' (0x4d) + +e ='T (0x49) + +e ='A' (0x41) to 'H' (0x48) inclusive. +where 'T' (Internal) is an alias for 'M'. + + +Apart from two additional flags, the value written to *pmedia is the same as the value written to the +mediatype of a p_DINFo struct by p_dinfo. The call is more efficient than a call to p_dinfo, provided that +the media type is the only information that is required. + + +The two extra flags that may be written to *pMedia are &_FMEDIA_BATTERY_VALID and +E_FMEDIA_BATTERY_GooD, defined in epoc.h. If —_FMEDIA_BATTERY_VALID is not set then the device does +not support battery measurement. If it is set then E_FMEDIA_BATTERY_Goop Will be clear if the battery +voltage is too low, otherwise it will be set. + + +Returns zero or a negative error number. Errors that may be returned are: + + +E_FILE_NOTREADY no device is available +E_FILE_DEVICE the device specified by aDevice is not in the valid range of devices +E_GEN_NSUP no PDD exists which can handle the device + + +E_GEN_UNKNOWN + + +Note that the media does not have to be mountable for this service to work. + + +p_locreadpdd Direct read of local SSD +INT p_locreadpdd(INT aDevice, LONG *aPos, VOID *aPtr, UINT aLen); +This function is only available in EPOC version 3.18 or later. + + +Read, to the buffer pointed to by apt r, aLen bytes starting at an offset of *apos bytes into the SSD from +the local SSD (that is, an SSD on the toc: : file system) specified by aDevice. The data is read by means +of direct access to the physical device driver (PDD) and the reading is therefore very efficient. + + +The value of aDevice must be one of: + +e = 'M' (0x4d) + +e =6'T (0x49) + +e ='A' (0x41) to 'H' (0x48) inclusive. +where 'T' (Internal) is an alias for 'M'. + + +The medium must have been mounted prior to using this service. (To ensure the medium is mounted, just +make any normal device access.) + + +The service returns zero or one of the following negative error numbers: +E_GEN_OS the medium is not mounted + + +E_FILE_CORRUPT the specified offset is greater than the size of the SSD + + +11-17 + + +PLIB REFERENCE + + +Operations on directories and files + + +p_open(P_FDIR) Get a directory list + + +INT p_open(VOID **ppfcb, TEXT *name, UINT mode) ; +INT p_iow(VOID *pfcb, INT func, TEXT *buf, P_INFO *pinfo); +INT p_close(VOID *pfcb) ; + + +To get a list of files in a directory you: +e call p_open with a mode of P_FD1R to open a directory list channel + + +e repeatedly call p_iow with a func of P_FREAD to read each directory entry (until it returns +E_FILE_EOF) + + +e call p_close to close the directory list channel + + +The name parameter to p_open is a zero terminated file specification. Internally to the call to p_open, this +is parsed with a wild card related name (such as "*.*") that will find all files in the directory. It is +therefore not necessary to include a file name or file name extension in name unless you wish to restrict the +directory search to files with that name and/or extension. If present, the file name and the file name +extension in name would normally contain wildcards. Passing a name of "" produces the names of all the +files in the current directory. The parameter mode must be P_FDIR. + + +Each successful call to p_iow (P_FREAD) writes the next matching file name (excluding the node, device +and directory component) as a zero terminated string to buf (buf should have a capacity of P_FNAMESIZE +(128) bytes). The call to p_iow(P_FREAD) returns E_FILE_EOF after all the file names have been read. + + +If the parameter pinfo is not NULL it is taken as the address of a P_INFo struct where p_1nro is defined in +p_file.h as: + + +typedef struct { +UWORD version; +UWORD status; /* status bits */ + + +ULONG size; /* size of the file in bytes */ + +ULONG modst; /* system time of last modification */ +UBYTE spare[4]; + +} P_INFO;. + + +The file status pinfo->status has the following bit fields: + + +P_FAWRITE set if file is not read-only + +P_FAMOD set if the file has been modified + +P_FAHIDDEN set if file is hidden + +P_FASYSTEM set if file is a system file + +P_FADIR set if the file is a directory file + +P_FAVOLUME set if the file is a volume name directory + +P_FATEXT set if file is a text file + +Note that a directory read may return with a volume name written to buf and p_FAVOLUME set in + + +pinfo->status. This will only occur if the directory is a root directory of a PC-based device that has a +volume name. + + +A directory read only returns with P_FaTEXT set in pinfo->status when the file system can recognise a +text file. The toc: : file system cannot recognise text files but a remote file server, running on an +operating system (eg VMS) which can recognise text files, will set the p_raTExt bit as appropriate. + + +The field pinfo->size gives the logical file length (the end-of-file position). + + +The field pinfo->modst gives the time the file was last modified, expressed in system time format (the +number of seconds since 00:00:00 January 1 1970). See the chapter Time, Timers and Dates for details on +how to convert to and from the system time. + + +The p_inro file information may also be obtained when using p_finfo, described below. + + +11-18 + + +11 FILES + + +Example +#include +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("%Ss: %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("S- 12s S8lu %02u-%02u-%02u %02u:%02u Zs", +name, pinfo->size,dt.day+1,dt.month+1,dt.year,dt-.hour,dt.minute, &b[0]); +} + + +LOCAL_C VOID CDECL PrintDirList (TEXT *dir) +{ +INT err,NoFiles; +P_INFO info; +TEXT name [P_FNAMESIZE]; + + +if ((err=p_open (&dcb, dir, P_FDIR) ) !=0) +panic("Failed to open directory file",err); +NoFiles=TRUE; +while (! (err=p_iow(dcb, P_FREAD, &name[0],é&info) ) ) +{ +NoFiles=FALSE; +PrintDirLine(&name[0],&info); +} +p_close(dcb); dcb=NULL; +if (err!=E_FILE_EOF) +panic("Failed to read directory",ret); +if (NoFiles) +p_printf("No files found"); +} + + +GLDEF_C INT main(VOID) + + +{ +TEXT name [P_FNAMESIZE] ; + + +while (p_get1l(">", &name[0],P_FNAMESIZE) ) +p_enter((VOID *)PrintDirList, éname[0]); +return (0); + + +} + + +11-19 + + +PLIB REFERENCE + + +p_finfo Return file information + + +INT p_finfo(TEXT *name, P_INFO *pinfo); +INT p_finfoasync(TEXT *name, P_INFO *pinfo, WORD *stat); + + +Parse name with a NULL related name and write information about the specified file (which may be a +directory file) to the p_1NnFo struct at pinfo. The same file information is written to pinfo as is obtained +when using p_iow(P_FREAD) on a directory list channel that was opened with p_open(P_FDIR), as +described above. + + +The version field pinfo->version is designed to allow future versions of p_finfo (which would write +further information to pinfo->spare[]) to be identified by the caller. At the time of writing, +pinfo->version Is set to 2. + + +Returns zero if successful or a negative error number. As well as the p_fparse error numbers if the parse +fails, p_finfo can return: + + +E_FILE_DEVICE if the device does not exist +E_FILE_NOTREADY if the device does not contain a medium +E_FILE_DIR if the directory does not exist +E_FILE_NXIST if the file does not exist + + +The atomic nature of the p_finfo (unlike p_open) makes it a good choice for checking whether a file +exists (it returns E_FILE_NxtsT if the file does not exist). To test for the existence of a directory, you can +also use p_testpth, described below. + + +p_testpth Test for the existence of a directory + + +INT p_testpth(TEXT *dname) ; +INT p_testpthasync(TEXT *dname, WORD *stat); + + +Return zero if the directory component of the zero terminated file specification dname exists. + + +The file specification dname is parsed with a nuLt related name and any file name component is +discarded. + + +If the parse fails, p_testpth returns the error return from p_fparse. It can also fail with: + + +E_FILE_DEVICE if the device does not exist +E_FILE_NOTREADY if the device does not contain a medium +E_FILE_DIR if the directory does not exist + + +For example, if the current path is Loc: :a:\, then: +p_testpth("\\dirl\\dir2\\fred.c"); + + +returns zero if the directory Loc: :A:\DIR1\DIR2\ exists. + + +p_rename Rename a file or directory + + +INT p_rename (TEXT *oldname, TEXT *newname) ; +INT p_renameasync(TEXT *oldname, TEXT *newname, WORD *stat); + + +Parse each of newname and oldname with a NULL related name and, if successful, rename oldname to +newname. Both buffers should be at least P_rNames1zE bytes in length. + + +The file specified by oldname must exist and newname must not already exist. +Neither file name may include wild cards. + + +Both files should be on the same node and device. On Loc: :, files may be renamed across directories (but +this may not be supported by some remote systems). Prior to version 3.5 of EPOC, renaming across +directories can fail when the target directory is the root of Loc: :m:. + + +Directory files (which do not need to be empty) may be renamed, but not across different directories. + + +11-20 + + +11 FILES + + +The function returns zero if successful or a negative error number if it fails. As well as a p_fparse error +number if either oldname Or newnane fails to parse, p_rename can return the following error numbers: + + +E_FILE_DEVICE oldname and newname are on different devices or the device does not exist +E_FILE_NOTREADY the device does not contain a medium + +E_FILE_DIR the directory does not exist + +E_FILE_EXIST newname already exists + +E_FILE_NXIST oldname does not exist + +E_FILE_LOCKED oldname exists but a process has the file open + +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) +E_FILE_FULL not enough room on the medium for the rename (possible on Flash SSDs) + + +For example, if the current path is toc: :a:\, then: +p_rename ("\\dirl\\dir2\\fred.c", "\\dirl\\dir2\\jim.c"); +renames FRED.C iN LOC::A:\DIR1\DIR2\ to giIm.c while: +p_rename ("\\dirl\\dir2\\fred.c","fred.c"); +effectively moves FRED.c iN LOC: :A:\DIR1\DIR2\ to the root directory. +It is sometimes useful to parse newname With oldname as a related name before calling p_rename as in: + + +GLDEF_C INT RenameFile(TEXT *oldname, TEXT *newname) + + +{ +TEXT buf [P_FNAMESIZE]; + + +if (ret=p_fparse (newname, oldname, &buf[0],NULL) ) +return (ret); +return (p_rename (oldname, &buf[0])); + + +} +Then, for example, calling: +RenameFile("\\dir1l\\dir2\\fred.c","jim.c"); +renames FRED.C iN LOC: :A:\DIR1\DIR2\ to gim.c while: +RenameFile("\\dir1l\\dir2\\fred.c","\\jim.c"); + + +renames FRED.C IN LOC: :A:\DIR1\DIR2\ to gIm.c and moves Jim.c to the root directory. + + +p_delete Delete a file or directory + + +INT p_delete (TEXT *name) ; +INT p_deleteasync(TEXT *name, WORD *stat); + + +Parse name with a nui related name and, if successful, delete the specified file (which may be a directory +file). + + +A directory can not be deleted unless it is empty. + + +The function returns zero if successful or a negative error number if it fails. As well as a p_fparse error +number if name fails to parse, p_delete can return the following negative error numbers: + + +E_FILE_DEVICE the device does not exist + +E_FILE_NOTREADY the device does not contain a medium + +E_FILE_DIR the directory does not exist + +E_FILE_NXIST the file does not exist + +E_FILE_LOCKED a process has name open + +E_FILE_ACCESS name is a read-only file + +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) +E_FILE_EXIST name is a directory that contains files + + +11-21 + + +PLIB REFERENCE + + +For example, if the current path is Loc: :a:\, then: +p_delete("\\dir1l\\dir2\\fred.c"); + + +deletes Loc: :A:\DIR1\DIR2\FRED.C. + + +p_mkdir Make a new directory + + +INT p_mkdir (TEXT *name) ; +INT p_mkdirasync(TEXT *name, WORD *stat); + + +Parse name with a NULL related name and create the specified directory. The name of the directory to be +created is specified by the file name component of name if name contains a file name component. +Otherwise it is specified by the directory component of the parsed file specification. + + +Intermediate directories are also created if necessary. + + +Although unusual, there is no reason why a directory should not have an extension, and any extension in +name is significant. + + +The function returns zero if successful or a negative error number if it fails. As well as the p_fparse error +numbers returned if name fails to parse, p_mkdir can return the following negative error numbers: + + +E_FILE_DEVICE the device does not exist + +E_FILE_NOTREADY the device does not contain a medium + +E_FILE_EXIST the directory already exists + +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) +E_FILE_FULL there is no more room on the medium + +E_FILE_DIRFULL there is no more room in the root directory + + +For example, if the current path is Loc: :a:\, then either: +p_mkdir("\\dirl\\dir2\\"); + +or +p_mkdir("\\dirl\\dir2") ; + + +makes the directory Loc: :A:\DIR1\DIR2\ and also makes Loc: :A:\DIR1\ if it does not already exist. + + +p_sfstat Set file attributes or label medium + + +INT p_sfstat (TEXT *name, UINT status, UINT mask); +INT p_sfstatasync(TEXT *name, UINT status, UINT mask, WORD *stat); + + +Set or clear the attributes of the file specified by the zero terminated file name name (but see also Setting +the volume name below). Both status and mask contain a bit field made up of the following bit masks: + + +P_FAWRITE set if file may be written to +P_FAMOD set if the file has been modified +P_FAHIDDEN set if file is hidden + +P_FASYSTEM set if file is a system file + + +The function only modifies those bits that are set in mask where attribute is set or cleared depending on +the value of the corresponding bit in status. + + +11-22 + + +11 FILES + + +The function returns zero if successful or a negative error number if it fails. As well as a p_fparse error +number if name fails to parse, p_sfstat can return the following negative error numbers: + + +E_FILE_DEVICE the device does not exist + +E_FILE_NOTREADY the device does not contain a medium + +E_FILE_DIR the directory does not exist + +E_FILE_NXIST the file does not exist + +E_FILE_LOCKED a process has name open + +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) + + +For example: +p_sfstat ("joe.doc",0,P_FAWRITE) ; +makes the file joe.doc read-only. + + +Setting the volume label + + +If mask has the p_ravouume bit set, status 1s ignored p_sfstat and p_sfstat sets or deletes the volume +name. + + +At the time of writing, only the toc: : file system supports setting the volume label (the function returns +E_GEN_Nsup if it is not supported). + + +The name parameter should be a zero terminated file specification with a root directory (name is parsed +with a nuuu related name) of the form: + + +LOC: :\ + + +to label the medium in , giving it the volume name . If name does not contain a + component, the volume label is deleted. + + +The function returns zero if successful or a negative error number if it fails. As well as a p_fparse error +number if name fails to parse, p_sfstat can return the following negative error numbers: + + +E_FILE_DEVICE the device does not exist +E_FILE_NOTREADY the device does not contain a medium +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) + + +For example, if the current path is toc: :a:\, then: +p_sfstat ("d:\mydisk",0,P_FAVOLUME) ; +gives the medium in device Loc: :p: the label myprskx, +p_sfstat ("d:\diskname.dsk", 0,P_FAVOLUME) ; +gives the medium in device toc: :p: the label prsKName.psx and: +p_sfstat ("d:\",0,P_FAVOLUME) ; + + +deletes any volume name from device Loc: :D:. + + +p_fdate Set file creation date + + +INT p_fdate(TEXT *name, ULONG date); +INT p_fdateasync(TEXT *name, ULONG date, WORD *stat); + + +Set the file creation date to date where date is in the form of the system time - that is, the number of +seconds since January Ist 1970. + + +The date may not be set earlier than January Ist 1980. If p_fdate is called with any earlier system time, +the date is forced (without error) to January Ist 1980. + + +The system time used for the creation date is always converted to an even number of seconds (i.e. the least +significant bit of date is discarded). + + +11-23 + + +PLIB REFERENCE + + +The function returns zero if successful or a negative error number if it fails. As well as a p_fparse error +number if name fails to parse, p_fdate can return the following negative error numbers: + + +E_FILE_DEVICE the device does not exist + +E_FILE_NOTREADY the device does not contain a medium + +E_FILE_DIR the directory does not exist + +E_FILE_NXIST the file does not exist + +E_FILE_LOCKED a process has name open + +E_FILE_ACCESS name is a read-only file + +E_FILE_PROTECT the medium is write protected or is read-only (eg a ROM SSD) + + +The following example copies the date of fred.doc to fred.txt. + + +P_INFO info; + + +p_finfo("fred.doc", &info) ; +p_fdate("fred.txt",info.modst) ; + + +Binary file access + + +To open a file to be manipulated as a flat binary file, you call p_open with the 3rd parameter mode or'ed +with P_FSTREAM. For example: + + +p_open (&fcb, "fred.dat",P_FSTREAM|P_FSHARE) opens a file for reading only. +p_open (&fcb, "fred.dat",P_FSTREAM|P_FUPDATE |P_FREPLACE|P_FRANDOM) creates a writable binary file. +The mode flags (eg P_FREPLACE) are described under p_open, below. + + +There is no practical limit to the number of channels that may be opened in the system or by a particular +process. + + +Once you have opened a binary file channel, the possible I/O operations are: + + +p_read to read from the file channel +p_ioc (P_FREAD) +p_ioa(P_FREAD) + + +p_write to write to the file channel +p_ioc (P_FWRITE) +p_ioa (P_FWRITE) + + +p_close to close the file channel + +p_seek to set and sense the channel file position + +p_iow (P_FSETEOF) to set the logical end of file + +p_iow (P_FFLUSH) to flush the file buffers + +p_iow (P_FCANCEL) to cancel all pending asynchronous requests (not actively supported) + + +Bytes can be read or written to the file in any length up to a maximum of P_rMaxss12ZE bytes per read or +write. + + +Shared access + + +Any number of processes can open the same file for reading only (but only if all the readers specify +P_FSHARE when they open the file). However, the file server does not allow multiple processes to open a +channel to the same file for writing. + + +Once a file has been opened for reading, it may not be opened again for writing (but it may be opened +again for reading). Once a file has been opened for writing, it may not be opened again for reading or for +writing. + + +11-24 + + +11 FILES + + +If you have an multi-process application design which needs to update shared data, consider one of the +following: + + +e put the shared data in a named segment (see the chapter Memory Allocation) + + +e access the shared file data via a server process (see the chapter Processes and Inter-Process +Messaging) + + +Example of binary file access + + +The following example, which compares the contents of two files, uses many of the functions described in +this chapter. + + +#include +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 f£2={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 (%s)",msg, &pf->name[0],&bb[0]); +pf->ret=0; +} +} + + +LOCAL_C VOID Exit (TEXT *msg) + +{ + +if (fl.ret>=0 && f£2.ret>=0) +p_printf (msg); + +CleanUp (msg, &f1); + +CleanUp (msg, &f£2); + +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) ) +Exit ("parse"); + +if (pf->ret=p_open (&pf->chan, &pf->name [0], P_FSTREAM|P_FSHARE|P_FRANDOM) ) +Exit ("open") ; + +pf->len=0L; p_seek (pf->chan, P_FEND, &pf->len) ; + +pos=0L; 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"); + + +11-25 + + +PLIB REFERENCE + + +LOCAL_C VOID CDECL CompareFiles (TEXT *filel, TEXT *file2) +{ +OpenFile(&f1,filel,NULL) ; +OpenFile(&f2,file2,&f1.name[0]); +p_printf ("Compare %s (%1d)",&f1.name[0],f1.1len); +p_printf(" with %s (%ld)",&f2.name[0],f£2.len); +if (fl.len!=f2.1len) +Exit ("Files are of different length"); +FOREVER +{ +ReadFile(&f1); +ReadFile(&f2) ; +if (fl.ret==E_FILE_EOF && f2.ret==E_FILE_EOF) +{ +fl.ret=f2.ret=0; +Exit ("Files are identical"); +} +if (p_bcmp(&f1l.buf[0],fl.ret,&f2.buf[0],f£2.ret) ) +Exit ("Files are different"); + + +} + + +GLDEF_C INT main(VOID) +{ +TEXT *p; +TEXT bb[P_FNAMESIZE]; + + +while (p_getl("Enter ? ",&bb[0],P_FNAMESIZE) ) +{ +p=p_skipch(&bb[0]); +if (*p) +*p++=0; +p_enter((VOID *)CompareFiles, &bb[0],p_skipwh (p)); +} +return (0); + + +} + + +The program solicits two file names to compare (where the second name is parsed with the first name as a +related name in CompareFiles) and reports whether they are the same or different. As well as illustrating +binary file access, the example gives a realistic illustration of the use of p_enter and p_leave. Note also +that the function cleanup takes advantage of the fact that p_close (NULL) is harmless. + + +p_open(P_FSTREAM) Open a binary file +INT p_open(VOID **ppfcb, TEXT *name, UINT mode); + + +Open a channel to the file specified by the zero terminated file specification name and, if successful, return +zero and write the channel to *ppfcb (ppfcb is not written to if the open fails). To open a file to be +manipulated as a flat binary file, mode should be or'ed with P_FsTREAM. + + +The file specification name is parsed with a nutt related file name (see p_fparse). If this fails, the open +fails and returns the return value from p_fparse. + + +The mode in which the file is opened is selected by oring in one (and only one) of the following bit fields +into mode: + + +P_FOPEN Open an existing file. If the file does not exist, the error E_LFILE_NXIST is +returned. This option would normally only be used to open a file for read +access. + +P_FCREATE Create a file which must not already exist. If the file does exist, the error + + +E_FILE_EXIST is returned. To enable write access to the file you must specify +P_FUPDATE (described below). + + +P_FREPLACE If the file exists, open it and truncate it to zero length. If the file does not exist, +then create a file. To enable write access to the file you must specify P_FUPDATE +(described below). + +P_FAPPEND This is the same as for P_FOPEN except that the initial current position is set to + + +the end of file such that the next write will append to the file. It is not necessary +to specify P_FRaNnpDom (described below) but to enable write access to the file you +must specify P_FUPDATE (described below). + + +11-26 + + +11 FILES + + +P_FUNIQUE Create a unique file using the passed path as the related path name in which to +create the file. The unique file name is written back to name (there should be +room for p_FNAMESIzE bytes). It is not necessary to specify p_FUPDATE +(described below). + + +The access which is subsequently permitted is formed by oring together a combination of the following +flags in mode: + + +P_FUPDATE specifies that write access as well as read access is required for the file. If an +attempt is made to write to a file when this flag has not been set, the error +E_FILE_RDONLY is returned. + + +P_FRANDOM specifies that random access (as opposed to sequential access) is required for +the file. If a call is made to p_seek with a file that has not been opened with +this option, the error E_FILE_INv is returned. You should not specify +P_FRANDoM unless you do intend to use p_seek because the file system may be +able to optimise the device access if it knows that only sequential access is +required. + + +P_FSHARE specifies that this open should not block the file from being opened again for +read access. If this flag is not set, a subsequent request to open a file (by the +same or another process) will fail with z_FILE_LOCKED. + + +Note that shared write access is not supported and p_rsHare can not be combined with p_ruppaTE. + + +Returns zero if successful or a negative error number if it fails. As well as the p_fparse error numbers +which may be returned if name fails to parse, p_open (P_FSTREAM) can return the following negative error +numbers: + + +E_GEN_NOMEMORY failed to allocate memory for the control block + +E_GEN_ARG mode contains an illegal combination of flags + +E_FILE_DEVICE the device does not exist + +E_FILE_NOTREADY the device does not contain a medium + +E_FILE_EXIST attempt to create a file which already exists + +E_FILE_NXIST attempt to open a file which does not exist + +E_FILE_ACCESS access to the file in the requested mode is not available + +E_FILE_DIRFULL there is no more room in the root directory + +E_FILE_PROTECT attempted to create/replace when the medium is write protected or is read-only +(eg a ROM SSD) + +E_FILE_FULL there is no room on the device to create/replace this file + +E_FILE_LOCKED the file is already open (possibly by another process) + +E_FILE_DEVICE the device in name does not exist + +E_FILE_DIR the directory in name does not exist + +p_close Close a binary file channel + + +INT p_close(VOID *pfcb) ; +Close the binary file channel pfcb and return zero if successful. If pcb is NULL, just return zero. + + +Although p_close can return an error, it will always succeed in closing the channel (and pfcb should not +be used subsequently). + + +If the file system buffers written data, the close operation may need to perform one or more write +operations on closing. Even if written data is not buffered, if data has been written to the file, the close +will update the modification date on the file. Because of this, p_close can return the some of the errors +numbers which can be returned from p_write and p_fdate. However, the failure to flush the data or to +write the new date will not cause the close operation to be aborted although the failure will be reported by +an error return. + + +11-27 + + +PLIB REFERENCE + + +Carefully written applications avoid this problem by using p_iow(P_FFLUSH) to flush the data and to apply +the date (and taking appropriate action if this fails) before closing the channel without risk of failure. + + +The toc: : file system on SIBO machines does not buffer written data. When EPOC is running on a PC, +the Loc:: file system is built over the MSDOS filing system which does buffer written data. + + +p_read Read from a binary file channel +INT p_read(VOID *pfcb, VOID *buf, UINT len); + + +Reads 1en bytes or the number of bytes remaining before the end of file, whichever is smaller, from the +current position of binary file channel pfcb and writes the data to buf. The current position is incremented +by the number of bytes read. + + +If the current position is already at the end of file, zero bytes are read and the negative error number +E_FILE_EOF is returned. + + +The parameter len must not be greater than p_rmaxss1zE (16K bytes). + + +The most efficient way of processing files is to read in multiples of P_rFBLKs1zE (512) while ensuring that +the file position remains on P_FBLKS1zE boundaries. + + +The function returns the number of bytes written to buf if successful or one of the following negative +error numbers: + + +E_FILE_EOF end of file encountered + + +E_FILE_ABORT the SSD containing the file is or was previously not present and the channel is +now in the abort state + + +E_FILE_READ failed to read from the file (eg because of a CRC failure on a floppy disk) + + +p_write Write to a binary file channel +INT p_write(VOID *pfcb, VOID *buf, UINT len); + + +Write len bytes from buf to file channel pfcb at the current file position. The current position is +incremented by the number of bytes written. + + +The parameter len must not be greater than p_rMaxss1zE (16K bytes). + + +The most efficient way of processing files is to write in multiples of P_FBLKs1z=z (512) while ensuring that +the file position remains on P_FBLKS1ZE boundaries. + + +When writing to Flash SSDs, you can physically overwrite a single byte (where len is one) provided that +the new byte can be written by just clearing bits in the old byte. In general, overwriting data on a Flash +SSD-based file will consume space and reduce the remaining capacity of the SSD. + + +The function returns zero if successful or one of the following negative error numbers: + + +E_FILE_FULL not enough room on the device for the data + +E_FILE_RDONLY the file channel was opened without the Pp_rupDaTE access bit set + +E_FILE_ABORT the SSD containing the file is or was previously not present and the channel is +now in the abort state + +E_FILE_WRITE failed to write to the file (eg because of a CRC failure on a floppy disk) + +E_GEN_BATFLASH failed to write to the file because the batteries are too low to write to a Flash +SSD + + +11-28 + + +11 FILES + + +p_seek (or f_seek) Position a binary file channel + + +INT p_seek (VOID *pfcb, INT sense, LONG *ppos) ; +INT f_seek(VOID *pfcb, INT sense, LONG *pos); + + +Set the current file position of file channel pfcb to a new file position which depends on sense and +*ppos, where sense is one Of: + + +P_FABS to set the current file position to *ppos + +P_FEND to set the current file position to *ppos relative to the current end-of-file +position + +P_FCUR to set the current file position to *ppos relative to the current file position + + +If successful, the new file position (which may be the same as the old) is written to *ppos and p_seek +returns zero. Otherwise, it returns one of the following negative error numbers: + + +E_FILE_INV the channel was not opened with p_rranpom + + +E_FILE_ABORT the SSD containing the file is or was previously not present and the channel is +now in the abort state + + +If the channel was opened with p_rsTREAM_TEXT on a remote file system, the full p_rszEx functionality +may not be supported. When this is the case, p_seek fails with r_F1LE_1nv. However, the following is +always supported on Pp_rSTREAM_TEXxT channels: + + +¢ using p_rass to set the current position to zero + + +¢ using p_FEND with a zero relative position to set the current position to the end of the file +(although with p_rsTREAM_TExT you should not use the value which is written to *ppos) + + +If calling p_seek results in an absolute file position which is negative then the file is positioned at the +beginning of the file. If the absolute file position is greater than the end of file then the new position is set +to the end of file. See p_iow(P_FSETEOF) for setting a new end of file. + + +The function £_seek is identical to p_seek except that, if there is an error, it calls p_leave (err) rather +than return the negative error number err. + + +For example, if the current file position is 0x2000 then +LONG pos; + + +pos=256L; +p_seek (pfcb, P_FCUR, &pos) ; + + +sets the current position to 0x2100 and + + +pos=-256L; +p_seek (pfcb, P_FCUR, &pos) ; + + +sets the current position to 0x1f£00 and + + +pos=0L; +p_seek (pfcb, P_FCUR, &pos) ; + + +does not change the current position but could be used to sense the current position (pos contains 0x2000 +after p_seek has returned). If the current end of file is 0x4000 then + + +pos=0L; +p_seek (pfcb, P_FEND, &pos) ; + + +sets the current position to the end of the file and senses the length of the file (pos contains 0x4000 after +p_seek has returned). To set the current position to the beginning of the file, use: + + +pos=0L; +p_seek (pfcb, P_FABS, &pos) ; + + +11-29 + + +PLIB REFERENCE + + +p_iow(P_FFLUSH) Flush internal file buffers + + +INT p_iow(VOID *pfcb, P_FFLUSH) ; +Flush all buffered written data to binary file channel pfcb and write the file's modification date. +Returns zero if successful (the negative error number returns are as for p_write). + + +The amount of information which is flushed depends on the file system and on the medium in the drive. +The RAM and Flash SSD PDDs do not buffer any file data (in this case, calling p_iow(P_FFLUSH) just +writes the file date). On Flash SSDs the last record written is held open until the file is closed or a write +occurs to another file on the same SSD (see the section Flash SSDs at the beginning of this chapter). +When EPOC is running on a PC, written file data is buffered to improve performance. Calling +p_iow(P_FFLUSH) will ensure that any buffered data is written to the file but repeated flushing is likely to +degrade performance. + + +Although harmless, there is absolutely no benefit in calling p_iow(P_FFrLusH) on file channels which were +opened without the p_ruppateE flag. + + +p_iow(P_FSETEOF) Set end of file + + +INT p_iow(VOID *pfcb, P_FSETEOF, ULONG *peof); + + +Set the logical end of file on channel pfcb to position *peof and return zero if successful (the negative +error number returns are as for p_write). The file channel must have been opened with p_FuPDATE. + + +If *peof is greater than the current end of file, the file size is extended to *peof. On block-structured +devices (ie excluding Flash SSDs), this is equivalent to appending indeterminate data to the end of the file +to pre-allocate storage. (It is not useful to extend a file on a Flash SSD.) The current position is not +affected when the file is extended with p_iow(P_FSETEOF). + + +If *peof is less than the current end of file, the file is truncated to *peof (the current position is also +reduced if necessary to the new end of file). + + +p_iow(P_FCANCEL) Cancel an asynchronous file channel request +INT p_iow(VOID *pfcb, P_FCANCEL) ; +Cancel all asynchronous I/O requests on channel pfcb and return zero. + + +The operation is harmless if no request is pending. In fact, for reasons which were described at the +beginning of this chapter (under the heading Asynchronous file operations), a call to p_iow (P_FCANCEL) +has no effect even when a request is pending. + + +However, if you are performing asynchronous file access (which is not at all common) you may (for the +sake of consistency and provided the status word is currently E_LFILE_PENDING) Use p_iow(P_FCANCEL) - +normally followed by a call to p_waitstat - to effect cancellation as you would do for any other +asynchronous request. It is always possible that a future implementation of the file server may process +P_FCANCEL operations. + + +At the time of writing, a preferable alternative is to simulate a cancel service, as illustrated in the earlier +example, under the heading Asynchronous file operations. + + +Stream text file access + + +Different file systems vary in their support of a text file type and (if such support is provided) implement +text files in different ways. + + +Some systems (for example, DEC's VMS operating system which runs on a Vax) support text file types +that are not implemented as crLF terminated records. Other systems (such as MSDOS, UNIX and the +EPOC toc: : file system on a SIBO machine or a PC) do not support a text file type, and on such systems +the following convention predominates: + + +e text records are terminated by a cRLF sequence - a carriage return (code 13) followed by a line +feed (code 10) + + +e a file may optionally be terminated by a sus character (code 26) + + +The terminating sus is not necessary on systems that store a logical file length and it is falling out of use. + + +11-30 + + +11 FILES + + +Applications running under EPOC that read or write text files can choose either to process the records in a +text file themselves, or to take advantage of the system's text file handling. The system support for text +files, using p_open (P_FTEXT) , is described in the next section of this chapter. + + +Applications that do their own text file processing, for performance purposes or otherwise, should use +p_open (P_FSTREAM_TEXT) in preference to p_open (P_FSTREAM) . + + +Using p_FsTREAM_TEXT when opening such a text file on the rem: : file system declares the intention that +the file is to be considered as a text file. It causes the remote file server to present the data from the file +as if it were implemented with criF terminated records. In more detail, this presentation layer does the +following: + + +when reading the text record content on the remote system is converted to that content +followed by a cRLF + + +when writing the data is parsed for crLF record terminators and converted into text records +on the remote system (the parser will also recognise cr, LF Or LFCR as a record +terminator) + + +Although in many cases (and certainly when opening a local file) opening with p_rsTREAM_TEXT has an +identical effect to opening with p_rsTReaw, there is no guarantee that the effect will be the same on a +remote file. There is no penalty to using p_rsTREAM_TExT - only a potential gain when accessing a remote +file. + + +The upshot of all this is... + + +All this sounds very complicated (and it is - especially for the implementor of the remote file server) but +you should trust the system and just remember this: + + +To open a text file to be manipulated as a flat binary file, you should call p_open with + +mode or'ed with p_rsTREAM_TEXT and not p_FSTREAM. +With the exception of p_open, all functions are exactly as for flat binary files, described in the previous +section. + + +p_open(P_FSTREAM_TEXT) Open a stream text file + + +INT p_open(VOID **ppfcb, TEXT *name, UINT mode); + + +Open a channel to the file specified by the zero terminated file specification name and, if successful, return +zero and write the channel to *ppfcb (ppfcb is not written to if the open fails). + + +To open a stream text file (a text file to be manipulated as a flat binary file) mode should be or'ed with +P_FSTREAM_TEXT. + + +For all other details, see the description p_open (P_FSTREAM) in the previous section. + + +Text file access + + +To open a file to be manipulated as a record oriented text file, you call p_open with the 3rd parameter +mode or'ed with p_rtext. For example: + + +p_open (&fcb, "fred. lis",P_FTEXT|P_FSHARE) opens a text file for reading only. +p_open (&fcb, "fred. lis", P_FTEXT|P_FUPDATE|P_FREPLACE) creates a text file which may be written to. +Once you have opened a text file channel, the possible I/O operations are: + + +p_read to read the next text record from the file channel +p_ioc (P_FREAD) +p_ioa(P_FREAD) + + +p_write to append a text record to the file channel +p_ioc (P_FWRITE) +p_ioa (P_FWRITE) + + +p_close to close the text file channel + + +11-31 + + +PLIB REFERENCE + + +p_seek to set and sense the channel file position + +p_iow (P_FSETEOF) to set the logical end of file + +p_iow (P_FFLUSH) to flush the file buffers + +p_iow (P_FCANCEL) to cancel all pending asynchronous requests (not actively supported) + + +The text file handling is not part of the file server but is implemented as a layer of code over the +P_FSTREAM_TEXT binary file access. The text file handling code runs in the caller's context ("on the client +side") in the same way as regular function calls. This layer of code is inserted between the application and +the file server by the F1L: device driver p_open code when it sees the P_FTEXT bit set in the mode +parameter. The data is, however, buffered in this layer, so flushing is necessary to ensure that any buffered +data is written to the file. + + +Implementing the code as a layer over P_FSTREAM_TEXT binary file access makes it independent of the file +system node which is providing the services. + + +What text file handling does +The text file handling assumes that text files obey the following conventions: + + +e text records are terminated by a cRLF sequence - a carriage return (code 13) followed by a line +feed (code 10) + + +e a file may optionally be terminated by a sus character (code 26) + + +The text file handling also assumes that the record content (excluding the record termination) does not +exceed a length of P_rmMaxRs1zE (256) bytes. A text record may not contain cr, LF or suB characters, but +there is no other restriction on the contents. + + +When reading a file, the text file handling parses a stream of bytes for cRLF record terminators such that +the application gets the data a record at a time (excluding the terminator). The parser will also recognise +CR, LF, LFCR or a SUB as a record terminator. If it sees a sus (either as a record terminator or immediately +after a CRLF, CR, LF Of LFCR record terminator), it will behave as if the end of file had been reached. + + +When writing to a file, the text file handling simply adds the record terminator (which is always CRLF) to +the end of the record data. A terminating svuB is not written. + + +For enthusiasts ... +This is for interest only and may certainly be skipped. + + +In case you were wondering what the Txt: device is, text file handling is implemented as an I/O device +driver (txT:) which layers over the FIL: P_FSTREAM_TEXT mode binary file access (which was described +in the previous section). The Fru: device redirects the p_open to TxT: when P_FTEXT is set in mode. This +means that the following calls to p_open: + + +p_open(&fcb, "fred.dat", P_FTEXT|P_FUPDATE|P_FREPLACE) ; +p_open (&fcb, "FIL: fred.dat", P_FTEXT|P_FUPDATE|P_FREPLACE) ; +p_open (&fcb, "TXT: fred.dat", P_FUPDATE |P_FREPLACE) ; + + +are all equivalent. (The above examples are provided to help de-mystify the I/O system and the FIL: +device and it would be obscure to use TxT: without good cause.) + + +p_open(P_FTEXT) Open a text file +INT p_open(VOID **ppfcb, TEXT *name, UINT mode); +Open a file to be manipulated as a record oriented text file where mode should be or'ed with P_FTExT. + + +Except for the use of P_FTEXT in place of P_FSTREAM or P_FSTREAM_TEXT, the parameters and returns are as +for opening a binary file, described in the previous section. + + +p_close Close a text file channel +INT p_close(VOID *pfcb); +Close the text file channel pfcb and return zero if successful. + + +Since text written to the file is buffered in the device driver, p_close may give rise to an E_FILE_WRITE +error. It is therefore advisable to call p_iow(pP_FFLusH) before calling p_close. Otherwise, the behaviour +and returns are as for closing a binary file, described in the previous section. + + +11-32 + + +11 FILES + + +p_read Read from a text file channel + + +INT p_read(VOID *pfcb, VOID *buf, UINT len); + + +Read the contents of the current record (ie excluding any record terminators) from text file channel pfcb, +writing up to 1en bytes to buf and, if successful, return the length of the record read (which is also the +number of bytes written to buf). The channel is positioned to the next record. + + +If 1en is less than the length of the current record, the first 1en bytes from the record are read and p_read +returns the negative E_FILE_RECoRD. The channel is still positioned to the next record. + + +Note that p_read returns zero if it encounters a record of zero length. + + +After the last record is read, the channel is positioned to the end of the file. When the channel is +positioned at the end of the file, p_ read returns the negative =_F1ILE_koF (nothing is written to buf). + + +Other negative error returns are: + + +E_FILE_ABORT the SSD containing the file is or was previously not present and the channel is +now in the abort state + +E_FILE_READ failed to read from the file (eg because of a CRC failure on a floppy disk) + +Example + + +LOCAL_D VOID *fcb=NULL; + + +LOCAL_C INT CDECL SearchFile(TEXT *file, TEXT *pattern) +{ +INT ret; +TEXT line [P_FMAXRSIZE+2]; + + +if (ret=p_open(&fcb, file, P_FTEXT) ) +panic("Failed to open file",ret); +while ((ret=p_read(fcb, &line[0],P_FMAXRSIZE) ) >=0) +{ +line [ret]=0; +if (ret && p_smatchi(é&line[0],pattern) ) +p_printf(&line[0]); +} +p_close(fcb); +if (ret!=E_FILE_EOF) +panic("Failed to read file",ret); +return (0); + + +} + + +p_write Write to a text file channel + + +INT p_write(VOID *pfcb, VOID *buf, UINT len); + + +Write a record of length 1en bytes (where 1en is zero to p_FMAxRS1ZE inclusive) from buf to the text file +channel pfcb. Returns zero if successful or one of the following negative error numbers: + + +E_FILE_FULL not enough room on the medium for the data + +E_FILE_RECORD the record size exceeds P_FMAXRSIZE + +E_FILE_RDONLY the file channel is opened without p_ruppatE being set in mode + +E_FILE_ABORT the SSD containing the file is or was previously not present and the channel is +now in the abort state + +E_FILE_WRITE failed to write to the file (eg because of a CRC failure on a floppy disk) + + +Records are always written to the end of file. + + +The data between buf and buf+1en should not include any record delimiters. + + +11-33 + + +PLIB REFERENCE + + +p_seek (or f_seek) Position a text file channel + + +INT p_seek (VOID *pfcb, INT sense, LONG *ppos) ; +INT f_seek(VOID *pfcb, INT sense, LONG *pos); + + +Set the current record position of text file channel pfcb to a position which depends on sense and *ppos, +where sense is one Of: + + +P_FREWIND to position to the first record (the value of ppos is ignored) +P_FRSENSE to get the position of the last record read or written +P_FRSET to set the record position which was previously got with a call to + + +p_seek (P_FRSENSE) +Returns zero if successful or the negative E_FILE_1nv if the file was not opened with P_FRANDoM. + + +Some remote file systems may not be capable of supporting p_seek (P_FRSET) and p_seek (P_FRSENSE) +and in this case p_seek will return E_FILE_INV. + + +The function f_seek is identical to p_seek except that, if there is an error, it calls p_leave (err) rather +than return the negative error number err. + + +It is important to note that this function sets the current record position for read operations only. Records +are always written at the end of file. + + +Example + + +while ((len=p_read(fcb, &buf[0],P_FMAXRSIZE) )>0) +{ +buf [len]=0; +if (buf[0]==':') +{ +p_seek (fcb, P_FRSENSE, &pos) ; +StoreLabel (&buf[1],pos); +} + + +p_iow(P_FFLUSH) Flush internal file buffers + + +INT p_iow(VOID *pfcb, P_FFLUSH) ; +Flush all buffered written data to text file channel pfcb and write the file's modification date. + + +The behaviour and returns are as for flushing a binary file, described in the previous section. Unlike the +binary file, however, data is buffered for all file systems and media. + + +p_iow(P_FSETEOF) Set end of text file + + +INT p_iow(VOID *pfcb, P_FSETEOF, ULONG *peof); +Set the logical end of file on channel pfcb to position *peof. + + +Behaviour and returns are as for flushing a binary file, described in the previous section. + + +p_iow(P_FCANCEL) Cancel an asynchronous file channel request +INT p_iow(VOID *pfcb, P_FCANCEL) ; +Cancel all asynchronous I/O requests on channel pfcb and return zero. + + +The behaviour and return values are as for cancelling a binary file request, described in the previous +section. + + +At the time of writing, a preferable alternative is to simulate a cancel service, as illustrated in the earlier +example, under the heading Asynchronous file operations. + + +11-34 + + +CHAPTER 12 + + +PROCESSES AND INTER-PROCESS MESSAGING + + +Processes + + +A process is a running program. It is normally created by loading an image file (also called an executable) +using p_execc. After loading the program, the process creator normally calls p_presume to start the +process running. + + +EPOC is a single-user multi-tasking operating system that rapidly switches contexts between a number of +independent processes - creating, at times, the illusion of multiple processes running in parallel. + + +The maximum number of processes that may exist is E_MAX_PROCESSES (24). + + +At any particular time, one process is actually running. On a reschedule, EPOC runs the process with the +highest priority that is ready to run. If there is only one ready process at the highest priority it will +continue to run indefinitely (and any lower priority ready processes will wait indefinitely). + + +Preemptive multi-tasking means that the running process may be replaced at any time - it does not have to +make a system call to yield the processor. A process which becomes ready will immediately run if it has +the highest priority. + + +If there is more than one ready process with the highest priority then each process is made current for a +fixed time period (4 system ticks) after which the operating system makes the next process of that priority +current in what is called a "round robin" fashion. On a SIBO machine, the system "ticks" 32 times a +second. + + +Because EPOC is a single-user system, the current process is comparatively rarely switched out by the +system tick. It is more likely to stop running because an event occurred that made a higher priority process +become ready or because the current process voluntarily gave up its ready status to wait for an event to +occur. + + +In EPOC, a process consists of at least the following: +e aprocess control block (described below) + + +e adata segment, containing the processor stack, static variables and the heap (as described in the +Memory Allocation chapter) + + +¢ aprimary code segment (which is shared if there are one or more other processes of the same +program) + + +e an I/O semaphore (as described in the chapter Asynchronous Requests and Semaphores) + + +On SIBO machines, a process that tries to write to a memory segment other than its own data segment +(except via functions that explicitly allow such activity) is panicked with panic number 60. + + +A code segment may exist in ROM or it may be loaded into a RAM memory segment from an executable. + + +A process may acquire other resources during its lifetime - for example, I/O channels or additional code +segments. The system automatically releases owned resources such as memory segments, I/O channels +and semaphores when it terminates. Server processes are also designed to clean up client resources when a +client process terminates. + + +12-1 + + +PLIB REFERENCE + + +System processes + + +When the operating system initialises itself, it creates a number of system processes some of which are +essential to the operation of EPOC. + + +After a system reset on a typical machine running EPOC, the system processes (by process name) are: + + +SYSSNULL.$01 the zero priority null process runs when no other process is ready to run and +switches the machine off (to reduce power consumption) after a period of +inactivity + +SYSSMANG.$02 the supervisor has a higher priority than any other process and performs many + + +critical system functions including memory segment moving and resource +clean-up when a process terminates + + +SYSSFSRV.$03 the file server (described in the Files chapter) has the second highest priority +and performs all file related operations, including loading an image to create a +process + +SYSSWSRV.$04 the window server (described in the Window Server manual) provides shared + + +access to the screen, keyboard and, if present, the digitiser (or mouse on a PC) + + +SYSS$SHLL.$05 the shell process provides a user interface that allows other processes to be +started (on a custom system it might provide a "turnkey" environment) + + +The extension of the process name gives the process number (assigned by the operating system). The +structure of process names is described later in this chapter. + + +The functions (described in this chapter) which change the process name, change the process priority and +suspend a process will fail when applied to syssnuLL, sySSMANG and SYSSFSRV. + + +On systems with a digitiser (or mouse), the window server creates a subsidiary process, sharing its data +segment, to draw the mouse icon. In EPOC, a subsidiary process that shares the data segment of its owner +is called a task and the window server task has a name such as sys$wsRV.@05. + + +The notifier service p_notify (described in the chapter Error Handling) may be provided by the window +server itself or it may be provided by a client of the window server. If a separate notifier exists, it has a +process name such as SYS$NTIFY.$07. + + +Process ID and process control block +Each process is identified by its process ID - a positive 16-bit number containing two bit fields: + + +e = The least significant 12 bits is the offset of the process control block in the operating system data +segment (also called the process slot). + + +e The most significant 4 bits contains a value in the range 0-7 (note that a valid process ID is +positive). This value is incremented modulo 8 each time a process slot is used so that a process +ID may be rejected after a process has terminated. + + +The function p_getpid returns the process ID of the caller. + + +If a system function is passed a process ID that is zero or negative, or in which the least significant 12 bits +is outside the range of the process table, the caller is panicked with panic number 7 (invalid process ID). + + +12-2 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The structure of the process control block is defined by the &_proc struct, defined in epoc.h as: + + +typedef struct e_proc + + +{ + + +struct e_proc *next; + + +struct e_proc *prev; +WORD queKey; +WORD queData; +deltaType; +addressTrap; + + +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UBYT +UWOR +UBYT +UBYT +UWOR +UBYT +UWORD + + +E +E +E +E +E +E +E +E +E +E +D +E +E +D +E + + +status; +sstatus; +priority; + + +priorityH; + + +ramOrRom; +isTask; + + +name [E_MAX_NAME+1]; + + +active; + + +semaphore; + + +*semHead; + + +*memBasePtr; + + +memGrowBy; +*mCtrlPtr; + + +minHeap; + + +HANDLE fServer; +HANDLE dataSeg; +HANDLE codeSeg; + + +UBYTE +UBYTE +UBYTE +UBYTE +UWORD +UWORD +UWORD + + +*saveSP; +*saveBP; +notify; +sndSem; +magic; +checkSum; + + +terminate; +} E_PROC;. + + +A copy of a process control block may be obtained by calling p_getosd (where zE_p1pMaskx is used to +mask out the address portion from the process ID) as follows: + + +E_PROC pcb; + + +p_getosd(&pcb, (VOID *) (pid&E_PIDMASK), sizeof (pcb) ); + + +Many of the fields of z_pRoc are described in the course of this chapter. The remaining fields are reserved +for system use. As an aside, and for the reader's interest, some miscellaneous fields (which would not +otherwise be described) are described below. It must be emphasised that none of these fields should be +modified directly by any application code. + + +sstatus + + +ramOrRom + + +isTask + + +active + + +semaphore + + +memBasePtr + + +memGrowBy + + +mCtrlPtr + + +TRUE if the process is waiting to be suspended (for example, if suspended while +on the time delta queue - on leaving the queue it will be suspended rather than +entering the ready queue) + + +TRUE if the process code segment is in RAM, ratss if the code segment is in +ROM + + +TRUE if the process is a task (a subsidiary process that shares the data segment +of its creator) + + +TRUE if the running of this process will stop the machine from switching off - as +set by p_marka and p_unmarka + + +the handle of the process I/O semaphore + + +the address of the start of the heap (4 bytes before that obtained from +p_allspace) + + +the heap granularity in paragraphs as set by p_hgran + + +contains the address of the message control block as set up by p_minit or zero +if p_minit has not been called + + +12-3 + + +PLIB REFERENCE + + +minHeap the minimum heap size in paragraphs + + +fServer the client ID as given by the file server or zero if the process has not connected +to the file server + + +dataSeg the handle of the process data segment + + +codeSeg the handle of the process code segment if the code is in RAM or the paragraph +address of the code segment if the code is in ROM + + +notify the notifier state as set by p_sentnotify (and sensed by p_getnotify) + + +sndSem TRUE if the process is waiting on the sound semaphore, to indicate the need to +call p_signal on termination of the process + + +magic the top 4 bits of the process ID, used to reject a process ID of a process that no +longer exists - even when another process has been created and re-uses the +same process slot + + +terminate contains the termination message type as set by p_onterminate or zero if +p_onterminate has not been called + + +Process states + + +Each process is in one of the following states (as stored in pcb. status): + + +E_PROC_CURRENT the process that is currently running (at any time, one process is in this state) +E_PROC_READY the process is waiting for a chance to run +E_PROC_SEMAPHORE the process is waiting on a semaphore, most likely its I/O semaphore +pcb. semaphore (described in the chapter Asynchronous Requests and +Semaphores) +E_PROC_DELTA the process is waiting in the timer delta queue (described in the chapter Time, + + +Timers and Dates) +E_PROC_SUSPENDED the process exists but will not run until it is resumed by calling p_presume + + +Process queues + + +Processes that are in the READY, SEMAPHORE Or DELTA State are in a doubly-linked queue (using pcb. next +and pcb. prev - see queues in the chapter Characters, Strings, Buffers and Queues). + + +The READY queue is ordered by the process priority as stored in pcb. priority. + + +Each semaphore heads a SEMAPHORE queue. This queue may be empty, or may contain one or more +processes in a first-in, first-out order. + + +The DELTA queue is a special kind of doubly-linked queue (called a delta queue, as described in +Characters, Strings, Buffers and Queues). It stores the time interval in system ticks between timer entries. + + +These queues are described in more detail in the chapter Asynchronous Requests and Semaphores. + + +Process priorities + + +When there is more than one process that is ready to run, the operating system runs the process with the +highest priority (an unsigned byte value in the range 1 to 255). Lower priority processes are blocked +indefinitely. + + +If there is more than one ready process with the same highest priority, they take it in turns to run every +four system ticks. + + +Applications should set their priority in the range E_MIN_PRIORITY (64) to E_MAX_PRIORITY (192) +inclusive (the operating system reserves the values outside this range). + + +The initial process priority is normally taken from a value stored in the program file or image (and is +generated by the tool used to build the image) but it may subsequently be changed using p_setpri +(p_getpri returns the priority of a process). + + +12-4 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +Interactive application processes that are clients of the window server are normally created at the priority +E_PRIORITY_FORE (128) and subsequently leave it to the window server to change their priority depending +on whether the process is receiving user input or not. See the Window Server manual. + + +The supervisor runs at priority 248 and the file server at priority 240. A hardware interrupt runs at the +same priority as the process it interrupts. Critical sections of interrupt code are protected by switching off +pre-emption. + + +Preemptive scheduling + + +It is possible for a process to run for as long as it wants to and, in practice, this often happens. In this +case, the current process eventually gives up its cuRRENT state by changing its state to: + + +SEMAPHORE by calling p_iowait to wait on the I/O semaphore (or p_wait to wait on any +semaphore) + +DELTA by calling p_sleep, p_sleept OF p_sleepa + +SUSPENDED by calling p_psuspend on its own process ID + + +However, many events can cause a reschedule in which the current process is preempted by a higher +priority process without completing its course. Such events include: + + +e the fourth consecutive system tick +e asemaphore being signalled (eg as a result of user input) which releases a higher priority process +e the expiry of a higher priority process in the timer DELTA queue + +The current process may, by its own action, cause itself to be preempted by: + + +e signalling the I/O semaphore of a higher priority process (by calling p_iosignalbypia or, for +example, by sending it an inter-process message) + + +e calling p_presume to release a higher priority process from the susPENDED state (especially after +loading a process from an image) + + +e raising the priority of a another process by calling p_setpri +e lowering its own priority by calling p_setpri + +Process names + +A process name takes the following form: + + + +where the component contains between one and eight characters and the component +consists of a period, a s and a two digit number of the form 01, 02, 03 .... This number gives the index +(starting from 1) of the process slot. + + +If the process is a task (a subsidiary process that shares the same data segment), the s is replaced by a e@ +where, except for the @, the process name is otherwise the same as the creator of the task. + + +The maximum length of a process name is =_max_Name (12), excluding the zero terminator (buffers +normally allow &_mMax_NamE+2 bytes to include the zero terminator and to keep following variables on an +even address). + + +When a process is created by loading an image using p_execc, the process is created with a taken +from the file name of the image. For example, if a program called Loc: :\B:\UTILS\SoRT. IMG is loaded +twice the process names might be: + + +SORT .$07 +SORT.$11 + + +The component of a process name guarantees that the process name is unique. Note that the process +data segments are given the same names (see the chapter Memory Allocation) but that these segment +names are held independently of the process name. + + +To convert a process name into a process ID, you use p_pidfind. Since a program cannot anticipate the + component, p_pidfind allows wild card characters in a match string. For example, to get the +process ID of a database server process that was loaded from db$serv.img, you would use +p_pidfind("DBSSERV.*"). + + +When there is the prospect of more than one process of the same (because a program was loaded +more than once), p_pfind may be used to get the process IDs of all instances. + + +12-5 + + +PLIB REFERENCE + + +In the following example, the general purpose function ProcsOfThisProg returns the number of processes +having the same process name (excluding the extension) as this process (that is, it returns the number of +processes of the calling program). + + +GLDEF_C INT ProcsOfThisProg (VOID) +{ +TEXT *pp; +HANDLE h; +INT count; +TEXT mm[E_MAX_NAME+2]; +TEXT bb[E_MAX_NAME+2]; + + +p_pname (p_getpid(), &mm[0] +pp=(&mm[p_slocr(&mm[0],'.' +*pptt='"*'; *pp=0; + +for (h=0,count=0; (h=p_pfind(h, &mm[0], &bb[0]))>=0; count++) ; +return (count) ; + + +} + + +)+1)); + + +The function gets the name of this process using p_pname and p_getpid and builds a match string in mm[] +by replacing the extension with the '*' wildcard. It then uses this match string to count the number of +matching processes. + + +This function could be used to stop more than one process of a program (especially a server) from being +executed where, for example, if ProcsoOfThisProg returns more than one, the server program could panic. + + +Reserved statics (magic statics) + + +The reserved statics (otherwise known as magic statics) are variables with fixed, known, addresses, +existing in the process data space between addresses 0x00 and 0x40. They are 'magic' in the sense that +they are accessible from all parts of the process code, even from dynamic library code (which does not +have any data space and therefore may not, normally, access statics). + + +Some of these variables are used by the operating system as part of the process context. Others are used by +system code such as the window server, and the graphics user interface libraries. Such usage differs from +machine to machine in the EPOC range; you will find a description of any such usage in the +Programming Guide for the appropriate machine or in user interface library documentation. + + +The remaining reserved statics are freely available for use by the process code. A common use is to +provide access from dynamic library code to application-specific data, without the need for it to be passed +in function parameters. + + +0x00 DatWordDead The word at this address contains the value 0xDEapD. This value must not +be changed by application code. Many operating system calls check for +this value and will panic the process with panic reason code PanicDead0 +if it has changed. A change in this value is symptomatic of a common +software bug; the unintentional use of a NULL pointer. + + +0x02 DatHandNext The data at these two addresses are used as pointers to a queue of wait +0x04 DatHandPrev handler function descriptors. This data should not be modified by +application code. + + +0x06 DatCountrySeg This holds the segment handle of the data segment containing the country +and language specific fold tables for the process. This data should not be +modified by application code. + + +0x08 DatClassHandle In applications which use any of the object oriented programming calls + +0x0a DatClassPtr (this includes use of Hwif programs) these locations hold data required by +the operating system to work out how to send a message to an object's +superclass. It is recommended that application code does not modify the +contents of these locations. + + +0x0c DatEClassHandle In applications which use any of the object oriented programming calls + +0x0e DatEClassPtr (this includes use of Hwif) these locations hold data required by the +operating system to work out how to perform a p_exactsend. It is +recommended that application code does not modify the contents of these +locations. + + +12-6 + + +0x10 + + +0x12 + + +0x14 + + +0x16 +0x18 + + +Oxla + + +Oxlc + + +Oxle + + +0x20 + + +0x21 + + +Ox22 + + +0x24 + + +0x26 + + +0x28 +Ox2a +Ox2c +Ox2e +0x30 +0x32 +0x34 + + +DatEnterFramePtr + + +wClientData + + +wserv_channel + + +DatOsFramePtr + + +DatATFlag + + +DatHeapLocked + + +DatProcessNamePtr + + +DatCommandPtr + + +DatTest + + +DatApp1 +DatApp2 +DatApp3 +DatApp4 +DatApp5 +DatApp6 +DatApp7 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The enter and leave mechanism provided by the operating system uses +this address to store the pointer to the last enter frame generated on the +stack. When a leave occurs this pointer is used to unwind the stack and +restore the register set. This location should not be modified by +application code. + + +In applications that use system user interface libraries this location is +assumed to hold the object handle of an instance of the 'wserv' object. The +application is responsible for ensuring that this location is set up +correctly, normally by calling system code on application start-up. + + +In applications that use the application manager object (all object oriented +programs and Hwif programs) this location is assumed to hold the object +handle of an instance of the application manager object. The application +is responsible for ensuring that this location is set up correctly, normally +by calling system code on application start-up. + + +These locations are used by the window server process to store +information about your application. If you use any graphics functions you +should not modify the contents of these locations. + + +This location is used by the OPL language translator. If your application +does not use OPL then this location is free for use by application code. + + +This location is used by the OPL language runtime code. This location +should not be modified by application code. + + +This location contains a pointer to the last member of a linked list of +operating system calling frames. Following this linked list will show +which functions called which operating system services. This location +should not be modified by application code. + + +This byte location contains the current address trap status for the process. +Certain operating system calls cause address trapping to be turned on or +off and the operating system sets or clears this flag to record the current +address trap hardware status. Just setting the flag to zero will not disable +address trapping. This location should not be modified by application +code. + + +This byte location contains the current state of the heap locked flag. +While the heap is being modified (for example, being resized, due to a +memory allocation request) the heap is locked. This prevents the +operating system from compressing the segment while the data structures +used by the operating system to run the heap are in an inconsistent state. +This location should not be modified by application code. + + +System user interface library code assumes that this location contains +either NULL or a pointer to a zero terminated string that the application +wishes to be displayed as its name. Otherwise it is free for use by +application code. + + +This location contains a pointer, set up by the operating system. It points +to an alloc cell that contains the full path name, as a zero terminated +string, of the .img or .app file from which the process was loaded. +Immediately following the zero terminator, the alloc cell contains leading +byte counted initial command line data. + + +Psion's test system library code assumes that this location contains the +object handle of the test code. Otherwise it is free for use by application +code. + + +These locations are free for application code to use. + + +One exception is DatApp7, which is used within the ISAM library. Code +that accesses the ISAM library, either directly or indirectly, may not use +DatApp7, but otherwise it is free for use. + + +12-7 + + +PLIB REFERENCE + + +0x36 DatDialogPtr System user interface library code may assume that this location contains +a pointer to the current dialog structure. Otherwise it is free for use by +application code. + + +0x38 DatGate System user interface library code may assume that this location contains +an object handle. Otherwise it is free for use by application code. + + +0x3a DatLocked System user interface library code may assume that this location contains +a flag indicating whether the application is capable of receiving +termination or switch files messages. Otherwise it is free for use by +application code. + + +0x3c DatStatusNamePtr System user interface library code may assume that this location contains +a pointer to a zero terminated string that will appear in a status window. +Otherwise it is free for use by application code. + + +0x3e DatUsedPathNamePtr | System user interface library code may assume that this location contains +a pointer to a fully parsed file name. Otherwise it is free for use by +application code. + + +Shared code segments + + +When a second or subsequent process of the same program is loaded, the existing code segment (which +has segment name .$sc) is shared and not loaded from the image file (however, the initialized +static data values are still loaded into the created process data segment). + + +The system checks that the contents of the existing code segment matches the code in the image file by +comparing pcb. checkSum with the checksum stored in the image header (the checksum in the image +header is also used to check the integrity of the code when it is loaded). If the checksums do not match, +the load fails. It follows that you cannot run different programs of the same name (or different versions of +the same program) at the same time. + + +Image files + + +An image file is a form of executable (program) file that is run by calling p_execc. It normally has a . mc +file name extension. Application files (with a .ApP extension) are a particular type of image file. + + +An image file is created by applying the emake.exe tool to a DOS executable. This is normally done +automatically as part of the build process that generates an EPOC application program (for an example of +the use of emake.exe, see \ts\sys\tsprj.txt). + + +The creation process adds an ImgHeader struct (defined in epoc.h) to the front of the file and may +optionally concatenate a number of other files into the image file. + + +The ImgHeader struct is effectively defined as: + + +#define SignatureSize 16 +#define MaxAddFiles 4 + + +typedef struct +{ +UINT offset; +UINT length; +} ADDFILE; + + +typedef struct +{ + + +Gq +1 tO +K + + +HZQZGZZZZ2ZRZ ZZ ZZae + + +TE Signature [SignatureSize]; +[ ImageVersion; + +[ HeaderSizeBytes; + +[ CodeParas; + +[ InitialIP; + +[ StackParas; + +[ DataParas; + +[ HeapParas; + +[ InitializedData; + +[ CodeCheckSum; + +[ DataCheckSum; + +[ CodeVersion; + +r Priority; + +ILE Add[MaxAddFiles]; +DylCount; + +NG DylTableOffset; + +[ Spare; + +mgHeader;. + + +iw) + + +Jy + + +E + + +i i RB mm i 1 a en et + + +12-8 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The meanings of the elements of this struct are as follows: + + +Signature + + +ImageVersion + + +HeaderSizeBytes + + +CodeParas + + +InitialIP + + +StackParas + + +DataParas + + +HeapParas + + +InitializedData + + +CodeCheckSum + + +DataCheckSum + + +CodeVersion + + +Priority + + +Add + + +Dy1lCount + + +DylTableOffset + + +Spare + + +contains the string "ImageFileType**". + + +the version number of the software tools used to create the image file. At the +time of writing the version is 2.00F (0x200£) + + +the offset of the start of the executable code within the image file + + +the required size, in (16 byte) paragraphs, of the memory to be reserved for the +code segment + + +the initial instruction pointer offset in the executable code - determined by the +linker, (and normally 0) + + +the size, in (16 byte) paragraphs of the stack - determined by which PLIB C +startup module is linked into the program (see the discussion of startup +modules in the Introduction chapter) + + +the total size, in (16 byte) paragraphs, of the declared static data (including the +initialised data - see below) + + +the required size, in (16 byte) paragraphs, of the initial - and minimum - alloc +heap, user definable via a parameter to emake.exe (see below) + + +the size, in bytes, of the initialised static data +internally generated and verified checksum on the code +internally generated and verified checksum on the data + + +the version number of the executable code, user definable via a parameter to +emake.exe (see Dbf£Version in the chapter Database Files for the form of a +version number) + + +the start-up priority of the process that will be created from this image file, user +definable via a parameter to emake.exe (default value is 0x80) + + +an array of four ADDFILE structs, describing up to four additional files +included within the image file (common included files, in .APP files, are an +icon graphic and a resource file) + + +the number of object dynamic libraries (DYLs) concatenated into the image +file. See also the Object Oriented Programming chapter of this manual. + + +the offset within the file of the start of an array of pyLENTRy structs (defined in +epoc.h) with pyicount entries, giving the names and file offsets of the included +DYLs + + +reserved + + +The contents of this header may be displayed by applying the edump.exe tool to an image file. + + +For efficiency, the value of Heapparas should be adjusted to be equal to, or slightly larger than, the heap +space used by the running process immediately after it has started. Setting a smaller value means that the +heap will have to be grown one or more times during the initialisation of the process. Growing the heap +may involve moving large amounts of in-memory data and may, therefore, significantly increase the +process start-up time (see also The heap allocator in the chapter Memory Allocation). + + +12-9 + + +PLIB REFERENCE + + +IO Ka ns Tn st +Process termination + + +The subject of process termination (with associated functions) is described in detail in the chapter Error +Handling. The functions described include those that terminate a process: + + +p_pterminate or to terminate another process (typically in response to a user request) +p_pkill +p_ppanic to panic another process (normally following unreasonable behaviour from the + + +process being terminated) +and those functions that request notification of the termination of other processes: +p_logona to be signalled when the specified process terminates + + +p_logon to receive an inter-process message when the specified process terminates +(convenient for server processes to keep track of their clients) + + +p_watchall to receive an inter-process message when any process terminates (only one +process can call p_watchal1 - normally the Shell to monitor the termination of +all processes) + + +When a process terminates, pcb. status in the process control block (which normally holds the process +state) is set to E_LPROC_FREE to mark it as available for use by a new process. When a newly created process +re-uses the slot, pcb.magic is incremented modulo 8, as described above. + + +SS a ae a a re eT) +Creating a process + + +p_execc Load an image +HANDLE p_execc(TEXT *pName, VOID *pCommand, INT length); + + +Create a suspended process from the image file described by the zero terminated file specification pNname +and, if successful, return the positive process ID of the created process. + + +The created process is suspended so that the creator can perform any initialisation (eg to set the process +priority) before allowing the process to run by calling p_presume. If the created process has a higher +priority than the creator, the call to p_presume may not return for some time. + + +The file specification pName is parsed with a related name of ". mc". + + +The function allocates a command cell from the heap of the created process. This cell is loaded with the +following sequence: + + +¢ acopy of the zero terminated full file specification resulting from the parse of pName +e a byte containing length +e acopy of the length bytes from pcommand + + +where length must be between zero and E_MAX_COMMAND_BUFFER (127) inclusive. If pcommand is NULL, +length is taken to be zero, whatever is passed. + + +The address of this command cell is written to the reserved static Dat CommandPtr in the created process +data segment. This variable is accessed from C by declaring: + + +GLREF_D UBYTE *DatCommandPtr; + + +Note that there is no restriction on the data in pcommang; it may include binary data structures as well as +text. For example, it is often useful to pass the process ID of the caller in the command line. + + +The name of the created process is taken from the file name component (excluding any extension) of +pName. If a process, loaded from pName, already exists (as determined by a name and checksum match), the +created process shares the loaded code segment. In this case, the code is not reloaded from pName +(however, the initialized static data values are still loaded into the created process data segment). + + +12-10 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The function returns a positive process ID if successful or a negative error number if it failed. As well as + + +the p_fparse error numbers that may be returned if the parse of pName fails, p_execc can return the +following error numbers: + + +E_GEN_NOMEMORY insufficient free system memory + +E_FILE_DEVICE the device in pName does not exist + +E_FILE_NOTREADY the device in pName does not contain a medium + +E_FILE_DIR the directory in pName does not exist + +E_FILE_NXIST the file in pName does not exist + +E_FILE_EXIST a process of a different program (ie with a different checksum) with the same + + +name already exists + + +E_GEN_IMAGE the file is not a valid image or if the image is corrupt + +E_GEN_NOPROC there are no more free process slots (the maximum process limit has been +reached) + +E_GEN_ARG the total size of the data, stack and heap exceeds oxrrero bytes or length + + +exceeds E_MAX_COMMAND_BUFFER + + +The loading of an image is performed by the file server (see the Files chapter) and the caller must + + +have connected to the file server before calling p_execc (otherwise the caller is panicked with panic + + +number 41). The standard PLIB library connects to the file server before calling main. + + +Example + + +#include + + +LOCAL_C VOID Exec(TEXT *name, TEXT *cmd, INT len) +{ +INT ret; +TEXT bb[E_MAX_ERROR_TEXT_SIZE]; + + +ret=p_execc (name, cmd, len); +if (ret<0) +{ +p_errs (&bb[0],ret); +p_printf ("Failed to start %s (%s)",name, &bb[0]); +} +else +{ +p_printf("Process ID is %x",ret); +p_presume (ret) ; +} +} + + +GLDEF_C INT main(VOID) +{ +TEXT *pl,*p2; +TEXT bb[64]; + + +while (p_getl("Enter ? ", &bb[0],64)) +{ +pl=p_skipwh (&bb[0]); + + +if (!*pl) + +continue; +p2=p_skipch (pl); +if (*p2) + + +{ +*p2tt+="\0'; +p2=p_skipwh (p2) ; +} +Exec (pl,p2,p_slen(p2) +1); +} +return (0); + + +} + + +12-11 + + +PLIB REFERENCE + + +The program solicits a line of input and parses out the name of the image to run and a text string to pass +to the created process (which is passed with the zero terminator). If this program is used to run +dummy.img in the default path (which happens to be Loc: :D: \) by entering: + + +dummy fred +and the code for dummy.img is: + + +#include +GLREF_D UBYTE *DatCommandPtr; + + +LOCAL_C VOID PrintCommandPtr (VOID) + + +{ +UBYTE *p, *pe; +UINT lcell; + + +if (!DatCommandPtr) +p_panic (0); + +lcell=p_alen(DatCommandPtr) ; + +p_print ("sd [",lcell); + +for (p=DatCommandPtr, pe=p+lcell;p", *p) ; + +p_printf£("]"); + +} + + +GLDEF_C INT main(VOID) +{ + + +PrintCommandPtr(); +p_getch(); +return (0); + + +} +then dummy.img prints: + + +24 [LOC::D:\DUMMY.IMG<00><05>fred<00>] + + +p_execcasync Load an image asynchronously + + +INT p_execcasync(TEXT *pName, VOID *pCommand, INT length, WORD *pStatus, HANDLE *pPid)j; + + +This is the asynchronous version of p_execc, which may return before the operation is complete. See the +chapter Asynchronous Requests and Semaphores for an explanation of asynchronous requests. + + +See p_execc above for the meaning of the parameters pName, pCommand and length, the behaviour of the +operation and its possible error returns. + + +The function p_execcasync returns zero if the asynchronous request was successful or a negative error +number if the operation failed to start (eg E_FILE_NAME if pName failed to parse). + + +When the load completes, the completion status is written to *pStatus and the process I/O semaphore is +signalled. If the load completes successfully, *pstatus contains zero and *pPid contains the process ID of +the created process (this corresponds to the value returned by p_execc). If the load completes +unsuccessfully, *pstatus contains a negative error number (eg E_GEN_NOMEMORY). + + +If pName refers to a file on the Loc: : file system, the load will actually have completed by the time +p_execcasync has returned because the file server runs at a higher priority than any of its clients. +However, if the image is on a REm: : file system where the connection is via an RS232 cable, +p_execcasync will return well before the load is complete. + + +p_pcreate Create a process + + +HANDLE p_pcreate(E_CPB *pBlock) ; + + +Create a process from the information in the E_cpB struct pointed to by pBlock and, if successful, return +the positive process ID of the created process. + + +This is the primitive process creation service that does not involve the file server. In the vast majority of +cases, it is more convenient to use p_execc, which will eventually call this service. + + +12-12 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The &_pcs struct is defined in epoc.h as: + + +typedef struct +{ + +UWOR: +UWOR: + + +D codeParagraphs; +D +UWORD stackParagraphs; +D +D + + +initiallp; + + +UWOR +UWORD heapParagraphs; +UBYTE *commandLine; +UWORD checkSum; + +UWORD minHeap; + +UBYTE priority; + +UBYTE ramOrRom; + +UBYTE name [E_MAX_NAME]; +} E_CPB;. + + +dataParagraphs; + + +The function creates a process of initial priority pBlock->priority where the process name is taken from +the zero terminated (up to 8 characters) in pBlock->name. + + +If pBlock->ramOrRom is TRUE and a process of the same name already exists, its checksum is compared +with pBlock->checkSum and, if they match, the existing code segment is shared (in which case +pBlock->codeParagraphs is ignored). + + +If pBlock->ramOrRom IS TRUE and a process of the same name does not already exist, p_pcreate creates a +code segment of length pBlock->codeParagraphs paragraphs (and pBlock->checkSum is stored as the +code segment checksum). In this case, the caller must deposit the code into the created code segment +before resuming the process. + + +If pBlock->ramOrRom IS FALSE, pBlock->codeParagraphs is taken to be the paragraph address of the code +segment in the ROM. + + +When the process is resumed, the initial instruction pointer is set to pBlock->initiallIp. + + +A data segment is created, of sufficient size to include the stack (of length pplock->stackParagraphs) a +static data space (of length pplock->dataParagraphs) and a heap (of length pplock->heapParagraphs). +The total size of the data, stack and heap must not exceed oxrre paragraphs. The +pBlock->dataParagraphs area in the data segment is zero filled. The minimum heap size subsequently +allowed for the created process is pBlock->minHeap paragraphs. + + +If pBlock->commandLine 1S not nuuL it should point to a zero terminated string, immediately followed by a +leading byte count buffer where the leading byte is less than or equal to E_Max_COMMAND_BUFFER (as +described in p_execc, above). The whole pBlock->commandLine data structure is copied into a heap cell +that is allocated in the created process. + + +The function returns a positive process ID if successful or on of the following negative error numbers: +E_GEN_NOMEMORY insufficient free system memory + + +E_FILE_EXIST a process of a different program (ie with a different checksum) with the same +name already exists + + +E_GEN_NOPROC there are no more free process slots (the maximum process limit has been +reached) +E_GEN_ARG the total size of the data, stack and heap exceeds oxrreo bytes or the leading + + +byte count length in the pBlock->commandLine data structure exceeds +E_MAX_COMMAND_BUFFER + + +E_FILE_NAME pBlock->name is invalid + + +12-13 + + +PLIB REFERENCE + + +Operations on the current process + + +See the chapter Error Handling for the functions (p_exit and p_panic) that terminate the current process. + + +p_getpid Get this process ID +HANDLE p_getpid(VOID) ; +Return the process ID of the caller. +For example: +TEXT ProcessName [E_MAX_NAME+2]; +p_pname (p_getpid(), &ProcessName[0]); + + +writes the name of this process as a zero terminated string to ProcessName. + + +p_unmarka Mark this process as non-active +VOID p_unmarka (VOID) ; + + +Mark the calling process as non-active such that the running of the process will not keep the machine +switched on. + + +The zero priority null process switches the machine off (to reduce power consumption) after a period of +inactivity. A context switch to a process marked as non-active does not count as activity. + + +When a process is created it is initially marked as active. + + +General purpose server processes should mark themselves as non-active since not to do so would disable +their clients from effectively calling p_unmarka. For example, if the file server was marked as active, a file +request by a non-active client would cause the file server to run and reset the inactivity timer. As it is, the +file server is marked as non-active and it is left to the clients of the file server to reset the inactivity timer +or otherwise. + + +Applications that respond to a continuously restarted short interval relative timer (as in, for example, a +clock program) should also call p_unmarka. Otherwise, the machine would never switch off while the +program is running. + + +Interactive programs that do call p_unmarka do not need to take any measure to reset the inactivity timer +when responding to user input (a key press or the use of a pointing device if there is one) since the system +(by one means or another) guarantees to reset the inactivity timer on user input. To reset the inactivity +timer in response to an event other than user input, call p_tickle, described next. + + +Note that a compute-bound process (such as a game program that is computing its best next move) will +not allow the machine to switch off, simply because the null process never gets an opportunity to run. +Such a process should assume responsibility for allowing the machine to switch off by calling p_allowoff +from time to time. + + +p_tickle Register activity +VOID p_tickle (VOID) ; +Reset the auto-switch-off inactivity timer. + + +It is used by a process that is marked as inactive, but wishes to stop the system switching off. An example +would be to keep the machine going if serial data is received. + + +You don't need to call p_tickle in response to user input since the system automatically registers activity +in this case. + + +12-14 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +p_marka Mark this process as active + + +VOID p_marka (VOID) ; + + +Mark the calling process as active such that the running of the process will stop the machine from +switching off. + + +The zero priority null process switches the machine off (to reduce power consumption) after a period of +inactivity. A context switch to a process marked as active resets the inactivity timer. + + +When a process is created it is initially marked as active and p_marka does not need to be called unless +p_unmarka has previously been called. + + +—EeEEeE—E—————— ey +Operations on any process + + +See the chapter Error Handling for functions (p_pterminate, p_pkill and p_ppanic) that terminate a +process. + + +p_getpri Get a process priority +INT p_getpri(HANDLE pid); + + +Return the positive priority of process pia, or the negative k_FILE_Nxtst if the process does not exist. + + +p_setpri Set a process priority +INT p_setpri(HANDLE pid, INT nPriority); + + +Set the priority of process pid to nPriority (between E_MIN_PRIORITy and E_MAX_PRIORITY inclusive) +and return zero if successful or one of the following negative error numbers: + + +E_GEN_RANGE nPriority 1s outside the range E_MIN_PRIORITY tO E_MAX_PRIORITY + +E_FILE_NXIST process pid does not exist + +E_GEN_FAIL attempted to change the priority of the null process, the supervisor, or the file +server + + +Calling p_setpri causes a reschedule. + + +p_presume Resume a process +INT p_presume (HANDLE pid); + +Resume process pia and return zero if successful or one of the following negative error numbers: +E_GEN_ARG pid 1s not suspended + +E_FILE_NXIST process pid does not exist + +If process pid has a higher priority than the caller, the call to p_presume may not return for some time. + + +If you actually want to wait for the resumed process to terminate before continuing, you can use +p_logona (described in the chapter Error Handling) as follows: + + +p_logona (pid, &stat) ; + + +p_presume (pid) ; +p_waitstat (&stat) ; + + +12-15 + + +PLIB REFERENCE + + +p_psuspend Suspend a process +INT p_psuspend (HANDLE pid); + +Suspend process pid and return zero if successful or one of the following negative error numbers: +E_FILE_NXIST process pid does not exist + +E_GEN_FAIL attempted to suspend the null process, the supervisor, or the file server + + +A process that is in the READY queue or is currently running (ie the calling process) is suspended +immediately. A process that is waiting on the SEMAPHORE queue or the DELTA queue is marked (in +pcb. sstatus) as requiring suspension and is subsequently placed in the susPENDED state when it would +otherwise have been transferred to the READY queue (unless the process is resumed before this happens). + + +p_pname Get a process name by ID +INT p_pname (HANDLE pid, TEXT *pName) ; + + +Write the name of process pid as a zero terminated string to pName (which should be big enough to receive +E_MAX_NAME+2 bytes) and return zero if successful or E_FILE_Nx1sT if the process does not exist. + + +The process name written to pName includes the process slot extension as in, for example, syS$NULL.$01. + + +p_prename Rename a process +INT p_prename (HANDLE pid, TEXT *pNewName) ; +Rename process pid to the zero terminated pNewName and return zero if successful. + + +The process name pNewName should not include a process slot extension (this is supplied by the system) +and should be between | and 8 characters long. No check is made that the new name is unique, but an +invalid name will return the error E_FILE_NamE. The possible error returns are: + + +E_GEN_ARG process pid is not suspended +E_FILE_NXIST process pid does not exist +E_FILE_NAME the new name is invalid + + +p_pidfind Get a process ID by name +HANDLE p_pidfind(TEXT *pName) ; + + +Return the positive process ID of the first process having a name matching the zero terminated pName +(which may contain wild card characters) or return E_FILE_Nxt1sT if there is no matching process. + + +For example, to find the process ID of a process created by loading db$serv.img, use: + + +pid=p_pidfind("DBSSERV.*") ; + + +p_pfind Find all processes +HANDLE p_pfind(HANDLE pid, TEXT *pMatch, TEXT *pName) ; + + +Called repeatedly to find all the processes that match the wild card string pointed to by pMatch, writing +the process name as a zero terminated string into pName (which should be big enough to receive +E_MAX_NAME+2 bytes). The first call should pass a zero pid. + + +Returns the positive process ID of the process found (which is also passed to the next find) or the negative +E_FILE_NXIST if no more matching processes can be found. + + +The wild card string pMatch should remain the same between successive calls. + + +No memory is used by this service and it can be abandoned at any time without taking any further action. + + +12-16 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +For example, to print the names of all processes: + + +GLDEF_C INT main (VOID) +{ +HANDLE h; +TEXT b[E_MAX_NAME+2]; +for (h=0; (h=p_pfind(h,"*",&b[0]))>=0;p_printf(&b[0])); +p_getch(); + + +return (0); + + +} + + +p_getowner Determine the owner of a process +HANDLE p_getowner (HANDLE pid); +This function is only available in EPOC version 2.17 or later. + + +Returns the process ID of the process which last resumed process pia, that is, the last process to call +p_presume (pid). This process is defined to be the owner of process pid. + + +This mechanism will fail in the case where the process being resumed has not attempted to run between a +call to p_psuspend and a subsequent call to p_presume. This is because a process is only truly suspended +at the time that it first attempts to run following a call to p_psuspend. + + +Note that there is no guarantee that the process whose ID is returned by p_getowner still exists. + + +Accessing a process data segment + + +The functions p_pcpyfr, p_piscpyfr and p_pcpyto copy data between a (normally different) process data +segment and the caller's data segment (cf p_sgcopyfr and p_sgcopyto which copy data between any +segment and the caller's data segment). + + +p_pcpyfr Copy data from a process + + +INT p_pcpyfr(HANDLE pid, VOID *pSource, VOID *pTarget, UINT nBytes); + + +Copy nBytes bytes at offset psource from the data segment of process pid to address ptarget (in the +current process) and return zero if successful. + + +If psourcet+nBytes exceeds the size of the processes data segment, the data up to the end of the segment is +copied and zero is returned. + + +The system ensures that the copy is not interrupted by another process. + + +The function returns &_GEN_arc if the process pid does not exist. + + +p_piscpyfr Indirected string copy from a process +INT p_piscpyfr(HANDLE pid, VOID *pSourceAddr, VOID *pTarget, UINT nBytes); +This function is only available in EPOC version 2.14 or later. + + +Read the pointer at offset psourceAddr in the data segment of process pid. Then copy the zero terminated +string indicated by this pointer to address ptarget (in the current process) and return zero if successful. + + +wie + + +If the pointer is nuuu, a null string (""") is copied to ptarget. + + +If the string is longer than nBytes, only nBytes of data (plus a terminating zero) are copied and zero is +returned. + + +If the implied length of the source string extends beyond the end of the processes data segment, the data +up to the end of the segment (plus a terminating zero) is copied and zero is returned. + + +The system ensures that the copy is not interrupted by another process. + + +The function returns z_cEn_arc if the process pid does not exist. + + +12-17 + + +PLIB REFERENCE + + +For example: + + +GLREF_D TEXT *DatProcessNamePtr; + + +LOCAL_C INT GetCalcName (VOID) + + +{ +HANDLE h; +TEXT buf [0x40]; + + +h=p_pidfind("calc.*"); +if (h<0) +return (h); +p_piscpyfr(h, &DatProcessNamePtr, &buf[0],0x40); +return (0); + + +} + + +fetches the process name of the calculator. + + +p_pcpyto Copy data to a process + + +INT p_pcpyto(HANDLE pid, VOID *pTarget, VOID *pSource, UINT nBytes); + + +Copy nBytes bytes from pSource in the current process data segment to pTarget in the data segment of +process pid and return zero if successful. + + +The system ensures that the copy is not interrupted by another process. +Address trapping is automatically switched off for the duration of the copy. + + +Returns the negative E_GEN_arc if the process does not exist or if pTarget+nBytes exceeds the size of the +target process data segment (in which case the data is not copied). + + +5 ——————_________________s_;;; +Inter-process messaging + + +Inter-process messaging in EPOC is designed for the efficient implementation of client-server +relationships where a particular server may have multiple clients. + + +A server process is a commonly provided to share a resource amongst multiple client processes. The +EPOC operating system starts up with three multi-client servers: + + +e the supervisor, which performs critical system functions and provides shared access to memory +via the memory segment allocator + + +e the file server, which provides shared access to file storage devices + + +e the window server, which provides shared access to the screen, keyboard and, if present, a +pointing device + + +A server may also be a client of another server. For example, the window server is a client of the file +server (since, for example, it loads bitmap files) and all processes are implicitly clients of the supervisor. + + +In order that the relative priorities of client processes have their intended effect, a multi-client server +process should run at a higher priority than any of its clients. A client's priority is effectively lowered to +that of the server while waiting for completion of a service provided by a low priority server. + + +Message slots +A process that wishes to receive messages must first call p_minit to initialise the message system. + + +Calling p_minit (nMess, 1Mess) allocates nMess message slots (from the heap) where each message slot +contains an E_MESSAGE struct header followed by a buffer of length 1Mess. The E_MESsAGE struct is +defined in epoc.h as: + + +typedef struct message +{ +struct message *next; +UBYTE *status; +UINT type; +HANDLE pid; +} E_MESSAGE;. + + +12-18 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The structure of the 1mess bytes of data following the z_messacz header is defined by the receiver of the +message and is normally limited to a few words. For example, the file server and the supervisor both use +an iMess of 8. Note that the sender has no control over the length of the message sent (a later version of a +server could increase the message length to provide additional services while maintaining upward +compatibility). + + +When the sender calls p_msend (or a variant) the arriving message is copied into a previously free message +slot, which is also placed in the receiver's message queue. + + +From this time the message slot is allocated, in the sense that it cannot be overwritten by another +incoming message. It contains the message type (as specified by the sender) in type and the process ID of +the sender in pia, followed by 1mess bytes of data from the sender. (The fields next and status in the +E_MESSAGE header are used internally by the message system.) + + +The message slot is removed from the queue when the receiver calls, for example, p_mreceivew (which +returns the address of the message slot). The content remains safe from being overwritten until the +receiver calls p_mfree to indicate that it has completed processing the message. Calling p_mfree returns +the message slot to its free state, available to receive another incoming message. + + +What the server does + + +A server is always a passive process that waits for messages to arrive from a client process. It is not +expected that a server will ever initiate a transaction by sending a message to a client. + + +As described earlier, the server first calls p_minit to initialise the message system. The server then waits +for a message to arrive by calling p_mreceivew (an asynchronous version, p_mreceive, also exists). When +the message arrives, the function returns the address of the message slot. + + +The server always removes messages from the front of the queue. Arriving messages are normally inserted +at the end of the queue but if the client's priority is 0x80 or more, the arriving message is inserted at the +front, overtaking any existing messages, regardless of their sender's priority. + + +When it is necessary to send more than the amount of information allowed for by the (typically short) +message length, the message contains the data by reference (ie by address and length). The server then +uses p_pcpyfr to copy the data from the client's data segment. + + +The message may also contain the address or addresses of buffers to receive data from the server when the +service has been completed. Here, the server uses p_pcpyto to copy the data to the client's data segment. + + +When the message has been processed, the server frees the message slot using p_mfree. If the message +was sent in such a way that the sender is expecting an acknowledgment of some kind (ie the message was +sent using p_msendreceivew Of p_msendreceivea rather than p_msena), the call to p_mfree also writes +back a completion status value and signals the sender's I/O semaphore. + + +Servers request to be informed of the termination of a client by calling p_logon (pid, nType) to receive a +message of type nType when client pid terminates. Process termination and p_logon are described in the +chapter Error Handling. + + +What the client does + + +The client process requests a service of the server by sending it typed fixed length messages (where the +message length is determined by the server) using: + + +p_msend to send the message "blind", returning when the message has been deposited +(but not necessarily processed) + + +p_msendreceivew to send the message and wait for the server to reply by calling p_mfree + + +p_msendreceivea to send the message, returning when the message has been deposited (as for +p_msenda) having set up an asynchronous request for a reply + + +If the server does not have any empty message slots, the message sending function waits on a mutual +exclusion semaphore until a message slot becomes free. It can therefore be blocked indefinitely, even if +using the asynchronous p_msendreceivea. Multi-client servers avoid this prospect by allocating a slot for +each potential client (by allocating say E_max_PROCESSES minus the number of known processes). + + +12-19 + + +PLIB REFERENCE + + +The only preparation required by the client is to obtain the process ID of the server. Examples of ways in +which this is done are: + + +the client gets the ID via the process name using p_pidfind (this is normally what is done for +multi-client servers) + + +the client knows the ID because it created the server using p_execc + + +the server created the client and passed its process ID as a command parameter to p_execc (as in +the above example) + + +For multi-client servers, the client typically sends an opening message to connect to the server. + + +An example of a server + + +typedef struct + + +{ + +E_MESSAGE mess; +TEXT *bofs; +UWORD len; + +} MESS; + + +LOCAL_C VOID RunServer (VOID) + + +{ +MESS *pmsg; +TEXT buf[256]; + + +FOREVER +{ +p_mreceivew(&pmsg) ; +if (pmsg->mess.type) + +{ + +p_mfree(pmsg, 0); + +break; + +} +p_pcpyfr(pmsg->mess.pid, pmsg->bofs, &buf[0],pmsg—>len) ; +p_printf("%*s",pmsg-—>len, &buf[0]); +p_mfree(pmsg, 0); + +} +} + + +LOCAL_C VOID Exec(TEXT *name) + + +{ +HANDLE pid; +TEXT bb[E_MAX _ERROR_TEXT_SIZE]; + + +pid=p_getpid(); +pid=p_execc (name, (UBYTE *) &pid, sizeof (pid) ); +if (pid<0) +{ +p_errs (&bb[0],pid); +p_printf ("Failed to start %s (%s)",name, &bb[0]); +} +else +{ +p_printf("Process ID is %xd",pid); +p_logon (pid, TRUE) ; +p_presume (pid) ; +RunServer (); +} +} + + +GLDEF_C INT main(VOID) + + +12-20 + + +{ +TEXT bb[P_FNAMESIZE]; + + +p_minit (1, sizeof (MESS) -sizeof (E_MESSAGE) ) ; + +while (p_getl("Enter ? ", &bb[0],P_FNAMESIZE) ) +Exec (p_skipwh(&bb[0])); + +return (0); + + +} + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +In the above example, main solicits a file specification of an image to run. This image is then (in Exec) +loaded using p_execc (passing the created process the process ID of its creator) and then resumed using +p_presume. + + +While the image is running, the program acts as a server to it where messages of type FALSE are taken to +contain a buffer by reference. The data from this buffer is copied from the process using p_pcpyfr and +printed using p_printé. + + +Before resuming the process in Exec, the server logs on to the process by calling p_1ogon. When the +process terminates, the server receives a type TRUE message. This causes the program to return from +RunServer and solicit another image file specification. + + +Corresponding client code example + + +The following example shows how to write that part of the client side code that corresponds to the above +example of server code. + + +GLREF_D UBYTE *DatCommandPtr; + + +LOCAL_D HANDLE pid=0; +LOCAL_D TEXT bb[256]; + + +GLDEF_C VOID printf(TEXT *pfmt,...) +{ + + +struct +{ +TEXT *pbuf; +UINT len; +} msg; + + +msg.len=p_atob(msg.pbuf=&bb[0],pfmt, &pfmt+1); +if (!pid) +pid=* (HANDLE *) (DatCommandPtr+p_slen(DatCommandPtr) +2) ; +p_msendreceivew (pid, FALSE, &msg) ; +} + + +The printf function behaves in the same way as p_printf except that the printing is performed by the +creator of the process in its console window. Note that the call to p_msendreceivew does not return until +the server calls p_mfree. + + +This example does not show the sending of the message with a type TRUE on termination of the client +process. + + +Asynchronous messaging + + +The server-client example described above uses synchronous messaging in both the server and the client. +While this may be sufficient in simple cases, there are situations where such an implementation will prove +inadequate. + + +A client that sends messages synchronously is effectively suspended from the moment it calls +p_msendreceivew until the server completes processing the message and calls p_mfree. If completion is +dependent on an external event, such as the expiry of a timer or the arrival of serial data, the client may be +suspended indefinitely. This will, in general, be unacceptable behaviour (particularly if the client must +remain responsive to other events, such as user input) and in such a case the client should use +asynchronous messaging. + + +A server does not, in general, have a user interface. If its only task is to receive and process messages from +its clients, then synchronous server code may be perfectly acceptable. As in the example server code given +earlier, the server is effectively suspended until a message is received and returns to the suspended state as +soon as it has finished processing the message. If the server also has to respond to other events, such as +the expiry of a timer, then the receipt of messages must be handled asynchronously. + + +Suppose a client needs to use asynchronous messaging because completion of the processing of the +message may be delayed indefinitely by an external event. This implies that the server itself must respond +to at least two events (the receipt of a message and the external event) and so must also handle events +asynchronously. + + +12-21 + + +PLIB REFERENCE + + +The sequence of events that occur during messaging between asynchronous client and server is as follows: +e the server makes a call to p_minit + + +e the server then calls p_mreceive, passing the address of its messaging status word, and later +makes a call to p_iowait (usually in its main event-handling loop) + + +e the client calls p_msendreceiva, passing the address of a status word, and later calls p_iowait +(usually in its main event-handling loop) + + +e the server is signalled that a message has been received, by noting that its messaging status word +is no longer E_FILE_PENDING on areturn from p_iowait, and commences processing the message + + +¢ on completion of the processing the server calls p_mfree which notifies the client of the +completion + + +e the client is signalled that processing is complete, by noting that the relevant status word is no +longer E_FILE_PENDING on areturn from p_iowait + + +If the processing of the message itself involves an asynchronous request, the server may process any +number of synchronous messages from any of its clients (including the one sending the asynchronous +message) while the request is pending. It is therefore quite possible for a synchronous message to complete +before an earlier asynchronous message from the same client. + + +On the assumption that clients may send messages asynchronously because they do not want to wait, the +server will generally need more than one message slot to avoid the client having to wait for a message slot +to become free. How many slots to provide depends on many factors, such as: + + +e the maximum expected number of clients + +e the maximum number of outstanding messages allowed per client (rarely more than two) + +e whether it is acceptable for any client ever to be suspended while waiting for a free slot +Message processing order + + +A message sent by a client to a server is placed in a message queue, normally at the end of the queue. The +server receives a message by removing the one at the front of the queue (into one of its message slots). +Thus, in normal circumstances, messages are processed in the order in which they are sent. As mentioned +in the previous section, it is possible for synchronous messages to 'overtake' asynchronous messages from +the same client. + + +The window server has a requirement, particularly in an overlapping window environment, to give +priority to messages from the foreground task. For example, when an area of the screen covering all or +part of a number of task windows needs redrawing (after, say, the disappearance of a dialog) the +foreground task should be redrawn first. The following scheme has been adopted to satisfy the window +server's requirement without causing an unacceptable performance penalty. + + +In all cases, messages from a client process with a priority of 0x80 or above (the foreground task normally +has a priority of 0x80, which is higher than the priority of background tasks) are placed at the front of the +queue. They therefore overtake all other messages in the queue (including any earlier messages from the +same client) irrespective of the priorities of their sending processes. + + +This has the added advantage of reducing the risk that switching to the shell task (which always runs at a +priority higher than the foreground task) can be blocked by a 'rogue' task. + + +There is, however, one problem, which can be illustrated as follows. Suppose a client with a priority of +0x80 sends an asynchronous message to a server. This message is inserted at the front of the queue. Before +the server removes any messages from the queue, the same client sends a cancel message, to cancel its +previous request. This second message is again inserted at the front of the queue, overtaking the message +it is supposed to be cancelling. + + +For this situation to arise, all the following conditions must be satisfied: +e the client must have a priority of 0x80 or above +e the client must use asynchronous messaging +e the client must be sensitive to the order in which the server processes its messages + + +e the server must not have removed the first message from the queue by the time the second +message is queued + + +12-22 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +The last of these conditions is rarely satisfied, since a server normally runs at a higher priority than its +clients. As soon as the server is signalled that a message has been queued the server pre-emptively +suspends the client. In most cases the client will not resume until the server has completed processing the +message and is waiting for another message. It is rare that a server has more than one message in the +message queue. + + +The main exception is when the processing of the message requires the server to call (directly or +indirectly) p_iowait, for example, to perform file I/O. + + +In such a case you should consider whether the client really needs to use asynchronous messaging. +Alternatively you can set the client's priority to be less than oxso. In this case the mechanism by which the +window server adjusts the priority of background and foreground tasks should be disabled (see the +description of wconnect in the Window Server manual). + + +Pa a a Ng eee +Server functions + + +All the server functions except p_minit call p_panic if messages have not been initialised and p_minit +itself calls p_panic if it is called a second time. + + +p_minit Initialise for message reception + + +INT p_minit (INT nMess, INT 1Mess) ; + + +Initialise a queue of nMess message reception slots of length 1Mess and return zero if successful or one of +the following negative error numbers: + + +E_GEN_NOMEMORY there is insufficient free memory to allocate the message queue + + +E_GEN_NOSEM there are no more free semaphores (p_minit creates a mutual exclusion +semaphore, initialised with nmess) + + +The message length imess excludes the &_messacg structure that is at the front of all messages. The +message queue is allocated as a single cell from the heap. Since this cell remains allocated for the lifetime +of the process, programs calling this service should do so early in their initialisation (before any cell has +been freed) to avoid heap fragmentation. All message slots are of the same size and the total size of the +message queue is nMess* (1Mess+sizeof (E_MESSAGE) ) bytes. + + +To avoid senders being blocked by message sending (quite different from waiting for a reply that can be +handled asynchronously), multi-client servers should allocate a message slot for each potential client. The +constant &_MAX_PROCESSES contains the total number of processes that can be supported by the system. In +practice this can be reduced by at least four, for the null process, supervisor, file server and window +server. + + +Only the least significant byte of nmess is significant, limiting the number of message slots to 255. + + +Calls p_panic if p_minit has already been called or if the least significant byte of nmess is zero. + + +p_mreceivew Wait for message reception + + +VOID p_mreceivew(VOID *pMess) ; + + +Return when a message has been received, where the address of the message slot containing the message +is written to *pMess. + + +The data in the message slot is protected from being overwritten by the receipt of another message until +the message slot is freed from the queue using p_mfree. + + +Calls p_panic if messages have not been initialised or if an asynchronous message receive request is +pending. + + +Example + + +typedef struct +{ +E_MESSAGE mess; +TEXT *bofs; +UWORD len; +} MESS; + + +MESS *pmsg; + + +p_mreceivew (&pmsg) ; + + +12-23 + + +PLIB REFERENCE + + +p_mreceive Asynchronous message reception + + +VOID p_mreceive (WORD *pStatus, VOID *pMess) ; + + +Make an asynchronous request to receive a message and return immediately without waiting for a message +to be received. + + +While the request is pending (and the message queue is empty), *pStatus contains E_FILE_PENDING. + + +When a message is received (or if there is already a received message in the queue) *pStatus is set to +zero, the address of the message slot containing the message is written to *pMess and the process I/O +semaphore is signalled. + + +The data in the message slot is protected from being overwritten by the receipt of another message until +the message slot is freed from the queue using p_mfree. + + +Calls p_panic if messages have not been initialised or if an asynchronous message receive request is +already pending. + + +Example + + +typedef struct +{ +E_MESSAGE mess; +TEXT *bofs; +UWORD len; +} MESS; + + +MESS *pmsg; +WORD status; + + +p_mreceive (&status, &pmsg) ; + + +p_mcancel Cancel a message receive request + + +VOID p_mcancel (VOID) ; + + +Cancel any pending asynchronous request to receive a message (which was previously requested using the +p_mreceive service). + + +It is not considered an error to call this service if no request is pending (since the request may complete at +any time). If the cancel is processed before a message is received, the associated status word *pStatus is +set to E_LFILE_CANCEL. + + +Note that this service does not cancel a pending p_msendreceivea (which is a client function). A server +may support a cancel service but this is invoked, like any other service, by sending the server a message. + + +p_mfree Free a message + + +VOID p_mfree(VOID *pMess, INT nReply); + + +.Free the message slot with address pMess (as returned from p_mreceivew or p_mreceive) and, if the +message was sent using p_msendreceivew Of p_msendreceivea, complete the request by signalling the +sending client's I/O semaphore and copying nRep1y to the client's status word (which is returned by +p_msendreceivew). A negative value of nReply normally indicates an error. + + +If the message was sent with p_msend, the message slot is just freed and nRep1ly is ignored. +The server should not read the contents of pMess after calling p_mfree. + + +If messages are not freed from the message queue then in due course sending processes will be blocked +waiting on the message queue mutual exclusion semaphore. + + +12-24 + + +12 PROCESSES AND INTER-PROCESS MESSAGING + + +Se ooo | Ht“fo#ooavouwHurNvwaavaH07U7TT84A«I0 °I™ 7v“T“>Yn=Nazsw—" +Client functions + + +p_msend Send a message + + +INT p_msend(HANDLE pid, UINT mType, VOID *pMessage) ; + + +Send message pMessage Of type mType to process pid and return zero when the message has been +deposited or the negative E_GEN_RECEIVER if pid does not exist or if process pid has not called p_minit. + + +The message is deposited into a free message slot in the server where the member type in the E_MESSAGE +header is set to mtype and the message body is copied from pMessage (where the length of the message +was specified by the server as a parameter to p_minit). + + +If pia does not have a free message slot, p_msend waits (on a mutual exclusion semaphore) until it does. + + +This function is only really suitable for sending messages where the whole information fits in the +message. That is, the data at pMessage should not contain the address of further data to be copied (using +p_pcpyfr) because there is no way of knowing when the server will copy the data so that pMessage may be +re-used. Where the message does reference further data, p_msendreceivew Of p_msendreceivea should be +used. + + +A client should certainly use p_msendreceivew Of p_msendreceivea if the service is to return information +(eg success or failure). + + +p_msendreceivew Send a message and wait for a reply + + +INT p_msendreceivew(HANDLE pid, UINT mType, VOID *pMessage) ; + + +Send message pMessage Of type mType to process pid and wait for the server to reply (which it does by +calling p_mfree (pid, nReply) ) and return the reply nreply. + + +Return immediately with the negative &_GEN_RECEIVER if pid does not exist or if process pia has not +called p_minit. + + +The message is deposited into a free message slot in the server where the member type in the E_MESSAGE +header is set to mtype and the message body is copied from pMessage (where the length of the message +was specified by the server as a parameter to p_minit). + + +If pia does not have a free message slot, p_msendreceivew waits (on a mutual exclusion semaphore) until +it does. + + +p_msendreceivea Asynchronous send message and get reply + + +INT p_msendreceivea (HANDLE pid, UINT mType, VOID *pMessage, WORD *pStatus) ; + + +Send message pMessage of type mType to process pia and asynchronously request a reply from the server. +Return zero if the message was successfully sent or the negative E_GEN_RECEIVER if pid does not exist or if +process pid has not called p_minit. + + +When the server completes the request and calls p_mfree (pid, nReply), *pStatus 1S Set to nReply and the +client's process I/O semaphore is signalled. While the reply is pending, *pstatus contains +E_FILE_PENDING. + + +The message is deposited into a free message slot in the server where the member type in the E_MESSAGE +header is set to mtype and the message body is copied from pMessage (where the length of the message +was specified by the server as a parameter to p_minit). + + +If pia does not have a free message slot, p_msendreceivea Waits (on a mutual exclusion semaphore) until +it does. + + +12-25 + + +CHAPTER 13 + + +GENERAL SYSTEM SERVICES + + +System information + + +p_version Get the operating system version +UINT p_version(VOID) ; +Return the operating system version number. +The returned version number should be interpreted as a 4-digit hexadecimal number of the form: +X.YYZ + + +where x is the major release number, yy is the minor release number and z is normally the hexadecimal +digit F (internal releases use a and B to designate alpha and beta releases, respectively). + + +For example, a return of 0x123F is interpreted as 1.23F. + + +p_romversion Get the ROM version +UINT p_romversion (VOID) ; +Return the ROM version number. + + +The ROM contains the operating system and other system components such as, for example, the window +server. The tool used to build the ROM requires a version number to be specified and this is the version +number that is retrieved by this function. + + +See p_version above for the interpretation of the version number. + + +p_getres Get the cause of the last system shut-down +INT p_getres (VOID); +Return a number indicating the cause of the last system shut-down, as follows: + + +E_IS_A_COLD_START The system started up for the first time (or after a period during which all +power had been removed, including the Lithium back-up). + + +E_IS_A_POWERFAIL_START The hardware forced a shut-down because the voltage got too low. This +should not happen because the system software gets a non-maskable +interrupt if the voltage drops below a certain threshold (but not low +enough for the hardware to force a shut-down) and this interrupt code +automatically switches the hardware off. However, if the clean-up takes +too long because of a poorly designed device driver, the hardware will +force the machine off before the interrupt completes - in which case +p_getres returns E_IS_A_POWERFAIL_START. The environment variables +and the contents of m: are preserved. + + +PLIB REFERENCE + + +E_IS_A_RESET_START The machine has been reset by pressing the recessed reset button. The +environment variables and the contents of m: will have been preserved (a +soft reset). + + +If the Esc key is held down while pressing the reset button, this causes a +hard reset. In this case both the environment variables and the contents of +m: will have been cleared. + + +Note that this value will not occur on a Workabout, since this machine +does not have a reset button. + + +E_IS_A_KERNEL_FAULT The system was reset because a serious fault occurred while executing in +the operating system kernel. This could result from: (1) a bug in the +operating system or a system process; (2) a program bug that managed to +overcome the operating system's defences or (3) a hardware problem such +as a RAM fault. The environment variables and the contents of mM: will be +preserved (unless the system detects a memory corruption). + + +On the Workabout, this value is also returned if the system is reset by +pressing Psion-Ctrl-Del. This is the equivalent of a soft reset on other +machine types and preserves both the environment variables and the +contents of M:. + + +E_IS_A_NEW_OS_START The system was reset after programming a new operating system into the +Flash ROM (normally after running the repro program). The +environment variables and the contents of m: have been cleared. + + +On the Workabout, this value is also returned if the system is reset by + +pressing Shift-Psion-Ctrl-Del. This is the equivalent of a hard reset on +other machine types and clears both the environment variables and the +contents of M:. + + +p_getosd Get operating system data +VOID p_getosd(VOID *pTarget, VOID *pSource, UINT length); +Copy length bytes from offset psource in the operating system data space to pTarget. + + +Operating system handles (such as memory segment handles and semaphore handles) are actually +addresses in the operating system data space of the appropriate control entry. + + +If you AND a process ID with E_PIDMASK you get the address in operating system space of the +corresponding process control entry - as described in the chapter Processes and Inter-Process Messaging. + + +p_getpsu Get power supply type +INT p_getpsu (VOID); + + +-Return one of the following values, defined in epoc.h, to indicate the power supply type on a SIBO +machine: + + +E_PSU_OLD +E_PSU_MAXIM +E_PSU_S3 +E_PSU_S3_A9 + + +Apart from this service EPOC hides the differences between the various power supplies. + + +Machines in the MC GI range of SIBO computers, for example, may use either the E_Psu_oLD or the +E_PSU_MAXIM power supply variants, each of which requires a slightly different variant of the EPOC +operating system. The REPRO program that blows a new operating system into the Flash ROM of the MC +GI range uses this service to blow the appropriate variant of EPOC. + + +13-2 + + +13 GENERAL SYSTEM SERVICES + + +Language and country + + +SIBO machines are produced in a number of language variants, differing in the following respects: +e the language code + + +e the language of the text used by the ROM-based software (for example, the error messages +returned by p_errs and the month names returned by p_nmmon) + + +e character type and conversion tables as described in the chapter Characters, Strings, Buffers and +Queues + + +e = the keyboard layout +e = the default country and country-dependent data + + +A particular language variant will always have a different language code and text but may not differ in all +the above. + + +The system was designed to be produced in a variety of languages and, as far as the system services are +concerned, all the above variations are encapsulated in a single configuration file in the ROM called +ROM: :SYS$CTRY.CFO. Depending on the machine, there may be further files (for example, "resource +files") containing language-dependent data for higher level system components. + + +Unlike the language-dependent data, the country-dependent data may be altered from the language- +dependent defaults. + + +p_getlanguage Get the language code +INT p_getlanguage (VOID) ; +-Return the language code from the ROM configuration file. + + +The language code can be used by applications that contain the text for more than one language to +determine which language to present. The language codes, defined in p_config.h, are as follows: + + +English +French +German +Spanish +Italian +Swedish +Danish +Norwegian + + +OMANI HDOBWNHE +hobo’ to bt tb obo tot + + +Finnish +USA +Swiss french +Swiss German +Portuguese +Turkish +Icelandic +Russian +Hungarian +Dutch +Belgian Flemish +Australian +New Zealand +Austrian + + +NNN N +WNHrRFROWOOAANAT AO PWN EF OO + + +Belgian french + + +p_gettext Get operating system text +INT p_gettext (INT n, TEXT *pBuffer); +Get the nth string from the ROM configuration file and write it to pBuffer. + + +Returns zero if successful or the negative z_cEN_arc if n 1s outside the range of the text strings in the +configuration file. + + +PLIB REFERENCE + + +This function is called by specific text retrieval functions such as p_errs and p_nmmon. + + +Applications only need to use p_gettext when retrieving text associated with a higher level of system +software (in which case the documentation of the higher level software will list appropriate values of n). + + +p_getctd Get country-dependent data +VOID p_getctd(E_CONFIG *pcfg); +Write a copy of the system E_conFiIc struct to pcfg where the E_conFIc struct is defined in p_config.h as: + + +typedef struct +{ + + +UWORD countryCode; + +WORD gmtOffset; + +UBYTE dateType; + +UBYTE timeType; + +UBYTE currencySymbolPosition; +UBYTE currencySpaceRequired; +UBYTE currencyDecimalPlaces; +UBYTE currencyNegativelInBrackets; +UBYTE currencyTriadsAllowed; +UBYTE thousandsSeparator; +UBYTE decimalSeparator; +UBYTE dateSeparator; + +UBYTE timeSeparator; + +UBYTE currencySymbol [9]; +UBYTE startOfWeek; + +UBYTE summerTime; + +UBYTE clockType; + +UBYTE dayAbbreviation; + +UBYTE monthAbbreviation; +UBYTE workDays; + +UBYTE units; + +UBYTE spare[9]; + + +} E_CONFIG; . + + +The count ryCode specifies a country by its international dialling code, and units is O for imperial units or +1 for metric units + + +See the description of p_getctd in the chapter Time, Timers and Dates for a description of the time- +related fields: gmtOffset, dateType, timeType, dateSeparator, timeSeparator, startOfWeek, +summerTime, clockType, dayAbbreviation, monthAbbreviation and workDays + + +See the description of p_getctd in the chapter Floating Point for a description of the fields that are +related to the display of floating point numbers and currency: currencySymbol, currencySymbolPosition, +currencySpaceRequired, currencyDecimalPlaces, currencyNegativelInBrackets, +currencyTriadsAllowed, thousandsSeparator and decimalSeparator. + + +p_setctd Set country-dependent data +VOID p_setctd(E_CONFIG *pcfg) ; +Sets the country-dependent data from the E_conrté structure pointed to by pcfg. +When changing a particular field or fields you would normally: +@ use p_getctd to get a copy of the E_conrie struct +e modify the field or fields, as required + + +@ use p_setctd to write back the modified E_conFIe struct + + +13-4 + + +13 GENERAL SYSTEM SERVICES + + +Switching on and off + + +By default, the auto-switch-off period is set to 300 seconds. The auto-switch-off period may be sensed and +set by calling p_getauto and p_setauto respectively. Auto-switch-off when a mains adaptor is connected +may be disabled by calling p_setautomains, and the corresponding state sensed by p_getautomains. + + +The zero priority null process automatically switches the machine off to reduce power consumption after +the system has been inactive for the auto-switch-off period. In situations where the null process does not +get an opportunity to run, a process can assume responsibility for allowing the machine to switch off by + +calling p_allowoff. + + +Some processes are marked as not being significant when it comes to determining what constitutes +activity. For example, a continuously running clock program should not stop the system from +automatically switching off in the absence of any significant activity. See p_unmarka and p_marka in the +chapter Processes and Inter-Process Messaging for additional details on how to avoid keeping the +machine switched on by continuously running applications. + + +p_off Switch off + + +VOID p_off(UINT uTime) ; + + +Switch off the machine indefinitely or for any time up to approximately 4.5 hours and return when the +machine switches on. + + +If uTime is oxf££f the machine switches off indefinitely and will stay off until an outstanding absolute +timer expires or the user switches on the machine. Equivalent to the machine automatically switching off +or being switched off by the user. + + +If uTime is greater than 8, the machine switches off for up to uTime 1/4ths of a second (although it will +still switch on if an outstanding absolute timer expires or the user switches on the machine). (If uTime is +less than or equal to 8, calling p_ofr has no effect.) + + +On the IBM PC version of EPOC, calling p_or¢ has no effect. + + +p_getauto Get the auto-switch-off period +INT p_getauto(VOID); +Return the current auto-switch-off period in seconds. + + +If the auto-switch-off period is oxf££4, the system does not automatically switch off. + + +p_setauto Set the auto-switch-off period +VOID p_setauto(INT n); + +Set the auto-switch-off period to n seconds. + +Passing an n of -1 (oxf££4£) stops the system from automatically switching off. + + +Calling p_setauto with n less than 15 is equivalent to calling p_setauto(15). + + +p_getautomains Get switch-off state when mains is present +INT p_getautomains (VOID) ; +This function is only available in EPOC version 3.18 or later. + + +Return true if auto-switch-off is disabled when mains is present, otherwise return FALSE. + + +PLIB REFERENCE + + +p_setautomains Disable/enable switch-off if mains is present +VOID p_setautomains (INT flag) + +This function is only available in EPOC version 3.18 or later. + +Disable or enable auto-switch-off if mains is present. + + +If flag is TRUE, auto-switch-off is disabled while mains is present and if flag is FALSE, auto-switch-off is +enabled. + + +Even if enabled, the machine will not switch off when mains is absent if switch-off has been stopped by +use of p_setauto. + + +p_allowoff Allow auto switch off +VOID p_allowoff (VOID) ; +Allow the machine to switch off if the auto-switch-off period has expired. + + +A compute-bound process which has marked itself as non-active (by calling p_unmarka) does not allow the +machine to switch off since the null process will never get an opportunity to run. Such a process should +call p_allowoff from time to time. There is no particular advantage in calling p_allowoff more +frequently than at intervals of 15 seconds - the shortest auto-switch-off period. + + +On the IBM PC version of EPOC, calling p_allowoff has no effect. + + +p_setonevent Enable/disable the ON key event +VOID p_setonevent (INT state) + +This function is only available in EPOC version 2.28 or later. + +Enables or disables the event that is sent to the window server when the ON key is pressed. + + +If state is FALSE, the event is disabled, any other value enables the event. + + +Pe i a __________________________iy +Power supply + + +This section describes functions to: + + +e determine the presence or absence of the main battery, the Lithium backup battery or the mains +adaptor (p_supplyinfo) + + +e get the voltage level of the main battery (or mains adaptor, if present) and the Lithium backup +battery (p_supply) + + +e determine whether the mains adaptor is connected (p_supp1ly) + + +e get the nominal maximum voltages of the main battery and the Lithium backup battery +(p_wsupply) + + +e¢ get the recommended low voltage warning levels for the main battery and the Lithium backup +battery (p_wsupply) + + +e get the time and date of insertion of the main battery, and information about main battery usage +(p_supplyinfo) + + +e sense and set the main battery type (p_getbat and p_setbat respectively) + + +The main battery type is only significant on machines that can take more than one battery type (such as +the MC GI range) and affects the voltages returned by p_wsupply. + + +13-6 + + +13 GENERAL SYSTEM SERVICES + + +The main battery types are as follows: + + +E_BATTERY_UNKNOWN the battery type is initially set to this value when EPOC starts up (equivalent in +its effect to E_BATTERY_ALKALINE) + + +E_BATTERY_ALKALINE the battery is an Alkaline + + +E_BATTERY_NICAD_600 __ the battery is a 600 mA hour NiCd rechargeable + + +E_BATTERY_NICAD_1000 _ the battery is a 1000 mA hour NiCd rechargeable + + +If the hardware is unable to identify automatically the battery type, it is the responsibility of the user to set +the battery type to match that actually fitted. The r_BaTTERY_UNKNowN value is intended to trigger the +system into prompting the user to identify the battery type. + + +p_supply Get power supply status +VOID p_supply(E_SUPPLY *pValue) ; +Write the status of the various supplies to the z_supp.y struct at pvalue where E_supp.y is defined as: + + +typedef struct +{ +UWORD mainBatteryReading; +UWORD lithiumBatteryReading; +WORD mainsPresent; +} E_SUPPLY;. + + +where: + + +mainBatteryReading is the main battery voltage in millivolts (or the mains adaptor voltage if the +mains adaptor is present) + + +lithiumBatteryReading _ is the Lithium backup battery voltage in millivolts + + +mainsPresent is negative if the mains adaptor status cannot be determined (because the SSD +pack doors are open); zero if the mains adaptor is not present; one if the mains +adaptor is present + + +p_supplyinfo Get additional power supply data +VOID p_supplyinfo(E_SUPPLY_INFO *pValue) ; + +This function is only available in EPOC version 3.18 or later. + +Write information concerning the various power supplies to the E_suPPLY_INFo Struct at pvalue. + +The &_suppLy_1nFo is defined in epoc.h as: + + +typedef struct + +{ + +UBYTE mainBatteryLevel; +UBYTE mainBatteryStatus; +UBYTE backupBatteryLevel; +UBYTE dcLevel; + +UWORD warningFlags; +ULONG insertionDate; +ULONG ticksInUseBattery; +ULONG ticksInUseDc; +ULONG maTicks; + +} E_SUPPLY_INFO;. + + +13-7 + + +PLIB REFERENCE + + +where: + + +mainBatteryLevel + + +mainBatteryStatus + + +backupBatteryLevel + + +dcLevel + + +warningFlags + + +insertionDate + + +ticksInUseBattery + + +ticksInUseDc + + +maTicks + + +is the present status of the main battery. It describes the voltage level as being in +one of four discrete states: + + +a) E_MBAT_GOOD +battery voltage is good + + +b) E_MBAT_LOW +battery voltage is low + + +C) E_MBAT_VERY_LOW +battery voltage is very low + + +d) E_MBAT_ZERO +there is no battery present! + + +No precise figures for the actual voltage levels corresponding to these states are +given. + +is the same as mainBatteryLevel described above except that it records the +lowest level that the battery has reached. It is reset when the main batteries are +removed from their housing. + + +is TRUE if the Lithium backup battery is present and ratse if the backup battery +level is low or the battery is not present + + +is TRUE if the mains adaptor is present and powered up +is a set of flags which can be one of: + + +a) E_SUPPLY_SYSTEM_TIME_CHANGED + +this flag only has meaning when the battery insertion date changes. If set, it +means that the system time has changed; if not set, it means that the main battery +has been changed. + + +b) E_SUPPLY_SOUND_WARNING + +this flag is set if the battery power level is too low to operate sound. Its setting +implies that the user has been warned at least once before of the failure of an +attempt to generate sound. + + +C) E_SUPPLY_FLASH_WARNING + +this flag is set if the battery power level is too low to operate a flash SSD. Its +setting implies that the user has been warned at least once before of the failure of +an attempt to write to flash. + + +These warning flags are intended to be used only for supplying information to a +user. The last two, in particular, do not necessarily imply that an attempt to +generate sound or to write to flash will definitely fail. Even if either or both of +these warning flags are set, the attempt may succeed - for example, either because +the battery voltage has recovered since an earlier failure, or because the machine +is now connected to mains power. An application is not expected to test either of +these flags before attempting the corresponding operation - failures should simply +be handled by standard error-recovery techniques. + + +is the system time when the present main battery was inserted + + +is the total length of time in 'ticks' (1/32 second) for which the machine has been +switched on and powered by the main battery. Any period during this time when +the machine has been powered by the mains adaptor is excluded from the total. + + +is the length of time in 'ticks' (1/32 second) for which the machine has been +switched on and powered using the mains adaptor. + + +is the cumulative current delivered by the present main battery; it is a product of +current x time and is measured in units of milliamps x 'ticks' where a 'tick' is 1/32 +second + + +On machines that use the ASIC1 chip (that is, the Series 3 classic and HC) this information is not +available, even if the machines contain version 3.18 or later of EPOC. In such a case, p_supplyinfo +writes zero values to all members of the E_SUPPLY_INFOo struct. + + +13-8 + + +13 GENERAL SYSTEM SERVICES + + +p_wsupply Get battery warning and maximum levels + + +VOID p_wsupply (E_SUPPLY_WARNINGS *pValue) ; + + +Write the recommended low voltage warning level and the nominal maximum voltage of the main battery +and the Lithium backup battery to pvalue. + + +The &_SUPPLY_WARNINGS Struct is defined as: + + +typedef struct +{ +UWORD mainBatteryWarning; +UWORD lithiumBatteryWarning; +UWORD mainBatteryMax; +UWORD lithiumBatteryMax; +} E_SUPPLY_WARNINGS; . + + +where: + +mainBatteryWarning is the recommended voltage at which to warn the user of a low main battery + +lithiumBatteryWarning is the recommended voltage at which to warn the user of a low Lithium +backup battery + +mainBatteryMax is the nominal maximum voltage of the main battery + +lithiumBatteryMax is the nominal maximum voltage of the Lithium backup battery + + +All voltages are provided in millivolts. + + +If the host machine can take more than one battery type, the voltages will depend on the battery type set +with p_setbat. + + +p_getbat Get the battery type + + +INT p_getbat (VOID); +Return the current battery type. +The battery types of the form =_BATTERY_xxx are described at the beginning of this section. + + +On machines whose hardware does not support detection of the battery type, a call to this function should +be preceded by a call to p_setbat. + + +p_setbat Set the battery type + + +INT p_setbat (INT nType); + + +Set the battery type to nType and return zero if successful or E_GEN_nsup if battery type nType is not +supported by the hardware. + + +The battery types of the form &_BATTERY_xxx are described at the beginning of this section. + + +This function has no practical effect on machines, such as the Workabout, whose hardware supports the +detection of the battery type. + + +Keyboard + + +p_getscancodes Get the state of all keys +INT p_getscancodes (UWORD *pScan) ; + +This function is only available in EPOC version 3.18 or later. + +Write the current state of all the keys on the keyboard to the array of ten words pointed to by pscan. + + +Each key corresponds to a bit in the word array. In the case of the Series 3a, the lowest eleven bits in each +of the first eight words are used. All other machines in the SIBO range use the lowest eight bits in all ten +words. If a key is depressed the corresponding bit will be set, otherwise it is clear. + + +13-9 + + +PLIB REFERENCE + + +The mapping between keys and bits in the array varies from machine to machine. In all cases, however, if +no key is depressed all ten words in the array will contain zero. The following example, to detect if any +key is pressed, is suitable for use on all SIBO machines: + + +GLDEF_C IsKeyDown (VOID) +{ +UWORD *p; +UWORD scans[10]; + + +p=&scans [0]; +p_getscancodes (p) ; +for (;p<=&scans[9];p++) +{ +if (*p) +return (TRUE) ; +} +return (FALSE) ; +} + + +The mapping between keys and the bits within the array for the Series 3a keyboard is given in the +description of the EPOC HwGetScancodes service, in the Hardware Management chapter of the EPOC +O/S System Services manual. + + +Display +p_geticd Get the system display type + + +INT p_getlcd(VOID); +-Return the (positive) system display type, where the display types are defined in epoc.h. +The function returns -1 if the host is a PC that has an unknown display type. + + +On a SIBO machine the display type is a good way of +identifying the model. The appropriate constants are defined in epoc.h. Examples are: + + +E_LCD_640_400 a 640x400 pixel display as on the MC 400 +E_LCD_640_200_SMALL a 640x200 pixel display as on the MC 200 +E_LCD_160_80 a 160x80 pixel display as on the HC +E_LCD_240_80 a 240x80 pixel display as on the Series 3 +E_LCD_480_160 a 480x160 pixel display as on the Series 3a +E_LCD_240_100 a 240x100 pixel display as on the Workabout + + +On a PC, the display types are: + + +E_PC_HERC Hercules graphics adaptor + +E_PC_CGA CGA graphics adaptor + +E_PC_MDA MDA display adaptor +E_PC_EGA_MONO EGA monochrome graphics adaptor +E_PC_EGA_COLOUR EGA colour graphics adaptor +E_PC_VGA_MONO VGA monochrome graphics adaptor +E_PC_VGA_COLOUR VGA colour graphics adaptor + + +If p_get1cd returns -1 (which can only happen on a PC), and you choose not to fail, it is recommended +that you proceed as if it had returned E_Pc_vGA_mMoNno. + + +p_Icdcontrastdelta Change the LCD contrast + + +VOID p_lcdcontrastdelta(INT nDelta); + + +Step the LCD contrast up or down depending on whether nbde1ta is positive or negative respectively (the +magnitude of nDelta is ignored. + + +The LCD contrast is changed through a sequence of values in a circular fashion. That is, stepping the +LCD contrast up when it is already at its maximum value sets it to its minimum value and vice versa. + + +The sequence of values that may be set varies from model to model. On a particular model, the values can +be ascertained by using p_get1cdcont rast, described below. + + +13-10 + + +13 GENERAL SYSTEM SERVICES + + +p_geticdcontrast Get the current LCD contrast + + +INT p_getlcdcontrast (VOID) + + +Return the current LCD contrast setting. + + +p_backlight Switch the backlight on or off +INT p_backlight (INT mode) ; + + +Switch the backlight on or off, depending on mode as follows: + + +E_BACKLIGHT_OFF switch the backlight off (if it is not already off) + +E_BACKLIGHT_ON switch the backlight on (if it is not already on) and reset the auto-switch-off +timer + +E_BACKLIGHT_TOGGLE switch the backlight on and reset the auto-switch-off timer if it is currently off +or switch the backlight off if it is currently on + +E_BACKLIGHT_QUERY does nothing and is used just to get the current backlight on/off state + + +For EPOC version 3.57 and above, provided a backlight is fitted, the function returns the on/off state +(&_BACKLIGHT_ON if on, E_BACKLIGHT_oFF if off) as it was as the function was entered. If no backlight is +fitted, the function returns E_GEN_NSUP. + + +For earlier versions of EPOC, the return value is unreliable. + + +p_setbacklight Set the backlight control value +VOID p_setbacklight (UINT flag) ; +Enable or disable the backlight key and set the backlight auto-switch-off interval in ticks. + + +If the most significant bit of f1ag is set (as given by the bit mask &_BACKLIGHT_DISABLE), the operating +system will not respond to the backlight key. (However, this does not stop the backlight from being +switched by a program calling p_backlight.) + + +The lower 15 bits of £1ag specifies the backlight auto-switch-off interval in ticks (1/32ths of a second). If +this value is zero, the backlight is not automatically switched off by a backlight timer and it will remain +on until the machine switches off. + + +For example: +p_setbacklight (96); + +sets the backlight auto-switch-off interval to 3 seconds and: +p_setbacklight (E_BACKLIGHT_DISABLE | (32*5)); + + +sets the backlight auto-switch-off interval to 5 seconds and disables the backlight key. + + +p_getbacklight Get the backlight enablement +UINT p_getbacklight (VOID) ; + + +Return the backlight control value as set by p_setbacklight, described above. + + +13-11 + + +PLIB REFERENCE + + +Sound + + +Most SIBO machines contain a piezo-electric buzzer in addition to a loudspeaker. + + +This section describes how to use the piezo to make a sound, and how to manipulate the set of flags used +to control the sound produced by the system. + + +The piezo uses very little power and is an easy way of generating sound, although it is fairly quiet. +Consider using the snp: device driver, which drives the loudspeaker, if greater sound complexity or a +louder sound is required. The snp: device driver is described in the I/O Devices Reference manual. + + +The bit masks for the flags controlling sound output are: + + +E_SOUND_KEYBOARD keyboard clicks are silenced if clear + +E_SOUND_BUZZER the piezo sound system is silenced (except for keyclicks) if clear +E_SOUND_DEVICE the snp: device driver is silenced if clear + +E_SOUND_LOUD the piezo will sound louder if set + +E_SOUND_DISABLE all sound in the system is silenced if set + +p_sound Make a sound with the piezo + + +VOID p_sound(UINT nDuration, UINT nPitch); + + +Make a sound through the piezo for nDuration system ticks and at pitch nPitch (where the pitch has +frequency 512/nPitch KHz). + + +Shared access to this piezo service is controlled by first waiting on a mutual exclusion semaphore that has +been pre-counted with 1 (mutual exclusion semaphores are described in the chapter Asynchronous +Requests and Semaphores). The effect of the mutual exclusion semaphore, assuming the piezo is not +already in use, is that the first call to p_souna will complete immediately but subsequent calls will wait +until the current operation completes. The result is that there could be an indefinite wait before the sound +is made. + + +If nDuration is passed as a negative value the call will always complete immediately, but will fail to make +a sound if the piezo is currently in use. + + +For example: +p_sound (5,320); + +makes a short beep, suitable for accompanying an error notification. The call: +p_sound (-5, 320); + + +will make the same sound, provided the piezo is not in use. + + +p_getsnd Get the sound flags +INT p_getsnd(VOID); +Return the current setting of the sound flags. + + +The flags are described at the beginning of this section. + + +p_setsnd Set the sound flags +VOID p_setsnd(INT nFlag); +Set the sound flags to nFlag. + + +The flags are described at the beginning of this section. + + +13-12 + + +13 GENERAL SYSTEM SERVICES + + +Sound on the Series 3a + + +The Series 3a machine does not contain a piezo-electric buzzer, so all sounds are made via the +loudspeaker. The Series 3a operating system does, however, contain a buzzer emulator (using the snp: +device driver) that supports the sound services described in the previous section. + + +This does, of course, mean that the p_sound service uses more power than in the case of machines that +contain a piezo-electric buzzer. Since all sounds are produced via the snp: device driver, sounds that, in +other machines, use the buzzer (keyclicks, for example) are disabled while the Series 3a is playing a +sound, such as an alarm. + + +Sound files +Series 3a sound files are files that contain a 32-byte header and a byte stream of A-Law encoded digital +sound. Such files normally have a .wve extension. + + +During recording 13-bit (a sign bit plus 12 magnitude bits) sound samples is converted to an 8-bit data +stream at 8000 bytes per second by CODEC hardware, using A-Law encoding. During playback the byte +stream is sampled at 8000 bytes per second and decoded to 13-bit sound by the CODEC. + + +In C, the file header is represented by the following struct (defined in epoc.h): + + +#define SignatureSize 16 +#define ALawSignature "ALawSoundFile**" + + +typedef struct +{ +TEXT Signature[SignatureSize]; +UWORD Version; +ULONG Samples; +UWORD SilenceInTicks; +UWORD Repeats; +UWORD Spare[3]; +} SndFile;. + + +This header is written and read by the Series 3a sound services described below. The meanings of the +items in the sndFile struct are: + + +Signature the 16-byte (including the zero terminator) string "ALawSoundFile**". + + +Version the Series 3a sound file version number as a 4-digit hexadecimal number of the +form xvyz, where x is the major release number, yy is the minor release number +and z is normally the hexadecimal digit r. See, for example, the description of + + +p_version. + + +Samples the number of bytes following the header. This must always be size of file less +the 32 bytes for the header. Dividing this by 8000 gives the duration of the +sound in seconds. + + +SilenceInTicks the number of system ticks of silence appended to each repeat on playback (in +practice, you get at least 2 ticks between repeats). + +Repeats the number of times to repeat the sound on playback (0 and | are the same). + +Spare reserved for future use. + + +A system tick is a 1/32th of a second, equivalent to 250 samples. + + +The program wav2wve.exe, supplied with the SDK (it is installed to the \sibosdk\sys directory) converts +.wav sound files to the .wve format. + + +The A-Law encoding scheme + + +The encoding scheme compresses signed, 12-bit magnitude (13 bits in all) samples into an 8-bit +representation. + + +A-Law encoding uses a logarithmic compression to reduce the size of sound files whilst preserving the +overall sound quality. The use of a logarithmic scale ensures that the low amplitude signals (which +contain most of the information in speech signals) are stored and reproduced with a minimal loss of +fidelity. + + +The A-Law encoding and decoding schemes are illustrated in the following sections. + + +13-13 + + +PLIB REFERENCE + + +Encoding + + +If the input data is represented by a normal two's complement signed value, it must first be converted into +a 12-bit magnitude, plus a 13th sign bit. For example, a value of -1 (represented by the 16-bit two's +complement value of 0xff£££) must be converted to the 13-bit binary representation (1) 000000000001, +where brackets indicate the sign bit. + + +The following table represents the range of possible 13-bit inputs. In this table an x character indicates +either a one or a zero (a "don't care" state) and an s character represents the sign bit: + + +0 +0 +0 +0 +0 +0 +0 +a + + +VrFOCCCCCO +TMrFDdAO0OCO +Qa7MmrFDVDGACO + + +faeces! +eucaeeeas + + +HANNNNHDADADN +xx AaATWrO +xxx AAOTM mM +xx xXKM ATS +xxx MM AAA +xx xxM MK OO +xxx MMM MM + + +A-Law compression of the above 13-bit inputs leads to the following range of 8-bit output values: + + +PRRERPODOO +PROOFRFOO +FPOrFPOFOFRSO +TOC OCC OO +aaaaaaa a + + +Ss +Ss +Ss +Ss +Ss +Ss +Ss +Ss + + +oo ooo mw ow w +aaaqaaaqaaaa + + +The compressed data is computed according to the following rules: +e the most significant bit preserves the sign bit of the original data item + + +e the following three bits represent the magnitude of the original data item, by recording the +position of the most significant non-zero bit (but note that the smallest magnitude group is +treated exceptionally) + + +e the remaining four bits record the next four most significant bits of the original data (in all but +the first group, these are the four bits that follow the most significant non-zero bit) + + +The compressed data is then manipulated to invert bits 0, 2, 4 and 6. This manipulation brings the ratio of +ones to zeroes closer to 50:50 and thus improves analog transmission of the data. + + +Examples of A-Law encoded data are given in the following table, where brackets identify the sign bit. + + +signed input 13-bit data compressed data encoded output +-1 (1)000000000001 (1)0000000 (1)1010101 ++2 (0)000000000010 (0)0000001 (0)1010100 +-371 (1)000101110001 (1)1000111 (1)0010010 ++2074 (0)100000011010 (0)1110000 (0)0100101 + + +A-Law encoding can be performed most simply and rapidly by means of a look-up table. Note that a 2048- +element table is sufficient, since the least significant bit of the input data has no effect on the encoded +value. + + +13-14 + + +13 GENERAL SYSTEM SERVICES + + +Where speed is not of the essence, an algorithmic method may be used, such as that illustrated by the + + +following code: + + +#define MAGICXOR 0x2a +#define ONE 1 +#define BIT8 0x80 +#define MASK2 0x03 +#define MASK3 0x70 +#define MASK4 Ox0f +#define MASK8 Oxff + + +GLDEF_C INT Compress(INT x) +/* + + +Compress input 16-bit 2's complement integer +8-bit signed compressed number using A-law. + + +ee: +{ +INT p,S,y; + + +/* convert 2's complement to sign bit and magnitude */ +p=BIT8; /* p is the (inverted) + + +if (x&0x1000) +{ + + +X= -X; +X&=OxFFF; +p=0; + + +} + + +if (x& (MASK4<<8)) /* Find leading + + +{ +if (x& (MASK2<<10) ) +s=(x& (ONE<<11)) ? +else +s=(x& (ONE<<9)) ? 5 +} +else +{ +if (x& (MASK2<<6) ) +s=(x& (ONE<<7)) ? 3 +else +s=(x& (ONE<<5)) ? 1 +} +if (s==0) +y=x>>1; +else + + +y=((x>>s) &MASK4) | (s<<4); +return ((~((y|p) *MAGICXOR) ) &MASK8) ; + + +} + + +sign bit */ + + +(13-bit magnitude) to + + +using binary search */ + + +Note that the final bit manipulation is done by adding in the (inverted) sign bit, performing an exclusive +or with maGIcxor (0x2a - inverting bits 1, 3 and 5) and then complementing the result. This exactly +corresponds with the formal definition of A-Law compression and also has the effect of restoring the sign + + +bit. + + +It would be marginally more efficient to replace the definition of macicxor with: + + +#define ALTXOR 0xD5 + + +and replace the last line of the function with: + + +return (((y|p) “ALTXOR) &MASK8) ; + + +13-15 + + +PLIB REFERENCE + + +Decoding + + +Decoding an A-Law compressed data value broadly consists of reversing the process that is described in +the previous section. + + +The bit manipulation is first reversed, by re-inverting bits 0, 2, 4 and 6. This results in the range of +possible 8 bit values as follows + + +0 +0 +0 +0 +1 +1 +1 +1 + + +ANDNHNANHADNA +PROORROO +FPOrROGCrROrROA +oo ooo ow w® +[on ON ON OE ON OME OO} +qgqaaqaaqaaqaaa +aaaaaaaa + + +Decompressing these 8 bit inputs using A-Law decoding leads to the following 13 bit outputs: + + +FOOCOCOO +CrFODCCCACO +ToMrFWCAOA0CO +QavTMrFDCOCSO +aanowraaonao +rPaATWMrFrAO +OrFaATMrFO +cooraQaqnoga yw +oooraq ogo +ooooraaqa +coooorga +COCO COOFRF + + +Ss +Ss +Ss +Ss +Ss +Ss +Ss +Ss + + +The decompressed data is computed according to the following rules: +e the most significant bit preserves the sign bit of the compressed data item + + +e the following three bits of the compressed data are used to determine the position of the most +significant non-zero bit of the decompressed data (but note that the smallest magnitude group is +treated exceptionally) + + +e the remaining four bits of the compressed data are used as the next four most significant bits of +the decompressed data (in all but the first group, these are the four bits that follow the most +significant non-zero bit) + + +e the next most significant bit of the decompressed data is set to one and any remaining trailing +bits are set to zero. The resultant value is thus set to the mean of all the possible values which, on +compression, give the value that is being decoded + + +If the output data is required in 16-bit two's complement format, then the sign bit must be extracted from +the data and, if it is set, the decoded value should be negated. + + +Examples of decoding are given in the following table, where brackets identify the sign bit. + + +encoded data compressed data 13-bit data signed output +(1)1010101 (1)0000000 (1)000000000001 -1 + +(0)1010100 (0)0000001 (0)00000000001 1 +3 +(1)0010010 (1)1000111 (1)000101111000 -376 +(0)0100101 (0)1110000 (0)100001000000 +2112 + + +The starting values in this table are the results from the encoding examples given in the previous section. +Notice that compression followed by decompression loses some of the information, as is expected. + + +13-16 + + +13 GENERAL SYSTEM SERVICES + + +As for encoding, A-Law decoding can be performed by means of a look-up table. In this case, a 256- +element table is sufficient. It is, however, simple to perform the decoding algorithmically, as illustrated in +the following code: + + +#define XORMASK 0x55 +#define BIT8 0x80 +#define MASK3 0x70 +#define MASK4 Ox0f +#define MASK8 Oxff + + +GLDEF_C INT ALawDecode (INT x) +/* +Expand input 8-bit signed compressed number to 16-bit +2's complement integer (13-bit magnitude) using A-law. +Si), + +{ + +INT s,y; + + +x= (x*XORMASK) &MASK8; +S=(x&MASK3) >>4; + + +y=0; +if (s) +{ +y=0x10; +s-=1; +} +y=(( (y+ (x&MASK4) ) <<1) +1) < + + +as well as the header files for using CLIB and/or PLIB. + + +Connecting to the window server + + +To use the services of the window server, a process must first connect to it by calling wconnect (or a +function that calls wconnect such as wStartup). + + +Not all processes are clients of the window server but an application process that is presenting a user +interface is likely to be a client”. + + +How you connect to the window server depends on whether you are using the CLIB or the PLIB C +startup module and what machine you are running on. + + +Note that the default project files set up by the installation of the SDK use the CLIB startup module. +Using the CLIB startup module on the HC, S3, S3a or Workabout + + +The CLIB startup module automatically opens a channel to the console device con:. This channel is +used to implement the CLIB functions that access the screen display and the keyboard. For example, +such functions as printf, gets, cprintf and cgets. + + +On an HC and all Series 3 machines, the console device is implemented such that opening it connects +to the window server, making the process a client of the window server. When using the CLIB startup +module, you take advantage of this console connection - as described in this section. If you mistakenly +attempt to connect a second time by calling wconnect or wStartup in your program, the process will +be panicked with panic number 100. + + +When the CLIB startup module opens con:, it puts the channel in the static variable winHandle, +which may be referenced as: + + +GLREF_D VOID *winHandle; + + +As well as connecting to the window server, opening a channel to the console creates and initialises a +backed-up window (which does not have to be redrawn). + + +As described in the Console chapter of the I/O Devices Reference manual, you can obtain the ID of +the console window using the r_1Nq I/O function, as in the following program: + + +#include +#include +#include + + +2One exception to this rule is on the MC where an application uses the services of the console process +(with process name SYS$CONS) to access the screen and keyboard. In this case it is SYSSCONS that is the +client of the window server - not the application process. On the MC, an OPL program (which is really a +process of SYS$OPLR) uses SYS$CONS to draw to the screen. + + +1-8 + + +1 INTRODUCTION + + +GLDEF_C INT main(VOID) +{ +CONSOLE_INFO cinfo; +WS_EV event; + + +p_iow (winHandle, P_FINQ, écinfo) ; +gCreateGC0 (cinfo.window_handle) ; +gPrintText (10,20,"Hello world!",12); +do + +{ + +wGetEventWait (&event) ; + +} while (event.type!=WM_KEY) ; +return (0); + + +} + + +where cinfo.window_handle is the console window ID. After displaying the "Hello world!" message, +the program waits for a key press event and then exits. + + +In CLIB programs you can prevent the automatic opening of a console channel by defining the +function p_xwind in your code, as in the following example: + + +extern void *winHandle; + + +void p_xwind (void) +{ +winHandle=(void *)1; + + +} + + +int main (void) + + +{ + + +return (0); + + +} + + +You should ignore the warning, given during the linking of your program, that the symbol _p_xwind +is duplicated. + + +If you use this technique, your CLIB program should not, of course, make any reference to stdin, +stdout Or stderr, unless you have redirected them. Setting winHandle to | (an illegal value for a +handle) will guarantee that any such reference will fail with a panic. + + +Using the PLIB startup module on the HC, S3, S3a or Workabout + + +The PLIB startup model does not open a channel to the console and the simplest way to get going is +to use the wstartup function that: + + +¢ connects to the window server +e creates and initialises a backed-up window to cover the whole screen +¢ creates a permanent graphics context on that window + + +After calling wstartup, you are in position to draw to the graphics context - as in the following +example: + + +#include +#include + + +GLDEF_C INT main(VOID) +{ +WS_EV event; + + +wStartup(); +gPrintText (10,20,"Hello world!",12); +do + +{ + +wGetEventWait (&event) ; + +} while (event.type!=WM_KEY) ; +return (0); + + +} + + +1-9 + + +WINDOW SERVER REFERENCE + + +Using the CLIB startup module on the MC + + +On the MC, the console device is implemented quite differently from the HC. When the con: device +is opened on an MC, a console display process is created by loading the SYS$CONS.IMG executable +from the ROM. When the opener of the console device calls the channel's I/O functions, the console +sends inter-process messages to the console display process which then sends inter-process messages +to the window server. The console process keeps a character map of the console screen which it uses +to redraw its window as necessary. The console process also manages a title bar that allows the +window to be moved and/or resized and a menu bar that allows the program to be stopped. + + +Because the console device is implemented in this way, the console does not support the p_F1nq I/O +function as described above for using the CLIB startup module on the HC. Because it is the console +and not the application process that is the client of the windows server, you can't use the console's +window. There is nothing to stop you from connecting to the window server using wStartup or +wConnect but you will then be running an application with two independent window systems and two +clients. The console channel is still in winHandle so you can close the console and terminate the +display process but this is hardly satisfactory. + + +In conclusion, on the MC, you are better off embracing the EPOC system more completely and using +the PLIB startup module. Despite what is said elsewhere, you can use some CLIB functions with the +PLIB header - those that do not rely on any initialisation. You can, for example, use strcpy - but you +can't use any I/O function such as open, or a memory allocation function such as malloc. + + +Using the PLIB startup module on the MC + + +As on the HC, the simplest way to get going is to use the wStartup function. + + +The MC is available with both version 2 and 3.5 of the window server. Version 2 does not support +bitmap backed-up windows. Even with version 3.5 on the MC, backed-up windows are less attractive +on a large screen where the bitmaps consume large amounts of memory and the processing overhead +of maintaining the bitmap is likely to be more noticeable. + + +You can still call wstartup but, with version 2 of the window server, you get a window that is not +backed-up and you have to deal with redraw events, as in the following example: + + +#include +#include + + +GLREF_D UINT wMainWid; + + +GLDEF_C INT main(VOID) +{ +WS_EV event; + + +wStartup (); +do +{ +wGetEventWait (&event) ; +if (event .type==WM_REDRAW) +{ +wBeginRedrawWin (wMainWid) ; +gPrintText (10,20,"Hello world!",12); +wEndRedraw() ; +} +} while (event.type!=WM_KEY) ; +return (0); + + +} +The global variable wMainwid contains the ID of the window that is created by wstartup. + + +On the MC with its larger screen, wStartup is probably too simplistic (for example, it creates a +window the full size of the screen) and is best seen as a quick starting point for exploratory +programming. In due course, you should look to using wconnect to implement a startup that is +appropriate to your application. + + +1-10 + + +1 INTRODUCTION + + +Error handling + + +How errors are signalled + +Should an error (such as out of system memory) occur in one of the window server functions, the +window server will do one of the following: + +e call p_leave, passing it the (negative) error number + + +e return the error number + + +By default, the window server calls p_1eave. You can make it return the error number by calling +wDisableLeaves (TRUE). From version 3.5 onwards of the window server, you can also set the +W_CONNECT_DISABLE_LEAVES flag when calling wconnect. This is equivalent to calling +wDisableLeaves (TRUE) except that it also affects whether wconnect itself leaves or returns an error. + + +The enter and leave mechanism (which uses p_enter; and .p_leave) is commonly used to implement +structured error recovery. See the Error Handling chapter of the PLIB Reference manual. + + +With the enter and leave mechanism, a call to p_1eave should only occur within the protection of a +p_enter harness. If you don't use p_enter and you don't call woisableLeaves and p_leave is called, +the process will be panicked with panic number 47. + + +Errors in blind operations + + +In the interests of performance, many of the functions performed by the window server have a "blind" +interface in the sense that the client does not receive any acknowledgement that the operation has +been performed. + + +Blind operations may be stored in a client-side buffer to be processed in batches when some condition +causes the buffer to be flushed (as described later). The functions that perform blind operations don't +return anything and are declared as vorp. + + +Many of the blind operations can't reasonably fail - such as drawing a line by calling gprawLine. +However, some functions can fail. For example, increasing or even decreasing the size of a bitmap +backed-up window by calling wset window can fail to allocate the additional memory (which is +required transiently when decreasing the size of a backed-up window). + + +If an error occurs in a blind operation, the window server goes into a special state in which it discards +all further blind operations until a function that can fail is called (such as wcreateWindow). + + +When such a non-blind function is called, it immediately fails - either by calling p_ieave or by +returning an error number, as described above. + + +When a failure does occur while drawing, you often don't care exactly where it failed and you can +happily wait until a non-blind function is called (which might mean waiting until weetEventWait, +wGetEvent Of wGetEvent Special is next called). + + +However, if you need to establish that the processing has been successful thus far, you can call +wCheckPoint which flushes the buffer and signals any failure (by calling p_ieave or by returning an +error number). + + +Cleaning up after an error + + +When handling an error while using the window server (say in response to a p_leave), you can use +wCleanUp to clean up any dangling window server resources where wcleanUp: + + +e frees the temporary graphics context (if it exists) +e ends a redraw if one was in progress + + +If there is a current graphics context that is attached to a window, wcleanUp also invalidates that +window so that it is not left in a partly drawn state. + + +1-11 + + +WINDOW SERVER REFERENCE + + +Panic numbers + + +See the Error Handling chapter of the PLIB Reference manual for a discussion of panics and panic +numbers. + + +The window server panics a client that attempts an illegal operation, using the following panic +numbers: + + +font does not exist + +illegal window or bitmap ID + +illegal window ID + +null handle given to server + +illegal graphics context ID + +illegal GMODE value (V2 only) + +illegal TEXTMODE value (V2 only) + +illegal font ID (V2 only) + +wBeginRedraw called while already in a redraw + +mouse icon does not exist + +illegal bitmap ID + +window tree is already initialised + +wEndRedraw Called when there isn't a redraw to end + +attempted to change the background of a backed-up window +wInitialiseWindowTree called when the parent window is not initialised +illegal parameters passed to wsAlertW, wsAlertA or wsAlertUpdate +illegal length in gPeekBit (V2 only) + +illegal x+length value in gPeekBit (V2 only) + +illegal ypos in gPeekBit (V2 only) + +tried to connect a second time + +tried to access a permanent graphics context while a temporary graphics context exists +illegal opcode in message + +command buffer received by wserv is too long + +generally bad message received + +wFree was called with an ID that doesn't refer to a freeable object +illegal DYL ID + +out of range count sent to wSetWinBitmap + +a bitmap was freed while still in use by a wSetwinBitmap command +illegal window-bitmap ID + +bad data or version in connect message + +called wGetEvent while the previous call was still pending + +function not available + +illegal clock ID in wssetClock + +illegal sprite ID (V4 only) + +client already has a sprite (V4 only) + +corrupt control block (possibly not connected) + +function number out of range + + +Note that because of client-side buffering, there may be a gap between calling the offending function +and the call to p_panic. When tracking down the cause of a window server panic, you may need to +insert temporarily calls to wFlush or wCheckPoint to precipitate the panic. + + +Series 3 compatibility mode. + + +To enable existing applications that were designed to run on the S3, to run successfully on the S3a +and Workabout while keeping the same 'look' and 'feel', version 4 of the window server can run in +what is called compatibility mode for that application. This mode is set or cleared by use of the +wCompatibilityMode function. + + +As far as is practicable, the window server on the S3a attempts to emulate its behaviour on the S3. +For example, in compatibility mode, all drawing to the screen is done in double pixel mode to +overcome the fact that the S3a has a screen of 480 x 160 pixels compared to the S3 screen of 240 x 80 +pixels. + + +When running in compatibility mode on the $3a or Workabout, the version_id member of the +CONNECT_INFO sub-structure will have ws_vERston_4 set. This constitutes the only difference between +the $3, S3a and Workabout in compatibility mode. + + +1-12 + + +1 INTRODUCTION + + +The Workabout has two different types of compatibility mode. In the first type, a 240 x 80 S3 display +is centred on the screen, leaving an unused area above and below the display. In this type of +compatibility mode, the only difference between the S3 and the Workabout is the version_id +member of conNECT_INFo, aS described above. + + +In the second type of compatibility mode for the Workabout, the display covers the full 240 x 100 +Workabout screen and uses a restyled status window. This type is intended for use by only those +applications that can adjust the dimensions of their windows to match the available screen size. It is +recommended that this type of compatibility mode should be used only if a centred 240x80 display is +truly unacceptable. + + +References to compatibility mode will occur throughout this manual. + + +Clients and the window server + + +Client-side functions + + +In the interests of performance, not all the window server functions cause an inter-process message to +be sent. + + +For example, the function gtextwidth, which calculates the printed width of a text string, is +implemented entirely on the "client side" without requiring any context switch between client and +window server. + + +Client-side buffer and flushing + + +Also in the interests of performance, functions that perform "blind" operations that have no return +values (such as most drawing operations) are not sent directly to the window server but are queued in +a client-side buffer. + + +In most cases, the client-side buffer is flushed automatically, when: + +e the buffer is about to overflow + +e an operation that requires a return value is requested + +e an input event is requested by calling wcetEventWait, wGetEvent Of wGetEvent Special + + +Applications should not, however, make any assumptions as to whether a particular window server +function call will or will not cause the buffer to be flushed. + + +The client-side buffer can be flushed explicitly (for example, to animate an image) by calling wriush. +In practice, it is rarely necessary to use wFlush and, although otherwise harmless, using wrlush +unnecessarily will degrade performance. + + +As described earlier, you can also flush the client-side buffer by calling wcheckPoint. + + +The client-side buffer is allocated from the heap when wconnect is called and is approximately 300 +bytes long. The address of the data structure that contains the client-side buffer is held in the +reserved static variable wclientData which may be referenced from C by declaring: + + +GLREF_D VOID *wClientData; + + +Testing for a connection + + +If a process has connected to the window server, wclientData will contain a non-zero value. If a +process has not connected to the window server, it will contain zero. + + +1-13 + + +WINDOW SERVER REFERENCE + + +Foreground and background clients + + +Of all the clients of the window server one client is the foreground client and all the other clients are +background clients. + + +The foreground client is the client that receives keyboard input from the user. + + +Some special key presses (such as the TASK key as described below) are processed by the window +server. A client can capture specific key presses (in which case it is sent the key whether it is +foreground or not) by calling wcapturekey. + + +The foreground client has its windows in front of the windows of any background client. On small +screen versions of the window server, that is, on the HC, S3, S3a and Workabout, the windows of any +background clients are not visible at all. + + +Events + + +For each client, the window server keeps a queue of events that inform the client of user input and +other events. The different types of window server events include: + + +e key presses + +e foreground/background changes + +e redraw events (described later) + +e mouse events (if the machine has a pointing device) + + +Mouse and key events are time stamped with a 16-bit time in system ticks which may be used to +calculate the time between successive events that occur within a short time period (such as a double +click). + + +Redraw and mouse events are directed at a particular window by a window handle event parameter. +This handle is specified by the client when the window is created (and is commonly the address of a +client data structure that contains the window ID). + + +The client can read the next event by calling wcetEventwait, which only returns when there is an +event to deliver. If the client's event queue is empty, wGetEventwait will wait indefinitely for an event +to occur. + + +Applications that need to respond to events other than just window server events (for example, serial +input) would use either of the asynchronous functions wGetEvent or wGetEventSpecial which +request an event without waiting. Asynchronous requests are described in the chapter Asynchronous +Requests and Semaphores in the PLIB Reference manual. + + +Note that wGetEvent Special is only available in version 4 of the window server and is a +generalisation of wGetEvent in that it permits the caller to select which events are to be delivered. +Calling wGetEvent Special (WE_EVENT_NORM) 1s equivalent to calling wcetEvent. + + +Task switching; + + +The window server keeps all the clients in a front to back task order. Position zero in the task order is +the front position and is held by the foreground client. Position 1 is held by the frontmost background +task and so on. + + +When a program connects to the window server, it normally takes the foreground. (A program can +connect in background by setting a parameter to wconnect.) + + +On an S3, an S3a or an HC that is running version 3.5 of the window server, when a process +disconnects, the window server attempts to make the "owner" of the process foreground. Here, the +owner is the process which last resumed it (by calling p_resume). If the owner has terminated or is +not a client of the window server, the shell is made foreground. + + +A client may bring itself or any other client to foreground (or put itself or any other client to +background) by calling wclientPosition. + + +Unless an application has taken steps to disable task switching, the user may switch tasks using the +machine-dependent task-switching keys, as described next. + + +3On large screen versions of the window server when one or more clients have attached to a client, you +can have multiple foreground clients (in the sense that they all last received a foreground event) but only +one of them (the frontmost client) receives key events. + + +1-14 + + +1 INTRODUCTION + + +Task switching on the HC + + +On an HC with an alpha-numeric keyboard (as opposed to just numeric), the window server brings +the foremost background client (at client position 1) to the foreground when the TASK key +(SHIFT+LEFT ARROW) is pressed (the former foreground client is moved to the end of the task list). + + +On an HC, an application can disable task switching in one of two ways: +e locking itself into foreground by calling wsystemModal (0) + +e capturing the task key by calling wcapturekey + +Task switching on the Workabout + + +On a Workabout, the window server brings the foremost background client (at client position 1) to +the foreground when the TASK key (SHIFT+ESC) is pressed (the former foreground client is moved to +the end of the task list). + + +On a Workabout, an application can disable task switching in one of two ways: +e locking itself into foreground by calling wsystemModal (0) + +e capturing the task key by calling wcapturekey + +Task switching on the S3 and the S3a + + +Task switching is controlled by the 8 membrane keys (called application keys) above the main +keyboard. Actually, the window server handles 16 application keys where a second set of 8 keys are +accessed by pressing the CONTROL shift key. + + +These keys are handled co-operatively by the window server and the shell. (The shell has process +name sysssHu and is known by the user as the System task.) + + +When the system starts up, the shell calls wappKkeyHandler to declare itself as the handler of the +application keys. The shell maintains two data structures pointed to by the reserved statics patapp1 +and DatApp2 which control the assignment of the application keys to particular applications. + + +When the system starts up, each application key is assigned to an in-built application. Using the +shell's user interface, the application keys other than the 2 System application keys (14 in all) may be +reassigned. + + +The application keys are handled as follows: + + +¢ On both the S3 and the S3a, if an application key (SHIFTed or otherwise) of an application +different from that of the foreground is pressed, the window server makes the frontmost process +of that application foreground‘. If no process of that application exists, the application key +handler (that is, the shell) is made foreground and sent a wM_TAsK_KEy event. + + +¢ On the S3 only, if an application key of the same application as that of the foreground is pressed, +the window server sends the foreground task a wm_xey event with key code w_kEy_MopE. +(Applications normally cycle through their display modes in response to this event.) + + +¢ On the S3 only, if a SHIFTed application key of the same application as that of the foreground is +pressed, the window server brings the frontmost background client of that application to the +foreground (the former foreground client is moved to the end of the task list). + + +¢ On the S3a under version 4 of the window server, pressing an application key of the same +application as that of the foreground brings the frontmost background client of that application to +the foreground (the former foreground client is moved to the end of the task list). Pressing the +SHIFTed application key of the same application as that of the foreground does the reverse. +In response to the DIAMOND key being pressed, the window server sends the foreground task a +WM_KEY event with key code w_kzy_mopg. (Applications normally cycle through their display +modes in response to this event.) +Note, however, that a foreground application running on the S3a in S3 compatibility mode will +also receive this event when the DIAMOND key is pressed. + + +¢ On both the S3 and the S3a, if a PSION shifted application key is pressed, the window server +makes the application key handler foreground and sends it a wm_TasK_kEy event. + + +4The application is identified by its name. For an $3 or S3a application process, the window server reads +the associated application name from the reserved static patProcessNamePtr. + + +WINDOW SERVER REFERENCE + + +The shell responds to a WM_TASK_KEY event (which indicates which key was pressed in a parameter) by +positioning to the appropriate icon. + + +The SYSTEM application key is permanently assigned to the shell. + + +The CONTROL+SYSTEM application key is assigned to a notional RunImg application such that if this key is +pressed, the window server makes the shell foreground and sends it a ww_TASK_KEY event. The shell then +positions to the RuniImg icon (a bubble containing the word IMG). + + +The shell calls wset TaskKey to assign SHIFT+SYSTEM as a task key. The window server responds to a task +key by moving the foreground client to the end of the task list thus bringing the client previously at +position | to the foreground. + + +The shell also calls wset BackTaskKey to assign SHIFT+PSION+SYSTEM to the "back-task" key which brings +the task furthest from the front to the foreground. + + +On the S3 and the S3a, an application can disable task switching in one of two ways: +e locking itself into foreground by calling wsystemModal (0) + + +¢ capturing all the application keys key by making 8 calls to wcaptureKey (capturing all shift states +in each call) + + +Task switching on the MC + + +On the MC, the windows of a foreground or background client that has a lower task position will, if they +overlap, obscure (partially or wholly) the windows of background client with a higher task position. + + +The user can change the task ordering by: + + +e pressing the TASK to move the foreground client to the end of the task list thus bringing the client +previously at position | to the foreground + + +¢ pressing SHIFT+TASK to cycle through tasks in the reverse direction + + +¢ pressing CTRL+TASK and CTRL+SHIFT+TASK that cycle in either direction in such a way that +iconised tasks are skipped + + +e using the digitiser to click on a background task's window + + +On the MC, it is also possible to attach a client to another (by calling wattachToClient or +wAttachToForegroundClient) such that the attached client and the client it is attached to behave as one +task (with the attached client in front). + + +An application can disable task switching by locking itself into foreground by calling wsystemModal (0). + + +Iconised clients + + +On large screen version of the window server such as the MC, a client can mark itself as iconised by +calling wclientIconised. + + +A client that marks itself as iconised is excluded from a form of window server controlled task switching +in which only non-iconised tasks are brought into the foreground. On an MC, if the user holds down the +CONTROL key while pressing the TASK key, the window server selects only non-iconised tasks. + + +If an iconised client is brought to the foreground by a call to wclientPosition (normally by another +process), the window server sends that client a WA_DEICONISE event (which would normally prompt the +client to deiconise itself). + + +Note that it is the client's responsibility to make any changes to its appearance as a result of a change in its +iconised state. + + +Client priorities + + +The window server can be instructed (by a parameter to wconnect or bya call to wSetPriorityControl) to +adjust automatically the process priority of a client when it gains and loses the foreground such that the +foreground client runs at a higher priority than any background clients. + + +A higher priority foreground client that is performing a computationally intensive task (for example, a +spreadsheet program that is calculating) will totally and indefinitely block any lower priority background +clients that are ready to run. This can be undesirable - particularly on the MC where the windows +belonging to background clients may be visible. + + +1-16 + + +1 INTRODUCTION + + +To avoid robbing background tasks of all processing, computationally intensive processing should be +bracketed with calls to wstartCompute and wEndCompute. In between the calls to wstartCompute and +wEndCompute, the window server holds the client's priority at the background client level regardless of +whether it has the foreground or not. + + +On machines using the small screen versions of the window server, where the windows belonging to +background clients are never visible, the arguments for using wstart Compute and weEndCompute are less +compelling but there may be circumstances when their use is still appropriate. For example, if a user +switches from a task which is printing to continue a game of chess, should the foreground chess task halt +the background task from printing? + + +System-modal clients + + +There is sometimes a requirement to disable task switching by locking a so called system modal task in the +foreground. For example, to notify the user of a condition that must be acknowledged or rectified before +proceeding. + + +A client may declare itself system modal by a parameter to wconnect, or may subsequently change its +system modal state by calling wsystemModal Of wCancelSystemModal. + + +The window server limits task switching to only those processes that have a lower client position than the +frontmost system modal task (if there is one). + + +A client that is system modal would normally be in one of the following client positions: +e take the foreground in which case task switching is disabled + + +e be furthest in the background (that is, with the highest client position) in which case task +switching excludes the system modal task + + +On larger screen versions of the window server (such as on an MC or a PC) where windows belonging to +different clients are typically simultaneously visible on the screen, a system modal client would normally +takes steps to make its windows invisible unless it has the foreground (since clicking on them will not +bring them to foreground). + + +Client management + + +The window server is in a natural position to undertake most of the work necessary to manage clients, for +example: + + +e handling foreground/background task switching + +e automatically adjusting client process priorities + +e notifying the user of clients which terminate abnormally (on machines other than the MC) +¢ supporting the link paste mechanism on the S3, S3a and Workabout + + +However, there are a few functions to support a special client (typically the shell, sysssHu1) taking on +some client management. These functions are: + + +wGetProcessList Gets the process IDs of the clients of the window server, in front to back order. +wClientPosition Used to bring a client into the foreground. + +wSendCommand Used to transfer up to 127 bytes from one window server client to another. +wGet Command + +wAppKeyHandler Used by the shell on the S3 and S3a to handle membrane keys (application + + +keys) in partnership with the window server. + + +wSystem Modify the behaviour of the window server on a non-client-specific level. For +example, to determine whether the window server handles the p_notify +service. See also the section System start-up at the end of this chapter. + + +wSetTaskKey Sets the window server to respond to additional keys that cycle through the +wCancelTaskKey tasks in the two directions. Provided mainly for the $3 and S3a (which do not +wSetBackTaskKey have a system task key on the keyboard). + +wCancelBackTaskKey + + +1-17 + + +WINDOW SERVER REFERENCE + + +Windows + + +A window is a rectangle in screen coordinates that provides a coordinate system for clipped drawing. + + +Once a window has been created using wcreat eWindow, its initial position and size may be changed (using +wSetWindow). + + +Note that at the window server layer, a window is invisible unless it is drawn to. If a window has a +boundary (or any other features) it is because the owning client drew it. + + +Most drawing is done to a graphics context to which a window has been assigned. Off-screen bitmaps can +also be assigned to a graphics context. Both windows and bitmaps are sometimes called drawables. + + +Window trees +Windows are linked in a hierarchy or tree with the screen as the root window. + + +A window is created relative to its parent window and is called the child window of the parent window. A +child window may be a parent of further child windows and so on to any depth. + + +The position of a child window is held relative to its parent. If a parent window is moved, all descendant +windows move by the same amount. You can obtain the offset between any two windows (wherever they +are in the hierarchy) by calling winquireWindowOffset. + + +A child window +e is in front of the parent (and will obscure any drawing to the parent window) +e is clipped to the boundaries of its parent. + + +Note that a child window may be smaller or larger than its parent. A window is often tiled with multiple +child windows which are smaller than the parent and where parts of the parent window may or may not be +visible depending on whether there are any gaps between the boundaries of the child windows. A window +may have a single child window that is slightly smaller than its parent and where the parent provides a +frame around the child window - any drawing to the child window is clipped to the boundaries of the child +window and will not corrupt the frame. A window may have as its child a larger window that is providing +a clipped scrolling view of some information (such as a list) where the view is scrolled by simply moving +the child window in its parent's coordinates. + + +A window is said to be the descendant of a window if it is its child or its grandchild and so on. All +windows are descendants of the root window. Child windows of the root window are sometimes called +top-level windows. + + +Child windows of the same parent are called sibling windows. Sibling windows have a front to back order +which is apparent if they overlap. + + +Ownership of windows + + +Except for the root window, all windows are owned by a particular client. A client does not have access to +windows belonging to other clients and can only create child windows of the root window (that is, top- +level windows) or of its own windows. + + +On larger screen versions of the window server such as on an MC or a PC, windows belonging to different +clients may (and typically are) simultaneously visible on the screen. + + +On small screen versions of the window server, only the foreground client's windows are visible at any +time. + + +Background client drawing + + +Background clients can still draw to their windows whether they are visible or not and programs do not +normally take any special measures to avoid drawing while in background. In fact, applications are +typically oblivious of whether they are foreground or background - they just don't get delivered any key +presses while in background. + + +In practice, background clients rarely draw to their windows on a small screen version of the window +server because they have been robbed of keyboard input. Exceptions are a client that is switched to +background while it is still processing and a client that is driven by events other than just key presses - for +example a terminal emulation program or a clock program. + + +1-18 + + +1 INTRODUCTION + + +Background clients of a large screen version of the window server commonly draw to their windows while +in background for two reasons. First, to take on the appearance of a background client (otherwise, unless +its windows are partially obscured by an overlapping window, it is difficult to differentiate between +background and foreground tasks). Second, to redraw its windows after being exposed by changes (of +position, size, front to back ordering or visibility) to windows that previously obscured it. + + +Drawing region + + +When you draw to a window, the drawing is clipped to the visible part of the window - called the drawing +region. When the window is partially obscured by overlapping windows, the drawing region is not a +simple rectangle (it is actually represented by a variable-length array of rectangles). + + +For example, suppose an application is displaying a clock as part of its main display area. On the +completion of a timer informing the application to update the appearance of the clock, the application can +happily go through the motions of drawing the entirety of the clock, without worrying whether part of +that display is being obscured by an overlapping dialog box or pulled-down menu. The window server +ensures that only drawing to unobscured portions of the window is effective: + + +In the diagram, any drawing to the dotted region in the Clock window will fail to appear. + + +The window server will discard a drawing region (since it can be recalculated at any time) rather than +maintain it unless the window is being drawn to or is assigned to a permanent graphics context. + + +Backed-up windows + + +A window can be created in such a way that all drawing to it is duplicated to off-screen bitmaps. The +window server can then automatically redraw the window without bothering the client. Prior to version 4, +the window needs to be created with a w_win_BACK_BITMap background. In version 4 upwards of the +window server the window can be created with one or both w_wIn_BACK_ BITMAP and +W_WIN_BACK_GREY_BITMap backgrounds (see creating and initialising a window in the Windows chapter). + + +This makes life much easier for the programmer. (Otherwise, the programmer has to respond to redraw +events and has to adopt a more sophisticated programming style, as described below.) + + +Prior to version 4, when a backed-up window is created, a single backup bitmap is also created with an +appropriate size. This bitmap is initialised with zeros corresponding to a clear screen (white on an LCD). + + +In version 4 of the window server, when a backed-up window is created which is enabled for drawing both +black and grey, two backed-up bitmaps are created with an appropriate size, one for the 'normal' plane and +one for the grey plane (see the Graphics chapter for a fuller discussion of grey). + + +If the size of a backed-up window is subsequently increased, the backup bitmaps are also increased and the +additional area (to the right and below) is filled with zeros. + + +If a backed-up window is scrolled using wsScrollRect Of wScrollwin, the area that is scrolled in from +outside the window is filled with zeros. + + +The disadvantages of using bitmap backed-up windows are: +e it takes longer to draw the image in the first place (since all drawing is duplicated) +e additional storage is required to store the backup bitmap(s) + + +Although the original drawing is slower, the window server redraws a backed-up window with blinding +speed. + + +WINDOW SERVER REFERENCE + + +Keeping backed-up bitmaps for a screen-sized window incurs a storage cost which varies according to the +machine type: + + +e On the HC (160 by 80 pixels), a backed-up bitmap occupies a modest 1600 bytes. +e On the S3 (240 by 80 pixels), a backed-up bitmap occupies 2400 bytes. + + +e On the Workabout (240 by 100 pixels) using version 4 of the window server, a backed-up bitmap +requires 3000 bytes. However, if the window is enabled to use both black and grey, two backed- +up bitmaps are needed, thus doubling the space required to 6000 bytes. + + +e On the S3a (480 by 160 pixels) using version 4 of the window server, a backed-up bitmap +requires 9600 bytes. However, if the window is enabled to use both black and grey, two backed- +up bitmaps are needed, thus doubling the space required to 19200 bytes. + + +e On the MC400, a full screen (640 by 400 pixels) bitmap requires 32K bytes. + + +Slowing down screen drawing is clearly more of a problem on a larger screen and, in summary, using +backed-up windows on an HC or an S3 with their smaller screens (and smaller windows) makes more +sense than on an MC. Using backed-up windows on an S3a or Workabout enabled to draw both black and +grey is questionable. + + +Note, however, that the size of the screen does not limit the size of the window. In most practical +situations, the windows will be smaller on a smaller screen model, but it is sometimes useful to create +windows that are larger (and possibly much larger) than the screen. For example, when presenting a +scrolling view of a map that is much larger than the screen size. With such large windows it would not be +desirable to use a backed-up window. + + +No-redraw windows + + +As well as backed-up windows, the programmer in search of an easy life should also consider windows +created with the w_wIN_No_REDRAW bit set (as a parameter to wcreat eWindow). + + +For such windows, the window server does not invalidate the window or generate redraw events. What it +does do when the window is partly or wholly invalidated (that is, when the backup bitmaps would have +been used if they existed) depends on the background parameter to wcreat eWindow as follows: + + +W_WIN_BACK_CLR prior to version 4, clears the pixels in the window (this is the default). This is +useful, for example, when the window is tiled with child windows but does not +itself contain any images. + + +in version 4, clears the pixels in the normal (black) plane of the window. + + +W_WIN_BACK_GREY_CLR available in version 4 only, clears the pixels in the grey plane of the window. + + +W_WIN_BACK_SET prior to version 4, sets the pixels in the window. This may be used, for +example, to implement a black thick border to a child window that is slightly +smaller and inset from its parent. + + +in version 4, sets the pixels in the normal (black) plane of the window. + + +W_WIN_BACK_GREY_SET available in version 4 only, sets the pixels in the grey plane of the window. + + +prior to version 4, either w_wIN_BACK_CLR or W_WIN_BACK_SET may be used when a window is entirely +covered with its child windows. For example, when a larger child window provides, in conjunction with +its parent, a scrolling view over a larger image. + + +In version 4, in addition to using either w_WwIN_BACK_CLR or W_WIN_BACK_SET, one of the corresponding +grey plane attributes w_wIN_BACK_GREY_CLR or W_WIN_BACK_GREY_SET may also be used, if appropriate. + + +Note that you should not rely on the fact that a window is always totally obscured by another window +(such as a child window) to suppress redraw events since the window server can send unnecessary redraw +events when there is insufficient free system memory to maintain update regions. For guaranteed +suppression of redraw events you should specify the w_wIN_No_REDRAW bit to wcreateWindow - even when a +window is always totally obscured. + + +In version 4 of the window server, redrawing can also be suppressed on a per-plane basis by setting the +. .._NO_REDRAW modes. This method is much preferred. + + +The w_wIN_No_REDRAWw bit does not need to be set. + + +1-20 + + +1 INTRODUCTION + + +The ..._No_rEDRaw background flags can be used as follows: + + +W_WIN_BACK_CLR_NO_REDRAW suppresses re-drawing to the normal plane but the window server +clears the pixels. + + +W_WIN_BACK_SET_NO_REDRAW suppresses re-drawing to the normal plane but the window server +sets the pixels. + + +W_WIN_BACK_NONE_NO_REDRAW suppresses re-drawing to the normal plane; the window server does +nothing to the pixels in this plane - it neither sets nor clears them. + + +W_WIN_BACK_GREY_CLR_NO_REDRAW suppresses re-drawing to the grey plane but the window server +clears the pixels. + + +W_WIN_BACK_GREY_SET_NO_REDRAW suppresses re-drawing to the grey plane but the window server sets +the pixels. + + +W_WIN_BACK_GREY_NONE_NO_REDRAW suppresses re-drawing to the grey plane; the window server does +nothing to the pixels in this plane - it neither sets nor clears them. + + +Bitmap sequences + + +A window may be given an animated image by attaching a sequence of up to twelve bitmaps to the +window by calling wsetwinBitmap. The sequence is modified by calling wchangewinBitmap and freed by +calling wrree (destroying the window automatically frees the bitmap sequence). + + +Each entry in the sequence specifies +e asource bitmap +e the position of the bitmap in the window +e the transfer mode + + +e the time to wait (in tenths of a second) before copying the next bitmap in the sequence to the +window + + +You should be careful about defining too short an interval between bitmaps (especially in combination +with large bitmaps) as the computational effort to maintain the sequence may leave little processor +bandwidth for the application to run. Note that the window server runs at a higher priority than its clients. + + +If the sequence contains a single bitmap, the bitmap is not animated. + + +Whether animated or not, a rectangle on the window that is currently covered by a bitmap in the sequence +is automatically redrawn when that part of the window is invalidated. + + +Any number of bitmap sequences may be attached to a window. Where there is an overlap, bitmaps from +sequences attached after another sequence appear behind that sequence. + + +Bitmap sequences are not designed to be used with backed-up windows and are typically used to produce: + + +e a window with a changing background bitmap for other drawing (however, if there is only one +bitmap in the sequence, the background does not change) + + +e a window that is only drawn from the bitmaps in the one or more bitmap sequences and which, +like backed-up windows, does not have to be redrawn (and the window should be created with the +W_WIN_NO_REDRAW attribute). + + +Unless the window is created with the w_wIN_No_REDRAw attribute, the window server invalidates the target +rectangle in the window after it has copied a bitmap (it also invalidates any parts of the previous rectangle +that is not covered by the new bitmap). The resulting redraw event is intended to prompt the client to draw +on top of the bitmap. If you do not intend to draw on top of the bitmap, you should create the window with +the w_wIN_No_REDRAW attribute. + + +As well as the changes that occur as the bitmaps in the sequence are cycled through by the window server, +you can make all manner of changes to the bitmaps themselves - for example, switching bitmaps and +drawing to them. + + +5The limit derives from the requirement to fit the sequence in the client-side buffer. + + +1-21 + + +WINDOW SERVER REFERENCE + + +In version 4 of the window server, bitmap sequences are, by default, drawn to the normal (black) plane +only and the grey plane will display the appropriate grey background as specified in the call to +wCreateWindow. However, there is nothing to prevent the client from drawing to the grey plane as a result +of a redraw event. + + +A member of a bitmap sequence can be made to appear grey by setting ws_wIN_BITMaAP_GREy for that +member in the call to wSetWinBitmap in which case the normal plane will display the appropriate normal +background. + + +If bitmap sequences are required which make use of both black and grey, then sprites (discussed later) +may be used instead. + + +Using an attached bitmap to avoid redraws + + +If you set up a no-redraw window with an attached bitmap sequence consisting of a single bitmap that fills +the window, you can draw to the bitmap and have that bitmap copied to the window by calling +wiInvalidateWin to invalidate the window. For flicker-free operation the window background should be +set to W_WIN_BACK_NONE. + + +In some cases, this may be more efficient than using backed-up windows (where everything is drawn +twice). + + +In version 4 of the window server, as mentioned before, the bitmap can be made to appear grey by setting +WS_WIN_BITMAP_GREY in the call to wSetWinBitmap. + + +The following program uses the technique described above and works on all versions of the window +server. + + +#include +#include + + +#define NWS_HANDLE 0 +#define MAIN_WIN 1 + + +GLDEF_D WSERV_SPEC wspec; + +GLDEF_D UINT gcid; + +GLDEF_D UINT wid; + +GLDEF_D P_POINT winsize={160, 80}; +GLDEF_D WS_WIN_BITMAP bitseq; + + +GLDEF_C VOID CreateBitmap (VOID) +{ +G_GC gc; + + +bitseq.bitmap=gCreateBit (0, &winsize) ; +bitseq.pos.x=0; + +bitseq.pos.y=0; + +bitseq.rect.tl.x=0; +bitseq.rect.tl.y=0; +bitseq.rect.br=winsize; +bitseq.mode=G_TRMODE_REPL; +gc.style=G_STY_BOLD|G_STY_DOUBLE; +gcid=gCreateGC (bitseq. bitmap, G_GC_MASK_STYLE, &gc) ; +gClrRect (&bitseq.rect,G_TRMODE_CLR) ; +} + + +GLDEF_C VOID CreateWindow (VOID) + + +{ +W_WINDATA windata; + + +windata.flags=W_WIN_NO_REDRAW; +windata.extent.tl.x=0; +windata.extent.tl.y=0; +windata.extent.width=winsize.x; +windata.extent.height=winsize.y; +windata.background=W_WIN_BACK_NONE; + + +1-22 + + +1 INTRODUCTION + + +wid=wCreateWindow (0,W_WIN_NO_REDRAW + +| W_WIN_EXTENT + +| W_WIN_BACKGROUND, &windata, MAIN_WIN) ; +wSetWinBitmap (wid,1, &bitseq) ; +wiInitialiseWindowTree (wid) ; + + +} + + +GLDEF_C INT main(VOID) +{ +WS_EV event; +P_RECT box; +TEXT bb[32]; + + +wConnect (&wspec, NWS_HANDLE, W_CONNECT_PRIORITY) ; +CreateBitmap(); +CreateWindow(); +box=bitseq.rect; +p_insrec(&box,1,1); +gDrawBox (&box) ; +winvalidateWin (wid) ; +p_insrec(&box,1,1); +for (77) +{ +wGetEventWait (&event) ; +if (event .type==WM_KEY) +{ +p_atos(&bb[0],"Key code: %d",event.p.key.keycode) ; +gPrintBoxText (&box, 50,G_TEXT_ALIGN_CENTRE, 0, &bb[0],p_slen(&bb[0])); +winvalidateWin (wid) ; +if (event.p.key.keycode==W_KEY_RETURN) +break; + + +} +return (0); + + +} +Sprites + + +In version 4 of the window server a window may be given an animated image by attaching a sprite to the +window. + + +A sprite is created at a specified position within the window and the animation produced by creating a +sequence of up to 13 bitmap sets attached to the sprite by calling wcreatesSprite. The bitmap sets and the +position of the sprite in the window can be changed by calling wset sprite; the sprite itself can be freed by +calling wrree. + + +Each bitmap set specifies: + + +e up to three source bitmaps for the normal plane, i.e. one for each of the three possible transfer +modes (set, clear and invert) + + +e up to three source bitmaps for the grey plane, i.e. one for each of the three possible transfer +modes (set, clear and invert) + + +e the position of the bitmaps relative to the sprite +e the time to wait (in tenths of a second) before displaying the next bitmap set + + +Unlike the pre-version 4 animated sequences, a sprite is not displayed as part of the window background. +The window server takes care of saving and restoring the contents of the underlying display even if this +changes during the sprite's existence. This can give the impression that the animation ‘floats’ above the +underlying display. + + +When the sprite is created, setting the flag w_spRITE_CLIP_CHILDREN allows child windows of the window +to which the sprite is attached, to clip the sprite. If the flag is not set, the sprite can only be clipped by the +edges of the window to which it is attached or by other non-related windows. + + +If the sequence contains a single bitmap set, the resulting display is not animated. + + +Only one sprite may be created for each client of the window server. + + +1-23 + + +WINDOW SERVER REFERENCE + + +Redrawing + + +Windows that are not backed up by bitmaps or an attached bitmap or are not created as no-redraw +windows must be redrawn as well as drawn. + + +If you intend to avoid redraws by using only backed-up windows, no-redraw windows and windows that +are drawn from bitmap sequences, none of this section applies. + + +Redraw events + + +A window should be redrawn by a client when it receives a redraw event from the window server (after +calling wGetEventWait, wGetEvent Or wGetEventSpecial). + + +A redraw event indicates +e the window to be redrawn +e arectangle within the window that needs to be redrawn +The rectangle is often ignored (especially for simple windows) and the whole window is drawn instead. + + +The window server keeps an update region for each window to record that part of a window that is +invalid. When the update region is not empty and the event queue is otherwise empty, the window server +will complete a client's call to wcetEventWait, wGetEvent Or wGetEventSpecial with a redraw event. + + +Note that user input events and foreground/background change events are effectively delivered at a higher +priority than redraw events. This is sometimes desirable and sometimes not. + + +Note also that, unlike other events, the sending of a redraw event by itself does not clear or otherwise +reduce the update region (this is described below). The window server will continue to send redraw events +indefinitely® until the update region is reduced by the client validating a part or the whole of the region - +normally by the client calling wBeginRedraw (or a variant thereof), as described below. + + +Update region + + +The update region is similar to the drawing region in that it consists of a list of rectangles that are used to +clip graphics output. Whereas the drawing region is used for drawing, the update region is used for +redrawing. The update region is also used to generate redraw events as described above. + + +The drawing region describes that part of the window that is visible. The update region describes that part +of the window that is both visible and invalid. + + +The window server automatically adds to a window's update region when: +e the window is first created +e the window's size is increased + + +e a previously obscured part of the window is exposed by changes (of position, size, front to back +ordering or visibility) to a window that previously obscured it + + +e the contents of a window is scrolled using wscrollRect or wScrollWin + + +A backed-up window always has an empty update region because the window server copies the data from +the backup bitmap rather than add to the update region. + + +Invalidating rather than drawing + + +The client can itself add to the update region by invalidating a part of the window or all of the window by +calling wInvalidateRect or wInvalidateWin respectively. + + +It is often simpler for an application (at the expense of performance) to invalidate a part of a window or +the whole of the window rather than draw to it.’ Invalidating causes the window server subsequently to +send redraw events to the client. + + +6A client that just ignores redraw events will loop indefinitely and "hog" the processor. + + +7If a window is not visible or is substantially obscured, invalidating can actually be more efficient than +drawing. However, this occurs rarely in practice. + + +1-24 + + +1 INTRODUCTION + + +The update region of a window is automatically reduced by the window server as a window becomes +obscured by other windows. However, in practice, the update region is normally reduced (partially or +wholly) before the client draws or redraws to it. + + +Validating before drawing or redrawing + + +You always automatically validate before redrawing (by calling a variant of wBeginRedraw) and you would +normally also validate before drawing (by calling wvalidateWin Of wvalidateRect). + + +As well as reducing the update region, validating can also prepare the background, depending on the +value of the background window attribute, as follows: + + +W_WIN_BACK_CLR prior to version 4 of the window server, clear the pixels in the window (this is +the default) + + +in version 4, clear the pixels in the normal (black) plane (this is the default) +W_WIN_BACK_SET prior to version 4 of the window server, set the pixels in the window +in version 4, set the pixels in the normal (black) plane +W_WIN_BACK_NONE do nothing; in version 4, this is specific to the normal (black) plane +In version 4 of the window server the above attributes can be OR'd with one of the following: + + +W_WIN_BACK_GREY_CLR Clear the pixels in the grey plane + + +W_WIN_BACK_GREY_SET set the pixels in the grey plane + + +W_WIN_BACK_GREY_NONE do nothing; specific to the grey plane + + +The w_wIn_Back_cur background is the easiest to deal with and is often used - particularly for simple +windows or for windows with no grey. For flicker-free drawing or redrawing, use w_WIN_BACK_NONE (and +W_WIN_BACK_GREY_NONE if using grey) and then program such that every pixel is covered when the +drawing code executes (for example, using gPrintBoxText rather than gPrintText). + + +Drawing +You normally draw to a window when the data it is displaying has changed (say as a result of user input). + + +When drawing a particular rectangle of a (non-backed-up) window, a client should call wvalidateRect +before commencing the drawing. When drawing the whole window (which is more common), the client +first validates the whole window by calling wvalidateWin. + + +You must validate before drawing if you are relying on the w_wIN_BACK_CLR, W_WIN_BACK_SET, +W_WIN_BACK_GREY_CLR Of W_WIN_BACK_GREY_SET Window attribute to prepare the background. + + +If you are drawing to a window with a w_wIN_BACK_NONE Or W_WIN_BACK_GREY_NonE background, you need +not validate before drawing to the window. If you don't validate, you will not preempt any redraw event +when the same area happens to be invalid at the time and the same image may subsequently be redrawn +unnecessarily (although, frankly, this is unlikely to be noticed by any user). + + +When drawing to a window, a client may use a permanent or a temporary graphics context. (Note that all +graphics output is directed at a current graphics context.) + + +When using a temporary graphics context, the calls to graphics output functions would be enclosed by +calls to gcreateTempcc and gFreeTempcc. If there is no requirement to change the default initial values of +the graphics context, you would use gcreateTempcco in place of gcreateTempGc. + + +When using a permanent graphics context (which was previously created and assigned to the window by a +call to gcreateGc OF gCreateGco), you would typically use gset cc or gsetcco to make the appropriate +permanent graphics context current before drawing. + + +Redrawing + + +While drawing is clipped to the window's drawing region, redrawing is clipped to the window's update +region (for appearance and efficiency reasons). + + +The client informs the window server that it is redrawing rather than drawing by enclosing the graphics +output function calls between calls to weeginRedraw and wEndRedraw. As well as informing the window +server that the client is about to redraw rather than draw, the call to wBeginRedraw also validates that +rectangle of the window (specified as a parameter to wBeginRedraw). + + +As with drawing, a client that is redrawing to a window may use a permanent or a temporary graphics +context. + + +1-25 + + +WINDOW SERVER REFERENCE + + +There are no fewer than six variants of wBeginRedraw which vary according to whether a temporary +graphics context is created (and, if so, whether it is to be altered from its default settings) and whether a +part or the whole of the window is being redrawn. The full set is as follows: + + +wBeginRedraw to redraw a part of the window using an independently created temporary or +permanent graphics context + + +wBeginRedrawWin to redraw the whole of the window using an independently created temporary +or permanent graphics context + + +wBeginRedrawGC to redraw a part of the window using a temporary graphics context that is +created and initialised with specified values + + +wBeginRedrawGC0 to redraw a part of the window using a temporary graphics context that is +created with default initial values + + +wBeginRedrawWinGC to redraw the whole of the window using a temporary graphics context that is +created and initialised with specified values + + +wBeginRedrawWinGC0 to redraw the whole of the window using a temporary graphics context that is +created with default initial values + + +When a begin redraw function is used to simultaneously create a temporary graphics context, the call to +wEndRedraw automatically frees it. + + +Note that if you mistakenly enclose the graphics output function calls between calls to wBeginRedraw and +wEndRedraw when drawing (rather than redrawing in response to a redraw event), the drawing will +probably not appear since it will be clipped to the update region (which is most likely to be null). + + +Going deaf + + +A client that owns one or more windows with invalid areas and which is not requesting events from the +window server is said to have "gone deaf". + + +An application goes deaf because it is performing a task that takes an extended time to complete. +Examples of such extended tasks are: + + +e loading or saving a large file (or some other processing of a large file) + +e astalled write to the parallel port (say, because the printer is out of paper) +e computing PI to a thousand decimal places + +e a bug that has caused the process to "hang" in an indefinite loop + + +Applications that process redraw events have a responsibility to process them within a reasonable time. If +this is not done, the screen may contain images drawn by some other client (which is very confusing to the +user). + + +With a window server in a preemptive multi-tasking operating system, deaf clients need not block the user +from switching to another task (as happens in non-preemptive multi-tasked window environments such as +Microsoft Windows and others, where a deaf application typically leads to an unwelcome mouse icon such +as an hour glass, a watch or, arguably more positively, a bee). With the window server handling the task +switch key or keys, an aberrant application task that has hung does not require a system reset - the user +can task to a suitable system application and terminate the task. + + +To make it easier to diagnose when a client has gone deaf, the window server has mechanisms to detect +deaf clients. On the HC, $3, S3a and Workabout, task switching to a deaf client will cause the "hung up" +status window to be presented. On the MC, the invalid areas are eventually covered with a grey pattern. +From the user's point of view, exposing a deaf client is preferable to leaving the debris of some other +client's windows which may lead the user to blame the wrong application. + + +The window server does not detect a client which is reading redraw events but discarding them. + + +Applications can avoid going deaf within potentially blocking functions such as a write to a parallel port +by performing such operations asynchronously - as described in chapter Asynchronous Requests and +Semaphores in the PLIB Reference manual. The same chapter also describes how to use p_ioyield to poll +at intervals for the receipt of a redraw message (after using the asynchronous wGetEvent or + +wGetEvent Special) while performing an extended process. Rather than polling, it is worth considering +using p_execc to create a transient sub-process to perform an extended task and to use p_logona to be +signalled when the process completes (as described in the chapter Processes and Inter-Process Messaging +in the PLIB Reference manual). + + +1-26 + + +1 INTRODUCTION + + +Applications that are structured to present percentage done indicators or a cancel option (or preferably +both) while performing an extended task are well structured to handle redraws and can easily avoid going +deaf. In any case, applications that are deaf (and dumb) to the user for extended periods are generally not +welcomed by them. + + +Redraw priority + + +Although redraw events always have a lower priority than user input events and background/foreground +events, there is a two-level redraw priority that operates between windows. + + +By default, windows are created at the lower priority and certain windows may be selected to receive their +redraw events before the crowd by specifying the w_win_pRiortty bit to wcreateWindow OF wSetWindow. +This is very much fine tuning, though. + + +More about windows + + +Creating and initialising a window system + + +A window is created by calling wcreateWindow where you specify such things as the parent window, the +position and size of the window (in the parent's coordinate system), whether the window is backed-up by +bitmaps and so on. + + +When sibling windows are created, they are created in front of any existing siblings (this is only +significant when sibling windows overlap - they often don't). You can set and sense the front-to-back +position of a window in its sibling list using wwindowPosition and wGetWindowPosition respectively. + + +Each successful call to wcreateWindow returns a window ID. The ID is used subsequently to refer to that +window. + + +After a successful return from wcreateWindow, the window is just a dormant data structure in the window +server's data segment with no visibility on the screen. You can't draw to the window and you won't get any +redraw events (or any mouse events if there is a pointing device) until the window is initialised by calling + + +wInitialiseWindowTree. + + +As its name suggests, wInitialiseWindowTree initialises not just the window but all its descendants as +well. In practice, a tree of windows is often created as a logical whole and it is desirable to activate the +whole tree at once by calling wInitialiseWindowTree (passing it the window ID of the parent) after + +having successfully set the tree up from the parent window down by successive calls to wcreatewindow. + + +The above is not meant to suggest that all new window systems take the form of a single tree with a single +parent (although this is the more common case). It is quite possible for the window system to be created to +consist of a number of (say sibling) windows or window trees. In such a case, you would still create the +whole system with successive calls to wcreateWindow and then make multiple calls to +wInitialiseWindowTree to initialise the system. + + +Note that wcreateWindow can fail through lack of system memory but wInitialiseWindowTree cannot. +When creating a window system you must be careful to destroy any partially created system should a call +to wCreat eWindow fail. + + +Destroying a window system + + +Just as windows are created a tree at a time, windows are, in general, destroyed a tree at a time by calling + + +wCloseWindowTree. + + +A client that builds window systems would keep at least the window IDs of the windows in client-side data +structures. In the client's data space, the data structures that contain the window IDs are unlikely to be +related in the same tree structure as the windows are in the window server. Where this is the case, it may +not be convenient for the client to recover the window side relationships and destroy windows a tree at a +time (effectively bottom up) when destroying a window system. If a client uses its relationships (which are +probably tree-like but a different tree) to destroy a window system, some windows would be destroyed +more than once (because wcloseWindowTree has to destroy any descendants as well as the specified +window). + + +In recognition of this problem in destroying window systems, the window server does not consider it an +error if a window is destroyed more than once. + + +This does (quite reasonably) assume that windows systems are destroyed without any intervening window +creations. + + +1-27 + + +WINDOW SERVER REFERENCE + + +Event sources other than the window server + + +You need only read this section if you are implementing a program that responds to event sources other +than just the window server (and therefore the program is using one of the asynchronous functions +wGetEvent Of wGetEventSpecial rather than wGetEventWait). + + +This section assumes familiarity with asynchronous requests - as described in the chapter Asynchronous +Requests and Semaphores in the PLIB Reference manual. + + +When responding to window server events that are requested asynchronously using wGetEvent or +wGetEvent Special, you should completely process a window server event (after returning from p_iowait +and having established that wcetEvent or wGetEvent Special has completed) before calling either +wGetEvent Of wGetEvent Special again to request the next event. + + +Bearing in mind the multi-tasking nature of the system and the fact that the window server runs at a +higher priority than its clients, it is quite possible for the request made by a call to wGetEvent or +wGetEvent Special to complete while responding to an event from a source other than the window server +(for example, the expiry of a timer or the receipt of some data from the serial port). + + +In particular, if one or more windows are directly destroyed in response to a non-window server event +there is the possibility that the next window server event (a redraw event say) will relate to a window that +has already been destroyed. + + +To guard against this possibility, you should not destroy a window or a window system directly in +response to a non-window server event but use wcancelGetEvent to instruct the window server to send the +caller a WM_CANCELLED event and then respond to the wM_CANCELLED event as you would otherwise have +responded to the non-window server event. + + +After a call to wcancelGetEvent, the window server delivers the w4_cANCELLED event at the highest +priority - any other events waiting in the window server client event queue are overtaken. The only +window server event WM_CANCELLED can't overtake is one that has already been delivered. + + +Visibility of windows + +A window is invisible when: +e it has been created (using wcreateWindow) but not yet initialised (using wInitialiseWindowTree) +e it has been made invisible by a call to wMakeInvisible; + + +e the window was created with the w_wIN_FOREGROUND_ONLY attribute set and belongs to a client +that is currently a background client (this case only applies to large screen versions of the +window server) + + +Note that wInitialiseTree, wMakeInvisible and W_WIN_FOREGROUND_ONLY all propagate their effect to +descendant windows. + + +After being initialised, a window is marked as visible. Once a window tree has been made invisible using +wMakeInvisible, it may be made visible again by calling wMakeVisible. + + +A call to wMakeVisible or wInitialiseWindowTree does not necessarily make all descendants visible +since wMakeInvisible may have been applied to a descendant. + + +The window server treats windows that are invisible as follows: +e if the window is backed-up, any drawing to it is drawn only to the backup bitmap(s) +e invalidating a window using wInvalidateRect or wInvalidateWin has no effect + + +e¢ windows behave as if they do not exist with respect to mouse input (this only applies when there +is a pointing device) + + +Scrolling + + +The contents of a window may be scrolled by a horizontal or vertical direction or a combination of the two +using wScrollWin Of wScrollRect. + + +Both these functions are better understood in terms of rectangle copying rather than scrolling where: + + +wScrollRect copies a source rectangle in a window to a rectangle of the same size in the +same window but displaced. + + +wScrollWin works just like wScrol1Rect except that the source rectangle is defined by the +boundaries of the window offset, in the opposite direction, by the amount of the +scroll. This is what is normally used to scroll the contents of a window. + + +1-28 + + +1 INTRODUCTION + + +Both functions copy only those parts of the source rectangle that are both visible and valid. This means +that the copy excludes the following from the source rectangle: + + +e those parts that are in the update region +e those parts that are obscured or clipped by other windows +e those parts that are beyond the boundaries of the window + + +Although these parts are not copied, their existence causes the corresponding region of the target +rectangle to be invalidated. + + +If the window is a backed-up window, the copy is also applied to the backup bitmap(s). For a backed-up +window: + + +e the update region is always empty +e those parts that are obscured or clipped can be recovered from the backup bitmap(s) +e those parts that are beyond the boundaries of the window are cleared. + + +Since these functions access the same window server operations that are applied when a window is moved +using wSetWindow, the above comments about not copying invalid regions applies to window moving too. +If you wish to simultaneously move and change the appearance of a window you should use +wInvalidateWin to invalidate those parts that are to change before using wSetwindow to move the window. + + +Continuous scrolling + + +The function wScro11win Is often used to scroll the contents of a window in response to user input (such +as down arrow key presses, for example). Calling this function necessarily introduces an invalid area at +the upwind border (or borders) of the direction of scroll. + + +If the window is a backed-up window, these areas are automatically cleared by the window server by the +wScrollWin operation and would subsequently be drawn by the client as part of the scroll processing. + + +If the window is not backed-up by a bitmap, the window server invalidates those areas brought in from +outside the window and there is the temptation to leave it to the redraw event handling to draw these +areas. + + +However, this is not good practice because redraw events are delivered only when there is no user input +and in the quite typical case where the user holds down the key that is causing the scroll, the redraws are +not processed until the user releases the key. This means that the screen rapidly fills with a copy of the +image that was at the upwind border of the scroll and the window is only redrawn with something sensible +when the key is released. + + +When using non-backed-up windows you should program as for backed-up windows and calculate the +area that needs to be drawn after the scroll and then validate and draw it. + + +Text cursor + + +A client can nominate at most one window at a time to contain a text cursor (which is optionally flashing) +by calling wrextcursor. The text cursor can subsequently be moved from one window to another by +calling wrextCursor again. To remove the text cursor from the window that contains it, you call +wEraseTextCursor. + + +The cursor is specified as a rectangle which is, in principle, xored with whatever is underneath it. +Applications typically define a text cursor as a vertical line in between characters, a horizontal line +underneath characters or a block cursor that fits over characters. + + +In version 4 of the window server, the cursor can be made to appear grey on those machines that support +grey such as the S3a and Workabout. + + +The window server handles the flashing of the cursor and ensures that it does not interfere with any +drawing or redrawing in its vicinity. + + +On large screen versions of the window server where the windows of more than one client are on the +screen at a time, the window server automatically ensures that only the foreground text cursor is visible. + + +1-29 + + +WINDOW SERVER REFERENCE + + +Bitmaps +Drawing to the screen from a bitmap + + +A bitmap is a piece of off-screen memory that is organised in the same way as the screen bitmap. A +bitmap can rapidly be copied to a window for display using one of: + + +gCopyBit to copy a rectangle from a bitmap to a given position in the current graphics +context +gDrawBit to copy a rectangle from an open bitmap file to a given position in the current + + +graphics context. This is available in version 4 of the window server. + + +gFillPattern to fill a rectangle in the current graphics context with repeated copies of a +bitmap +wSetWinBitmap to copy bitmaps to a window at specified time intervals from a sequence of + + +bitmaps (as described earlier) +All the above functions can copy a bitmap in one of four transfer modes: +G_TRMODE_REPL where bits in the source pattern replace corresponding bits in the destination. + + +G_TRMODE_SET where Is in the source pattern set corresponding bits in the destination (Os in +the source do not change corresponding bits in the destination). This would +normally be used to copy a bitmap on to a previously cleared destination. + + +G_TRMODE_CLR where Is in the source pattern clear corresponding bits in the destination (Os in +the source pattern do not change corresponding bits in the destination). This +would normally be used to copy a bitmap on to a previously set bitmap. + + +G_TRMODE_INV where Is in the source pattern toggle corresponding bits in the destination (Os +in the source pattern do not change corresponding bits in the destination). This +is suitable for copying over an existing pattern and may be reversed by a second +identical application. + + +Creation and storage of bitmaps + + +A bitmap is created uninitialised by calling gcreateBit or (more likely) it is loaded from a file that +contains one or more bitmaps using gOpenBit or gGetBit. A bitmap is freed using wrree. + + +The function gSetOpenAddress may be used immediately before gopenBit or gGet Bit to load the bitmap +from anywhere within the file (typically used to load a bitmap which has been embedded into the program +file). + + +In version 4 of the window server, gInitBit is used to open a multiple bitmap file ready for calls to +gGetBit OF gDrawBit. + + +When a bitmap is successfully created, gcreateBit, gopenBit and gGetBit return a bitmap ID (which is +subsequently used to reference the bitmap). + + +The window server keeps a built-in ROM-based grey bitmap (with a chequerboard pattern). This may be +accessed with the bitmap ID ws_s1Tmap_crey. The bitmap has size WS_BITMAP_GREY_S1ZE_X by +WS_BITMAP_GREY_SIZE_Y. + + +Note that version 4 of the window server supports grey for those machines such as the Series 3a that can +display true grey. + + +When a bitmap is created, it may be stored in the window server's data space or in a named memory +segment (named memory segments are described in the Memory Allocation chapter of the PLIB Reference +manual). + + +The window server automatically places bitmaps that are larger than 2K in named memory segments. You +can request that a bitmap be stored in a named segment rather than the window server's data segment +(regardless of the size). + + +A bitmap that is in a named memory segment can be accessed directly by the client using p_sgcopyfr and +p_sgcopyto (described in the Memory Allocation chapter of the PLIB Reference manual) or otherwise. + + +1-30 + + +1 INTRODUCTION + + +Drawing to bitmaps + + +Like windows, bitmaps can be drawn to using any of the window server graphics output functions. + + +However, unlike windows there is no drawing region or update region (so there is no such thing as +validating before drawing). Drawing is clipped only to the limits of the bitmap. + + +Bitmaps that are loaded from a file are typically read-only (which also makes them shareable). If you are +going to draw to a loaded bitmap, you should specify the ws_B1T_wRITE attribute when you call either +gOpenBit OF gGetBit to load the bitmap. + + +Graphics output is directed at a current graphics context (which may be assigned to a window or a +bitmap). As with drawing to a window, a program may use a permanent or a temporary graphics context. + + +When using a temporary graphics context, the calls to graphics output functions would be enclosed by +calls to gcreateTempGc and gFreeTempcc. If there is no requirement to change the default initial values of +the graphics context, you would use gcreateTempcGco in place of gcreateTempGc. + + +When using a permanent graphics context (which was previously created and assigned to the bitmap by a +call to gcreateGc Or gCreateGco), you would typically use gset cc or gsetcco to make the appropriate +permanent graphics context current before drawing. + + +Bitmap files + + +Bitmap files (which normally have the file name extension .pic) may be created in one of the following +ways: + + +e by saving the contents of a bitmap, a screen or a backed-up window using gsSaveBit (which saves +the whole bitmap) or gsaveRect (which saves a rectangle of the bitmap). In version 4 of the +window server, if the screen or a backed up window uses grey, saving either of them will create a +double bitmap. + + +e by saving the contents of a bitmap, a screen or a backed-up window using gSavemultiBit (which +saves the whole bitmap) or gsaveMultiRect (which saves a rectangle of the bitmap). If the screen +or a backed up window uses grey, saving either of them will create a double bitmap. Available in +version 4 only. + + +e by converting a PCX file using the wspcx program (which runs on a PC). Many PC-based +graphics applications are able to produce PCX files. + + +e by saving the whole screen to a file by pressing SHIFT-CTRL-PSION-S. This is not possible on +machines without a CTRL key (such as the HC). + + +Using wspcx + + +The wspcx.exe program (which is placed in the \sibosdk\sys directory by the installation) may be used to +convert PCX files to window server bitmap files and vice versa and also to link a number of .pic files into +one .pic file. + + +Where the .pcx file contains more than two colours, the following 'rules' apply: +¢ white is converted to white +e black is converted to black +e all other colours are converted to grey + +On conversion: + + +e If a.pcx file is marked as being black and white only, then the .pic file will contain a single +bitmap. + + +e =Ifa.pcx file is marked as being in colour, then the .pic file will contain a double bitmap, where +the first bitmap represents the normal plane and the second represents the grey plane. + + +e If a.pcx file is marked as being in colour but only contains an image using the black and white +"colours", then the .pic file will still contain a double bitmap. + + +1-31 + + +WINDOW SERVER REFERENCE + + +To convert a .pcx file to a window server .pic bitmap file, use: +wspcx -p [-i] [-o] [-s] [-x] + + +where the -p indicates PCX to PIC conversion and is the name of file to be converted (which is +assumed to have a .pcx extension unless otherwise specified). The remaining optional parameters are: + + +-i Invert the bitmap while converting. + + +-o Specifies the output file name and directory (otherwise it is the same as the +input file name with a .pic extension). + + +-x Clip or expand the bitmap to the specified size (in pixels). If expanded, the +-y bitmap is padded out with blank space. +-s Suppresses output messages. + + +For example: + +wspcx -p -i sausage.pcx +produces the inverted sausage.pic. +To convert from a .pic file to a .pcx file, you use: +wspcx -w [-i] [-o] [-s] +To just invert the bits in a .pic file without any other conversion, you use: +wspcx -i [-o] [-s + + +To link a number of .pic files into one output .pic file, you use: + + +wspcx -l [-o] [-s + + +where is a text file (with extension .p/k) that lists the .pic files to be linked to produce a file with +the same name as the .p/k file but with the .pic extension. A C header file (with extension .ph) is also +generated that contains #defines for the index number and dimensions of each component bitmap. + + +Capturing the screen to a bitmap file + + +Pressing SHIFT-CTRL-PSION-S on an MC, S3, S3a or a Workabout saves the current screen to a file called +screen.pic in the current path of the window server. Any existing file of the same name is replaced. + + +In practice, the current path of the window server on a SIBO machine is always LOC::M:\ (it is defined +when the window server process is started - well before you have any chance of influencing it). + + +However, if an environment variable with the name $WS_SD exists, the window server uses its value to +open the file to be created. For example, running the following program: + + +#include + + +GLDEF_C INT main(VOID) +{ +p_setenv ("SWS_SD", "B:\\SCREEN.PIC"); +return (0); + + +} +subsequently causes the screen dump to be written to the root directory of the local B: drive. + + +If the save fails for any reason (such as disk full), the file is not produced and no notification of the failure +is given. + + +You can use this behaviour to disable the SHIFT-CTRL-PSION-S screen dump key by setting up $WS_SD to +contain an illegal file specification. For example, just inserting the following line of code: + + +p_setenv("SWS_SD",""); + + +disables the screen dump key. + + +1-32 + + +1 INTRODUCTION + + +Screen capture program for the HC + + +The following program illustrates how you can construct your own screen capture program on an HC, or +an $3. The program will work on an S3a or Workabout provided that the screen does not contain grey. To +capture grey, the program code needs to be changed in order to capture the grey plane as well as the +normal plane (see gPeekBit in the Graphics Output chapter and any reference manual on PCX file +formats). + + +The program has a "quick and dirty" user interface constructed from the simple console functions +p_printf, p_getch and p_get1 (described in the PLIB Reference manual). The first call to p_printf +automatically connects to the window server and must precede the call to wcapturekey. + + +To save a screen (by default to rem::screen.pic), you task to the application and press PSION+S. + + +/* +SCAPT.C - Capture the screen to a file +*/ + + +#include +#include + + +GLDEF_C VOID main (VOID) + + +INT ret; +TEXT name[64]; + + +p_scpy (éname[0],"rem::screen.pic") ; +p_printf("\£"); /* connect to window server */ +wCaptureKey (W_SPECIAL_KEY|'s',0,0); +for (77) +{ +p_printf("\fCapture file is\r\n%s", &name[0]); +p_printf("\nE to Exit\r\nN to set file Name\r\nPsiont+S to capture"); +switch (p_getch() ) +{ + + +case 'e';: + +case 'E';: +p_exit (0); + +case 'n': + +case 'N': +p_getl("Name:", &name[0], 64); +break; + + +case W_SPECIAL_KEY|'s': +ret=gSaveBit (&name[0],0); +if (ret) +p_notifyerr(ret,"Screen save failed",0,0,0); +break; + + +} +Capturing the screen directly to a PCX file + + +It isn't that difficult to generate a PCX file directly from the screen or any other bitmap. The module +pcxsave.c (supplied in \sdkdoc\demo) contains the code which supports the function pcxScreenSave that +saves the entire screen in PCX format of a given name. + + +The source of pcxsave.c is as follows: +7. * +Save the screen to PCX file + + +x7: + + +#include +#include + + +#define BUFLEN 256 + + +GLREF_D WSERV_SPEC *wserv_channel; + + +1-33 + + +WINDOW SERVER REFERENCE + + +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, &0buf[0],pobuf-&o0buf[0]); +pobuf=ésobuf [0]; + + +LOCAL_C VOID putb(INT b) + + +*pobuf++=b; + +if (pobuf==&0buf [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*0Oxff); + + +} + + +LOCAL_C VOID WritePCXLine(UBYTE *buf,UINT len) +{ +UBYTE *p; +UINT end; +UINT count; +INT byte; + + +p=buf; +byte=*ptt; +count=1; +do + + +{ +end= (p==(&buf[0]+len)); +if (byte==*p && count<0x3f && !end) +{ +count++; +ptt; +} +else +{ +byte=rev (byte) ; +if (count>1 || (byte&0xC0)==0xC0) +putb (count+0xC0) ; +putb (byte); + + +byte=*ptt; +count=1; +} + +} while (!end); + + +1-34 + + +1 INTRODUCTION + + +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 +#include + + +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 (pct1); +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); + + +} +To build scapt.img from scapt.pr, scapt.c and pcxsave.c, just enter: +TSC/M SCAPT + + +You might consider using Tscx rather than Tsc. See the Installation chapter of the General Programming +Manual for more information. + + +The program scapt.img is designed to be run on the target from MCLINK on the PC. In preparation, copy +scapt.img to the root directory of the default drive on the target (an S3 say). To capture the screen to say +fred.pcx in the current directory of your PC, start MCLINK and enter: + + +RUN SCAPT FRED + + +The target machine beeps faintly (from the call to p_souna) when the screen has been saved. If you omit +the FRED, you get screen.pcx (from the related file name in the call to p_fparse). + + +The physical structure of bitmap files and bitmaps + + +Bitmap files start with a PICc_HEAD struct, defined in wlib.h as: + + +typedef struct +{ +P_FSIG sig; +UWORD count; +WS_PIC_HEADER wspic; +) PIC_HEAD; + + +1-36 + + +1 INTRODUCTION + + +The first member of this struct is a p_rstc header: + + +typedef struct +{ +TEXT app_id[3]; /* application ID */ +UBYTE chk_sum; /* application ID checksum */ +UBYTE file_vn; /* file version number */ +UBYTE app_vn; /* application version number */ +} P_FSIG; + + +where the p_Fsic struct is defined in p_file.h. For a bitmap file, the appropriate values for the p_rsic +header are: + + +P_FSIG sig = {"PIC",'PY+'I'+'C';,0n30;, 0x30}; + + +The p_rstc header is followed by a worp count of the number of bitmaps in the file. This is then followed +by an array of that many ws_PICc_HEADER structs. A ws_PIC_HEADER Struct is defined in wiib.h as follows: + + +typedef struct +{ +UWORD checksum; +P_POINT size; +UWORD byte_size; +ULONG offset; +} WS_PIC_HEADER; + + +The members of ws_Ppic_HEADER are as follows: + + +checksum is calculated by applying the p_crc function (described in the PLIB Reference +manual) to the bitmap that is referenced by the ws_p1c_HEADER struct +(excluding all headers). + + +size the pixel dimensions of the bitmap (size.x by size.y) +byte_size the byte size of the bitmap. +offset the relative offset from the end of this header to the start of the bitmap. + + +The bitmap consists of size.y scan lines from top to bottom. Each scan line consists of an array of +((size.x+15)/16) words describing the pixels in the scan line from left to right. The leftmost pixel in a +scan line corresponds to the least significant bit of the first word. + + +A named memory segment which contains a bitmap (created, for example, using gopenBit OF gGetBit) +contains just the bitmap, without the ws_p1c_HEADER header. + + +One example of the use of the physical bitmap structures described above is to animate the screen from a +previously generated sequence of equally sized bitmaps from a bitmap file. After creating the bitmap +memory segment using gOpenBit, gCreateBit OF gGetBit, the steps in the animation sequence are: + + +e@ use p_read to read the bitmap from the file into a buffer +@ use p_sgcopyto to copy the data to the bitmap segment +@ use gCopyBit to draw the bitmap to the screen + + +Since the bitmaps are stored sequentially there is no need to position the file between each p_read - you +only have to position each time you return to the first bitmap in the sequence. + + +Embedded bitmap files + + +A bitmap file may be built into a program file by including its name in an add-file list. This process is +more fully described in the Building an Application chapter of the General Programming manual. + + +1-37 + + +WINDOW SERVER REFERENCE + + +Text fonts + + +A text font is a bitmap that contains up to 256 bit-images called character graphics. The character +graphics in the font are indexed by a character code in the range 0 to 255. + + +Fonts are primarily used to implement the SIBO character set in different typefaces and sizes. + + +A font may also be used to implement any collection of bit-images that have the same height (as an +alternative to using independent bitmaps). + + +A text font may not contain character graphics for the whole 256 code range and within the code range +supported there may also be "holes" for which there is no character graphic.® + + +Although all the character graphics in a font are of the same height, their widths may in general vary. +When all the characters with codes greater than 31 have the same width, the font is said to be monospaced +(otherwise it is said to be proportional). + + +The SIBO character set is compatible with the IBM code page 850 character set for character codes in the +range 32 to 255. In some proportional fonts, the code page 850 block graphics characters (for example, +the box drawing characters) are absent. The characters with codes less than 32 are not compatible with +any standard and vary from font to font. + + +Fast fonts +Fast fonts are stored in an expanded form that uses more memory but can be drawn faster. +All characters in a fast font must be less than or equal to 8 pixels wide. + + +The window server automatically recognises the difference between normal and fast fonts. Window +servers before version 3.5 do not recognise fast fonts and will refuse to load them. + + +ROM-based fonts + + +An application can access the ROM-based fonts by font IDs that are known at compile time. The ROM- +based font IDs start at ws_rFonT_BASE and you can use WS_FONT_BASE+1 etc for as many fonts as are built +into the ROM. + + +The default font of a newly created graphics context, sometimes called the system font, is in most cases +the first font in the ROM - with ID ws_FonT_BASE. + + +Whenever it is expecting a font ID, the window server converts the constant ws_FoNT_SYSTEM to the +system font (WS_FONT_SYSTEM is outside the range of possible font IDs). You can also obtain the system +font ID directly from the system_font member of the W_SERVER_INFo struct (as described under wconnect +in the next chapter). + + +On the HC and the S3, the system font is determined by the sws_sF environment variable which should +contain a worp binary value of 0 for ws_FonT_BASE and | for Wws_FONT_BASE+1 and so on. If you change the +value of sws_sFr, you must reset the machine by pressing the recessed reset button to effect the change. + + +In version 4 of the window server which runs on the S3a, the system fonts are determined by the sws_Fnts +environment variable. This contains a series of words each of which contains the fonts used by the +window server in various situations (listed in the changes section earlier). The full list is repeated below +and is given in the correct order. + + +e §=©System font + +e §=6Notifier/Alert font + +e Status Window font + +e Symbols font used for the status window diamond symbol +e Medium 2 digital clock font + +e Medium 2 date font + +e §©Notifier/alert button font + + +e Small status window clock font + + +8If a client passes a character code for which there is no graphic, the graphic with the highest code is +selected. + + +1-38 + + +1 INTRODUCTION + + +On the MC, the system font is determined in the same way except that two environment variables are used +- sws_sF2 and sws_sr4. If the screen has fewer than 300 lines (as on the MC200), sws_sr2 is used. +Otherwise (as on the MC400), sws_sr4 is used. + + +The following program illustrates how the environment variable may be changed. +#include + + +GLDEF_C INT main(VOID) +{ +WORD flags; + + +flags=1; /* choose WS_FONT_BASE+1 */ +return (p_setenviron("SWS_SF",6,&flags,2)); +} + + +Changing the system font may upset existing applications. + + +In version 4 of the window server used on the Series 3a, fonts can be collected into what are called ‘font +groups’. A more detailed discussion of this concept can be found in the description of gconfigureFonts in +the Graphics Output chapter of this manual. + + +Briefly, font groups are a collection of fonts with a single identity. Essentially, each font within the group +will have been specially designed with a style or a combination of styles in mind. Where a font group is to +be used to print text, the window server will select the best font from within this group according to +criteria based on the style or combination of styles selected (i.e. bold, italics etc). Having selected a font +from within the group, it may, if necessary, algorithmically apply further styles. + + +The font groupings for the Series 3a and Workabout machines are summarised in the header file fonts.h, +which also supplies a range of defined constants that can be used to identify the various ROM-based fonts. + + +HC fonts +On a standard HC, there are six ROM-based fonts: + + +WS_FONT_BASE - large proportional +(the system font). Also the system +font on the MC400. + + +Normal text (15) Bald text +Ttale text Mang text + + +ier Doble bl + + +ia a =] feo i +SS ee + + +fF) +0 +i +A + +| + +I +I + + +| a eee . S| + + +Fi +: +| +f +l +i +i +i +( +i + + +J +oS +fo +t f +a4 +C +| +td +5 ft +da +i i +ii +Hf +a +EE +( ¢ +i + + +aA aot oa eee eos es ee re +_ = oe a SES S| asa +— od + + +1-39 + + +WINDOW SERVER REFERENCE + + +<< +, «LCE Fox Po aot -Com Co + + +a ot, ct a ey a Ree ee i eee | = + + +1oDeset 4. = -on Coo +| | ee ee ee | a +olsen pn BO Eee. we LC ble et neem en toc] jalor we oe Se I --e + + +Be Ef aicahe sm ne npsicias [SIE Lees lame ems ge cect tenth + + +co) a pee eee OO oe EOC + + +ofc eet eee Qt CoS = eS + + +coCI + ee ee ee oe EO +tt ee pes Heo Os) ---s |] SCO Dek RBG Ngee) OC +on |e oa eee eo Dose ES oo cao Coa Ea Oe +Oo fed 0 I a a ee ey eo]D Do oo aM oe tH a +Cars Pes oS cee Dali sn LW mS WbeoCoeD al H LO +oom Oo oe meee ac] PO [OD oS Seco Coe am sor +Owl © Danese +o ee ea is od MO +tsi O eet OR Oem coe laws] [| oO et oe Oe moe I ane CO +wo EO at +a: woo tee bao] JO = Soe oo eee oC Fado + + +Mow eS aa ad ae ee +vie GS Tt + + +Goes) Cer oo oP ooo, or ss Le Le oT Oo er boo 00 2 oo oo La Le GN Oo ue so rh oo eT oo Le Le + + +paced + + +(the console font). Only used on the + + +HC. + + +Bold +Mono text + + +proportional. Also the system font +on the MC200. + + +monospaced. The monospaced font +on the MC. + + +Hormal text (8) Bold tex + + +Italic text Mono text + + +ca +_ TI += +— += += +a += +cs +-—i +cu += +ou +—_— +—o += +— +coc + + +Double herant Double bo] + + +- +% +wu ++ += +—_ += +o +~~. +—_— +fn} +—" ++ +* +a +_ +a += +— +J += + + ++ +m +a + ++4 += += += + += + ++ +te + +au + += + ++ + +Lome! + + +WS_FONT_BASE+2 - fast monos + + += +— +— +— +=! +— +—— +— +— +[ a | +—" +—— +Semene + +#include + + +LOCAL_D WSERV_SPEC wSpec; + + +GLDEF_C INT main(VOID) + + +INT NotifierPid; + + +if ((NotifierPid=p_pidfind("SYSSNTFY.*") )>0) +{ +wConnect (&wSpec, 0,W_CONNECT_AT_BACK) ; +wSystem (WSERV_FLAG_NO_NOTIFIER_REBOOT, WSERV_FLAG_NO_NOTIFIER_REBOOT) ; +p_pterminate (NotifierPid, 0); +wSystem (WSERV_FLAG_HOOK_NOTIFIER, WSERV_FLAG_HOOK_NOTIFIER) ; +} + + +return (0); + + +} +If syssntFy exists, the program connects to the window server and: +e stops the window server from re-booting the notifier +e kills the notifier process +¢ causes the window server to hook the notifier + + +On the HC, the font used by the notifier is determined by the Internal Font environment variable, sws_ir, +which should contain a worp binary value of 0 for ws_ront_Base, | for ws_FONT_BASE+1, and so on. + + +If you change the value of sws_1r, you must reset the machine by pressing the recessed reset button to +effect the change. The height of the font should not exceed 12 pixels. + + +The "factory" setting of sws_t1F is 4 (which selects the S3 font). + + +In version 4 of the window server, the fonts used by the notifier are determined by the sws_Fnts +environment variable. This contains a number of words containing the font ids used by the window server +as described at the beginning of this chapter. + + +In particular, the second word contains the ID of the notifier font while the seventh word contains the ID +of the notifier button font. + + +The $WS_FL environment variable on the HC + + +On an HC with version 3.5 of the window server, the initial value of the internal parameter that is set by +wSystem 1s loaded from the sws_ri environment variable when the window server starts. + + +After setting sws_r1 to the desired worp value, you must reset the HC by pressing the recessed reset button +to make the new value effective. + + +Recall that environment variables survive a soft reset but are cleared (and loaded from a ROM +initialisation file) on a hard reset (where the ON key is pressed at the same time as the reset button). + + +The wsystem flags parameter is made up by ORing a number of bit fields of the form wsERV_FLAG_xxx +where some of the values of xxx are!?: + + +NO_NOTIFIER_REBOOT If set, the window server does not boot or re-boot the notifier. +HOOK_NOTIFIER If set, the window server attempts to hook the notifier. +NO_PANIC_NOTIFY If clear and the window server has successfully hooked the notifier, the window + + +server notifies the user of a process that terminates abnormally with a panic or +with a negative reason number. This flag is ignored unless the window server +has hooked the notifier. You would set this flag to prevent the window server +from reporting abnormal terminations when HooK_NOTIFIER Is Set. + + +12See the description of wsystem for the full set and also for the application of these flags to the $3, the +S3a and the MC. + + +1-59 + + +WINDOW SERVER REFERENCE + + +LOW_BATTERY_WARNINGS _ If set, the window server notifies the user of a low lithium or main battery. Note +that the window server only checks for low battery when the machine is turned +on and that the window server is only informed of the machine being switched +on after p_setonevent (TRUE) has been called. The on-event state is FALSE after +any reset. + + +HUNG_UP If set, the window server presents a "hung up" status window if the foreground +task is not using backed-up windows and fails to respond to redraw events. + + +After a hard reset on an HC with version 3.5 of the window server, the $ws_FL environment variable does +not exist (which is equivalent to it being zero). + + +The following example program sets the $ws_FL environment variable: + + +#include +#include + + +GLDEF_C INT main(VOID) + + +WORD flags; + + +f lags=WSERV_FLAG_NO_NOTIFIER_REBOOT |WSERV_FLAG_HOOK_NOTIFIER +| WSERV, FLAG LOW_BATTERY. WARNINGS |WSERV_FLAG_HUNG_UP_SW; + +return (p_setenviron("SWS_FL",6,&flags,2))j; + +} + + +After running this program and resetting the HC, the window server will: +e provide the notifier service +e report low battery voltages +e present a hung-up status window if an application hangs + + +¢ report a process that terminates with a panic or with a negative reason number + + +S3a + + +In version 4, some HC features from the later releases of version 3.5 have been added to the S3a variant of +the window server. This includes: + + +e the use of the environment variable sws_rt for the initial value of the window server system flags +(as referenced by wsystem). + + +Replacing the shell on the HC + + +By default, the window server runs Rom: :SyS$SHLL.1Mc. This program provides a classical command- +driven user interface to perform such commands as copy and pir and to run programs (for example, LINK) +in response to the program's file name being entered. + + +When developing a turnkey system, it is advisable to run an alternate custom shell that provides a +restricted end-user environment. With version 3.5 of the window server, this is particularly +straightforward as the window server can be persuaded to take over many of the responsibilities - +particularly the link paste services - that previously had to be provided by the shell. You simply call your +main application sys$sHELL.1Mc and place it in the root directory of any drive. The window server will +run the shell on system start-up and it will also re-run the shell should it terminate. + + +Since any restarting EPOC system will pick up a sys$sHLL. mc (such as the debugger, for example), it is +a good idea not to call such a program sysssHuL but to rename it when you copy it to its intended working +destination. + + +To revert to the ROM shell when using an SSD-based syss$su11, first remove the SSD and then either +terminate the existing shell process or reset the machine. If you have placed a sys$sHLL. IMG in M:\, you +can revert to the ROM shell by hard resetting the machine (which clears the contents of m: \ and resets the +environment variables) or you can place an alternate syS$sHLL.1mc in an SSD drive (since the drives are +scanned in alphabetic order). + + +The following simple shell/application program terminates any sys$nTFy process and sets up the window +server to provide the notifier service and other services (as described above) and then presents a user +interface that reports on key presses. + + +1-60 + + +1 INTRODUCTION + + +/* +HCSHELL.C - Sample shell for the HC +*/- + + +#include +#include + + +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*linet+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; (F<) + +{ + +wGetEventWait (&event) ; + +if (event .type==WM_KEY) + +HandleKeyPress (&event.p.key) ; + + +} + + +GLDEF_C INT main(VOID) + + +{ +INT NotifierPid; + + +1-61 + + +WINDOW SERVER REFERENCE + + +p_setonevent (TRUE); /* required on the HC */ + +wStartup(); + +wSystem(WSERV_FLAG_NO_NOTIFIER_REBOOT, Oxfff); + +if ((NotifierPid=p_pidfind("SYSSNTFY.*") )>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); + + +} + + +You may prefer to use the following shell (the source may be found in \sibosdk\demo\lkshell.c) when +using the remote debugger on the HC: + + +/* +LKSHELL.C - Just starts up the link +xy: + + +include +include + + +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*linet+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 (3-7) +{ +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==W_KEY_RETURN) +wiInvalidateWin (wMainWid) ; + + +1-62 + + +1 INTRODUCTION + + +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("SYSSNTFY.*") )>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("SYSSNCP.*") <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); +wiInitialiseWindowTree (wMainWid) ; +wMainGc=gCreateGCO (wMainWid) ; +MainEvent Loop () ; +} + + +To save memory, the program processes redraw messages rather than keep a backup bitmap. Pressing +ENTER causes the "Free Memory" figure to be re-evaluated. + + +There is further information on creating a replacement shell in the HC Programming Guide. + + +PC EPOC + + +On the PC version, the window server looks for the shell and notifier in the following directories: +e the current directory +e the directory that contains sysswsRv.IMG + + +e the ROM + + +1-63 + + +CHAPTER 2 + + +GENERAL WINDOW SERVER FUNCTIONS + + +The connection to the window server + + +Before you use any window server services you must connect to the window server. + + +How you connect to the window server depends on whether you are using the CLIB or the PLIB C startup +module and what machine you are running on. See the section Connecting to the window server in the +first chapter for a full discussion. + + +The CLIB C startup module opens the console device con: before calling main. On the HC, S3 and S3a, +the console device open function connects to the window server. If you try to connect a second time, your +program will be panicked with panic number 100. + + +Provided the C startup module has not already connected the process, you may call either wstartup or +wConnect to connect. The convenience function wStartup calls wconnect and then carries on to perform +additional setting up that will satisfy the requirements of many applications. For a more sophisticated use +of the window server, you would use wconnect directly. + + +wStartup Connect and initialise a window +VOID wStartup (VOID) ; +Perform the following actions: + +e Connect to the window server using wconnect. + +e Create a window to cover the whole screen and store its ID in wMainwid. + +e Initialise wMainwid so that it is visible. + +e Create a permanent graphics context on the window and store its ID in wMainGe. + + +On version 3 of the window server, the window is created with a backed-up bitmap (so that no redraws are +required). + + +The code for wstartup is effectively!: + + +#include +#include + + +#define NWS_HANDLE 0 +#define MAIN_WIN 1 + + +GLDEF_D WSERV_SPEC wSpec; +GLDEF_D UINT wMainGc; +GLDEF_D UINT wMainWid; + + +!The actual code in WLIB is written in 8086 assembler. + + +2-1 + + +WINDOW SERVER REFERENCE + + +GLDEF_C VOID wStartup (VOID) +{ +UINT field_set; +W_WINDATA windata; + + +wConnect (&wSpec, NWS_HANDLE, W_CONNECT_PRIORITY) ; +field_set=0; +if ((wSpec.conn.info.version_id&WS_VERSION_MASK) !=WS_VERSION_2) + +{ + +field_set=W_WIN_BACKGROUND; + +windata.background=W_WIN_BACK_BITMAP; + +} +wMainWid=wCreateWindow (0, field_set, &éwindata,MAIN_WIN) ; +wiInitialiseWindowTree (wMainWid) ; +wMainGc=gCreateGCO0 (wMainWid) ; + +} + + +The created graphics context is the current graphics context and, after calling wstartup, you are ina +position to draw to the window. If necessary, you can reference wSpec, wMainGe and wMainWid by +including the following declarations: + + +GLREF_D WSERV_SPEC wSpec; +GLREF_D UINT wMainGc; +GLREF_D UINT wMainWid; + + +The following example is suitable for an HC, an S3 or an S3a: + + +#include +#include + + +GLREF_D UINT wMainGc; +GLREF_D WSERV_SPEC wSpec; + + +GLDEF_C INT main(VOID) +{ +WS_EV event; +G_GC gc; +P_RECT box; +TEXT bb[32]; + + +wStartup(); +box.tl.x=box.tl.y=0; +box.br=wSpec.conn.info.pixels; +p_insrec (&box, 8,8); +gBorder (W_BORD_SHADOW. D|w BORD_SHADOW_ON) ; +gc.style=G_STY_BOLD|G_STY_DOUBLE; +gSetGC (wMainGc, G_GC_MASK_STYLE, &gc) ; +for (77) +{ +wGetEventWait (&event) ; +if (event .type==WM_KEY) +{ +p_atos(&bb[0],"Key code: %d",event.p.key.keycode) ; +gPrintBoxText (&box, box.br.y>>1,G_TEXT_ALIGN_CENTRE, 0, +&bb[0],p_slen(&bb[0])); + + +if (event.p.key.keycode==W_KEY_RETURN) +break; + + +} + + +return (0); + + +} + + +2-2 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +wConnect Connect to the window server +VOID wConnect (.i.WSERV_SPEC *pwserv_spec, VOID *pnws_handle, UINT flags); +Connect to the window server. + + +The parameter flags should contain a combination of the following bit masks: + + +W_CONNECT_AT_BACK Connect as a background application (the default is foreground). +W_CONNECT_USER_FLAG The value of this flag is returned by a wclientInfo call. +W_CONNECT_SYSTEM_MODAL Makes the client system modal. + +W_CONNECT_PRIORITY Enables the window server's process priority handling for the client. In + + +version 4 of the window server, process priority handling can be both +enabled and disabled by a suitable call to wsetPriorityControl. + + +W_CONNECT_DISABLE_LEAVES If set, the window server will return negative error numbers rather than call +p_leave. Equivalent to calling woisableLeaves (TRUE) except that it also +affects whether wconnect itself leaves or returns an error. + + +The parameter pnws_hand1le is a handle that the window server will use in events sent to the client that +are not directed at a window (for example, key events). + + +The parameter pwserv_spec is the address of a wszRV_spPEc struct that must be maintained for the +duration of the connection (it holds information used by WLIB functions). The wszrv_spec struct is +typically implemented as a static variable or as allocated memory. + + +The wserv_spPeEc struct is defined as: + + +typedef struct +{ +UWORD handle_check; /* used internally */ +CONNECT_INFO conn; +Fi /* used internally */ +} WSERV_SPEC; + + +typedef struct +{ +UWORD client_handle; /* used internally */ +W_SERVER_INFO info; +} CONNECT_INFO; + + +where wConnect writes information useful to the client in the connEcT_1NFo sub-struct conn (the only part +of wsERv_spxc that should be accessed by the client). + + +The w_SERVER_INFO Struct is defined as: + + +typedef struct +{ +P_POINT pixels; /* display size */ +UWORD width_1000_pixels_mm; /* width of 1000 pixels in mm */ +UWORD height_1000_pixels_mm; +UBYTE set_is_dark; /* TRUE if set pixels are dark */ +UBYTE version_id; /* machine type and window server version */ +UWORD system_font_handle /* ID of default font */ + +cece /* extra space for future expansion */ + +} W_SERVER_INFO; + + +where: + +pixels the size of the screen in pixels (pixels.x wide by pixels.y high). + +width_1000_pixels_mm the width and height (in millimetres) of 1000 screen pixels for applications + +height_1000_pixels_mm that wish to draw objects of a certain physical size or to correct for the pixel +aspect ratio. Note that, for the Series 3 (but not for other machines, +including the Series 3a) these two values are not reliable. + +set_is_dark TRUE if a set bit appears dark on the display (as on an LCD display) and + + +FALSE otherwise (as for a CRT display). An application can invert drawings +according to this flag so that they appear the same on both types of display. +(Not reliable on a PC version of the window server.) + + +WINDOW SERVER REFERENCE + + +version_id the machine type and window server version number. +version_id|WS_TYPE_MASK is one of WS_TYPE_MC, WS_TYPE_HC, WS_TYPE_S3, +WS_TYPE_S3A or WS_TYPE_S3c depending on whether the machine is an MC, +HC, S3, S3a or Workabout. The value of version_id|WS_VERSION_MASK is +WS_VERSION_2, WS_VERSION_3 Of WS_VERSION_4 depending on whether a +connection was made to version 2, version 3 or version 4 of the window +server. In this context, version 3.5 is grouped with version 3. + + +system_font_id the ID of the default font that you get when you create a graphics context. +(Alternatively, you can use WS_FONT_SYSTE™ to specify the system font.) + + +Note that any application running on the S3a in S3 compatibility mode will find that the version_id is set +to WS_TYPE_S3A|WS_VERSION_4. In a similar situation, an application running on the Workabout will have +version_id Set to WS_TYPE_S3C|WS_VERSION_4. Therefore, the window server is not providing a +completely identical interface to such applications. + + +Whether wconnect was called directly or indirectly, the address of the wsERV_sPEc variable which was +passed is recorded in the reserved static wserv_channel. This can be used in general purpose code to +obtain the above information. For example: + + +GLREF_D WSERV_SPEC *wserv_channel; +LOCAL_D P_POINT ScreenSize; + + +ScreenSize=wserv_channel->conn.info.pixels; + + +The following example program (which requires the PLIB C startup module) illustrates the use of +wConnect to connect to the window server. + + +#include +#include + + +#define WBORDER 8 + + +GLDEF_D WSERV_SPEC wspec; +GLDEF_D UINT wid; +GLDEF_D WMSG_KEY key; + + +GLDEF_C VOID CreateWindow (VOID) +{ +UINT border; +W_WINDATA windata; + + +windata.flags=W_WIN_NO_REDRAW; +windata.background=W_WIN_BACK_SET; + + +border=wCreat eWindow (0, W_WIN_NO_REDRAW|W_WIN_BACKGROUND, &windata, 2) ; +windata.extent.t1.x=WBORDER; + +windata.extent.t1.y=WBORDER; + +windata.extent .width=wspec.conn.info.pixels.x-(2*WBORDER) ; +windata.extent .height=wspec.conn.info.pixels.y-(2*WBORDER) ; +windata.background=W_WIN_BACK_NONE; + +wid=wCreat eWindow (border, W_WIN_EXTENT |W_WIN_BACKGROUND, &windata, 1) ; +wiInitialiseWindowTree (border) ; + + +} + + +GLDEF_C INT main(VOID) +{ +WS_EV event; +G_GC gc; +P_RECT box; +TEXT bb[32]; + + +wConnect (&wspec, 0,W_CONNECT_PRIORITY) ; +CreateWindow(); + +box.tl.x=box.tl.y=0; +box.br.x=wspec.conn.info.pixels.x-(2*WBORDER) +box.br.y=wspec.conn.info.pixels.y-(2*WBORDER) + + +’ +’ + + +2-4 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +for (77) + +{ + +wGetEventWait (&event) ; + +if (event .type==WM_REDRAW) +{ +gc.style=G_STY_BOLD|G_STY_DOUBLE; +wBeginRedrawWinGC (wid, G_GC_MASK_STYLE, &gc) ; +p_atos(&bb[0],"Key code: %d",key.keycode) ; + + +gPrintBoxText (&box, box.br.y>>1,G_TEXT_ALIGN_CENTRE, 0, &bb[0],p_slen(&bb[0])); + +wEndRedraw(); +} + +if (event .type==WM_KEY) +{ +key=event.p.key; +if (key. keycode==W_KEY_RETURN) + +break; + +wiInvalidateWin (wid) ; +} + +} + +return (0); + + +} + + +The function creat eWindow sets up a two-window parent-child system where the parent implements a +thick border and all drawing is done to the child window. The main function contains an event loop that +handles redraw events and key events to display the code of the last key pressed. Note the use of +wInvalidatewin to update the screen on receipt of a key event by forcing a redraw. + + +The true screen and pixel dimensions of the various LCD screens are as follows: + + +Machine Screen Pixel Pixel Screen Screen + +type (pixels) pitch (mm) size (mm) size (cm) size (in) +HC 160x80 0.34x0.43 0.31x0.40 5.44x3.44 2.14x1.35 +S3 240x80 0.385x0.43 0.355x0.40 9.24x3.44 3.64x1.35 +Workabout 240x100 0.26x0.30 0.23x0.27 6.24x3.00 2.45x1.18 +S3a 480x160 0.259x0.259 0.20x0.20 12.477x4.156 4.915x1.637 +MC200 640x200 0.33x0.33 0.30x0.30 21.12x6.60 8.31x2.60 +MC400 640x400 0.33x0.33 0.30x0.30 21.12x13.20 8.31x5.20 + + +In the above table, the horizontal measure is shown before the vertical measure. The pixel pitch measures +the horizontal and vertical distance between the same points on adjacent pixels. The difference between +the pixel size and the pixel pitch gives the gap between pixels. + + +wDisconnect Disconnect from the window server + + +VOID wDisconnect (VOID) ; + + +Disconnect from the window server and free resources within the client process and within the window +server. + + +A client is automatically disconnected if it terminates. + + +wFlush Flush buffered commands + + +VOID wFlush (VOID); + + +Flush any contents of the client-side buffer. This will ensure that the window server has received and +executed all previous functions. + + +Note that wr1lush does not report any errors that occur in the processing of the client-side buffer. The +function wcheckPoint (described below) flushes the buffer and reports errors. + + +The client-side buffer is automatically flushed when: +e the buffer is about to overflow + + +e the client calls a function that returns a value that requires the window server process to run (for +example wcreateWindow returns the ID of the window it creates). The functions grextwidth, +gTextCount, gFont Info and wCheckBitmapid do not flush the client-side buffer because they are +implemented by code that runs in the client's process. + + +e = the client calls weetEventWait, wGetEvent OF wGetEvent Special + + +Most applications don't need to call wriush and calling wriush unnecessarily will degrade performance. + + +2-5 + + +WINDOW SERVER REFERENCE + + +Programs that perform animation or that respond to an event source other than the window server (such +as a serial I/O device) may need to use wFlush. For example, the following code, intended to produce +some animation: + + +gClrRect (prect,G_TRMODE_INV); /* invert a rectangle */ +p_sleep(5L); /* pause for half a second */ +gClrRect (prect,G_TRMODE_INV); /* invert it back again */ + + +does not have the intended effect. The code should be as follows: + + +gClrRect (prect, G_TRMODE_INV) ; +wF lush () ; + +p_sleep(5L); + +gClrRect (prect, G_TRMODE_INV) ; + + +When debugging a program, it can be useful to insert calls to wFlush (which are removed subsequently) to +force the screen to be updated. + + +Series 3 compatibility modes + + +Both the Series 3a and the Workabout can be set to operate in Series 3 compatibility mode. The +motivation for this is to be able to emulate Series 3 graphics, so that unmodified Series 3 applications can +run on either machine. Naturally, grey is not available to any application running in Series 3 compatibility +mode. + + +On the Series 3a, the compatibility mode is implemented by allowing all Window Server graphics +commands to draw with double size pixels. Because the Series 3a's screen has 480 x 160 pixels, compared +to the Series 3's 240 x 80 pixels, doubling up the pixels on the Series 3a screen gives the 'look' and ‘feel’ of +the Series 3 screen for Series 3 applications running on the Series 3a. + + +On the Workabout, with its 240 x 100 screen, full Series 3 compatibility is implemented by restricting +drawing to a 240 x 80 region, centred on the screen, leaving ten rows of pixels unused at both the top and +bottom of the screen. + + +The Workabout has a second compatibility mode that, while not allowing the use of grey, allows an +application to draw to the full 240 x 100 extent of the screen. This mode can only be used with a Series 3 +application that is written in such a way that it can adjust the sizes of its windows according to the screen +dimensions of the machine on which it is running. It is recommended that this mode be used only if the +appearance of a Series 3 application running in full Series 3 compatibility mode on the Workabout is truly +unacceptable. + + +Drawing with double size pixels is a feature that is available in version 4 of the window server. As well as +being used for compatibility mode on the Series 3a, it can be set for individual windows; see the Windows +chapter for further information. + + +The following two functions relate to compatibility mode. + + +wCompatibilityMode Set or cancel compatibility mode +VOID wCompatibilityMode(UINT flags,.i.WSERV_SPEC *pwspec) ; +On the S3a and Workabout, full S3 compatibility mode is turned on by setting flags to W_CTBY_S3. + + +On the Workabout, the S3 compatibility mode that allows use of the full 240 x 100 extent of the screen is +turned on by setting flags to W_CTBY_S3_SCR. + + +On both machines, Series 3 compatibility is turned off by setting flags to zero. + + +The pwspec parameter must point to the same WSERV_SPEC structure that was passed to the wconnect +function (see earlier in this chapter). wcompat ibiltyMode modifies information such as the screen +dimensions, held in this structure. + + +2-6 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +winquireCompatibility Inquire state of compatibility flags +UINT wInquireCompatibility (VOID) ; + + +The function returns the current state of the compatibility flags of the calling client. The flags are the +same as set by the function wcompatibilityMode. + + +Error handling + + +wCleanUp Return to defined state +VOID wCleanUP (VOID) ; +Put the window server back into a defined state by: + +e freeing the temporary Graphics Context if it exists + +e ending the redraw if one was in progress + + +If there is a current graphics context that is attached to a window, wcleanup also invalidates that window - +so that it is not left in a partly drawn state. + + +The function wcleanup is typically called in response to a p_leave. + + +wCheckPoint Check for an error +INT wCheckPoint (VOID) ; +Flush the client-side buffer (as for wriush) and return zero if there was no error. + + +If there is an uncleared error or if an error occurred in the processing of the buffer, call p_leave (err) or +return err, depending on whether woisableLeaves has been called, where err is the negative error +number. + + +wDisableLeaves Disable/enable leaves + + +UINT wDisableLeaves(UINT flag); + + +If £1ag is TRUE, the window server functions will (for the calling client) return an error code rather than +call p_leave when they encounter an error. If f1ag 1s FALSE, enable p_leaves. + + +Returns the previous value of £1ag (not before version 3.5). +By default, the window server functions that can fail call p_1eave when an error occurs. + + +Not available in version 2 of the window server. + + +Priority changing + + +The window server will not change a client's process priority unless the client has priority control +enabled. + + +Priority control is enabled if the client sets the w_conNEcT_PRIorRITY flag when it connects to the window +server or, if running version 4 of the window server, the client calls wsetPriorityControl (TRUE). + + +Priorities are set as follows: +e when a client loses the foreground or calls wstartCompute, its priority is set to E_PRIORITY_BACK + + +e when a client gains the foreground and is not in compute mode, its priority is set to the higher +priority E_PRIORITY_FORE + + +A client with priority control enabled should not change its own priority. + + +2-7 + + +WINDOW SERVER REFERENCE + + +wSetPriorityControl Set process priority handling on or off +INT wSetPriorityControl(UINT state); + + +Introduced in version 4 of the window server, this function enables and disables process priority handling +for a client. Setting state to TRUE enables it, while setting state to FALSE disables it. + + +The function always returns 0. + + +wStartCompute Enter compute mode +VOID wStartCompute (VOID) ; + + +Mark the client as being in compute mode, setting the caller's process priority to E_PRIORITY_BACK +regardless of whether it has the foreground or not. + + +Should be called before performing a computationally intensive task. + + +Has no effect unless the client has priority control enabled. + + +wEndCompute Leave compute mode +VOID wEndCompute (VOID) ; + +The caller is marked as not being in compute mode. + +Its priority will be set to E_PRIORITY_FORE whenever it is foreground. + + +Has no effect unless the client has priority control enabled. + + +General client functions + + +wClientinfo Get information about a client + + +INT wClientInfo(UINT pid); +Return a word mask giving information about the window server client with process ID pia. + + +If pia is a client of the window server, the function returns a bit mask that contains the following bit +fields: + + +W_CONNECT_CONNECTED this is set +W_CONNECT_USER_FLAG if set, the W_CONNECT_USER_FLAG was specified at connect time +W_CONNECT_SYSTEM_MODAL if set, the W_coNNECT_SYSTEM_MopAL flag was specified at connect time or + + +the client is in a system modal state as a result of calling wSystemModal +W_CONNECT_PRIORITY if set, priority control is enabled. + + +If pid is not a client of the window server, the function calls p_leave (E_FILE_NXIST) or returns +E_FILE_NXxIST, depending on whether wDisableLeaves has been called. + + +On version 2 of the window server, the function returns zero if pid is not a client of the window server. + + +wClientPosition Position client in task order +VOID wClientPosition(UINT pos, UINT pid); + + +Position client pid to position pos in the task order, zero being at the front and any value greater than the +number of connected tasks being at the back. + + +The constant WS_LAST_CLIENT_POSITION is provided to position a client at the back. +Passing a pid of zero is equivalent to passing the pid of the caller. + + +On a large screen version of the window server such as the MC, if the client pia is marked as iconised and +it is positioned to the front by a call to wclientPosition, it will be sent a WM_DEICONISE event. + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +wClientlconised Mark client as iconised +VOID wClientIconised(UINT state); +Mark the caller as iconised if state is TRUE, Otherwise mark it as deiconised. + + +This function only applies to large screen version of the window server such as the MC (and is not +available on hand-held machines such as the HC, $3, S3a and Workabout). + + +On an MC, if the user holds down the CONTROL key while pressing the TASK key, iconised task are +skipped and only non-iconised tasks are selected. + + +If a client is marked as iconised, the window server generates a wM_DEICONISE event to client pid if +wClientPosition (pid, 0) is called (normally by another client) to make client pia the foreground client. +The wM_DEICONISE event would normally prompt the client to deiconise itself. + + +On the MC, the window server recognises the shell (with process name sys$shll) and sends it a +WM_DEICONISE event when the PSION+TASK key is pressed while the shell is iconised. + + +wSystemModal Make client system modal +VOID wSystemModal (UINT pos); +Make the caller system modal and place it at position pos in the task list. + + +The window server limits task switching to only those processes that have a lower client position than the +frontmost system modal task. If there are no clients with a lower client position, the system modal task is +locked into the foreground. + + +When wSystemModal is used, pos is commonly zero - to lock the client to the foreground. +Not available in version 2 of the window server. + + +It is important to note that calling this function does not prevent a task from being made foreground. For +example, a user pressing ENTER on a task in the system screen will cause that task to be made foreground. + + +To handle an attempt to bring an application into foreground, it must test for a ww_FoREGROUND event. In +response to this event, the application can call wcLientPosition to return itself to background. + + +wCancelSystemModal Cancel system modal state +VOID wCancelSystemModal(UINT pos); +Cancel the caller's system modal state and place it at position pos in the task list. + + +Not available in version 2 of the window server. + + +wEnablePauseKey Enable pause key +VOID wEnablePauseKey (VOID) + +Allow the user to pause the calling client's graphics output when it has the foreground. + +Useful, for example, to stop information scrolling off the top of a display. + + +On the HC, the pause key is PSION+LEFT-ARROW and on the $3, S3a, Workabout and MC, it is CTRL+S. +The user resumes the client by pressing any key. The key press that resumes the client is not delivered to +the client. + + +The pause key may be disabled by calling woisablePauseKey. +The pause key is disabled by default, except in Console applications, where it is enabled by default. + + +When the user presses the pause key, the client will be stalled within a window server function and can +not therefore process any events that occur in the meantime. Applications that redraw their windows or +that respond to events other than the window server (such as the receipt of data from the serial port) +should not enable the pause key. + + +Not available in version 2 of the window server. + + +2-9 + + +WINDOW SERVER REFERENCE + + +wDisablePauseKey Disable pause key +VOID wDisablePauseKey (VOID) ; + +Disable pause key processing for the calling client. + +The pause key is enabled by calling wEnablePauseKey. + + +Not available in version 2 of the window server. + + +wGetProcessList Get client list +VOID wGetProcessList (UWORD *pbuf) ; + + +Write the process IDs of the clients of the window server as a zero terminated list in front to back order to +pbuf. + + +There should be at least ws_max_cLIENTS+1 words of memory at pbuf. + + +Not available in versions prior to version 3.5 of the window server. + + +Screen-based output + + +When using the window server, graphics output can be directed at: +e a graphics context (as described in the Graphics Output chapter) +e a particular window (as described in the Windows chapter) +e the screen as a whole (as described next) + + +On the HC, the font used for output that is not graphics context directed is determined by the sws_iF +("Internal Font") environment variable. + + +This should contain a worp binary value of 0 for ws_ronT_BasE and | for Wws_FoNT_BASE+1 and so on. If +you change the value of sws_1Fr, you must reset the machine by pressing the recessed reset button to effect +the change. + + +The "factory" setting of sws_1F is 4 (which selects the S3 font). + + +In version 4 of the window server, the environment variable $ws_FNTs is used to contain the indices of the +fonts to be used by the window server for notifies, clocks and so on. + + +In order, they are: +e System font +e §=6Notifier/Alert font +e Status Window font +e Symbols font used for the status window diamond symbol +e Medium 2 digital clock font +e Medium 2 date font +e §=Notifier/alert button font + + +e Small status window clock font + + +2-10 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +winfoMsgCorner Present an information message +INT wiInfoMsgCorner (TEXT *pmsg,UINT corner) ; +Displays the zero terminated string pmsg for 2 to 2.5 seconds or until cancelled. + + +The message is displayed in one of the four corners of the screen depending on corner, which should be +one of: + + +W_CORNER_TOP_LEFT to display pmsg in the top left corner +W_CORNER_TOP_RIGHT to display pmsg in the top right corner +W_CORNER_BOTTOM_LEFT to display pmsg in the bottom left corner +W_CORNER_BOTTOM_RIGHT to display pmsg in the bottom right corner + + +The length of pmsg (excluding its zero terminator) should be less than or equal to w_INFO_MSG_MAX_LEN +(64) bytes. A longer pmsg is truncated. + + +The message display is cancelled when: + + +e the calling client loses the foreground (the message is never displayed if the caller is a +background client) + + +e wiInfoMsgCorner OF wInfoMsg is called again +e the message is explicitly cancelled by calling winfomMsg (NULL) Of wInfoMsg("") + + +The function behaves as for wcheckPoint in that it flushes the client-side buffer and reports any uncleared +error - either by calling p_ieave or by returning the error number. + + +winfoMsg Present an information message + + +INT wiInfoMsg(TEXT *pmsg) ; + + +Displays the zero terminated string pmsg in the bottom right hand corner of the screen for 2 to 2.5 seconds +or until cancelled. + + +Behaves as for wInfoMsgCorner (&msg, W_CORNER_BOTTOM_RIGHT). + + +wSetBusyMsg Present a flashing busy message + + +INT wSetBusyMsg(TEXT *pmsg,UINT corner_delay) ; + + +Displays the zero terminated string pmsg as a flashing "busy" message in the specified corner of the +screen. + + +The message continues to display whenever the caller has the foreground. +The message is cancelled by calling wcancelBusyMsg, wSetBusyMsg (NULL) Of wSetBusyMsg(""). + + +The parameter corner_delay specifies both the corner of the screen in which the message will appear and +a delay to stop the message from appearing instantly. The delay is used to stop the message from +appearing at all when there is the possibility that the task can be completed in a short time. + + +The time delay should be ored in with the corner mask, which should be one of: + + +W_CORNER_TOP_LEFT to display pmsg in the top left corner +W_CORNER_TOP_RIGHT to display pmsg in the top right corner +W_CORNER_BOTTOM_LEFT to display pmsg in the bottom left corner +W_CORNER_BOTTOM_RIGHT to display pmsg in the bottom right corner + + +The delay is specified in half seconds. For example: +wSetBusyMsg ("Saving",W_CORNER_TOP_LEFT | 6); + + +will display the message in the top left corner after 3 seconds if it has not been cancelled before the time is +up. + + +The delay can range from 0 to 63 half seconds, inclusive. + + +2-11 + + +WINDOW SERVER REFERENCE + + +The length of pmsg (excluding its zero terminator) should be less than or equal to w_BUSY_MSG_MAX_LEN +(20) bytes. A longer pmsg is truncated. + + +The function behaves as for wcheckPoint in that it flushes the client-side buffer and reports any uncleared +error - either by calling p_leave or by returning the error number. + + +While the window server is loading a large bitmap or font (gopenBit or gOpenFont) or saving a large +bitmap (gSaveBit), it doesn't maintain the busy message. In these cases, the busy message will not flash +and it might not even appear. + + +wCancelBusyMsg Cancel a flashing busy message + + +INT wCancelBusyMsg (VOID) ; +Cancel a busy message. + + +Entirely equivalent to wSetBusyMsg (NULL). + + +Alerts + + +The functions that support alerts are available on S3, S3a and Workabout machines - and on HC +machines that are running version 3.5 or later of the window server. + + +Alerts present a p_notify-like display where the user is presented with a message and prompted to +respond by pressing a button. Unless you are already familiar with the notifier services, you may find it +useful to read the Notifier Services section of the Error Handling chapter in the PLIB Reference manual. + + +Alerts extend the specification of p_notify as follows: + + +e the maximum number of message lines is increased from 2 to 3. In version 4 of the window +server, the maximum number is increased to 4 (provided the screen is large enough to display +four lines of text in an alert) + + +e message lines may be centred or placed at a specified horizontal position + + +e rather than specify the address of a text string, it is possible to specify built in text strings by +number (the same text strings that are obtained using p_gettext) + + +e an asynchronous function is also provided so that the calling program can perform other tasks +while waiting for the user to respond + + +The alert functions are: + + +wsAlertW presents the user with a message and waits for a response. This function is +similar in effect to p_notify. + + +wsAlertA is the asynchronous form of wsAlertw. Using this, the program can perform +other tasks while waiting for the user to respond. There is no asynchronous +form of p_notify. + + +wsAlertUpdate is used to update a pending alert (which was launched using wsAlerta). +For example, the program: + + +#include +#include + + +LOCAL_D WSERV_SPEC wSpec; + + +GLDEF_C INT main(VOID) +{ +wConnect (&wSpec, 0,W_CONNECT_PRIORITY) ; +wsAlertW (WS_ALERT_CLIENT, "Hello World",NULL, NULL) ; +return (0); + + +} + + +2-12 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +when compiled and linked to produce a program with the name sample.img, presents the following +display on the HC. + + +Hello World + + +Continue +Esc + + +From top to bottom, the display consists of 3 parts: + + +Title Displays the program name. If the reserved static patstatusNamePtr contains +other than NULL, it is assumed to point to a zero terminated string which is +taken as the program name (of up to 8 characters in length and stopping when +a'.' is reached). If patstatusNamePtr iS NULL (which it will be if not explicitly +set), the process name is used. The process name is normally the name of the +executable and, for a single source file program, the name of the executable is +normally the name of the source file so you can deduce that the above example +had the file name sample.c. On the S3, the title area also contains the date and + + +time. +Message The message area contains up to 3 lines of text. +Buttons The button area contains one, two or three buttons. + + +On the S3a, running version 4 of the window server, the display is slightly different. Using the above +code results in the following: + + +Sample +Hello World + + +Continue + + +On the Workabout, the appearance is as follows: + + +Sample + + +Hello World + + +Continue + + +If there is a single button, it is activated by Esc. With two buttons, the left button is activated by Esc and +the right button is activated by ENTER. With three buttons, the buttons are activated by, from left to right, +ESC, SPACE and ENTER. + + +Version 3.5 of the window server added the ability to provide the notifier services (accessed via p_notify +and p_notifyerr). In EPOC terminology, the window server is said to "hook the notifier". + + +On the S3, S3a and Workabout, the window server always hooks the notifier. + + +WINDOW SERVER REFERENCE + + +On an HC, version 3.5 the window server does not by default hook the notifier (for backward compatibility +with version 3 of the window server). However, an HC may be configured such that the window server +does hook the notifier - as described in the section System start-up in the first chapter. + + +If you remove the first parameter from wsAlertw or the first two parameters from wsAlerta, the remaining +parameters correspond to the 5 parameters to p_notify. + + +If the window server has hooked the notifier, the program: + + +#include + + +GLDEF_C INT main(VOID) +{ +p_notify ("Hello World",NULL,NULL, NULL, NULL) ; +return (0); + + +} + + +produces the same result as the above example using wsAlertw - visually at least (and assuming that the +program is still called sample.img). + + +However, there are differences between wsAlertW and p_notify: + + +e = The alert presented by p_not ify is system modal - the user can't task away from it. In contrast, +wsAlertw is not system modal. For example, if a program reports a "No system memory" error +using wsAlertw, it can reasonably include a "Retry" option because it is possible to task to +another process and release memory (say by exiting a task) before returning to the alert and +selecting the Retry button. + + +e =6The caller of p_notify need not be a client of the window server. + + +e = When p_notify is called, the alert is presented regardless of whether the calling client is +foreground or not (although calling p_not ify does not displace the foreground client). If a +background client calls wsAlertw, the alert is not drawn until that task is made foreground. In +some circumstances, it may be desirable to call wclientPosition(0,0) and then wrlush to make +the caller foreground before calling wsAlertw. + + +e As well as having an extra leading parameter, wsAlertw has a stack-based calling convention +which is prototyped in such a way that unnecessary trailing NULLs may be omitted whereas +p_notify uses a register calling convention that requires all 5 parameters to be present. + + +The similarities between p_notify and wsAlertw are: + + +e In terms of setting up the display, all the features of wsAlertw are also available via p_notify +and vice versa. (Unfortunately, this means that the additional parameters associated with the +increased functionality have been squeezed into the existing p_notify compatible parameters in a +somewhat inelegant way.) + + +e =They are both designed not to fail when there is no free system memory. Both are ideal for +reliably reporting errors - including a "No System Memory" error. + + +The extra parameters are provided by passing data structures that are differentiated from a zero terminated +string by a leading zero. It follows that zero length strings should not be used as parameters to any of the +alert-based functions (they should be converted to NULLS). + + +Calling an alert-based function does not flush the client-side buffer. + + +On the HC, the font used to present alerts is determined by the sws_ir environment variable - as described +earlier. + + +wsAlertW Present and wait for an alert +INT wsAlertW(INT mode, TEXT *pT1, TEXT *pT2, TEXT *pOl, TEXT *p02, TEXT *p0O3); + + +Present a p_notify-like display where the user is presented with a message and prompted to respond by +pressing a button. As with p_notify, the function waits for the user to respond and returns the index (in +the range 0 to 2) of the button pressed. + + +When called from a regular application, the mode parameter should be ws_ALERT_CLIENT. Other values can +only be used by a special "alarm server" client. (The alarm server is a system component on the S3 and +S3a.) + + +Except for the additional mode parameter and except for the behavioural differences noted above, this +function provides the same services as p_notify - as described in the PLIB Reference manual. + + +2-14 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +The following describes only the extensions to the functionality normally provided by p_notify. +Note that wsAlertw is actually prototyped as: +INT CDECL wsAlertW(INT, TEXT *,TEXT *,TEXT *,...); + + +so that you can leave out trailing nuLLs when it is appropriate to do so. The compiler will complain if you +leave out trailing nuLLs in a call to p_notify (because p_notify uses a register calling convention which +does not permit a variable number of parameters). + + +Access to built in text + + +You can access operating system text (such as an error message) by passing a 3 byte array in place of a +text string to any of the 5 text parameters. The contents of the array should contain: + + +byte 0 zero +byte | Oxfe (0376 in octal) +byte 2 the signed index of the operating system text as passed to p_gettext. + + +For example, the following program, again compiled and linked as sample.img: + + +#include +#include + + +LOCAL_D WSERV_SPEC wSpec; + + +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) +{ +wConnect (&wSpec, 0,W_CONNECT_PRIORITY) ; +AlertErr (E_GEN_NOMEMORY, "Failed to save"); +return (0); + + +} +when run on the HC, displays: + + +Failed to saye +Mo system memory + + +Continue +Esc + + +when run on the S3a under version 4 of the window server, displays: + + +Failed to save +No system memory + + +Continue + + +2-15 + + +WINDOW SERVER REFERENCE + + +and when run on the Workabout displays: + + +Sample + + +Failed to save +No system memory + + +Continue + + +LEsc_] + + +Formatted text with 3 message lines + + +If the first two bytes at pT1 are zero, pT2 is ignored and wsAlertw assumes that the two zero bytes are +immediately followed by: + + +e an array of three DEsc structs + + +¢ immediately followed by a character buffer of maximum length w_ALERT_TEXT_MAx_LEN (80) that +contains the text for the three lines + + +The struct Desc is defined in wlib.h as: + + +typedef struct +{ +UBYTE hposition; +UBYTE length; +UWORD offset; + + +} DESC; +where +hposition is either 0xff for centred text or any other value to specify the pixel position +from the left of the alert +length is the length of the text for the line, to be taken from the buffer +offset is the offset of the start of the text relative to pti + + +Such a data structure would normally be built up by a function as in, for example: + + +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=é&ml1; + +for (pd=éal.line[0],pdend=pd+3; pdhposition=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) ; + + +} + + +2-16 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +where the following line: +Alert3("Line 1","Line 2","Line 3"); + + +when executed on an HC, displays: + + +Line 1 +Line 7? + + +Line 3 +Continue + + +Esc + + +when executed on the S3a under version 4 of the window server, displays: + + +Continue + + +and when executed on the Workabout, displays: + + +Sample + + +Line 1 +Line +Line 3 + + +Continue + + +LEsc_] + + +Text with 4 message lines + + +This is possible in version 4 of the window server and is achieved by oring the ws_ALERT_B attribute into +the mode parameter. The interpretation of the parameters pt1 and pt2 is changed. + + +The text referenced by the parameter pT1 is used as the title and is placed above the main box. This +contrasts with the normal practice of wsAlertw in using the program name as the title. + + +The text referenced by the parameter pr2 is a single string but can include up to three carriage return +characters (0x13 or '\r' in C programs). Each carriage return character causes the remaining text to be +wrapped to a new line and each line is centred within the main display box. + + +Note that this text need not contain carriage return characters. If the text is too long to fit onto one line, +carriage returns will be inserted at appropriate points. Whole words, however, will not be split. + + +2-17 + + +WINDOW SERVER REFERENCE + + +The sample code fragment below illustrates how this can be done. Note also the use of three buttons in +this example: + + +TEXT *ptxt,text[108]; + +ptxt = p_scpy(&text[0],"This is an example \r to demo"); +ptxt = p_scpy(ptxt,"nstrate the use \r"); + +ptxt = p_scpy(ptxt,"of four\r"); + + +ptxt = p_scpy(ptxt," message lines in the alert box"); + + +wsAlertW(WS_ALERT_CLIENT|WS_ALERT_B, "Title Line", &text[0],"A","B","C"); + + +This results in the following alert when run on a Series 3a machine under version 4 of the window server: + + +Tithe Line + + +This is an example +to demonstrate the use +of four +message lines in the alert box + + +Although the Workabout uses version 4, its screen is not large enough to display four lines of text in an +alert. If the above code is run on Workabout, the fourth line is not displayed and the appearance of the +alert is as follows: + + +Title line + + +This is an example +to demonstrate the use + + +of four + + +Note that the techniques used to access built in text and formatted text with three message lines as +described earlier, cannot be used with the attribute ws_ALERT_B set. + + +If any illegal parameters are passed, the function will raise a W_PANIC_ALERT panic. + + +wsAlertA Present an alert +VOID wsAlertA(INT mode,WORD *pstat,TEXT *pt1,TEXT *pt2,TEXT *pbl,...); + + +This function is not suitable for general use in applications. It is intended to be used only by the process +designated to be the alarm server; any application, however, may use wsAlertw. + + +Presents a p_notify-like display where the user is presented with a message and prompted to respond by +pressing a button. + + +Functionally identical to wsalertw except that it returns immediately without waiting for the user to +respond. It is the asynchronous form of wsAlertw. + + +Asynchronous requests are described in the chapter Asynchronous Requests and Semaphores in the PLIB +Reference manual. + + +When the user does respond, the calling process I/O semaphore is signalled and the index of the button +pressed (0, | or 2) is written to *pstat. + + +Once launched, there is no way of cancelling an asynchronous alert - it can only be completed by the user. + + +If any illegal parameters are passed, the function will raise a W_PANIC_ALERT panic. + + +2-18 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +wsAlertUpdate Update a pending alert +INT wsAlertUpdate (TEXT *pt1,TEXT *pt2,TEXT *pbl,...); + + +This function is not suitable for general use in applications. It is intended to be used only by the process +designated to be the alarm server; any application, however, may use wsAlertw. + + +Update an asynchronous alert where the parameters pt1, etc are as for wsAlerta. +Does nothing if the user has already responded to the alert. + + +If any illegal parameters are passed, the function will raise a w_pANIC_ALERT panic. + + +Pe ee En a ee +Status windows + + +Status windows are part of the $3, S3a and Workabout user interfaces. + + +In principle, status windows are also supported on an HC that is running version 3.5 of the window server. +However, their use requires the cooperation of a client which has declared itself as the application key +handler by calling wappKeyHandler (the application key handler is the shell on the $3, S3a and +Workabout). In practice, it would be difficult for an external developer to set up status windows on the +HC. + + +The window server supports two kinds of status window: + + +temporary If temporary status windows are enabled, the window server displays a pop-up +transient status window in front of the foreground client's existing windows +when PSION+MENU is pressed. The status window remains for 2 to 2.5 seconds. + + +permanent While enabled, the window server maintains a permanent status window to the +right of the screen and behind existing windows. If an application supports a +permanent status window, it is meant to "tile" its main top-level window with +the status window. On the S3 and S3a, higher level software toggles the +presentation of a permanent status window in response to a CTRL+MENU press. + + +The following shows the S3 World application's display with a temporary status window to the right of the +screen using a version prior to version 4 of the window server: + + +7 616 B44 + + +Wellinatoriy +Hew “ealand Dist! 11689 fi + + +There is no difference between the appearance of a permanent and a temporary status window. + + +The status window gives the user a view of (from top to bottom): + + +a program icon A client's icon is determined by a structure pointed to by the application key +handler. +a program name If the reserved static patStatusNamePtr contains other than NULL, it is assumed + + +to point to a zero terminated string that gives the program name (of up to 8 +characters, terminated by any'.'). If patstatusNamePtr is NULL, the process +name is used. + + +time and date The time and data is presented following the information in the £_conrte struct +as obtained by calling p_getctd. + + +2-19 + + +WINDOW SERVER REFERENCE + + +The following shows the S3a World application's display with a temporary status window to the right of +the screen using version 4 of the window server: + + +3 616 64 4 + + +gellington, +Dist: 11689 Miles United|_Thuz9 + + +|New Zealand + + +Note that the S3a has a larger and finer grained screen (480 x 160) pixels). + + +In version 4 of the window server, the status window has been modified. The program name and the +program icon have changed places and four new features can be displayed (although not all are shown in +the above example): + + +e Low battery indicator +e SSD pack indicators +e Remote link indicator +e Caps lock indicator + + +Each of these features can be disabled by setting the appropriate flags when configuring the window +server uSiNg wSystem. + + +The following illustration shows the S3a Database application display with a permanent status window to +the right of the screen. The application's main window has been neatly tiled with it: + + +First Name(s}: A.P. +Surname(s)-+ Another +Address: 123 Anyavenue +Anytown +Anycounty + + +Post Code: <1 0A +#2 Home: 071-123-4567 + + +Find: another + + +On the Workabout, an equivalent display of the Database application appears as shown below: + + +Name->A.P. Another +a Home: 071-123-4567 +Address: 123 Anyavenue +Anytown, Anycc + + +Find: another + + +Applications can have different 'modes' of operation, the precise definition being dependent on the +application. As well as using menu options and ‘hot' keys to switch between the different modes, an S3a +application can set the diamond key to cycle around some or all of them. + + +By using the wsSetList function, introduced in version 4, the program icon in the status window can be +replaced by a list of modes. In the S3a display shown above, all three modes of the Database application +are shown with the diamond symbol pointing to the current mode. + + +Note that the Workabout status window does not display either the application's icon or a list of modes. + + +2-20 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +Compatibility mode status window + + +In version 4, applications on the S3a and Workabout can run in $3 compatibility mode. This allows an +application to have the 'look' and 'feel' of the same application running on an S3. On the S3a, this is +achieved by doubling up the pixels. For example, a line which is 10 x 1 pixels on the S3 will be drawn 20 +x 2 pixels on the S3a and should 'look' the same. On the Workabout, applications running in compatibility +mode will normally exactly match the S3 appearance. + + +If an application is running in compatibility mode on the S3a or Workabout, then a call to wsEnable +creates a compatibility mode status window which looks and behaves like an S3 status window. + + +Alternatively, the version 4 function wst atusWindow can be used to create a compatibility status window. + + +wsEnable Enable the permanent status window + + +VOID wsEnable (VOID) ; + + +Create and maintain a permanent status window, behind existing windows. Does nothing if a permanent +status window already exists. + + +Before calling wsEnab1e, the calling application should resize its main window such that it is tiled with +the status window. + + +Under version 4, the required window extent should be determined by calling wInquirestatusWindow to +get the size of the status window and then performing a simple calculation. Under earlier versions of the +window server, uS€ wsScreenExt. + + +In version 4, if running in compatibility mode on the S3a or Workabout, the status window will have the +appearance of the S3 status window. + + +wStatusWindow Set the state of the status window + + +VOID wStatusWindow(INT state); + + +Available in version 4 only, this sets the permanent status window into one of a number of mutually +exclusive states by setting the parameter state to one of the following: + + +W_STATUS_WINDOW_OFF no status window is visible + +W_STATUS_WINDOW_SMALL display the small version of the status window +W_STATUS_WINDOW_BIG display the full size version of the status window +W_STATUS_WINDOW_CTBY display the S3 compatibility status window + +Calling this function with the parameter value w_sTATUS_WINDOW_oFF is equivalent to calling +wsDisable(); calling this function with the parameter value w_sTATUS_WINDOW_BIG (or +W_STATUS_WINDOw_cTBy if in S3 compatibility mode) is equivalent to calling wsEnable(). + + +See the description of wInquireStatusWindow (or, for versions of the window server earlier than version +4, wsScreenExt) for a means of determining the size and position of a status window. + + +wsScreenExt Get screen extent for tile with status window +VOID wsScreenExt (P_EXTENT *pext) ; + + +This function should only be used when running versions of the window server earlier than version 4. It is +available in version 4 for compatibility only. + + +It is strongly recommended that the function wInquireStatusWindow be used instead of wsScreenExt in +version 4 of the window server. + + +The function writes the extent of the screen remaining to the data structure pointed to by pext when there +is a permanent status window. + + +2The resize may fail with out of memory - so it is best to delay wsEnable until after the resize is +successful. + + +2-21 + + +WINDOW SERVER REFERENCE + + +The P_EXTENT struct is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; +WORD width; +WORD height; +} P_EXTENT; + + +Series 3 applications that support permanent status windows running under older versions of the window +server (i.e. earlier than version 4) can use wsScreenExt to determine the extent of the window to use while +a permanent status window is enabled. + + +Recall that the size of the entire screen (used in the absence of a permanent status window) may be +obtained from the wsERv_sPEc struct filled in by wconnect. For example: + + +GLREF_D WSERV_SPEC *wserv_channel; +LOCAL_D P_POINT ScreenSize; + + +ScreenSize=wserv_channel->conn.info.pixels; + + +wsUpdate Update the permanent status window +VOID wsUpdate(INT flags); + +Update the displayed permanent status window. + +The parameter flags can be one of: + + +WS_UPDATE_NAME to change the displayed permanent status window name (for example, after +changing DatStatusNamePtr). + + +WS_UPDATE_CLOCK to update any displayed clocks (for example, after changing settings such as +12/24 hour, analog/digital, the time separator and so on). + + +wsDisable Disable the permanent status window +VOID wsDisable (VOID) ; +Destroy the permanent status window (if one exists). + + +Before calling wsDisab1le, the calling application should resize its main window to take up the whole +screen. As with wsEnable, the required window extent may be determined by calling +wiInquireStatusWindow and doing a simple calculation. + + +wsEnableTemp Enable temporary status windows +VOID wsEnableTemp (VOID) ; +Enable the window server's processing of PSION+MENU to present a temporary status window. + + +Unlike wsEnable, the effect of this call is system wide. On the S3 and S3a, wsEnableTemp is called by the +shell as part of its initialisation. + + +wsDisableTemp Disable temporary status windows + + +VOID wsDisableTemp (VOID) ; +Disable the processing of PSION+MENU to present a temporary status window. + + +The effect of this call is system wide. Calling wsDisableTemp on the $3 and S3a will disable temporary +status windows for all applications. + + +2-22 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +wsSetList Set list of modes to display in status window + + +INT wsSetList (UINT count, TEXT **plist,UINT pos); + + +Available in version 4 only, this function sets up the text for the list of modes to be displayed in the status +window. + + +The count parameter is the number of text items in the list; the plist parameter is a pointer to an array of +string pointers (one string per mode) and pos is the position within the list where the diamond symbol is +to be placed. The first position is given a value of 0. + + +If the diamond symbol is not to be shown, pos should be set to w_STATUS_WIN_NO_DIAMOND. + + +To replace the list of modes with the application icon, count should be set to w_sTATUS_WINDOW_ICON. +With count set to this value, the other two parameters are ignored. Typically, a call would look like this: + + +wsSetList (W_STATUS_WINDOW_ICON, NULL, 0) ; + + +The function returns 0 if successful or =_GEN_Nomemory if it fails to allocate space for the new list. + + +Note that calling wssetList on the Workabout has no visible effect, since its status window does not +display a list of modes. + + +wsSelectList Set select position in status window mode list + + +VOID wsSelectList (INT pos); + + +Available in version 4 only, this function allows the diamond symbol in the list of modes in the status +window to be (re-)positioned. + + +The position is specified by giving a value to the parameter pos. The first position is given a value of 0. If +the diamond symbol is not currently shown, setting a position will cause it to reappear. Giving pos a value +of w_STATUS_WIN_NO_DIAMoND causes the diamond symbol to be removed from the status window. + + +Note that calling wsselectList on the Workabout has no visible effect, since its status window does not +display a list of modes. + + +winquireStatusWindow Inquire state and extent of status window +INT wiInquireStatusWindow(INT state,P_EXTENT *pextent) ; +Available in version 4 only, this function does two things: + + +e it returns the current state of the status window as set by wstatusWindow. It returns one of the +values w_STATUS_WINDOW_OFF, W_STATUS_WINDOW_SMALL, W_STATUS_WINDOW_BIG and +W_STATUS_WINDOW_CTBY. + + +e it fills in the pextent of the status window corresponding to state. In other words, by setting +state to one of the values w_sTATUS_WINDOW_OFF, W_STATUS_WINDOW_SMALL, +W_STATUS_WINDOW_BIG Of W_STATUS_WINDOW_CTBY, it supplies the position, width and height of a +status window of that type. + +Further, if state is given a value of -1, the extent of the current status window is supplied. + + +It is interesting to note that if the status window is off, the extent information describes a status window +located at the right hand edge of the screen with zero width and full height. + + +For a description of the p_ExTENT structure, see wsScreenExt. + + +2-23 + + +WINDOW SERVER REFERENCE + + +Configuring the window server + + +The functions which have a system wide effect on the window server (as opposed to just affecting the +calling client) are: + + +wSystem which is described next +wsEnableTemp to enable/disable permanent status windows (as described above) +wsDisableTemp + + +These functions should only be used when an application takes over the whole machine. This is more +likely on an HC than say an S3, S$3a or Workabout. + + +wSystem Configure the window server +INT wSystem(UINT new_flags,UINT flag_mask) ; + + +Set an internal set of flags to modify the system-wide behaviour of the window server where: + + +new_flags is a bit mask containing the values of the bit flags to be modified +flag_mask is a bit mask indicating (by those bits that are set) the bit flags that are to be +modified + + +The function returns the old value of the flags. +The flags are of the form ws—ERV_FLAG_xxx where xxx is one of: + + +Stops the window server from restarting the shell (that is, sys$shll.img) +NO_SHELL_REBOOT whenever it terminates. Clearing this flag when there is no shell running causes +the window server to restart the shell. Available on all machines. + + +NO_NOTIFIER_REBOOT The same as above except it applies to the notifier process (sys$ntfy.img). +Available on the HC and MC. + + +Prior to version 4, the window server on the S3 always provides the notifier +itself and never starts a sys$ntfy.img. + + +Under version 4, this flag can be set for the S3a and Workabout because the +possibility of building a separate notifier process exists. + + +HOOK_NOTIFIER If set, the window server attempts to hook the notifier, as explained in the +earlier Alerts section of this chapter. All MC versions are unable to hook the +notifier. + + +Prior to version 4, this flag applies to the HC only; the S3 effectively assumes +that it is permanently set. + + +Under version 4, this flag can be set for the S3a and Workabout. + + +NO_PANIC_NOTIFY Disables the window server from reporting processes which terminate with a +panic or a negative reason code. Available on the HC, $3, S3a and Workabout +but not the MC. This flag is ignored unless the window server has hooked the +notifier. On machines other than the MC, you would set this flag to prevent the +window server from reporting abnormal terminations when HOOK_NOTIFIER is +set. + + +UPDATE_MSGS Enables the window server to send wM_TASK_UPDATE events to the shell to +inform it of the termination of any process (not just clients of the window +server). The MC version does not support WM_TASK_UPDATE events. + + +Prior to version 4, this flag applies to the HC only; the S3 effectively assumes +that it is permanently set. + + +Under version 4, this flag can be set for the S3a and Workabout. + + +2-24 + + +2 GENERAL WINDOW SERVER FUNCTIONS + + +LOW_BATTERY_WARNINGS _ If set, the window server notifies the user of a low lithium or main battery. Note +that the window server only checks for low battery when the machine is turned +on. On the HC, the window server is only informed of the machine being +switched on after p_setonevent (TRUE) has been called. The MC version of the +window server does not support low battery warnings. + + +Prior to version 4, this flag only applies to the HC; on the S3, the window +server always reports low battery warnings. + + +Under version 4, this flag can be set for the S3a and Workabout. + + +HUNG_UP_SW If set, the window server presents a "hung up" status window if the foreground +task is not using backed-up windows and fails to respond to redraw events. The +MC version of the window server does not support status windows. + + +Prior to version 4, this flag only applies to the HC; the S3 effectively assumes +that it is permanently set. + + +Under version 4, this flag can be set for the S3a and Workabout. + + +The following flags are introduced in version 4 and apply only to S3a and Workabout machines. + + +SW_NO_LOW_BATTERY If set, it disables the low battery indicator in the status window. +SW_NO_PACKS If set, it disables the two pack indicators in the status window. +SW_NO_LINK If set, it disables the link indicator in the status window. +SW_NO_CAPS If set, it disables the caps lock indicator in the status window. + + +Prior to version 4, when the window server starts, the internal flags are all clear although, on the HC, this +can be altered by setting the sws_rn environment variable. + + +Under version 4 of the window server the internal flags on the S3a and Workabout can be altered, like on +the HC, by setting the sws_rL environment variable. + + +In practice, wsystem 1s more likely to be used on the HC rather than the S3, S3a, Workabout or MC. See +the section System start-up in the Introduction chapter for further discussion (including further details on +$wS_FL) and examples of the use of wsystem. + + +Attached Clients + + +This section only applies to large screen versions of the window server, such as the MC. + + +Clients can attach to and detach from each other by use of the wattachToClient, +wAttachToForegroundClient and wDetachClient Calls. + + +The client that calls the attach function is attached in front of the client it is attaching to. + + +When clients are attached they move round in the task order together - when one of the attached tasks +moves, it pulls the other task (or tasks) with it. When they become foreground, all attached tasks are sent a +WM_FOREGROUND event. + + +Two examples of the use of attached clients on the MC are: + + +e The system notifier sys$ntfy uses wAttachToForegroundClient to attach itself to the foreground client +to display its message. + + +e The voice server uses wAttachToClient to attach itself to its client (where both are clients of the +window server) to implement a dialog box as a separate process. + + +In both cases, the attaching client is behaving as if it were part of the client it is attached to. The notifier +could have been implemented using wclientPosition to make itself visible but the holder of the +foreground would then inappropriately go into background (and get a wM_BACKGROUND event). + + +When a client attaches to another, the window server sends a wM_ATTACHED event to the client being +attached to. When the attaching client detaches, it sends a wm_DETACHED event to the client being detached +from. + + +A detaching client is positioned to the back of all clients. + + +2-25 + + +WINDOW SERVER REFERENCE + + +wAttachToClient Attach to client + + +INT wAttachToClient (UINT pid); +Attach the caller to client pid. + + +If client pid does not exist, the function leaves or returns E_FILE_NXIST. + + +wAttachToForegroundClient Attach to foreground client + + +VOID wAttachToForegroundClient (VOID) ; +Attach the caller to the foreground client. + + +Does nothing if the caller has the foreground. + + +wDetachClient Detach from client + + +VOID wDetachClient (VOID) ; +Detach from a client and position to the back of all clients. + + +If the caller is no longer attached to another client (say because that client has terminated), the caller is +just positioned to the back. + + +PSO Oe a eae | +Miscellaneous + + +A number of general functions which do not fit under any of the previously discussed topics are described +here. Unless otherwise stated, they are all introduced in version 4 of the window server. + + +wSupportinfo Get information on supported features + + +VOID wsSupportInfo(.i.W_SUPPORT_INFO *pinfo); + + +The function fills the w_suppoRT_INFo type structure with information on the currently supported +features. The supplied parameter pinfo must point to a structure of type Ww_SUPPORT_INFO. + + +It can set the following values in the flags member: +W_SUPPORT_GREY if set, the window server supports the current scheme for drawing grey graphics + + +W_SUPPORT_CTBY_S3 if set, the window server supports a Series 3 compatibility mode (there is no +distinction between different Series 3 compatibility modes, such the two that +are available on the Workabout) + + +Currently, no other information is returned. The rest of the w_supPpoRT_INFo structure is set to zeros. The +function is well placed for expansion in future versions and releases of the window server. + + +The w_SUPPORT_INFO structure is defined as follows: + + +typedef struct +{ +UINT flags; +UINT fillers[15]; /* will be filled with 0's */ +} W_SUPPORT_INFO; + + +wDisableKeyClick Set or cancel key click disable state + + +VOID wDisableKeyClick(INT state); +If state is set to TRUE, the behaviour of the key click for an application is changed: + + +e = The key click is disabled while the application is in foreground. +e = The key click state is reset when the application goes to background. + + +Setting state to FALSE cancels this state for an application. + + +2-26 + + +CHAPTER 3 + + +WINDOWS + + +Creating and initialising a window + + +Window attributes + + +The functions: +wCreateWindow +wSetWindow + + +wiInquireWindow + + +to create a window and set its attributes +to set a window's attributes + + +to sense a window's attributes + + +take the address of a w_winpata struct as a parameter to hold the window attributes where the w_winpaTa +struct is defined as: + + +typedef struct + + +{ +WORD x; +WORD y; + + +} P_POINT; + + +ttypedef struct + + +{ +P_POINT + + +tale + + +WORD width; +WORD height; +} P_EXTENT; + + +ttypedef struct + + +{ + + +UWORD flags; +P_EXTENT extent; +WORD mouse_icon; +UBYTE background; +UBYTE filler; + +} W_WINDATA; + + +where: + + +flags + + +extent + + +mouse_icon + + +background + + +is a set of binary attributes, described below. In the root window, the flags field +is zero (so all the binary attributes are clear). + + +is the position and size of the window relative to its parent in pixel coordinates. +In the root window the extent coincides with the whole screen. + + +is the ID of the window mouse icon (only used when the machine has a +pointing device such as on the MC) + + +specifies whether the window is backed-up by a bitmap (or bitmaps) and, if not, +how the window should be prepared when it is validated + + +3-1 + + +WINDOW SERVER REFERENCE + + +background (up to version 3.5) + + +In versions of the window server up to and including 3.5 the background field of the w_winpata struct +should be one of: + + +W_W + + +W_W + + +W_W + + +W_W + + +IN_BACK_BITMAP all drawing to the window is duplicated to an off-screen bitmap. Redraws are +automatically done from this bitmap, so no ww_REDRAW events are ever +generated. When the background has this value, it may not be altered by calling +wSetWindow. Not available on version 2 of the window server. + +IN_BACK_CLR clear the pixels in the window on validation (the root window has this value). +This is the default value. + +IN_BACK_SET set the pixels in the window on validation. + +IN_BACK_NONE do nothing on validation (on the assumption that the drawing covers every + + +pixel). Best for flicker-free graphics. + + +background (version 4) + + +In version 4 of the window server, there are changes in meaning and values caused by the introduction of +grey. To control drawing to the normal (black) plane, one of the following must be set: + + +W_WIN_BACK_BITMAP all drawing to the normal (black) plane of the window is duplicated to an +off-screen bitmap. Redraws are automatically done from this bitmap, so no +WM_REDRAW events are ever generated. When the background has this value, +it may not be altered by calling wset window. + +W_WIN_BACK_CLR clear the pixels in the normal (black) plane of the window on validation (the +root window has this value). This is the default value. + +W_WIN_BACK_SET set the pixels in the normal (black) plane of the window on validation. + +W_WIN_BACK_NONE do nothing to the normal (black) plane of the window on validation (on the +assumption that the drawing covers every pixel). Best for flicker-free +graphics. + +W_WIN_BACK_CLR_NO_REDRAW to clear the pixels in the normal (black) plane of the window but prevent +any drawing or redrawing to this specific plane. + +W_WIN_BACK_SET_NO_REDRAW to Set the pixels in the normal (black) plane of the window but prevent any +drawing or redrawing to this specific plane. + +W_WIN_BACK_NONE do nothing to the normal (black) plane of the window on validation but also + +NO_REDRAW prevent any drawing or redrawing to this specific plane. + + +To control drawing to the grey plane, one of the following must be ored into the background field with + + +one of the above normal plane values: + +W_WIN_BACK_GREY_BITMAP all drawing to the grey plane of the window is duplicated to an off-screen +bitmap. Redraws are automatically done from this bitmap, so no ww_REDRAW +events are ever generated. When the background has this value, it may not +be altered by calling wset window. + +W_WIN_BACK_GREY_CLR clear the pixels in the grey plane of the window on validation (the root +window has this value). + +W_WIN_BACK_GREY_SET set the pixels in the grey plane of the window on validation. + +W_WIN_BACK_GREY_NONE do nothing to the grey plane on validation (on the assumption that the +drawing covers every pixel). Best for flicker-free graphics. + +W_WIN_BACK_GREY_CLR to clear the pixels in the grey plane of the window but prevent any drawing + +NO_REDRAW or redrawing to this specific plane. This is the default value. + +W_WIN_BACK_GREY_SET to set the pixels in the grey plane of the window but prevent any drawing or + +NO_REDRAW redrawing to this specific plane. + +W_WIN_BACK_GREY_NONE do nothing to the grey plane of the window on validation but also prevent + +NO_REDRAW any drawing or redrawing to this specific plane. + + +3 WINDOWS + + +If drawing is enabled to both the normal (black) and the grey planes, then both planes will be moved when +scrolling or moving a window. + + +If no drawing is intended for one of the planes in a window, then overheads can be cut by disabling the +unused plane. For example, if no drawing is to be done to the grey plane, disable this plane by NOT +setting any of w_WIN_BACK_GREY_CLR, W_WIN_BACK_GREY_SET, W_WIN_BACK_GREY_NONE OF +W_WIN_BACK_GREY_BITMAP. + + +Note that if both w_wmn_BAcK_BITMAP and w_WIN_BACK_GREY_BITMapP are set, then the window will be +backed up to two bitmaps, one for the normal plane and one for the grey plane. + + +Also note that setting one of: + + +W_WIN_BACK_CLR_NO_REDRAW + + +W_WIN_BACK_SET_NO_REDRAW + + +W_WIN_BACK_NONE_NO_REDRAW + + +and setting one of: + + +W_WIN_BACK_GREY_CLR_NO_REDRAW + + +W_WIN_BACK_GREY_SET_NO_REDRAW + + +W_WIN_BACK_GREY_NONE_NO_REDRAW + + +is equivalent to setting the w_wIN_No_REDRaw bit (as a parameter to wcreat eWindow). +flags (all versions) +The following bits of f1ags apply to all versions of the window server on all machines: + + +W_WIN_NO_REDRAW windows with this flag set never receive redraw events. This flag may not be +altered by a wSetwindow command. + + +W_WIN_PRIORITY redraw events for windows with this flag set have priority over redraw events +for windows with this flag clear. + + +flags (version 4) + +The following bit of f1ags applies to version 4 of the window server: + +W_WIN_DOUBLE_PIXEL when set, causes all graphics in this window to work in double pixel mode. +Large screen flags + +The following bit of f1ags applies only to large screen versions of the window server such as the MC: + + +W_WIN_FOREGROUND_ONLY if set, the window is only visible while the client is foreground. Note that a +descendant window of a roREGROUND_ONLY window is necessarily also +FOREGROUND_ONLY regardless of the value of this flag. This flag may not be +altered by a wSetwindow command. + + +Mouse-related flags + + +The following bit of f1ags apply only when the machine has a pointing device, such as on the MC: + + +W_WIN_NO_MOUSE a window with this flag set will not receive any mouse events (however, +the mouse cursor is still displayed). All other mouse-related flags have no +affect when this flag is set. + + +W_WIN_INACTIVE if a mouse click occurs anywhere in a window with this flag set or in any +of its descendants, a wM_AcTIVE event is sent to the window. + + +W_WIN_INPUT_ONLY if set, the window is input-only. Input-only windows are invisible and exist +solely for the purpose of detecting mouse events. This flag may not be +altered by a wSetwindow command. + + +W_WIN_MOUSE_MOVE if set, mouse movement events are generated when the mouse button is up. +W_WIN_MOUSE_DRAG if set, mouse movement events are generated when the mouse button is +down. + + +3-3 + + +WINDOW SERVER REFERENCE + + +W_WIN_MOUSE_GRAB if set, the mouse is automatically grabbed when the mouse button is +pressed. The grab is automatically released when the mouse button is +released and a wM_MOUSE event of type WM_MOUSE_RELEASE is sent to the +grabbing window, even if the release occurs outside the window. If +W_WIN_MOUSE_DRAG is also set, any intermediate wM_MouSE_MOVE events are +also delivered to the grabbing window. + + +W_WIN_RUBBER_BAND If a mouse down event occurs in a window with this bit set, it and + +CAPTURE subsequent mouse and keyboard events are captured to the window server's +rubber band processing until the rubber band mode is terminated. This first +mouse click generates a WW_RUBBER_BAND_INIT event to which the client +must respond with a call to wRubberBand. This flag may not be altered by a +wSetWindow command. + + +W_WIN_RUBBER_BAND If when calling wRubberBand in response to a WM_RUBBER_BAND_INIT event + +COMPLETE_ON_RELEASE you specify that the rubber band should be completed on a mouse up event, +you should also set this bit. This flag may not be altered by a wSet Window +command. + +wCreateWindow Create a window + + +INT wCreateWindow(UINT parent_id, UINT field_set, .i.W_WINDATA *pwindata, UWORD handle); +Create a window and, if successful, return the positive ID of the window where: + + +parent_id is the window ID of the parent window. To create a top-level window, where +the parent is the root window (ie the whole screen), pass parent_id as zero. + + +handle is the client's own identifier for the window (which must be non-zero) to be +embedded in events which are directed at the window (for example, redraw and +mouse events). In medium to large applications, handle is commonly the +address of a control block which contains the window ID. + + +field_set is a set of bit flags which specify (by being set) which fields in the pwindata +struct are to be used to set the window attributes. In most cases, an attribute +which is not set from pwindata is inherited from parent_id (as detailed +below). If field_set is zero, pwindata 1s ignored. + + +pwindata is the address of a W_WINDATA struct as described above. If field_set is zero, +pwindata is ignored. + + +The bits in field_set are made up of the same bit masks as for pwindata->flags to indicate that the +corresponding bit in pwindata->flags should be used. And, in addition, field_set may contain: + + +W_WIN_EXTENT to uSe pwindata->extent +W_WIN_MOUSE_ICON to use pwindata->mouse_icon +W_WIN_BACKGROUND to uSe pwindata->background + + +If a field_set bit is clear, the corresponding attribute is inherited from the parent window parent_ida, +except for: + + +W_WIN_RUBBER_BAND_CAPTURE +W_WIN_INACTIVE +W_WIN_NO_REDRAW +W_WIN_PRIORITY +W_WIN_FOREGROUND_ONLY + + +These five attributes are never inherited from any parent window. If they are not set explicitly, by setting +the appropriate bit in fielda_set and the corresponding data value in the w_winpata struct pointed to by +pwindata, they are set to zero. + + +If parent_id has one or more child windows, the new window is created in front of its siblings. + + +After a successful return from wcreat eWindow, the window is just a dormant data structure in the window +server's data segment with no visibility on the screen. You can't draw to the window and you won't get any +redraw events (or any mouse events if there is a pointing device) until the window is initialised by calling +wInitialiseWindowTree, described below. + + +3-4 + + +3 WINDOWS + + +If the function fails because there is insufficient memory, it calls p_leave (E_GEN_NOMEMORY) or returns +E_GEN_NOMEMoRY, depending on whether wDisableLeaves has been called. + + +See the description of wconnect for an example. + + +wSetWindow Set window attributes + + +VOID wSetWindow(UINT wid, UINT field_set, .i.W_WINDATA *pwindata) ; + + +Set one or more window attributes of the window with ID wia where field_set and pwindata are as for +wCreateWindow, described above. + + +The function wSetwindow ignores the following bits in field_set which correspond to window attributes +which are not modifiable: + + +W_WIN_NO_REDRAW + +W_WIN_INPUT_ONLY +W_WIN_FOREGROUND_ONLY +W_WIN_RUBBER_BAND_COMPLETE_ON_RELEASE + + +You cannot modify any of the attributes of the root window. +In practice, wSetWindow 1s commonly use to move and/or resize a window. + + +If the size of a backed-up window is increased, the backup bitmap(s) will also be increased and the +additional area (to the right and below) is filled with zeros. + + +In this situation, the call can fail with an out-of-memory condition; it should be noted that such a failure +might not be reported immediately because of the buffering of window server requests (see the Clients and +the window server section in the Introduction chapter). + + +Any areas of the window that are exposed as a result of making the call to wset window (because the effect +has been to expand or move the window) are invalidated. Areas that are covered, moved offscreen, or lost +because the window has become smaller are marked as valid, thus preventing any redraws that might have +been pending for these areas. The validity of any other areas is not affected by the call. + + +winquireWindow Get window attributes + + +INT wiInquireWindow(UINT wid, .i.W_WINDATA *pwindata) ; + + +Write a copy of window wia's extent and flags to *pwindata (pwindata->mouse_icon and +pwindata->background are left undefined). + + +wlnitialiseWindowTree Initialise window tree + + +VOID winitialiseWindowTree(UINT wid); + +Initialise window wid and all its descendants. + +None of these windows may be initialised again. + +Provided that the window is not made invisible between creation and initialisation, the following occurs: + + +backed-up window! The backup bitmap (which is initialised with zeros when the window is created) +is copied to any visible parts of the window, clearing it. In version 4 of the +window server there may be two backup bitmaps which are copied to the visible +parts of the window's normal and grey plane respectively. + + +no-redraw window2 Any visible pixels are cleared if the background attribute is w_wIN_BACK_CLR or +set if the background attribute is w_win_Back_seEt. In version 4 of the window +server, these attributes clear or set the visible pixels in the window's normal +plane while w_wIN_BACK_GREY_CLR and W_WIN_BACK_GREY_SET Clear or set the +visible pixels in the window's grey plane. + + +non-backed-up redraw _— Any visible parts are added to the update region (which will subsequently cause +window redraw events to be generated). + + +!Where the window attribute background is W_WIN_BACK_BITMaP (and/or w_WIN_BACK_GREY_BITMAP in +version 4 of the window server). + + +2Where the w_wIn_No_REDRAw window attribute is set. + + +3-5 + + +WINDOW SERVER REFERENCE + + +wCloseWindowTree Destroy a window and its descendants + + +VOID wCloseWindowTree(UINT wid); + + +Destroy window wid and all its descendants, freeing any associated window server resources (such as an +attached graphics context). + + +When destroying a window system, it is sometimes difficult to destroy windows bottom-up with respect to +the window parentage tree. To make life easier, the window server allows windows to be destroyed more +than once as long as other window server objects, such as graphics contexts, bitmaps, fonts, icons or +windows are not created in the mean time. + + +If you are using wGetEvent or wGetEvent Special rather than wGetEventWait, you should be very careful +about destroying windows while a request made by calling wcetEvent or wGetEvent Special is pending. +Bearing in mind the multi-tasking nature of the system and the fact that the window server runs at a +higher priority than its clients, it is quite possible for an event to be delivered before the window is +destroyed in which case there is the possibility that the next event will relate to a window which has +already been destroyed (a redraw event, say). + + +The solution to this problem normally involves calling wcancelGetEvent, as described in the first chapter. + + +winquireWindowOffset Get window to window offset + + +INT wiInquireWindowOffset (UINT from_wid, UINT to_wid, .i.P_POINT *poffset); +Write the offset of to_wid relative to from_wid tO poffset and return zero. +The P_POINT struct is: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +Useful when positioning windows relative to each other. To find the absolute position of a window on the +screen set from_wid to zero (the root window ID). + + +If the window server has a pending error with error number err, the function calls p_leave (err) or +returns err, depending on whether wDisableLeaves has been called. + + +wReassignRootWindow Reassign the root window + + +VOID wReassignRootWindow(UINT wid); + + +Reassign the window ID of zero to mean the window wid rather than the root window which covers the +whole screen. + + +The assignation applies only to the calling client. +Passing a wid of zero resets the window ID of zero to mean the whole screen. + + +Used for creating development environments on a large screen version of the window server which +simulate a small screen environment. + + +Not available in version 2 of the window server. + + +Visible and invisible windows + + +wMakelnvisible Make window invisible +VOID wMakeInvisible(UINT wid); +Mark window wid as invisible. +When a window is marked as invisible it and all its descendants are made invisible. +The window server treats windows which are invisible as follows: +e if the window is backed-up, any drawing to it is drawn only to the backup bitmap(s) +e invalidating a window using wInvalidateRect or wInvalidateWin has no effect + + +e¢ windows behave as if they do not exist with respect to mouse input (this only applies when there +is a pointing device) + + +3-6 + + +3 WINDOWS + + +wMakeVisible Make window visible +VOID wMakeVisible(UINT wid); +Mark window wid as visible. + + +Unless wMakeInvisible has been applied to a descendant, calling wMakevisible makes all descendants +visible. + + +Sibling positions + + +wWindowPosition Change position in sibling list +VOID wWindowPosition(UINT wid, UINT pos); +Move window wid to the position pos in its sibling list. + + +If pos is greater than the number of siblings then window wia will go to the back of the sibling list, if pos +is zero then it will go to the front of the sibling list. + + +wGetWindowPosition Get position in sibling list +INT wGetWindowPosition(UINT wid); +Return the position of window wid in its sibling list. + + +The function behaves as for wcheckPoint in that it flushes the client-side buffer and reports any uncleared +error - either by calling p_ieave or by returning the error number. + + +Not available in version 2 of the window server. + + +Scrolling + + +wScrollRect Copy a rectangle +VOID wScrollRect (UINT wid, .i.P_RECT *prect, P_POINT *poffset); + +Copy the pixels in rectangle prect in window wid to the same sized rectangle, displaced by poffset. + +The structs p_pornt and p_rRect are defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; +The copy excludes the following from prect: +e those parts which are in the update region (that is, those parts which are invalid) +e those parts which are obscured or clipped by other windows + + +e those parts which are beyond the boundaries of the window + + +Although these parts are not copied, their existence causes the corresponding region of the displaced +rectangle to be invalidated. + + +3-7 + + +WINDOW SERVER REFERENCE + + +In version 4 of the window server, if drawing is enabled to both the normal and the grey planes, then the +copying activity described above is done to both planes. + + +If the window is a backed-up window, the copy is also applied to the backup bitmap(s). For a backed-up +window: the update region is always null; those parts which are obscured or clipped can be recovered from +the backup bitmap(s); those parts which are beyond the boundaries of the window are cleared. + + +Note that wScrol1Rect may also be applied to a bitmap where wid is a bitmap ID (but not in version 2 of +the window server). + + +wsScrollWin Scroll a window +VOID wScrollWin(UINT wid, .i.P_POINT *poffset) ; + +Scroll the whole of window wid by displacement poffset. + +Entirely equivalent to wScrollRect with prect set to a rectangle covering the whole window. + + +Note that wScrollwin may also be used to scroll a whole bitmap where wid is a bitmap ID (but not in +version 2 of the window server). + + +Redrawing + + +There are six variants of wBeginRedraw which vary according to whether a temporary graphics context is +created (and, if so, whether it is to be altered from its default settings) and whether a part or the whole of +the window is being redrawn, as follows: + + +wBeginRedraw to redraw a part of the window using an independently created temporary or +permanent graphics context + + +wBeginRedrawWin to redraw the whole of the window using an independently created temporary +or permanent graphics context + + +wBeginRedrawGC to redraw a part of the window using a temporary graphics context which is +created and initialised with specified values + + +wBeginRedrawGC0 to redraw a part of the window using a temporary graphics context which is +created with default initial values + + +wBeginRedrawWinGC to redraw the whole of the window using a temporary graphics context which is +created and initialised with specified values + + +wBeginRedrawWinGC0 to redraw the whole of the window using a temporary graphics context which is +created with default initial values + + +Note that the last character in both wBeginRedrawGco and wBeginRedrawwWincco is the digit zero (and not +the letter 'o'). + + +When a begin redraw function is used to simultaneously create a temporary graphics context, the +corresponding call to wEndRedraw automatically frees it. + + +All variants validate at least a part of a window and cause subsequent drawing to use the update region +rather than the normal drawing region. If the background attribute of the window is w_wIN_BACK_CLR, +validated pixels in the update region are cleared and if the background attribute is w_wIn_BACK_SET, the +same pixels are set. + + +In version 4 of the window server, the above two background attributes apply to validated pixels in the +normal (black) plane in the update region. In addition, if the background attribute of the window is +W_WIN_BACK_GREY_CLR Or W_WIN_BACK_GREY_SET, validated pixels in the grey plane in the update region +are cleared or set respectively. + + +A way of ensuring flicker-free redrawing, is to set the background attribute to w_wIN_BACK_NONE and cover +every pixel in the redraw. + + +In version 4 of the window server, W_WIN_BACK_NONE applies only to the normal (black) plane. To achieve +the same effect when drawing to the grey plane, the corresponding attribute w_wIN_BACK_GREY_NONE +should also be set. + + +3-8 + + +3 WINDOWS + + +wBeginRedraw Start a partial redraw + + +VOID wBeginRedraw(UINT wid, .i.P_RECT *prect); + + +Validate the rectangle prect in window wia and clip subsequent drawing to the intersection of prect and +the window's update region (as it was before the validate). The normal drawing region is restored when +wEndRedraw is called. + + +The struct p_rect is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +wBeginRedrawWin Start a full redraw + + +VOID wBeginRedrawWin(UINT wid); + + +Validate the whole of window wia and clip subsequent drawing to the window's update region (as it was +before the validate). The normal drawing region is restored when wEndRedraw is called. + + +Equivalent to calling wBeginRedraw with a rectangle covering all of window wia. + + +wBeginRedrawGC Start a partial redraw (GC) + + +VOID wBeginRedrawGC (UINT wid, .i.P_RECT *prect, UINT field_set, G_GC *pgc); + + +Validate the rectangle prect in window wia and clip subsequent drawing to the window's update region +(as it was before the validate). + + +In addition, create a temporary graphics context which is initialised with those fields from pgc which have +their corresponding bit fields set in field_set. + + +The c_cc struct is defined in wlib.h as: + + +typedef struct +{ + + +UBYTE gmode; /* G_TRMODE_SET, CLR, INV (line) */ + +UBYTE textmode; /* G_TRMODE_SET, CLR, INV, REPL (text) */ + +UBYTE style; /* G_STY_NORMAL, _BOLD, _UNDERLINE, _INVERSE, _DOUBLE, _MONO, +_ITALIC */ + +UBYTE flags; /* controls use of grey & double pixel mode */ + +WORD font; /* ID of font to use */ + +} G_GC; + + +where the bit fields for field_set are: + + +G_GC_MASK_GMODE corresponding to the gmode member +G_GC_MASK_TEXTMODE corresponding to the textmode member +G_GC_MASK_STYLE corresponding to the style member +G_GC_MASK_FONT corresponding to the font member + +G_GC_MASK_GREY corresponding to the flags member (version 4 only) +G_GC_MASK_DOUBLE corresponding to the £1ags member (version 4 only) + + +The flags member is introduced in version 4 of the window server. Prior to version 4, the space occupied +by this member was unused. + + +See the Graphics Output chapter for a complete description of the fields in a c_cc struct. + + +The graphics context is freed (and the normal drawing region is restored) when wendRedraw is called. + + +3-9 + + +WINDOW SERVER REFERENCE + + +wBeginRedrawGCOo Start a partial redraw (GCO) + + +VOID wBeginRedrawGCO (UINT wid, .i.P_RECT *prect); + + +Validate the rectangle prect in window wid and clip subsequent drawing to the window's update region +(as it was before the validate). + + +In addition, create a temporary graphics context with default initial values. + + +The graphics context is freed (and the normal drawing region is restored) when wEndRedraw is called. + + +wBeginRedrawWinGC Start a full redraw (GC) + + +VOID wBeginRedrawWinGC(UINT wid, UINT field_set, .i.G_GC *pgc); + + +Validate the whole window wid and clip subsequent drawing to the window's update region (as it was +before the validate). + + +In addition, create a temporary graphics context which is initialised with those fields from pge which have +their corresponding bit fields set in field_set. + + +The graphics context is freed (and the normal drawing region is restored) when wEndRedraw is called. +The c_cc struct is defined in wlib.h as: + + +typedef struct +{ + + +UBYTE gmode; /* G_TRMODE_SET, CLR, INV (line) */ + +UBYTE textmode; /* G_TRMODE_SET, CLR, INV, REPL (text) */ + +UBYTE style; /* G_STY_NORMAL, _BOLD, _UNDERLINE, _INVERSE, _DOUBLE, _MONO, +_ITALIC */ + +UBYTE flags; /* controls use of grey & double pixel mode */ + +WORD font; /* ID of font to use */ + +} G_GC; + + +where the bit fields for field_set are: + + +G_GC_MASK_GMODE corresponding to the gmode member +G_GC_MASK_TEXTMODE corresponding to the textmode member +G_GC_MASK_STYLE corresponding to the style member +G_GC_MASK_FONT corresponding to the font member + +G_GC_MASK_GREY corresponding to the flags member (version 4 only) +G_GC_MASK_DOUBLE corresponding to the flags member (version 4 only) + + +The flags member is introduced in version 4 of the window server. Prior to version 4, the space occupied +by this member was unused. + + +See the Graphics Output chapter for a complete description of the fields in a c_cc struct. +Example + + +LOCAL_C VOID BeginRedraw(INT wid, INT fid, INT style) +{ +G_GC gc; + + +gc.font=fid; +gc.style=style; + + +wBeginRedrawWinGC (wid, G_GC_MASK FONT |G GC_MASK_STYLE, &gc) ; +} + + +wBeginRedrawWinGCo Start a full redraw (GCO) + + +VOID wBeginRedrawWinGCO(UINT wid); + + +Validate the whole of window wid and clip subsequent drawing to the window's update region (as it was +before the validate). + + +In addition, create a temporary graphics context with default initial values. + + +The graphics context is freed (and the normal drawing region is restored) when wEndRedraw is called. + + +3-10 + + +3 WINDOWS + + +wEndRedraw End a redraw +VOID wEndRedraw (VOID) ; + +End a redraw. + +Drawing is set back to use the normal drawing region (which clips to the visible region of a window). + + +If a temporary graphics context was created by calling wBeginRedrawGC, wBeginRedrawWinGC, +wBeginRedrawGCO OF wBeginRedrawwineco, the temporary graphics context is freed. + + +Validating + + +Validating a rectangle in a window removes that rectangle from the window's update region (if the +window has an update region). Validating the whole window deletes the window's update region. + + +When responding to the receipt of a wm_REDRAw event (see the Events chapter) it is essential to perform a +validation: until a window's update region has been entirely validated, wm_rEDRaw events will continue to +be received. + + +The normal response to a wM_REDRAW event is to perform a validation and to draw all or part of the window +(drawing will be clipped to the intersection with the window's update region). The rectangle that is +validated should correspond exactly to the rectangle that is drawn, rather than to the rectangle specified by +the wM_REDRAW event. + + +Depending on the window's background attribute, validation may also set, clear or leave unchanged all the +pixels in the rectangle. You should set the background attribute to select the action that is most +appropriate for the particular situation. + + +If the background attribute of the window is w_wIN_BAck_cLR, validated pixels in the drawing region are +cleared and if the background attribute is w_wIN_BACK_sET, the same pixels are set. + + +In version 4 of the window server, these attributes refer to validated pixels in the normal (black) plane of +the update region. In addition, if the background attribute w_wIN_BACK_GREY_CLR is set, validated pixels in +the grey plane of the drawing region are cleared and if the background attribute w_wIN_BACK_GREY_SET 1S +set, the same pixels are set. + + +A way of ensuring flicker-free redrawing of a window is to set the background attribute to +W_WIN_BACK_NONE and cover every pixel in the draw. + + +In version 4 of the window server, the w_wIN_BACK_NONE attribute refers to the normal (black) plane. If you +are also drawing to the grey plane, then the same result can be achieved in this plane by setting the +W_WIN_BACK_GREY_NONE attribute. + + +wValidateRect Validate a rectangle of a window +VOID wValidateRect (UINT wid, .i.P_RECT *prect); + +Validate the rectangle prect in window wid. + +The struct p_rect is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +wValidateWin Validate a whole window + + +VOID wValidateWin(UINT wid); +Validate the whole of window wid. + + +Equivalent to calling wvalidateRect with a rectangle covering window wid. + + +3-11 + + +WINDOW SERVER REFERENCE + + +a +Invalidating + + +Invalidating a rectangle in a window adds that rectangle to the window's update region. Invalidating the +whole window sets the window's update region to cover the whole window. + + +When a client wishes to draw an area in one of its windows, there are two approaches: +e to draw directly to the area (normally after calling wvalidateRect or wValidateWin) + + +e to invalidate a rectangle and make use of the code which redraws its window in response to a +WM_REDRAW event + + +The advantages of invalidating are: +e It makes use of the code which must in any case be provided to redraw the window. + + +e An application can effectively use the window server's update region to accumulate disjoint +invalid areas without having to worry about whether those areas overlap (since overlapping areas +will generate a single redraw). + + +e Because the areas invalidated are clipped to the visible areas of the window, responding to the +WM_REDRAW events can require less work than drawing the whole window (since the whole +window may be partially or totally obscured or it may be invisible). + + +The main disadvantage of invalidating is the loss of performance resulting from the extra context +switching from the client to the window server to process the invalidate command and then back to the +client to process the redraw. + + +winvalidateRect Invalidate a rectangle +VOID wiInvalidateRect (UINT wid, .i.P_RECT *prect) ; + +Invalidate the rectangle prect in window wid. + +The struct p_RecT is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +winvalidateWin Invalidate a window +VOID wiInvalidateWin(UINT wid); +Invalidate the whole of window wid. + + +Equivalent to calling wInvalidateRect with a rectangle covering the whole of window wid. + + +————e—————————— EE eT) +Text cursor + + +wTextCursor Draw a text cursor + + +VOID wTextCursor(UINT wid, .i.W_CURSOR *pcursor) ; +Present a text cursor (which is optionally flashing) in window wid. + + +There is only one text cursor per client. If a text cursor already exists, it is removed before the new cursor +is positioned (you do not have to call wzEraseTextCursor if you are moving the cursor to another position +in the same or a different window). + + +Version 4 of the window server allows the text cursor to appear grey. This is achieved by setting +W_CURSOR_GREY in the flags member of the w_cursor structure. + + +3-12 + + +3 WINDOWS + + +The w_cursor struct is defined in wlib.h as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT pos; /* text cursor position */ +UBYTE height; /* text cursor height */ +BYTE ascent; /* text cursor ascent */ +UBYTE width; /* text cursor width */ +UBYTE flags; /* for obloid cursor and to disable flashing */ +} W_CURSOR; + + +The height, ascent and width members specify the height, ascent and width of the text cursor. The flags +member may be zero or it may contain any combination of the following bit flags: + + +W_CURSOR_OBLOID to round off the corners of the cursor +W_CURSOR_NO_FLASH to disable the flashing of the cursor +W_CURSOR_GREY to make the text cursor appear grey + + +The position of the cursor is consistent with positioning conventions for text where the top left of the +cursor is ascent above the position passed to wrextCursor. In fact, the x, y position for wrextcursor +should be the same as for drawing a text string. See the description of gPrintText in the Graphics Output +chapter. + + +Applications which use a vertical line cursor to indicate a position between two characters should (by +convention) place the cursor in the leftmost position of the character cell which is to the right of the +cursor. In this case, width is set to 1 (or 2), and ascent and height are set according to the font currently +in use. + + +A block or underline cursor is sometimes appropriate when using a monospaced font where width should +be set to the width of a characters in the font. + + +For an underline cursor, height should be set to 1. To draw the underline along the baseline of the font, +ascent Should be set to zero. To draw it along the bottom line of the characters, ascent should be set to +(font.ascent—font.height+1). + + +The window server controls the flashing of the cursor and makes sure that it does not interfere with any +drawing. + + +On large screen versions of the window server such as the MC, the window server automatically ensures +that only the foreground text cursor is visible. + + +wDrawTextCursor Draw a text cursor + + +VOID wDrawTextCursor(UINT wid, .i.W_CURSOR *pcursor) ; + + +A now defunct function to support older applications which leave pcursor->flags undefined (before +version 3.5 of the window server, pcursor->flags was a filler for word alignment). + + +This function is the same as wrextCursor except that it ignores pcursor->flags and consequently does +not support w_CURSOR_OBLOID, W_CURSOR_NO_FLASH OF W_CURSOR_GREY. + + +New applications should use wrextcursor. + + +wEraseTextCursor Erase a text cursor +VOID wEraseTextCursor (VOID); +Remove the caller's text cursor. + + +In programming terms, calling this function when there is no cursor is harmless. However, be aware that +careless use of this function can cause problems. + + +3-13 + + +WINDOW SERVER REFERENCE + + +Only one cursor is ever visible on the screen at any one time and wEraseTextCursor erases the text cursor +regardless of the window in which it appears. An application, therefore, must ensure that a text cursor is +erased at the appropriate time. + + +An inappropriately timed call to weraseText Cursor can "steal" the cursor from the currently emphasised +window. + + +EEE +Bitmap sequences + + +The window server has the ability to attach an animated sequence of bitmaps to a window. This sequence +specifies the bitmap, position, bitmap source rectangle, blit mode and time to wait before advancing the +sequence. The sequence is set up by the wSetWinBitmap call, modified by the wchangewWinBitmap call and +freed with wrree. + + +A bitmap is displayed as part of the window background, and a client can draw on top of the bitmap. +Because of this the client will normally be sent a wM_REDRAW event telling it to redraw the window +containing the bitmap every time the sequence advances. If you do not require to draw on top of the +bitmap you should set the w_wIn_No_REDRaw flag for the window so that your application is not slowed +down by unnecessary WM_REDRAW events. + + +wSetWinBitmap Attach bitmap sequence to window +INT wSetWinBitmap(UINT wid, UINT count, .i.WS_WIN_BITMAP *pdata) ; + + +Attach a sequence of one to twelve bitmaps to window wid where pdata is the address of an array of count +bitmap sequence records. + + +The structure of a bitmap sequence record is described by the ws_wIn_BiTmap struct which is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +typedef struct +{ +WORD bitmap; /* Bitmap ID */ +P_POINT pos; /* position of bitmap */ +P_RECT rect; /* Source rectangle in bitmap */ +UWORD mode; /* Blit mode */ +ULONG time; /* Time till next bitmap in sequence */ +} WS_WIN_BITMAP; + + +where: + +bitmap is the bitmap ID. If any of the bitmaps in the sequence is freed before the +bitmap sequence is freed, the window server will panic the calling client when +it tries to display the freed bitmap. + +pos is the target position in the window wid of the top left of the bitmap + +rect is the rectangle within the bitmap to copy from + +mode is the graphics mode to use when copying the bitmap (one of G_TRMODE_REPL, +G_TRMODE_SET Of G_TRMODE_CLR Or G_TRMODE_INV). In version 4 of the window +server, a member of a bitmap sequence can be made to appear grey. This is +achieved by OR'ing the flag ws_wIN_BITMAP_GREY into this member. + +time is the interval in tenths of a second after which the window server advances to + + +the next bitmap (in a circular fashion). If this time is too short, the window +server will hog the processor animating the bitmaps and the performance of the +rest of the machine will be degraded. + + +Returns the ID of the bitmap sequence. + + +3-14 + + +3 WINDOWS + + +wChangeWinBitmap Change a bitmap +VOID wChangeWinBitmap(UINT bsid, UINT index, .i.WS_WIN_BITMAP *pdata) ; +Replace bitmap sequence record index in the bitmap sequence with ID bsia with the contents of pdata. + + +The whole of pdata must be set up even if only one of the elements of the structure is being changed. + + +wFree Free a bitmap sequence +VOID wFree(UINT bsid); +Free bitmap sequence bsid. + + +A bitmap sequence is automatically freed if the window it is attached to is destroyed. + + +Sprites +In version 4 of the window server, an animated sequence of bitmaps known as a 'sprite' can be created. + + +While a sprite is 'connected' to a particular window, it differs from an animated bitmap sequence in that it +is not displayed as part of the window background. The window server takes care of saving and restoring +the contents of the underlying window display. This can give the impression of the sprite 'floating' above +the underlying display. + + +Each application (or client, in general) can have only one sprite at a time and each sprite consists of a +sequence of up to thirteen bitmap sets. Each bitmap set consists of up to six bitmaps, three for the normal +plane and three for the grey plane. + + +wCreateSprite Create a sprite + + +INT wCreateSprite (INT wid,P_POINT *pos,INT flags,INT count,.i.W_SPRITE *psprite); + + +Available in version 4 of the window server, this function creates a sprite connected to the window with +ID wia based at the position specified by the p_pornt struct pointed to by pos. + + +The value of f1ags controls clipping of the sprite. If it contains the flag w_spRITE_CLIP_CHILDREN, the +sprite will be clipped by any child windows of the window to which the sprite is connected. If this flag is +not set, the sprite can only be clipped by other windows or by the limits of its own window. + + +The use of the w_spRITE_CLIP_CHILDREN flag needs some care. If this flag is set, the sprite should not be +connected to the root window. The application's top level window is always a child window of the root +which would clip or overlay a sprite. + + +Menus and dialog boxes are not child windows of any of the application's windows; therefore a sprite will +always be clipped by menus and dialog boxes regardless of the setting of w_sPpRITE_CLIP_CHILDREN. + + +The count parameter specifies how many bitmap sets the sprite has. + + +The psprite parameter points to an array of w_spRITE structures, one for each bitmap set. Note, therefore, +that there are count elements in the array. + + +The structure of w_spRrteE is defined as follows: + + +typedef struct +{ + + +WORD bit_set; /* (normal plane) bitmap for pixels to be set 1 A +WORD bit_clr; /* (normal plane) bitmap for pixels to be cleared */ +WORD bit_inv; /* (normal plane) bitmap for pixels to be inverted*/ +WORD bit_gr_set; /*(grey plane) bitmap for pixels to be set ay: +WORD bit_gr_clr; /* (grey plane) bitmap for pixels to be set */ +WORD bit_gr_inv; /* (grey plane) bitmap for pixels to be set */ + + +P_POINT offset; +UWORD time; +} W_SPRITE; + + +3-15 + + +WINDOW SERVER REFERENCE + + +The time parameter indicates the length of time in units of 1/10th of a second that the bitmap set is to be +displayed. However, this field is ignored if the sprite consists of only one bitmap set (i.e. count is set to +one). + + +The members bit_set, bit_clr, and bit_inv contain the bitmap ids to be displayed in the normal plane +using the modes G_TRMODE_SET, G_TRMODE_CLR and G_TRMODE_INV respectively (see the section on +Graphics contexts in the chapter Graphics Output). + + +Similarly, bit_gr_set, bit_gr_clr and bit_gr_inv contain the bitmap ids to be displayed in the grey +plane. + + +Note that setting a bitmap field to zero means that no bitmap will be used for the relevant plane and mode. + + +The bitmap fields can be set in any combination as appropriate. Setting all of them to zero results in the +sprite being left blank for the specified time. + + +The offset parameter indicates the (x,y) offset of the top left-hand position of the bitmaps relative to the +specified sprite position. + + +All bitmaps within a bitmap set must be the same size or else E_GEN_aRG will be returned. +If successful, the function returns the sprite id. + + +If the application (or client, in general) already has a sprite, the function panics with panic +W_PANIC_SPRITE_EXISTS. + + +wSetSprite Change a sprite's bitmaps and position + + +INT wSetSprite(INT id,P_POINT *pos, INT index,.i.W_SPRITE *psprite) ; + + +Available in version 4 of the window server, this function allows the position and individual bitmap sets +of an existing sprite to be changed. + + +The parameter id must be a valid sprite handle as returned from a call to wcreateSprite, otherwise the +function panics with a W_PANIC_SPRITE. + + +If the parameter pos is not NULL, it is assumed to point to a P_POINT structure specifying the new position +for the sprite. If the parameter is NULL, it is ignored and the sprite's position will be left unchanged. + + +If the parameter psprite is not NULL, it is assumed to point to a W_SPRITE type structure specifying a new +bitmap set. The index parameter indicates which of the original bitmap sets is to be replaced; a zero value +refers to the first. If the psprite parameter is NULL, then both it and the index parameters are ignored and +the sequence of the bitmap sets will be left unchanged. + + +If the sprite is being enlarged, then this call can fail with an E_GEN_MEMory. Changing the position of the +sprite cannot fail. + + +wFree Free a sprite +VOID wFree(UINT id); + + +This function frees the sprite identified by the parameter ia. + + +Clocks + + +On the Series 3, the Series 3a and an HC that is running version 3.5 and upwards of the window server, +the window server can maintain a date and time clock in a window. + + +The various clock displays are influenced by the date and time related members of the E_conrie struct +(see the description of p_getctd in the Time, Timers and Dates chapter of the PLIB Reference manual). +On the S3 and S3a, the E_conFic struct is used to store system-wide user preferences. + + +On the S3, the textual components of the clock displays use the $3 system font. + + +On the HC, the font used for clock displays is determined by the sws_ir ("Internal Font") environment +variable (as with all output that is not directed at a graphics context). The "factory" setting of this +environment variable selects the same font as is used on the S3. + + +3-16 + + +3 WINDOWS + + +On the S3a, the clock displays depend on the function used to draw the clock. The description and +discussion of the function wscreateClock (see below) applies equally to the S3 and the S3a. However, +wsCreateClock was designed for the S3 with its 240 x 80 pixel screen. On the S3a with its 480 x 160 +pixel screen, a clock drawn using wsCreateClock will 'work' but will appear clumsy and ungainly. + + +The enhanced version 4 function wscreateClock2 1s to be preferred for applications running on the S3a. + + +wsCreateClock Create a clock + + +INT wsCreateClock(UINT wid, UINT flags, INT xpos, INT ypos, INT offset); + + +In version 4 of the window server, this function is superseded by wscreateClock2 which includes ALL of +its functionality. wscreateClock should only be used if running earlier versions of the window server. + + +Create and maintain a clock at pixel position (xpos,ypos) in window wid. The clock displays the system +time offset by offset minutes. + + +In all cases, (xpos,ypos) specifies the internal position of the top left corner of a rectangle containing the +time display. + + +The appearance of the clock is controlled by the f1ags parameter which should be one of: + + +WS_CLOCK_SMALL_DIGITAL To present a small digital clock. Displayed in the system font on the S3. +Displayed in the S3 system font on the S3a (in native and compatibility +mode). Displayed in the ‘internal’ font on the HC (as used by wInfomsg and +wSetBusyMsg). The coordinates (xpos,ypos) specify the top left corner of +the rectangle containing the first character of the time display. + + +WS_CLOCK_MEDIUM To display a medium sized clock in either digital (using double height +characters) or analogue (using a 36x32 bitmap) form. Unless overridden by +the flags described below, the selection between analogue and digital is +controlled by the clockType member of the z_conFie struct (which should +contain either E_ANALOGUE_CLOCK Of E_DIGITAL_CLOCK). Whether digital or +analogue, the coordinates (xpos,ypos) specify the top left corner of a 36 +pixel wide by 32 pixel high rectangle containing the time display. + + +WS_CLOCK_LARGE_ANALOG To display a large analogue clock using a 66x60 bitmap. The coordinates +(xpos,ypos) specify the top left corner of the 66 pixel wide by 60 pixel high +clock bitmap. + + +The above values may be qualified by oring in combinations of the following flags: + + +WS_CLOCK_WITH_DATE To also display the date. With ws_cLocK_SMALL_DIGITAL, the date is +displayed to the left of the time. With ws_cLock_mEep1um, the date is +displayed under the time. Not available with ws_cLocK_LARGE_ANALOG. + + +WS_CLOCK_WITH_SECONDS To also display seconds. With ws_cLock_sMALL_DIGITAL, the seconds field +is added to the end of the display. With ws_cLock_LARGE_ANALOG, a second +hand is added. Not available with ws_cLock_mMEDIUM. + + +WS_CLOCK_FORCE_ANALOG Valid only with ws_cLock_mep1vm to display an analogue clock regardless +of the value of the clockType member of the z_conrie struct. + + +WS_CLOCK_FORCE_DIGITAL Valid only with ws_cLock_mep1vm to display a digital clock regardless of +the value of the clockType member of the =_conrFie struct. + + +WS_CLOCK_AM_PM To also display an am/pm indicator when the timeType member of the +E_CONFIG Struct is E_TIMEz_12 (although the relative positions may still be +altered when timeType iS E_TIME_24). With ws_cLOCK_SMALL_DIGITAL, the +am/pm indicator is displayed at the end of the time string. With a +WS_CLOCK_MEDIuM analogue clock, the am/pm indicator is displayed to the +right of the base of the clock face. With a ws_cLock_mep1Ivm digital clock, +the time digits are moved up and the am/pm indicator is displayed between +the time digits and the position of the date. Ignored if +WS_CLOCK_LARGE_ANALOG is set. + + +WS_CLOCK_CENTERED Only applies to ws_cLocK_SMALL_DIGITAL with ws_cLOcK_AM_pPM set. +Causes the time string to be centred in the wider space that allows for the +am/pm indicator when the timeType member of the E_conr1e struct is +E_TIME_24. + + +3-17 + + +WINDOW SERVER REFERENCE + + +If successful, the function returns the ID to use when calling wsSetClock and wrree. Otherwise, the +function can leave or return &_GEN_NOMEMORY. + + +The following sample program: + + +#include +#include + + +LOCAL_D WSERV_SPEC wSpec; +LOCAL_D UINT wid; + + +LOCAL_C VOID MainEventLoop (VOID) + + +WS_EV event; + + +for (77) + +{ + +wGetEventWait (&event) ; + +if (event .type==WM_REDRAW) +{ +wBeginRedrawWinGCO (wid) ; +gBorder (W_BORD_SHADOW. D|w BORD_SHADOW_ON) ; +wEndRedraw (); +} + + +} + + +GLDEF_C VOID main(VOID) +{ +wConnect (&wSpec, 0,W_CONNECT_PRIORITY) ; +wid=wCreateWindow(0,0,0,1); +wsCreateClock (wid, WS_CLOCK_LARGE_ANALOG|WS_CLOCK_WITH_SECONDS, 4, 4,0); + + +wsCreateClock (wid, WS_CLOCK_MEDIUM|WS_CLOCK_FORCE_DIGITAL|WS_CLOCK_WITH_DATE, 4+66+6, 4,0 +i + + +wsCreateClock (wid, WS_CLOCK_MEDIUM|WS_CLOCK_FORCE_ANALOG | WS_CLOCK_WITH_DATE, 4+66+6+36+6 +14,0); + + +wsCreateClock (wid, WS_CLOCK_SMALL_DIGITAL|Wws CLOCK_WITH DATE |WS CLOCK_WITH_SECONDS, 104, +66,0); + +wiInitialiseWindowTree (wid) ; + +MainEvent Loop () ; + + +} + + +when run on an HC, produces: + + +1438 L-: + + +fon 24 Mon 28 + + +Morn 28 Jan 14835812 + + +Note that the seconds field of the small digital clock is badly drawn because it changed from 11 to 12 +while the screen was being captured. + + +The screen was in fact captured using the scapt program described in the Bitmaps section of the first +chapter. It is left as an exercise for the reader to convert pcxsave.c (which is used by scapt) to take true +snapshots of a changing screen?. + + +3One strategy is to save the screen as a bitmap to a temporary local file using gsaveBit and then to +convert the file. + + +3-18 + + +3 WINDOWS + + +wsCreateClock2 Create a clock - Enhanced version + + +INT wsCreateClock2(.i.WS_CREATE_CLOCK *pclock,TEXT *pfmt) ; + + +This function is introduced in version 4 of the window server and is an enhanced version of the +wsCreateClock function. It is much preferred and should be used for applications designed to run on the +Series 3a. + + +Note that this function includes the functionality of wscreateClock. + + +The clock it creates is based on the values in the ws_cREATE_CLOcK structure pointed to by the parameter +pclock and the value in the second parameter pfmt. + + +The structure ws_CREATE_cLocK can be found in wilib.h but is defined as follows: + + +typedef struct +{ +UINT id; /* window ID */ +UINT type; /* clock type */ +P_POINT pos; /* position ey: +INT offset; /*time offset */ +INT flags; /*clock flags */ +INT font; +INT style; +} WS_CREATE_CLOCK; + + +The function creates a clock in window id at position pos of the specified type. The clock displays the +system time offset by the number of minutes specified in the of fset member. + + +The possible values for type and flags include those values which can be specified in the flags +parameter in the old wscreateClock function. However, in wsCreateClock2, some values apply to type +while the others apply to flags. + + +The second parameter pfmt and the ws_cREATE_CLOCK members font and style are only relevant when +the type of clock being created is ws_cLocK_FORMATTED. For all other types of clock pfmt must be set to +NULL. + + +To summarise, type should be one of the following: + + +WS_CLOCK_SMALL_DIGITAL To present a small digital clock. This clock has the appearance as described +in wsCreateClock and is designed for the Series 3 screen. On the Series 3a +in non-compatibility mode it will appear small and is not recommended. + + +WS_CLOCK_MEDIUM To present a medium sized clock. This clock has the appearance as +described in wsCreateClock and is designed for the Series 3 screen. On the +Series 3a in non-compatibility mode it will appear small and is not +recommended. + + +WS_CLOCK_MEDIUM2 To display a medium sized clock that is larger than the old medium sized +clock. It behaves in a similar way to the old medium clock in that, unless +overridden by the flags described below, the selection between analogue and +digital is controlled by the clockType member of the E_conFIe struct. + + +This clock is drawn using black/white and grey. The analog clock uses a +58x51 bitmap. + + +WS_CLOCK_LARGE_ANALOG To display a large analog clock. This clock has the appearance as described +in wsCreateClock and is designed for the Series 3 screen. On the Series 3a +in non-compatibility mode it will appear small and is not recommended. + + +WS_CLOCK_XL_ANALOG To display an extra-large analog clock as used in alerts. +This clock is drawn using black/white and grey. It uses a 99x99 bitmap. + + +WS_CLOCK_FORMATTED To display a formatted digital clock/date. The display is controlled by the +format string whose address is passed in the second parameter pfmt. The +meaning of the format string is the same as for the PLIB function p_dt2str. +See the PLIB manual for more detail on the syntax and meaning of this +string. The font and style are specified by the font and style parameters in +the ws_CREATE_CLOCK Structure. + + +The clock types described above can be modified by setting combinations of the following flags in the +flags member of the ws_cREATE_CLOcK Structure: + + +3-19 + + +WINDOW SERVER REFERENCE + + +WS_CLOCK_WITH_DATE + + +WS_CLOCK_WITH_SECONDS + + +WS_CLOCK_FORCE_ANALOG + + +WS_CLOCK_FORCE_DIGITAL + + +WS_CLOCK_AM_PM + + +WS_CLOCK_CENTERED + + +WS_CLOCK_BOX + + +WS_CLOCK_GREY + + +To also display the date. With ws_cLockK_SMALL_DIGITAL, the date is +displayed to the left of the time. With ws_cLock_mMED1um and +WS_CLOCK_MEDIUM2, the date is displayed under the time. Not available with +WS_CLOCK_LARGE_ANALOG Or WS_CLOCK_XL_ANALOG. Not applicable to +WS_CLOCK_FORMATTED. + + +To also display seconds. With ws_cLocK_SMALL_DIGITAL, the seconds field +is added to the end of the display. With ws_cLockK_LARGE_ANALOG, +WS_CLOCK_XL_ANALOG and the analog version of WS_CLOCK_MEDIUM2, a +second hand is added. Not available with ws_cLocK_Mep1Iv™ or the digital +version of WS_CLOCK_MEDIuM2. Not applicable to ws_cLOcK_FORMATTED. + + +Valid only with ws_cLock_MEDIUM and WS_CLOCK_MEDIUM2 to display an +analogue clock regardless of the value of the clockType member of the +E_CONFIG struct. Not applicable to ws_cLOCK_FORMATTED. + + +Valid only with ws_cLock_MEDIUM and WS_CLOCK_MEDIUMz2 to display a +digital clock regardless of the value of the clockType member of the +E_CONFIG struct. Not applicable to ws_cLOCK_FORMATTED. + + +Valid as for wsCreateClock. In addition, this is not available for +WS_CLOCK_MEDIUM2 and is not applicable to ws_cLOCK_FORMATTED. + + +Only applies to ws_cLOCK_SMALL_DIGITAL with ws_CLOCK_aAM_PM set. Causes +the time string to be centred in the wider space that allows for the am/pm +indicator when the timeType member of the E_CONFIG struct is E_TIME_24. +Not applicable to ws_cLOCK_FORMATTED. + + +Only applies to ws_cLocK_FORMATTED. Causes graphics to be drawn +enclosing the formatted clock as shown in one of the examples. + + +If set, it causes those clocks which are normally drawn in black & white +only, to be drawn in grey. + + +It has no effect on those clocks which are drawn in both black/white and +grey. + + +If successful, the function returns the ID to use when calling other 'clock' functions such as wsSet Clock + + +and wFree. + + +For example, when run on the S3a, the code: + + +#include +#include + + +GLREF_D WSERV_SPEC wSpec; +GLREF_D UINT wMainWid; + + +LOCAL_C VOID MainEventLoop (VOID) + + +{ +WS_EVENT event; + + +for (77) + + +{ + + +wGetEventWait (&event) ; +if (event .type==WM_KEY) + + +{ + + +if (event.p.key.keycode==W_KEY_RETURN) + + +break; + + +3-20 + + +3 WINDOWS + + +GLDEF_C INT main (void) +{ +WS_CREATE_CLOCK clock; + + +wConnect (&wSpec, 0,W_CONNECT_PRIORITY) ; +wCompatibilityMode (0, &wSpec) ; +wMainWid = wCreateWindow(0,0,0,1); + + +winitialiseWindowTree (wMainWid) ; +clock.id = wMainWid; + +clock.type = WS_CLOCK_XL_ANALOG; +clock.pos.x = 200; + +clock.pos.y = 40; + +clock.offset = 0; + +clock.flags = WS_CLOCK_WITH_SECONDS; + + +wsCreateClock2 (&clock, NULL) ; +MainEventLoop() ; +return (0); + + +} + + +displays the extra large analog clock with +a seconds hand as shown opposite. + + +An example of a formatted clock is given next. The digital clock/date is displayed in bold, with double +height and surrounded by a neat box. The code used to display the clock is as follows: + + +#include +#include +#include + + +GLREF_D WSERV_SPEC wSpec; +GLREF_D UINT wMainWid; + + +LOCAL_C VOID MainEventLoop (VOID) +{ +WS_EVENT event; + + +for (77) +{ +wGetEventWait (&event) ; +if (event .type==WM_KEY) +{ +if (event.p.key.keycode==W_KEY_RETURN) +break; + + +GLDEF_C INT main (void) +{ +WS_CREATE_CLOCK clock; + + +wConnect (&wSpec, 0,W_CONNECT_PRIORITY) ; +wCompatibilityMode (0, &wSpec) ; + +wMainWid = wCreateWindow(0,0,0,1); +wiInitialiseWindowTree (wMainWid) ; + + +3-21 + + +WINDOW SERVER REFERENCE + + +clock.id = wMainWid; + +clock.type = WS_CLOCK_FORMATTED; + +clock.pos.x = 150; + +clock.pos.y = 70; + +clock.offset = 0; + +clock.flags = WS_CLOCK_BOX; + +clock.font = FONT_ID_SWISS_8; + +clock.style = G_STY_DOUBLE|G_STY_BOLD; +wsCreateClock2 (&éclock, "Sh%:%m%:%s Se %da%/Sm%s/Sy") ; + + +MainEvent Loop (); +return(0); + + +} + + +Take particular note of the text string +forming the second parameter to 1 — +wsCreateClock2. The format and structure | 17a Wednesday 18/88/1993 +of this text string governs the display of +this clock. + + +wsSetClock Set the clock offset + + +VOID wsSetClock (INT clock_id, INT offset); + + +Change the time offset (in minutes from the system time) of clock clock_id (where clock_id was +returned from a call to wscreateClock). + + +wFree Free a clock +VOID wFree(INT clock_id); +Free the clock clock_id (where clock_id was returned from a call to wscreateClock). + + +A clock is automatically freed if the window it contains is closed as a result of a call to +wCloseWindowTree. If a clock is freed by wcloseWindowTree, it must not be freed a second time by a call +to wFree. + + +Mouse icons + + +On the large screen version of the window server (such as that on the MC), each window has an +associated mouse icon - as specified by the mouse icon ID in the mouse_icon window attribute. The +mouse_icon window attribute is set when you create the window by calling wcreateWindow and it may +subsequently be changed by calling wset Window + + +Mouse icons can be selected from one of three categories: + + +e The two built-in icons, the default icon w_WwIN_MI_STANDARD and the invisible mouse icon +W_WIN_MI_NULL. + + +¢ ROM-based icons which are automatically loaded by the window server when it boots up. + + +e External mouse icons which are loaded from a file by calling gopenMouseIcon (which returns the +mouse icon ID). + + +On MC machines, the following mouse icons are built into the ROM: +W_WIN_MI_STANDARD standard mouse icon. + +W_WIN_MI_NULL invisible mouse icon. + +W_WIN_MI_PUSHER hollow standard mouse icon. +W_WIN_MI_TEXT text window mouse icon. + +W_WIN_MI_CROSS cross. + + +3-22 + + +W_WIN_MI_MARGIN text window margin icon. +W_WIN_MI_PG_DOWN page down scroll bar icon. +W_WIN_MI_PG_UP page up scroll bar icon. +W_WIN_MI_VSLIDE scroll bar vertical slider icon. +W_WIN_MI_HSLIDE scroll bar horizontal slider icon. +W_WIN_MI_TO_BIG resize gadget expand window icon. +W_WIN_MI_TO_SMALL resize gadget shrink window icon. +W_WIN_MI_RESIZE resize gadget move-resize icon. +W_WIN_MI_MOVE move window icon. + +W_WIN_MI_LEFT horizontal scroll bar move left icon. +W_WIN_MI_RIGHT horizontal scroll bar move right icon. +gOpenMouselcon + + +INT gOpenMouselIcon(TEXT *filename, UINT index) ; + + +Load mouse icon index from file filename. + + +3 WINDOWS + + +Load a mouse icon + + +Returns the positive ID of the mouse icon to use in the w_winpata structure when calling wsetwindow or + + +wCreateWindow. + + +If an error with error number err occurs while loading the mouse icon, the function calls p_leave (err) or + + +returns err, depending on whether wDisableLeaves has been called. + + +If filename is not a full file specification, the unspecified components are taken from the window server's + + +default path which, in practice, is always the internal drive M:\. + + +See also gSetOpenAddress in the next chapter for loading a mouse icon file which is embedded in another + + +file. + + +wFree + + +VOID wFree(UINT mouse_icon_id) ; + + +Free a mouse icon. + + +Any windows using the freed icon revert to using the default icon. + + +Free a mouse icon + + +3-23 + + +CHAPTER 4 + + +GRAPHICS OUTPUT + + +Graphics contexts + + +You must create a graphics context before performing any graphics output (apart from the screen and +window directed graphics described in the previous two chapters). + + +The use of a graphics context reduces the number of parameters required when calling graphics functions. +A graphics context contains the following: +e the ID of a drawable (a window or a bitmap) that is the ultimate recipient of the graphics output + + +e whether to set, clear or invert pixels when drawing lines using gDrawLine, gDrawPolyLine, +gDrawBox, gBorderRect, gBorder, gBorder2Rect Of gBorder2 + + +e the font, style and transfer mode to use when drawing text using gPrintText, gPrintClipText, +gXPrintText, gPrintBoxText OF gShadowText. + + +The drawable is set once and for all when the graphics context is created (using gcreateGc or a variant +thereof). The rest of the content can be set up when the graphics context is created and it can also be +altered subsequently (using gSetcc). + + +A graphics context is set with the aid of a c_cc struct, which is defined in wlib.h as: + + +typedef struct +{ + + +UBYTE gmode; /* mode for line drawing */ + +UBYTE textmode; /* mode for writing text */ + +UBYTE style; /* style of text: bold, underline etc. */ +UBYTE flags; /* controls use of grey & double pixel mode */ +WORD font; /* ID of font to use */ + +} G_GC; + + +Note that the flags member is introduced in version 4 of the window server. Prior to version 4, the space +occupied by this member was unused. + + +Introduced in version 4, grey is available (in one shade only) on the S3a and Workabout. At a software +level this is implemented by introducing the concept of a plane. + + +There are two planes to which drawing can be directed. The normal plane can be thought of as being +associated with the drawing of black while the grey plane, as its name implies, is associated with the +display of grey. + + +Drawing is normally done to one or both planes. However, they are not entirely independent; for example, +to display grey, the normal plane should be clear and the grey plane set. If a pixel in the normal plane is +set, it is displayed black regardless of the grey plane setting. This is best thought of as the normal plane +‘overlaying’ the grey plane. + + +Also introduced in version 4, all graphic commands can be set to perform all drawing with double sized +pixels. This feature is motivated by the need to run Series 3 applications on the Series 3a; in other words, +to use the S3a in S3 compatibility mode. + + +4-1 + + +WINDOW SERVER REFERENCE + + +gmode + + +The gmode field is used by the line drawing functions gDrawLine, gDrawPolyLine, gDrawBox, +gBorderRect, gBorder2Rect, gBorder, gBorder2, wDOrawButton and wDrawButton2 and may be one of: + + +G_TRMODE_SET set pixels in the line. This is the default. +G_TRMODE_CLR clear pixels in the line. + +G_TRMODE_INV invert pixels in the line. + +textmode + + +The textmode field controls the method of writing text in gPrintText and gPrintClipText and may be +any of: + + +G_TRMODE_SET where Is in the font set bits in the destination and Os do not change bits in the +destination (used to print on to a previously cleared area). This is the default. + + +G_TRMODE_REPL where Is and Os in the font overwrite the destination (used to print over +unprepared areas). + + +G_TRMODE_CLR where Is in the font clear bits in the destination and Os do not change bits in +the destination (used to print on to a previously set area). + + +G_TRMODE_INV where Is in the font toggle corresponding bits in the destination and Os in the +source pattern do not change bits in the destination (used to print over an +existing image and may be reversed by a second application). + + +style + + +The style field controls the style of text in gPrintText, gPrintClipText, gXPrintText, gPrintBoxText, +gShadowText, wDrawButton and wDrawButton2. The precise mechanism of applying a style depends on +the version of the window server. Prior to version 4, styles may be any combination of: + + +G_STY_NORMAL text is drawn as it is in the font. This is the default. + + +G_STY_BOLD text is drawn bolded (generally bolded characters are one pixel wider than +normal characters). + + +G_STY_UNDERLINE text is drawn underlined where each character (including space) is drawn with +a horizontal line beneath its graphic. + + +G_STY_INVERSE text is drawn in inverse video (where the bits in the font are inverted before +drawing). +G_STY_DOUBLE text is drawn with double height characters where each row of pixels in the + + +character graphic is doubled up before drawing. + + +G_STY_MONO text is drawn with additional space around the characters of a proportional font +to turn it into a monospaced font. For this to be effective, the proportional font +should be designed with monospacing in mind (as is the built in font on the + + +Series 3). + +G_STY_ITALIC text is drawn italicised by shifting the top half of each character across by one +pixel. + +G_STY_SUPERSCRIPT indicates an intention to draw in superscript, not processed by the window +server. + +G_STY_SUBSCRIPT indicates an intention to draw in subscript, not processed by the window server. + + +Fast text printing of a fast font only works with normal style or with just c_sty_mono. The use of any other +style will cause text drawing to fall back to the slower algorithm. + + +In version 4 of the window server and upwards, the above styles still apply. However, in version 4, font +groups are available as discussed in the section on ROM-based fonts in the Introduction chapter of this +manual and in the description of gconfigureFonts later in this chapter. + + +If the font to which the above styles (except G_sTY_SUPERSCRIPT and G_STY_SUBSCRIPT) are applied is a +font group, then the window server will select the most appropriate font from within that group. + + +4-2 + + +4 GRAPHICS OUTPUT + + +Depending on how the font group is configured and the combination of styles to be applied, some further +algorithmic styling, as described above, may be necessary. + + +In version 4 of the window server and upwards, the following two styles are also available: + + +G_STY_SUPERSCRIPT2 text is drawn in superscript. This style only has meaning when used in +conjunction with a font group configured with a suitable superscript font. + + +If this style is used with a single font (ie not a font group), then the style is +ignored. + + +G_STY_SUBSCRIPT2 text is drawn in subscript. This style only has meaning when used in +conjunction with a font group configured with a suitable subscript font. + + +If this style is used with a single font (ie not a font group), then the style is +ignored. + + +Note that when configuring a font group to include fonts for the c_sty_suPERSCRIPT2 and +G_STY_SUBSCRIPT2 Styles, the AscentAdjust field in the c_ront_conrie data structure can be used to +adjust the font's ascent when printing (see the gconfigureFonts function later in this chapter). + + +The bits c_sty_SUPERSCRIPT and G_sTy_SUBSCRIPT are reserved for higher level software. For example: + + +LOCAL_C VOID DrawTextBox(INT fid, INT style,TEXT *str,P_RECT *prect,INT ascent) +{ +G_GC gc; + + +gc.font=fid; +gc.style=style; +gSetGC (0, G_GC_MASK. FONT |G GC_MASK_STYLE, &gc) ; +if (style&G_STY_SUPERSCRIPT) +ascent-—=1; +if (style&G_STY_SUBSCRIPT) +ascentt=1; +gPrintBoxText (prect, ascent, G_TEXT_ALIGN_LEFT,0,str,p_slen(str)); +} + + +flags + + +Introduced in version 4 of the window server, the flags member is used to indicate the plane to which +drawing is to be directed. It is also used to indicate whether drawing should be done in double or single +pixel mode. Possible values are: + + +G_GC_FLAG_GREY_PLANE graphics drawing is directed to the grey plane only +G_GC_FLAG_BOTH_PLANES — graphics drawing is directed to both the grey plane and the normal plane + + +G_GC_FLAG_DOUBLE if set, all drawing is done in double pixel mode. Unsetting this puts the GC +back into single pixel mode; this can be used to reverse a previous call to set +double pixel mode or in windows that are in this mode by default either +because the application is in compatibility mode or the window has the +W_WIN_DOUBLE_PIxEL flag set. + + +Note that this flag should not be set if drawing is done to a backed-up +window. If the window needs to be restored from the backup, then the +drawing will be displayed in single pixel mode. In this situation, it is best to +set the whole window into double pixel mode. + + +font + + +The font field contains the ID of the font to be used in gPrint Text, gPrintClipText, gXPrintText, +gPrintBoxText, gShadowText, wDrawButton and wDrawButton2. + + +The font ID may be that of a ROM-based font or an ID of a font that was loaded from a file by calling +gOpenFont. + + +The ROM-based font IDs start at ws_ronT_BaAsE and you can use wS_FONT_BASE+1 etc for as many fonts as +are built into the ROM. + + +By default, a graphics context is initialised with the ID of the system font (as described in the section Text +fonts in the first chapter). You can reset a graphics context back to the system font by specifying +WS_FONT_SYSTEM. + + +4-3 + + +WINDOW SERVER REFERENCE + + +a —Ss +Creating a permanent graphics context + + +gCreateGC Create a permanent GC +INT gCreateGC(UINT drawable_id, UINT field_set, G_GC *pgc); + + +Create a permanent graphics context that is assigned to the drawable drawable_id (the ID of a previously +created window or bitmap) and select the created graphics context as current. + + +The c_cc struct is defined as: + + +typedef struct +{ + + +UBYTE gmode; /* G_TRMODE_SET, _CLR, _INV (line) */ + +UBYTE textmode; /* G_TRMODE_SET, _CLR, _INV, _REPL (text) */ + +UBYTE style; /* G_STY_NORMAL, _BOLD, _UNDERLINE, _INVERSE, _DOUBLE, _MONO, +_ITALIC */ + +UBYTE flags; /* G_GC_FLAG_DOUBLE, _GREY_PLANE, _BOTH_PLANES */ + +WORD font; /* ID of font to use */ + +} G_GC; + + +Note that the flags member is introduced in version 4 of the window server. Prior to version 4, the space +occupied by this member was unused. + + +If field_set is Zero, pgc is ignored and the graphics context is created with default values (but, in this +case, you should use gcreateGCco). + + +If field_set is non-zero it should contain a bit mask to specify which fields in pgc are used to set the +graphics context, as follows: + + +G_GC_MASK_GMODE to use pgc->gmode + +G_GC_MASK_TEXTMODE to use pgc->textmode + +G_GC_MASK_STYLE to use pgc->style + +G_GC_MASK_FONT to use pgc->font + +G_GC_MASK_GREY to use pgc->flags (looks at G_GC_FLAG_GREY_PLANE and + + +G_GC_FLAG_BOTH_PLANES only) (version 4 only) +G_GC_MASK_DOUBLE to use pge->flags (looks at G_GC_FLAG_DOUBLE only) (version 4 only) +Returns the ID of the graphics context if successful. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns err, depending on +whether wDisableLeaves has been called. Possible values for err are: + + +E_GEN_NOMEMORY insufficient system memory +E_GEN_ARG an invalid gmode, textmode, style or font was specified +E_GEN_FAIL none of the grey background modes had been previously set for the window and + + +an attempt was made to set G_GC_FLAG_GREY_PLANE. This error can only be +returned in version 4 of the window server. + + +In version 2 of the window server, the function calls p_panic if an invalid gmode, textmode, style or font +is specified. + + +In version 4 of the window server, setting the c_cc_MasK_GcREyY bit in field_set causes the window server +to look at the two grey flags in the flags member; setting the G_cc_MASK_DOUBLE bit in field_set causes +the window server to look at the double pixel flag in the flags member. + + +Setting G_GC_FLAG_GREY_PLANE directs graphics to the grey plane only, while setting +G_GC_FLAG_BOTH_PLANES directs graphics to both the normal and the grey planes. + + +Setting G_GC_FLAG_DOUBLE causes all drawing to be done in double pixel mode. + + +4 GRAPHICS OUTPUT + + +gCreateGCO Create a permanent GC with default values +INT gCreateGCO(UINT drawable_id); +A code saving convenience routine, equivalent to: + + +gCreateGC (drawable_id,0,0); + + +wFree Free a permanent GC +VOID wFree(UINT gc_id); + +Free the permanent graphics context with ID gc_ia. + +To free a temporary graphics context, use gFreeTempGc not wrree (WS_TEMPORARY_GC) . + + +Because graphics contexts consume memory, they should be freed when they are no longer required. + + +Creating a temporary graphics context + + +gCreateTempGC Create a temporary GC + + +VOID gCreateTempGC (UINT drawable_id, UINT field_set, G_GC *pgc); + + +Create a temporary graphics context that is initialised with those fields from pgc which have their +corresponding bit fields set in field_set. + + +The c_cc struct is defined as: + + +typedef struct +{ + + +UBYTE gmode; /* G_TRMODE_SET, _CLR, _INV (line) */ + +UBYTE textmode; /* G_TRMODE_SET, _CLR, _INV, _REPL (text) */ + +UBYTE style; /* G_STY_NORMAL, _BOLD, _UNDERLINE, _INVERSE, _DOUBLE, _MONO, +_ITALIC */ + +UBYTE flags; /* G_GC_FLAG_DOUBLE, _GREY_PLANE, _BOTH_PLANES */ + +WORD font; /* ID of font to use */ + +} G_GC; + + +where the bit fields for field_set are: + + +G_GC_MASK_GMODE corresponding to gmode +G_GC_MASK_TEXTMODE corresponding to textmode +G_GC_MASK_STYLE corresponding to style +G_GC_MASK_GREY corresponding to flags (version 4 only) +G_GC_MASK_DOUBLE corresponding to flags (version 4 only) +G_GC_MASK_FONT corresponding to font + + +Note that the f1ags member is introduced in version 4 of the window server. Prior to version 4, the space +occupied by this member was unused. + + +The behaviour is as for gcreatecc, apart from the following: + + +@ gCreateTempcc does not return an ID. This improves efficiency, because the window server does +not have to reply to the gcreateTempGc. + + +@ gCreateTempcc remembers the currently selected permanent graphics context (if any), and +gFreeTempec reselects that same graphics context. + + +4-5 + + +WINDOW SERVER REFERENCE + + +While a temporary graphics context exists, you may not call: +e gCreateGC +e gCreateTempGC +e gSetGCo +@ gSetéc to set a graphics context other than ws_TEMPORARY_GC +e wrree (for any graphics context) + + +e wBeginRedrawGC, wBeginRedrawGC0, wBeginRedrawWinGC Or wBeginRedrawWinGCO + + +gCreateTempGCOo Create a temporary GC with default values +VOID gCreateTempGC0 (UINT drawable_id) ; +A code saving convenience routine, equivalent to: + + +gCreateTempGC (drawable_id,0,0); + + +gFreeTempGC Free a temporary GC +VOID gFreeTempGC (VOID) ; +Free the temporary graphics context created by gcreateTempGc or gCreateTempGCo. + + +If a permanent graphics context was current before the temporary graphics context was created, it is +reselected. + + +Setting a graphics context + + +gSetGC Set a graphics context + + +VOID gSetGC(UINT gc_id, UINT field_set, G_GC *pgc); + + +Select gc_id as the current graphics context and alter those fields from pge which have their +corresponding bit fields set in field_set. + + +The c_cc struct is defined as: + + +typedef struct +{ + + +UBYTE gmode; /* G_TRMODE_SET, _CLR, _INV (line) */ + +UBYTE textmode; /* G_TRMODE_SET, _CLR, _INV, _REPL (text) */ + +UBYTE style; /* G_STY_NORMAL, _BOLD, _UNDERLINE, _INVERSE, _DOUBLE, _MONO, +_ITALIC */ + +UBYTE flags; /* G_GC_FLAG_DOUBLE, _GREY_PLANE, _BOTH_PLANES */ + +WORD font; /* ID of font to use */ + +} G_GC; + + +where the bit fields for field_set are: + + +G_GC_MASK_GMODE corresponding to gmode +G_GC_MASK_TEXTMODE corresponding to textmode +G_GC_MASK_STYLE corresponding to style +G_GC_MASK_GREY corresponding to flags +G_GC_MASK_DOUBLE corresponding to flags +G_GC_MASK_FONT corresponding to font + + +Note that the flags member is introduced in version 4 of the window server. Prior to version 4, the space +occupied by this member was unused. + + +4-6 + + +4 GRAPHICS OUTPUT + + +To alter a temporary graphics context with gsetGc, pass gc_id aS WS_TEMPORARY_GC. + + +In version 3 and upwards of the window server, passing gc_ia as zero will modify the current graphics +context, be it temporary or permanent. In version 2, passing a gc_id of zero will panic the process with +panic number 85 (illegal graphics context ID). + + +gSetGCo Make a permanent GC current +VOID gSetGCO(UINT gc_id); + +Make the permanent graphics context with ID gc_ia current. + +Equivalent to: + + +gSetGC (gc_id,0,0); + + +———EE— EE —————————————— ESS — Sy +Line drawing + + +The functions in this section are all directed at the drawable associated with the current graphics context +and are subject to the gmode field of the current graphics context. + + +gDrawLine Draw a line +VOID gDrawLine(INT xl, INT yl, INT x2, INT y2); +Draw a line between pixel (x1,y1) and pixel (x2, y2). + + +When drawing a horizontal line with y1 equal to y2, the line includes the pixel with the lower x +coordinate and excludes the pixel with the higher x coordinate. + + +Similarly, when drawing a vertical line with x1 equal to x2 the line includes the pixel with the lower y +coordinate and excludes the pixel with the higher y coordinate. + + +When drawing a line in which both coordinates change, the window server turns the coordinates of the +end pixels into a rectangle with a top-left internal pixel and a bottom-right external pixel. The line +drawing algorithm then fills in those pixels that are intersected by a mathematical line between the +corners of the mathematical rectangle on the boundary of those pixels that are in the rectangle. + + +gDrawPolyLine Draw a sequence of lines +VOID gDrawPolyLine(INT x, INT y, WORD *plist); +Draw a sequence of lines as specified in the polyline piist, starting at the position (x,y). + + +A polyline is a sequence of line drawing and movement commands. The drawing is self-relative in that +each operation is relative to the end point of the last. + + +The polyline 1ist has the following structure: + + +UWORD n; /* number of word-pairs following */ +WORD xl, /* flag and x displacement */ +WORD yl; /* y displacement */ + + +/* +Bit Bo As S22 FAs OM 9 6B 6252-4 32-21 0 +$----------------------------- +--+ +| X-displacement | | Move/draw flag +$----------------------------- +--+ +| Y-displacement | +$------------------------------- + +af +WORD x2,y2; /* 2nd flag and x, y displacement */ +WORD xn,yn; /* nth flag and x, y displacement */ + + +WINDOW SERVER REFERENCE + + +Each element of the polyline list consists of an x,y displacement, and a bit flag that is set to move and +clear to draw. The move/draw flag is held in bit 0 of the x displacement word where bits 1..15 contain the +actual x displacement!. The y displacement is stored as normal. + + +In version 2 of the window server plist is limited to 61 move/draw operations. + + +For example, the following polyline draws a button consisting of two concentric squares of dimensions +50x50 and 30x30 as in the following diagram: + + +static WORD button[]= +{ + + +95, /* 9 operations follow */ +50*2, 0, /* draw right 50 */ +0*2, 50, /* draw down 50 */ +-50*2, 0, /* draw left 50 */ + + +0*2, -50, /* draw up 50 */ +(10*2) |1, 10, /* move right 10, down 10 */ + + +30*2, 0, /* draw right 30 */ +0*2, 30, /* draw down 30 */ +=30%*2; 0; /* draw left 30 */ + + +0*2, -30 /* draw up 30 */ +hi + + +gDrawPolyLine(0,0,&button[0]); + + +gDrawBox Draw a box +VOID gDrawBox(P_RECT *prect) ; + +Draw a box composed of the outermost pixels in the rectangular block of pixels specified by prect. + +The P_RECT struct is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +gBorderRect Border a rectangle + + +VOID gBorderRect (P_RECT *prect, UINT flags); +This function is not available in version 2 of the window server. + + +Draw a border inside the rectangular block of pixels specified by prect, as controlled by flags where +flags should be one of: + + +Zero to use corner type 2 +W_BORD_CORNER_1 to use corner type | +W_BORD_CORNER_4 to use corner type 4 +W_BORD_OPEN a special case used for menus on the S3 and the S3a + + +'For example, you can get the x displacement into bits 1..15 by multiplying the required x displacement +by 2 (which also clears bit zero). If you want to move rather than draw, you must then set bit zero. + + +4-8 + + +4 GRAPHICS OUTPUT + + +One of the three corner types may be qualified by oring in a combination of the following bit fields: + + +W_BORD_CUSHION to leave a one pixel clear cushion all around + +W_BORD_SHADOW_S for a single shadow area (mutually exclusive with w_porD_SHADOW_D) +W_BORD_SHADOW_D for a double shadow area (mutually exclusive with w_porD_SHADOW_S) +W_BORD_SHADOW_ON the pixels in the shadow area are set - otherwise they are cleared (meaningless + + +unless either the w_BoRD_SHADOW_S OF W_BORD_SHADOW_D flag is set) + + +W_BORD_TOP_ON to draw an arrow in the top right corner +W_BORD_TOP_OFF to clear an arrow in the top right corner +W_BORD_BOT_ON to draw an arrow in the bottom right corner +W_BORD_BOT_OFF to clear an arrow in the bottom right corner + + +The meanings of the flags are illustrated by the following diagrams: + + +W_BORD_CUSHION |W_BORD_CORNER_1 + + +W_BORD_CUSHION |W_BORD_CORNER_4 W_BORD_CUSHION|W_BORD_SHADOW_S + + +W_BORD_CUSHION |W BORD_SHADOW s|w. BORD_SHADOW_ON + + +W_BORD_CUSHION |W BORD_CORNER 4|w BORD_SHADOW s|w. BORD_SHADOW_ON + + +W_BORD_CUSHION |W BORD_CORNER 4|w. BORD_SHADOW. D|w BORD_SHADOW_ON + + +W_BORD_CUSHION |W BORD_SHADOW. D|w BORD_SHADOW_ON W_BORD_OPEN + + +W_BORD_SHADOW. D|w BORD_SHADOW_ON + + +Although some of the effects may look gross on the above diagrams, bear in mind they will typically be +used on much larger windows. + + +Some of the flag combinations presuppose a minimum size of rectangle. + + +4-9 + + +WINDOW SERVER REFERENCE + + +The w_Borp_opEN flag is a special case that overrides all the others. The top two corners are drawn as for +W_BORD_CUSHION |W_BORD_SHADOW_S |W_BORD_SHADOW_ON, but the bottom two are laws unto themselves. +Note also the non-appearance of lines along the bottom. This is used for the header of a Series 3 or +Series 3a pull-down menu. + + +Except for those combinations designed to change shadows and arrows, the borders are designed to be +drawn over a clear background. For example, those pixels at the perimeter of the rectangle that are +obtained with w_BoRD_CUSHION are not explicitly cleared. + + +The above assumes that gmode in the graphics context is set to G_TRMODE_SET (its default value). + + +Drawing shadows + + +The first line of a shadow is inset by 2 pixels at the bottom left and at the top right, and a second line (for +double shadowing) is inset a further one pixel. + + +At the bottom right, the outside line matches the inside line, just being displaced either one or two pixels +diagonally downwards and outwards. + + +The pixels that are set for w_BORD_SHADOW_ON are explicitly cleared when this flag is absent, so that the +call + + +gBorderRect (prect, W_BORD_SHADOW_S) ; +can be used to de-emphasise a window formerly emphasised using + + +gBorderRect (prect, W_BORD_SHADOW s|w. BORD_SHADOW_ON) ; + + +Arrows + + +The following shows the use of W_BORD_BoOT_oN to draw an arrow in the bottom right corner on the S3 or +the S3a: + + +Process name Alloc bytes Alloc cells Let stack +Sy SEMANGEAS +SSE SRY EAS CFe 2356 +SyYSE/SRY64 1DFa 14C + + +STSPSHLLFHS = 1518 300) +TIME.$86 BF2 430 +DATAFer BE 463 + + +Remember, that when running version 4 of the window server on the Series 3a in Series 3 compatibility +mode, the image will be drawn in double pixel mode! + + +gBorder Border a drawable +VOID gBorder(UINT flags); +Equivalent to gBorderRect where the rectangle covers the entire drawable (bitmap or window). + + +Not available in version 2 of the window server. + + +gBorder2Rect Draw a 'shadowed' border +VOID gBorder2Rect (INT type, P_RECT *prect,INT flags); + + +Introduced in version 4 of the window server, this function is similar to gBorderRect but includes the +ability to draw a 3-dimensional style border. + + +This function can be regarded as a generalisation of gBorderRect as not only can it draw the 3D style +borders but includes the functionality of gBorderRect itself. + + +It draws a border inside the rectangular block of pixels specified by the parameter prect with a style +specified by the parameter type. The flags parameter 'fine-tunes' the border display. + + +The type can be one of: +¢ W_BORDER_TYPE_0 - to draw a border in the old style as done by gBorderRect + + +¢ W_BORDER_TYPE_1 - to draw a 3-dimensional grey and black border. + + +4-10 + + +4 GRAPHICS OUTPUT + + +Note that for w_BoRDER_TYPE_1 borders, the window must be enabled for drawing grey. + + +The flags parameter can be used to fine-tune the border display. They are, to all intents and purposes, the +same as those used in the function gBorderRect with some minor changes in meaning. + + +Flags should be one of: + + +W_BORD_CORNER_2 to draw a corner type 2, the same as that drawn by gBorderRect. This is the +default corner and need not be explicitly coded. This flag applies to both border +types. + +W_BORD_CORNER_1 to draw a corner type 1, the same as that drawn by gBorderrRect. This flag +applies to both border types. + +W_BORD_CORNER_4 to draw a corner type 4, the same as that drawn by gBorderRect. This flag +applies to both border types. + +W_BORD_OPEN to draw a special corner used for menus on the S3 and S3a and is the same as +that drawn by gBorderRect. This flag applies to w_BorRDER_TyPE_o borders +only. + +The corner types can be qualified by OR'ing a combination of the following bit fields: + +W_BORD_CUSHION to leave a | pixel clear cushion right around the border. This flag applies to +both border types + +W_BORD_SHADOW_S to draw a single shadow area. This flag applies to a w_BoRDER_TYPE_o border +only. + +W_BORD_SHADOW_D to draw a double shadow area for a w_BoRDER_TYPE_O border. + + +to set the thickness of the grey and black areas, which give the 3-D effect, to 4 +pixels (compared to a default value of 2 pixels) for a w_BoRDER_TYPE_1 border. + + +W_BORD_SHADOW_ON to set the pixels in the shadow area for a w_BoRDER_TYPE_0 border. One of +W_BORD_SHADOW_S OF W_BORD_SHADOW_D must also be set. If this flag is not set, +the pixels are cleared. + + +to draw a rectangle with the shadowed effect in grey and black as shown in the +diagrams below for a w_BoRDER_TYPE_1 border. In drawing, it draws only the +grey and black parts of the border. It leaves the white parts untouched because +it assumes a pre-cleared background. + + +If this flag is not set, it draws the outline of the border as shown and clears the +area between the two outlines. This allows the shadow effects to be turned off +by simply calling gBorder2Rect again. + + +The following diagrams show examples of the various 3-dimensional style borders introduced with this +function. All are of type w_BORDER_TYPE_1. The caption below each diagram shows the flag combinations +used to draw it. + + +LJ OC + + +W_BORD_CORNER_4 W_BORD_CORNER_4 | W_BORD_SHADOW_ON W_BORD_CORNER_4 | W_BORD. + + +SHADOW_ON | W_BORD_SHADOW_D + + +W_BORD_CORNER_1 | W_BORD_SHADOW_ON W_BORD_CORNER_2 | W_BORD_SHADOW_ON + + +4-11 + + +WINDOW SERVER REFERENCE + + +gBorder2 Draw a 'shadowed' border +VOID gBorder2 (INT type, INT flags); + + +Introduced in version 4 of the window server, this is equivalent to gBorder2Rect but the rectangle is set to +be the whole drawable, either the whole window or a bitmap. + + +gDrawObject Draw a graphics object +VOID gDrawObject (INT type,P_RECT *prect,INT flags) ; + + +Introduced in version 4 of the window server, this draws the scaleable graphics object specified by type. +The object is scaled to fit inside the rectangle specified by the parameter prect. + + +The type of objects currently available are: + + +G_DRAW_OBJECT_TYPE_0 a 3-dimensional box + + +The flags applicable to this type of object are as follows: + + +W_BORD_CORNER_2 to draw the box with a corner type 2, the same as that drawn by gBorder. This +is the default and need not be explicitly coded. + +W_BORD_CORNER_1 to draw the box with a corner type 1, the same as that drawn by gBorder. + +W_BORD_CORNER_4 to draw the box with a corner type 4, the same as that drawn by gBorder. + +W_BORD_SHADOW_D to draw the box with double the thickness of the dark and light edge effects. + + +Area filling + + +The functions in this section act upon the drawable associated with the current graphics context. + + +gCirRect Change a rectangle +VOID gClrRect (P_RECT *prect, UINT mode); + + +Change all pixels within the rectangular block specified by prect where the change depends on mode as +follows: + + +G_TRMODE_SET set the pixels +G_TRMODE_CLR clear the pixels +G_TRMODE_INV invert the pixels (this is reversible by another invert) + + +The P_RECT struct is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +4-12 + + +4 GRAPHICS OUTPUT + + +gilnvObloid Invert an obloid + + +VOID gInvObloid(P_EXTENT *pext) ; +Invert all the pixels (except the four corner pixels) in the rectangular block specified by pext. +The p_extEnT struct is defined as: + + +typedef struct +{ +P_POINT tl; +WORD width; +WORD height; +} P_EXTENT; + + +Not available in version 2 of the window server. + + +gFillPattern Fill a rectangle with a bitmap + + +VOID gFillPattern(P_RECT *prect, UINT bitmap_id, UINT mode); + + +Repeatedly copy the bitmap with ID bitmap_ia over the rectangular block of pixels specified by prect as +many times as is necessary to fill the rectangle. + + +The parameter mode should be one of: +G_TRMODE_REPL where bits in the source pattern replace corresponding bits in the destination. + + +G_TRMODE_SET where Is in the source pattern set corresponding bits in the destination (Os in +the source do not change corresponding bits in the destination). + + +G_TRMODE_CLR where Is in the source pattern clear corresponding bits in the destination (Os in +the source pattern do not change corresponding bits in the destination). + + +G_TRMODE_INV where Is in the source pattern toggle corresponding bits in the destination (Os +in the source pattern do not change corresponding bits in the destination). + + +A larger bitmap will give improved performance. If the pattern is all ones or all zeros, gFillPattern is +equivalent to gclrRect, but less efficient. + + +There is a built in grey bitmap with the handle ws_prTmap_crey and size ws_BITMAP_GREY_STzE_x by +WS_BITMAP_GREY_SIzE_y. This is not true grey as found on the Series 3a but is a pseudo-grey, built up +from a pattern of alternate black and white pixels (ie pixels alternately set on and off in the normal plane). + + +The parameter bitmap_id can also be the ID of a backed-up window to refer to the backup bitmap (but not +in version 2). + + +For example to fill the current drawable with the grey cheque board pattern: + + +LOCAL_C VOID GreyWin (VOID) +{ +P_RECT rect; + + +rect.tl.x=0; + +rect.tl.y=0; + +rect.br.x=10000; + +rect.br.y=10000; +gFillPattern(&rect,WS_BITMAP_GREY,G_TRMODE_REPL) ; +} + + +In version 4 of the window server, when bitmap_id refers to a backed-up window, the function has a +special way of handling grey: + + +e In normal mode, the black plane only is copied from the source to the destination. + + +e In G_GC_FLAG_GREY_PLANE mode, the grey plane from the source is selected and copied to the +grey plane of the destination. If the source only has one plane, then that is used as the source. + + +e In G_GC_FLAG_BOTH_PLANES mode, and with a two plane source, both planes are copied to their +respective destination planes. If only one plane exists, then it will be copied to both planes of the +destination. + + +Note that this does not apply when copying from any other form of bitmap - in all other cases the black +and grey planes must be copied by two separate calls to gFillPattern. + + +4-13 + + +WINDOW SERVER REFERENCE + + +—EeE——E—E—————————————————————————— ee) +Text fonts + + +Fonts are generally described in terms of: +e ascent, descent, and vertical leading +e width and horizontal leading +e low character and high character (the range of ASCII values covered). + + +To clarify the meaning of some of these terms, refer to the following diagram: + + +The string 'Specify' has been printed at a point (x, y) which is indicated in the diagram by a pair of +partially drawn lines. The horizontal of the pair of lines is known as the baseline. + + +The descent of a character is the number of pixels that it extends below the baseline. Thus in the font +shown, 'S' has a zero descent whereas 'p' has a descent of 1. + + +The ascent of a character is the number of pixels that it extends above the baseline. In the font shown, 'S' +has an ascent of 7 whereas 'p' has an ascent of 5. The ascent quoted for a font is always the maximum +ascent of all the characters in the font, and likewise for the descent. The sum of the ascent and the descent +is the height of the font. + + +Vertical leading is the number of additional pixels that separate adjacent lines of text, over and above the +stated height of each line of text. This is usually at least one, to prevent the highest ascent of one line ever +joining up with the lowest descent of the line above. On occasion, however, such joining up may actually +be intended, for example to support box-drawing via the IBM graphics characters in the extended portion +of a font. In any case, it should be noted that, strictly speaking, vertical leading is not a characteristic of a +font as such; rather, it describes how a font is used on a particular occasion. To complicate matters, +different uses of a font will in fact often have different vertical leading. + + +Horizontal leading is the number of pixels that separate adjacent characters in a line of text. + + +The term width is, unfortunately, possessed of two subtly different meanings. The more useful of the two +meanings is that the width of some text is the number of pixels from the start of that text to where a piece +of text following on from the first one would start. This is the value returned by window server inquiry +functions such as gText Width. Thus the width of the character 'S' in the above font is the number of pixels +from the start of the 'S' to the start of the following character (‘p'), namely 6. With this meaning, all the +characters shown in the diagram have width 6, except for 'i' (4) and 'f' (5). + + +The second of the two meanings of width discounts the horizontal leading, so that, by this reckoning, the +width of 'S' is just 5 pixels. This latter meaning of width is sometimes referred to as basic width. + + +There is an important difference between horizontal and vertical leading: horizontal leading is always +supplied as part of the font; on the other hand the amount of vertical leading (if any) to be applied is up to +the user of the font. Stated otherwise, applications have no choice about horizontal leading, but do have +choice over vertical leading. For this reason, the simple term leading is commonly used to denote what is +here being called vertical leading (since horizontal leading is usually just taken for granted). + + +The width of the widest character in a font is called the maximum width, and the width of the numeric +character '0' is called the numeric width, or sometimes the column width. (In any well designed font, all +numeric characters will have the same width). + + +Occasionally, a font is described in terms of its body cell. The font depicted has a basic body cell of 5 by 8 +(which excludes both vertical and horizontal leading), and a corresponding expanded body cell of 6 by 9. + + +Not all the character codes within the range need have a representation within the font. When drawn, +these characters will be represented by the last character in the font. + + +4-14 + + +4 GRAPHICS OUTPUT + + +An application can switch between many different fonts of varying sizes. Each Graphics Context may +have a different font. The appearance of text can also be altered by various style options such as underline +or bold (these are independent of the font). + + +Fonts are generally proportional, ie the characters within the font can be of differing width. It is left to an +application to determine the width of text and make decisions about layout accordingly. + + +Information is provided to allow fonts of differing heights to be aligned vertically about a baseline. When +characters are drawn, the y-coordinate given corresponds to the baseline of the character. If a line of text +is drawn using characters from fonts of different height, this ensures that the text lines up vertically. + + +gOpenFont Open a font +INT gOpenFont (TEXT *filename) ; +Load the font from filename and return the font ID. + + +If an error (with error number err) occurs (for example, the file does not exist or if it is not a valid font +file), the function calls p_leave (err) or returns err, depending on the wDisableLeaves State. + + +To use the font for text drawing functions, the font ID must be assigned to a graphics context (using +gSetGC). + + +Note that the parameter filename is ultimately passed to p_open by the window server process - not the +client process. If fi 1ename is not a full file specification, the unspecified components are taken from the +window server's default path which, in practice, is always the internal drive M.\. This is unlikely to meet +the requirements of a finished product so filename should specify the drive and directory as well as the +file name. Typically, you might place a font file in the same location as the application file in which case +you would use something like: + + +GLREF_D TEXT *DatCommandPtr; + + +LOCAL_C INT OpenFont (TEXT *name) +{ +TEXT full [P_FNAMESIZE]; + + +f_fparse (name, DatCommandPtr, &full[0],NULL) ; +gOpenFont (&full[0]); +} + + +See also gSetOpenAddress for loading a font file which is embedded in another file. + + +gSetOpenAddress Set pos to open font/bitmap/mouse icon +VOID gSetOpenAddress (UINT mode, ULONG pos); + + +Set the file position for the next call to gopenFont, gOpenFont Index, gInitBit, gOpenBit or +gOpenMouselcon as a function of mode and pos. + + +The possible values of mode are defined by constants of the form c_opEN_MopE_xxx where xxx is one of: + + +OFFSET to indicate that pos is the file position of the data + +WORD_PTR_OFFSET to indicate that pos is the file position of a uworp containing the file position of +the data + +LONG_PTR_OFFSET to indicate that pos is the file position of a uLonc containing the file position of +the data + +NORMAL to cancel the effect of any previous unused call to gsetopenaddress (pos iS +ignored) + + +The effect of the call only lasts until the next call to gopenFont, gopenFontIndex, gInitBit, gOpenBit OF +gOpenMouseIcon So you wouldn't normally need c_opEN_MoODE_NoRMAL - especially as a call to +gSetOpenAddress would normally occur immediately before the gopenxxx call it is intended to effect. + + +The data at the effective file position should be the entire contents of the normal font, multiple font, +bitmap or mouse icon file - including all headers. + + +4-15 + + +WINDOW SERVER REFERENCE + + +wFree Free a font +VOID wFree(UINT font_id); + + +Free a previously loaded font. + + +gFontinfo Get font information + + +INT gFontInfo(UINT font_id, UINT style, G_FONT_INFO *pinfo); + + +Write information about the font with ID font_id as modified by the text style style to the G_FoNT_INFO +struct at pinfo where the G_FONT_INFO struct is defined in wlib.h as: + + +typedef struct +{ + + +UWORD low_ch; /* lowest character code in font */ + +UWORD high_ch; /* highest character code in font */ + +UWORD height; /* height of font */ + +UWORD descent; /* height of bottom part of a character */ + +UWORD ascent; /* height of top part of a character */ + +UWORD numeric_width; /* width of the '0' character */ + +UWORD max_width; /* width of widest character in the font */ + +UWORD flags; /* flags specifying information about the font */ +TEXT name[16]; /* Text name of the font */ + + +} G_FONT_INFO; + + +The field numeric_width is actually the width of the '0' (zero) character, however any well designed font +will have all its numeric characters the same width. If a font is monospaced, all characters are of width + + +max_width. + + +The field max_width is set by the font designer when the font is created. It is not necessarily the widest +character in the font, since the font designer will normally exclude any special characters that are rarely +used - max_width is normally the width of 'M' or 'W'. + + +The fields numeric_width, max_width, height, descent and ascent can be modified from their base +values by the style given. + + +The flags field consists of the following bit fields: + +G_FONT_FLAG_ASCII the font contains the standard ASCII character set +G_FONT_FLAG_CP850 the font contains the IBM code page 850 character set +G_FONT_FLAG_BOLD the font is designed to look bolded +G_FONT_FLAG_ITALIC the font is designed to look italic + +G_FONT_FLAG_SERIF the font character graphics have serifs + + +Returns zero if successful or, if font_id is invalid, it calls p_leave (E_GEN_NOFONT) or returns +E_GEN_NOFONT, depending on whether wDisableLeaves has been called. + + +To get information on the system font, font_id may be set to WS_FONT_SYSTEM. + + +On version 2 of the window server you should not call gFont Info with an invalid font_id (if you do, +gFont Info writes garbage to pinfo). + + +gTextWidth Get text width + + +INT gTextWidth(UINT font_id, UINT style, TEXT *pbuf, UINT len); +Return the width in pixels of the 1en characters at pbuf when drawn with font font_id and style style. + + +Any character code in pbuf that does not have a corresponding character graphic in the font is taken to +have the width of the last character in the font. + + +Note that the style can affect the width returned because bolding, italicising, mono-spacing etc widens +each character. + + +To get the text width when using the system font, font_id may be set to WS_FONT_SYSTEM. + + +If font_id is invalid, the function calls p_leave (E_GEN_NOFONT) or returns E_GEN_NOFONT, depending on +whether wDisableLeaves has been called. + + +4-16 + + +4 GRAPHICS OUTPUT + + +gTextCount Clip text to pixel width + + +INT gTextCount (UINT font_id, UINT style, TEXT *pbuf, UINT len,UINT *pwidth) ; + + +Return the number of characters from pbuf (up to 1en) that will fit in their entirety in *pwidth pixels +when drawn with font font_id and style style. Also overwrite *pwidth with the remaining width. + + +Any character code in pbuf that does not have a corresponding character graphic in the font is taken to +have the width of the last character in the font. + + +Note that the style can affect the width returned because bolding, italicising, mono-spacing etc widens +each character. + + +When using the system font, font_id may be set to wS_FONT_SYSTEM. + + +If font_ida 1s invalid, the function calls p_leave (E_GEN_NOFONT) or returns E_GEN_NOFoONT, depending on +whether wDisableLeaves has been called. + + +gGetWidthTable Get a font width table + + +INT gGetWidthTable(UINT font_id, UINT style, UBYTE *ptab); +Generate a usyTE array of character pixel widths in *ptab for font font_id and style style. + + +The first byte in *ptab is the width of the character with code 1ow_ch and the length of the array written is +high_ch-low_ch+1 (where low_ch and high_ch are from the font's c_rontT_inro struct). + + +The function is provided to speed optimise calculations based on character widths - such as those +performed by gTextwidth and gTextCount. + + +Any character code that does not have a corresponding character graphic in the font is taken to have the +width of the last character in the font. + + +Note that the style can affect the width returned because bolding, italicising, mono-spacing etc widens +each character. + + +When using the system font, font_id may be set to ws_FONT_SYSTEM. + + +Returns zero if successful or, if font_id is invalid, it calls p_leave (E_GEN_NOFONT) or returns +E_GEN_NOFONT, depending on whether wDisableLeaves has been called. + + +wSetSystemFont Set the system and internal fonts + + +INT wSetSystemFont (INT mode, INT handle, UINT style); + + +Available in version 4 of the window server, this function mat be used on the Series 3a and Workabout to +set up the system and internal fonts. + + +The mode parameter is used to indicate which font type is to be the target of the set up. This parameter can +take one of the following values: + + +W_SYSTEM_FONT_S3B sets up the native system font +W_SYSTEM_FONT_S3 sets up the Series 3 compatibility mode system font +W_SYSTEM_FONT_INTERNAL_S3B _ sets up the native internal font +W_SYSTEM_FONT_INTERNAL_S3 __ sets up the Series 3 compatibility mode internal font +The handle parameter references the font to be used as the source for the setup. This can be: +e the handle returned for a loaded font +e the handle of one of the built-in fonts +e the handle of a font group created by gconfigureFonts + + +The style parameter can be used to modify the style of text when setting up either of the two internal font +types. This parameter is ignored if setting up any of the other font types. The style parameter adopts the +same values as those applicable to the sty1e field in the graphics context. + + +4-17 + + +WINDOW SERVER REFERENCE + + +The function returns zero if successful, =_cEN_Noront if an invalid font handle is supplied or =_cEN_are if +an invalid mode is supplied. Alternatively, it calls p_leave if wDisableLeaves has been called. + + +Note that at the time of writing, there is no way of notifying applications that the system font has changed. + + +gOpenFontindex Open a font from a multiple font file + + +INT gOpenFontIndex(TEXT *fname,UINT index) + + +Available in version 4 of the window server, this function is similar to gopenFont except that it allows a +font to be loaded from a file containing more than one font. + + +The index parameter is used to indicate which font within the file is to be loaded. The first font in the file +corresponds to an index of zero, while the second font corresponds to an index value of one and so on. + + +Single-font files can be opened by setting index to zero. +Multiple-font files are invalid to older versions of the window server. +If index refers to a font file beyond the final one in the file, error E_FILE_EOoF is reported. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns err, depending on +whether wDisableLeaves has been called. + + +Multiple-font files can be created by versions 2.00 upwards of the font compiler WSFCOMP. + + +gConfigureFonts Configure a font group +INT gConfigureFonts (INT count,G_FONT_CONFIG *pfcfg[]) +Available in version 4, this function is used to create a font group and return its id. + + +A font group is a compromise solution to the problem of deciding whether to use the window server's +algorithmic method of obtaining a style (see style subsection of the Graphics context section) or to use a +font designed specifically for the purpose. This is even more important where the situation is ambiguous. +For example, given a bold font and an italicised font, if the application wishes to print in bold and italics, +does it choose to apply the bold style to the italicised font or apply the italic style to the bold font? + + +Designing a font for every combination of style is impractical while the result of applying the window +server's algorithmic method may not always give satisfactory results. + + +Essentially, a font group is a list of font id's and style combinations. + + +When an application wishes to print text, typically it will specify a (group) font ID and a combination of +styles to be applied. In response, the window server scans down each entry in the list searching for the best +match. It then uses the font in this entry for printing. + + +The font group is specified by the parameter pfcfg which points to an array of G_FONT_CONFIG structures. +The array has count elements. Each element in the array is, in effect, an entry in the list discussed above. +The G_FonT_conF1IG structure is defined as follows: + + +typedef struct +{ +UINT FontId; /*Replacement Font is +UINT RepStyles; /*Styles needing to be replaced*/ +UINT FontStyles; /*Styles used with this Font ay +UI +} + + +NT AscentAdjust; /*Adjustment to Font's ascent */ +G_FONT_CONFIG; + + +The order of the elements in the array is important because of the way the search algorithm works. This +proceeds as follows: + + +1. The window server initially chooses the base font as the 'best'. In other words, the first entry +in the array. + + +2. Initially, each entry in the array is scanned, starting with the first, until one is found where +the RepStyles field contains styles which are a subset of the styles to be printed. + + +4-18 + + +4 GRAPHICS OUTPUT + + +3. Subsequently, the scan continues, searching for entries whose RepStyles field contains +styles which are a subset of the styles to be printed and which also (as a minimum) contain +the styles of the current 'best' entry. Where such an entry is found, this becomes the 'best'. + + +4. The process, numbered 3 above, is repeated until the array is exhausted, The window server +uses the font corresponding to the Font1d of the ‘best’ entry in the array. + + +Having found a suitable font, the window server then applies those styles which the application wants +printed but which are not specified in the Repstyles field. For example, suppose the application wants +bold and italic printed. Suppose also that the 'best’ entry in the array specifies only the bold style in the +RepStyles field. The window server will use the Font 1d as the font to be used and will apply the italic +style to this font. + + +In addition, the rontstyles member of each entry in the array specifies styles which are also to be applied +to the chosen font when it is drawn. + + +The Ascentadjust field specifies an adjustment to be made (positive or negative) to the font's ascent when +printing. This is primarily of use for superscript and subscript fonts. See the c_sty_suBscRIPT2 and +G_STY_SUPERSCRIPT2 styles at the beginning of this chapter. + + +gReadFontHeader Read a font header from a file + + +INT gReadFontHeader (TEXT *fname, INT index,UBYTE *pbuffer) + + +Available in version 4 of the window server, this function reads up to a maximum of +FONT_MAX_HEADER_LEN bytes of font data from the font referenced by fname and index into the buffer +pointed to by pbuffer. + + +fname references the font file while the index parameter indicates the actual font within the file. For a +single font file, index must be set to 0; for a multiple font file, an index value of zero refers to the first +file, an index value of one refers to the second file and so on. + + +If the call is successful, the function returns the length of data actually read. + + +If an error (with error number err) occurs (for example, the file does not exist or it is not a valid font file), +the function calls p_leave (err) or returns err, depending on the wDisableLeaves State. + + +gReadFontGroupHeader Read a font group header from a file + + +INT gReadFontGroupHeader (TEXT *fname,UBYTE *pbuffer) + + +Available in version 4 of the window server, this function reads up toa maximum of +FONT_MAX_HEADER_LEN bytes of font header data from the font file referenced by fname into the buffer +pointed to by pbuffer. + + +In the first word of the buffer, the function places the number of fonts contained in the file. This word is +followed by the group header. This means that the actual maximum length of header data that can be +stored in the file is FONT_MAX_HEADER_LEN - 2 bytes. + + +If the call is successful, the function returns the length of data actually read. + + +If an error (with error number err) occurs (for example, the file does not exist or it is not a valid font file), +the function calls p_leave (err) or returns err, depending on the wDisableLeaves State. + + +See the description of wsfcomp for information on how to add header data. + + +Text output functions + + +The functions in this section are all directed at the drawable associated with the current graphics context +and are all subject to the style and font fields of the current graphics context. + + +The functions gPrintText and gPrintClipText are also subject to the textmode field. The functions +wDrawButton, and wDrawButton2 are also subject to the gmode field. + + +In version 4 of the window server, the plane to which drawing is directed in the current graphics context +will affect the 'colour' of the display. + + +4-19 + + +WINDOW SERVER REFERENCE + + +gPrintText Print text +VOID gPrintText (INT x, INT y, TEXT *pbuf, UINT len); + + +Print the len characters at pbuf horizontally from pixel position x, y where len must not be greater than +WS_MAX_PRINT_TEXT_LEN. + + +The first character graphic is positioned such that its leftmost pixel that is just above the baseline is over +pixel (x,y) of the drawable. (The baseline is the mathematical line between the upper ascent pixels and +the lower descent pixels that make up the height of the font.) + + +The text is printed relative to the baseline so that the characters in a line of text that contains different +fonts (with potentially different ascents and descents) line up correctly, as illustrated by the following +diagram: + + +Baseline + + +Descent + + +sil + + +X is the printing position. + + +The text is printed according to the textmode, style and font in the current graphics context. + + +Any character code in pbuf that does not have a corresponding character graphic in the font is printed as +the last character in the font. + + +Note that gPrintText performs no special processing on control characters (ie characters with a code that +is less than 32) and if they are not represented in the font then they will also be printed as the last +character in the font. + + +gPrintClipText Print clipped text +INT gPrintClipText (INT x, INT y, TEXT *pbuf, UINT len, UINT clip_width) ;;; +Similar to gprintText except that it only draws as many characters as will fit inside clip_width. + + +Returns the number of characters actually printed. + + +gPrintBoxText Print text in a box + + +VOID gPrintBoxText (P_RECT *prect, UINT ascent, UINT align, INT margin, TEXT *pbuf, UINT +len); + + +Print the len characters at pbuf with a fixed textmode of G_TRMODE_REPL within the rectangular block of +pixels specified by prect, clearing (or setting) those pixels that are not replaced by characters from the +font (1en must not be greater than ws_Max_PRINT_BOX_TEXT_LEN). + + +If necessary, the drawing is pixel-clipped to the rectangle defined by prect. +The P_REcT struct is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +4-20 + + +4 GRAPHICS OUTPUT + + +The characters are positioned vertically such that there are ascent pixels between the top of the rectangle +and the base line of the characters (unless you intend to clip the top off the text, ascent should be greater +than or equal to the current font's ascent) as illustrated by the following diagram: + + +ascent ascent +of +font + + +baseline of font + + +The excess space around the text is cleared or set depending on the inverse bit in the style. + + +The text may be left or right aligned, or centred within prect depending on whether align is +G_TEXT_ALIGN_LEFT, G_TEXT_ALIGN_RIGHT Of G_TEXT_ALIGN_CENTRE. + + +The parameter margin is used to clear extra space to the left or right of the text where margin is +interpreted as follows: + + +align = G_TEXT_ALIGN_LEFT + + +left-aligned text + + +align = G_TEXT_ALIGN_RIGHT + + +right-aligned text + + +For centred text, the margin can be placed either to the right or to the left of the text according to the sign +of margin, as follows: + + +align = G_TEXT_ALIGN_CENTRE, margin>=0 + + +centred text + + +align = G_TEXT_ALIGN_CENTRE, margin<0O + + +centred text + + +The text is printed according to the style and font in the current graphics context (but not textmode). + + +Using gPrintBoxText avoids the flicker that is generated between a separate clear and print. + + +gXPrintText Print text with embellishment + + +VOID gXPrintText (INT x, INT y, TEXT *pbuf, UINT len, UINT flags); + + +Print the 1en characters at pbuf horizontally from pixel position x, y with highlighting in a style that +depends on the value of f1ags (1en must not be greater than ws_MAx_PRINT_TEXT_LEN). + + +4-21 + + +WINDOW SERVER REFERENCE + + +The text is printed according to the style and font in the current graphics context (but not textmode). + + +Equivalent to calling gPrintText with a fixed textmode of G_TRMODE_REPL followed by some +embellishment depending on the value of f1ags. Possible flag values are illustrated below for the string +‘Specify’, in each case printed with the same value of x and y. + + +Zero (no embellishment). | + + +rT TT : 8 +The partially drawn lines indicate H Sian: CMM. SUMMERS Ros CaGd Ce +the point to which the coordinates x l ial laa fe i +and y-apply; _ TTT "a1: iF sae _ + + +G_XP_INV_BLOCK + + +G_XP_INV_OBLOID + + +G_XP_INV. BLOCK |G XP_REDUCED + + +G_XP_INV_OBLOID|G_XP_REDUCED + + +G_XP_UND_BLOCK nnnn a Be +a nnnE ann EEE BB a ] | +ann 6G _ Ho no One 66 ] +| a HEREE 8 | f a | +et | a ] a nnnE +nnnE 6G EERE SEE Boe OU a + + +G_XP_UND BLOCK |G XP_REDUCED + + +All the reduced forms are intended for use on text strings with no characters having descenders, such as +numbers and upper case letters. + + +A zero flags is equivalent to gPrintText with a textmode of G_TRMODE_REPL and may be used to cancel an +embellishment set up previously. + + +Not available in version 2 of the window server. + + +In version 4 of the window server, by setting the graphics context to draw to the grey plane and making +sure that the window is enabled for drawing grey, all of the text and embellishments in the above +examples will be drawn in grey. + + +4-22 + + +4 GRAPHICS OUTPUT + + +gShadowText Print shadowed text + + +VOID gShadowText (INT posx,INT posy, G_SHADOW *pshadow, TEXT *ptxt,INT len); + + +Introduced in version 4 of the window server, this function prints the 1en characters at ptxt with a +shadowed effect from pixel position posx, posy where 1en must not be greater than +WS_MAX_PRINT_TEXT_LEN. + + +It uses the current font and style (ie the current graphics context) but ignores the current textmode. +The pshadow parameter must point to a structure of type c_sHaDow which is defined as follows: + + +typedef struct +{ +UBYTE BodyColour; +UBYTE ShadowColour; +UBYTE LightColour; +UBYTE filler; +UWORD Flags; +WORD ShadowSizexX; +WORD ShadowSizey; +WORD LightSizex; +WORD LightSizeyY; +WORD Spacing; +} G_SHADOW; + + +The shadow is always placed at the bottom right of the text while the lighting effect is always placed at the +top left of the text. + + +The size of the shadow effect is specified by snadowSizex and ShadowSizey. The size of the lighting effect +is specified by Lightsizex and LightSizey. + + +The 'colours' for the body, shadow and light can be one of black, grey, white or none by setting the +G_SHADOW Members BodyColour, ShadowColour and LightColour to one of G_COLOUR_BLACK, +G_COLOUR_GREY, G_COLOUR_WHITE Of G_COLOUR_NONE. + + +The display can consist of either a single copy of the text giving an impression of the text floating above +the shadow or a solid block linking the text to the background. By default, the floating style shadow is +used. The solid block effect is achieved by setting the riags member to G_SHADOW_SOLID. + + +The gap between characters can be set by giving the spacing member a suitable value. This is useful if a +character's shadow effects are not to overlap the following character. + + +The following picture shows four examples of the effect of using gshadowText: + + +t Ihe + + +In all examples, shadowSizex was Set to 6, ShadowSizey was Set to 6, LightSizex was set to 2 and +LightSizey was Set to 2. + + +Spacing was Set to 6 to allow sufficient space between the characters so that the shadow effects could be +seen. + + +4-23 + + +WINDOW SERVER REFERENCE + + +Looking at each example from left to right, the following values were used: + + +1. BodyColour set to G_COLOUR_BLACK +ShadowColour Set tO G_COLOUR_GREY +LightColour set to G_COLOUR_NONE + + +2. BodyColour set to G_COLOUR_BLACK +ShadowColour Set tO G_COLOUR_GREY +LightColour set to G_COLOUR_NONE +Flags set to G_LSHADOW_SOLID + + +3. BodyColour set to G_COLOUR_BLACK +ShadowColour Set tO G_COLOUR_GREY +LightColour set tO G_COLOUR_WHITE +Flags set to G_LSHADOW_SOLID + + +4. BodyColour set tO G_COLOUR_WHITE +ShadowColour Set tO G_COLOUR_BLACK +LightColour set to G_COLOUR_GREY +Flags set to G_LSHADOW_SOLID + + +wDrawButton Draw a text button +VOID wDrawButton(P_RECT *prect, TEXT *pstr, UINT depressed); + + +Draw a button within rectangle prect containing the zero terminated string pstr. If depressed 1s TRUE, +draw the button with the text and the box displaced to give a 3D illusion of a depressed button. + + +The length of pst r must not be greater than w_DRAW_BUTTON_MAX_LEN (240). + + +The text is printed according to the style and font in the current graphics context. Both the box lines and +the text string are drawn according to the gmode (the value of textmode is ignored). + + +The P_REcT struct is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT + + +~ + + +The intended use of worawButton is illustrated by the following example: + + +include +include + + +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) + + +gFont Info (Font ID=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) ; +} + + +4-24 + + +4 GRAPHICS OUTPUT + + +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 (77) + +{ + +wGetEventWait (&event) ; + +if (event .type==WM_REDRAW) +{ +wBeginRedrawWinGCO (wMainWid) ; +gBorder (W_BORD_SHADOW. D|w BORD_SHADOW_ON) ; +SetGC(); +DrawButton (FALSE) ; +wEndRedraw (); +continue; +} + +if (event .type==WM_KEY) +{ +gCreateTempGCO0 (wMainWid) ; +SetGC (); +DrawButton (TRUE) ; +wF lush () ; +p_sleep(51); +DrawButton (FALSE) ; +gFreeTempGC () ; +} + + +} + + +GLDEF_C VOID main(VOID) + + +{ +wConnect (&wSpec, 0,W_CONNECT_PRIORITY) ; + + +wMainWid=wCreateWindow(0,0,0,1); +wiInitialiseWindowTree (wMainWid) ; +SetFont (WS_FONT_SYSTEM, G_STY_BOLD) ; +MainEvent Loop () ; + + +} + + +wDrawButton2 Draw a text button + + +VOID wDrawButton2 (INT type, P_RECT *prect, TEXT *ptext, UINT state); + + +Introduced in version 4 of the window server, this function not only draws the new style Series 3a buttons, +but also the old style Series 3 types. + + +The parameter prect points to a p_REcT structure that specifies a rectangle that fully encloses the button +in all of its states. + + +The ptext parameter specifies a zero terminated string to be drawn inside the button in the current font +and style. It is the responsibility of the caller to make sure that the text will fit inside the button; there is +no clipping of text. The maximum length of text is w_DRAW_BUTTON_MAX_TEXT. + + +The parameter type indicates which style of button is to be drawn. This can have the following values and +meanings: + + +W_BUTTON_TYPE_1 draws the Series 3 style buttons + + +W_BUTTON_TYPE_2 draws the Series 3a style buttons + + +4-25 + + +WINDOW SERVER REFERENCE + + +The state parameter has different meanings for the different types. +For w_BUTTON_TYPE_1 buttons, 0 draws a raised button while | draws a depressed(flat) button. + + +For w_BUTTON_TYPE_2 buttons, 0 draws a raised button, 1 draws a semi-depressed button while 2 draws a +fully depressed(sunken) button. + + +The following picture shows three examples of w_BUTTON_TYPE_2 buttons. From left to right, the +examples show: a state O button (raised), a state | button (semi-depressed) and a state 2 button (fully +depresses). + + +raised Sen] depressed fully depressed + + +For the purpose of comparison, the following picture shows examples of w_BUTTON_TYPE_1 buttons. From +left to right, the examples show: a state 0 button (raised) and a state | button (fully depressed). + + +raleed fully depressed + + +It is important to note that before calling worawButton2 to draw W_BUTTON_TYPE_2 buttons, the window +must be enabled for drawing grey. + + +Bitmaps + + +Although directed at the drawable associated with the current graphics context, the graphics output +functions in this section do not depend on any of the settable fields in the graphics context. + + +gCreateBit Create a bitmap +INT gCreateBit (UINT flags, W_OPEN_BIT_SEG *pbitseg) ; + + +Create an uninitialised bitmap where the size of the bitmap and its method of storage is controlled by +flags and the W_OPEN_BIT_SEG struct at pbitseg. + + +The W_OPEN_BIT_SEG Struct is defined as: + + +typedef struct +{ +P_POINT size; +TEXT seg_name[14]; +} W_OPEN_BIT_SEG + + +where pbitseg->size specifies the dimensions of the bitmap in pixels and pbitseg->seg_name is written +to by gcreateBit when requested by the bit in flags (as described next). + + +If f£1ags is zero, the bitmap may be stored in the window server's data space or in a named memory +segment depending on the size of the bitmap. If the bitmap requires less than 2.5K bytes, it is stored in +the window server's data space. + + +The storage of the bitmap is controlled by setting the following bits in flags: +WS_BIT_SEG to store the created bitmap in its own memory segment (regardless of its size) + + +WS_BIT_SEG_ACCESS to create the bitmap in its own memory segment and to write the name of the +segment as a zero terminated string to pbitseg->seg_name. The segment name +can be used to access the bitmap directly using p_sgcopyfr and p_sgcopyto +(described in the Memory Allocation chapter of the PLIB Reference manual) or +otherwise. + + +WS_BIT_SEG_ZERO_SIZE Used in conjunction with ws_BIT_SEG_ACcCcEss to create the bitmap's memory +segment with zero size. You must subsequently increase the size at a later date. +This is designed to be used in conjunction with graphics functions that are +added using wLoadDYL. + + +4-26 + + +4 GRAPHICS OUTPUT + + +If flags is either zero or WS_BIT_SEG, pbitseg—>seg_name is not written to and, in this case, pbitseg may +just be the address of a p_pornt struct. The prototype for gcreateBit actually declares pbitseg asa +voIp * so that you can pass either a wS_BIT_SEG * Of a P_POINT *. + + +You may use all the window server graphics functions to draw to a bitmap unless the +WS_BIT_SEG_ZERO_S1ZE flag is set, in which case the graphics functions will have no effect. + + +Returns the positive ID of the bitmap if successful. + + +If the function fails because there is insufficient memory, it calls p_leave (E_GEN_NOMEMORY) or returns +E_GEN_NOMEMoRY, depending on whether wDisableLeaves has been called. + + +gOpenBit Load a bitmap +INT gOpenBit (TEXT *filename, UINT index, UINT flags, W_OPEN_BIT_SEG *pbitseg) ; + + +Load bitmap index from file filename where index is used to select a bitmap from a file that contains +multiple bitmaps (a zero index selects the first bitmap). To load from a file containing a single bitmap, +pass the index as zero. + + +The function writes to the w_oPEN_BIT_sSEG Struct at pbitseg where w_opEN_BIT_SEG is defined as: + + +typedef struct +{ +P_POINT size; +TEXT seg_name[14]; +} W_OPEN_BIT_SEG + + +If the bitmap is successfully loaded, the dimensions of the bitmap in pixels is written to pbitseg->size +and the ID of the bitmap is returned. + + +If £1ags is zero, the bitmap may be stored in the window server's data space or in a named memory +segment depending on the size of the bitmap. If the bitmap requires less than 2.5K bytes, it is stored in +the window server's data space. + + +The storage of the bitmap is controlled by setting the following bits in fags: +WS_BIT_SEG to store the loaded bitmap in its own memory segment (regardless of its size) + + +WS_BIT_SEG_ACCESS to store the loaded bitmap in its own memory segment and to write the name of +the segment as a zero terminated string to pbitseg->seg_name. The segment +name can be used to access the bitmap directly using p_sgcopyfr and +p_sgcopyto (described in the Memory Allocation chapter of the PLIB +Reference manual) or otherwise. + + +WS_BIT_WRITE if set, you are given write access to the bitmap and a new bitmap is always +created. If the flag is not set, the bitmap will only be created once and if any +client calls gopenpit on the same bitmap, the loaded bitmap will be shared. + + +Provided that the ws_B1T_wr1TE flag is set, you may use all the window server graphics functions to draw +to a bitmap. If the ws_B1T_wr1te flag is not set, the graphics output functions will have no effect. + + +If ws_BIT_SEG_ACCESS iS not set in flags, pbitseg->seg_name is not written to and, in this case, pbitseg +may just be the address of a p_pornt struct. The prototype for gopenBit actually declares pbitseg as a +voIp * so that you can pass either a wS_BIT_SEG * Of a P_POINT *. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns err, depending on +whether wDisableLeaves has been called. + + +Note that the parameter filename is ultimately passed to p_open by the window server process - not the +client process. If filename is not a full file specification, the unspecified components are taken from the +window server's default path which, in practice, is always the internal drive M:\. This is unlikely to meet +the requirements of a finished product so filename should specify the drive and directory. + + +4-27 + + +WINDOW SERVER REFERENCE + + +Typically, the bitmap file might be built into the application to create a .app file as described in the +Building An Application chapter in the General Programming manual. In this situation you might have a +code fragment that looks like: + + +GLREF_D TEXT *DatCommandPtr; + + +LOCAL_C INT OpenBit (TEXT *name) + + +{ +W_OPEN_BIT_SEG bseg; +TEXT full [P_FNAMESIZE]; + + +f_fparse (name, DatCommandPtr, &full[0],NULL); +gOpenBit (&full[0],0,0, &bseg) ; +} + + +See also gSetOpenAddress for loading a bitmap file which is embedded in another file. + + +wFree Free a bitmap + + +VOID wFree(UINT bitmap_id); +Free the bitmap with ID bitmap_ia. + + +Any Graphics Contexts drawing to bitmap_id is automatically freed. + + +gSaveBit Save a bitmap + + +INT gSaveBit (TEXT *filename, UINT bitmap_id) ; + + +Save the bitmap with ID bitmap_id to file filename or, if bitmap_id is zero, save the screen to file + + +filename. + + +The parameter bitmap_id can also be the ID of a backed-up window to refer to the backup bitmap (but not +in version 2). + + +Returns zero if successful. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns err, depending on +whether wDisableLeaves has been called. + + +If filename is not a full file specification, the unspecified components are taken from the window server's +default path which, in practice, is always the internal drive M:\. + + +In version 4 of the window server, the function will save a double bitmap when saving the screen or a +backed-up window with a grey plane. + + +gSaveRect Save part of a bitmap +INT gSaveRect (TEXT *filename, UINT bitmap_id, P_RECT *prect); + + +Save the rectangular block of pixels specified by prect from the bitmap with ID bitmap_id to file +filename or, if bitmap_id is zero, save the rectangular block of pixels specified by prect from the screen +to file filename. + + +The P_REcT struct is defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +4-28 + + +4 GRAPHICS OUTPUT + + +The parameter bitmap_id can also be the ID of a backed-up window to refer to the backup bitmap (but not +in version 2). + + +Returns zero if successful. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns err, depending on +whether wDisableLeaves has been called. + + +If filename is not a full file specification, the unspecified components are taken from the window server's +default path which, in practice, is always the internal drive M:\. + + +Not available in version 2 of the window server. + + +In version 4 of the window server, the function will save a double bitmap when saving the screen or a +backed-up window with a grey plane. + + +gCopyBit Copy a bitmap to a window +VOID gCopyBit (P_POINT *pos, UINT bitmap_id, P_RECT *prect, UINT mode); + + +Copy the rectangular block of pixels specified by prect in the bitmap with ID bitmap_ia to position pos +in the destination. + + +The parameter mode should be one of: +G_TRMODE_REPL where bits in the source pattern replace corresponding bits in the destination. + + +G_TRMODE_SET where Is in the source pattern set corresponding bits in the destination (Os in +the source do not change corresponding bits in the destination). + + +G_TRMODE_CLR where Is in the source pattern clear corresponding bits in the destination (Os in +the source pattern do not change corresponding bits in the destination). + + +G_TRMODE_INV where Is in the source pattern toggle corresponding bits in the destination (Os +in the source pattern do not change corresponding bits in the destination). + + +The p_point and p_rect structs are defined as: + + +typedef struct +{ +WORD x; +WORD y; +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left pixel (internal) */ +P_POINT br; /* bottom right pixel (external) */ +} P_RECT; + + +This function should not be used to copy from a bitmap onto itself, since it does not handle overlapping +source and destination areas - gcopyRect should be used instead. + + +The parameter bitmap_id can also be the ID of a backed-up window to refer to the backup bitmap (but not +in version 2). + + +In version 4 of the window server, when bitmap_ia refers to a backed-up window, the function has a +special way of handling grey: + + +e In normal mode, the black plane only is copied from the source to the destination. + + +e In G_GC_FLAG_GREY_PLANE mode, the grey plane from the source is selected and copied to the +grey plane of the destination. If the source only has one plane, then that is used as the source. + + +e In G_GC_FLAG_BOTH_PLANES mode, and with a two plane source, both planes are copied to their +respective destination planes. If only one plane exists, then it will be copied to both planes of the +destination. + + +Note that this does not apply when copying from any other form of bitmap - in all other cases the black +and grey planes must be copied by two separate calls to gcopyBit. + + +4-29 + + +WINDOW SERVER REFERENCE + + +gCopyRect Copy a bitmap onto itself +VOID gCopyRect (P_RECT *prect, P_POINT *pos, UINT mode); + +Copy the rectangular block of pixels specified by prect to position pos. + +The parameter mode is as for gcopyBit, described above. + + +This function should only be used when the current graphics context is assigned to a bitmap. It should not +be used to copy parts of windows since it does not handle invalid areas or possible obscuring windows - +wScrollRect should be used instead. + + +gPeekBit Read a bitmap +INT gPeekBit (UINT bitmap_id, P_POINT *pstart, UINT len, UBYTE *presult) ; + + +Copy a horizontal slice of 1en bits starting at (pstart->x, pstart->y) from bitmap_id to presult +(which must be at least (((1en+15)/8) & (~1)) bytes long). + + +To copy from the screen, set bitmap_id to zero. +If the section specified by start and len extend outside the bitmap then gPeekBit will call p_panic. +The parameter bitmap_id can also be the ID of a backed-up window to refer to the backup bitmap. + + +On version 2 of the window server, 1en must be less than (8*MAX_WSERV_TO_CLIENT_BUFFER) bits long. + + +In version 4 of the window server, if the most significant bit of the bitmap_id is set, then the function will +‘peek' from the grey plane. For example, the following code fragment re-directs the function to ‘peek’ from +the grey plane: + + +bitmap_id |= 0x8000; + +gPeekBit (bitmap_id, ... ); +gCheckBitmapID Check if a bitmap is valid +INT gCheckBitmapID(UINT bitmap_id) ; +Check if a bitmap is valid. + + +Returns zero if it is valid. Otherwise the function calls p_leave(E_FILE_NxIST) or returns E_FILE_NXIST, +depending on whether woisableLeaves has been called. + + +Not available in version 2 of the window server. + + +Multiple bitmaps + + +In version 4 of the window server, a set of bitmap functions is available that allows a bitmap file to be +opened so that bitmaps within the file can be loaded or drawn direct from the file. + + +Loading multiple bitmaps from a file with this method is considerably quicker than repeated calls to +gOpenBit as the file does not have to be opened and closed for every bitmap loaded. + + +Drawing bitmaps direct from a file is advantageous when drawing part of a large bitmap; only the parts +actually drawn are loaded, saving on access time and storage. + + +When using this method to draw the whole bitmap, there is a trade-off between memory usage and the +time taken to perform the draw. While loading the bitmap "bit by bit" as it is drawn makes it slower than +loading the whole bitmap in one go and then drawing it, it needs less memory, as only that part of the +bitmap to be drawn needs to be in memory at any one time. + + +4-30 + + +4 GRAPHICS OUTPUT + + +glnitBit Open a bitmap file +INT gInitBit (TEXT *filename, INT *pcount) ; + + +Available in version 4 of the window server, this function opens the bitmap file £i1ename ready for calls +to gGet Bit OF gDrawBit. + + +If the open is successful, the function returns the handle of the open file and the number of bitmaps held +in the file is written to *pcount. + + +If filename is not a full file specification, the unspecified components are taken from the window server's +default path which, in practice, is always the internal drive M:\ + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns the (negative) error +number, depending on whether woisableLeaves has been called. + + +See also gSetOpenAddress for opening a bitmap file which is embedded within another file. + + +gGetBit Load a bitmap from an open file + + +INT gGetBit (UINT handle, UINT index,UINT flags, W_OPEN_BIT_SEG *pbitseg) ; + + +Available in version 4 of the window server, this function loads a bitmap from the bitmap file referenced +by handle (as returned from a previous call to ginitBit). + + +index indicates the position of the bitmap within the file; zero indicates the first bitmap, one indicates the +second and so on. + + +The behaviour of the function and the meaning of the parameters flags and pbitseg are the same as for +gOpenBit. + + +Returns the ID of the bitmap if successful. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns the (negative) error +number, depending on whether woisableLeaves has been called. + + +gDrawBit Draw a bitmap from an open file +INT gDrawBit (P_POINT *pos, INT handle,P_RECT *prect, INT mode, INT index) ; + + +Available in version 4 of the window server, this effectively performs a gGetBit, gCopyBit and wrree. +The pos, prect and mode parameters are the same as for gcopyBit in that they specify what is drawn. The +handle and index parameters are the same as for gcetBit in that they reference the open bitmap file and +indicate the position of the source bitmap within the file (relative to zero). + + +Only the relevant scan lines for the parts to be drawn are loaded; these are loaded one at a time. This +means that no extra memory needs allocating. + + +Returns zero if successful. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns, depending on +whether woisableLeaves has been called. + + +gQueryBit Query the size of a bitmap + + +INT gQueryBit (INT handle, INT index, P_POINT *psize); + + +Available in version 4 of the window server, this function queries the size of a bitmap within a file opened +by gInitBit. The open file is referenced by handle while index indicates the position of the bitmap +within the file (relative to zero). The structure pointed to by psize is filled in with the size of the bitmap. + + +Returns zero if successful. + + +If an error (with error number err) occurs, the function calls p_leave (err) or returns, depending on +whether woisableLeaves has been called. + + +4-31 + + +WINDOW SERVER REFERENCE + + +wFree Close an open bitmap + + +VOID wFree(UINT handle) ; + + +In version 4 of the window server, if passed the handle referencing an opened bitmap file (as returned +from a call to ginitBit), the function closes the bitmap file but leaves loaded any bitmaps that came from +that file. + + +ginitMultiSave Initialise a multiple bitmap file +INT gInitMultiSave (TEXT *fname, INT count) ; + + +Available in version 4 of the window server, this function creates a file fname prepared to receive up to +count bitmaps. + + +The call returns a positive handle if the file was successfully opened and initialised. This handle should be +used in subsequent calls to gSaveMultiBit, gSaveMultiRect and gEndMultiSave. + + +Any errors generated by the filing system when creating the file will be returned (or leave called). In this +event, any file created will be deleted. + + +gSaveMultiBit Save a bitmap to a multi bitmap file +INT gSaveMultiBit (INT handle, INT bitmap) ; + + +Available in version 4 of the window server, this function attempts to save the bitmap with ID bitmap to +the initialised multiple bitmap file referenced by hand1e. If bitmap is zero, the screen is saved to the file. + + +The call returns zero if successful. + + +Any error generated by the filing system when writing to the file will be returned (or leave called) in the +same way as for gSaveBit. If an attempt is made to save more than the maximum permitted number of +bitmaps (set by the parameter count in the call to ginitMultiSave) the function will return +E_GEN_TOOMANY. + + +If the call fails (for whatever reason), the multiple bitmap file will be left in good condition and any +bitmaps already saved will still be accessible. However, any further attempts to save to the file will not be +allowed and it must be closed by a call to gzEnaMultiSave. + + +gSaveMultiRect Save part of bitmap to multi bitmap file +INT gSaveMultiRect (INT handle, INT bitmap, P_RECT *prect); + + +Available in version 4 of the window server, this function behaves in the same way as gSaveMultiBit. +However, only that part of the bitmap specified by the rectangle defined by prect is saved. + + +The call can fail for exactly the same reasons as gSaveMult iBit returning the same values. + + +gEndMultiSave End multiple bitmap save and close file +INT gEndMultiSave (INT handle) ; + + +Available in version 4 of the window server, this function ends the saving of bitmaps to a multiple bitmap +file referenced by handle and closes the file. + + +The call returns zero if successful. + + +Any error generated by the filing system when closing the file will be returned (or leave called). + + +ginquireChecksum Inquire screen or bitmap checksum +VOID gInquireChecksum(INT handle, UWORD *pchecksum) ; + + +Available in version 4 of the window server, this function calculates a checksum and places the value in a +UWORD pointed to by pchecksum. + + +handle references the object of the checksum operation and can be the ID of a bitmap or a backed-up +window. If handle is zero, the object of the checksum operation is the whole screen. + + +4-32 + + +4 GRAPHICS OUTPUT + + +Adding graphics output functions + + +The window server can be extended by building additional low-level graphics output services, that write +directly to the screen memory, into a dynamic link library (DYL). Such a DYL, when loaded using +wLoadDYL, effectively becomes part of the window server. + + +Note that the services described in this section are not suitable for loading and accessing any other type +of DYL. + + +Producing the window server extension DYL itself is an advanced topic and is not documented in this +Software Development Kit. At the time of writing, no such DYL exists. + + +A DYL that extends the window server must first be loaded by calling p_1oad1ib (described in the Object +Oriented Programming chapter in the PLIB Reference manual). It must then be loaded by the window +server using wLoadDYL. The services supplied by the DYL can then be accessed using wcalipyL and +wCallDYLReply. + + +wLoadDYL Load a DYL + + +INT wLoadDYL(TEXT *name) ; +Load the loaded window server extension DYL name into the window server. +The DYL should already have already been loaded into memory by a call to p_loadlib. + + +The parameter name is the DYL segment name (which is the same as the DYL file name, but does not +include the directory or the device). + + +Returns the ID of the DYL (to be used by wcalipyu and wcal1DyLReply). + + +Example + + +GLDEF_C UINT LoadWservDYL (VOID) +{ +f_leave(p_loadlib("C:\DYL\TEST.DYL", &test_dyl_handle, TRUE)); +return (wLoadDYL("TEST.DYL") ); +} + + +wCallIDYL Call a DYL function + + +VOID wCallDYL(UINT dyl_id, UINT class, UINT size_of_data, VOID *pdata); + + +Call a graphic function within the DYL ay1_id where class specifies which function within the DYL to +call (as specified by the builder of the DYL). + + +pdata points to the parameters to be passed to the DYL. + + +size_of_data 1s the number of bytes of data at paata. + + +wCallDYLReply Call a DYL enquiry function +INT wCallDYLReply(UINT dyl_id, UINT class, UINT size_of_data, VOID *pdata, VOID *presult) ; +Call an enquiry function within the DYL where the function called should not do any graphics output. +pdata points to the parameters to be passed to the DYL. + +size_of_data is the number of bytes of data at paata. + + +Returns the value returned by the DYL function (negative return values cause p_leave to be called, +positive values are returned normally). + + +The DYL function may also return a buffer of data, if it does presult should point to a buffer large +enough to hold the returned data. + + +4-33 + + +CHAPTER 5 + + +EVENTS + + +DS ew En a FS EF +Getting the next event + + +wGetEventWait Wait for an event + + +VOID wGetEventWait (WS_EV *event) ; + + +Wait for a window server event and return with the event type and parameters written to the ws_zv struct +at address event where ws_Ev is defined as: + + +typedef struct +{ +WORD type; +UWORD handle; +UWORD time; +WS_EVENT_UNION p; + + +} WS_EV; + +where: + +type is the positive event type of the form wu_xxxx + +handle For events that are directed at a window (eg wM_REDRAW, WM_MOUSBE), this is the +handle that was specified to wcreateWindow. For events that are not directed at +a window (eg WM_KEY, WM_FOREGROUND), it is set to the value specified to +wConnect. + +time is set by key and mouse events. It gives the low order word of the system tick +count (a tick is 1/32 of a second) when the event occurred. It may be used, for +example, to detect double clicks. + +Pp is a union of event type-dependent parameters + + +The ws_EVENT_UNION union is defined as: + + +typedef union +{ +UWORD uword; +UBYTE *dpoint; +P_RECT rect; +WMSG_KEY key; +WMSG_MOUSE mouse; +WMSG_RUBBER rubber; +WMSG_CAPS caps; +} WS_EVENT_UNION; + + +These event-specific parts are described under the description of the associated event type, in the course of +this chapter. + + +5-1 + + +WINDOW SERVER REFERENCE + + +wGetEvent Asynchronously request an event +VOID wGetEvent (WS_EV *event) ; + + +Request an event from the window server and return without waiting for the request to complete. This is +the asynchronous version of wGetEventWait. For more information on asynchronous events, see the +chapter Asynchronous Requests and Semaphores in the PLIB Reference manual. + + +Calling wGetEvent initially sets event->type to E_FILE_PENDING to indicate that no event has yet arrived. +When there is an event to deliver, the window server sets event->type to the event type and also sets the +rest of event as appropriate for event->type. It then signals the caller's I/O semaphore. + + +Only one wGetEvent may be outstanding at a time. The window server panics the process if a second +wGetEvent is called when one is already pending. + + +wGetEventSpecial Asynchronously request selected events +VOID wGetEventSpecial (WS_EV *event,UINT flags); + + +Introduced in version 4 of the window server, this is an enhanced version of the function wGetEvent, +where the flags parameter is used to select which type of event(s) the window server is to deliver. + + +There can only be one call outstanding to either wGetEvent or wGetEvent Special at any one time. + + +To change the type of event(s) selected in an outstanding wGetEvent or wGetEvent Special, use the +function wGetEventUpdate. + + +The following flags can be used to select the corresponding events. They can be ored together: + + +WE_KEY Selects key and task key events + +WE_REDRAW Selects wM_REDRAW events + +WE_STATUS Selects the WM_FOREGOUND, WM_BACKGROUND and WM_oN events + +WE_MOUSE Selects mouse and rubber band events + +WE_OTHERS Selects all events other than those listed above. + +WE_NORMAL Selects all of the above events + +WE_ESC This is only relevant when wE_KEy is not set. If the ESC key is pressed, the +keyboard buffer is thrown away and a wM_EScaAPE event is delivered to the +application. + + +Note that calling weetEvent Special with the we_Normat flag set is equivalent to calling wGetEvent. + + +wGetEventUpdate Change event types selected +VOID wGetEventUpdate(UINT flags); + + +Introduced in version 4 of the window server, this function modifies the type of event(s) that the window +server is to deliver where there is an outstanding wGetEvent or wGetEvent Special call. + + +The previously selected event type(s) are discarded and replaced with a new set as specified in the flags +parameter. The possible values for f1ags are the same as those described in wGetEvent Special. + + +Note that if there is no outstanding call to either wGetEvent or wGetEvent Special then calling +wGetEventUpdate will have no effect. + + +5-2 + + +5 EVENTS + + +Event types +This section describes event types that are common to more than one machine type. +The following descriptions assume that event is declared as: + + +WS_EV event; + + +WM_KEY Key press event + + +Sent when a key is pressed where the key press is described by the wasc_xey struct event.p.key where +wMsG_kEy is defined as: + + +typedef struct +{ + + +UWORD keycode; /* Code for the key pressed */ +UBYTE modifiers; /* State of mouse button, shift keys etc */ +UBYTE count; /* Used to accumulate auto-repeat counts */ + + +} WMSG_KEY; +Count +For single key presses, event .p.key.count is l. + + +If a key is held down, count will get to be greater than | when the client is unable to process keys at the +rate at which the system generates repeated keys. + + +As described in the Keyboard input section of the first chapter, application programmers are best advised +just to ignore the repeat count. + + +Modifiers + + +event .p.key.modifiers is a Set of bit flags: + + +W_SHIFT_MODIFIER SHIFT key down +(0x02) + +W_CTRL_MODIFIER CTRL key down +(0x04) + +W_PSION_MODIFIER PSION key down +(0x08) + +W_CAPS_MODIFIER caps lock on +(0x10) + + +W_NUM_LOCK_MODIFIER num lock on (MC only) +(0x20) + + +Keycode + + +When a "standard" key that represents a character from the SIBO character set! is pressed, + +event .p.key.keycode contains the character code of the corresponding character in the range 0x20 to +(nominally) oxt£ but excluding ox7£. The actual upper limit on the code which can be directly produced +from the keyboard is less than oxfr and depends on what language (eg French, German) the keyboard is +produced for. + + +The SHIFT and CAPS LOCK keys modify the keycode following the normal conventions and as suggested by +the labelling of the key. + + +In most cases on the HC and MC and for those keys that are used as accelerators on the S3 and S3a, the +PSION shift key produces a keycode that is generated by adding 0x200 (w_spEcIAL_kEy) to the unshifted +keycode with caps lock off. For example, pressing PSION+A with or without CTRL and SHIFT and regardless +of the caps lock state produces a keycode of 0x261 (the code for lower case 'a' plus w_SPECIAL_KEY). + + +'Similar to IBM's code page 850 - see the section Text Fonts in the first chapter. + + +WINDOW SERVER REFERENCE + + +On machines which have a CTRL key (that is, excluding the HC), you can generate any keycode from 0x00 +to 0xff indirectly by holding down the CTRL key and typing the required code as a 3-digit decimal number +(using leading zeros as necessary). In this case, a single key event is generated after the third decimal +number is pressed. Also, following normal conventions, pressing CTRL-A to CTRL-Z produces a keycode + + +from 0x01 to Oxia. + + +Many of the keys do not represent printable characters from the SIBO character set (these keys are +sometimes called "special keys"). Such keys generate a keycode which is either less than 0x20, 0x7f or + + +greater than Oxff. + + +The following lists the key codes produced by the special keys: + + +W_KEY_TAB (0x9 or +"\t') + + +W_KEY_DELETE_LEFT +(0x08 or '\b') + + +W_KEY_DELETE_RIGHT +(Ox7£) + + +W_KEY_RETURN (0x0d + + +or ' Nx) + + +W_KEY_ESCAPE (0x1b) + + +W_KEY_UP (0x100) + + +W_KEY_DOWN (0x101) + + +W_KEY_RIGHT (0x102) + + +W_KEY_LEFT (0x103) + + +W_KEY_PAGE_UP + + +(0x104) + + +W_KEY_PAGE_DOWN + + +(0x105) + + +W_KEY_HOME (0x106) + + +W_KEY_END (0x107) + + +W_KEY_TASK (0x108) + + +W_KEY_VOICE (0x109) + + +5-4 + + +Produced by TAB, with or without SHIFT or CTRL. On the HC and MC only, the +PSION key adds w_sPECIAL_KEY. On the Workabout, the PSION key (but not +SHIFT+PSION) converts the keypress to W_KEY_TASK. + + +Produced by DEL on the HC, DELETE with or without CTRL or PSION on the S3 +and $3a, BACKSPACE with or without SHIFT or CTRL on the MC, and DEL +without SHIFT on the Workabout. On the HC and MC, the PSION key adds +W_SPECIAL_KEY. + + +Produced by SHIFT+DEL on the HC and Workabout, SHIFT+DELETE on the $3 +and S3a, DELETE with or without SHIFT or CTRL on the MC. On the MC only, +the PSION key adds w_sPECIAL_KEY. + + +Produced by ENTER, with or without SHIFT or CTRL. On the HC and MC only, +the PSION key adds w_sPECIAL_KEY. + + +Produced by ESC, without SHIFT or CTRL on the Workabout; with or without +SHIFT or CTRL on all other machines. On the HC and MC only, the PSION key +adds w_SPECIAL_KEY. + + +Produced by UP ARROW, with or without SHIFT or CTRL. On the HC and MC +only, the PSION key adds w_SPECIAL_KEY. + + +Produced by DOWN ARROW, with or without SHIFT or CTRL. On the HC and MC +only, the PSION key adds W_SPECIAL_KEY. + + +Produced by RIGHT ARROW on the HC, RIGHT ARROW with or without SHIFT or +CTRL on the $3, S3a, Workabout and MC. On the HC and MC only, the PSION +key adds w_sPECIAL_KEY. + + +Produced by LEFT ARROW on the HC, LEFT ARROW with or without SHIFT or +CTRL on the $3, S3a, Workabout and MC. On the HC and MC only, the PSION +key adds Ww_SPECIAL_KEY. + + +Produced by PSION+UP ARROW on the $3, S3a and Workabout, PAGE UP with or +without SHIFT or CTRL on the MC. On the MC only, the PSION key adds +W_SPECIAL_KEY. + + +Produced by PSION+DOWN ARROW on the $3, S3a and Workabout, PAGE DOWN +with or without SHIFT or CTRL on the MC. On the MC only, the PSION key adds +W_SPECIAL_KEY. + + +Produced by PSION+LEFT ARROW on the $3, S3a and Workabout, HOME with or +without SHIFT or CTRL on the MC. On the MC only, the PSION key adds +W_SPECIAL_KEY. + + +Produced by PSION+RIGHT ARROW on the $3, S3a and Workabout, END with or +without SHIFT or CTRL on the MC. On the MC only, the PSION key adds +W_SPECIAL_KEY. + + +Produced by SHIFT+LEFT ARROW (TASK) on the HC, TASK with or without SHIFT +or CTRL on the MC and PSION+TAB on the Workabout. On the MC only, the +PSION key adds W_SPECIAL_KEY. + + +Normally processed by the window server to switch the foreground task and not +passed to clients. However, you can use wCaptureKey to capture the W_KEY_TASK +key (as described under wcaptureKey). + + +Produced by RECORD with or without SHIFT or CTRL on the MC only. The PSION +key adds w_sPECIAL_KEY. + + +W_KEY_CAPS_LOCK +(0x10c) + + +W_KEY_BACKLIGHT +(0x120) + + +W_KEY_INFO (0x121) + + +W_KEY_MENU (0x122) + + +W_KEY_HELP (0x123) + + +W_KEY_DIAMOND +(0x124) + + +W_KEY_APP1 to + + +W_KEY_APP8 (0x131 to + + +0x138) + + +W_KEY_MODE (0x130) + + +W_KEY_LCD (0x2000) +W_KEY_LCD_MINUS +(0x2001) + + +W_KEY_ON (0x2002) + + +5 EVENTS + + +Produced by CAPS LOCK on the $3 and MC, by PSION+DIAMOND on the S3a and +by PSION+SPACE on the Workabout. + + +This key press is processed by the operating system to set the caps lock state +and passed to the window server on the $3, S3a and MC (but not on the HC). +On the MC, the window server generates a wM_KEYBOARD_STATE_CHANGE event +to the shell. The window server does not normally pass it on to the foreground +client. You can use wcaptureKey to capture the w_KEY_cAPs_LOocK key. + + +Produced by the BACKLIGHT key with or without SHIFT on the HC and the +Workabout. On the HC only, the PSION key adds w_spECIAL_KEY. + + +This key is normally processed by the operating system although you can +disable it by calling p_setbacklight as described in the General System +Services section of the PLIB Reference manual. The key is normally passed +through to the foreground client (unless captured by a client using +wCaptureKey). + + +Produced by SHIFT+RIGHT ARROW (INFO) on the HC only. + + +Produced by MENU with or without SHIFT on the HC and by MENU with or +without SHIFT, CTRL or PSION on the S3, S3a and Workabout. On the HC only, +the PSION key adds w_spEcIAL_KEY. + + +If wsEnableTemp has been called, the window server processes PSION+MENU to +present a temporary status window (in which case it does not pass the key press +on to the client). By convention on the S3 and S3a, CTRL+MENU is processed by +clients to present a permanent status window. + + +Produced by HELP with or without SHIFT, CTRL or PSION on the S3 and S3a, and +by ESC with either SHIFT or CTRL, but not PSION, on the Workabout. + + +As suggested by the S3/S3a key labels, PSION+HELP on these machines should +be interpreted as a DIAL key. + + +Produced by DIAMOND on the S3a only. Used by applications to switch from one +mode to another. + + +Produced by the 8 membrane keys on the S3 from left to right (also called +application keys). + + +These are normally handled by the window server in co-operation with the +system task. For more information, see the section on Clients and the Window +Server in the Introduction chapter of this manual. + + +Produced on the S3 only when the application key that is associated with the +foreground application is pressed. Applications normally cycle through their +display modes in response to this key event. + + +Produced by DIAMOND on the S3a when running in S3 compatibility mode. + + +Produced by the LCD BRIGHTER and LCD DIMMER keys on all machines except +the Workabout. On the Workabout the single LCD BRIGHTER key produces +W_KEY_Lcp only, and SHIFT+LCD BRIGHTER is used to dim the LCD. + + +These keys are processed by the operating system rather than the window server +so you can't use wCaptureKey to disable them. These keys are normally passed +through to the foreground client. + + +Produced on an HC with version 3.5 of the window server, and on the S3, S3a +and Workabout when the ON key is pressed. + + +Also, when the machine switches on for any reason (such as the expiry of an +absolute timer) the operating system manufactures an w_KEyY_on event to the +window server?. + + +2On the HC, the window server is only informed of the machine being switched on after +p_setonevent (TRUE) has been called. + + +5-5 + + +WINDOW SERVER REFERENCE + + +This event is normally processed by the window server to: + + +1. pass a WM_ON event to the foreground client (provided it has called +wiInformOn) or, in version 4 of the window server, pass a WM_ON event +to a client whether it is in foreground or background (provided it has +called wInformonAll (TRUE) ) + + +2. present an info message to inform the user of any low battery state? +3. to present the password alert if a password has been set. + + +When processed by the window server, the w_KEY_on event is not passed to the +foreground client. + + +You can use wCaptureKey to capture the w_KEy_oNn key. This will disable all +window server processing of this event. + + +W_KEY_OFF (0x2003) Produced by the OFF key on the HC, $3, S3a and Workabout only. + + +Normally processed by the window server to turn the machine off and not +passed to clients. However, you can use wCaptureKey to capture the OFF key (as +described under wcapturekey). The capturer can turn the machine off by +calling p_off - as described in the General System Services section of the PLIB +Reference manual. (The same section also describes p_setauto which can be +used to stop the machine from automatically switching off.) You don't get a +W_KEY_OFF event when the machine automatically switches off. + + +WM_REDRAW Redraw event (WM + + +Sent when the client's event queue is empty and one or more windows has an update region. + + +The parameter event .p.rect describes a rectangular block of pixels from the update region (and which +needs to be redrawn). + + +The only event type that has a lower priority than wM_REDRAW is WM_USER_MSG. + + +WM_BACKGROUND Background event + + +Sent to a foreground client when it goes background. +Only event.type is set. + + +On all machines except the MC, you generally do not need to do anything when you receive a +WM_BACKGROUND event. However, if you are doing anything that requires real-time input from the user (a +game, for example) or you are doing an animated display, you should suspend the operation until you +receive a WM_FOREGROUND event. + + +WM_FOREGROUND Foreground event + + +Sent to a background client when it becomes foreground. + + +Only event.type is set. + + +WM_CANCELLED Cancellation event + + +Sent in response to a call to wcancelGetEvent command - see the description of wcancelGetEvent in this +chapter. + + +Only event.type is set. + + +3See also the description of the wsERV_FLAG_LOW_BATTERY_WARNINGS flag in wsystem. + + +5-6 + + +5 EVENTS + + +WM_USER_MSG User message event + + +Sent in response to a call to wusermsg. This event has the lowest priority of all and can be used to indicate +that the window server has no more messages to send - see the description of wuserMsg in this chapter. + + +Only event .type is set. + + +WM_ON Machine switched on event + + +Available in version 3.5 of the window server; if the client has called wrnformon, it is sent this event when +the machine is switched on and it is in foreground. + + +The event is designed to prompt the foreground client to update its display. + + +On the HC, the window server is only informed of the machine being switched on after +p_setonevent (TRUE) has been called. + + +In version 4 of the window server, if the client has called winformonAll (TRUE), it is sent this event when +the machine is switched on, whether it is in foreground or background. + + +Only event .type is set. + + +WM_COMMAND Command received from another client + + +This is sent in response to a wSendCommana from another client to prompt the receiver of the event to call +wGetCommand to get the command data. It is only available in version 3.5 of the window server. + + +Only event .type is set. + + +WM_TASK_UPDATE Inform shell of process termination + + +Sent to the shell if it is foreground and any process terminates (not just clients of the window server). + + +Available only on the $3, $3a and Workabout, and on an HC running version 3.5 upwards of the window +server. Disabled by default on the HC - see the description of wsystem. + + +Only event .type is set. + + +WM_TASK_KEY Inform application key handler + + +Sent to the application key handler when: +e an application key is pressed and no process of that application exists +e a PSION shifted application key is pressed + +Applies only to the S3, S3a and Workabout. + + +The index of the application key in the range 0 to 15 is written to event.p.key. keycode. The window +server handles 16 application keys, where a second set of 8 keys are accessed by holding down the +CONTROL key. + + +WM_DATE_CHANGED Change of date event + + +Introduced in version 4 of the window server. Sent whenever the date changes, either because the date has +en reset or the clock has gone past midnight. + + +The message is sent to any Series 3a or Workabout application which is not in Series 3 compatibility +mode and is in foreground at the time of the event + + +Non compatibility mode applications which are in background will receive the message the next time they +come into foreground. + + +If the machine is off at the time of the event, the message is delivered when the machine is next turned on. + + +WINDOW SERVER REFERENCE + + +WM_ESCAPE Escape-key event + + +In version 4 of the window server, this message is delivered to an application when the ESC key is pressed +in the following circumstances: + + +e =The application must have asynchronously requested selected events by calling +wGetEventSpecial. + + +e Among the events selected for delivery, WZ_EVENT_ESC must be included but wE_EVENT_KEY must +be excluded. + + +In this situation, the content of the keyboard buffer is discarded. + + +Large screen events + + +The event types in this section are only generated on large screen versions of the window server, such as +on the MC200 and MC400 machines. + + +WM_DEICONISE Deiconisation event + + +Sent to a client to tell it to deiconise. The client will have previously declared itself iconised with a +wClientIconised call. + + +Only event .type Is set. +A client receives this message when another client calls wclientPosition to position it to the foreground. + + +It is also sent to the system application (sys$shll.img) when it is iconised and selected by the PSION-TASK +key press. + + +WM_ATTACHED Attachment event + + +Sent to a client to tell it another client has attached itself on top of it. The uword field of the +WS_EVENT_UNION structure is set to the process ID of attached client. After receiving this message the +client will not be able to receive wM_KEyY events until the attached client detaches, terminates or +disconnects from the window server. + + +Only event.type is set. + + +A client will receive a WM_ATTACHED event when the notifier process (sys$nt fy) attaches itself to the +foreground client when any process calls p_notify or p_notifyerr. + + +WM_DETACHED Detachment event + + +Sent to a client when a previously attached client detaches (either by a wDetachClient call, by terminating +or by disconnecting from the window server). + + +Only event .type is set. + + +WM_KEYBOARD_STATE_CHANGE Keyboard state change event + + +This event is only ever sent to the system application (sys$shll.img). It is sent when either the numlock or +capslock state changes. The new states of these can be read from event .p.caps.modifiers. + + +5 EVENTS + + +a EEEEEEEEEOEOEOEeEeEeEeEeseseseeess +Mouse events + + +The event types in this section are only generated on machines with a pointing device, such as on the +MC200 and MC400. + + +WM_MOUSE Mouse event + + +Sent when ever there is a change of state on the mouse (digitiser). +The wmsc_mouse structure is defined as: + + +typedef struct +{ +UBYTE event; /* type of mouse event */ +UBYTE state; /* state of mouse button, shift keys etc */ +P_POINT pos; /* mouse position (relative to window) */ +} WMSG_MOUSE; + + +event .p.mouse.event gives the type of the mouse event that occurred and is one of: + + +WM_MOUSE_MOVE mouse movement event (this is filtered out by default) +WM_MOUSE_PRESS mouse press event +WM_MOUSE_RELEASE mouse release event + + +Mouse movement events (wmM_MousE_move) are filtered out unless explicitly enabled, on a per-window +basis. See wcreateWindow and wSetWindow for details. + + +event .p.mouse.state gives the state of the mouse and the key modifiers when the event occurred, it may +be tested using the bit masks: + + +W_MOUSE_DOWN mouse button down + +W_MOUSE_OUTSIDE mouse event occurred outside window +W_SHIFT_MODIFIER SHIFT key down + +W_CTRL_MODIFIER CTRL key down + +W_PSION_MODIFIER PSION key down + +W_CAPS_MODIFIER Caps lock on + + +W_NUM_LOCK_MODIFIER Num lock on + + +The w_mMousE_ouUTSIDE bit is set when a mouse event occurs outside the visible portion of the given +window. This can happen when either: + + +a window has grabbed the mouse, by specifying the w_wIN_mMousE_GRAB bit, WM_MOUSE_RELEASE +events are sent to the same window that received the wm_MousE_PRESS event, even if the mouse +has subsequently moved outside the visible portion of the window. + + +or: +a window has captured the mouse by calling wcaptureMouse. + + +Testing the w_mousk_ouTSIDE bit is not equivalent to checking the mouse position against the extent of the +window, because a client can never know if part of the window has been obscured. + + +WM_RUBBER_BAND INIT Start rubber band + + +This is a special version of the wu_mousE message, it also uses the wmsc_mouseE Structure. It is sent instead +of a wM_MousE event when a mouse press occurs inside a window with the w_wIN_RUBBER_BAND_CAPTURE +flag set. + + +See the Rubber Band section for details. + + +WINDOW SERVER REFERENCE + + +WM_RUBBER Complete rubber band + + +Sent on completion of a rubber band. + + +See the Rubber Band section for details. + + +WM_ ACTIVE Activation event + + +Sent to a window that has previously set the w_wIN_INacTIVE bit (in a call to wcreat eWindow or +wSetWindow) whenever a WM_MOUSE event of type WM_MOUSE_PRESS is sent to the window or any of its +descendants. + + +Only event .type is set. + + +WM_ACTIVE notifies a parent that the mouse has clicked somewhere in its window tree. The wm_mousE event +is then sent straight to the window where the click occurred (unless that window has the w_wIN_No_MoUSE +bit set). + + +If a window and its descendant both have the w_w1n_1NacTIVE bit set, they both receive a WM_ACTIVE event +if there is a click in a descendant of the descendant window. + + +SSS SSS SS — SS ——————————e +Event functions + + +wCancelGetEvent Request a cancel event +VOID wCancelGetEvent (VOID) ; +Instruct the window server to send the caller a WM_CANCELLED event. + + +After a call to wcancelGetEvent, the window server delivers the w4_CANCELLED event at the highest +priority - any other events waiting in the window server client event queue are overtaken. + + +wUserMsg Request a user event +VOID wUserMsg (VOID) ; +Instruct the window server to send the client a w“_USER_MsG as soon as it has no other event to report. + + +A second call to this function before the first w1_usER_msc is delivered will have no effect. + + +wSendCommand Send a command to another client +INT wSendCommand(HANDLE pid, VOID *pbuf, UINT len); +Send the 1en bytes of data at pbuf to the window server client with process ID pia. + + +If the call is successful, the function returns zero and client pid will receive a wM_COMMAND event to which +it should respond by calling wGet command (as described below). + + +If no client with process ID pid exists, the function leaves or returns with the error number E_FILE_NXIST. + + +The function can be used to send up to 127 bytes. If 1en is | or 2, the function does not allocate any +memory. If 1en is greater than 2, the function could leave or return with the error number +E_GEN_NOMEMORY. + + +Only available in version 3.5 and upwards of the window server. + + +5-10 + + +5 EVENTS + + +wGetCommand Get a command from another client + + +INT wGetCommand (VOID *pbuf) ; + +Write to pbuf, the command data that was last sent to this process (with a call to wsendcommand). +This function should be called in response to the receipt of a wa_commanp event. + +There should be at least 127 bytes of memory at pbuf. + + +If another command is sent to the client before it has read the old command, the old command is +overwritten with the new data. + + +The function behaves as for wcheckPoint in that it flushes the client-side buffer and reports any uncleared +error - either by calling p_ieave or by returning the error number. + + +Only available in version 3.5 and upwards of the window server. + + +winformOn Enable the reception of WM_ON events +VOID wInformOn (VOID) ; + +Enable the reception of a wu_on event when the machine is switched on. + +The window server only sends a wy_on event to the foreground client. + + +On the HC, the window server is only informed of the machine being switched on after +p_setonevent (TRUE) has been called (normally by the shell). + + +Only available in version 3.5 and upwards of the window server. + + +winformOnAll Enable/disable the reception of WM_ON events + + +VOID wInformOnAll(UINT state); + + +Available in version 4 of the window server, this function is similar to wInformon. However, there are +some subtle differences. + + +If state is TRUE, it enables the reception of wu_on events; on the other hand, if state 1s FALSE, it disables +the reception of wm_on events. + + +When enabled by this call, wu_on events are delivered whenever the machine is switched on, regardless of +whether the calling client is in foreground or in background. + + +Disabling wu_on events with this call disables the reception of wu_on events regardless of whether they +were originally enabled by a call to wInformonall Or wInformon. + + +Capturing keys + + +wCaptureKey Capture a key +INT wCaptureKey(UINT keycode, UINT modifiers, UINT modifier_mask) ; +Send the specified key press(es) to the calling client, whether it is foreground or not. +Every time a key is pressed the window server evaluates +(key_pressed_code==keycode) && ((key_pressed_modifiersé&émodifier_mask) ==modifiers) +and if the result is TrRuz then the keyboard event is sent to the client that specified the capture. +For example: +wCaptureKey (W_SPECIAL_KEY|'a',W_PSION_MODIFIER, W_PSION_MODIFIER) ; +captures PSION+A, PSION+SHIFT+A, PSION+SHIFT+CTRL+A, and PSION+CTRL+A. Whereas: +wCaptureKey (W_SPECIAL_KEY| 'a',W_PSION_MODIFIER, W_PSION_MODIFIER|W_SHIFT_MODIFIER) ; + + +captures PSION+A and PSION+CTRL+A. + + +5-11 + + +WINDOW SERVER REFERENCE + + +Note from the above that it is possible for two different but similar key/modifier combinations to capture +the same key presses. This is significant if the two calls to wcapturekey came from different clients. +Where two key capture records select the same key press, the key event is delivered to the first client to +call wCaptureKey. + + +The function is useful for implementing "hotkeys" which select a particular task. However, you should +only capture relatively obscure key combinations which are not normally used by the tasks themselves +(capturing the unmodified A key, for example, would be disastrous). + + +The function returns zero if successful. Errors include E_GEN_NomeEmory and, if there is already a capture +record with a matching keycode, modifiers and modifier_mask (even as a result of a wcaptureKey from +another client), E_FILE_Ex1stT. The function either leaves or returns the error, depending on whether +wDisableLeaves has been called. + + +The window server automatically cancels any calls a client has made to wcaptureKey when that client +disconnects or terminates. + + +On an HC, an application can disable the window server's processing of the TASK key by capturing it with: +wCaptureKey (W_KEY_TASK,0,0); + + +Not available in version 2 of the window server. + + +wCancelCaptureKey Cancel key capture +INT wCancelCaptureKey(UINT keycode, UINT modifiers, UINT modifier_mask) ; + + +Cancel a key capture set up by wcapturekey, the keycode and masks must exactly match those used to +initiate the capture. + + +The function returns zero if successful. If the keycode/modifier combination is not marked as captured +then the function will leave or return E_FILE_NxIST. + + +Not available in version 2 of the window server. + + +Setting task switch keys + + +wSetTaskKey Set a task switch key +INT wSetTaskKey(UINT keycode, UINT modifiers, UINT modifier_mask) ; + + +Set the specified keypress(es) to move the foreground client to the end of the task list and bring the client +previously at position | (where the foreground process has position zero) to the foreground. + + +As for captured keys, every time a key is pressed the window server evaluates +(key_pressed_code==keycode) && ((key_pressed_modifiersémodifier_mask) ==modifiers) +and if the result is TRUE, the tasks are cycled. + + +The effect of setting the task key does not cease when the calling client disconnects or terminates. The +only way to stop the key press from being a task key is to call wcancelTaskKey. + + +Any number of task switch keys may be set. On the HC and MC, these operate in addition to the +W_KEY_TASK key (unless the w_KEy_TAs«K key has been captured). + + +The function returns zero if successful. If there is already a set task key record with a matching keycode, +modifiers and modifier_mask, the function leaves or returns E_FILE_EXIST. It can also fail with +E_GEN_NoMEmoRY. If there is already a capture record with a matching keycode, modifiers and +modifier_mask, the capture key record is cancelled and replaced by the task key record. + + +The shell on the S3 and S3a calls wSet TaskKey to assign SHIFT+SYSTEM as a task key. + + +Only available in version 3.5 upwards of the window server. + + +5-12 + + +5 EVENTS + + +wCancelTaskKey Cancel a task switch key +INT wCancelTaskKey(UINT keycode, UINT modifiers, UINT modifier_mask) ; +Cancel a task key setting, set up with wset TaskKey. + + +The function returns zero if successful. If the keycode/modifier combination is not marked as a task key +then the function will leave or return £_FILE_NXIST. + + +wSetBackTaskKey Set a back task switch key +INT wSetBackTaskKey(UINT keycode, UINT modifiers, UINT modifier_mask) ; + +Set the specified keypress(es) to bring the client furthest from the front to the foreground. + +Except that it cycles tasks in the opposite direction, wSetBackTaskKey is identical to wset TaskKey. + + +The shell on the S3 and S3a calls wsetBackTaskKey to assign SHIFT+PSION+SYSTEM to the "back-task" key +which brings the task furthest from the front to the foreground. + + +wCancelBackTaskKey Cancel a back task switch key +INT wCancelBackTaskKey (UINT keycode, UINT modifiers, UINT modifier_mask) ; +Cancel a back task key setting, set up with wSetBackTaskKey. + + +The function returns zero if successful. If the keycode/modifier combination is not marked as a back task +key then the function will leave or return E_FILE_NXIST. + + +Capturing the mouse + + +wCaptureMouse Capture the mouse + + +VOID wCaptureMouse(UINT wid); + + +Capture the mouse within window wid and all its descendants. This function does not capture with +respect to other clients' windows. + + +It is used, for example, by the dialog box that allows the user to click on it or any of its constituent +windows, but ignores clicks to other windows in the application (ie the menu bar and the application's +client window). + + +If mouse capture is already active in another window then the previous capture will be cancelled before +the new capture is activated. + + +If a window with capture is destroyed the mouse is automatically released. + + +wReleaseMouse Release the mouse + + +VOID wReleaseMouse (VOID) ; + + +Cancel the mouse capture, does nothing if there was no capture active. + + +WINDOW SERVER REFERENCE + + +The rubber band + + +The rubber band is only implemented on machines with a pointing device, such as on the MC200 and +MC400. + + +wRubberBand Rubber banding + + +VOID wRubberBand(UINT msg_window, UINT band_window, W_RUBBER_BAND *prubber) ; + + +Start the rubber band and return immediately where the result is returned later as a WA_RUBBER event +(which might just indicate that the parameters are illegal). + + +msg_window is the ID of the window to which the wM_RUBBER event will be sent. + + +band_window is the ID of the window in which the rubber band will be drawn, it is usually set to zero (the +whole screen). + + +The rubber band is displayed as specified by the w_RUBBER_BAND struct at address prubber where +W_RUBBER_BAND is defined as: + + +typedef struct +{ + + +P_EXTENT start; /* initial size and position */ +P_EXTENT outer; /* outer bounding rectangle */ +P_EXTENT inner; /* inner bounding rectangle */ +UWORD flags; + +UWORD minx; /* max and min size limits */ + + +UWORD miny; + +UWORD maxx; + +UWORD maxy; + +P_POINT grid_snap; /* x and y grid snap values */ +} W_RUBBER_BAND; + + +If flags is set to zero then the following default values will be used: + + +resizing Disabled. + +minx Not applicable when resizing disabled. +miny + +maxx + +maxy + +start The extent of msg_window. + +outer No outer bounds. + +inner The visible extent of band_window. +grid_snap (1,1) in the x and y directions. +complete on release Disabled. + + +Each of these defaults may be overridden by setting the following bits in flags: + + +W_BAND_RESIZE enables resizing of the rubber band, if this is selected the rubber band will +appear on screen with its resize triangles, if resizing is disabled the rubber +band appears as a rectangle. When resizing is enabled then minx, miny, maxx +and maxy (which determine the maximum and minimum sizes of the rubber +band) must be set. + + +W_BAND_START sets the start position and size to start. If this conflicts with inner, outer or +the maximum or minimum size limits then it will be modified appropriately. + + +W_BAND_INNER sets the inner rectangle to inner. The movement of the rubber band is +restricted such that part of the rubber band stays within this rectangle. + + +W_BAND_OUTER sets the outer rectangle to outer. The movement of the rubber band is +restricted such that no part of the rubber band extends outside this rectangle. + + +5-14 + + +5 EVENTS + + +W_BAND_GRID_SNAP sets the grid snap values to grid_snap. The rubber band will move/resize in +steps of grid_snap. + + +W_BAND_GRID_SNAP_SIZE aS for W_BAND_GRID_SNap except that only the size of the rubber band (and not +its position) is grid snapped. + + +W_BAND_COMPLETE_ON_UP causes the rubber band to complete on the first mouse up event. +The values in start, outer and inner are all relative to band_window. + + +If there is no legal position for the rubber band then the rubber band completes immediately with a +WM_RUBBER message with the state set to ww_BAND_ERROR. This could happen (say) if minx is greater than +maxx Or if inner does not intersect with outer. + + +WM_RUBBER events + + +The window server sends a wM_RUBBER message when the rubber banding completes. The format of the +WM_RUBBER message is: + + +typedef struct +{ +UWORD state; /* completion state */ +P_EXTENT extent; /* the selected extent */ +} WMSG_RUBBER; + + +Sstate is set to one of the following: + + +WM_BAND_NOMOVE the band position was selected without any moving or resizing, extent is the +same as set in wRubberBand. + + +WM_BAND_MOVE the rubber band moved but did not change size. extent is set to the new +position and the old height and width. + + +WM_BAND_RESIZE the rubber band has been resized (and perhaps also moved). extent contains +the new position and size. + + +WM_BAND_CANCEL the rubber band was cancelled. extent is undefined. +WM_BAND_ERROR the rubber band was not displayed because of illegal parameters in +wRubberBand. + + +Capturing mouse and keyboard events + + +The flag w_wIN_RUBBER_BAND_CAPTURE USed in the wSetWindow and wcreateWindow commands can be +used to capture all mouse and keyboard events to the rubber band from the moment the mouse was pressed +in the specified window. The first click in the window will be sent to the window as a +WM_RUBBER_BAND_INIT event and held in a buffer as a wu_mouse event (of type wM_MOoUSE_PRESS). +Subsequent mouse and keyboard events will also be buffered. When the rubber band becomes active it will +receive all the buffered events. The capture is cancelled on completion of the rubber band. + + +When a client receives a WM_RUBBER_BAND_INIT event it MUST call wRubberBand immediately. This is +because all clients will have all their mouse events and keys blocked. If the client decides that it does not +want to launch a rubber band then it should set the w_sanp_KILL_capTurE flag in flags and call +wRubberBand, this will cancel the mouse capture without actually launching a rubber band (all parameters +in the w_RUBBER_BAND Structure are ignored except that msg_window must be a valid window ID). + + +5-15 + + +CHAPTER 6 + + +WINDOW SERVER REFERENCE UPDATE + + +This document is a beta version and may be subject to change. + + +This chapter describes the changes and additions that have been made to the Window server as a result of +the introduction of the Siena and Series 3c machines into the SIBO range. + + +Note: Siena was codenamed Vine by Psion during development, hence the naming of some of the +constants given below. + + +Screen sizes + + +The true screen and pixel dimensions of the various LCD screens on all SIBO machines are as follows: + + +Machine type Screen Pixel pitch Pixel size Screen size Screen size +(pixels) (mm) (mm) (cm) (in) +HC 160x80 0.34x0.43 0.31x0.40 5.44x3.44 2.14x1.35 +S3 240x80 0.385x0.43 0.355x0.40 9.24x3.44 3.64x1.35 +Workabout 240x100 0.26x0.30 0.23x0.27 6.24x3.00 2.45x1.18 +Siena 240x160 0.25x0.25 0.23x0.23 6.00x4.00 2.36x1.57 +S3a 480x160 0.259x0.259 0.20x0.20 12.477x4.156 4.915x1.637 +S3c 480x160 0.26x0.26 0.20x0.20 12.478x4.158 4.915x1.637 +MC200 640x200 0.33x0.33 0.30x0.30 21.12x6.60 8.31x2.60 +MC400 640x400 0.33x0.33 0.30x0.30 21.12x13.20 8.31x5.20 + + +In the above table, the horizontal measure is shown before the vertical measure. The pixel pitch measures +the horizontal and vertical distance between the same points on adjacent pixels. The difference between +the pixel size and the pixel pitch gives the gap between pixels. + + +The Series 3c and the Siena screens support the use of grey in exactly the same way as for the Series 3a. + + +Keyboard + + +Except where stated below, the keycodes produced on the Series 3c and the Siena are identical to those +produced on the Series 3a. + + +The following table lists the additional and/or modified key codes produced by the special keys on the +Siena and the Series 3c, as listed in wskeys.h: + + +W_KEY_TAB (0x9 or Produced by TAB, with or without SHIFT or CTRL. On the HC and MC only, the +"\t') PSION key adds w_spEcIaL_kEy. On the Workabout, the PSION key (but not +SHIFT+PSION) converts the keypress to Ww_KEY_TASK. + + +On the Series 3c, the PSION key (including SHIFT+PSION) converts the keypress +tO W_KEY_IR_LINK (0x142). + + +6-1 + + +WINDOW SERVER REFERENCE + + +W_FUNC_MODIFIER +(0x80) + + +W_KEY_APP1 to +W_KEY_APP9 (0x131 to +0x139) + + +W_KEY_IR_BRING +(0x140) + + +W_KEY_IR_SEND +(0x141) + + +W_KEY_IR_LINK +(0x142) + + +W_KEY_CALC_CLEAR +(0x01b) + + +W_KEY_CALC_MEM_CLEAR +(0x150) + + +W_KEY_CALC_MEM_RECAL +L (0x151) + + +W_KEY_CALC_MEM_ MINUS +(0x152) + + +W_KEY_CALC_MEM_ PLUS +(0x153) + + +W_KEY_CALC_CHNG_SIGN +(0x154) + + +W_KEY_CALC_PERCENT +(0x155) + + +W_KEY_CALC_DECIMAL +(0x156) + + +W_KEY_CALC_MEM_INPUT +(0x158) + + +W_RUSSIAN_MODIFIER +(0x1000) + + +6-2 + + +On the Siena only, an FN modifier key is provided that produces this additional +modifier code. + + +Note that the same value is used for Mouse Down (w_mousE pown) on the Psion +MC range of machines. + + +On the Series 3 and Series 3a, key codes w_kEY_APP1 tO W_KEY_APP8 are +produced by the eight membrane keys (also called application keys) in order, +from left to right. + + +The Series 3c has a ninth membrane key, on the extreme right, that produces +W_KEY_APP9. + + +On the Siena only, this key code is produced by the IR receive key. + + +On the Siena only, this key code is produced by the IR send key. + + +On the S3c only, this key code is produced by the PSION + TAB key combination. + + +On the Siena only, this key code is produced by the ON/CE key. + + +On the Siena only, this key code is produced by FN + the ‘3’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by FN + the ‘2’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by FN + the ‘-’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by FN + the ‘+’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by FN + the ‘.’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by FN + the ‘=’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by the ‘.’ key on the numeric +keypad. + + +On the Siena only, this key code is produced by FN + the ‘1’ key on the numeric +keypad. + + +On the Russian variant Series 3a and Series 3c only, (for Psion internal use +only). + + +6 WINDOW SERVER REFERENCE UPDATE + + +Status windows +Series 3c + + +Status windows on the Series 3c are functionally identical to those on the Series 3a. Some minor cosmetic +changes have been made, including a new analog clock design for the wide status window. + + +Siena + + +Only a narrow status window is available on the Siena. A smaller font is used and the diamond list has +been reorganised, compared with that of the Series 3a, to maximise the space for displaying text. Despite + + +these changes, only four characters of the application name and up to five characters of each diamond list +item can be displayed. + + +Diamond list text items that contain more than five characters are automatically truncated. Since such +truncation may occur at an unsuitable point in the text, you should consider supplying truncated versions + + +of the diamond text for use in the status window, such as the four-character abbreviations for ‘Normal’ +and ‘Outline’ shown in the above illustration. + + +The following constants are defined in wlib.h: + + +WS_WIDTH_V4c 51 Normal status window width on Series 3c, in pixels; +this is not a new constant - it also exists on the Series 3a + + +WS_WIDTH_SMALL_V4c 32 Narrow status window width on Series 3c, in pixels; +this is not a new constant - it also exists on the Series 3a + + +WS_WIDTH_VINE 36 Narrow status window width on Siena, in pixels + + +6-3 + + +WINDOW SERVER REFERENCE + + +Clocks + + +The clock creation functions, for example, wscreateClock2, on the Siena and Series 3c support additional +clock styles. The new styles and their appearances and dimensions are given below. The associated +symbolic constants are defined in wlib.h. + + +Siena + + +The Siena supports one additional clock, of type ws_cLocK_VINE: + + +WS_CLOCK_VINE 0x06 + +WS_BITMAP_VINE_CLOCK_SIZE_X 70 Width of Siena analogue clock, in pixels +WS_BITMAP_VINE_CLOCK_SIZE_Y 69 Height of Siena analogue clock, in pixels +Series 3c + + +The Series 3c supports two additional clock types, ws_cLock_MEDIUM3 and ws_CLOCK_XL2_ANALOG: + + +WS_CLOCK_MEDIUM3 0x06 + +WS_BITMAP_MEDIUM3_CLOCK_SIZE_X 58 Width of Series 3c medium analogue clock, in pixels + +WS_BITMAP_MEDIUM3_CLOCK_SIZE_Y 51 Height of Series 3c medium analogue clock, in pixels + +WS_CLOCK_XL2_ANALOG 0x07 + +WS_BITMAP_XL2_CLOCK_SIZE_X 111 Width of Series 3c extra large analogue clock, in +pixels + +WS_BITMAP_XL2_CLOCK_SIZE_Y 110 Height of Series 3c extra large analogue clock, in +pixels + + +Window Server versions + + +The following values are contained in the version_id member of the w_sERVER_INFo Struct. The constants +and the struct are defined in wilib.h: + + +WS_TYPE_S3C 0x60 Series 3c window server + + +WS_TYPE_VINE 0x70 Siena window server + + +6-4 + + +INDEX + + +$WS_FL + + +environment variable, 1-2, 1-55, 1-56, 2-25 + + +$WS_FNTS + +environment variable, 1-2, 1-38, 2-10 +$WS_IF + +environment variable, 2-10, 3-16 +$WS_SD + +environment variable, 1-32 +$WS_SF + +environment variable, 1-38 +$WS_SF2 + +environment variable, 1-39 +$WS_SF4 + +environment variable, 1-39 +.pcex files + +from screen capture, 1-33 + +to bitmap PIC files, 1-31 +.ph files + +multi bitmap header file, 1-31 +.pic files + +checksum, 1-37 + +from a PCX file, 1-31 +.plk files + +multi bitmap files, 1-31 +activation + +event, 5-10 +add files + +embedded bitmap files, 1-37 +alert flag + +WS_ALERT_B, 1-3 +alerts + +asynchronous, 2-18 + +message display, 2-12 + +synchronous, 2-14 + +updating, 2-19 + +wsAlertW, 1-3 +animation + +bitmap sequences, 1-21, 3-14 + +sprites, 1-3, 1-23, 3-15 +application keys + +handler, 1-15 + + +W_KEY_APPn, 5-5 +wAppKeyHandler, 1-15 + + +area fill pattern + +gFillPattern, 4-13 +area filling + +modes, 4-12, 4-13 + +WLIB functions, 4-12 +arrow keys + +rubber band mode, 1-54 +arrows + +drawing, 4-10 +ascent + +fonts, 4-14 +asynchronous + +events, 5-2 +attached clients + +WLIB functions, 2-25 +attachment + +event, 5-8 +backed up windows + +bitmaps, 1-19 +background + +client, 1-14 + +client switch task order, 2-8 + +event, 5-6 +background modes + +window, 1-3 +backlight + +key code, 5-5 +baseline + +fonts, 4-14 +bitmaps + +capture screen to, 1-32 + + +converting from pcx with wspcx.exe, 1-31 + + +copying, 4-29, 4-30 + +creation of, 1-30, 4-26 + +drawables, 1-18 + +drawing from, 1-30, 4-31 + +drawing to, 1-31 + +embedded files, 1-37 + +files creating, 1-31 + +files creating with grey, 1-31 + +find in file gSetOpenAddress, 1-30 +freeing, 4-28, 4-32 + +freeing sequences, 3-15 + +from PCX files, 1-31 +G_TRMODE_CLR, 1-30 +G_TRMODE_INV, 1-30 +G_TRMODE_REPL, 1-30 +G_TRMODE_SET, 1-30 + +gCopyBit, 1-30 + +gDrawBit, 1-30 + +gFillPattern, 1-30 + +grey, 1-22 + +gSetOpenAddress, 1-30 + +header file for multi bitmap files, 1-31 +horizontal slice, 4-30 + +joining multiple from PLK file, 1-31 +loading, 4-27, 4-31 + +multiple, 4-30 + +open multiple bitmap file gInitBit, 1-30 +opening, 4-31 +overview, 1-30 + +pixel coordinates, 1-47 +reading, 4-30 + +redraws avoiding, 1-22 + + +WINDOW SERVER REFERENCE + + +redraws avoiding example code, 1-22 + +ROM-based grey, 1-30 + +saving, 4-28 + +screen capture, 1-31 + +sequences, 1-21, 3-14 + +storage of, 1-30 + +structure, 1-36 + +validating, 4-30 + +wFree, 1-30 + +WLIB functions, 1-2, 4-26 + +wsetWinBitmap, 1-30 +bitmaps copying + +gCopyBit, 4-29 + +gCopyRect, 4-30 +bitmaps create + +gCreateBit, 4-26 +bitmaps drawing from + +gDrawBit, 4-31 +bitmaps freeing + +wFree, 4-32 +bitmaps function + +wChangeWinBitmap, 3-15 + +wFree, 3-15 + +wsetWinBitmap, 3-14 +bitmaps loading + +gGetBit, 4-31 + +gOpenBit, 4-27 +bitmaps multi save end + +gEndMultiSave, 4-32 +bitmaps multiple initialise + +gInitMultiSave, 4-32 +bitmaps multiple saving + +gSaveMultiBit, 4-32 +bitmaps open + +embedded, 4-28 + +structure, 4-26, 4-27 +bitmaps opening + +gInitBit, 4-31 +bitmaps partial save + +gSaveMultiRect, 4-32 +bitmaps position + +gSetOpenAddress, 4-15 +bitmaps reading + +gPeekBit, 4-30 +bitmaps saving + +gSaveBit, 4-28 + +gSaveRect, 4-28 + +multiple, 4-32 +bitmaps sequences + +wChangeWinBitmap, 1-21 + +wFree, 1-21 + +wsetWinBitmap, 1-21 +bitmaps size get + +gQueryBit, 4-31 +bitmaps validating + +gCheckBitmapID, 4-30 +black + +plane, 1-3, 1-19, 3-8, 4-1, 4-13 +blind operations + +window server, 1-11 +body cell + +fonts, 4-14 +border + +WLIB function, 4-8 + + +ii + + +WLIB functions, 4-10 +border attribute +W_BORD_CORNER_1, 4-11 +W_BORD_CORNER_2, 4-11 +W_BORD_CORNER_4, 4-11 +W_BORD_CUSHION, 4-11 +W_BORD_OPEN, 4-11 +W_BORD_SHADOW_D, 4-11 +W_BORD_SHADOW_ON, 4-11 +W_BORD_SHADOW_S, 4-11 +border drawing +gBorder, 4-10 +gBorder2, 4-12 +gBorder2Rect, 4-10 +gBorderRect, 4-8 +types, 4-10 +box +WLIB function, 4-8 +buffered commands +window server, 1-11, 1-13, 2-5 +busy +message cancel, 2-12 +message display, 2-11 +busy message +window server option, 1-6 +button drawing +example code, 4-24 +button text +wDrawButton, 4-24 +wDrawButton2, 4-25 +cancelled +event, 5-6, 5-10 +capturing +keyboard events, 5-15 +keys, 1-51, 5-11 +mouse, 1-53, 5-13 +mouse events, 5-15 +screen to a bitmap file, 1-32 +checksum +font files, 1-46 +pic files, 1-37 +WLIB function, 4-32 +checksum get +gInquireChecksum, 4-32 +child +window, 1-18 +clear area +gClrRect, 4-12 +CLIB +library, 1-8 +startup module, 1-8, 2-1 +startup module MC, 1-10 +client +attach caller, 2-26 +attach caller to foreground, 2-26 +attached, 2-25, 5-8 +background, 1-14 +command event, 5-7 +command get, 5-10 +command send, 5-10 +de-iconised event, 5-8 +detach caller, 2-26 +detached, 2-26, 5-8 +foreground, 1-14 + + +INDEX + + +going deaf, 1-26 +iconised, 1-16 +iconised mark as, 2-9 +information get, 2-8 +list get, 2-10 +management, 1-17 +pause disable, 2-10 +pausing, 1-52 +pausing enable, 2-9 +priority, 1-16, 2-7 +system-modal, 1-17, 2-9 +task order, 2-8 +wCancelSystemModal, 2-9 +client commands +between window server clients, 1-6 +client window +background drawing, 1-18 +clients +window server, 1-13 +clients terminating +window server, 1-6 +client-side buffer +flushing, 1-13 +clipping +redrawing, 3-9 +windows, 1-25 +windows child, 1-18 +clock +creating, 3-17, 3-19 +example code, 3-18, 3-20, 3-21 +freeing, 3-22 +offset, 3-22 +Series 3c and Siena update, 6-4 +Series 3c update, 6-4 +Siena update, 6-4 +structure, 3-19 +WLIB functions, 3-16 +clock attribute +WS_CLOCK_AM_PM, 3-17, 3-20 +WS_CLOCK_BOX, 3-20 +WS_CLOCK_CENTERED, 3-17, 3-20 +WS_CLOCK_FORCE_ANALOG, 3-17, +3-20 +WS_CLOCK_FORCE_DIGITAL, 3-17, +3-20 +WS_CLOCK_FORMATTED, 3-19 +WS_CLOCK_GREY, 3-20 +WS_CLOCK_LARGE_ANALOG, 3-17, +3-19 +WS_CLOCK_MEDIUM, 3-17, 3-19 +WS_CLOCK_MEDIUM2, 3-19 +WS_CLOCK_SMALL_DIGITAL, 3-17, +3-19 +WS_CLOCK_WITH_DATE, 3-17, 3-20 +WS_CLOCK_WITH_SECONDS, 3-17, +3-20 +WS_CLOCK_XL_ANALOG, 3-19 +clock drawing +automatic, 1-6 +clock function +wFree, 3-22 +wsCreateClock, 3-17 +wsCreateClock2, 3-19 +wsSetClock, 3-22 + + +code +key, 1-51 +keys, 5-3 + + +command data get + +wGetCommand, 5-10 +compatibility mode + +S3 display mode, 2-6 + +Series 3, 1-12 + +status windows, 2-21 + +W_CTBY_S3, 2-6 + +W_CTBY_S3_SCR, 2-6 + +wInquireCompatibility, 2-7 +compute mode + +ending wEndCompute, 2-8 + +priority setting wStartCompute, 2-8 +configure + +font group, 4-18 + +window server, 2-24 +connect to + +window server, 2-1, 2-3 +CONNECT_INFO + +structure, 2-3 +console device + +channel to, 1-8 +coordinates + +pixel, 1-47 +copying bitmaps + +WLIB function, 4-29, 4-30 +corner type + +border attribute, 4-8 + +border attributes, 4-11 +count + +key repeat, 1-51 + +keys repeat, 5-3 +cursor + +flashing, 1-29 + +grey, 1-29 + +text, 3-12 + +text window, 1-29 + +wTextCursor, 1-29 +cursor attribute + +W_CURSOR_GREY, 3-12 +cursor function + +wDrawTextCursor, 3-13 + +wEraseTextCursor, 3-13 + +wTextCursor, 3-12 +cursor remove + +wEraseTextCursor, 1-29 +date changed + +event, 5-7 +DatStatusNamePtr + +magic static, 2-13 +deaf clients + +multi-tasking, 1-26 + +window server flag, 1-56 +de-iconise + +event, 5-8 +descent + +fonts, 4-14 +destroying + +windows, 1-27 +detachment + +event, 5-8 + + +iii + + +WINDOW SERVER REFERENCE + + +diamond key + +key code, 5-5 + +key press, 1-15 + +mode display, 2-20 +disable + +status window, 2-22 + +status window temporary, 2-22 +disconnect from + +window server, 2-5 +display + +brief message, 2-11 +display process + +SYS$CONS on MC, 1-7 +double pixel mode + +window, 1-12 +doubled sized pixels + +mode, 4-1 + +S3 display mode, 2-6 +drawable + +graphics context, 4-1 + +windows and bitmaps, 1-18, 1-50 +drawing + +arrows, 4-10 + +background client, 1-18 + +lines, 4-7 + +polygon, 4-7 + +shadowed text, 4-23 + +shadows, 4-10 + +text, 1-44 + +to bitmaps, 1-31 + +windows, 1-25 +drawing mode + +G_GC_FLAG_BOTH_PLANES, 4-3 + +G_GC_FLAG_DOUBLE, 4-3 + +G_GC_FLAG_GREY_PLANE, 4-3 +drawing region + +window, 1-19 +DYL graphics + +WLIB function, 4-33 +E_CONFIG + +structure, 3-16 +E_PRIORITY_BACK + +window server flag, 2-7 +E_PRIORITY_FORE + +window server flag, 2-7 +embedded + +font files, 1-47 +embedded bitmap files + +add file lists, 1-37 +enable + +status window temporary, 2-22 +end rubber band + +event, 5-10 +environment variable + +$WS_FL, 1-2, 1-55, 1-56, 2-25 + +$WS_FNTS, 1-2, 1-38, 2-10 + +$WS_IF, 2-10, 3-16 + +$WS_SD, 1-32 + +$WS_SF, 1-38 + +$WS_SF2, 1-39 + +$WS_SF4, 1-39 +EPOC + +operating system, 1-1 + +PC version, 1-59 + + +iv + + +error + + +cleaning up, 1-11 +handling window server, 2-7 +panic numbers window server, 1-12 + + +error handling + + +window server, 1-11 + + +escape-key + + +event, 5-8 + + +event + + +W_KEY_MODE, 1-2 +W_MOUSE_DOWN, 5-9 +W_MOUSE_OUTSIDE, 5-9 +WM_ACTIVE, 1-53, 5-10 +WM_ATTACHED, 2-25, 5-8 +WM_BACKGROUND, 5-6 +WM_CANCELLED, 1-28, 5-6, 5-10 +WM_COMMAND, 5-7 +WM_DATE_CHANGED, 1-3, 5-7 +WM_DEICONISE, 1-16, 2-8, 5-8 +WM_DETACHED, 2-25, 5-8 +WM_ESCAPE, 5-8 +WM_FOREGROUND, 2-25, 5-6 +WM_KEY, 1-15, 1-51, 5-3 +WM_KEYBOARD_STATE_CHANGE, +5-8 +WM_MOUSE, 1-52, 5-9 +WM_MOUSE_MOVE, 5-9 +WM_MOUSE PRESS, 5-9 +WM_MOUSE_RELEASE, 1-53, 5-9 +WM_ON, 5-7, 5-11 + +WM_REDRAW, 3-12, 5-6 +WM_RUBBER, 1-53, 5-10, 5-14 +WM_RUBBER_BAND_INIT, 1-54, 5-9 +WM_TASK_KEY, 1-15, 5-7 +WM_TASK_UPDATE, 5-7 +WM_USER_MSG, 5-7, 5-10 +WS_EVENT_UNION, 5-1 + + +event function + + +wCancelGetEvent, 5-10 +wGetEvent, 1-51 + +wGetEvent get async, 1-14 +wGetEventSpecial, 1-51 +wGetEventSpecial get async, 1-14 +wGetEventWait, 1-51 +wGetEventWait event get, 1-14 +wSendCommand, 5-10 +wUserMsg, 5-10 + + +event selected + + +WE_ESC, 5-2 +WE_KEY, 5-2 +WE_MOUSE, 5-2 +WE_NORMAL, 5-2 +WE_OTHERS, 5-2 +WE_REDRAW, 5-2 +WE_STATUS, 5-2 + + +event selected update + + +wGetEventUpdate, 5-2 + + +event types + + +described, 5-3 + + +events + + +activation, 5-10 +asynchronous, 1-28, 5-2 +attachment, 5-8 +background, 5-6 + + +cancelled, 5-6, 5-10 +client command, 5-7, 5-10 +date changed, 5-7 +de-iconise, 5-8 +detachment, 5-8 +end rubber band, 5-10 +escape-key, 5-8 +foreground, 5-6 +getting next, 5-1 +inform key handler, 5-7 +key, 1-14 +key presses, 1-51 +keyboard capturing, 5-15 +keyboard state change, 5-8 +large screen, 5-8 +machine on, 5-7 +mouse, 1-14, 1-52, 5-9 +non window server, 1-28 +other sources, 1-28 +process termination, 5-7 +redraw, 1-24, 5-6 +rubber, 5-15 +selected, 5-2 +start rubber band, 5-9 +synchronous, 5-1 +time-stamping, 1-14 +types, 5-3 +update selected, 5-2 +user, 5-10 +user message, 5-7 +waiting, 5-1 +wGetEvent async, 5-2 +wGetEventWait sync, 5-1 +window server clients, 1-14 +WLIB functions, 5-10 +events selected async +wGetEventSpecial, 5-2 +fast fonts +described, 1-38 +file format +bitmaps, 1-36 +fonts, 1-46 +files +bitmaps creating, 1-31 +font, 1-42 +fill area +gClrRect, 4-12 +filling areas +modes, 4-12, 4-13 +WLIB functions, 4-12 +flashing +cursor, 1-29 +FLK +font source file list file, 1-44 +flushing +client-side buffer, 1-13 +commands window server, 2-5 +window server, 1-11 +flushing commands +window server, 2-7 +FON +file, 1-42 +font group configure +gConfigureFonts, 4-18 + + +INDEX + + +font group header read +gReadFontGroupHeader, 4-19 +font header read +gReadFontHeader, 4-19 +font information +structure, 4-16 +font internal +wSetSystemFont, 4-17 +font loading +gOpenFont, 4-15 +font open index +gOpenFontIndex, 4-18 +font position +gSetOpenAddress, 4-15 +font style +G_FONT_FLAG_ASCII, 4-16 +G_FONT_FLAG_BOLD, 4-16 +G_FONT_FLAG_CP850, 4-16 +G_FONT_FLAG_ITALIC, 4-16 +G_FONT_FLAG_SERIF, 4-16 +G_STY_BOLD, 4-2 +G_STY_DOUBLE, 4-2 +G_STY_INVERSE, 4-2 +G_STY_ITALIC, 4-2 +G_STY_MONO, 4-2 +G_STY_NORMAL, 4-2 +G_STY_SUBSCRIPT, 4-2 +G_STY_SUBSCRIPT2, 4-3 +G_STY_SUPERSCRIPT, 4-2 +G_STY_SUPERSCRIPT2, 4-3 +G_STY_UNDERLINE, 4-2 +font system +wSetSystemFont, 4-17 +font type system +W_SYSTEM_FONT_INTERNAL_S3, 4-17 +W_SYSTEM_FONT_INTERNAL_S3B, +4-17 +W_SYSTEM_FONT_S3, 4-17 +W_SYSTEM_FONT_S3B, 4-17 +font width table +gGetWidthTable, 4-17 +fonts +ascent, 4-14 +baseline, 4-14 +bitmaps, 1-38 +body cell, 4-14 +compiler wsfcomp.exe, 1-43 +configure group, 4-18 +descent, 4-14 +fast, 1-38 +file structure, 1-46 +files, 1-42 +files checksum, 1-46 +files embedded, 1-47 +files p_cre, 1-46 +finding in file gSetOpenAddress, 1-42 +FON files, 1-42 +freeing, 4-16 +group, 4-18 +group header, 4-19 +HC, 1-39 +header, 4-19 +high character, 4-14 +horizontal leading, 4-14 + + +WINDOW SERVER REFERENCE + + +ID field, 4-3 +ID start WS_FONT_BASE, 1-38 +ID system WS_FONT_SYSTEM, 1-38 +information, 1-44, 4-16 +internal IDs, 4-17 +loading gOpenFont, 1-42 +loading gOpenFontIndex, 1-42 +low character, 4-14 +MC, 1-41 +monospaced, 1-38 +multiple, 4-18 +opening, 4-15, 4-18 +proportional, 1-38 +roman, 1-41 +ROM-based, 1-38, 4-3 +S3, 1-40 +S3a, 1-41 +source file list FLK file, 1-44 +source FSC file, 1-43 +structure, 1-46 +style, 1-45, 4-2 +style G_STY_BOLD, 1-45 +style G_LSTY_DOUBLE, 1-45 +style G_STY_INVERSE, 1-45 +style G_STY_ITALIC, 1-45 +style G_LSTY_MONO, 1-45 +style G_STY_NORMAL, 1-45 +style G_LSTY_UNDERLINE, 1-45 +swiss, 1-42 +system IDs, 4-17 +text, 1-38, 4-14 +vertical leading, 4-14 +width, 4-14 +width table, 4-17 +Workabout, 1-41 + +Fonts + + +ID system from W_SERVER_INFO, 1-38 + + +ID system S3/HC from $WS_SF, 1-38 + + +ID system S3a from $WS_SFNTS, 1-38 + + +information gFontInfo, 1-44 +fonts.h + +header file, 1-39, 1-41 +foreground + +client, 1-14 + +client switch task order, 2-8 + +event, 5-6 +freeing + +bitmap sequences, 3-15 + +bitmaps, 4-28, 4-32 + +clocks, 3-22 + +fonts, 4-16 + +mouse icon, 3-23 + +permanent graphics contexts, 4-5 + +sprites, 3-16 + +temporary graphics contexts, 4-6 +FSC file + +font source file, 1-43 +G_FONT_CONFIG + +structure, 4-18 +G_FONT_FLAG_ASCTI + +font style, 4-16 +G_FONT_FLAG_BOLD + +font style, 4-16 + + +vi + + +G_FONT_FLAG_CP850 + +font style, 4-16 +G_FONT_FLAG_ITALIC + +font style, 4-16 +G_FONT_FLAG_SERIF + +font style, 4-16 +G_FONT_INFO + +font information structure, 4-16 + +structure, 1-46 +G_GC + +plane flag, 1-3 + +structure, 3-9, 4-1 +G_GC_FLAG_BOTH_PLANES + +drawing mode, 4-3 +G_GC_FLAG_DOUBLE + +drawing mode, 4-3 + +graphics flag, 1-2 +G_GC_FLAG_GREY_PLANE + +drawing mode, 4-3 +G_SHADOW + +structure, 4-23 +G_STY_BOLD + +font style, 1-45, 4-2 +G_STY_DOUBLE + +font style, 1-45, 4-2 +G_STY_INVERSE + +font style, 1-45, 4-2 +G_STY_ITALIC + +font style, 1-45, 4-2 +G_STY_MONO + +font style, 1-45, 4-2 +G_STY_NORMAL + +font style, 1-45, 4-2 +G_STY_SUBSCRIPT + +font style, 4-2 +G_STY_SUBSCRIPT2 + +font style, 4-3 +G_STY_SUPERSCRIPT + +font style, 4-2 +G_STY_SUPERSCRIPT2 + +font style, 4-3 +G_STY_UNDERLINE + +font style, 1-45, 4-2 +G_TRMODE_CLR + +bitmap transfer mode, 1-30 + +text mode, 4-2 + +text transfer mode, 1-45 +G_TRMODE_INV + +bitmap transfer mode, 1-30 + +text mode, 4-2 + +text transfer mode, 1-45 +G_TRMODE_REPL + +bitmap transfer mode, 1-30 + +text mode, 4-2 + +text transfer mode, 1-45 +G_TRMODE_SET + +bitmap transfer mode, 1-30 + +text mode, 4-2 + +text transfer mode, 1-45 +gBorder + +graphics output, 1-49 + +WLIB function, 4-10 +gBorder2 + +graphics output, 1-49 + + +WLIB function, 4-12 +gBorder2Rect + +graphics output, 1-49 + +WLIB function, 4-10 +gBorderRect + +graphics output, 1-49 + +WLIB function, 4-8 +gCheckBitmapID + +WLIB function, 4-30 +gClrRect + +graphics output, 1-49 + +WLIB function, 4-12 +gConfigureFonts + +WLIB function, 4-18 +gCopyBit + +bitmap WLIB function, 1-30 + +graphics output, 1-49 + +WLIB function, 4-29 +gCopyRect + +graphics output, 1-49 + +WLIB function, 4-30 +gCreateBit + +bitmap WLIB function, 1-30 + +WLIB function, 4-26 +gCreateGC + +graphics context permanent, 1-50 + +WLIB function, 4-4 +gCreateGCO + +graphics context permanent, 1-50 + +WLIB function, 4-5 +gCreateTempGC + +graphics context temporary, 1-51 + +WLIB function, 4-5 +gCreateTempGCO + +graphics context temporary, 1-51 + +WLIB function, 4-6 +gDrawBit + +bitmap WLIB function, 1-30 + +graphics output, 1-49 + +WLIB function, 4-31 +gDrawBox + +graphics output, 1-49 + +WLIB function, 4-8 +gDrawLine + +graphics output, 1-49 + +WLIB function, 4-7 +gDrawObject + +graphics output, 1-49 + +WLIB function, 4-12 +gDrawPolyLine + +graphics output, 1-49 + +WLIB function, 4-7 +gEndMultiSave + +WLIB function, 4-32 +gFillPattern + +bitmap WLIB function, 1-30 + +graphics output, 1-49 + +WLIB function, 4-13 +gFontInfo + +fonts WLIB function, 1-44 + +WLIB function, 4-16 +gFreeTempGC + +graphics context free, 1-51 + +WLIB function, 4-6 + + +INDEX + + +gGetBit + +bitmap WLIB function, 1-30 + +WLIB function, 4-31 +gGetWidthTable + +WLIB function, 4-17 +gInitBit + +bitmap WLIB function, 1-30 + +WLIB function, 4-31 +gInitMultiSave + +WLIB function, 4-32 +gInquireChecksum + +WLIB function, 4-32 +gInvObloid + +graphics output, 1-49 + +WLIB function, 4-13 +gmode + +graphics modes, 4-2 +gOpenBit + +bitmap WLIB function, 1-30 + +WLIB function, 4-27 +gOpenFont + +fonts WLIB function, 1-42 + +WLIB function, 4-15 +gOpenFontIndex + +fonts WLIB function, 1-42 + +WLIB function, 4-18 +gOpenMouselcon + +WLIB function, 3-23 +gPeekBit, 1-35 + +WLIB function, 4-30 +gPrintBoxText + +graphics output, 1-49 + +text drawing WLIB function, 1-44 + +WLIB function, 4-20 +gPrintClipText + +graphics output, 1-49 + +text drawing WLIB function, 1-44 + +WLIB function, 4-20 +gPrintText + +graphics output, 1-49 + +text drawing WLIB function, 1-44 + +WLIB function, 4-20 +gQueryBit + +WLIB function, 4-31 +graphics + +adding output functions, 4-33 + +DYL, 4-33 + +G_GC_FLAG_DOUBLE flag, 1-2 + +output, 2-10 + +structures, 1-48 + +WLIB functions, 1-47 +graphics contexts + +current, 1-50 + +free gFreeTempGC, 1-51 + +free wEndRedraw, 1-51 + +gCreateGC, 4-4 + +gCreateGCO, 4-5 + +gCreateTempGC, 4-5 + +gCreateTempGCO0, 4-6 + +gFreeTempGC, 4-6 + +gSetGC, 4-6 + +gSetGCO, 4-7 + +overview, 1-50, 4-1 + +permanent, 1-50, 4-4 + + +WINDOW SERVER REFERENCE + + +permanent freeing, 4-5 +permanent gCreateGC, 1-50 +permanent gCreateGCO, 1-50 +set specific gSetGC, 1-50 +set specific gSetGCO, 1-50 +setting, 4-6 +temporary, 1-51, 4-5 +temporary & permanent, 1-50 +temporary freeing, 4-6 +temporary gCreateTempGC, 1-51 +temporary gCreateTempGCO, 1-51 +temporary wBeginRedrawGC, 1-51 +temporary wBeginRedrawGCo, 1-51 +temporary wBeginRedrawWinGC, 1-51 +temporary wBeginRedrawWinGCO, 1-51 +wFree, 4-5 +windows, 1-18 +graphics DYL call +wCallDYL, 4-33 +graphics DYL enquiry call +wCallDYLReply, 4-33 +graphics DYL load +wLoadDYL, 4-33 +graphics functions +not to current graphics context, 1-49 +to current graphics context, 1-49 +graphics modes +gmode, 4-2 +graphics objects +gDrawObject, 4-12 +type attributes, 4-12 +types, 4-12 +graphics output +gBorder, 1-49 +gBorder2, 1-49 +gBorder2Rect, 1-49 +gBorderRect, 1-49 +gClrRect, 1-49 +gCopyBit, 1-49 +gCopyRect, 1-49 +gDrawBit, 1-49 +gDrawBox, 1-49 +gDrawLine, 1-49 +gDrawObject, 1-49 +gDrawPolyLine, 1-49 +gFillPattern, 1-49 +gInvObloid, 1-49 +gPrintBoxText, 1-49 +gPrintClipText, 1-49 +gPrintText, 1-49 +gShadowText, 1-49 +gXPrintText, 1-49 +not to current graphics context, 1-49 +to current graphics context, 1-49 +wCancelBusyMsg, 1-49 +wDrawButton, 1-49 +wDrawButton2, 1-49 +wDrawTextCursor, 1-49 +wEraseTextCursor, 1-49 +wInfoMsg, 1-49 +winfoMsgCorner, 1-49 +wsAlertA, 1-50 +wsAlertCancel, 1-50 +wsAlertUpdate, 1-50 + + +viii + + +wsAlertW, 1-50 +wsCreateClock, 1-49 +wsCreateClock2, 1-49 +wscrollRect, 1-49 +wScrollWin, 1-49 +wsDisable, 1-50 +wsDisableTemp, 1-50 +wsEnable, 1-50 +wsEnableTemp, 1-50 +wsSetBusyMsg, 1-49 +wsSelectList, 1-50 +wsSetClock, 1-49 +wsSetList, 1-50 +wsStatusWindow, 1-50 +wsUpdate, 1-50 +wTextCursor, 1-49 +gReadFontGroupHeader +WLIB function, 4-19 +gReadFontHeader +WLIB function, 4-19 +grey +cursor, 1-29 +plane, 1-3, 1-19, 3-8, 4-1, 4-13 +gSaveBit +bitmap WLIB function, 1-31 +WLIB function, 4-28 +gSaveMultiBit +bitmap WLIB function, 1-31 +WLIB function, 4-32 +gSaveMultiRect +bitmap WLIB function, 1-31 +WLIB function, 4-32 +gSaveRect +bitmap WLIB function, 1-31 +WLIB function, 4-28 +gSetGC +graphics context specific, 1-50 +WLIB function, 4-6 +gSetGCO +graphics context specific, 1-50 +WLIB function, 4-7 +gSetOpenAddress +bitmap WLIB function, 1-30 +fonts WLIB function, 1-42 +WLIB function, 4-15 +gShadowText +graphics output, 1-49 +text drawing WLIB function, 1-44 +WLIB function, 4-23 +gTextCount +text layout WLIB function, 1-44 +WLIB function, 4-17 +gTextWidth +text layout WLIB function, 1-44 +WLIB function, 4-16 +gXPrintText +graphics output, 1-49 +text drawing WLIB function, 1-44 +WLIB function, 4-21 +HC +fonts, 1-39 +replacing the shell, 1-56 +shell example code, 1-56 +task switching, 1-15 + + +header file +for multi bitmap files, 1-31 +wlib.h, 1-8 +header files +fonts.h, 1-39, 1-41 +high character +fonts, 4-14 +hook notifier +process, 1-55 +window server option, 1-5 +horizontal leading +fonts, 4-14 +hotkeys +capturing, 5-12 +implementing, 5-12 +hot-spot +mouse icon, 1-52 +hung-up +redrawing delays, 1-26 +window server flag, 1-56 +icon ID +WS_DEFAULT_ICON, 1-3 +icon ID grey +WS_DEFAULT_ICON+1, 1-3 +iconised +client, 1-16 +client mark as, 2-9 +icons +mouse, 1-52, 3-22 +include file +key code wskeys.h, 6-1 +inform key handler +event, 5-7 +input +rubber band mode, 1-53 +internal fonts +IDs, 4-17 +invalidate function +wlInvalidateRect, 3-12 +wlInvalidateWin, 3-12 +invalidating +windows, 1-24 +WLIB function, 3-12 +invert obloid +gInvObloid, 4-13 +invisible window +wMakelnvisible, 1-28 +key +pause disable wDisablePauseKey, 1-52 +pause enable wEnablePauseKey, 1-52 +specific cancel wCancelCaptureKey, 1-51 +specific wCaptureKey, 1-51 +tasks setting, 1-52 +key capture +wCaptureKey, 5-11 +key capture off +wCancelCaptureKey, 5-12 +key code +diamond, 5-5 +Series 3c and Siena update, 6-1 +W_FUNC_MODIFIER, 6-2 +W_KEY_BACKLIGHT, 5-5 +W_KEY_CALC_CHNG_SIGN, 6-2 +W_KEY_CALC_CLEAR, 6-2 + + +INDEX + + +_CALC_DECIMAL, 6-2 +_CALC_MEM_CLEAR, 6-2 +_CALC_MEM_INPUT, 6-2 +_CALC_MEM_MINUS, 6-2 +_CALC_MEM_PLUS, 6-2 +_CALC_MEM_RECALL, 6-2 +_CALC_PERCENT, 6-2 +_CAPS_LOCK, 5-5 +_DELETE_LEFT, 5-4 + + +_HELP, 5-5 + + +MENU, 5-5 + + +qeidddddddddedeedeeeeeeeeeas + + +Sebi bie eb bii ibis bts bist tts + + +Me +Y_ +Y_ +Y_ +NX +Y_ +Y_LEFT, 5-4 +Mes +Y_ +Y +Y_' +Y_ +Y_PAGE_UP, 5-4 +Y + + +agceead + + +W_KEY_VOICE, 5-4 +W_RUSSIAN_MODIFIER, 6-2 +wskeys.h, 6-1 +key code applications +W_KEY_APPn, 5-5 +key modifier +W_CAPS_MODIFIER, 5-3, 5-9 +W_CTRL_MODIFIER, 5-3, 5-9 +W_NUM_LOCK_MODIFIER, 5-3, 5-9 +W_PSION_MODIFIER, 5-3, 5-9 +W_SHIFT_MODIFIER, 5-3, 5-9 +key press +diamond, 1-15 +keyboard +events capturing, 5-15 +input, 1-14, 1-51 +key press events, 1-51 +rubber band, 5-15 +Series 3c and Siena update, 6-1 +state change event, 5-8 +update for Series 3c and Siena, 6-1 +key-click +disable, 2-26 +enable, 2-26 +keys +application handler, 1-15 +cancel back task switch keys, 5-13 +cancel task switch keys, 5-12 +capturing, 1-51, 5-11 +code, 1-51, 5-3 + + +WINDOW SERVER REFERENCE + + +code - Series 3c and Siena update, 6-1 +code wskeys.h, 6-1 +count, 1-51, 5-3 +events, 1-14 +key press events, 1-51 +modifier, 5-3 +repeat count, 1-51, 5-3 +set back task switch keys, 5-13 +set task switch keys, 5-12 +large screen +event, 5-8 +LCD display resolution +by machine, 2-5 +leading horizontal +fonts, 4-14 +leading vertical +fonts, 4-14 +leaving +disable, 2-7 +enable, 2-7 +libraries +WLIB using, 1-8 +line drawing +gDrawBox, 4-8 +gDrawLine, 4-7 +gDrawPolyLine, 4-7 +WLIB functions, 4-7 +link paste +window server services, 1-6 +low character +fonts, 4-14 +machine on +event, 5-7 +machine type +from wConnect, 1-2 +magic static +DatStatusNamePtr, 2-13 +MC +fonts, 1-41 +task switching, 1-16 +wAttachToClient, 1-16 +wAttachToForegroundClient, 1-16 +MC200 +Fonts system ID, 1-39 +mouse, 5-9 +MC400 +Fonts system ID, 1-39 +mouse, 5-9 +message +cancel busy, 2-12 +display alerts, 2-12 +display brief, 2-11 +display busy, 2-11 +message constant +W_INFO_MSG_MAX_LEN, 2-11 +message flag +W_CORNER_BOTTOM_LEFT, 2-11 +W_CORNER_BOTTOM_RIGHT, 2-11 +W_CORNER_TOP_LEFT, 2-11 +W_CORNER_TOP_RIGHT, 2-11 +mode display +diamond key, 2-20 +mode list +status window, 2-23 + + +modifier +keys, 5-3 +monospaced fonts +sets, 1-38 +mouse +capturing, 1-53, 5-13 +event, 5-9 +events, 1-14, 1-52, 5-9 +freeing icon, 3-23 +grabbing, 1-53 +icons, 1-52, 3-22 +input, 1-52 +releasing, 5-13 +rubber band, 5-15 +mouse capture +wCaptureMouse, 5-13 +mouse icon +gOpenMouselcon, 3-23 +hot-spot, 1-52 +W_WIN_MI_STANDARD, 1-52 +wFree, 3-23 +mouse icon attribute +W_WIN_MI_CROSS, 3-22 + + +_MI_MARGIN, 3-23 +I_MOVE, 3-23 +_ NULL, 1-52, 3-22 +_PG_DOWN, 3-23 +_PG_UP, 3-23 +_PUSHER, 3-22 +_RESIZE, 3-23 +_RIGHT, 3-23 +_STANDARD, 3-22 +_TEXT, 3-22 +MI_TO_BIG, 3-23 +_MI_TO_SMALL, 3-23 +N_MI_VSLIDE, 3-23 +mouse icon position + +gSetOpenAddress, 4-15 +mouse release + +wReleaseMouse, 5-13 +multiple + +bitmaps, 4-30 + +fonts, 4-18 +multi-tasking + +redraw response, 1-26 + +window destroying and, 3-6 +normal + +plane, 1-3, 1-19, 3-8, 4-1, 4-13 +notifier + +hook the process, 1-55 + +window server option, 1-5 +notify + +process SYS$NTFY, 1-54 +obloid invert + +gInvObloid, 4-13 +on event enable + +winformOn, 5-11 + +winformOnAll, 5-11 +opening + +bitmaps, 4-31 + +fonts, 4-15, 4-18 + + +z +z + + +— + + +— + + +— + + +— + + +z'z'z'czzzzzz + + +— + + +— + + +— + + +eececccece +Ssscccaces + + +ZAZZAZLZAZLZAZLZLAZLZZ + + +z= +=i + + +F + + +p_cre +font files, 1-46 +function, 1-37 + + +p_enter + +window server, 1-11 +p_execc + +sub-process create, 1-26 +P_EXTENT + +structure, 1-48, 3-1 +P_FSIG + +structure, 1-37, 1-46 +p_iowait + +and window server events, 1-28 +p_leave + +window server, 1-11 +p_panic + +window server, 1-12 +P_POINT + +structure, 1-48, 3-1, 4-30 +P_RECT + +structure, 1-48, 4-29 +p_resume + +function, 1-14 +panic + + +W_PANIC_SPRITE, 3-16 + +W_PANIC_SPRITE_EXISTS, 3-16 +panic numbers + +window server, 1-12 +parent + +window, 1-18 +password support + +window server option, 1-6 +pause + +client disable, 2-10 + +client enable, 2-9 + + +pausing + +client, 1-52 +PC + +EPOC, 1-59 +PCX file + + +from screen capture, 1-33 + +to bitmap file, 1-31 +pcxsave.c + +example program screen capture, 1-33 +pcxScreenSave + +screen capture, 1-33 +permanent + +status window, 2-19 +PH file + +multi bitmap header file, 1-31 +PIC file + +from a PCX file, 1-31 +PIC_HEAD + +structure, 1-36 +pixel + +coordinates, 1-47 + +double sized mode, 4-1 + +screen resolutions, 2-5 +pixel coordinates + +bitmaps, 1-47 +plane + +black, 1-3, 1-19, 4-1 + +grey, 1-3, 1-19, 3-8, 4-1, 4-13 + +normal, 1-3, 1-19, 4-1, 4-13 + + +INDEX + + +plane flag + +in G_GC, 1-3 +PLIB + +library, 1-8 + +startup module, 1-9, 2-1 + +startup module MC, 1-10 +PLK file + +multi bitmap files, 1-31 +polygon drawing + +WLIB function, 4-7 + + +priority +changing clients, 2-7 +client, 1-16 + + +compute mode end wEndCompute, 2-8 +compute mode setting wStartCompute, 2-8 +redraw events, 1-27 +wEndCompute, 1-17 +wSetPriorityControl, 2-8 +wsStartCompute, 1-17 +process +SYS$FSRV, 1-54 +SYS$MANG, 1-54 +SYS$NTFY, 1-54 +SYS$NULL, 1-54 +SYS$SHLL, 1-15, 1-54 +SYS$WSRYV, 1-54 +wsystem, 1-55 +process termination +event, 5-7 +proportional fonts +sets, 1-38 +reading bitmaps +WLIB function, 4-30 + + +redraw +event, 5-6 +events, 1-24 + + +priority, 1-27 +priority bit W_WIN_PRIORITY, 1-27 +responsively, 1-26 +update region, 1-24 +validating before, 1-25 +redraw function +wBeginRedraw, 3-9 +wBeginRedrawGC, 3-9 +wBeginRedrawGC0, 3-10 +wBeginRedrawWin, 3-9 +wBeginRedrawWinGC, 3-10 +wBeginRedrawWinGC0O, 3-10 +wEndRedraw, 3-11 +redrawing +wBeginRedraw WLIB functions, 1-26 +windows, 1-24, 1-25 +windows variants, 3-8 +redraws +avoiding using bitmaps, 1-22 +avoiding using bitmaps example code, 1-22 +releasing mouse +WLIB function, 5-13 +repeat count +key, 1-51 +keys, 5-3 +reserved static +see magic static, 2-4 + + +WINDOW SERVER REFERENCE + + +ROM +built in grey bitmap, 1-30 +roman +fonts, 1-41 +ROM-based fonts +IDs, 4-3 +sets, 1-38 +root +window, 1-18 +rubber band +arrow keys, 1-54 +enter mode wRubberBand, 1-54 +input mode, 1-53 +keyboard events, 5-15 +mouse events, 5-15 +WLIB functions, 5-14 +rubber band attribute +W_BAND_COMPLETE_ON_UP, 5-15 +W_BAND_GRID_SNAP, 5-15 +W_BAND_GRID_SNAP_ SIZE, 5-15 +W_BAND_INNER, 5-14 +W_BAND_OUTER, 5-14 +W_BAND_RESIZE, 5-14 +W_BAND_START, 5-14 +rubber band flag +WM_BAND_CANCEL, 5-15 +WM_BAND_ERROR, 5-15 +WM_BAND_MOVE, 5-15 +WM_BAND_NOMOVE, 5-15 +WM_BAND_RESIZE, 5-15 +rubber band start +wRubberBand, 5-14 +83 +fonts, 1-40 +S3a +fonts, 1-41 +saving bitmaps +WLIB function, 4-28 +saving multiple bitmaps +WLIB function, 4-32 +scapt +screen capture example program, 1-36 +screen +coordinates, 1-18 +double pixel mode, 1-2 +event, 5-8 +screen capture +disabling, 1-32 +example code, 1-33 +HC, 1-33 +pexScreenSave function, 1-33 +scapt example program, 1-36 +to a bitmap, 1-31 +to bitmap file, 1-32 +to PCX file pexsave.c, 1-33 +screen resolution +by machine, 2-5 +by machine update, 6-1 +Series 3c and Siena update, 6-1 +screen sizes +by machine update, 6-1 +scrolling +rectangle, 3-7 +window, 3-7, 3-8 + + +xii + + +windows, 1-28 +windows continuous, 1-29 +selected events +WLIB function, 5-2 +Series 3 +compatibility mode, 1-12 +task switching, 1-15 +Series 3a +task switching, 1-15 +server +window server connecting to, 1-8 +setting graphics contexts +WLIB functions, 4-6 +shadowed text +WLIB functions, 4-23 +shadows +drawing, 4-10 +shell +event, 5-7 +HC replacing the shell, 1-56 +HC shell example code, 1-56 +process, 1-15, 1-54 +sibling +window, 1-18, 3-7 +sprite +structure, 3-15 +sprite attribute +W_SPRITE_CLIP_CHILDREN, 3-15 +sprite function +wCreateSprite, 3-15 +wFree, 3-16 +wsetSprite, 3-16 +sprites +animated bitmaps, 1-3 +animated graphics, 1-23 +animation, 3-15 +black plane, 1-23 +changing, 3-16 +creating, 3-15 +freeing, 3-16 +grey plane, 1-23 +normal plane, 1-23 +plane grey, 1-23 +W_SPRITE_CLIP_CHILDREN, 1-23 +wCreateSprite, 1-23 +wFree, 1-23 +wsetSprite, 1-23 +start rubber band +event, 5-9 +startup module + + +PLIB MC, 1-10 +start-up system +process, 1-54 +status window +compatibility mode, 2-21 +disable, 2-22 +drawing, 1-6 +extent get, 2-21 +mode list, 2-23 +overview, 2-19 +permanent, 2-19 + + +permanent enable, 2-21 + +permanent set state, 2-21 + +select position set, 2-23 + +Series 3c and Siena update, 6-3 + +Series 3c update, 6-3 + +Siena update, 6-3 + +state get, 2-23 + +temporary, 2-19 + +temporary disable, 2-22 + +temporary enable, 2-22 + +update displayed, 2-22 + +wsStatusWindow permanent, 2-21 +status window flag + + +W_STATUS_WIN_NO_DIAMOND, 2-23 + + +W_STATUS_WINDOW_BIG, 2-21 + + +W_STATUS_WINDOW_CTBY, 2-21 +W_STATUS_WINDOW_ICON, 2-23 + + +W_STATUS_WINDOW_OFF, 2-21 + + +W_STATUS_WINDOW_SMALL, 2-21 + + +structures +bitmap open, 4-26, 4-27 +clock, 3-19 +CONNECT_INFO, 2-3 +E_CONHIG, 3-16 +G_FONT_CONHIG, 4-18 +G_FONT_INFO, 1-46, 4-16 +G_GC, 3-9, 4-1 +G_SHADOW, 4-23 +graphics, 1-48 +P_EXTENT, 1-48, 3-1 +P_FSIG, 1-37 +P_POINT, 1-48, 3-1, 4-30 +P_RECT, 1-48, 4-29 +PIC_HEAD, 1-36 +sprite, 3-15 +W_SERVER_INFO, 1-38, 2-3 +W_SUPPORT_INFO, 2-26 +W_WINDATA, 3-1 +wMainGc, 2-2 +wMainWid, 2-2 +WMSG_KEY, 5-3 +WMSG_MOUSE, 5-9 +WMSG_RUBBER, 5-15 +WS_EV, 5-1 +WS_PIC_HEADER, 1-37 +WSERV_SPEC, 2-3 +wSpec, 2-2 +Structures +WS_FONT_FILE_HEADER, 1-46 +style +fonts, 1-45, 4-2 +sub-process +create p_execc, 1-26 +Swiss +fonts, 1-42 +synchronous +events, 5-1 +SYS$CONS +display process on MC, 1-7 +SYS$FSRV +process, 1-54 +SYS$MANG +process, 1-54 + + +INDEX + + +SYS$NTFY + + +process, 1-54 + + +SYS$NULL + + +process, 1-54 + + +sys$shll, 2-9 +SYS$SHLL + + +process, 1-54 + + +SYS$WSRV + + +process, 1-54 +window server process, 1-1 + + +system fonts + + +IDs, 4-17 + + +system modal + + +wCancelSystemModal, 1-17 +wsystemModal, 1-17 + + +system start-up + + +process, 1-54 + + +system type + + +from wConnect, 1-2 + + +system-modal + + +client, 1-17, 2-9 + + +task key + + +back set wSetBackTaskKey, 1-52 +cancel wCancelTaskKey, 1-52 +set wSetTaskKey, 1-52 + + +Task key + + +$3 and 3a, 1-52 + + +task key back cancel + + +wCancelBackTaskKey, 1-52 + + +task keys + + +setting, 1-52 + + +task order + + +client position, 2-8 + + +task switching + + +cancel back task switch keys, 5-13 +cancel task switch keys, 5-12 + +HC, 1-15 + +MC, 1-16 + +Series 3, 1-15 + +Series 3a, 1-15 + +set back task switch keys, 5-13 + +set task switch keys, 5-12 + +window server, 1-14 + + +task switching back cancel + + +wCancelBackTaskKey, 5-13 + + +task switching key cancel + + +wCancelTaskKey, 5-12 + + +task switching key set + + +wsetTaskKey, 5-12 + + +task switching set back + + +wsetBackTaskKey, 5-13 + + +temporary + + +text + + +status window, 2-19 + + +button, 4-24, 4-25 + +cursor, 1-29, 3-12 + +drawing, 1-44 + +fonts, 1-38, 4-14 + +transfer mode, 1-45, 4-2 + +transfer mode G_TRMODE_CLR, 1-45 +transfer mode G_TRMODE_INV, 1-45 +transfer mode G_TRMODE_REPL, 1-45 +transfer mode G_TRMODE_ SET, 1-45 +width, 4-16 + + +xiii + + +WINDOW SERVER REFERENCE + + +text count +gTextCount, 4-17 +text drawing +gPrintBoxText, 1-44 +gPrintClipText, 1-44 +gPrintText, 1-44 +gShadowText, 1-44 +gXPrintText, 1-44 +text mode +G_TRMODE_CLR, 4-2 +G_TRMODE_INV, 4-2 +G_TRMODE_REPL, 4-2 +G_TRMODE_SET, 4-2 +text output +WLIB functions, 4-19 +text print +boxed, 4-20 +clipped, 4-20 +embellishment, 4-21 +gPrintText, 4-20 +shadowed, 4-23 +text print boxed +gPrintBoxText, 4-20 +text print clipped +gPrintClipText, 4-20 +text print embellished +gXPrintText, 4-21 +text print shadowed +gShadowText, 4-23 +text width +gTextCount, 1-44 +gTextWidth, 1-44 +wGetWidthTable, 1-44 +text width get +gTextWidth, 4-16 +textmode +transfer mode, 1-45, 4-2 +time-stamp +events, 1-14 +top-level +window, 1-18 +transfer mode +text, 1-45, 4-2 +update event selection +WLIB function, 5-2 +update region +redrawing, 1-24 +user +event, 5-10 +user message +event, 5-7 +validate function +wValidateRect, 3-11 +wValidateWin, 3-11, 3-12 +validating +before drawing, 1-25 +WLIB function, 3-11 +version_id +window server, 2-4 +versions +window server, 1-1 +vertical leading +fonts, 4-14 + + +Xiv + + +visibility +window, 3-6 +visibility of +windows, 1-28 +visible window +wMakeVisible, 1-28 +W_BAND_COMPLETE_ON_UP +rubber band attribute, 5-15 +W_BAND_GRID_SNAP +rubber band attribute, 5-15 +W_BAND_GRID_SNAP_SIZE +rubber band attribute, 5-15 +W_BAND_INNER +rubber band attribute, 5-14 +W_BAND_OUTER +rubber band attribute, 5-14 +W_BAND_ RESIZE +rubber band attribute, 5-14 +W_BAND_START +rubber band attribute, 5-14 +W_BORD_CORNER_1 +border attribute, 4-11 +W_BORD_CORNER_2 +border attribute, 4-11 +W_BORD_CORNER_4 +border attribute, 4-11 +W_BORD_CUSHION +border attribute, 4-11 +W_BORD_OPEN +border attribute, 4-11 +W_BORD_SHADOW_D +border attribute, 4-11 +W_BORD_SHADOW_ON +border attribute, 4-11 +W_BORD_SHADOW_S +border attribute, 4-11 +W_CAPS_MODIFIER +key modifier, 5-3, 5-9 +W_CONNECT_AT_BACK +window server flag, 2-3 +W_CONNECT_CONNECTED +window server flag, 2-8 +W_CONNECT_DISABLE_LEAVES +window server flag, 2-3 +window server option, 1-11 +W_CONNECT_PRIORITY +window server flag, 2-3, 2-7, 2-8 +W_CONNECT_SYSTEM_MODAL +window server flag, 2-3, 2-8 +W_CONNECT_USER_FLAG +window server flag, 2-3, 2-8 +W_CORNER_BOTTOM_LEFT +message flag, 2-11 +W_CORNER_BOTTOM_RIGHT +message flag, 2-11 +W_CORNER_TOP_LEFT +message flag, 2-11 +W_CORNER_TOP_RIGHT +message flag, 2-11 +W_CTBY_S3 +compatibility mode, 2-6 +W_CTBY_S3_SCR +compatibility mode, 2-6 + + +W_CTRL_MODIFIER + +key modifier, 5-3, 5-9 +W_CURSOR_GREY + +cursor attribute, 3-12 +W_FUNC_MODIFIER + +key code, 6-2 +W_INFO_MSG_MAX_LEN + +message constant, 2-11 +W_KEY_APP1 + +application keys, 5-5, 6-2 +W_KEY_APP2 + +application keys, 5-5, 6-2 +W_KEY_APP3 + +application keys, 5-5, 6-2 +W_KEY_APP4 + +application keys, 5-5, 6-2 +W_KEY_APP5 + +application keys, 5-5, 6-2 +W_KEY_APP6 + +application keys, 5-5, 6-2 +W_KEY_APP7 + +application keys, 5-5, 6-2 +W_KEY_APP8 + +application keys, 5-5, 6-2 +W_KEY_APP9 + +application keys, 6-2 +W_KEY_APPn + +application keys, 5-5 +W_KEY_BACKLIGHT + +key code, 5-5 +W_KEY_CALC_CHNG_SIGN + +key code, 6-2 +W_KEY_CALC_CLEAR + +key code, 6-2 +W_KEY_CALC_DECIMAL + +key code, 6-2 +W_KEY_CALC_MEM_CLEAR + +key code, 6-2 +W_KEY_CALC_MEM_INPUT + +key code, 6-2 +W_KEY_CALC_MEM_MINUS + +key code, 6-2 +W_KEY_CALC_MEM_PLUS + +key code, 6-2 +W_KEY_CALC_MEM_RECALL + +key code, 6-2 +W_KEY_CALC_PERCENT + +key code, 6-2 +W_KEY_CAPS_LOCK + +key code, 5-5 +W_KEY_DELETE_LEFT + +key code, 5-4 +W_KEY_DELETE_RIGHT + +key code, 5-4 +W_KEY_DIAMOND + +key code, 5-5 +W_KEY_DOWN + +key code, 5-4 +W_KEY_END + +key code, 5-4 +W_KEY_ESCAPE + +key code, 5-4 +W_KEY_HELP + +key code, 5-5 + + +INDEX + + +W_KEY_HOME + +key code, 5-4 +W_KEY_INFO + +key code, 5-5 +W_KEY_IR_BRING + +key code, 6-2 +W_KEY_IR_LINK + +key code, 6-2 +W_KEY_IR_SEND + +key code, 6-2 +W_KEY_LCD + +key code, 5-5 +W_KEY_LCD_MINUS + +key code, 5-5 +W_KEY_LEFT + +key code, 5-4 +W_KEY_MENU + +key code, 5-5 +W_KEY_MODE + +event, 1-2 + +key code, 1-15, 5-5 +W_KEY_OFF + +key code, 5-6 +W_KEY_ON + +key code, 5-5 +W_KEY_PAGE_DOWN + +key code, 5-4 +W_KEY_PAGE_UP + +key code, 5-4 +W_KEY_RETURN + +key code, 5-4 +W_KEY_RIGHT + +key code, 5-4 +W_KEY_TAB + +key code, 5-4, 6-1 +W_KEY_TASK + +key code, 5-4 +W_KEY_UP + +key code, 5-4 +W_KEY_VOICE + +key code, 5-4 +W_MOUSE_DOWN + +events, 5-9 +W_MOUSE_OUTSIDE + +events, 5-9 +W_NUM_LOCK_MODIFIER + +key modifier, 5-3, 5-9 +W_PANIC_SPRITE + +panic, 3-16 +W_PANIC_SPRITE_EXISTS + +panic, 3-16 +W_PSION_MODIFIER + +key modifier, 5-3, 5-9 +W_RUSSIAN_MODIFIER + +key code, 6-2 +W_SERVER_INFO + +for system font ID, 1-38 + +structure, 1-38, 2-3 +W_SHIFT_MODIFIER + +key modifier, 5-3, 5-9 +W_SPRITE_CLIP_CHILDREN + +sprite attribute, 3-15 + +sprites, 1-23 + + +WINDOW SERVER REFERENCE + + +W_STATUS_WIN_NO_DIAMOND + +status window flag, 2-23 + +window status flag, 2-23 +W_STATUS_WINDOW_BIG + +status window flag, 2-21 +W_STATUS_WINDOW_CTBY + +status window flag, 2-21 +W_STATUS_WINDOW_ICON + +status window flag, 2-23 +W_STATUS_WINDOW_OFF + +status window flag, 2-21 +W_STATUS_WINDOW_SMALL + +status window flag, 2-21 +W_SUPPORT_CTBY_S3 + +window server flag, 2-26 +W_SUPPORT_GREY + +window server flag, 2-26 +W_SUPPORT_INFO + +structure, 2-26 +W_SYSTEM_FONT_INTERNAL_S3 + +font type system, 4-17 +W_SYSTEM_FONT_INTERNAL_S3B + +font type system, 4-17 +W_SYSTEM_FONT_S3 + +font type system, 4-17 +W_SYSTEM_FONT_S3B + +font type system, 4-17 +W_WIN_BACK_BITMAP + +window attribute, 1-19, 3-2 +W_WIN_BACK_CLR + +window attribute, 1-20, 1-25, 3-2 +W_WIN_BACK_CLR_NO_REDRAW + +window attribute, 1-21, 3-2 +W_WIN_BACK_GREY_BITMAP + +window attribute, 1-19, 3-2 +W_WIN_BACK_GREY_CLR + +window attribute, 1-20, 1-25, 3-2 + + +REDRAW +window attribute, 1-21 + + +window attribute, 1-21, 3-2 +W_WIN_DOUBLE_PIXEL +window attribute, 1-2, 3-3 + + +window attribute, 1-53, 3-3 +W_WIN_INPUT_ONLY +window attribute, 1-53, 3-3 + + +Xvi + + +W_WIN_MI_CROSS + +mouse icon attribute, 3-22 +W_WIN_MI_HSLIDE + +mouse icon attribute, 3-23 +W_WIN_MI_LEFT + +mouse icon attribute, 3-23 +W_WIN_MI_ MARGIN + +mouse icon attribute, 3-23 +W_WIN_MI_ MOVE + +mouse icon attribute, 3-23 +W_WIN_MI_ NULL + +mouse icon attribute, 1-52, 3-22 +W_WIN_MI PG_DOWN + +mouse icon attribute, 3-23 +W_WIN_MI_PG_UP + +mouse icon attribute, 3-23 +W_WIN_MI PUSHER + +mouse icon attribute, 3-22 +W_WIN_ML RESIZE + +mouse icon attribute, 3-23 +W_WIN_MIL RIGHT + +mouse icon attribute, 3-23 +W_WIN_MI STANDARD + +mouse icon, 1-52 + +mouse icon attribute, 3-22 +W_WIN_MI_ TEXT + +mouse icon attribute, 3-22 +W_WIN_MIL TO _BIG + +mouse icon attribute, 3-23 +W_WIN_MI_TO_SMALL + +mouse icon attribute, 3-23 +W_WIN_ML_ VSLIDE + +mouse icon attribute, 3-23 +W_WIN_MOUSE_DRAG +window attribute, 1-52, 3-3 +W_WIN_MOUSE_GRAB, 1-53 + +window attribute, 3-4 +W_WIN_MOUSE_MOVE +window attribute, 1-52, 3-3 +W_WIN_NO_MOUSE +window attribute, 1-52, 3-3 +W_WIN_NO_REDRAW + +window attribute, 1-20, 3-3 +W_WIN_PRIORITY + +redraw priority, 1-27 + +window attribute, 3-3 +W_WIN_RUBBER_ BAND +indow attribute, 3-4 + +window attribute_, 3-4 +W_WIN_RUBBER_BAND_ CAPTURE + +window attribute, 1-54 + + +iS +5 + + +W_WIN_RUBBER_BAND_COMPLETE_ON_ + + +RELEASE + +window attribute, 1-54 +W_WINDATA + +structure, 3-1 +wAppKeyHandler + +application keys, 1-15 +wAttachToClient + +MC, 1-16 + +WLIB function, 2-26 +wAttachToForegroundClient + +MC, 1-16 + +WLIB function, 2-26 + + +wBeginRedraw + + +redrawing WLIB functions, 1-25, 1-26 + + +WLIB function, 3-9 +wBeginRedrawGC + +graphics context temporary, 1-51 + +WLIB function, 3-9 +wBeginRedrawGCO + +graphics context temporary, 1-51 + +WLIB function, 3-10 +wBeginRedrawWin + +WLIB function, 3-9 +wBeginRedrawWinGC + +graphics context temporary, 1-51 + +WLIB function, 3-10 +wBeginRedrawWinGCO + +graphics context temporary, 1-51 + +WLIB function, 3-10 +wCallDYL + +WLIB function, 4-33 +wCallDYLReply + +WLIB function, 4-33 +wCancelBackTaskKey + +task key back cancel, 1-52 + +WLIB function, 5-13 +wCancelBusyMsg + +graphics output, 1-49 + +WLIB function, 2-12 +wCancelCaptureKey + +key specific cancel, 1-51 + +WLIB function, 5-12 +wCancelGetEvent + +and window server events, 1-28 + +WLIB function, 5-10 +wCancelSystemModal + +system modal cancel, 1-17 + +WLIB function, 2-9 +wCancelTaskKey + +task key cancel, 1-52 + +WLIB function, 5-12 +wCaptureKey + +specific key, 1-51 + +WLIB function, 5-11 +wCaptureMouse + +WLIB function, 5-13 +wChangeWinBitmap + +bitmap sequences, 1-21 + +WLIB function, 3-15 +wCheckPoint + +WLIB function, 2-7 +wCleanUp + +WLIB function, 2-7 +wClientIconised + +WLIB function, 2-9 +wClientInfo + +WLIB function, 2-8 +wClientPosition + +WLIB function, 2-8 +wCloseWindowTree + +windows destroying, 1-27 + +WLIB function, 3-6 +wCompatibilityMode + +S3 display mode, 2-6 +wConnect + +WLIB function, 1-8, 2-1, 2-3 + + +wCreateSprite + +sprites, 1-23 + +WLIB function, 3-15 +wCreateWindow + +window create, 1-18, 1-27 + +WLIB function, 3-1, 3-4 +wDetachClient + +WLIB function, 2-26 +wDisableKeyClick + +WLIB function, 2-26 +wDisableLeaves + +WLIB function, 2-7 +wDisablePauseKey + +pause key disable, 1-52 + +WLIB function, 2-10 +wDisconnect + +WLIB function, 2-5 +wDrawButton + +graphics output, 1-49 + +WLIB function, 4-24 +wDrawButton2 + +graphics output, 1-49 + +WLIB function, 4-25 +wDrawTextCursor + +graphics output, 1-49 + +WLIB function, 3-13 +WE_ESC + +event selected, 5-2 +WE_KEY + +event selected, 5-2 +WE_MOUSE + +event selected, 5-2 +WE_NORMAL + +event selected, 5-2 +WE_OTHERS + +event selected, 5-2 +WE_REDRAW + +event selected, 5-2 +WE_STATUS + +event selected, 5-2 +wEnablePauseKey + +pause key enable, 1-52 + +WLIB function, 2-9 +wEndCompute + +priority, 1-17 + +WLIB function, 2-8 +wEndRedraw + +graphics context free, 1-51 + +WLIB function, 3-11 +wEraseTextCursor + +cursor remove, 1-29 + +graphics output, 1-49 + +WLIB function, 3-13 +wFlush + +WLIB function, 2-5 +wFree + +bitmap free, 1-30 + +bitmap sequences, 1-21 + +sprites, 1-23 + + +WLIB function, 3-15, 3-16, 3-22, 3-23, 4-5, + + +4-16, 4-28, 4-32 +wGetCommand +WLIB function, 5-10 + + +WINDOW SERVER REFERENCE + + +wGetEvent + +event, 1-28, 1-51 + +event get async, 1-14 + +WLIB function, 5-2 +wGetEventSpecial + +event, 1-28, 1-51 + +event get async, 1-14 + +WLIB function, 5-2 +wGetEventUpdate + +WLIB function, 5-2 +wGetEventWait + +event, 1-51 + +event get, 1-14 + +WLIB function, 5-1 +wGetProcessList + +WLIB function, 2-10 +wGetWidthTable + +text layout WLIB function, 1-44 +wGetWindowPosition + +window position get, 1-27 + +WLIB function, 3-7 +width + +fonts, 4-14 +window + +attributes, 3-1 + +attributes get, 3-5 + +attributes set, 3-5 + +back up bitmaps, 1-19 + +back up bitmaps advantages, 1-19 + +back up bitmaps disadvantages, 1-19 + +back up bitmaps memory, 1-20 + +background field, 3-2 + +background modes, 1-3 + +child, 1-18 + +clipping, 1-25 + +creating, 1-27, 3-1, 3-4 + +destroying, 1-27, 3-6 + +drawing, 1-25 + +drawing region, 1-19 + +flicker free drawing, 1-25 + +flicker free redrawing, 1-25 + +inactive, 1-53 + +initialising, 1-27, 3-1 + +invisible function, 3-6 + +mouse only input, 1-53 + +no-redraw, 1-20 + +ownership, 1-18 + +parent, 1-18 + +position get wGetWindowPosition, 1-27 + +position set wWindowPosition, 1-27 + +root, 1-18 + +scrolling, 1-28, 3-7 + +scrolling optimised, 1-3 + +sibling, 1-18, 3-7 + +sibling position get, 3-7 + +sibling position set, 3-7 + +status, 2-19 + +top-level, 1-18 + +trees, 1-18, 3-5 + +visibility, 1-28, 3-6 + +visible function, 3-7 + +W_WIN_DOUBLE_PIXEL flag, 1-2 + +wInvalidateWin, 1-24 + + +XViii + + +Window +offset get, 3-6 +root reassign, 3-6 + +window attribute +W_WIN_BACK_BITMAP, 1-19, 3-2 +W_WIN_BACK_CLR, 1-20, 1-25, 3-2 +W_WIN_BACK_CLR_NO_REDRAW, + + +1-21, 3-2 +W_WIN_BACK_GREY_BITMAP, 1-19, +3-2 +W_WIN_BACK_ GREY _CLR, 1-20, 1-25, +3-2 + + +W_WIN_BACK_GREY_CLR_, 3-2 +W_WIN_BACK_GREY_CLR_NO_ +REDRAW, 1-21 +W_WIN_BACK_GREY_NONE, 1-25, 3-2 +W_WIN_BACK_GREY_NONE_, 3-2 +W_WIN_BACK_GREY_NONE_NO_ +REDRAW, 1-21 +W_WIN_BACK_GREY_SET, 1-20, 1-25, +3-2 +W_WIN_BACK_GREY_SET_, 3-2 +W_WIN_BACK_GREY_SET_NO_ +REDRAW, 1-21 +W_WIN_BACK_NONE, 1-25, 3-2 + + +1-21, 3-2 +W_WIN_DOUBLE_PIXEL, 3-3 + + +W_WIN_INACTIVE, 1-53, 3-3 +N_INPUT_ONLY, 1-53, 3-3 +IN_MOUSE_DRAG, 1-52, 3-3 +IN_MOUSE_GRAB, 3-4 +IN_MOUSE_MOVE, 1-52, 3-3 +IN_NO_MOUSE, 1-52, 3-3 +IN_NO_REDRAW,, 1-20, 3-3 +IN_PRIORITY, 3-3 +IN_RUBBER_BAND_, 3-4 +IN_RUBBER_BAND_CAPTURE, + + +Z + + +geececace +geeeeeez + + +25 +af + + +_WIN_RUBBER BAND_COMPLETE_ +ON_RELEASE, 1-54 +WS_WIN_BITMAP_GREY, 1-22 + +window create +wCreateWindow, 1-18, 1-27 + +window destroying +multi-tasking and, 3-6 + +window function +wCreateWindow, 3-1 +wInquireWindow, 3-1 +wSetWindow, 3-1 + +window invisible +wMakelInvisible, 1-28 + +window offset +wInquireWindowOffset, 1-18 + +window rectangle +wlInvalidateRect, 1-24 + +window scrolling +continuous, 1-29 + + +wscrollRect, 1-28 +wScrollWin, 1-28 +window server +buffered commands, 2-7 +changes, 1-1 +client information by process id, 2-8 +client list get, 2-10 +clients, 1-13 +configure, 2-24 +connect to, 1-8, 2-1, 2-3 +connecting to example code, 2-4 +disconnect from, 2-5 +error handling, 1-11, 2-7 +events and p_iowait, 1-28 +events and wCancelGetEvent, 1-28 +events and WM_CANCELLED, 1-28 +flag WSERV_FLAG_HOOK_NOTIFIER, +1-55 +flag WSERV_FLAG_HUNG_UP, 1-56 +flag WSERV_FLAG_LOW_BATTERY_ +WARNINGS, 1-56 +flag WSERV_FLAG_NO_NOTIFIER_ +REBOOT, 1-55 +flag +WSERV_FLAG_NO_PANIC_NOTIFY, +1-55 +introduction, 1-1 +process SYS$WSRYV, 1-1 +Series 3c and Siena update, 6-1 +supported features get, 2-26 +task switching, 1-14 +version 3, 1-7 +version 3.5, 1-5 +version 4, 1-2 +version from wConnect, 1-2 +version_id, 2-4 +versions, 1-1 +versions Series 3c and Siena update, 6-4 +versions Series 3c update, 6-4 +versions Siena update, 6-4 +W_CONNECT_DISABLE_LEAVES flag, +1-11 +wConnect WLIB function, 1-8 +WLIB functions, 2-1 +window server configuration +see WSERV_FLAG, 2-24 +window server constant +WS_LAST_CLIENT_POSITION, 2-8 +window server flag +E_PRIORITY_BACK, 2-7 +E_PRIORITY_FORE, 2-7 +W_CONNECT_AT_BACK, 2-3 +W_CONNECT_CONNECTED, 2-8 +W_CONNECT_DISABLE_LEAVES, 2-3 +W_CONNECT_PRIORITY, 2-3, 2-7, 2-8 +W_CONNECT_SYSTEM_MODAL, 2-3, +2-8 +W_CONNECT_USER_FLAG, 2-3, 2-8 +W_SUPPORT_CTBY_S3, 2-26 +W_SUPPORT_GREY, 2-26 +window server flags +see also WSERV_FLAG, 2-24 +window status flag +W_STATUS_WIN_NO_DIAMOND, 2-23 + + +INDEX + + +window tree +wlnitialiseWindowTree, 1-27 +window visible +wMakeVisible, 1-28 +windows +clipping child, 1-18 +drawables, 1-18 +graphics contexts, 1-18 +invalidating, 1-24 +overview, 1-18 +overview additional info, 1-27 +redrawing, 1-24, 1-25 +redrawing variants, 3-8 +windows and bitmaps +drawables, 1-18 +windows destroying +wCloseWindowTree, 1-27 +winfoMsg +graphics output, 1-49 +WLIB function, 2-11 +winfoMsgCorner +graphics output, 1-49 +WLIB function, 2-11 +winformOn +WLIB function, 5-11 +winformOnAll +WLIB function, 5-11 +wlnitialiseWindowTree +window tree, 1-27 +WLIB function, 3-5 +wInquireCompatibility +compatibility mode get, 2-7 +wInquireStatusWindow +WLIB function, 2-23 +wlInquireWindow +WLIB function, 3-1, 3-5 +wInquireWindowOffset +window offset, 1-18 +WLIB function, 3-6 +winvalidateRect +and invisible windows, 1-28 +window rectangle, 1-24 +WLIB function, 3-12 +winvalidateWin +and invisible windows, 1-28 +window, 1-24 +WLIB function, 3-12 +WLIB +header file, 1-8 +library with CLIB and PLIB, 1-8 +wLoadDYL +WLIB function, 4-33 +WM_ACTIVE +event, 1-53, 5-10 +WM_ATTACHED +event, 2-25, 5-8 +WM_BACKGROUND +event, 5-6 +WM_BAND_CANCEL +rubber band flag, 5-15 +WM_BAND_ERROR +rubber band flag, 5-15 +WM_BAND_ MOVE +rubber band flag, 5-15 + + +WINDOW SERVER REFERENCE + + +WM_BAND_NOMOVE +rubber band flag, 5-15 +WM_BAND_RESIZE +rubber band flag, 5-15 +WM_CANCELLED +and window server events, 1-28 +event, 1-28, 5-6, 5-10 +WM_COMMAND +event, 5-7 +WM_DATE_CHANGED +event, 1-3, 5-7 +WM_DEICONISE +event, 1-16, 2-8, 5-8 +WM_DETACHED +event, 2-25, 5-8 +WM_ESCAPE +event, 5-8 +WM_FOREGROUND +event, 2-25, 5-6 +WM_KEY +event, 1-15, 1-51, 5-3 +WM_KEYBOARD_STATE_ CHANGE +event, 5-8 +WM_MOUSE +event, 1-52, 5-9 +WM_MOUSE_MOVE +event, 5-9 +WM_MOUSE_PRESS +event, 5-9 +WM_MOUSE_RELEASE +event, 1-53, 5-9 +WM_ON +event, 5-7, 5-11 +WM_REDRAW +event, 3-12, 5-6 +WM_RUBBER +event, 1-53, 5-10, 5-14, 5-15 +WM_RUBBER_BAND_INIT +event, 1-54, 5-9 +WM_TASK_ KEY +event, 1-15, 5-7 +WM_TASK_UPDATE +event, 5-7 +WM_USER_MSG +event, 5-7, 5-10 +wMainGc +structure, 2-2 +wMain Wid +structure, 2-2 +wMakelnvisible +window WLIB function, 1-28 +WLIB function, 3-6 +wMake Visible +window WLIB function, 1-28 +WLIB function, 3-7 +WMSG_KEY +structure, 5-3 +WMSG_MOUSE +structure, 5-9 +WMSG_RUBBER +structure, 5-15 +Workabout +fonts, 1-41 +task switching, 1-15 + + +». ©. ¢ + + +wReassignRootWindow + +WLIB function, 3-6 +wReleaseMouse + +WLIB function, 5-13 +wRubberBand + +enter rubber band mode, 1-54 + +WLIB function, 5-14 +WS_ALERT_B + +alert flag, 1-3 +WS_CLOCK_AM_PM + +clock attribute, 3-17, 3-20 +WS_CLOCK_BOX + +clock attribute, 3-20 +WS_CLOCK_CENTERED + +clock attribute, 3-17, 3-20 +WS_CLOCK_FORCE_ANALOG + +clock attribute, 3-17, 3-20 +WS_CLOCK_FORCE_DIGITAL + +clock attribute, 3-17, 3-20 +WS_CLOCK_FORMATTED + +clock attribute, 3-19 +WS_CLOCK_GREY + +clock attribute, 3-20 +WS_CLOCK_LARGE_ANALOG + +clock attribute, 3-17, 3-19 +WS_CLOCK_MEDIUM + +clock attribute, 3-17, 3-19 +WS_CLOCK_MEDIUM2 + +clock attribute, 3-19 +WS_CLOCK_SMALL_DIGITAL + +clock attribute, 3-17, 3-19 +WS_CLOCK_WITH_DATE + +clock attribute, 3-17, 3-20 +WS_CLOCK_WITH_SECONDS + +clock attribute, 3-17, 3-20 +WS_CLOCK_XL_ANALOG + +clock attribute, 3-19 +WS_DEFAULT_ICON + +icon ID, 1-3 +WS_DEFAULT_ICON+1 + +icon grey ID, 1-3 +WS_EV + +structure, 5-1 +WS_EVENT_UNION + +events, 5-1 +WS_FONT_BASE + +define, 1-38 +WS_FONT_FILE_HEADERS + +structure, 1-46 +WS_FONT_SYSTEM + +define, 1-38 +WS_LAST_CLIENT_POSITION + +window server constant, 2-8 +WS_PIC_HEADER + +structure, 1-37 +WS_WIN_BITMAP_GREY + +window attribute, 1-22 +wsAlertA + +graphics output, 1-50 + +WLIB function, 2-18 +wsAlertCancel + +graphics output, 1-50 +wsAlertUpdate + +graphics output, 1-50 + + +WLIB function, 2-19 +wsAlertW + +alerts, 1-3 + +graphics output, 1-50 + +WLIB function, 2-14 +wsCreateClock + +graphics output, 1-49 + +WLIB function, 3-17 +wsCreateClock2 + +graphics output, 1-49 + +WLIB function, 3-19 +wscrollRect + +graphics output, 1-49 + +window scrolling, 1-28 + +WLIB function, 3-7 +wscrollWin + +graphics output, 1-49 + +window scrolling, 1-28 + +WLIB function, 3-8 +wsDisable + +graphics output, 1-50 + +WLIB function, 2-22 +wsDisableTemp + +graphics output, 1-50 + +WLIB function, 2-22 +wsEnable + +graphics output, 1-50 + +WLIB function, 2-21 +wsEnableTemp + +graphics output, 1-50 + +WLIB function, 2-22 +wsendCommand + +WLIB function, 5-10 +WSERV_FLAG + +HOOK_NOTIFIER, 2-24 + +HUNG_UP_SW, 2-25 + +LOW_BATTERY_WARNINGS, 2-25 + +NO_NOTIFIER_REBOOT, 2-24 + +NO_PANIC_NOTIFY, 2-24 + +NO_SHELL_REBOOT, 2-24 + +SW_NO_CAPS, 2-25 + +SW_NO_LINK, 2-25 + +SW_NO_LOW_BATTERY, 2-25 + +SW_NO_PACKS, 2-25 + +UPDATE_MSGS, 2-24 +WSERV_FLAG_HOOK_NOTIFIER + +window server flag, 1-55 +WSERV_FLAG_HUNG_UP + +window server flag, 1-56 +WSERV_FLAG_LOW_BATTERY_ +WARNINGS + +window server flag, 1-56 +WSERV_FLAG_NO_NOTIFIER_REBOOT + +window server flag, 1-55 +WSERV_FLAG_NO_PANIC_NOTIFY + +window server flag, 1-55 +WSERV_SPEC + +structure, 2-3 +wsetBackTaskKey + +task key back set, 1-52 + +WLIB function, 5-13 +wSetBusyMsg + +graphics output, 1-49 + +WLIB function, 2-11 + + +INDEX + + +wsetPriorityControl + +WLIB function, 2-8 +wsetSprite + +sprites, 1-23 + +WLIB function, 3-16 +wsSetSystemFont + +WLIB function, 4-17 +wsetTaskKey + +task key set, 1-52 + +WLIB function, 5-12 +wsetWinBitmap + +bitmap sequences, 1-21 + +bitmap WLIB function, 1-30 + +WLIB function, 3-14 +wsetWindow + +WLIB function, 3-1, 3-5 +wsfcomp.exe + +font file compiler, 1-43 +WSpcx.exe + +bitmap converter, 1-31 + +bitmap file converter, 1-31 +wSpec + +structure, 2-2 +wsScreenExt + +WLIB function, 2-21 +wsSelectList + +graphics output, 1-50 + +WLIB function, 2-23 +wsSetClock + +graphics output, 1-49 + +WLIB function, 3-22 +wsSetList + +graphics output, 1-50 + +WLIB function, 2-23 +wsStatus Window + +graphics output, 1-50 +wStartCompute + +priority, 1-17 + +WLIB function, 2-8 +wStartup + +WLIB function, 2-1 +wStatus Window + +status window permanent set, 2-21 +wsUpdate + +graphics output, 1-50 + +WLIB function, 2-22 +wsupportInfo + +WLIB function, 2-26 +wsystem + +process, 1-55 + +WLIB function, 2-24 +wsystemModal + +system modal, 1-17 + +WLIB function, 2-9 +wTextCursor + +cursor WLIB function, 1-29 + +graphics output, 1-49 + +WLIB function, 3-12 +wUserMsg + +WLIB function, 5-10 +wValidateRect + +WLIB function, 1-25, 3-11, 3-12 +wValidateWin + +WLIB function, 1-25, 3-11 + + +WINDOW SERVER REFERENCE + + +wWindowPosition +window position set, 1-27 +WLIB function, 3-7 + + +xxii + + diff --git a/docs/2-03 IO Devices Reference 2.30_djvu.txt b/docs/2-03 IO Devices Reference 2.30_djvu.txt new file mode 100755 index 0000000..d3ab4df --- /dev/null +++ b/docs/2-03 IO Devices Reference 2.30_djvu.txt @@ -0,0 +1,14945 @@ +SIBO 'C' Software Development Kit + + +I/O DEVICES REFERENCE + + +Version 2.30 + + +March 1, 1999 + + +(C) Copyright Psion PLC 1990-97 + + +All rights reserved. This manual and the programs referred to herein are copyrighted works of Psion PLC, +London, England. Reproduction in whole or in part, including utilization in machines capable of +reproduction or retrieval, without express written permission of Psion PLC, is prohibited. Reverse +engineering is also prohibited. + + +The information in this document is subject to change without notice. + + +Psion and the Psion logo are registered trademarks, and Psion, Psion MC, Psion HC, Psion Series 3, Psion +Series 3a, Psion Series 3c, Psion Siena and Psion Workabout are trademarks of Psion PLC. + + +TopSpeed is a registered trademark of Clarion Software Corporation. Intel 8086 and 80286 are registered +trademarks of Intel Corporation. IBM, IBM XT and IBM AT are registered trademarks of International +Business Machines Corp. Microsoft and MS-DOS are registered trademarks of Microsoft Corporation. +Apple and Macintosh are registered trademarks of Apple Computer Inc. VAX and VMS are registered +trademarks of Digital Equipment Corporation. Brief is a registered trademark of Underware Inc. Psion +PLC acknowledges that some other names referred to are registered trademarks. + + +Contents + + +1 Introduction + + +Conventions used in this manual + + +2 Console + + +Introduction + + +Automatic opening of a console channel +Explicit opening of a console channel +P_FSET service call convention + +Panics + + +Console services + + +Open the console (p_open) + +Close the console (p_close) + +Write to the console (p_write) + +Read a keypress (P_LFREAD) + +Cancel an outstanding read (P_FCANCEL) + +Test for outstanding keypresses (P_FTEST) + +Flush keyboard buffer (P_FFLUSH) + +Edit a string (P_FEDIT) + +Sense console data (P_FSENSE) + +Set the console window size (P_FSET, P_SCR_WSET) +Scroll the window content (P_LSCR_SCROLL) + +Clear a rectangle (P_FSET, P_SCR_CLR) + +Position cursor to next line (P_FSET, P_SCR_NEL) + +Set the cursor position (absolute) (P_LFSET, P_SCR_POSA) +Set the cursor position (relative) (P_LFSET, P_SCR_POSR) +Turn the cursor on or off (P_FSET, P_SCR_CURSOR) +Set scroll lock (P_LFSET, P_LSCR_SLOCK) + +Set auto wrap (P_FSET, P_SCR_WLOCK) + +Set escape on or off (P_FSET, P_SCR_ESCAPE) + +Set compatibility on or off (P_FSET, P_LSCR_COMPATIBILITY) +Set the use of grey on or off (P_LFSET, P_LSCR_GREY) + + +Additional console services + + +Read an event (PLEVENT_READ) + +Test for outstanding event (P_LEVENT_TEST) + +Get console data (P_FINQ) + +Flush window server buffer (P_FWFLUSH) + +Set the console output rectangle (P_FSET, P_SCR_CSET) + +Set character attributes (P_FSET, P_SCR_ATTRB) + +Set the screen font (P_FSET, P_SCR_FONT) + +Set the last line wrap (P_FSET, P_SCR_LAST_LINE_WRAP) +Set window server flushing (P_FSET, P_SCR_FLUSH) +Disable reads (P_FSET, P_SCR_DISABLE READS) + +Bring to foreground (P_FSET, P_SCR_CLIENT_FOREGROUND) +Capture a key (P_LFSET, P_SCR_CAPTURE_KEY) + + +Cancel a key capture (P_LFSET, PLSCR_CANCEL_CAPTURE_KEY) +Example + + +3 Parallel Port + + +Introduction + + +Parallel port device names +Panics + + +Ww & +ae es + + +Parallel port services + + +Open a parallel port (p_open) + +Close a parallel port (p_close) + +Write to a parallel port (P_FWRITE) +Cancel a write request (P_FCANCEL) +Sense the input control lines (P_FSENSE) +Write the output control lines (P_FSET) + + +Example + + +Introduction + + +Serial port device names +Panics + + +Serial port parameters + + +Baud rate + +Character frame +Parity + +Handshaking + +Control flags +Terminator characters + + +Serial port errors +Serial port services + + +Open a serial port (p_open) + +Close a serial port (p_close) + +Read from the serial port (P_FREAD) + +Write to the serial port (P_FWRITE) + +Cancel any outstanding requests (P_FCANCEL) +Sense the serial port characteristics (P_FSENSE) +Set the serial port characteristics (P_FSET) +Flush the read buffer (P_FFLUSH) + +Test for received characters (P_FTEST) + +Test and set control lines (P_FCTRL) + +Inquire supported serial characteristics (P_FINQ) + + +Introduction + + +Sound on MC and HC machines +Sound on Series 3 machines +Sound on Series 3a machines +Panics + + +Sound services + + +Open the sound channel (p_open) + +Close the sound channel (p_close) + +Cancel a write request (P_FCANCEL) +Sense sound characteristics (P_FSENSE) +Set sound characteristics (P_FSET) +Write alarm note sequence (E_LFALARM) + + +HC, MC and Series 3a additional sound service + + +Write to voice n (E_LFSSOUNDCHANNELn) + + +Series 3 and Series 3a additional sound service + + +Write DTMF dial tones (E_FDIAL) + + +Example + + +1/0 DEVICES REFERENCE + + +WwW WW WW WwW W +WNHONNNR RR + + +4 Serial Port + + +5 Sound + + +NNANAAnAnNnaannannnnnann +r + + +ABRRBOBBWNNHNNHNNHNKRHR SEE + + +ii + + +CONTENTS + + +6 The Alarm Device Driver 6-1 +Introduction 6-1 + +Panics 6-2 + +Series 3, Series 3a and MC alarm services 6-2 + +Open the alarm channel (p_open) 6-2 + +Close the alarm channel (p_close) 6-2 + +Cancel an alarm request (P_FCANCEL) 6-2 + +Queue a timed alarm (A_FTIMED) 6-2 + +Queue an untimed alarm (A_FUNTIMED) 6-3 + +Series 3a additional alarm services 6-3 + +Queue a Series 3a timed alarm (A_FTIMED_X) 6-3 + +Queue a Series 3a untimed alarm (A_FUNTIMED_X) 6-4 + +7 The Free-Running Counter 7-1 +Introduction 7-1 + +FRC services 7-1 + +Open the FRC channel (p_open) 7-1 + +Close the FRC channel (p_close) 7-2 + +Cancel the FRC request (P_FCANCEL) 7-2 + +Start the free-running counter (A_FTIMED) 7-2 + +Read the elapsed time in ELFRC_COUNTING mode (P_FREAD) 7-2 + +Read the elapsed time in E_-FRC_REPEATING mode (P_FREAD) 7-3 + +8 The Series 3 World Database 8-1 +Introduction 8-1 + +Mode 8-1 + +Series 3 and Series 3a World database services 8-2 + +Open the World channel (p_open) 8-2 + +Close the World channel (p_close) 8-2 + +Cancel a World request (P_FCANCEL) 8-2 + +Find by city (WR_FIND_CITY) 8-2 + +Find by country (WR_FIND_COUNTRY) 8-2 + + +Find by city and country (WR_FIND_EXACT) 8-3 +Find next city (WR_NEXT) 8-3 +Find previous city (WR_BACK) 8-3 +Find home city (WR_GET_HOME) 8-3 +Set home city (WR_SET_HOME) 8-3 +Find default country (WR_GET_DEFAULT_COUNTRY) 8-4 +Set default country (WR_SET_DEFAULT_COUNTRY) 8-4 + + +Get dial string (WR_GET_DIAL_STRING) 8-4 +Open file for additional data (WR_SET_EXTRA) 8-5 +Modify additional data (WR_EXTRA) 8-5 +Read city data (WR_GET_CITY_DATA) 8-6 +Read city data (WR_GET_COUNTRY_DATA) 8-7 +Calculate distance, sunrise and sunset (WR_CALC) 8-8 +Read next city name (WR_NEXT_LOCK) 8-9 +World file types and their locations 8-9 +Main World file 8-9 +World Extension file 8-9 +World File format 8-9 +World Extension File format 8-10 +File header 8-10 +Data block 8-10 + + +iii + + +I/O DEVICES REFERENCE + + +9 Xmodem and Ymodem + + +Introduction +Data transfer protocols overview +One byte checksum +Two byte Cyclic Redundancy Check (CRC) +The Xmodem protocol +Link establishment +The data transfer phase +Link termination +Checksum data flow showing error recovery +The CRC variant +CRC data flow showing error recovery +The 1K variant +The 1K option data flow +Abandoning a transfer +The Ymodem protocol +Link establishment +The data transfer phase +Link termination +Ymodem file transfer data flow +The 1K variant +The G variant +Ymodem-G file transfer data flow +Abandoning a transfer +Protocol problems +Xmodem/Ymodem services +Open an Xmodem/Ymodem channel (p_open) +Close the Xmodem channel (p_close) +Connect to the remote computer (P_FCONNECT) +Disconnect from the remote computer P_FDISCONNECT) +Read data from the remote computer (P_FREAD) +Write data to the remote computer (P_FWRITE) + + +10 NCP and Link + + +iv + + +Introduction +Panics + +The Psion logical link layer protocol + +The SYS$NCP process +Connection establishment +Data transfer + +The LINK process + +NCP services +Open an NCP channel (p_open) +Close the NCP channel (p_close) +Connect to a remote process (P_FCONNECT) +Disconnect from the remote process (P_FDISCONNECT) +Read data from the remote process (P_LFREAD) +Write data to the remote process (P_FWRITE) +Cancel any outstanding request (P_FCANCEL) +Read supervisory information (P_FRSUPER) +Respond to a supervisory message (P_FINQ) +Sense the current channel activity (P_FSENSE) +Request the SYS$NCP terminate (P_FSTOP) + +Example + + +° +— + + +XO 0 0 O_O OO O_O SOO SO 0 XO +BBWWWWNNN DN RRR + + +Ne) +I I I I I I I +aN + + +KH HB woeomOUNUUADAUUY + + +So +Neo + + +11 Cradle and Docking Station + + +Introduction + +Cradle/Docking Station services +Open the device (p_open) +Close the channel (p_close) +Read from the device (P_FREAD) +Cancel a read (P_LFCANCEL) +Set the device type (P_FSET) +Sense the device type (P_FSENSE) + + +12 HC Magnetic Card Reader + + +Introduction +Open the MCR device (p_open) +Close the channel (p_close) +Read from the MCR device (P_FREAD) +Cancel a read (P_LFCANCEL) +Set the pull-up resistors (P_FSET) + + +13 HC Bar Code Reader + + +Hardware Description + +The Bar code reader interface module + +The bar code reader wand. + +Device drivers + +Bar code driver services +Open the bar code device (p_open) +Close the channel (p_close) +Read from the MCR device (P_FREAD) +Cancel a read (P_LFCANCEL) + + +14 HC Intelligent Bar Code Reader/RS232 Port + + +RS232/intelligent bar code reader module +The RS232 serial port interface +Power consumption +Powering the HC from an external power source +DSR auto wakeup switch +The bar code interface +Power consumption +Powering a bar code wand from the HC +Bar code symbologies +Code 128 +Codabar +Interleaved 2 of 5 +Code 39 +The UPC/EAN bar code formats +UPC E +UPC E + 2 digits +UPC E + 5 digits +EAN 8 bar code format +EAN 8 + 2 digits +EAN 8 + 5 digits +EAN 13 +EAN 13 + 2 digits +EAN 13 + 5 digits +UPC A +UPC A + 2 digits +UPC A + 5 digits + + +CONTENTS + + +I/O DEVICES REFERENCE + + +Bar code commands +Multiple options in a command +Issuing multiple commands +Serial intercharacter delay +Hard reset +Select bar code symbology +Check character options +Decoding options +Single read mode +Single read control +Set Interleaved 2 of 5 length +Set termination string +Code ID characters +Status request +Scanner enable + +RS232 port/bar code driver services +Open the device (p_open) +Close the channel (p_close) + + +Sense serial port characteristics (P_FSENSE) + + +Set serial port characteristics (P_FSET) +Read from device (P_FREAD) +Write to device (P_FWRITE) + +An example program + + +15 Introduction to Psion Infrared Communications + + +About this chapter +The IrDA protocol layer model +Introduction to Psion infrared communications +The Psion protocol layer model +The physical layer +Port geometry +Data transfer rate +Data link layer +Primary and secondary stations +IrLAP services +The network layer +IAS application logging +Discovery +Multiplexing +Link Control +The Psion IR Communications application +Third party applications +System resources +Keypresses +The IR printer port device driver + + +16 The AccessIr API + + +Using the AccessIr API +Prerequisites +Introduction to using the AccessIr API +Initialising the IR protocol stack + + +Opening and closing a channel to the IR device + + +Discovery + +Selection + +Connection + +Sending and accepting data +Disconnection + +Constants + + +CONTENTS + + +Opening and closing a channel to the IR device 16-3 +Open a channel to the IR device (p_open) 16-3 +Close a channel to the IR device (p_close) 16-4 + +Discovery, selection and connection 16-4 + +Discover IR enabled machines (P_FIRDISCOVER) 16-4 + +Select remote machine to connect to (P_FIRSELECT) 16-4 + +Connect to selected machine (P_FIRMAKECONNECT) 16-5 + +Wait for remote connect (primary) (P_FIRAWAITCONNECT) 16-5 + +Send and accept data 16-6 + +Accept data from selected remote machine (P_FREAD) 16-6 + +Send data to the selected remote machine (P_FWRITE) 16-6 + +Disconnection 16-6 + +Disconnect from remote machine (P_FIRDISCONNECT) 16-6 + +Example application 16-7 + +17 The IrMUX API 17-1 + +Using the IrMUX API 17-1 +Prerequisites 17-1 +Introduction to using the ITMUX API 17-1 +Initialising the IR protocol stack 17-1 +Logging on to and logging off from the ITMUX server 17-2 +Registering/unregistering applications with the LM-IAS server 17-2 +LM-IAS services 17-2 + +The IAS Get Value By Class message frame 17-3 +The IAS Get Value By Class reply frame 17-3 +Connectionless calls 17-3 +Reading and writing data 17-3 +Connection-oriented calls 17-3 +Discovery 17-4 +Connection - first time 17-4 +Disconnecting - first time 17-4 +Connection - second time 17-4 +Reading and writing data 17-4 +Disconnecting - second time 17-4 +Using Exclusive mode 17-4 +The IrMUX API 17-5 +IrMUX message format 17-5 +Log on to the IrMUX server (LM_Logon) 17-5 +Log off from the ITMUX server (LM_Logoff) 17-5 +Register a port number with the LM-IAS server (LM_RegisterPort) 17-5 +Free registered port with LM-IAS server (LM_UnRegisterPort) 17-6 +Queue a connectionless read request (LM_CLReadRequest) 17-6 +Queue a connectionless write request (LM_CLWriteRequest) 17-7 +Return info on in-range machines (LM_DiscoverDevicesRequest) 17-7 +Attempt to connect to a remote machine (LM_ConnectRequest) 17-7 +Wait for remote machine to connect (LM_WaitForConnection) 17-8 +Return the status of the link (LM_StatusRequest) 17-9 +Queue a read request on a connection (LM_ReadRequest) 17-9 +Queue a write request on a connection (LM_WriteRequest) 17-10 +Queue an unreliable read request (LM_UReadRequest) 17-10 +Queue an unreliable write request (LM_UWriteRequest) 17-11 +Obtain/release exclusive access (LM_AccessModeRequest) 17-11 +Place the connection into Idle/Active mode (LM_IdleRequest) 17-12 +Set retries on each data frame (LM_SetHandshakingLevel) 17-12 +Disconnect (LM_DisconnectRequest) 17-13 + + +1/0 DEVICES REFERENCE + + +18 Fast Charger + + +Introduction +Docking Station services + +HC/Workabout docking station fast charger services + +Fast charging batteries + +Measuring battery capacity +Rated charge capacity of standard Psion battery packs +Example calculations +Open the fast charger device (p_open) +Close the channel (p_close) +Set the battery charge mode (FCHG_SETCHARGEMODE) +Charging Psion battery packs +Charging custom battery packs +Read battery charge mode (FCHG_READCHARGEMODE) +Read the battery status (FCHG_READSTATUS) +Read the battery status asynchronously (FCHG_ASYNCHREAD) +Cancel an asynchronous read (FCHG_CANCEL) +Fast charge the main battery (FCHG_FASTCHARGE1) +Fast charge the spare battery (FCHG_FASTCHARGE2) +Discharge the main battery (FCHG_DISCHARGE1) +Example program + + +18-1 +18-1 +18-1 +18-2 +18-3 +18-3 +18-3 +18-3 +18-4 +18-4 +18-4 +18-5 +18-6 +18-6 +18-7 +18-7 +18-7 +18-7 +18-8 +18-8 + + +CHAPTER 1 + + +INTRODUCTION + + +This manual describes the I/O device drivers that have been written by Psion, except for the files device +driver and the the asynchronous timer device driver which are described in the Files and the Time, +Timers and Dates chapters of the PLIB Reference manual. + + +Before using any of the devices described in this manual the reader should be familiar with the contents of +the Asynchronous Requests and Semaphores and the I/O System chapters of the PLIB Reference manual. + + +Conventions used in this manual + + +I/O devices support a number of services, each specified by a function number of the form P_Fxxxx +(defined in p_file.h). For example, to write to a channel opened with a control block at *pcb, you may call: + + +p_ioc(pcb,P_FWRITE, additional parameters) ; +The notation p_ioc(P_FWRITE) or, more simply, P_FWRITE is used to refer to this function call. + + +All I/O function requests are asynchronous in principle. In practice, however, many I/O requests are +implemented synchronously, that is, the I/O operation will complete before the service call returns. For +example, the P_FCLOSE service is always implemented synchronously but the p_rREaD service is commonly +implemented asynchronously. + + +The description of a service that is implemented synchronously gives either the specific synchronous call +(such as p_open or p_close) or the p_iow service call prototype. Services implemented synchronously are +prototyped using only the p_iow I/O primitive, since there is no advantage in calling them +asynchronously. + + +A service that is implemented asynchronously may be called synchronously or asynchronously. The +description gives both the synchronous call (as described above) and the asynchronous p_ioc service call +prototype. Such a service may be called using the p_iow, p_ioc or p_ioa primitives. Note that the use of +p_ioc is in almost all cases preferable to the use of p_ioa (since the former will complete even in the +event of an error). + + +Note that smaller code will be generated by use of the primitives: + + +p_iow2, p_iow3, p_iow4, p_iow5, +p_ioc3, p_ioc4, p_ioc5d, +p_ioa3, p_ioa4, p_ioad. + + +Again the use of, for example, p_ioc3 is in almost all cases preferable to the use of p_ioa3. The same +statement applies to the other two variants of each function. + + +CHAPTER 2 + + +CONSOLE + + +Introduction + + +The console (con: ) device provides a basic set of screen and keyboard services, suitable for use by +relatively simple character-based C application programs. OPL programs automatically open a console +channel to provide support for the screen display and keyboard commands. + + +The console device is implemented differently on different machines in the SIBO range: +e on the HC and Series 3 machines the console device connects directly to the window server. + + +e onthe MC 200 and MC 400 machines the console device is implemented by an intermediate +sysscons display process. + + +There are also some differences in the services that are available on different machines. These differences +are stated in the description of the particular service to which they apply. + + +Some of the console functions use the P_PoINT, P_RECT and P_REcTP structures. They are defined in +p_graf.h (which is included by p_cons.h) as: + + +typedef struct +{ +WORD x; /* x coordinate */ +WORD y; /* y coordinate */ +} P_POINT; + + +typedef struct +{ +P_POINT tl; /* top left coordinates */ +P_POINT br; /* bottom right coordinates */ +} P_RECT; + + +typedef struct +{ +P_RECT r; /* rectangle */ +P_POINT p; /* point */ +} P_RECTP; + + +Co-ordinates are measured from the top left corner of the window (0, 0), and increment to the right (x) +and down (y). Co-ordinates are measured in character units. + + +When rectangles are specified the top left point is included in the rectangle and the bottom right corner is +just outside the rectangle. If a rectangle extends outside the console window then it is clipped to fit inside +the window (this feature may be used to save sensing the size of the window when a scroll or clear is +required up to the right/bottom edge of the window). + + +Versions of EPOC prior to version 2.32 do not support the opening of a console device when the +application program's total memory usage exceeds 32k. + + +I/O DEVICES REFERENCE + + +Automatic opening of a console channel + + +A channel to the console device is opened automatically during the start-up initialisation of a C program +built with the CLIB start-up module. This does not occur in the case of programs built with the PLIB +start-up module. + + +In PLIB programs, however, the console (if not already open) is opened automatically by the first use of +one of the PLIB simple console I/O functions (p_getch, p_printf, etc.) described in the //O System +chapter of the PLIB Reference manual. + + +The console channel handle of an automatically opened console device channel is stored in the pre- +defined static winHandle. + + +An automatically opened console is set to a size appropriate for the SIBO machine on which the +application is running. In a PLIB program you may, however, specify the window size of an automatically +opened console by setting the global p_REcT structure _DefScreenRect, as follows: + + +GLDEF_D _DefScreenRect; + + +_DefScreenRect.tl.x=0; +_DefScreenRect.tl.y=0; +_DefScreenRect.tl1.x=40; /* 40 columns */ +_DefScreenRect.tl.x=8; /* 8 rows */ + + +An automatically opened console is also set to the native mode of the machine. On the Series 3a machine +the console is opened in non-compatibility, with access to grey. In a PLIB program you may modify the +console mode by setting the global variable _pefscreenMode. The possible modes that may be set are: + + +use the native mode of the machine - this is the default value +compatibility mode, allowing Series 3 software to run on the Series 3a +non-compatibility mode, with grey enabled + +compatibility mode, but with grey enabled + + +WN FO + + +Thus, compatibility mode may be set as follows: + + +GLDEF_D INT _DefScreenMode; +_DefScreenMode=1; + + +Values that are not relevant to a particular type of machine are simply ignored. + + +If used, the values of _DefScreenRect and _DefScreenMode must be set before the first usage of any +function that causes the console to be opened. Ignore the ‘duplication’ message generated by the linker +when this code is included in your application. + + +In CLIB programs you can prevent the automatic opening of a console channel by defining the function +p_xwind in your code, as in the following example: + + +extern void *winHandle; + + +void p_xwind (void) +{ +winHandle=(void *)1; + + +} + + +int main(void) + + +{ + + +return (0); + + +} + + +You should ignore the warning, given during the linking of your program, that the symbol _p_xwind is +duplicated. + + +2 CONSOLE + + +If you use this technique, your CLIB program should not, of course, make any reference to stdin, stdout +or stderr, unless you have redirected them. Setting winHandle to | (an illegal value for a handle) will +guarantee that any such reference will fail with a panic. + + +Explicit opening of a console channel + + +In a PLIB program you may, if you wish, explicitly open a console channel by means of p_open. The +console channel handle must be stored in the pre-defined static winHandle that is used for an +automatically opened console channel. For example: + + +GLREF_D VOID *winHandle; +p_open (&winHandle, "CON:",-1); + + +This is particularly important if your program uses any of the PLIB simple console I/O functions. +Otherwise you may inadvertently attempt to open two console channels from the same process and your +process will be panicked. + + +After explicitly opening the console and before making any other use of its services you must make it +visible by setting its size with the p_rseEt service, using the p_scr_wset function code. + + +Compatibility mode and the availability of grey can be set by means of the p_Fset service, using the +P_SCR_COMPATIBILITY and p_scr_GRey function codes. + + +P_FSET service call convention + + +The p_rset function provides a number of services, determined by a function code. The function code is +assigned to a uworp whose address is passed as the third parameter to the p_iow function. The convention: + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CLR, P_RECT *prect); +is used to denote this. It should be interpreted as: +UWORD function; + + +function = P_SCR_CLR; +p_iow (pcb, P_FSET, &function,prect) ; + + +or equivalent. + + +Panics + + +All services (with the exception of p_open) will cause the calling process to be panicked if the passed +channel handle is not valid. Other panics are described under the particular service to which they apply. + + +SSS ee +Console services + + +p_open(CON:) Open the console +INT p_open(VOID **ppcb, CON:, -1); + + +Open a channel to the console device, writing the channel handle to *ppcb if successful. The console +window is not made visible until its size has been set by the p_rset service with a function code of +P_SCR_WSET. + + +When first opened the console properties are: +e auto wrap on +e auto flushing on +e — scroll lock off +e cursor display off +e pause key sequence enabled +e exit key sequence enabled (escape on) + + +e last line wrap (not available on MC) off + + +I/O DEVICES REFERENCE + + +It is recommended that ppcb should be the address of the pre-defined static winHandle, as in the +following example: + + +GLREF_D VOID *winHandle; + + +LOCAL_D UWORD func; +LOCAL_D INT err; + + +if ((err=p_open (&winHandle, "CON:",-1)) !=0) +{ +fail: +p_notifyerr(err,"Failed to open console",NULL, NULL, NULL) ; +p_exit (0); +} + +/* set the screen size */ + +rect.tl.x = rect.tl.y = 0; + +rect.br.x 257 + +rect.br.y = 9; + +func = P_SCR_WSET; + +if ((err=p_iow4 (winHandle, P_FSET, &func, &rect) ) !=0) +{ + + +p_close(winHandle) ; + + +goto fail; +} + + +You should not open the console yourself if your program is built with the CLIB start-up module. +The calling process is panicked if it already has an open channel to the console. + + +Returns zero if successful, or the negative error E_FILE_ALLOc if it failed to allocate memory for the +channel control block. In versions of EPOC prior to version 2.32, p_open("con:") will fail (and return a +negative number) if the total application memory usage exceeds 32k. + + +p_close Close the console +INT p_close(VOID *pcb) ; +Close the channel to the console. + + +Returns zero. + + +p_write Write to the console + + +INT p_write(VOID *pcb, UBYTE *buf, UWORD len); + + +Write len bytes of data from buf to the screen, starting at the current column (x coordinate) in the current +line (y coordinate). The value of 1en must be less than or equal to 255. + + +The request will always return immediately (but the text may not appear immediately if auto flushing is +turned off) and there is no advantage in calling this service in any way other than with p_write. + + +Characters are printed directly on the screen unless they are one of: + + +BELL sound the bell (buzzer) + +TAB go to the next tab stop (tabs are every 8 characters) +BS backspace + +CR move the cursor to the beginning of the current line +LF, VT move the cursor down one line + +FF move the cursor down one screen + + +2 CONSOLE + + +If there are more characters in buf than will fit on the current line, the writing of the additional characters +depends on the auto wrap and scroll states as set by the p_rsEt service with function codes p_scR_WLOCK +and p_SCR_SLOCK: + + +e if auto wrap is on then any additional characters in buf are written from character position zero +in the following line. If this following line is off the screen then the screen will first be scrolled +up by one line, provided scroll lock is off. + + +e if auto wrap is off then the additional characters in buf successively overwrite the last character +in the line. On completion of the write request the last character in the row will therefore be the +final character in but. This assumes, of course, that there are no cursor movement characters in +buf. + + +The request cannot fail and so the function call always returns zero. + + +P_ FREAD Read a keypress + + +INT p_iow(VOID *pcb, P_FREAD, P_CON_KBREC *kbrec);_.VOID p_ioc(VOID *pcb, P_FREAD, WORD +*pstat, P_CON_KBREC *kbrec) ; + + +RRead a keypress record into the p_con_KBRECc struct pointed to by kbrec. The p_con_KBREC Struct is +defined in p_cons.h as: + + +typedef struct +{ + + +UWORD keycode; /* Code for the key pressed */ +UBYTE modifiers; /* State shift keys etc */ +UBYTE count; /* Used to accumulate auto-repeat counts */ + + +} P_CON_KBREC; + + +The content of modifiers is a set of bit flags indicating which modifier keys were held down when a key +was pressed: + + +W_SHIFT_MODIFIER SHIFT key down +W_CTRL_MODIFIER CONTROL key down +W_PSION_MODIFIER PSION key down +W_CAPS_MODIFIER Caps lock on + + +W_NUM_LOCK_MODIFIER Num lock on + + +The content of keycode for a standard keypress is simply its ASCII character code. There are also many +special values that the keycode can provide, corresponding to particular keypresses or keypress +combinations. These are fully described in the Events chapter of the Window Server Reference manual. + + +A P_FREAD request will not complete until either there is an outstanding keypress to read or the request is +cancelled. A synchronous request may therefore take an indefinitely long time to return. A prior +p_iow(P_FTEST) call will determine if there is an outstanding keypress. + + +The calling process is panicked if pcb is not a valid channel handle, or if there is an outstanding p_rFREAD +(Or P_EVENT_READ) request. + + +The completion status code is returned by the synchronous p_iow(P_FREAD) and written to *pstat by +asynchronous calls. The completion status code is zero if the p_rREAD request completed successfully, or +the negative error &_FILE_CANCEL if the request was cancelled by a p_FcaANCEL request. + + +P_FCANCEL Cancel an outstanding read +INT p_iow(VOID *pcb, P_FCANCEL) ; +Cancel an outstanding read; the request is harmless if there are no reads outstanding. + + +The request cannot fail and always returns zero. + + +P_FTEST Test for outstanding keypresses +INT p_iow(VOID *pcb, P_FTEST, UWORD *pflag); +Set *pflag to TRUE if there are any keypresses outstanding, otherwise set it to FALSE. + + +The request cannot fail and always returns zero. + + +1/0 DEVICES REFERENCE + + +P_FFLUSH Flush keyboard buffer +INT p_iow(VOID *pcb, P_FFLUSH) ; +Flush the keyboard buffer, all key presses held in the buffer are discarded. + + +The request cannot fail and always returns zero. + + +P_FEDIT Edit a string + + +INT p_iow(VOID *pcb, P_FEDIT, P_CEDIT *cedit, UWORD *plen); +Edit a string. The p_cepiT struct is defined in p_screen.h as: + + +typedef struct +{ + + +UBYTE cursorpos; /* not used */ + +UBYTE trap; /* trap input errors or not */ +UBYTE string[P_MAXEDITSTR]; /* string to edit */ + +} P_CEDIT; + + +Allows the user to edit the text in string. The cursor is initially positioned at the end of the string. The +user is not allowed to expand the string beyond *plen characters (string must be initially not more than +*plen characters in length). Since *plen does not include the terminating zero, its value must be Jess than +P_MAXEDITSTR (256). + + +Pressing the left or right arrow keys moves the cursor one character to the left or right in the string. The +HOME and END keys move the cursor to the start and end of the string. + + +Pressing Esc clears the content of the string. The value of trap determines what happens if Esc is pressed +when the string is already clear. If trap is TRUE, then the editing operation will complete with string +unchanged, if trap is FALSE then nothing will happen. + + +Returns zero, or E_LFILE_CANCEL if editing is terminated by pressing Esc. + + +P_FSENSE Sense console data + + +INT p_iow(VOID *pcb, P_FSENSE, P_RECTP *prectp) ; + + +Write the cursor position to (prectp->p.x,prectp->p.y) and write the window co-ordinates to prectp- +>x. The window co-ordinates are those specified by the most recent prior call to P_rsET with function code +P_SCR_WSET or P_SCR_CSET. + + +For example: + + +LOCAL_C VOID SenseConsole (VOID) + + +{ +P_RECTP rectp; +WORD x_pos, y_pos, width, height; + + +p_iow (winHandle, P_FSENSE, &rectp) ; +X_pos = rectp.p.x; + +y_pos = rectp.p.y; + +width = rectp.r.br.x - rectp.r.tl.x; +height = rectp.r.br.y - rectp.r.tl.y; + + +/* do something with the coordinates here */ + + +} + + +The request cannot fail and always returns zero. + + +2 CONSOLE + + +P_FSET, P_SCR_WSET Set the console window size + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_WSET, P_RECT *prect); + + +Set the console window size. A p_rEcT structure is used for historical reasons; in practice prect- +>rect .t1 should always be (0,0). For example, to set the console size to 9 lines high by 25 columns wide +(the full screen size for HC machines) you should use: + + +P_RECT rect; +UWORD func; + + +rect.tl.x rect.tl.y = 0; +rect.br.x = 25; + +rect.br.y = 9; + +func = P_SCR_WSET; + + +p_iow(winHandle, P_FSET, &func, &rect) ; + + +Returns zero if successful, otherwise the error =_GEN_NomEmory if unable to create a window of the new size. + + +P_FSET, P_SCR_SCROLL Scroll the window content + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_SCROLL, P_RECTP *pscrl)j; + + +Scroll the rectangle pscri->r by the vector amount (pscr1->p.x,pscrl->p.y). The area left behind the +trailing edge(s) is cleared. Scrolling a rectangle is not affected by setting or clearing the scroll lock. + + +pscrl->r describes the rectangle to scroll; +pscrl->p.x gives the horizontal distance to scroll (negative left, positive right); +pscrl->p.y gives the vertical distance to scroll (negative up, positive down). + + +For example: + + +LOCAL_C VOID scroll(WORD amnt_v, WORD amnt_h) + +/* scroll the whole window vertically amnt_v and horizontally amnt_h */ +{ +UWORD func; +P_RECTP scrl; + + +p_iow(winHandle, P_FSENSE, &scrl); + + +scrl.r.br.x -= scrl.r.tl.x; +scrilsr.br vy == serlar.tl.y; +scrl.r.tl.x = 0; +scrl.r.tl.y = 0; + +scrl.p.x = amnt_h; + +scrl.p.y = amnt_v; + +func = P_SCR_SCROLL; + + +p_iow(winHandle, P_FSET, &éfunc, &éscrl) ; +} + + +Returns zero. + + +P_FSET, P_SCR_CLR Clear a rectangle + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CLR, P_RECT *prect); + + +Clear the rectangle *prect. If *prect extends outside the console window then it is clipped so that only +the part that intersects with the window is cleared. + + +For example: + + +LOCAL_C VOID clear(P_RECT *prect) +{ +INT func; + + +func = P_SCR_CLR; +p_iow(winHandle, P_FSET, &éfunc,prect) ; +} + + +Returns zero. + + +I/O DEVICES REFERENCE + + +P_ FSET, P_SCR_NEL Position cursor to next line + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_NEL) ; + + +Move the cursor position to the first column on the next line. If the current row is the bottom row then, +provided scroll lock is not set, the window image scrolls up. + + +Returns zero. + + +P_FSET, P_SCR_POSA Set the cursor position (absolute) + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_POSA, P_POINT *ppoint); + + +Position the cursor to the point *ppoint. If *ppoint is outside the window the cursor moves to the the +position in the window closest to *ppoint. + + +Returns zero. + + +P_FSET, P_SCR_POSR Set the cursor position (relative) + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_POSR, P_POINT *ppoint); + + +Position the cursor by adding the displacement *ppoint to its current co-ordinates. If *ppoint is outside +the window the cursor moves to the the position in the window closest to *ppoint. + + +Returns zero. + + +P_FSET, P SCR_CURSOR Turn the cursor on or off + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CURSOR, UWORD *pflag); +Turn the cursor off if *pflag is FALSE, turn it on if *pflag is TRUE. + + +Turning the cursor on or off has no affect on the screen driver output other than enabling or disabling the +display of the cursor. + + +Returns zero. + + +P_FSET, P_ SCR_SLOCK Set scroll lock + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_SLOCK, UWORD *pflag); +Turn scroll lock off if *pflag is FALSE, turn it on if *pflag is TRUE. + + +When scroll lock is on scrolling of the console (caused by either P_scR_NEL or p_write) is disabled. It has +no effect on scrolling by means of P_rsET with function code P_SCR_SCROLL. + + +Returns zero. + + +P_FSET, P_SCR_WLOCK Set auto wrap + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_WLOCK, UWORD *pflag); +Turn auto wrap off if *pflag is FALSE, turn it on if *pflag 1s TRUE. + + +If auto wrap is off then character printing by p_write stops at the right margin, with further characters +successively overwriting the last character in the line. If auto wrap is on then trying to write a character +beyond the end of the line causes the cursor to move to the start of the next line. If the cursor is in the last +line of the window (and scroll lock is off) this will cause a scroll. + + +Returns zero. + + +2 CONSOLE + + +P_FSET, P_ SCR_ESCAPE Set escape on or off + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_ESCAPE, UWORD *pflag); +Turn escape handling off if *pf1ag is FALSE, turn it on if *pflag iS TRUE. + + +If escape handling is off then the user will not be able to use the exit key sequence to exit the console +application. The exit key sequence is PSION-ESC on HC and Series 3 machines, PSION-E on (English- +language) MC machines (PSION-? on foriegn language MCs, where ? is a character that depends on the +language). Additionally, on MC machines, the stop menu button will be disabled when escape is off. + + +Escape handling is initially on. + + +Returns zero. + + +P_FSET, P_SCR_COMPATIBILITY Set compatibility on or off + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_COMPATIBILITY, UWORD *pflag); +This function code is only available on machines that contain version 4, or later, of the window server. +Turn compatibility off if *pf1ag is FALSE, turn it on if *pflag iS TRUE. + +If compatibility is turned on, all drawing to the screen of the Series 3a is performed in double pixel mode. +On Series 3a machines, compatibility mode is initially on. + +Returns zero. + + +Note: A tru value of *pf1ag must be the value 1. Any other non-zero value may be interpreted differently +on future machines. + + +P_FSET, P_SCR_GREY Set the use of grey on or off +INT p_iow(VOID *pcb, P_FSET, &P_SCR_GREY, UWORD *pflag); + +This function code is only available on machines that contain version 4, or later, of the window server. +Turn the use of grey off if *pfiag 1s FALSE, turn it on if *pflag iS TRUE. + +On Series 3a machines, the use of grey is initially off. + + +Returns zero. + + +Additional console services + + +The following services have been implemented to support OPL/g on HC and Series 3 machines. They are +not available on machines in the MC range. + + +If your application is sufficiently complex to require these services it is recommended that you consider +writing it as a window server application rather than using the console device. + + +P_EVENT READ Read an event + + +INT p_iow(VOID *pcb, P_EVENT_READ, P_CON_KBREC *kbrec) ; +VOID p_ioc(VOID *pcb, P_EVENT_READ, WORD *pstat, P_CON_KBREC *kbrec) ; + + +RRead an event record (including keypress events) into the p_con_KBrREc struct pointed to by kbrec. The +P_CON_KBREC Struct is defined in p_cons.h as: + + +typedef struct +{ + + +UWORD keycode; /* Code for the key pressed */ +UBYTE modifiers; /* State shift keys etc */ +UBYTE count; /* Used to accumulate auto-repeat counts */ + + +} P_CON_KBREC; + + +I/O DEVICES REFERENCE + + +If the event was a keypress (a wM_KEy event) the result is exactly as for a P_FREAD request, described +earlier. + + +Other window server events result in one of the following values being written to keycode: + + +CONS_EVENT_FOREGROUND received a WM_FOREGROUND event +CONS_EVENT_BACKGROUND received a WM_BACKGROUND event +CONS_EVENT_ON_OFF received a WM_ON event +CONS_EVENT_COMMAND received a WM_COMMAND event + + +Future versions of the console device may report additional event types. Applications should be written to +ignore event types other than those listed above. + + +A P_EVENT_READ request will not complete until either an event is received or the request is cancelled. A +synchronous request may therefore take an indefinitely long time to return. A prior p_iow (P_EVENT_TEST) +call will determine if there is an outstanding event to be read. + + +The calling process is panicked if pcb is not a valid channel handle, or if there is an outstanding +P_EVENT_READ (or P_FREAD) request. + + +The completion status code is returned by the synchronous p_iow(P_EVENT_READ) and written to *pstat +by asynchronous calls. The completion status code is zero if the P_LEVENT_READ request completed +successfully, or the negative error E_LFILE_CANCEL if the request was cancelled by a P_FcANCEL request. + + +P_EVENT_ TEST Test for outstanding event + + +INT p_iow(VOID *pcb, P_EVENT_TEST, UWORD *pflag); + + +Set *pflag to TRUE if there are any events (including keypress events) outstanding, otherwise set it to +FALSE. + + +The request cannot fail and always returns zero. + + +P_FINQ Get console data + + +INT p_iow(VOID *pcb, P_FINQ, CONSOLE_INFO *pinfo); + + +Return information about the window server resources used by the console. coNSOLE_iInFo is defined in +p_cons.has: + + +typedef struct +{ + + +UINT window_handle; /* window server id of the console window */ + + +UINT font_handle; /* window server id of the console font */ +UINT line_height; /* pixel height of a console line - font height + leading */ +UINT char_width; /* pixel width of a monospaced console character */ + + +} CONSOLE_INFO; + + +Returns zero. + + +P_FWFLUSH Flush window server buffer + + +INT p_iow(VOID *pcb, P_FWFLUSH) ; +Flush the commands buffered to the window server - has no effect when auto flushing is on. + + +Returns zero. + + +P_FSET, P_SCR_CSET Set the console output rectangle + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CSET, P_RECT *prect); + + +Set the console output rectangle. All subsequent output is restricted (and wrapped) to the rectangle +described by prect within the console window. + + +Returns zero if successful, or E_GEN_aRG if any part of prect is outside the console window (i.e. either of +prect->tl.x Or prect->t1.y is less than zero, or prect->br.x Of prect->br.y respectively exceed the +width or height of the console window). + + +2-10 + + +2 CONSOLE + + +P_FSET, P_SCR_ATTRB Set character attributes + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_ATTRB, UWORD *pattrib); + + +Set the character attributes (style) to be used to display future characters written to the console. This +service permits the mixing of a number of different styles in the console window. + + +The value of *pattrib may be +P_SCR_NORMAL No additional style + + +or any combination of the bit flags: + + +P_SCR_BOLD Bold +P_SCR_REVERSE Reverse video +P_SCR_UNDLINE Underlined +P_SCR_BLINK Blinking +P_SCR_ITALIC Italics + + +It is not guaranteed that all the above attributes are supported in all versions of the console for the HC and +Series 3, but unsupported attributes are harmlessly ignored. + + +Any attribute which would have the effect of changing the width of a displayed character (such as +P_SCR_BOLD in current machines) is ignored. At the time of writing, no machine supports p_scR_BLINK. + + +For example: + + +UWORD func; +UWORD attrib; + + +p_printf("This is normal"); + +func = P_SCR_ATTRB; + +attrib = P_SCR_UNDLINE; + +p_iow (winHandle, P_FSET, &func, &attrib) ; +p_printf("This is underlined"); + +attrib = P_SCR_NORMAL; + +p_iow (winHandle, P_FSET, &func, &attrib) ; +p_printf ("Back to normal text"); + + +Returns zero. + + +P_FSET, P SCR_FONT Set the screen font + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_FONT, P_SCR_SET_FONT *pfont); + + +Set the console font and style for the entire window to those specified by the content of the +P_SCR_SET_FONT Struct pointed to by pfont. The struct is defined in p_cons.h as: + + +typedef struct +{ +UWORD id; /* font id */ +UWORD style; /* font style */ +} P_SCR_SET_FONT; + + +The allowed values for the font ia and style are those that are appropriate for setting a window server +graphics context (see the Window Server Reference manual). Note that the font must be monospaced; if +you set id to be the font id of a proportional font you should also include G_sty_mono in style. + + +For example: + + +UWORD func; +P_SCR_SET_FONT font; + + +font.id = WS_FONT_BASE; + +font.style = G_STY_MONO|G_STY_DOUBLE; +func = P_SCR_FONT; +p_iow(winHandle, P_FSET, &func, &font) ; + + +Since the size of the console window may be altered by changing the font, a call to p_rserT with function +code p_scr_Font will automatically clear and resize the console. + + +I/O DEVICES REFERENCE + + +It is not possible to mix different fonts and/or styles in the console window by means of this service. +Certain aspects of the font style may be changed using the P_FsET service with function code +P_SCR_ATTRB. + + +Returns zero. + + +P_FSET, P_SCR_LAST_ LINE WRAP Set the last line wrap + + +INT p_iow(VOID *pcb, P_FSET, &P_LAST_LINE_WRAP, UWORD *pflag); +Turn last line wrap on if *pflag is TRUE, turn it off if *pflag is FALSE. + + +If last line wrap is off then the display immediately wraps and scrolls (provided wrapping and scrolling +are not disabled) when a character is printed to the bottom right position in the console. + + +Last line wrap is initially off. + + +Returns zero. + + +P_FSET, P_SCR_FLUSH Set window server flushing + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_FLUSH, UWORD *pflag); + +Disable auto-flushing if *pflag is FALSE, enable it if *pflag is TRUE. + +Auto-flushing is initially enabled. + +When auto-flushing is enabled each window server function call is flushed immediately. + + +If auto-flushing is disabled, one or more window server function calls may be buffered. Execution of a +window server function may therefore be deferred until after the initiating function call has returned. In +such a case a function may return a window server error that was caused by an earlier, but buffered, +function call. + + +Returns zero. + + +P_FSET, P_SCR_DISABLE_READS Disable reads + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_DISABLE_READS, UWORD *pflag) ; +Disable reads if *pflag is TRUE, enable reads if *pflag iS FALSE. + + +A console application which needs to receive events directly from the window server, by calling +wGetEvent, should first disable reads. Otherwise all events are preferentially reported to the console. + + +No P_FREAD Of P_EVENT_READ request should be outstanding when this service is called and no more reads +may be performed until reads are re-enabled. + + +Initially reads are enabled. + + +Returns zero. + + +P_FSET, P_SCR_CLIENT_FOREGROUND Bring to foreground + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CLIENT_FOREGROUND, UWORD *pid); + + +Make the process with process ID *pid the foreground process. Use a value of zero for «pid to bring the +current process to the foreground. + + +The service does nothing if the process specified by *pid does not exist. + + +Returns zero. + + +2 CONSOLE + + +P_FSET, P_SCR_CAPTURE KEY Capture a key + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CAPTURE_KEY, CONSOLE_CAPTURE_KEY *pcapt) ; +Specify a keypress that is to be sent to the calling process, irrespective of its foreground/background status. + + +The keypress combination to be captured is specified by the content of the consoLE_CAPTURE_KEY Struct, +defined in p_cons.h as: + + +typedef struct +{ +UWORD code; +UBYTE modifier_mask; +UBYTE dont_care_mask; +} CONSOLE_CAPTURE_KEY; + + +Every time a key is pressed the window server evaluates +(key_pressed==code) && ((key_pressed_modifiersédont_care_mask) ==modifier_mask) + + +and if the result is TRuz then the keyboard event is sent to the process that specified the capture. + + +For example, + + +UWORD func; +CONSOLE_CAPTURE_KEY capture; + + +capture.code = W_SPECIAL_KEY|'a'; + +capture.modifier_mask = W_PSION_MODIFIER; +capture.dont_care_mask = W_PSION_MODIFIER|W_SHIFT_MODIFIER; +func=P_SCR_CAPTURE_KEY; + +p_iow (winHandle, P_FSET, &func, &capture) ; + + +captures PSION+A and PSION+CTRL+A. + + +See also the equivalent window server function wcapturekey, described in the Window Server Reference +manual. The struct elements code, modifier_mask and dont_care_mask correspond to the wcaptureKey +parameters keycode, modifiers and modifier_mask respectively. + + +Returns zero if successful, or =_FILE_ExIst if the specified keycode/modifier combination is currently +captured by any process. + + +P_FSET, P_SCR_CANCEL_CAPTURE_KEY Cancel a key capture + + +INT p_iow(VOID *pcb, P_FSET, &P_SCR_CANCEL_CAPTURE_KEY, CONSOLE_CAPTURE_KEY *pcapt) ; + + +Cancel a key capture set up by p_rset with function code p_scR_caPTURE_KEY. The content of pcapt must +exactly match that used to initiate the capture. + + +Returns zero if successful, or E_F1LE_nx1st 1f the keycode/modifier combination is not marked as +captured. + + +I/O DEVICES REFERENCE + + +Example + + +The following short program exercises many of the services described above. It consists of two parts, the +first of which simply receives keys typed by the user and reports them by type on the screen. The second +part enables the user to scroll a part of the display and to set the console attributes (scroll lock, line wrap +etc) to see how they affect the way typed characters are displayed. + + +#include +#include +#include +GLREF_D VOID *winHandle; + + +LOCAL_D P_RECTP RectP; + + +#define CON_HEIGHT 9 +#define CON_WIDTH 25 + + +LOCAL_C VOID doSetMode (UWORD mode, VOID *al) + + +/* +Shell to P_FSET +Hf, + +{ + +INT err; + +if ((err=p_iow4 (winHandle, P_FSET, &mode, al) ) !=0) + + +p_notifyerr(err,"Set service failed",NULL,NULL, NULL) ; + + +LOCAL_C VOID clear_line (VOID) +/* +position cursor to begining of the line and clear the line +*/ +{ +P_RECTP rectp; + + +p_iow3 (winHandle, P_FSENSE, &rectp) ; +rectp.p.x = 0; + +doSetMode (P_SCR_POSA, &rectp.p) ; +rectp.r.tl.x = 0; + +rectp.r.br.x = CON_WIDTH; +rectp.r.tl.y = rectp.p.y; +rect.r.br.y = rectp.p.y + 1; +doSetMode (P_SCR_CLR, &rectp.r); + +} + + +LOCAL_C VOID ReportKey (VOID) +{ +P_CON_KBREC kbrec; + + +p_printf ("Press Any Key (ESC quits)\r\n"); +FOREVER +{ +p_iow3 (winHandle, P_FREAD, &kbrec) ; +clear_line(); +if (kbrec.modifiers&W_PSION_MODIFIER) +p_printf ("Psion key %x",kbrec.keycode) ; +else if (p_isprint (kbrec.keycode) ) +p_printf ("Normal key %c",kbrec.keycode) ; +else if (kbrec. keycode==W_KEY_ESCAPE) +break; +else +p_printf("Non printable key %x",kbrec.keycode) ; + + +LOCAL_C VOID TryModes (VOID) +{ +INT wrap_lock,scroll_lock, escape; +P_RECTP rectp; +P_CON_KBREC kbrec; + + +escape = TRUE; /* set toggle flags to default values */ +wrap_lock = TRUE; +scroll_lock = FALSE; + + +rectp.r.tl.x = 5; /* define a rectangle for scrolling */ +rectp.r.tl.y = 1; +rectp.r.br.x = 20; +rectp.r.br.y = 6; + + +FOREVER +{ +p_iow3 (winHandle, P_FREAD, &kbrec) ; +if (! (kbrec.modifiers&W_PSION_MODIFIER) ) +{ +if (p_isprint (kbrec.keycode) ) +p_putch (kbrec.keycode) ; +else if (kbrec.keycode==W_KEY_RETURN) +doSetMode (P_SCR_NEL, 0); +else if (kbrec.keycode=='\b') +/* make backspace destructive */ +p_print("\b \b"); +else if (kbrec.keycode==W_KEY_ESCAPE) + + +break; +} +else +{ +kbrec.keycodeé&=(~W_SPECIAL_KEY) ; +switch (kbrec. keycode) +{ +case W_KEY_LEFT: +rectp.p.x = (-1); +rectp.p.y = (-1); +scroll: doSetMode (P_SCR_SCROLL, &rectp) ; +break; +case W_KEY_RIGHT: +rectp.p.x = (1); +rectp.p.y = (1); + + +goto scroll; +case W_KEY_DOWN: +rectp.p.x = 1; +rectp.p.y = 0; +goto scroll; +case W_KEY_UP: +rectp.p.x = (-1); +rectp.p.y = 0; +goto scroll; +case 'w': /* PSION modifier always gives lower case key */ + + +wrap_lock = !wrap_lock; +doSetMode (P_SCR_WLOCK, &wrap_lock) ; +break; + +case 's': +scroll_lock = !scroll_lock; +doSetMode (P_SCR_SLOCK, &scroll_lock) ; +break; + +case 'q': +escape = !escape; +doSetMode (P_SCR_ESCAPE, &escape) ; +break; + +default: /* do nothing */ +break; + + +} + + +2 CONSOLE + + +I/O DEVICES REFERENCE + + +GLDEF_C INT main(VOID) +/* +Allow user to type characters etc +xf +{ +INT err; +P_RECT rect; + + +if ((err=p_open (&winHandle, "CON:",-1)) !=0) +{ +p_notifyerr(err,"No Console device",NULL, NULL, NULL) ; +p_exit (0); +} +rect.tl.x = rect.tl.y = 0; /* set the screen size */ +rect.br.x = CON_WIDTH; +rect.br.y = CON_HEIGHT; +doSetMode (P_SCR_WSET, &rect) ; + + +p_printf ("Simple console program") ; +ReportKey (); + + +p_putch(0x0c) ; /* form feed to clear screen */ +p_printf ("Type characters or:"); + +p_printf ("Psion <- scrolls left/up"); + +p_printf ("Psion -> scrolls rght/dn"); +p_printf("Psion Down scrolls down"); +p_printf("Psion Up scrolls up"); + +p_printf("Psion W toggles wrap lock"); +p_printf("Psion S toggles scrl lock"); +p_printf("Psion Q toggles escape"); + +TryModes () ; + + +p_close(winHandle) ; +return(0); + + +} + + +CHAPTER 3 + + +PARALLEL PORT + + +Pc 9 EEEEEEEEEEE—— Ss +Introduction + + +One or more standard centronics parallel ports are available on all SIBO machines, in the form of either a +dual serial/parallel expansion module (for example, the HC and MC ranges) or a parallel expansion +module (such as the parallel 3-link for the Series 3). The HC cradle provides a third parallel port. + + +Parallel port device names + + +Depending on the number and location of ports available, the port device names are "PAR:A", "PAR:B" and +"PAR:C". For example, the Series 3 recognises only "PaAR:a", but an MC fitted with two serial/parallel +expansion modules recognises "Ppar:a" (left hand module, looking from the front of the machine) and +"PAR:B" (right hand module, looking from the front of the machine). + + +The parallel port driver is an output-only device driver that does not support a read service. + + +Panics + + +All services (with the exception of p_open) will cause the calling process to be panicked if the passed +channel handle is not valid. Other panics are described under the particular service to which they apply. + + +Parallel port services + + +p_open(PAR:) Open a parallel port +INT p_open(VOID **pcb, TEXT *pname, -1); + + +Open a channel to the parallel port *pname, where pname points to the string "PAR:A", "PAR:B" OF +"PAR:C", writing the address of the channel control block to *pcb. + + +The parallel port lines are powered up and all control lines are cleared low. The port will continue to +consume power until the channel is closed. + + +Returns zero if successful, or one of the following negative error numbers: + + +E_FILE_ALLOC failed to allocate memory for the control block +E_FILE_DEVICE the port does not exist +E_FILE_LOCKED or the port is already open + + +E_GEN_INUSE + + +p_close Close a parallel port + + +INT p_close(VOID *pcb); + + +Power down the parallel port lines and close the port channel corresponding to the specified control block, +first cancelling any outstanding Pp_FwRITE request. + + +Returns zero. + + +1/0 DEVICES REFERENCE + + +P_FWRITE Write to a parallel port + + +INT p_iow(VOID *pcb, P_FWRITE, VOID *buf, UWORD *plen); +VOID p_ioc(VOID *pcb, P_FWRITE, WORD *pstat, VOID *buf, UWORD *plen)j; + + +Write *plen bytes of data from buffer buf to the parallel port. It is the user's responsibility to preserve the +data at *pbuf and *plen until the write request completes. + + +The write request will never complete if the parallel port is not physically connected to a functioning +receiver. It is therefore advisable always to write asynchronously to the parallel port, and to use a timer +that provides a timeout on each write, as illustrated in the example at the end of this chapter. + + +Panics if a P_FWRITE request is currently outstanding, or if pcb is not a valid channel handle. + + +The completion status code is returned by the synchronous p_iow(P_FWRITE) and written to *pstat by +asynchronous calls. The completion status code is zero if the P_FWRITE request completed successfully, or +one of the following negative error numbers: + + +E_FILE_WRITE failed to write + + +E_FILE_CANCEL the write was cancelled by a call to the P_FcANCcEL service + + +P_FCANCEL Cancel a write request + + +INT p_iow(VOID *pcb, P_FCANCEL) ; +Cancel any outstanding P_FwRITE request, causing it to complete with an E_FILE_CANCEL completion code. + + +If a write request is outstanding then an indeterminate amount of data will have been written to the +parallel port before the request is cancelled. + + +Performing a cancel is harmless if no write request is outstanding. + + +Returns zero. + + +P_FSENSE Sense the input control lines +INT p_iow(VOID *pcb, P_FSENSE, UWORD *port); + + +This service is not, at the time of writing, available for any version of either the Series 3 or the Series 3a. +It is only available for machines in the HC and MC ranges that contain EPOC with a version number of +2.30 or later. + + +Write the current values of the centronics port input control lines to *port (all control lines are cleared +low when the port is opened). + + +The input control line values are defined, in p_par.h, according to the following table, where the pin +numbers are those appropriate for a 25-way D-type connector. + + +Symbol Control line Pin number +S_BUSY Busy 11 + +S_ACK Acknlg 10 +S_ERROR Error 15 + +S_PE Paper error 12 + + +Following the call, the values of the remaining bits at *port are undefined. + + +Returns zero. + + +P_FSET Write the output control lines + + +INT p_iow(VOID *pcb, P_FSET, UWORD *type, UWORD *port); + + +This service is not, at the time of writing, available for any version of either the Series 3 or the Series 3a. +It is only available for machines in the HC and MC ranges that contain EPOC with a version number of +2.30 or later. + + +Set or clear the centronics output control lines (all control lines are cleared low when the port is opened). + + +3-2 + + +3 PARALLEL PORT + + +If *t ype is 1 then the control lines corresponding to the bits set in *port will be set high. +If *t ype is 0 then the control lines corresponding to the bits set in *port will be cleared low. + + +The output control line values are defined, in p_par.h, according to the following table, where the pin +numbers are those appropriate for a 25-way D-type connector. + + +Symbol Control line Pin number +S_SPARE === See below +S_INIT Init 16 +S_AUTOFD Autofeed 14 +S_SELECT Select 17 + + +Any other bits set in *port are ignored. + + +The s_sparz bit is not available on the centronics connector. It may be of use in custom hardware designs +as it corresponds to pin 42 of the Psion-specific custom peripheral chip, astcs5. Changing this bit will +have no effect on the standard RS232/parallel expansion module. + + +Returns zero. + + +EEE +Example + + +The following example copies one or more files to a parallel port. It uses many of the parallel port +services, and illustrates the use of a timer to provide a timeout in conjunction with the p_rwRITE service. + + +include +include +include +include + + +LOCAL_D VOID *fcb=NULL; +LOCAL_D VOID *pcb=NULL; +LOCAL_D VOID *tcb=NULL; + + +LOCAL_C VOID Report (INT err) + + +TEXT buf [E_MAX_ERROR_TEXT_SIZE]; + + +p_errs (&buf[0],err); +p_printf("%s", &buf[0]); +} + + +LOCAL_C INT BufToParallel (VOID) +{ +WORD len; +WORD pstat,tstat; +ULONG time; +TEXT buf [64]; + + +len=p_read(fcb, &buf[0], 64); +if (len>=0) +{ +p_ioc5 (pcb, P_FWRITE, &pstat, &buf[0],é&len) ; +time=50; /* 5 second timeout */ +p_ioc4 (tcb, P_FRELATIVE, &tstat, &time) ; +p_iowait (); +if (pstat==E_FILE_PENDING) /* timer timed out */ +{ +p_iow2 (pcb, P_FCANCEL) ; +p_waitstat (&pstat) ; +return (E_FILE_CANCEL) ; +} +p_iow2 (tcb,P_FCANCEL); /* cancel timer */ +p_waitstat (&tstat) ; +} +return (len); + + +} + + +1/0 DEVICES REFERENCE + + +LOCAL_C VOID FileToParallel (VOID) + + +{ +INT err; + + +if ((err=p_open(&pcb, "PAR:A",-1))<0) /* open parallel port */ + + +{ +Report (err) ; +return; +} +FOREVER + + +{ +if ((err=BufToParallel()) <0) + + +{ +if (err!=E_FILE_EOF) + + +Report (err) ; +break; +} +} +p_close (pcb); +pcb=NULL; +} + + +GLDEF_C INT main(VOID) +{ +INT err; +TEXT bb[P_FNAMESIZE]; + + +if ((err=p_open(&tcb,"TIM:",-1))<0) /* open timer for timeouts */ + + +{ +Report (err) ; +return (0); +} +while (p_getl("Enter file name: + + +{ +if ((err=p_open (&fcb, &bb[0],P_FOPEN|P_FSTREAM) ) <0) /* open a file */ + + +{ + +Report (err); +continue; + +} +FileToParallel(); +p_close(fcb); + +} +p_close(tcb); +return(0); + + +} + + +Note that this example is based on the assumption that the only two asynchronous events that can occur +are the completion of a write to the parallel port and the expiry of the timer. For further discussion of a +more general case, see the description of p_ioc in the PLIB Reference manual. + + +", &bb[0],P_FNAMESIZE) ) + + +CHAPTER 4 + + +SERIAL PORT + + +eee ————————>>>——EE—————>>>>eE~— Ss +Introduction + + +The serial driver in the EPOC operating system supports a fully interrupt driven industry-standard RS-232 +serial link. + + +The driver consists of two cooperating layers. The lower driver is a physical device driver (PDD). It +provides a set of services that hide any hardware dependencies from the upper layer. + + +The upper layer of the driver is a logical device driver (LDD). It provides the logical (hardware +independent) services that are described in this chapter. Incoming data is buffered at this level. +Serial port device names + + +The first serial port on a SIBO machine has the device name "Tty:a". Many machines in the SIBO range +have more than one serial port available; a second port has the device name "TTy:8". For example, a +Series 3 fitted with a 3 Link (RS232) recognises only "tty:a", but an MC fitted with two serial/parallel +expansion modules recognises "TTy:a" and "tTy:B" (left and right hand modules respectively, looking +from the front). HC machines have a third port, on the cradle, with the device name "TTy:c". + + +HC machines also support serial ports with TTL level signals with device names "TTY:D", "TTY:E", +"TTy:F" (direct TTL levels) and "tTv:c", "TTy:H", "TTY:1" (inverted TTL levels). These ports are not +described in this chapter. + + +Panics + + +All services (with the exception of p_open) will cause the calling process to be panicked if the passed +channel handle is not valid. Other panics are described under the particular service to which they apply. + + +eee +Serial port parameters + + +The serial port parameters are set and sensed with the aid of a p_sRcuar struct, defined in p_serial.h as: + + +typedef struct + + +UBYTE tbaud; /* transmit baud rate */ + +UBYTE rbaud; /* receive baud rate */ + +UBYTE frame; /* number of data, parity and stop bits */ +UBYTE parity; /* parity type */ + +UBYTE hand; /* handshake flags */ + +UBYTE xon; /* XON character */ + +UBYTE xoff; /* XOFF character */ + +UBYTE flags; /* controlling flags */ + +ULONG tmask; /* terminator mask */ + + +} P_SRCHAR; +The possible settings are described in the following subsections. + + +One of the major problems with serial communications is ensuring that both ends of a physical link are +using the same port parameters. Typically, if one or more of the parameters differ, some data may be +transferred successfully whilst other data may not. This can make it difficult to determine which +parameter is incorrect. + + +1/0 DEVICES REFERENCE + + +Baud rate (tbaud, rbaud) + + +The Baud rate is, strictly speaking, a measure of the electrical signalling rate (the frequency of electrical +impulses) of a communications link. In practice, however, it is used to specify the data transfer rate, in +bits per second. The Baud rate and the data transfer rate are equal if one bit of data is encoded in each +signalling period. + + +For back-to-back serial communications the Baud rate and the data transfer rate are equivalent. It is only +when considering data transfer over a modem that the Baud rate and data transfer rate may differ. +Typically, modems that transfer data at a rate higher than 1200 bits per second encode more than | bit of +data into a single signalling period. For such a modem the Baud rate will differ from the data transfer +rate. + + +The transmit and receive Baud rates (tbaud and rbaud respectively) may be set to one of the following +values, which are defined in p_serial.h: + + +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA +P_BA + + +D_50 +D_75 +D_110 +D_134 +D_150 +D_300 +D_600 +D_1200 +D_1800 +D_2000 +D_2400 +D_3600 +D_4800 +D_7200 +D_9600 +D_19200 +D_38400 +D_56000 + + +U +U +U +U +U +U +U +U +U +U +U +U +U +U +U +U +U +U + + +The default value for both tbaud and rbaud is P_BAuD_9600. None of the SIBO serial port hardware +currently supports split Baud rates (separate transmit and receive Baud rates). + + +All machines in the SIBO range support Baud of rates of P_BAUD_50 to P_BAUD_9600 inclusive. In addition +the MC 200, MC 400 and Series 3a machines support a rate of P_BAUD_19200. The HC and Series 3 +machines can also be set to use P_BAUD_19200. However, the clock speed on current machines is slightly +too slow to handle this rate of data transfer, and overrun errors occur fairly frequently. Error correcting +protocols (eg Link) will run on the HC and Series 3 at 19200 Baud but, because of the high number of +retransmissions, they are slower than if they were run at 9600 Baud. + + +At 19200 Baud an interrupt occurs approximately every 500 microseconds. The following table shows the +number of instruction cycles available on a range of machines between two interrupts occurring at this +rate. + + +Machine Clock speed Instruction cycles +HC 3.84MHz 480 +Series 3 3.84MHz 480 +Series 3a 7.68MHz 960 +IBM PC/AT 4.77MHz 596 +MC 200/400 7.68MHz 960 + + +Character frame (¢rame) + + +The basic unit of transmission is the RS-232 asynchronous character frame. This is a sequence of bits +which consists of one start bit, between five and eight data bits, an optional parity bit and one or two stop +bits. + + +The start and stop bits are used to synchronise the data transmission. + + +The number of data bits required largely depends on the nature of the data that is being transferred. For +example, eight data bits are needed to transmit arbitrary binary data bytes, but seven bits are sufficient to +transmit text, containing only ASCII character codes with values not exceeding Ox7F. + + +Including a parity bit provides for an elementary degree of error detection in the transmitted data. + + +4-2 + + +4 SERIAL PORT + + +The value of frame describes the character frame. It may contain one of one of the following values, +defined in p_serial.h: + + +P_DATA_5 5 data bits +P_DATA_6 6 data bits +P_DATA_7 7 data bits +P_DATA_8 8 data bits + + +The value in frame may be ored with any combination of: + + +P_TWOSTOP 2 stop bits if set, 1 if clear +P_PARITY parity bit is present if set + + +All SIBO machines support all of the above settings. The default value of frame is +P_DATA_8 +for eight data bits, one stop bit and no parity. + + +In the majority of cases the total number of bits needed to transmit a single character is close to ten (for +example, one start bit, seven data bits, one parity bit and one stop bit). As a result, a reasonable estimate +of the character transfer rate is usually found by dividing the Baud rate by ten. + + +Parity (parity) + + +If present, the parity bit may be set or cleared to ensure that the combined sum of the set data and parity +bits is either odd (odd parity) or even (even parity). Alternatively it may be always set (mark parity) or +always clear (space parity). If the p_parrty bit is set in fiela, then parity should be set to one of the +following values, defined in p_serial.h: + + +P_PAR_EVEN even parity +P_PAR_ODD odd parity +P_PAR_MARK mark parity +P_PAR_SPACE space parity + + +Provided that p_partty is set in frame, the parity bit is generated (for transmission) and verified (on +receipt) by the port hardware. Reporting of parity errors may be suppressed by setting p_IGNORE_PARITY in +flags (see below). + + +The default value of parity is zero. No machine in the SIBO range supports either mark or space parity. + + +Handshaking (xon, xoff, hand) + + +Handshaking (also called flow control or buffer control) is a mechanism by which either end of a +communications link can pause and restart data transmission from the other end. There are two basic +forms: + + +e software handshaking +e hardware handshaking + + +Handshaking is required to prevent one end from sending data faster than the receiving end can process it. +For example, you may be able to send data to a printer at 9600 Baud, but it is unlikely that the printer is +capable of printing 960 characters per second. The printer will use handshaking to suspend the +transmission of data from time to time (when its internal buffer becomes full) and restart it when it is able +to receive more characters (some buffer space becomes available). + + +Software handshaking involves the transmission of particular characters, one to suspend and one to +resume transmission. This is usually called XON/XOFF handshaking, since the characters normally +selected to suspend and resume transmission are XOFF (0x13, pc3) and XON (0x11, pDc1) respectively. +Other characters may be used, provided that both ends of the communications link agree. + + +Software handshaking can sensibly be used only to transfer data that has pure textual content. Arbitrary +binary data may include bytes with values equal to one or other of the handshaking control characters. +The remote end will not be able to distinguish between such a character being sent as data or as a +handshaking control. For example, a WordStar file may contain the binary value 0x13 (XOFF) as an +underscore range marker. On receipt of this character the remote end will not transfer any data until it +receives an XON and so the transfer process may hang. More importantly, the XOFF character will be +removed from incoming data, being interpreted as a control character rather than as data. Thus, in the +above example, underscore range markers will be lost during the transfer. + + +The character codes used to resume and suspend transmission in software handshaking are stored in xon +and xoff. The default values are DC1 (0x11) and DC3 (0x13) respectively. + + +I/O DEVICES REFERENCE + + +Hardware handshaking involves the setting of a particular electrical state on specific control lines. It +usually involves a pair of lines, the output from one end being the input to the other, and vice versa. A +common cause of failure of hardware handshaking is the use of an improperly wired cable. Various +control line combinations may be used, as listed below. + + +DSR/DTR This form of handshaking uses the RS-232 control lines Data Set Ready (DSR) +and Data Terminal Ready (DTR). These lines were not originally intended for +use as data flow control lines, but were meant to be used to indicate the +presence or absence of a remote machine. However, many printers use +DSR/DTR handshaking to control the flow of data from a computer. + + +The receiver's output line (DTR) is held inactive (-ve) to suspend data transfer +and set active (+ve) to resume data transfer. This signal is expected to arrive +on the remote (sending) machine's DSR input line. + + +RTS/CTS This form uses the RS-232 control lines Request To Send (RTS) and Clear To +Send (CTS). These lines are the ones originally intended for use to control data +flow from either end. RTS/CTS handshaking is normally used for hardware +handshaking with a modem, and the DSR and DTR lines are used for their +originally intended purposes of indicating that a remote machine exists and the +port is open. + + +The output line (RTS) is held inactive (-ve) to suspend data transfer and set +active (+ve) to resume data transfer. This signal is received by the remote +machine via the CTS input line (ie its now Clear To Send data). + + +The Data Carrier Detect (DCD) line is not a control of flow handshaking line as described above. It is a +condition indicator from a modem to indicate that a connection now exists with a remote modem. The +DCD signal is an input only signal and there is no corresponding output line. + + +The form of handshaking to be used is specified by the value of hana. It should contain a combination of +the following bits, defined in p_serial.h: + + +P_OBEY_XOFF If set, receipt of the characters specified in xoff and xon suspend and resume +data transmission. If clear, these characters are treated as ordinary data. This +controls input XON/XOFF handshaking, which is independent of output +XON/XOFF handshaking. + + +P_SEND_XOFF If set, the characters specified in xoff and xon are transmitted to the remote +device to suspend and resume data transmission from the remote device. This +controls output XON/XOFF handshaking, which is independent of input +XON/XOFF handshaking. + + +P_IGN_CTS If clear, the driver will set its RTS line inactive to suspend transmission from +the remote device, and transmission will be suspended when the remote device +sets its RTS (incoming CTS) line inactive (RTS/CTS handshaking). If set, then +RTS is permanently active and the state of the input CTS line is ignored. + + +P_OBEY_DSR If set, transmission will be suspended when the remote device sets its DTR +(incoming DSR) line inactive (DTR/DSR handshaking). If clear, the state of +the incoming DSR line is ignored. In all cases the DTR line is held +permanently active while the seial port is powered up and open. + + +P_FAIL_DSR This is ignored unless p_oBEY_pDsR is set. If P_FAIL_DsR is set and the remote +device sets its DTR line inactive then any outstanding P_FWRITE or P_FREAD +request is completed with an E_FILE_LINE error (rather than simply suspending +transmission). The CCITT recommendations state that a serial port should hold +its DTR line active while the port is powered up and active. Setting +P_FAIL_psR allows application code to detect that a conforming remote device +has been removed or the connection broken. + + +P_OBEY_DCD If set, then transmission is suspended if the remote device sets the incoming +DCD line inactive. If clear, the state of the DCD line is ignored. + + +P_FAIL_DCD This is ignored unless P_oBEY_pDcD is set. If P_FAIL_pcp is set and the remote +device sets the incoming DCD line inactive then any outstanding P_FWRITE or +P_FREAD request is completed with an &_FILE_LINE error (rather than simply +suspending transmission). + + +4 SERIAL PORT + + +The default value of hana is zero, setting RTS/CTS handshaking. + + +In addition to using the control lines for hardware data flow control (which is transparent to the +application code), the serial port services allow the explicit testing of the state of the control lines or, for +example, to wait for the DCD line to be driven by a modem. + + +Control flags (¢1ags) + + +The control flags specify how the device driver should handle certain events. At the time of writing there +is only one control flag, defined in p_serial.h: + + +P_IGNORE_PARITY The presence or absence of a parity bit in received data is not under the +receiver's control. Setting p_1GNoRE_PaRITy causes the serial driver to discard +any parity errors on received data. A character received with a parity error is +placed in the receive buffer and treated as a normal character, even though it +may be in error. + + +For future compatibility the remaining bits of £1ags should be zero. +The default value of £1ags is zero. + + +Terminator characters (tmask) + + +A receiver has no universally reliable way of knowing when the transmitter has no more data to send. +Once some data has been received, the receiver may be entitled to assume that a period (say, five seconds) +in which no data arrives means that no further data will arrive. Clearly, this is not foolproof. + + +This problem may be solved provided that the transmitter cooperates with the receiver to the extent of +sending mutually agreed terminating characters. + + +One or more terminating characters may be specified by setting one or more bits of tmask. This consists of +32 bit flags, each corresponding (in order, from bit zero to bit 31) to a terminating character code in the +range 0x00 to ox1f inclusive. + + +Thus, setting bit zero (0x00000001) selects character code 0x00 to be a terminating character and setting +bit 26 (0x04000000) selects crru—z. An important use is to set bit 13 and/or bit 10 to select cr and/or Lr. +This allows text to be read a line at a time from a serial port. + + +The default value of tmask is zero, to select no terminating characters. + + +Serial port errors + + +Several errors can arise from a serial port that do not occur elsewhere. They include: + + +E_FILE_PARITY A parity error means that the received electrical signal corresponding to the +parity bit does not match the parity value calculated from the received data +bits. This is typically caused by electrical noise and usually indicates that the +data has been corrupted in transmission. Parity error detection is not +particularly robust, since many errors pass undetected. + + +E_FILE_FRAME A framing error means that the received electrical signal does not match the +start and stop bits. This most commonly occurs if data is being sent at a Baud +rate which differs from that which the receiver is expecting. Alternatively it +may mean that the number of stop bits expected by the receiver is greater than +the number being sent by the transmitter. + + +E_FILE_OVERRUN An overrun error occurs when the received electrical signal does not match the +stop bits. Overrun and framing errors are very similar and it is often difficult to +differentiate between them. Some devices may not report them as different +errors. + + +E_FILE_LINE A line error is generated when the hardware detects an inactive signal on an +input control line that the receiver requires to be permanently active (see also +Handshaking in the Serial port parameters section). + + +I/O DEVICES REFERENCE + + +I a SS SS 8 tev oo _TT_|vam_J =] +Serial port services + + +p_open(TTY:) Open a serial port +INT p_open(VOID **ppcb, TEXT *pname,-1) ; + + +Open a channel to the serial port *pname, where pname points to a serial port device name, as specified +earlier. If successful, write the channel to *ppcb and return zero. + + +For example: + + +if (!p_open(&pSerial, "TTY:A",-1) ) +{ + + +p_close(pSerial); + + +} + + +If successful the port will be powered up and the DTR line will be driven active to indicate to a connected +remote device that the port is open. + + +When opened a serial port will adopt its default characteristics of +e =©Baud +e data bits, no parity, 1 stop bit +e ~=RTS/CTS handshaking +e DCl1 is the XON, DC3 is the XOFF character +e Parity errors are not ignored +e No terminator characters + + +These characteristics may be incorrect for the required usage. To ensure that no received data is lost from, +say, a buffered modem, the RTS line will not be driven active until either the first P_rFREAD request or the +setting of some serial characteristics. (This, of course, assumes that the remote device is using RTS/CTS +handshaking.) + + +The call to p_open returns zero if successful, or a negative error. Errors include: + + +E_GEN_NOMEMORY there is not enough memory available to open the device + +E_GEN_INUSE the specified port is currently in use + +E_FILE_DEVICE an illegal or non-existent device is specified + +E_FILE_LOCKED attempting to open too many channels to the device driver + +p_close Close a serial port + + +INT p_close(VOID *pcb) ; +Close the specified channel to the serial driver. + + +The internal receive data buffer is flushed. If a character is currently being transmitted, the P_FCLOSE +request waits until its transmission is complete. The transmit data register becomes empty. + + +Any outstanding serial driver P_FREAD or P_FWRITE requests are cancelled. + + +The RTS and DTR lines are set inactive to indicate that the serial port is no longer in use and the serial +port is powered down. + + +Returns zero. + + +4 SERIAL PORT + + +P_FREAD Read from the serial port + + +INT p_iow(VOID *pcb, P_FREAD, VOID *buf, UWORD *plen); +VOID p_ioc(VOID *pcb, P_FREAD, WORD *pstat, VOID *buf, UWORD *plen)j; + + +Read up to *pien bytes to *buf from the serial port. The supplied buffer is assumed to be at least *pien +bytes long. The only limit to the amount of data that can be received in one call is the size of the data +buffer at but. It is the user's responsibility to preserve the data space pointed to by buf and plen until the +P_FREAD request completes. + + +The p_rreap request will typically take a significant length of time to complete and should normally be +called asynchronously in a quality system. + + +The request will complete when one of the following occurs: + + +@ *plen bytes have been received and transferred to *but. The request completes with zero +completion status code. + + +e areceive error is detected. The number of bytes received before the the error occurred is written +to *plen and these bytes transferred to *buf. The request completes with a negative error +completion status code. + + +¢ one of the terminating characters specified by the tmask field of the serial characteristcs is +received. The number of bytes received, including the terminating character, is written to *plen +and these bytes transferred to *buf. The request completes with zero completion status code. + + +e the request is cancelled. The number of bytes so far transferred to *buf is written to *plen. +The request completes with the —_F1LE_caNcEL completion status code. + + +The buffering mechanism at the serial driver's logical device driver level means that, following a +P_FCANCEL request, more characters may be available that have not yet been transferred to *but. The user +should test for this by calling the p_rtEst service and, if necessary, calling the p_rREAD service +synchronously to extract the remaining characters, as in the following example. + + +len=100; +p_ioc(pSerial,P_FREAD, &stat, &buf[0],&len) ; + + +p_iow(pSerial, P_FCANCEL) ; +p_waitstat (&stat); /* use up P_FREAD signal */ + + +p_printf("Buf[] contains %d bytes",len); + + +p_iow(pSerial, P_FTEST, &len) ; +if (len) +p_read(pSerial,&buf[0],len); /* will complete immediately */ + + +p_printf("There are %d more bytes available",len); + + +The calling process is panicked if a p_FREaD request is already outstanding or if pcb is not a valid channel +handle. + + +The completion status code is returned by the synchronous p_iow(P_FREAD) and written to *pstat by +asynchronous calls. The completion status code is zero if the p_rREaD request completed successfully, +otherwise it is a negative error number. Errors include: + + +E_FILE_PARITY a parity error occurred while receiving a character. This error will only be +reported if the user has not set p_IGNORE_PARITY in the serial characteristics. +Otherwise the error is discarded and the character (although in error) will +simply be transferred to *buE. + + +E_FILE_FRAME a serial framing error has occurred. + +E_FILE_OVERRUN a serial overrun error has occurred. + +E_FILE_LINE a line failure has occurred. + +E_GEN_OVER the internal serial driver buffer has become full and further incoming + + +characters have been discarded. Some form of handshaking is required to slow +the transmitter down. + + +1/0 DEVICES REFERENCE + + +E_FILE_RECORD a terminator mask has been set, *plen bytes have been received and written +into *pbuf but no terminator character has been received. No characters have +been lost or received in error but the data format being received is not as +expected. This may or may not be regarded as an error, depending on the +application. + + +P_FWRITE Write to the serial port + + +INT p_iow(VOID *pcb, P_FWRITE, VOID *buf, UWORD *plen); +VOID p_ioc(VOID *pcb, P_FWRITE, WORD *pstat, VOID *buf, UWORD *plen)j; + + +Transmit *plen characters from the buffer at buf, obeying the currently selected handshaking. + + +The only limit to the amount of data that can be transmitted in one call is the size of the data buffer at buf. +A value of zero for *plen is permissible. It is the user's responsibility to preserve the data space pointed to +by buf and plen until the write request completes. + + +A P_FWRITE request will typically take a significant length of time to complete and should normally be +called asynchronously in a quality system. + + +A P_FWRITE request may be cancelled by using the P_FcANCEL service. The P_FWRITE request will complete +with the E_FILE_CANCEL completion status code. The serial driver does not report how many bytes have +been transmitted before the request was cancelled. + + +The P_FWRITE service can be used to wait for changes in hardware flow control lines. For example, a +physical link to a remote PC could be deemed to be established when the DSR line is set active. A +P_FWRITE request of zero bytes with handshaking set to P_OBEy_psR will only complete when the DSR line +is set active, as in the following example: + + +P_SRCHAR serChar; + + +p_iow(pSerial, P_FSENSE, &serChar) ; + +serChar.hand|=P_OBEY_DSR; + +p_iow(pSerial, P_FSET, &serChar) ; + +len=0; + +if (!p_iow(pSerial,P_FWRITE, &ébuf[0],é&len) ) +{ /* DSR now being driven */ +serChar.hand|=P_FAIL_DSR; +p_iow(pSerial,P_FSET, &serChar) ; + + +} +serChar.hand&=~ (P_OBEY. DSR|P FAIL_DSR) ; +p_iow(pSerial, P_FSET, &serChar) ; + + +In this example the serial handshaking is first set so that the first P_FWRITE request will wait until the +remote machine's DTR (incoming DSR) line is set active, at which time connection is deemed to have +been established. The handshaking is then set to cause any following read or write requests to fail if the +connection is lost (incoming DSR line set inactive). Finally, the handshaking is restored to its original +state. + + +The calling process is panicked if a P_FwRITE request is already outstanding, or if pcb is not a valid +channel handle. + + +The completion status code is returned by the synchronous p_iow(P_FWRITE) and written to *pstat by +asynchronous calls. The completion status code is zero if the P_FWRITE request completed successfully, +otherwise it is a negative error number. Errors include: + + +E_FILE_LINE a line failure has occurred. + + +P_FCANCEL Cancel any outstanding requests + + +INT p_iow(VOID *pcb, P_FCANCEL) ; + + +Cancel any outstanding P_FREAD and P_FWRITE requests, causing them to complete with the +E_FILE_CANCEL completion status code. + + +See the descriptions of the p_FREAD and P_FwRITE services for their behavior with respect to P_FCANCEL. +The p_FCANCEL service 1s harmless if no P_FREAD Or P_FWRITE requests are outstanding. + + +The P_FCANCEL service cannot fail and returns zero. + + +4-8 + + +4 SERIAL PORT + + +P_FSENSE Sense the serial port characteristics +INT p_iow(VOID *pcb, P_FSENSE, P_SRCHAR *pch) ; +Write the current serial characteristics to the p_sRcHar struct pointed to by pch. + + +The p_FSENSE service cannot fail and returns zero. + + +P_FSET Set the serial port characteristics +INT p_iow(VOID *pcb, P_FSET, P_SRCHAR *pch) ; +Set the serial port characteristics to those passed in the p_srcuar struct pointed to by pch. + + +An application which wishes to change the serial port characteristics will normally first sense the current +characteristics, using the p_rsENsE service. It will then make the required change and use the p_rsEt +service to apply the new characteristics. + + +The calling process is panicked if there is an outstanding Pp_FREAD or P_FWRITE request or if pcb is not a +valid channel handle. + + +Returns zero if the p_rsrET request completed successfully, otherwise a negative error. Errors include: + + +E_GEN_ARG one or more of the values specified in the p_srcuar struct is illegal. The +current characteristics are not changed. + + +E_GEN_NSUP one of the required characteristics is not supported by this particular driver. +The current characteristics are not changed. + + +E_FILE_LINE either DSR is inactive and p_ratL_psr has been specified or DCD is inactive +and p_rarL_pcp has been specified (or both). + + +P_FFLUSH Flush the read buffer + + +INT p_iow(VOID *pcb, P_FFLUSH) ; + + +Discard the current contents of the internal serial read buffer (at the logical device driver level) and clear +any outstanding error status. Any handshaking that has paused transmission from the remote device is +cleared so that the remote device is free to resume transmission. + + +The p_FFLuSH service cannot fail and returns zero. + + +P_FTEST Test for received characters +INT p_iow(VOID *pcb, P_FTEST, UWORD *plen); +Set *pien to the number of bytes that are currently available in the serial driver's internal buffer. + + +Following the call it is guaranteed that there are at least *p1en bytes available. These bytes may be read +synchronously, since a synchronous p_REaD request to read *pien bytes will complete immediately. + + +By the time the p_rrest request has completed there may be more than *pien bytes available, since data +is received under interrupt control. + + +The calling process is panicked if there is an outstanding p_rREaD request or if pcb is not a valid channel +handle. + + +The p_Ftest service cannot fail and returns zero. + + +P_FCTRL Test and set control lines + + +INT p_iow(VOID *pcb, P_FCTRL, UBYTE *pctrl); + + +Read the current state of the CTS, DSR and DCD input control lines to *pctr1 as a bit mask and, +optionally, set the DTR output control line. + + +I/O DEVICES REFERENCE + + +The following bit flags are defined in p_serial.h: + + +P_SRCTRL_CTS if set CTS is active, otherwise it is inactive +P_SRCTRL_DSR if set DSR is active, otherwise it is inactive +P_SRCTRL_DCD if set DCD is active, otherwise it is inactive + + +If the byte pointed to by * (pctr1+1) is non-zero it is used to set the state of the DTR output line. If non- +zero it should take one of the following values, defined in p_serial.h: + + +P_SRDTR_ON to set DTR active +P_SRDTR_OFF to set DTR inactive + + +Returns zero if the p_FcTRL request completed successfully, otherwise a negative error number. Errors +include: + + +E_GEN_NSUP this driver does not support the setting of the DTR line. All current SIBO +machines support the setting of the DTR line. + + +P_FINQ Inquire supported serial characteristics +INT p_iow(VOID *pcb, P_FINQ, UWORD *pmask) ; + + +Write three words, into *pmask, * (pmask+1) and * (pmask+2), containing the serial characteristics that the +driver supports. Each word consists of a set of bit flags with each bit set indicating a supported +characteristic. + + +The first word, at *pmask, indicates a combination of the following potentially supported Baud rates, +defined in p_serial.h: + + +P_SRINQ_50 +P_SRINQ_75 +P_SRINQ_110 +P_SRINQ_134 +P_SRINQ_150 +P_SRINQ_300 +P_SRINQ_600 +P_SRINQ_1200 +P_SRINQ_1800 +P_SRINQ_2000 +P_SRINQ_2400 +P_SRINQ_3600 +P_SRINQ_4800 +P_SRINQ_7200 +P_SRINQ_9600 +P_SRINQ_19200 + + +The serial driver in all SIBO machines reports that all the above Baud rates are suppported, however see +Baud rate in the earlier Serial port parameters section for a discussion of the use of 19200 Baud. + + +The second word, at * (pmask+1), indicates a combination of the following potentially supported Baud +rates, defined in p_serial.h: + + +P_SRINQ_38400 +P_SRINQ_56000 + + +SIBO machines do not currently support either of these Baud rates. + + +The third word, at * (pmask+2), indicates support for a combination of the following characteristics, +defined in p_serial.h: + + +P_SRINQ_DATAS supports 5 data bits +P_SRINQ_DATA6 supports 6 data bits +P_SRINQ_DATA7 supports 7 data bits +P_SRINQ_DATA8 supports 8 data bits +P_SRINQ_STOP2 supports sending 2 stop bits +P_SRINQ_PAREVEN supports even parity +P_SRINQ_PARODD supports odd parity +P_SRINQ_PARMARK supports mark parity + + +4 SERIAL PORT + + +P_SRINQ_PARSPACE supports space parity +P_SRINQ_SETDTR supports the setting of DTR +P_SRINQ_SPLIT supports the setting of split Baud rates + + +The SIBO machines support all of the above except p_sRINQ_PARMARK, P_SRINQ_PARSPACE and +P_SRINQ_SPLIT. + + +The p_Fing service cannot fail and returns zero. + + +ee +Example + + +The following example, which assumes that the serial port is connected to a modem, uses many of the +serial services described above. + + +After opening a console it sends a dialling string to the modem and waits for a connection to a remote +modem. It then receives text records transmitted by the remote modem and displays them in the console +window. This continues until the user exits the program by pressing the ESCAPE key. + + +include +include +include + + +define OPEN_TIMER 0 +define OPEN_PORT 1 +define DTR_HAND 2 +define DIALLING 3 +define LINE_FEED 0x0a + + +LOCAL_D VOID *pTimer=0; /* Timer channel handle */ +LOCAL_D WORD timStat; /* Timer completion status */ +LOCAL_D VOID *pSerial=0; /* Serial channel handle */ + + +LOCAL_D WORD serWriteStat; /* Serial write completion status */ +LOCAL_D WORD serReadStat; /* Serial read completion status */ + + +GLREF_D VOID *winHandle; /* Console channel handle */ + + +LOCAL_D WORD winStat; /* Console completion status */ + + +LOCAL_C VOID reportError(INT func, INT error) + + +UBYTE bb[100]; + + +switch (func) +{ +case OPEN_TIMER: +p_puts("Failed to open timer channel"); +break; +case OPEN_PORT: +p_puts("Failed to open serial port"); +break; +case DTR_HAND: +p_puts ("Modem not driving DSR"); +break; +case DIALLING: +p_puts ("Failed to connect to remote Modem") ; +break; +default: +p_puts ("Unknown function error"); +} +p_errs(&bb[0],error); +p_puts (&bb[0]); +p_close(pSerial) ; +p_close(pTimer) ; +p_exit (1); +} + + +I/O DEVICES REFERENCE + + +LOCAL_C VOID QueueTimer (ULONG timeout) +{ +p_ioc(pTimer,P_FREAD, &timStat, &timeout) ; +} + + +LOCAL_C VOID CancelTimer (VOID) +{ +p_iow(pTimer,P_FCANCEL) ; +p_waitstat (&timStat) ; +} + + +LOCAL_C VOID QueueSerialWrite(UBYTE *buf,UWORD *plen) + + +p_ioc(pSerial,P_FWRITE, &serWriteStat,buf,plen) ; + + +LOCAL_C VOID CancelSerialWrite (VOID) + + +p_iow(pSerial,P_FCANCEL) ; +p_waitstat (&serWriteStat) ; + + +LOCAL_C setHand(INT clrflag, INT setflag) + + +P_SRCHAR sch; + + +p_iow(pSerial,P_FSENSE, &sch) ; + +sch. hand&=clrflag; + +sch.hand|=set flag; + +return (p_iow(pSerial,P_FSET, &sch) ); +} + + +LOCAL_C VOID resetModem (VOID) +/* +Reset a modem by driving DTR low for 2 seconds +x +{ +UBYTE bb[2]; + + +bb [1]=P_SRDTR_OFF; +p_iow(pSerial,P_FCTRL, &bb[0]); +p_sleep(20L); + +bb [1]=P_SRDTR_ON; +p_iow(pSerial,P_FCTRL, &ébb[0]); +} + + +LOCAL_C dialNumber (VOID) +/* +Returns zero if successful, else -ve error number +ey. +{ +UWORD len; +INT ret; + + +len=11; +QueueSerialWrite ("ATD9, 123456", &len) ; +QueueTimer(50L); /* 5 secs to send dial string */ +p_iowait (); +if (serWriteStat !=E_FILE_PENDING) +{ /* sent dial string */ +CancelTimer(); +if (!serWriteStat) +{ /* sent dial string Ok */ +if ((ret=setHand(-1,P_OBEY_DCD) ) !=0) +return (ret); +len=0; +QueueSerialWrite("",&len); /* Wait for DCD */ +QueuveTimer(1200L); /* 2 mins to get through */ +p_iowait (); +if (serWriteStat !=E_FILE_PENDING) +{ +CancelTimer (); +if (!serWriteStat) +{ +if ((ret=setHand(-1,P_FAIL_DCD) ) !=0) +return (ret); + + +} +else +CancelSerialWrite(); + + +} + + +else /* timeout sending dial string */ +CancelSerialWrite(); +return (serWriteStat) ; + + +} + + +4 SERIAL PORT + + +I/O DEVICES REFERENCE + + +GLDEF_C main (VOID) +{ +INT ret; +UWORD len; +P_SRCHAR sch; +P_CON_KBREC kbrec; +UBYTE key[2]; +UBYTE buf [128+2]; + + +p_puts("Serial Driver Example"); /* opens a console */ + + +if ((ret=p_open (&pTimer, "TIM:",-1)) !=0) +reportError (OPEN_TIMER, ret) ; +if ((ret=p_open(&pSerial,"TTY:A",-1)) !=0) + + +reportError (OPEN_PORT, ret) ; +resetModem () ; + + +if ((ret=setHand(-1,P_OBEY DSR|P FAIL_DSR) ) !=0) +reportError (DTR_HAND, ret); +if ((ret=dialNumber () ) !=0) + + +reportError (DIALLING, ret) ; +p_iow(pSerial,P_FSENSE, &sch) ; +sch.tmask=(1< + + +LOCAL_C VOID PlaySound(VOID *pcb) +{ +WORD notesl1[] = {1048,24,524,12}; +WORD notes2[] = {1048,4,1320,4,1568,4,2092,4,1568,4,1320,4,1048,12}; +WORD sndstat1,sndstat2; +WORD lenl,len2; + + +INT i; +lenl = sizeof (notes1) /4; +len2 = sizeof (notes2) /4; + + +p_ioc5 (pcb, E_FSSOUNDCHANNEL1, ésndstat1, ¬es1[0],é&lenl); +p_ioc5 (pcb, E_FSSOUNDCHANNEL2, &ésndstat2, ¬es2[0],&len2) ; +i= -1; +do + +{ + +p_iowait (); + +itt; + +} while (sndstatl == E_FILE_PENDING && sndstat2 == E_FILE_PENDING) ; +if (sndstatl == E_FILE_PENDING) + +p_waitstat (&sndstatl); +else + +p_waitstat (&sndstat2) ; +while (i--) + +p_iosignal(); + + +} + + +GLDEF_C INT main(VOID) +{ +VOID *pcb; +E_SOUND sound; + + +p_open(&pcb, "SND:",-1); +p_iow (pcb, P_FSENSE, &sound) ; +p_iow (pcb, P_FSET, &sound) ; +PlaySound (pcb) ; + +p_close (pcb); + +return (0); + + +} + + +Series 3 and Series 3a additional sound service + + +This service is available only on Series 3 and Series 3a machines. + + +E FDIAL Write DTMF dial tones + + +VOID p_ioc(VOID *pcb, E_FDIAL, WORD *pstat, TEXT *pstr, E_DIAL *pdial); +INT p_iow(VOID *pcb, E_FDIAL, TEXT *pstr, E_DIAL *pdial); + + +Write a DTMF tone sequence from the zero terminated string *pstr, with timing as specified by the +content of the E_DIAL struct pointed to by pdial. This struct is defined in epoc.h as: + + +typedef struct +{ +UBYTE toneLengthTicks; /* tone length in 1/32 sec */ +UBYTE delayLengthTicks; /* inter-tone delay in 1/32 sec */ +UWORD pauseLengthTicks; /* pause length in 1/32 sec */ +} E_DIAL; + + +5 SOUND + + +DTMF tones are produced for the following valid characters: +e the digits 0 to 9 +e upper or lower case alphabetic characters in the range A to F +e the characters # (0x23) and * (0x2A) which are converted to F and E respectively. + + +Space and comma characters generate a pause of length specified by the &_p1at struct element +pauseLengthTicks. All other characters are ignored. + + +The string at pstr may be of any length, but the total number of valid tone and pause generating characters +characters in it may not exceed 26. + + +For example, assuming a dial-out code of 9, + + +E_DIAL dial; +TEXT digits[10]; + + +dial.toneLengthTicks=8; +dial.delayLengthTicks=8; +dial.pauseLengthTicks=48; + +p_scpy (&digits[0],"9,0711234") ; +p_iow(pcb,E_FDIAL, &digits[0],&dial) ; + + +will emit the DTMF dialling tones to dial the external number 071 1234. + + +Panics if an E_FDIAL Of E_FALARM request is currently outstanding, or if pcb is not a valid channel handle. + + +The completion status code is returned by the synchronous p_iow(E_FDIAL) service and written to *pstat +by an asynchronous call. The completion status code is zero if the E_Fp1aL request completed successfully, +or one of the following errors: + + +E_FILE_CANCEL the write was cancelled by a call to the p_rcancEL service +E_GEN_ARG the string contains too many valid characters + + +a ——— +Example + + +The following code implements a simple tone dialing system for HC, MC or Series 3a machines. +#include +#include +#include + + +GLREF_D VOID *winHandle; + + +LOCAL_D WORD tones1[] = +941,1,697,1,697,1,697,1,770,1,770,1,770,1, 852,1, 852,1,852,1,941,1,941,1}; + + +LOCAL_D WORD tones2[] = +1336,1,1209,1,1336,1,1447,1,1209,1,1336,1,1447,1,1209,1,1336,1,1447,1,1209,1,1477,1}; + + +LOCAL_C VOID dial(VOID *psoundcb, INT tone) + + +WORD len = 1; +WORD sl_status; +WORD *ptonel, *ptone2; + + +if(tone >= 0 && tone <= 11) +{ +ptonel = &tones1[0] + tone*2; +ptone2 = &tones2[0] + tone*2; +p_ioc5 (psoundcb, E_FSSOUNDCHANNEL1, &sl1_status,ptonel, &len) ; +p_iow4 (psoundcb, E_FSSOUNDCHANNEL2, ptone2, &len) ; +p_waitstat (&sl_status) ; +} + + +IEVICES REFERENCE + + +VOD + + +GLDEF_C INT main(VOID) +{ +INT c,tone,err; +VOID *psoundcb; +UWORD func; +P_RECT rect; +E_SOUND sound; + + +if ((err=p_open (&winHandle, "CON:",-1)) !=0) +{ +p_notifyerr(err,"No Console device",NULL, NULL, NULL) ; +p_exit (1); +} + + +rect.tl.x + + +rect.tl.y = 0; /* set the screen size */ +rect.br.x = 25; +rect.br.y = 9; +func = P_SCR_WSET; +p_iow4 (winHandle, P_FSET, &func, &rect) ; +p_printf ("Tone dial demo"); +if ((err=p_open (&psoundcb, "SND:",-1)) !=0) +{ +p_notifyerr(err,"Cannot open sound device",NULL, NULL, NULL) ; +p_close (winHandle) ; +p_exit (1); +} +sound.volume = 3; +sound.beatsPerMinute = 76; +p_iow3 (psoundcb, P_FSET, &sound) ; +FOREVER +{ +c = p_getch(); +if (c==W_KEY_RETURN) ; + + +break; +p_putch (c); +if (c=='"*') +tone = 10; +else if (c=='#"') +tone = 11; +else +tone =c - '0O'; + + +dial (psoundcb, tone) ; + +} +p_close (psoundcb) ; +p_printf("\r\nDemo finished"); +p_printf ("Press any key to exit"); +p_getch (); +p_close(winHandle) ; +return (0); + + +} + + +CHAPTER 6 + + +THE ALARM DEVICE DRIVER + + +Introduction + + +The atm: device driver supplied on Series 3, Series 3a and MC machines provides support for alarms +(as used in the Agenda application). A process may specify an alarm sound (Series 3a only), an alarm +message and an appointment time. + + +The following picture illustrates the screen display for an untimed alarm on a Series 3a machine. + + +Alarm (Agenda) 12:32:18 pm + + +Alarm: Mon 18th Oct + + +Finish the alarm server chapter ... + + +Clear alarm Snooze Silence + + +Note that the appointment date is displayed but not the appointment time. + + +The following picture illustrates the screen display for a timed alarm on a Series 3a machine. + + +Alarm (Agenda) 12:58:89 pm + + +Alarm: Mon 18th Oct 2:46 pm +Finish the alarm server chapter ... + + +Clear alarm Snooze Silence + + +—Enter_| + + +Both the time and the date of the appointment are displayed. + + +An alarm is set by sending an alarm request to the alarm device driver (atu: ). This request may be made +synchronously, using p_iow, or asynchronously, by using p_ioc, for example. + + +Note that the alarm server holds a copy of the data relating to an outstanding alarm request. An +outstanding alarm can therefore survive the termination of its parent, that is, the process that made the +alarm request. Such an alarm is referred to as an orphaned alarm. + + +An orphaned alarm is automatically reparented when an identical alarm request is made. This feaure is +used by, for example, the Agenda application. Thus, even if an Agenda file is repeatedly closed and +reopened, an entry with an alarm will not be marked with a large number of identical alarm requests.) + + +I/O DEVICES REFERENCE + + +Panics + + +An application will be panicked if it makes an alarm request before any previous alarm request from that +application has completed. All services (with the exception of p_open) will cause the calling process to be +panicked if the passed channel handle is not valid. + + +The #defines and structs for the alarm server device are in the header file hasrv.h. + + +Series 3, Series 3a and MC alarm services + + +The Series 3a also has additional services that are described in the following section. + + +Note that all alarm services are provided by the Time application that is built into Series 3 and Series 3a +machines, rather than being an integral part of the operating system. + + +p_open(ALM:) Open the alarm channel + + +INT p_open(VOID **pcb, "ALM:", -1); +Open a channel to the alarm device. +Returns zero if the alarm device is opened successfully, otherwise one of the following errors: + + +E_GEN_OPEN +E_GEN_NOMEMORY +E_FILE_NXIST + + +p_close Close the alarm channel + + +INT p_close(VOID *pcb); +Close the alarm device channel. + + +Returns zero. + + +P_FCANCEL Cancel an alarm request + + +INT p_iow(VOID *pcb, P_FCANCEL) ; +Cancel any outstanding alarm request. Performing a cancel is harmless if no alarm request is outstanding. + + +Returns zero. + + +A_FTIMED Queue a timed alarm + + +VOID p_ioc(VOID *pcb, A_FTIMED, WORD *pstat, A_DETAILS *pd, TEXT *pm) ; + + +Queue a timed alarm specified by a pointer to an A_DETAILS struct, and a pointer to a zero terminated text +message. + + +The A_DETAILS struct would be defined as follows: + + +typedef struct +{ +ULONG absTime; +ULONG dueTime; +} A_DETAILS; + + +¢ absTime is the alarm time as a system time. +¢ dueTime is the appointment time as a system time. +The appointment time should not be earlier than the time of the alarm. + + +The text message pointed to by pm should be a zero terminated string of not more than 65 characters +including the zero terminator. If no text message is required then pm should point to the null string. + + +The completion status is written to *pstat. The status is zero if the service completed successfully +otherwise a negative error number. + + +6-2 + + +6 THE ALARM DEVICE DRIVER + + +A_FUNTIMED Queue an untimed alarm + + +VOID p_ioc(VOID *pcb, A_FUNTIMED, WORD *pstat, A_DETAILS *pd, TEXT *pm); + + +Queue an untimed alarm specified by a pointer to an a_DETAILSs Struct, and a pointer to a zero terminated +text message. + + +This service is identical to a_rTIMED (see above) except that only the day and month of the appointment +time are displayed, the hours and minutes being omitted. + + +Series 3a additional alarm services + + +The services listed in this section are only available on the Series 3a machine. + + +A_FTIMED X Queue a Series 3a timed alarm +VOID p_ioc(VOID *pcb, A_FTIMED_X, WORD *pstat, AXDATA *pa, TEXT *pm); + + +Queue a timed alarm specified by a pointer to an axpata struct, and a pointer to a zero terminated text +message. + + +The axpara struct is defined in hasrv.h as follows: + + +typedef struct +{ +ULONG absTime; +ULONG dueTime; +SE_SND sound; +} AXDATA; + + +@ absTime 1s the alarm time as a system time. +@ dueTime is the appointment time as a system time. +® sound is the alarm sound (see below). + + +The se_swp struct defines the sound to be made and is defined in hasrv.h as follows: + + +typedef struct +{ +UBYTE len; +TEXT name[8]; +UBYTE zero_term; +} SE_SND; + + +¢ en is the length of the string in the name field. +¢ name specifies the name of the alarm sound (see below). +@ zero_term is the nuut character. +The element name in the sE_swp struct can have one of the following values: + + +e asingle byte containing a value between | and 16 inclusive. Currently only 1, 2 and 16 are used, +corresponding to the rings, chimes and silent alarms respectively. The contents of following +unused bytes are not significant. For example: + + +AXDATA axdata + + +axdata.sound.len=1; +axdata.sound.name[0]=1; + + +would set the rings sound. + + +I/O DEVICES REFERENCE + + +¢ anon-zero-terminated string specifying one of the .wve digital sound files resident in the ROM. +Currently these are: SYS$ALO/ for a 'Fanfare', SYS$AL02 for 'Soft bells' and SYS$AL03 for +‘Church bells’. For example: + + +AXDATA axdata + + +axdata.sound.len=8; +p_scopy (&axdata.sound.name[0],"SYSSAL03") ; + + +would set the 'Church bells' sound. + + +¢ anon-zero-terminated string specifying a .wve sound file resident in a local \wve\ directory. The +contents of following unused bytes are not significant. For example: + + +AXDATA axdata + + +axdata.sound.len=p_slen("mysound") ; +p_scopy (&axdata.sound.name[0],"mysound") ; + + +would set the sound to be that contained in a \wve\mysound.wve file. + + +The message pointed to by pm should be a zero terminated string of not more than 161 characters, +including the zero terminator. If no text message is required, then pm should point to a null string. + + +The completion status is written to *pstat. The status is zero if the service completed successfully +otherwise a negative error number. + + +A_FUNTIMED X Queue a Series 3a untimed alarm + + +VOID p_ioc(VOID *pcb, A_FUNTIMED_X, WORD *pstat, AXDATA *pa, TEXT *pm); +Queue an untimed alarm specified by a pointer to an axpata struct, and an associated text message. + + +This service is identical to the A_FTIMED_x service (see above) except that only the day and month of the +appointment time are displayed, the hours and minutes being omitted. + + +CHAPTER 7 + + +THE FREE-RUNNING COUNTER + + +Introduction + + +The Series 3a and Workabout machines are supplied with a device driver for a built in free-running +counter (FRC). This device driver may be accessed by applications and provides for the measurement of +elapsed time with an accuracy of +/- 2ppm (corresponding to 2.6 seconds per month) and a resolution of +1/1024 seconds. + + +The free-running counter device driver may be used in one of three ways: + + +e to provide a value that increments once every 1/1024 second, effectively a relative clock. An +application can read the value at any time, without resetting it. + + +e to trigger an event after a specified interval, in units of 1/1024 second. In effect this provides the +same function as a relative timer, except that the free-running counter works to a higher +resolution. + + +e to provide a value that increments once every specified time interval, in units of 1/1024 second. +This allows an application to create a relative clock, with the resolution tailored to the +application's requirements. The value is reset to zero each time that it is read. + + +As the FRC device driver can support only one process at any one time, applications should use it for no +longer than is absolutely necessary. + + +An application that only needs to work with time intervals with a resolution of 1/32 second or greater +should not use the FRC, but should use either a relative or an absolute timer: details of these timers can be +found in the Time, Timers and Dates chapter of the Plib Reference manual. + + +FRC services + + +The FRC: device driver is specific to the Series 3a and Workabout machines. + + +All services (with the exception of p_open) will cause the calling process to be panicked if the passed +channel handle is not valid. Other panics are described under the particular service to which they apply. + + +p_open(FRC:) Open the FRC channel +INT p_open(VOID **pcb, "FRC:", -1); + +Open a channel to the FRC device. + +Returns zero if the device was opened successfully, otherwise a negative error code. Errors include: +E_FILE_OPEN The device can not be accessed as it is in use. + + +E_GEN_NOMEMORY There is insufficient memory to allow a channel to be opened. + + +I/O DEVICES REFERENCE + + +p_close Close the FRC channel +INT p_close(VOID *pcb) ; +Close the device channel, first cancelling any outstanding read request. + + +Returns zero. + + +P_FCANCEL Cancel the FRC request + + +INT p_iow(VOID *pcb, P_FCANCEL) ; +Cancel any outstanding request. Performing a cancel is harmless if no request is outstanding. + + +Returns zero. + + +P_FSTART Start the free-running counter +INT p_iow(VOID *pcb, P_FSTART, UWORD *pmode, UWORD *pint); + +Start the free-running counter. + +The uworp pointed to by pmode must specify one of the following modes, defined in epoc.h: + + +E_FRC_COUNTING a counter increments every 1/1024 seconds from an initial value of zero. The +value of pint is ignored. + + +E_FRC_REPEATING a counter increments every *pint multiple of 1/1024 seconds, starting from +zero. The value of *pint should be in the range 10 to 65535, representing time +intervals approximately in the range of 0.01 to 64 seconds. + + +Any outstanding P_FREAD request will be cancelled and the counter reset to zero. + + +Returns zero if the request completed successfully, otherwise returns a negative error number. Errors +include: + + +E_GEN_NSUP an invalid mode was specified. + + +E_GEN_RANGE the specified repeat interval is not valid, i.e. it is in the range 0 to 9 inclusive. + + +P_ FREAD Read the elapsed time in E_ FRC_COUNTING mode + + +VOID p_ioc(VOID *pcb, P_FREAD, WORD *pstat, ULONG *argl); +INT p_iow(VOID *pcb, P_FREAD, ULONG *argl1); + + +Sense the current counter value, following a previous P_FSTART request that set E_LFRC_COUNTING mode. + + +The value written to *arg1 is the time, in units of 1/1024 seconds, since the last P_rsTarT request. The +value is not reset by the P_FREAD request. + + +The application will be panicked if an earlier P_FREAD request is outstanding. + + +The completion status is written to *pstat for p_ioc and returned by p_iow. It is zero if the request +completed successfully. Otherwise it is a negative error number. Errors include: + + +E_GEN_OVER the elapsed number of repeat intervals is too large to be written to *arg1. +E_FILE_CANCEL the P_FREAD request was cancelled before it completed. +E_FILE_READ either the counter was not running, or the machine was switched off while the + + +counter was running. + + +7 FRC + + +P_ FREAD Read the elapsed time in E_ FRC_REPEATING mode + + +VOID p_ioc(VOID *pcb, P_FREAD, WORD *pstat); +INT p_iow(VOID *pcb, P_FREAD) ; + + +Sense the current counter value, following a previous p_rstTarT request that set E_FRC_REPEATING mode. + + +The completion status value that results from a successful call to this service is the number of complete +time intervals (as specified by the earlier p_rstart request) that have elapsed since the last request for +either a P_FSTART Of a P_FREAD Service. The service will not complete until one time interval has elapsed, +otherwise completion is immediate. Time is not lost between successive P_FREAD requests, since the FRC +hardware is not reset. + + +The application will be panicked if an earlier p_rREaD request is outstanding. + + +The completion status is written to *pstat for p_ioc and returned by p_iow. It is a positive value if the +request completed successfully. Otherwise it is a negative error number. Errors include: + + +E_GEN_OVER the elapsed number of repeat intervals exceeds 32767. +E_FILE_CANCEL the p_FREAD request was cancelled before it completed. +E_FILE_READ either the counter was not running, or the machine was switched off while the + + +counter was running. + + +CHAPTER 8 + + +THE SERIES 3 WORLD DATABASE + + +Introduction + + +The World database is supported by all of the Series 3 range of machines. It stores a range of data for a +large number of countries - in practice only small or very recently created countries are not present. +Further data is stored for the larger cities in each country. + + +The wip: device driver allows an application to navigate the database by means of a number of search +services. A successful search sets the current city and/or country for other services that can access or +update the constituent data according to specific requirements. It supports multiple channels. + + +The services of this device driver are provided by the World application that is built into the ROM of all +machines in the Series 3 range. + + +The data stored in the database includes various codes required for dialling as follows: +e the national code for each country. +e the international prefix code for each country. +e the national prefix for long distance calls. +The database also includes the following data for each city: +e the deviation of the local time from Greenwich Mean Time. +e the times of sunset and sunrise expressed as a local time (these are actually calculated). +e the latitude and the longitude of the city. +e the coordinates of the city on the World map. +e the zone for daylight saving time (DST). +An application may also: +e set its home city. +e set its default country. + + +The database supports the creation of a file containing extra items which may be either new cities, or +replacement data for existing cities: only 32 extra items may be included in any one file. (A greater +number of extra items would significantly degrade the performance of the database search operations.) + + +Mode + + +A minority of services change the mode of the the database which can effect the operation of subsequent +services. Thus the wR_NEXT service moves to the next city if the database is in city mode. Otherwise the +WR_NEXT Service moves to the next country. + + +A service is assumed not to change the mode unless it is explictly stated to the contrary. + + +1/0 DEVICES REFERENCE + + +Series 3 and Series 3a World database services + + +Note that these services are provided by the World application that is built into Series 3 and Series 3a +machines, rather than being an integral part of the operating system. + + +p_open(WLD:) Open the World channel +INT p_open(VOID **ppcb, "WLD:", Oxffff); + +Open a channel to the World database and write the handle of the channel to «ppcb. + +Returns zero on success, otherwise a negative error code including the following: + + +E_FILE_ALLOC failed to allocate memory for the control block. + + +p_close Close the World channel +INT p_close(VOID *pcb) ; +Close the channel to the World database specified by pcb. + + +Returns zero on success. + + +P_FCANCEL Cancel a World request + + +INT p_iow(VOID *pcb, P_FCANCEL) ; + + +Cancel any outstanding World request on channel pcb and return zero - performing a cancel is harmless if +there is no outstanding request. + + +The P_FCANCEL request cannot fail. + + +WR_FIND_CITY Find by city + + +INT p_iow(VOID *pcb, WR_FIND_CITY, TEXT *match, WR_FIND_RES *result) ; + + +Find the first city that matches the string at address match writing the name of the matching city and the +associated country to the WR_FIND_RES struct pointed to by result - the matching is not case sensitive. + + +The WR_FIND_RES struct is defined as follows: +typedef struct + +{ +TEXT city [WR_MAX_NAME+1]; +TEXT country [WR_MAX_NAME+1]; +} WR_FIND_RES; + +The significance of the members of the WwR_FIND_RES struct is as follows: + +city the name of the matching city expressed as a zero terminated string. + + +country the name of the associated country expressed as a zero terminated string. + + +Returns WR_FOUND on success, Or WR_NOT_FOUND otherwise. + + +WR_FIND_COUNTRY Find by country + + +INT p_iow(VOID *pcb, WR_FIND_COUNTRY, TEXT *match, WR_FIND_RES *result); + + +Find the first country that matches the string at address match writing the name of the matching country +and its capital city to the wR_FIND_RES struct pointed to by result - the matching is not case sensitive. + + +8 SERIES 3 WORLD DATABASE + + +The wR_FIND_RES Struct is defined as follows: +typedef struct +{ +TEXT city [WR_MAX_NAME+1]; +TEXT country [WR_MAX_NAME+1]; +} WR_FIND_RES; +The significance of the members of the wR_FIND_REs struct is as follows: + + +city the name of the capital city of the matching country expressed as a zero +terminated string. + + +country the name of the matching country expressed as a zero terminated string. + + +Returns wR_FOUND on success, Or WR_NOT_FOUND otherwise. + + +WR_FIND_EXACT Find by city and country + + +INT p_iow(VOID *pcb, WR_FIND_EXACT, WR_FIND_RES *match) ; + + +Find the country that exactly matches the city specified in match->city, or if this is NuLL, the country +specified in match->country - the matching is not case sensitive. + + +For a description of the wR_FIND_REs Struct, see the above descriptions of the wR_Finp_crTy and +WR_FIND_COUNTRY Services. + + +Returns wR_FOUND on success, Or WR_NOT_FOUND otherwise. + + +WR_NEXT Find next city + + +VOID p_iow(VOID *pcb, WR_NEXT, WR_FIND_RES *result) ; + + +Write the names of the next city and the associated country, or the next country and its capital city, +depending on the mode, to the wR_FIND_REs struct pointed to by result. + + +The service is always successful. + + +WR_BACK Find previous city + + +VOID p_iow(VOID *pcb, WR_BACK, WR_FIND_RES *result); + + +Write the name of the previous city and the associated country, or the previous country and its capital city, +depending on the mode, to the wR_FIND_REs struct pointed to by result. + + +The service is always successful. + + +WR_GET_HOME Find home city + + +VOID p_iow(VOID *pcb, WR_GET_HOME, WR_FIND_RES *result); + + +Write the names of the home city and the associated country to the wR_FIND_REs struct pointed to by + + +result. + + +The service is always successful. + + +WR_SET HOME Set home city + + +INT p_iow(VOID *pcb, WR_SET_HOME) ; +Set the home city to the current city. +This is a system wide setting. + + +Returns zero on success, or WR_NOTVALID_ERR if the current city is no longer valid 1.e. the current city has +been deleted. + + +1/0 DEVICES REFERENCE + + +WR_GET_DEFAULT_ COUNTRY Find default country + + +VOID p_iow(VOID *pcb, WR_GET_DEFAULT_COUNTRY, WR_FIND_RES *result); +Write the name of the default country and its capital city to the wR_FIND_RES struct pointed to by result. +Note that the service sets the database to city mode. + + +The service is always successful. + + +WR_SET_ DEFAULT COUNTRY Set default country + + +INT p_iow(VOID *pcb, WR_SET_DEFAULT_COUNTRY) ; +Set the default country current country to the current country. +Note that the service sets the database to country mode. + + +Returns zero on success, Or E_GEN_UNDER if the current city is no longer valid i.e. the current country has +been deleted. + + +WR_GET_DIAL_STRING Get dial string + + +INT p_iow(VOID *pcb, WR_GET_DIAL_STRING, TEXT *inString, TEXT *outString); +Convert the string pointed to by inst ring into a dial string, written to the buffer pointed to by out string. + + +The output string may be played using the sound device: for futher details of tone dialling see the Sound +chapter of the I/O Devices Reference manual. + + +During the conversion, both spaces and hyphens are removed, but commas are left unchanged. A full stop +is interpreted as marking the end of the input string. For the significance of commas see the Sound +chapter of the //O Devices Reference manual. As an example, 0-171,123 4567.89 would be converted to +0171,1234567. + + +Returns zero on success, otherwise one of the following negative error codes: + + +E_GEN_ARG either the input string includes only one square bracket, or the country +specified in square brackets does not match a country in the database. + + +E_GEN_OVER at some stage in the conversion, the output string exceeded the maximum +allowed length of wR_MaAx_DIAL_STRING characters. + + +The conversion is illustrated by the following examples: +009 44 171 234 5678 + + +009 is an international access code which indicates that an international call is being made. The example +international access code is that of Denmark. In the United Kingdom the international access code is 001. + + +44 is a country code which indicates the destination country. The example country code is that of the +United Kingdom. + + +171 is an area code - in this case it is the Inner London code. +234 5678 is the local telephone number. + +For this example the service simply outputs 009441712345678. +009 44 (0) 171 234 5678 + + +(0) is the national prefix and is enclosed in brackets to indicate that it is not required for international +calls. + + +the other components are as described above. + + +the output string is 009441712345678. In this case the number corresponds to calling London from +Denmark. + + ++44 171 234 5678 + ++ is an abbreviation for the international access code. +44 is the country code for the United Kingdom. + +171 is the area code. + + +234 5678 is the local number. + + +8-4 + + +8 SERIES 3 WORLD DATABASE + + +the interpretation of the string depends on the home country. When this is Denmark, the service replaces +the plus character with the international access code of Denmark giving 009441712345678. On the other +hand, when the home country is the United Kingdom, the plus character and the country code are replaced +with the national prefix and the output string is 01712345678. + + +171 234 5678 [United Kingdom] + + +171 is the area code. +234 5678 is the local number. + + +[United Kingdom] is a convenient means of specifying the destination country: note the space between the +last digit and the first bracket and that the country is specified in full. + + +When the home country is Denmark, the output string is 009441712345678. +When the home country is the United Kingdom, the output string is 01712345678. +0 171 234 5678 + + +0 is the national prefix - sometimes referred to as the STD prefix - and is omitted on international calls. + + +the output string is 0171 234 5678. + + +WR_SET_EXTRA Open file for additional data + + +INT p_iow(VOID *pcb, WR_SET_EXTRA, WORD *flag, TEXT *name) ; + + +Open a file to store extra cities where name should point to the full file specification stored as a zero +terminated string and f1ag should always be set to p_FoPEN. + + +The filename is parsed with an extension of . wip. +The service will fail if the file does not exist. + + +Returns zero on success, otherwise £_GEN_1macE if the file is either badly formatted, or has a different +database version number, or a system error code. + + +WR_EXTRA Modify additional data + + +INT p_iow(VOID *pcb, WR_EXTRA, WORD *func, WR_EXTRA_DATA *data); + +Add, update or delete database entries in the file opened by the earlier wR_sET_ExTRa call. + +The service assumes that an extra World database file has been opened using the wR_sET_EXTRA Service. +The func argument may take one of the following values: + + +WR_EXTRA_ADD_CITY specifies that a city should be added to the World database - the data is read +from the wR_EXTRA_DATA union pointed to by data. The city must be in an +existing country. + + +The wR_EXTRA_DATA union is defined as follows: + + +typedef union +{ +WR_CITY_DATA ci; +WR_COUNTRY_DATA co; +} WR_EXTRA_DATA; + + +For further details of the wr_crTy_pata struct, see the description of the +WR_GET_CITY_DATA service. + + +WR_EXTRA_UPDATE_CITY specifies that a city in the World database should be updated - the new data is +read from the wR_EXTRA_DATA union pointed to by data. The city must be in an +existing country. + + +For details of the wR_ExTRA_DATA union see above. For details of the +WR_COUNTRY_DATA Struct see the description of the wR_GET_COUNTRY_DATA +service. + + +I/O DEVICES REFERENCE + + +WR_EXTRA_DELETE_CITY delete a city in the extra database file - the name of the city and the name of +the country are read from the wR_EXTRA_DATA union pointed to by data. + + +WR_EXTRA_UPDATE_COUNTRY — update a country in the World database - the data associated with the country is +read from the WR_EXTRA_DATA union pointed to by data. Renaming a country +does not delete or otherwise modify the member countries + + +On success, the service returns either zero or one of the following values: +WR_REVERTED the city has reverted to its original built-in data. +WR_DELETED the city has been deleted. + +Otherwise the service returns a negative error code which includes the following: + + +E_GEN_ARG tried to update a non-existent country, or specified a non-existent city as the +capital of a country. + + +WR_TOO_MANY_ERR attempted to exceed the maximum allowed number of items in the extra World +database file. The maximum number of allowed items is 32. + + +WR_DUPLICATE_ERR the new name for a city/country matches an already existing name. +WR_NOT_VALID attempted to delete a built-in city. +WR_DELHOME_ERR attempted to delete the home city. +WR_DEL_CAPITAL_ERR attempted to delete a capital city. + + +WR_GET_ CITY DATA Read city data + + +INT p_iow(VOID *pcb, WR_GET_CITY_DATA, WR_CITY_DATA *result); +Write data associated with the current city to the wR_cITy_pata struct pointed to by result. +The wR_c1tTy_pata struct is defined as follows: +typedef struct +{ +WR_FIND_RES f; +UBYTE units; +UBYTE DST; +WORD GMT; +LATL latl; +TEXT dial [WR_MAX_DIAL+1]; +TEXT STD[WR_MAX_CODE+1]; +P_POINT pos; +} WR_CITY_DATA; +The members of the wR_cr1Ty_pata struct have the following significance: + + +£ the names of the current city and the associated country: for further details see +the description of the WwR_FIND_CITY service. + + +units may be one of the following values: +WR_UNITS_MILES the units of distance are to be miles. +WR_UNITS_KILOMETERS the units of distance are to be kilometers. +WR_UNITS_NAUTICAL the units of distance are to be nautical miles. +DST may be one of the following values: +0x00 the daylight saving time is to be constant. +0x02 the daylight saving time is to be European. +0x04 the daylight saving time is to be American. + + +0x08 the daylight saving time is to be Southern. + + +8 SERIES 3 WORLD DATABASE + + +GMT the local time - this is expressed as a deviation from Greenwich Mean Time in +units of minutes. + + +latl the Lat struct is defined as follows: + + +typedef struct +{ +WORD iLat; +WORD iLong; +} LATL; + + +the iat member gives the latitude of the city in units of minutes of arc. +Positive values correspond to northern latitudes. + + +the iLtong member gives the longitude of the city in units of minutes of arc. +Positive values correspond to western longitudes. + + +dial the city dialling code - stored as a zero terminated string. + +STD the city area code - stored as a zero terminated string. + +pos the coordinates of the city on the World map: used, for example, by the World +application. + + +Returns zero on success, otherwise WR_NOTVALID_ERR if the item is no longer valid, for example, if the +current city has been deleted or renamed. + + +WR_GET_COUNTRY_DATA Read city data + + +INT p_iow(VOID *pcb, WR_GET_COUNTRY_DATA, WR_CITY_DATA *result); +Write the data for the current country to the wR_counTRY_pata Struct pointed to by result. +The wR_countRy_pata struct is defined as follows: + + +typedef struct +{ +WR_FIND_RES f; +UBYTE baseGMT; +UBYTE DST; +WORD GMT; +CO_DIAL dial; +} WR_COUNTRY_DATA; + + +The members of the wR_counrry_para struct have the following significance: + + +£ contains the names of the current country and the associated capital city: for +further details see the description of the wR_FIND_COUNTRY Service. + + +baseGMT reserved for internal use. + + +DST may be one of the following values: +0x00 the daylight saving time is to be constant. +0x02 the daylight saving time is to be European. +0x04 the daylight saving time is to be American. +oxos the daylight saving time is to be Southern. + + +GMT the local time - this is expressed as the deviation from Greenwich Mean Time +in units of minutes. + + +dial the country dialling code information (see below). +The co_prat struct is defined as follows: + + +typedef struct +{ +TEXT dialIntra[WR_MAX_INTRA+1]; +TEXT dialInter [WR_MAX_INTER+1]; +TEXT dial [WR_MAX_CODE+1; +UBYTE dummy; +} CO_DIAL; + + +1/0 DEVICES REFERENCE + + +The significant members of the co_p1at struct have the following meaning: + + +dialintra a zero terminated string of up to four digits, containing the national dialling +prefix. + +dialiInter a zero terminated string of up to four digits, containing the international +dialling prefix. + +dial a zero terminated string of up to eight digits, containing the national code. + + +Returns zero on success, otherwise WR_NOTVALID_ERR indicating that the current country is no longer +valid, for example, if the current country has been renamed. + + +WR_CALC Calculate distance, sunrise and sunset + + +VOID p_ioc(VOID *pcb, WR_CALC, WORD *pstat, WORD *state, WR_CALC_DATA *calc); +INT p_iow(VOID *pcb, WR_CALC, WORD *state, WR_CALC_DATA *calc); + +Obtain the distance of the target city from the home city and the local sunrise and sunset times. +The calculation proceeds in stages in order that it may be discontinued as and when required. + + +The first time the wR_catc service is called, *state must be set to WR_START_STATE. The service should +then be repeatedly called until *st ate is equal to WR_END_STATE indicating that the calculation is +complete. + + +The wR_cALc_paArTa struct is defined as follows: + + +typedef struct +{ +WR_CITY_DATA in; +WR_CALC_OUT out; +} WR_CALC_DATA; + + +The members of the wR_catc_pata struct have the following significance: + + +in specifies the data for the target city: for further details of the wR_cITy_paTa +struct see the description of the wR_GET_CITY_DATA service. + + +out the result of the calculation: the wR_caLc_out struct is defined as follows: + + +typedef struct +{ +WORD distance; +WORD sunRise; +WORD sunSet; +WORD always; +} WR_CALC_OUT + + +the distance member specifies the distance from the home city in the +specified units. + + +the sunRise member specifies the time of sunrise - this is a local time in units +of minutes. + + +the sunSet member specifies the time of sunset - this is a local time in units of +minutes. + + +the always member specifies whether the city is always dark (-1), always light +(1) or neither (0). + + +The completion status code is returned by the synchronous p_iow and written to *pstat by the +asynchronous p_ioc. + + +The completion status code is zero if the request completed successfully, otherwise a negative error code. + + +8 SERIES 3 WORLD DATABASE + + +WR_NEXT_ LOCK Read next city name + + +INT p_iow(VOID *pcb, WR_NEXT_LOCK, WR_FIND_RES *result); + + +Writes the name of the next city as a zero terminated string to the city member of the wR_FIND_REs struct +pointed to by result. + + +The name of the associated country is also written to the country member of the wR_FIND_REs struct +pointed to by result. + + +Returns zero on success, otherwise a negative error. + + +World file types and their locations + + +This section gives a summary of the file structures used by the World Server. The main bulk of the data is +stored using a complex compression algorithm. This cannot be duplicated realistically by a third party +developer, and the functionality is available through the World Server device driver, so it is not given in +detail. + + +Main World file + +The main World database file is stored in the ROM. For a single-language ROM it is: +ROM::WORLD.DAT + +For a multi-lingual ROM is: +ROM::WORLD._ + + +where lang is the language number selected as returned by p_get language, formatted as a 2-digit number, +left-filled with 0 if the language number is <10. + + +For English the filename of the World file in a multi-lingual ROM is ROM::WORLD.DAT. In a multi- +lingual ROM you are obviously going to have a number of such World files. + + +World Extension file + + +Users by default get an extension file World.dat created, but they can make their own world extension +files with different names. These files contain changes to the main data (city additions and changes, and +country changes), which the World Server reads to override the main world database file. + + +World File format + + +First 2 bytes The World file variant signature. This is a scrambled combination of the file version +and language. (Each language can have up to 15 versions; these correspond to new +releases.) + +Next 30 bytes 15 two-byte table pointers. These point to tables, or key positions within tables + +Remaining data Various tables, including a decode table, because all the data following is encoded. + + +I/O DEVICES REFERENCE + + +World Extension File format + +File header + +A World Extension File has a header of 32 bytes: + +First 16 bytes World Extension File signature worldFileType**<0x0> + + +17-18th bytes World file variant signature. On creation is copied from the main database file. Files +which are opened which do not match the main database file are rejected. + + +19-20th bytes Unsigned WORD containing size of extra data block +21st-32nd bytes Not used, filled with oxo bytes +Data block + + +The extra data block follows, which is a string of leading byte count data blocks. Each contains either +city or country alteration information. With the Series 3a and its newer brothers, there is a limit on the +number of blocks to 32 (excluding the final, empty, field). This data block is at least one byte long +(0x0, i.e. a leading byte count list terminator). + + +CHAPTER 9 + + +XMODEM AND YMODEM + + +Introduction + + +All Psion SIBO machines include an Xmodem/Ymodem device driver which implements the industry +standard Xmodem and Ymodem data transfer protocols. Only the data transfer protocols are implemented. +The applications perform the required file I/O. + + +The Psion SIBO Xmodem/Ymodem device driver is attached to a lower level driver which must support +the services provided by the Psion SIBO serial device driver. As it is an attached driver it can run over any +serial channel without modification. + + +There are numerous variations of both the Xmodem and the Ymodem protocols. The following are +supported: + + +e Xmodem Checksum +e Xmodem CRC + +e Xmodem CRC (1K) +e Ymodem + +e Ymodem (1K) + +e Ymodem-G + +e Ymodem-G (1K) + + +I _ +Data transfer protocols overview + + +The Xmodem and Ymodem protocols were established to allow two way error correcting data transfers +between remote computers. The protocols define the data as a series of data blocks each of which is +transmitted with a check for data corruption (a few other bytes are also added - see later sections). The +Xmodem/Y modem device driver supports either a one byte checksum or a two byte CRC data integrity +check. + + +One byte checksum + + +The one byte checksum is the sum of the bytes in the data block with the carries discarded. A one byte +checksum is not as reliable an integrity check as a two byte CRC. + + +Two byte Cyclic Redundancy Check (CRC) + + +The two byte CRC is the remainder after the datablock (treated as a large binary number) is divided by a +sixteen bit number. The supplied device driver uses the CRC sixteen bit divisor recommended by the +CCITT (in polynomial form this is x!° + x!? + x> + 1). The reader should be aware that other CRCs are +also in widespread use (the CRC-16 polynomial for example). + + +I/O DEVICES REFERENCE + + +The Xmodem protocol + + +The Xmodem data transfer protocol was developed in the late seventies as a 'quick hack' for transferring +data between dissimilar machines. It was written on and for machines that had eight bit UARTS +(Universal Asynchronous Receivers and Transmitters) and is thus an eight bit data transfer protocol. + + +The protocol is very simple and thus easy to port to other machines. This and the fact that the original +implementation was placed in the public domain very early in its life has meant that the Xmodem protocol +has become a defacto industry standard data transfer protocol. + + +The protocol lacks many features considered mandatory in modern data transfer protocols including full +duplex transfer and windowing. Worse still it is not robust: corruption of acknowledgement characters or +the data frame header characters can fool the protocol into adopting the wrong state. + + +The file transfer facilities provided by applications that use the protocol simply send the body of the file as +data in data frames. Since the protocol was originally developed on CP/M machines, text files should +consist of lines of printable ASCII terminated by the CRLF (0x0d 0x0a) character sequence, with the file +terminated with the SUB (0x1a) character. It is the responsibility of the application to perform the +required file translation. The SIBO filing system allows text files to be opened in 'stream' mode (i.e. as a +constant data stream with each text record delimited by CRLF characters), see the P_FSTREAM_TEXT +section within the Files chapter of the PLIB Reference Manual. The local filing system of machines in the +SIBO range store data in the same format as MSDOS. Thus a text file can be opened using the P_FsTREAM +mode and still present CRLF delimited data. However a remote filing system, that of the Macintosh for +example, would not necessarily store data in the same format. + + +Binary files can be transferred with the Xmodem protocol. In this case no format is implied. All the data +should be written to file as it is presented in the Xmodem data frames. + + +Link establishment + + +The Xmodem protocol does not define a distinct link establishment phase. The sender of the data waits for +a link establishment character (NAK) and then sends the first data frame. When the first data frame is +received the link is established and both sides are in the data transfer phase. + + +If the sender (receiver) does not receive the expected NAK character (data frame) within a reasonable time +(two minutes for example) it should quit. The receiver will continue sending NAK characters at regular +intervals until either the first data frame is received or the allowed time period has elapsed. + + +The data transfer phase + + +The sender transmits a series of Xmodem Checksum data frames. These consist of: + + +SOH the start of header character (0x01). + +Block number a one byte binary number labelling each data block. The number wraps to zero +at Oxff. + +oxff - block number the one's complement of the block number. This validates the block number. + +Data block a block of 128 data bytes. + +One byte checksum the sum of the data bytes with the carrys discarded. + + +Each frame must contain exactly 132 bytes. Thus when there is insufficient data to fill the data block +padding must be added. Typically the padding consists of end of file (SUB) characters, although NULL +characters would probably be better when sending binary files. + + +If the data and the block number have not been corrupted the receiver will send a positive +acknowledgement character (ACK) requesting the sender to transmit the next data frame. Otherwise the +receiver will transmit a negative acknowledgement character (NAK) requesting the sender to retransmit +the previous (corrupted) data frame. + + +Link termination + + +An Xmodem link termination phase does not exist separately to the data transfer phase. When the last +data frame has been transmitted the sender transmits a one byte EOT character that informs the receiver +that there is no more data. The receiver should acknowledge this in the same way that a normal data +frame is acknowledged, that is with either ACK or NAK characters. Once successfully acknowledged the +link has terminated. + + +9-2 + + +9 XMODEM AND YMODEM + + +Checksum data flow showing error recovery + + +Sender Receiver +NAK + +NAK + +SOH,0x01,0xFE,<128bytes>,CHK +NAK + +SOH,0x01,0xFE,<128bytes>,CHK +ACK + +SOH,0x02,0xFp,<128bytes>,CHK +ACK + +SOH,0x03,0xFc,<128bytes>,CHK + + + +SOH,0x03,0xFc,<128bytes>,CHK +ACK + +EOT +NAK + +EOT +ACK + + +The CRC variant + + +Xmodem CRC differs from the Xmodem Checksum protocol only in the data integrity check and the link +establishment character. + + +The Xmodem CRC protocol data frames include a two byte CRC data integrity check (with the high byte +being sent before the low byte) in place of the one byte checksum. This gives an improved data integrity +check at the expense of an extra byte of non-data - data frames are thus 133 bytes long. The PLIB function +p_crce will generate the required CRC. + + +The receiver establishes an Xmodem CRC link by sending a C (0x43) link establishment character. The +link establishment will fail if the sender does not support the CRC mode. + + +CRC data flow showing error recovery + + +Sender Receiver +C + +Cc + +SOH, 0x01,0xFE,<128 bytes>,CRCHI,CRCLO +ACK + +SOH,0x02,0xFD,<128 bytes>,CRCHI,CRCLO +NAK + +SOH,0x02,0xFpD,<128 bytes>,CRCHI,CRCLO + + + +SOH,0x02,0xFD,<128 bytes>,CRCHI,CRCLO +ACK + +EOT +ACK + + +The 1K variant + + +The 1K variant allows the sender to transmit 1024 bytes of data per data frame. Each 1K data frame starts +with an STX character (not an SOH character) and is otherwise identical to an Xmodem CRC data frame. +The link establishment, data transmission and link termination phases are the same as for the Xmodem +CRC protocol. + + +The 1K option allows 1024 byte data frames to be intermixed with 128 byte data frames, with the +restriction that a retransmitted frame must be the same size as the originally transmitted frame. + + +1K data frames are more sensitive to corruption (remember that the whole data block is destroyed by the +corruption of only one data byte). Thus 1K protocols should not be used when the transmission line is +noisy. + + +The 1K Xmodem variant supports only a two byte CRC data integrity check. It is inadvisable to use a one +byte checksum with 1K data frames and this option is not supported by the supplied driver. + + +I/O DEVICES REFERENCE + + +The 1K option data flow + + +Sender Receiver + +C +STX,0x01,0xFE,<1024 bytes>,CRCHI,CRCLO + +ACK +STX,0x02,0xFD,<1024 bytes>,CRCHI,CRCLO + +NAK +STX,0x02,0xFD,<1024 bytes>,CRCHI,CRCLO + + + +STX,0x02,0xFD,<1024 bytes>,CRCHI,CRCLO + +ACK +SOH,0x03,0xFc,<128 bytes>,CRCHI,CRCLO + +ACK +STX,0x04,0xFB,<1024 bytes>,CRCHI,CRCLO + +ACK +EOT + +ACK + + +Abandoning a transfer + + +The Xmodem specification does not explicitly provide for abandoning a data transfer session. In practice +various implementations will request link abandonment by sending a series of CAN (0x18) characters. +This method does not work well when the sender is currently transmitting a data frame. The safest option +is to continue sending the data frame and afterwards transmit the CAN characters. For a high quality +interface this alternative implies an unacceptable wait (for the 1K protocol with a 1200 baud transmission +rate the wait would be about eight seconds). The second alternative is to quit data frame transmission +immediately and send a series of CAN characters (which could be misinterpreted as belonging to the +abandoned data frame). Even if the receiver misinterprets some CAN characters the session will +eventually be abandoned. + + +When sending data the supplied driver will simply stop transmitting the current data frame and send a +CAN character immediately. + + +When receiving data the supplied driver will send a CAN character. + + +If a CAN character is received by the driver (except as part of a data frame) it will fail any outstanding +request with the E_FILE_CANCEL completion status. + + +The Ymodem protocol + + +The Ymodem protocol was developed from the realisation that the Xmodem protocol has several +weaknesses: + + +e Only one file can be transferred per command. The file name must be entered at both ends of the +link implying that the user has direct or indirect access to both computers (in addition to the +Xmodem link). + + +e The transferred files can contain up to 127 (or even 1023) useless bytes. These are added to pad +out the last data block. + + +e The time and date that the file was last modified are lost. + + +Some of the other weaknesses of the original specification had already been resolved by developing +variants of the Xmodem protocol. These variants (discussed in the previous section) allow for a more +sophisticated data integrity check (the CRC variant) and larger data frames (the 1K variant). + + +The three weaknesses in the above list are all concerned with file transfer rather than data transfer. Unlike +Xmodem, the Ymodem protocol is specifically designed for file transfer. + + +The Ymodem protocol does not attempt to overcome problems with or enhance the actual data flow +protocol. Thus Ymodem is subject to the same data corruption problems as Xmodem. + + +All Ymodem variants use CRCs. + + +9 XMODEM AND YMODEM + + +Link establishment + + +The Link establishment phase is identical to that for Xmodem CRC except that the first data frame +transmitted has a block number of zero rather than one. This block contains file information as follows: + + +e A zero terminated name. This is either the fully specified path name for the file to be transferred +or (more commonly) the file name with no path specified. In either case the name must be +acceptable to both the sender's and receiver's filing systems (in general machines that have +different filing systems will accept only the file name). This field is mandatory. + + +e = The file length. This is stored as a sequence of decimal digits immediately following the zero +terminated name. The receiver may use the file length to set the end of file position at the end of +the transfer. If further fields are present the file length must be present. If there are no further +fields the file length is optional. + + +e = The file modification date. This is stored as a sequence of octal digits specifying the time at +which the file was last modified in seconds from 00:00:00, January 1, 1970 (Unix time). A +single space character separates the file modification date from the file length. If further fields +are present the file modification date must be present. If there are no further fields the file +modification date is optional. + + +e The mode. This is stored as a sequence of octal digits and specifies the file mode. Unless the file +was sent from a Unix machine the mode is set to zero. Files sent from Unix machines that have +the mode set to 0x8000 are assumed to be a Unix type regular file. The mode field is separated +from the file modification date by a single space character. If further fields are present the mode +must be present. If there are no further fields the mode is optional. + + +e Serial number. This is stored as a sequence of octal digits and specifies the serial number of the +sender's software. The receiver's use of this number is optional. The serial number field is +separated from the mode field by a single space character. This field is optional. + + +All undefined fields, and the remaining bytes of the data frame, should be set to zero to allow for future +compatibility. + + +The following code fragment generates the first data frame containing the required Ymodem information +for filename, length and modification date. + + +p_bfil(&buf[0],128,0); +p_finfo(pFilename, &info) ; +p=p_scpy (&buf[0],pFilename) +1; +pt=p_gltob(p,info.size,10); +*ptt=" '; +pt=p_gltob(p,info.modst, 8); + + +When the first frame arrives the receiver should attempt to open the specified file. If the open request is +successful the receiver should send back an ACK to continue with the transfer, otherwise a CAN to cancel +the transfer. + + +When there are no more files to transfer the link connection should be re-established with a zero length +file name, after which the batch file transfer ends. + + +The data transfer phase +The data transfer phase is identical to the Xmodem CRC data transfer phase. + + +Link termination + + +The Ymodem file transfer termination phase does not exist separately from the data transfer phase. When +the file has been transmitted a one byte EOT character is sent to the receiver. The receiver should +acknowledge this in the same way that a normal data frame is acknowledged using either ACK or NAK +characters. The transfer of the file is now complete. When one or more additional files are to be sent the +sender must reestablish a link with the receiver and send the next file in exactly the same manner. When +all files have been sent the sender must send an initial (block number zero) data frame containing a zero +length file name. + + +I/O DEVICES REFERENCE + + +Ymodenm file transfer data flow + + +Sender Receiver + +C +SOH, 0x00,0xFF,,CRCHI,CRCLO + +ACK +SOH,0x01,0xFE,<128bytes>,CRCHI,CRCLO + +ACK +SOH,0x02,0xFD,<128bytes>,CRCHI,CRCLO + +ACK +EOT + +ACK + +C +SOH,0x00,0xf£,,CRCHI,CRCLO + +ACK +SOH,0x01,0xFE,<128bytes>,CRCHI,CRCLO + +ACK +SOH,0x02,0xFD,<128bytes>,CRCHI,CRCLO + +ACK +EOT + +ACK + +C +SOH,0x00,0xf£,,CRCHI,CRCLO + +ACK + + +The 1K variant + + +The 1K variant allows the sender to transmit 1024 bytes of data per frame. The 1K variant data frames are +identical to Xmodem 1K data frames (with the exception of the first frame as discussed earlier). + + +The G variant + + +The Ymodem-G protocol does not have any specified way of reporting an error to the sender, or more +specifically of requesting a re-transmission of a broken data frame. The only advantages over straight +ASCII transfer is that the receiver can detect errors (although nothing can be done about them) and +multiple files can be transferred. The design philosophy seems to have been that error correcting modems +guarantee that the files are not corrupted during transfer and that the inclusion of software error corection +severely reduces the modem's throughput. However error correcting modems only ensure that the data is +not corrupted during the transfer from one modem to another.They do not check for corruption of the data +while it is being sent from the computer to the modem, and vice versa. A typical problem can occur with +PCs connected to networks where some network software insists on disabling interrupts for extended +periods of time, certainly long enough to get serial overrun errors. The Ymodem-G protocol is highly +susceptible to such errors. + + +A Ymodem-G link is established by the receiver sending a G (0x47) character. + + +The Ymodem-G protocol only has acknowledgement characters after the first data frame (indicating that +the file was successfully opened) and after the EOT character (indicating that the file was successfully +closed). + + +The supplied device driver will send a CAN character if an error was detected while in Ymodem-G mode. +This will typically abort the entire transfer. + + +9 XMODEM AND YMODEM + + +Ymodem.-G file transfer data flow + + +Sender Receiver +G +SOH, 0x00,0xFr,,CRCHI,CRCLO +G +SOH,0x01,0xFE,<128bytes>,CRCHI,CRCLO +SOH,0x02,0xFp,<128bytes>,CRCHI,CRCLO +EOT +ACK +G +SOH,0x00,0xf£,,CRCHI,CRCLO +G +SOH,0x01,0xFE,<128bytes>,CRCHI,CRCLO +SOH,0x02,0xFpD,<128bytes>,CRCHI,CRCLO +EOT +ACK +G + + +SOH,o0x00,0xf£,,CRCHI,CRCLO + + +Abandoning a transfer + + +The Ymodem specification does not explicitly provide for abandoning a data transfer session. Various +implementations will send CAN (0x18) characters in an attempt to inform the remote computer that the +data transfer session should be abandoned. + + +When sending data the supplied driver will simply stop transmitting the current data frame and send a +CAN character immediately. + + +When receiving data the supplied driver will send a CAN character. + + +If a CAN character is received by the driver (except as part of a data frame) it will fail any outstanding +request with the E_FILE_CANCEL completion status. + + +Protocol problems + + +The primary task of any data transfer protocol is to ensure that the data sent is the same as the data +received. If the physical media being used could not corrupt the data then ASCII file transfer would be +ideal since no overheads are required in validating the data. + + +Although the Xmodem and Ymodem protocols address the majority of problems concerned various holes +in the error recovery have been pointed out. For example: + + +e Synchronisation will be lost if the NAK character sent by the receiver is corrupted to an ACK +character. The transfer will thus fail. + + +e = The use of different link establishment and acknowledgement characters for Xmodem, Ymodem +and Ymodem-G protocols can lead to confusion if the character is corrupted. For example, the +Ymodem protocol attempts to establish the link by sending a C character. Corruption of the +C to aG would fool the receiver into connecting in Ymodem-G mode. + + +e The use of anonymous acknowledgement characters for requesting data frame (re)transmission +can cause timing problems. For example, consider a receiver that sends an ACK or NAK +character requesting transmission of a data frame and finds that the sender is preoccupied. The +protocol allows for the receiver to wait for a specified time interval and then send another ACK +or NAK character. This will work fine unless the sender replies after transmission of the second +ACK or NAK character, and before its receipt. In this case the receiver will assume that the +transmitted data frame corresponds to the second ACK or NAK character and thus +synchronisation will be lost. + + +In actual field usage the Xmodem and Ymodem protocols perform more than adequately. + + +I/O DEVICES REFERENCE + + +ee en +Xmodem/Ymodem services + + +p_open(XMD:) Open an Xmodem/Ymodem channel + + +INT p_open(VOID **ppXmodem, "XMD:", —-1); + + +Attach the Xmodem/Ymodem driver to the open channel specified by ppxmodem. All I/O requests on that +channel will now be routed to the Xmodem/Ymodem device driver. + + +The passed channel is assumed to support the set of services provided by the serial driver. Currently only +the try: driver supports the serial services. + + +For example: +VOID *pcb; +if (!p_open(&pcb, "TTY:A",-1) ) +{ + + +if (!p_open(&pcb, "XMD:",-1) ) +{ + + +p_close (pcb); +} + +p_close (pcb) + +} + + +Note that two calls to p_close are required, one to close the channel to the Xmodem/Ymodem driver and +the second to close the channel to the serial driver. + + +The Xmodem/Ymodem driver senses the current serial driver's characteristics, removes any XON/XOFF +handshaking, sets the terminator mask to zero and sets the framing to eight bits, no parity and one stop +bit. The original serial characteristics are restored when the driver is closed. + + +Once a channel to the Xmodem/Ymodem driver has been opened, the application must connect to the +computer at the remote end. This done with the p_FconNECT service. + + +The calling process will be panicked if the serial driver to which the Xmodem/Ymodem driver is attached +has any outstanding requests on it. + + +Returns zero if the request completed successfully otherwise a negative error number. + + +p_close Close the Xmodem channel + + +INT p_close(VOID *pXmodem) ; + + +Close the Xmodem channel specified by pXmodem. The device driver should be closed when the file +transfer has completed. All I/O requests on the driver channel will then be routed to the underlying serial +driver. + + +Every outstanding request on the Xmodem/Ymodem driver will be completed, its completion status word +will be set to E_FILE_CANCEL and a signal will be generated. + + +The characteristics of the serial driver are restored to the values held before the Xmodem/Ymodem driver +was opened. + + +The p_FCLOSE request cannot fail and returns zero. + + +P_FCONNECT Connect to the remote computer + + +VOID p_ioc(VOID *pXmodem, P_FCONNECT, WORD *pstat, UWORD &type, UWORD &mode) ; +INT p_iow(VOID *pXmodem, P_FCONNECT, UWORD &type, UWORD &mode) ; + + +Obtain a connection to a computer assumed to be running some Xmodem/Ymodem software. +The connection type can be established as one of: +@ =P_XMDM_ACCP + + +e P_XMDM_INIT + + +9-8 + + +9 XMODEM AND YMODEM + + +where p_xmpmM_accp would be used to accept a connection (the application wishes to transmit a file or +files) and p_xmpM_1nrtT would be used to initiate the connection (the application wishes to receive a file or +files). + + +The connection mode determines the file transfer mode and can be one of: + + +P_XMDM_CRCORCHECKSuUM _ the connection should be established in either Xmodem checksum or Xmodem +CRC mode depending on which mode is supported by the remote computer. +The driver has a bias towards CRC mode. When transmitting connection +request characters it sends two CRC connection request characters (C,0x43) to +every checksum connection request character (NAK,0x15). When accepting a +connection it will throw away the first NAK character it receives while waiting +for a potential C character. + + +P_XMDM_CHECKSUMMODE the connection should be established in Xmodem checksum mode only. This +will connect to a remote computer that is using checksum mode faster than the +P_XMDM_CRCORCHECKSUM option. (If the remote computer is trying to establish a +connection in CRC mode a connection will still be established. This fact will +be reported to the caller.) + + +P_XMDM_CRCMODE the connection should be established in Xmodem CRC mode only. If the +remote computer does not support CRC mode no connection will be +established. + +P_YMODEM_MODE the connection should be established using the Ymodem batch protocol. + +P_YMODEM_G_MODE the connection should be established using the Ymodem-G batch protocol. + + +As an option on any of the protocols that support CRC error checking (Xmodem CRC and all the +Ymodem variants) the p_xmpM_onz_x flag can be ored into mode to indicate that data frames of size 1K +can be transmitted and received. + + +For example: +mode=P_XMDM_CRCMODE | P_XMDM_ONE_K; + + +When this flag is not set the Xmodem/Ymodem driver will refuse to accept 1K data frames and will +instead reply with NAK characters. This will eventually cause the data transfer to fail. + + +When a connection cannot be established, the reason for the failure will be written back to the completion +status word. + + +If the connection is successfully established the completion status word will contain zero and the actual +connection mode will be written back to mode. + + +For example: + + +type=P_XMDM_INIT; +mode=P_XMDM_CRCORCHECKSUM; +if (!p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +{ +if (mode==P_XMDM_CRCMODE) +p_puts ("CRC mode") +else if (mode==P_XMDM_CHECKSUMMODE) +p_puts ("Checksum mode") + + +} +Note that the data space for mode must be preserved until the connection request completes. + + +In general the connection request will take an extended time. Thus the request should be made +asynchronously. The connection request can be cancelled with the p_FDISCONNECT service. + + +If the p_FconnEcT request was started successfully the I/O request returns either zero or a negative error +number. + + +The completion status word is returned by the synchronous p_iow request and written to *pstat by the +asynchronous p_ioc request. It is set to =_FILE_PENDING while the request is outstanding and zero on +successful completion. If the request fails to complete it is set to a negative error number. + + +The calling process will be panicked if there is an outstanding p_rcoNnNECcT request. + + +I/O DEVICES REFERENCE + + +Examples + + +To receive files using the Xmodem-CRC 1K protocol: + + +type=P_XMDM_INIT; + +mode=P_XMDM_CRCMODE | P_XMDM_ONE_K; + +if (!p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +{ + + +} +To send files using the Ymodem batch protocol: + + +type=P_XMDM_ACCP; + +mode=P_YMODEM_MODE; + +if (!p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +{ + + +} +To send files using the Ymodem-G 1K batch protocol: + + +type=P_XMDM_ACCP; + +mode=P_YMODEM_G MODE |P XMYM_ONE_K; + +if (!p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +{ + + +P_FDISCONNECT Disconnect from the remote + + +INT p_iow(VOID *pXmodem, P_FDISCONNECT) ; +Disconnect from the remote computer. + + +The P_FDISCONNECT request can also be used to abandon the Xmodem/Ymodem session during the +connection establishment or data transfer phases. + + +If a connection has already been established then the p_rp1IscoNnNEcT request will cause a CAN character +to be transmitted to the remote computer. This may or may not be picked up by the remote +Xmodem/Ymodem implementation to indicate that the data transfer phase is being abandoned. The +Xmodem/Ymodem protocols do not have any standard mechanism for abandoning data transfer. + + +If no connection has been established yet, or if the transfer is now complete, no characters will be +transmitted to the remote computer. + + +Any outstanding asynchronous requests will be cancelled by the p_FpIsconnEcT request, and their +completion status words set to E_FILE_CANCEL. For each outstanding request a signal will be generated +and must be used up by the application. + + +Typically the p_FDISCONNECT request would be called synchronously. +The P_FDISCONNECT request can not fail and returns zero. + + +Example + + +type=P_XMDM_INIT; +mode=P_XMDM_CRCORCHECKSUM; +p_ioc (pXmodem, P_FCONNECT, &xStat, &type, &mode) ; +p_ioc(pConsole, P_FREAD, &kStat, &kbr) ; +p_iowait(); +if (xStat!=E_FILE_PENDING) + +{ /* Xmodem connect completed */ + + +} +else +{ /* key press occurred - cancel P_FCONNECT */ +p_iow (pXmodem, P_FDISCONNECT) ; +p_waitstat (&xStat); + + +9 XMODEM AND YMODEM + + +P_FREAD Read data from the remote computer + + +VOID p_ioc(VOID *pXmodem, P_FREAD, WORD *pstat, UBYTE *buffer, UWORD *plen)j; +INT p_iow(VOID *pXmodem, P_FREAD, UBYTE *buffer, UWORD *plen); + + +Read data from the remote computer. If the connection was not established with a type of p_xmpm_rntT the +request will fail with the negative error E_FILE_DISc. + + +When data is available it will be written to the buffer pointed to by buffer and the length of the data will +be written to *plen. + + +When the end of data indicator (EOT) from the remote computer is received the p_rreap request will be +completed with the (negative) z_F1ILE_zoF error number. + + +The application is responsible for supplying a buffer large enough to hold the largest data frame that can +arrive. If the p_xmpM_onz_k mode flag was set in the p_rconnecT request this is 1024 bytes otherwise it is +128 bytes. + + +If the Ymodem protocols are being used the first data frame read will contain the Ymodem file +information. + + +If the p_rREAD request was started successfully the synchronous I/O request returns zero otherwise it +returns a negative error number. + + +Whilst an asynchronous P_FREAD request is outstanding the completion status word is set to +E_FILE_PENDING. On completion the status word is set to zero if the read request completed successfully +otherwise a negative error number. In particular the completion code is set to E_F1LE_zoF if there is no +more data to read. + + +The calling process will be panicked if there is an outstanding p_rREapD request. + + +Examples + + +Receiving multiple files using the Ymodem protocol: + + +type=P_XMDM_INIT; +mode=P_YMODEM_G_MODE; +FOREVER +{ +if (ret=p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +break; +if (ret=p_iow(pXmodem, P_FREAD, &fileinfo[0],élen) ) +break; +if (!p_slen(&fileinfo[0])) +{ /* finished multi-file receive */ +ret=0; +break; +} +p_open (&pFile, &fileinfo[0],P_FUPDATE|P_FSTREAM|P_FREPLACE) ; +while (! (ret=p_iow(pXmodem, P_FREAD, &buf[0],&len) ) ) +{ +if (ret=p_write (pFile, ébuf[0],1len) ) +break; +} +if (ret==E_FILE_EOF) +{ +/* Truncate the file as specified in fileinfo[] */ +} +p_close(pFile) ; +/* set the file modification date */ +if (ret!=E_FILE_EOF) +break; +} +p_iow (pXmodem, P_FDISCONNECT) ; +if (ret) +p_puts ("Error receiving files"); + + +I/O DEVICES REFERENCE + + +Receiving a single file using the Xmodem protocol: + + +type=P_XMDM_INIT; +mode=P_XMDM_CRCORCHECKSUM; +if (!p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +{ /* Xmodem connect completed */ +p_open (&pFile, "temp.tmp", P_FUPDATE |P_FSTREAM|P_FREPLACE) ; +while (! (ret=p_iow(pXmodem, P_FREAD, &buf[0],&len) ) ) +{ +if (ret=p_write(pFile, ébuf[0],1len) ) +break; +} +p_close(pFile) ; +p_iow (pXmodem, P_FDISCONNECT) ; +if (ret!=E_FILE_EOF) +p_puts ("Error occurred"); + + +P_FWRITE Write data to the remote computer + + +VOID p_ioc(VOID *pXmodem, P_FWRITE, WORD *pstat, VOID *buffer, UWORD *plen); +INT p_iow(VOID *pXmodem, P_FWRITE, VOID *buffer, UWORD *plen); + + +Write data to the remote computer. If the connection was not established with a type of P_xmpM_accp the +request will fail with the negative error E_FILE_DISc. + + +Data can be written in buffers of 128 or 1024 bytes, although the device driver does not check whether or +not the connect request specified the p_xmpm_onE_x flag. If the receiver has not been set up to receive +1024 byte frames (the 1k option) it will in general fail to accept the data. + + +The 1K option specification allows the user to intermix the transmission of 128 and 1024 byte frames, this +driver conforms to that specification. + + +If the write request is for fewer than 128 bytes the internal transmit buffer is padded to 128 bytes with +SUB (0x1a) characters. If the request is for more than 128 but fewer than 1024 characters, the internal +buffer will similarly be padded with SUB characters. + + +As an exception to the above, if a write request of zero length is received this is taken to indicate that the +end of text marker should be transmitted to the remote computer, thus completing that data transfer. + + +Unlike for many device drivers the application does not have to preserve the data buffer or the length word +data spaces until data transmission has completed. + + +If the Ymodem protocols are being used the first data frame to be written is assumed to contain the +Ymodem file information. + + +If the p_rwRITE request was started successfully the I/O request returns zero otherwise it returns a negative +error number. + + +Whilst an asynchronous P_FWRITE request is outstanding the completion status word is set to +E_FILE_PENDING. On completion the status word is set to zero if the write request completed successfully +otherwise, it is set to a negative error number. + + +The calling process will be panicked if there is an outstanding P_FwRITE request. + + +9 XMODEM AND YMODEM + + +Examples + + +Sending a single file using the Xmodem protocol: + + +type=P_XMDM_ACCP; +mode=P_XMDM_CRCMODE; +if (!p_iow(pXmodem, P_FCONNECT, &type, &mode) ) +{ /* Xmodem connect completed */ +p_open (&pFile, "temp.tmp", P_FOPEN|P_FSTREAM|P_FSHARE) ; +while ((len=p_read(pFile, &ébuf[0],128) )>0) +{ +if (ret=p_iow(pXmodem, P_FWRITE, &buf[0],&len) ) +break; +} +if (!ret && (!len || len==E_FILE_EOF) ) +{ +len=0; /* Force EOT to be sent */ +p_iow (pXmodem, P_FWRITE, &buf[0],&len); +} +p_close(pFile) ; +p_iow (pXmodem, P_FDISCONNECT) ; +if (ret) +p_puts ("Error occurred") ; + + +Sending multiple files using the Ymodem protocol: + + +type=P_XMDM_INIT; +mode=P_YMODEM MODE |P XMDM_ONE_K; +FOREVER + +{ + +if (ret=p_iow(pXmodem, P_FCONNECT, &type, &mode) ) + + +break; +if (! (ret=getNextFileName (&name[0]) ) ) +break; /* gets Ymodem 1st frame info */ +len=128; +if (ret=p_iow(pXmodem, P_FWRITE, &name[0],&len); +break; + + +p_open (&pFile, gname[0],P_FOPEN|P_FSTREAM|P_FSHARE) ; +while ((len=p_read(pFile, &buf[0],1024) )>0) + + +if (ret=p_iow(pXmodem, P_FWRITE, &buf [0], &len) ) +break; + + +if (!ret && (!len || len==E_FILE_EOF) ) + + +len=0; /* Force EOT to be sent */ +p_iow (pXmodem, P_FWRITE, &buf[0],&len); + + +p_close(pFile); +if (ret) +break; +} +p_iow (pXmodem, P_FDISCONNECT) ; +if (ret) +p_puts ("Error sending files"); + + +CHAPTER 10 + + +NCP AND LINK + + +Introduction + + +This chapter describes the Psion Link application and the peer to peer data transfer services that are +provided to enable client server type applications to communicate with each other when the client and +server processes exist on different machines. + + +The basic Link application consists of two processes: LINK and syssncp. The Linx process varies from +machine to machine and provides only the user interface and one basic service. The syss$ncpP process is +identical on all machines and handles the physical connection and data transfer services. + + +The Link application is organised in four layers, each of which is responsible for a particular job: + + +e Physical Layer: for example the Serial Driver. This layer provides a set of services that hide any +hardware dependencies from the Logical Layer. + + +e Logical Link Layer. This layer provides the logical (hardware independent) services required by +the third layer. + + +e Data Transport and Multiplexing Layer +e = Application Layer + + +The first three layers are contained within the syssncp process, whose services are accessed via the NcP: +device driver. The syssncp process provides the data transport mechanism that allows client server +processes on different machines to communicate with each other. + + +There are many possible application layers, one of which is the LINK process. Client and server processes +are also examples of application layer processes. + + +Panics + + +All services (with the exception of p_open) will cause the calling process to be panicked if the passed +channel handle is not valid. Other panics are described under the particular service to which they apply. + + +The Psion logical link layer protocol + + +The Psion Link protocol provides the logical link layer services required by the syssncp process. The +services provided are fairly primitive. The syssncp process adds value to these services. A brief summary +of the protocol is presented here to aid in the explanation of the overall system. + + +The Psion Link protocol is a proprietary protocol based on the MNP protocol. It provides a symmetrical +‘error-free’ link between computers including: + + +e Full duplex data transmission. + +e 16 bit CRC error detection. + +e Multiple retransmissions. + +e Dataframe sequencing. + +e Variable dataframe size up to a maximum of 300 bytes per dataframe. + + +e A window size of one. + + +10-1 + + +I/O DEVICES REFERENCE + + +One of the major design criteria of the protocol was that it could be implemented in a very small amount +of code and required a small working set. Thus features such as large data frames (eg 1K) and windowing +were rejected. + + +The protocol is a data transfer protocol, not a file transfer protocol. The file transfer or more accurately +file access and management services are provided by application layer processes. + + +The SYS$NCP process + + +The two primary functions of the syssncp process are connection establishment and data transfer. +Connection establishment + + +A connection is established when the following criteria have been met: + +e A physical link has been established. + +e A logical link has been established. + +e The syssncp process has successfully exchanged logon messages with its remote counterpart. +If any of the above fail or the remote counterpart is not compatible a connection will not be established. + + +A physical link is deemed to have been established when the local machine detects that the remote +machine is driving the DTR (local machines DSR) hardware handshaking line (for further details see the +Serial Port chapter). + + +When establishing a modem link, a physical link is deemed to have been established when a modem +driver reports that an incoming call has arrived or that the dial request has been sucessful. + + +A logical link is deemed to have been established when the Pp_FconneEcT request on the link layer protocol +driver completes sucessfully. + + +The syssncp processes exchange logon messages that contain a version number and the time at which the +process was started. + + +The version numbers are checked to ensure compatibility (for possible future expansion). + + +The communicating sys$NncP processes exchange the time at which each was started so as to allow +connection re-establishment in the event of an error at either the logical or physical layer. The re- +establishment of the application layer connections (if present) will be transparent to the applications. + + +Data transfer + + +The syssncp process creates eight separate logical (software implemented) channels through which +applications can communicate. The first channel, channel zero, is used by the sys$ncp process, leaving +seven channels free for client server applications. When sending data the syssncp process multiplexes the +eight logical channels into one physical channel. Conversely, when receiving data the process +demultiplexes the data from one physical channel to eight logical channels. + + +The transferred data can be divided into control data and application data. + + +Control data is the data exchanged between communicating syssNcp processes that concerns application +connection, disconnection and data flow control. + + +Application data is the data exchanged between connected applications. It is transparent to the sys$ncP +process (which places no significance on any of the transferred bytes). Full 8 bit data transfer is available. +The syssncp process simply ensures that the data sent on a particular channel is routed to the correct +destination process. + + +The syssncp process removes a limitation of the logical link layer, namely the data frame size. The +SYSSNCP process will 'segment' application data such that the only frame size limitation is that of the +particular application. + + +10-2 + + +10 NCP AND LINK + + +The LINK process + + +The three primary tasks of the LINK process are: +e to provide a user interface for the Link application +e to respond to state changes in the syssncp process +e to set up the remote filing system, after successful connection establishment. + + +On both the Series 3 and the HC, the Link application has no visible user interface: the application is +started and stopped by the system process. For example, on the Series 3 the user turns the Link application +on or off and sets the baud rate by selecting the Remote link option on the Special menu. The system +process launches or terminates the application accordingly. + + +Since there is no user interface on the Series 3 and the HC, all state changes are handled without +prompting the user for a response. See the p_rFRsuPER and P_FINQ services described below. + + +When the syssncp informs the L1nx process that a connection has been established the L1nx process at +each end runs a process called syssrrsv (the remote file server process). The syssrrsv process provides +remote file access and management services. The L1nx process then adds the REM-:: filing system PDD +(Physical Device Driver) to the file server, thus creating a client server pair. + + +The 1nx process also sets itself up as an IPC (InterProcess Communication) message receiver. An +application may send the following messages to the LINK process: + + +LNKMSG_TERMINATE request that the Link application terminate. This involves removing the remote +file system client server pair, and informing the syssncp process that it should +terminate. Instead of sending a message directly an application can use the +p_pterminate system service to send this message indirectly. + + +LNKMSG_LOADREMOTE request that a message to load and run a specified process be sent to the remote +LINK process. The message is assumed to contain up to E_Max_NamE + 2 bytes. +The message consists of the name of the remote process that is to be loaded +followed by an optional leading byte count command line. If a command line +is required then the process name must be padded out to z_max_namE + 2 bytes +(with NULLS) for compatiblity purposes. The name is parsed with .JMG and +the resultant file name (no device or path) taken as the match pattern for a +search that will firstly look in the default directory of the remote LINK process +(typically LOC::M:\) then in the root directory of any devices that exist on the +remote machine and finally in the ROM. If a process is sucessfully loaded it +will be resumed immediately, the remote L1nx process will force a context +switch to allow the newly loaded process to run, typically for long enough to +open a channel on the nce: device. The resultant process id and full process +name are sent from the remote L1Nnx to the local tnx process. The local L1nk +process will write back the full process name into the buffer passed and +complete the IPC message send with the positive remote process id or negative +error number, very similar to the return values for p_execc. + + +LNKMSG_CONFIG request that the L1nx process inform the syssncp process to change its driver +configuration. The message parameter is the full pvrs struct to be passed to the +SYSSNCP process. + + +The tnxmsc_... message numbers can be found in link_def.h and the pvrs struct definition is in sys$ncp.h. + + +NCP services + + +p_open(NCP:) Open an NCP channel +INT p_open(VOID **ppNcp,"NCP:",-1); + + +Requests that a channel to the SYS$NCP process be opened and a channel allocated to the calling process +in preparation for connection to, and communication with, a remote process. + + +10-3 + + +I/O DEVICES REFERENCE + + +The nep: device driver is a root device driver, it does not require any opened channels to be passed to the +p_open request. All I/O requests on the allocated channel will be routed to the sys$ncp process by this +device driver automatically. + + +Opening a channel does not cause any data to be transferred to the remote machine. +A single process may open as many channels on the ncp: device as it likes. + + +If a process terminates for any reason without closing the channel to the ncp: device the syssNncP process +will tidy up, reporting to any remotely connected channel that this channel has now been closed. + + +Returns zero if the open request completed sucessfully otherwise a negative error number. A typical error +is that the syssncp process is not currently running in which case the E_FILE_NxIST error value will be +returned. + + +Example + + +if (!p_open(&pNcp, "NCP:",-1) ) +{ + + +p_close(pNcp) ; +} + + +p_close() Close the NCP channel +INT p_close(VOID *pNcp) ; +Requests that the currently opened channel to the syssncp process be closed. + + +Any outstanding I/O requests will be completed with the E_FILE_CANCEL completion status and a signal +will be generated. + + +If the process is still connected to a remote process the remote process will be informed that the +connection has been closed, any outstanding requests the remote process has will be completed with the +E_FILE_DIsc completion status. + + +The close request cannot fail and always returns zero. + + +P_FCONNECT Connect to a remote process + + +VOID p_ioc(VOID *pNcp, P_FCONNECT, WORD *pstat, UBYTE *pname, UWORD *plen); +INT p_iow(VOID *pNcp, P_FCONNECT, UBYTE *pname, UWORD *plen); + + +Requests that the channel be connected to a remote channel that has been opened by the named process. + + +In a typical client server application only the client process would make a p_FCoNNECT request. The server +process would typically open an nce: channel and queue a P_FREAD request awaiting its first command +from a client. + + +If both processes of an application attempt to obtain a connection they should ensure that their counterpart +is running and has an nce: channel open before making the P_FCONNECT request otherwise the request will +fail with the E_FILE_NxIstT completion status. Obviously if the connection request fails with the +E_FILE_NXIST completion status the request can be retried. The number of retries should, however, be +limited. + + +If an open channel is already connected to a remote channel the request will complete sucessfully. + + +In the Link application both of the L1nx processes attempt to obtain a connection. In this case both of +these processes will be running and have an ncp: channel open, since they launch the syssncpP process in +the first place. + + +The pname parameter is a pointer to a buffer containing the name of the remote process to connect with. +The name is used as the match parameter to the p_pidfind service on the remote machine. If that process +does not exist or does not have an opened syssncp channel the request will fail with the =_FILE_NxIsT +completion status. The data space pointed at is assumed to remain valid until the completion of the +P_FCONNECT request. + + +10-4 + + +10 NCP AND LINK + + +The plen parameter points to a word containing the length of the buffer at pname including the zero +terminator. The data space pointed at is not required to remain valid until the completion of the +P_FCONNECT request. + + +The p_Fconnect request will typically take a significant length of time and as such should be called +asynchronously in a quality system. + + +The p_FconnectT request may be cancelled by using the p_FcanceEt service, the original request will be +completed with r_FILE_CANCEL completion status and a signal generated. + + +How the remote process came to be running in the first place is of no concern to the syssncp process, it is +however of great concern to an application writer. + + +Three primary methods are available to get the remote process running: +e Inturnkey systems the remote process may be automatically loaded by the system initialisation. + + +e The user may be prompted to run the remote process from the command shell or system +applications. + + +e An application can request that the Linx process run the remote process on its behalf. +The latter of these three methods is the most general and is best explained by an example as given below. + + +The completion status is written to *pstat by an asynchronous request and returned by a synchronous +request. The status is zero if the service completed successfully, otherwise it is a negative error number. + + +Errors include: + + +E_FILE_NXIST the named process does not have a channel open on the remote syssncp. + +E_FILE_DISC the link is disconnected, there is no data path available to talk to the remote +SYSSNCP. + +E_FILE_LINE the link was disconnected whilst attempting to send data to the remote +SYSSNCP. + +E_FILE_RETRAN the retransmission threshold was reached because the link has been +disconnected. + +Example + + +Simple connection to a currently running remote process: + + +if ('!p_open(&pNcp, "NCP:",-1) ) +{ +len=8; /* incl zero terminator */ +if (!p_iow(pNcp, P_FCONNECT, "RPROC.*", &len) ) +{ + + +p_iow(pNcp, P_FDISCONNECT) ; +} + +p_close (pNcp) ; + +} + + +Connection to a remote process that is not currently running: + + +if ((linkPid=p_pidfind("LINK.*") ) <0) +p_exit (1); +p_scpy (&bb[0],"RPROC.IMG"); /* name only, no paths */ +p=(&bb[0]); +if (p_msendreceivew (linkPid, LNKMSG_LOADREMOTE, &p) <0) +p_exit (1); +len=p_slen(&bb[0])+1; /* full process name here now */ +if (!p_iow(pNcp, P_FCONNECT, &bb[0], &len) ) +{ + + +p_iow(pNcp, P_FDISCONNECT) ; +} + + +10-5 + + +I/O DEVICES REFERENCE + + +P_FDISCONNECT Disconnect from the remote process + + +INT p_iow(VOID *pNcp, P_FDISCONNECT) ; + + +Requests that the current connection to a remote process be broken. An application may use the channel to +connect to the same remote process or a different remote process if required. + + +Any outstanding P_FREAD or P_FWRITE requests will be completed with the E_FILE_CANCEL completion +status and a signal generated. + + +A P_FDISCONNECT request is harmless if no connection has been established or the current connection is +temporarily disconnected. + + +The p_FDISCONNECT request cannot fail and returns zero. + + +P_ FREAD Read data from the remote process + + +VOID p_ioc(VOID *pNcp, P_FREAD, WORD *pstat, UBYTE *buf, UWORD *plen); +INT p_iow(VOID *pNcp, P_FREAD, UBYTE *buf, UWORD *plen); + + +Requests that the next 'message' sent by the remote process be placed in the buffer provided, the length of +which be written to *plen. + + +A ‘message’ is the data sent by the remote application process in a P_FWRITE request. The contents of the +message and its format are entirely determined by the application using the ncp: channel. + + +The buffer provided must be large enough to hold the largest message that can be sent by the remote +application at this point in time (it does not necessarily follow that this is the largest possible message that +can be sent). The syssncp process does not check that the buffer provided is large enough, it simply writes +the message into the buffer. If the buffer is not large enough then other data will invaribly become +corrupted. + + +The data space pointed at by both the buf and plen parameters must be preserved until the P_FREAD +request completes. + + +The p_FREAD request will typically take a significant length of time and as such should be called +asynchronously in a quality system. + + +The p_FREAD request may be cancelled by using the P_FcaNcEt service, the original request will be +completed with E_FILE_CANCEL completion status and a signal generated. + + +A channel connection does not have to exist for a process to queue a P_FREAD request on the channel. In a +typical client-server application the client would run the remote server process which would open an NcP: +channel and queue a P_FREAD request. The client would queue a P_FCONNECT request and when complete +send the server any messages as required using the P_FWRITE service. + + +The calling process will be panicked if a p_FREAD request is currently outstanding or if pNcp is not a valid +channel handle. + + +The completion status is written to *pstat by an asynchronous request and returned by a synchronous +request. The status is zero if the service completed successfully, otherwise it is a negative error number. + + +Errors include: + + +E_FILE_LINE the physical link has failed. This is typically caused by the remote machine +or switching off or the pack doors being opened. The application process if a +E_FILE_RETRAN server Can re-queue a P_FREAD request awaiting the next message. Typically + + +the server should preserve the current state awaiting the next request. A client +would typically report the error and await user input before retrying the +operation. + + +E_FILE_DISC the channel has become disconnected because the remote application process +has terminated (either normally or abnormally). The application should tidy up +any resources and terminate. + + +E_GEN_RECEIVER the remote syss$NcpP process is terminating or a new one has attempted to +connect to the local syssncp process. The application should tidy up any +resources and terminate. + + +Example + + +See the client-server example at the end of this chapter. + + +10 - 6 + + +10 NCP AND LINK + + +P_FWRITE Write data to the remote process + + +VOID p_ioc(VOID *pNcp, P_FWRITE, WORD *pstat, UBYTE *buf, UWORD *plen); +INT p_iow(VOID *pNcp, P_FWRITE, UBYTE *buf, UWORD *plen)j; + + +Requests that the 'message' contained in the buffer of length *pien be sent to the connected process. +The data space pointed to by buf must be preserved until the p_rwriTE request completes. + + +The syssncp process contains a flow control mechanism such that if a process sends data to a connected +process faster than it can handle it, backwards pressure is applied to the sending process by the local +syssncp process. This mechanism is transparent to both the sender and receiver of the message. This flow +control is such that a sending process may send data as fast as it likes without the receiver ever being +swamped. + + +The amount of data that can be sent in one message is only restricted to the size of the sending processes +data space (64K less the stack, static variables and other allocated cells) however, the receiving process +must have a buffer as large as the largest message that can be sent. + + +A channel must be connected to a remote channel before a p_FwritTE request is made, if not the request +will complete with z_r1LE_p1sc completion status. + + +When the p_FwRITE request completes sucessfully this indicates that the remote process to which the +message has been sent has received that message. It does not indicate that the remote process has +sucessfully processed that message. + + +The p_FrwrRITE request will typically take a significant length of time and as such should be called +asynchronously in a quality system. + + +The p_FwrITE request may be cancelled by using the p_FcanceEt service, the original request will be +completed with &_FILE_CANCEL completion status and a signal generated. + + +The calling process will be panicked if a p_rwRitE request is currently outstanding or if pNcp is not a valid +channel handle. + + +The completion status is written to *pstat by an asynchronous request and returned by a synchronous +request. The status is zero if the service completed successfully, otherwise it is a negative error number. + + +Errors include £_FILE_LINE, E_FILE_RETRAN, E_FILE_DISsc and E_GEN_RECEIVER, all of which have the +same meaning as for the p_rREAD service. + + +Example + + +See the client-server example at the end of this chapter. + + +P_FCANCEL Cancel any outstanding request +INT p_iow(VOID *pNcp, P_FCANCEL) + + +Requests that any outstanding requests be cancelled, the outstanding requests will complete with the +E_FILE_CANCEL completion status and a signal be generated. It is indeterminate as to how much of the +message being sent to the remote process (using P_FWRITE) has actually been sent. + + +The p_rcancex request should typically only be used to cancel requests immediatly before the application +terminates. + + +The p_FcancEL request cannot fail and returns zero. + + +P_FRSUPER Read supervisory information +INT p_iow(VOID *pNcp, P_FRSUPER, NCLINK_INFO *pinfo, UWORD *plen); + +This function should only be called by a process that replaces the L1nxK process. + +Requests that the next state change be written back to the supplied buffer. + + +One process in the system is responsible for receiving the state change messages and responding to them. +In the supplied system this is the tnx process. In order for the process receiving the state change +messages to ensure that it does not miss any of the messages (and cause potential system deadlock) it +should have a process priority higher than that of the syssncp process. A priority of OxBO is adequate. + + +10-7 + + +I/O DEVICES REFERENCE + + +A connection does not have to exist (and infact should not exist before the first request is made) for this +request to be queued sucessfully. + + +Some state changes are purely informational and can be used as such as required, others require some +action before the syssNncp process can continue. The action may be hard coded into the LINK process +(typically the non user interface versions) or prompt the user for a solution to the new state. + + +The following informational state changes are reported: + + +PHYS_PHYS_LINK_ESTABLISHED, a physical link has been sucessfully established. The L1nx +process on the Series 3 and HC ignores this message. + + +PHYS_WAITING_FOR_CALL, the physical layer is waiting for an incoming call from the modem +driver in order to obtain a physical connection. The L1nx process on the Series 3 cannot receive +this status message as there is no modem driver available. On an HC the message is ignored. + + +PHYS_DIALLING_NUMBER, the physical layer is currently dialing a phone number in order to obtain +a physical connection. The phone number that is being dialled is in the 'phoneno' field of the +Dvrs struct. The LINK process on the Series 3 cannot receive this status message as there is no +modem driver available. On an HC the message is ignored. + + +PHYS_CONFIGURING_MODEM, the physical layer is currently waiting for the modem driver to finish +sending modem configuration commands. The Linx process on the Series 3 cannot receive this +status message as there is no modem driver available. On an HC the message is ignored. + + +PHYS_NCP_LINK_ESTAB_OK, a connnection to a remote sys$ncp process has been established or re +established if the physical or logical connections have previously failed. The L1Nx process on the +Series 3 and HC ignores this message. The connection details are contained in the pvrs struct. + + +PHYS_NCP_LINK_ESTAB_NEW_NCP, a connection to a remote sys$ncp process has been established, +however the remote sys$ncp is different to the one we were connected to earlier. The connection +details, eg port and baud rate are contained in the pvrs struct. The LINK process on the Series 3 +and HC should respond by sending a NCLINK_CTRL_NEW_NCP_OK response. + + +The following error state changes are reported, they all require some action, the response is sent back to +the syssncp process via the P_FINQ service. + + +10-8 + + +PHYS_NCP_LINK_ESTAB_INVALID_VER, the remote sys$ncp is version 1.0. We cannot continue +with the session since the operation of the two sys$ncp's is significantly different. There are very +few version 1.0 syssncp's. The local end should terminate by responding with the appropriate +p_FINQ message. + + +PHYS_NCP_LINK_END, the remote syssncp is terminating, the local end should either prompt for +continuation or termination and respond to the sys$ncpP with the appropriate p_FINQ message. + + +PHYS_SERCONFIG_FAILED, the physical layer has reported that the serial port the user has +specified does not exist. The local end should report the error to the user and typically terminate +by sending the appropriate p_FINQ message. + + +PHYS_CHARS_FAILED, the physical layer has reported that an attempt to set the serial +characteristics failed, presmably because the serial driver does not support the specified +configuration. The local end should report the error to the user and typically terminate by +sending the appropriate p_FINQ message. + + +PHYS_LINK_FAILED, the logical link layer driver has reported that the link has failed. If the +physical connection was over a modem link or a previous logical link connection has been made +the local end should ask the user for confirmation to re-try for a physical connection. If no link +has ever been established (no pHys_NCP_LINK_ESTAB_OK status message been received) the local +end should simply ask the syssNcp process to retry for a link. + + +PHYS_CONNECT_FAILED, the waiting for a physical connection has failed, typically this is caused +by a modem being removed from the serial port whilst waiting for an incoming call to arrive. +The local end should either exit or request the physical action be re-tried by sending the +appropriate P_FINQ response. + + +10 NCP AND LINK + + +@ PHYS_INIT_FAILED, the physical layer has reported that the initialisation of the modem failed, +presumably because of an invalid modem configuration string. The local end should either exit +or request the physical action be re-tried by sending the appropriate p_r1No response. + + +@ PHYS_DIAL_FAILED, the physical layer has reported that dialling the phone number failed. The +local end should either exit or request the physical action be re-tried by sending the appropriate +P_FINQ response. + + +@ PHYS_MDMCONFIG_FAILED, the physical layer has reported that sending additional modem +configuration strings has failed. The local end should either exit or request the physical action be +re-tried by sending the appropriate p_F1Nno response. + + +The p_FRsupPER request will typically take a significant length of time. In a high quality system it should +be called asynchronously. + + +The p_FRSUPER request may be cancelled by using the p_rcancet service. The original request will be +completed with k_FILE_CANCEL completion status and a signal generated. + + +All syssncp defines and structure definitions can be found in sys$ncp.h. + + +The calling process will be panicked if a p_rFRsuPER request is currently outstanding or if pNcp is not a +valid channel handle. + + +The p_rRsuPER request cannot fail and returns zero. + + +P_FINQ Respond to a supervisory message +INT p_iow(VOID *pNcp, P_FINQ, INT response, DVRS *pdvr) ; +This function should only be called by a process that replaces the LINK process. + + +In response to a P_FRSUPER event the state change process handler (typically L1nk) must send back a +response. + + +A response message may be one of the following: + + +@ NCLINK_CTRL_RETRY, to retry the action that failed. This would typically retry for a link +connection or a physical connection depending on which event occured earlier. The pdvr +parameter is irrelevant for this message type. + + +@ NCLINK_CTRL_EXIT, to request that all channels be closed, the local syssncp process inform the +remote syssncp process that it is about to terminate and actually break the physical and logical +connections. The pavr parameter is irrelevant for this message type. + + +@ NCLINK_CTRL_NEW_NCP_oK, to inform the syssncp process that the different remote syssncp +process is acceptable and that the controlling process (L1nx) has sorted out any channels that it is +responsible for (the remote filing system channels). The pdvr parameter is irrelevant for this +message type. + + +At any point in time a proces may inform the syssncp process that it should restart with new parameters +by sending it the following message + + +¢ NCLINK_CTRL_NEW_CONFIG, restart the syssncp process with the new configuaration as specified +in pavr. If any of the parameters are illegal or the request fails then a subsequent P_FRSUPER +request will received the failure state. + + +The p_ring request cannot fail and returns zero. + + +All syssncp defines and structure definitions can be found in sys$ncp.h. + + +10-9 + + +1/0 DEVICES REFERENCE + + +P_FSENSE Sense the current channel activity + + +INT p_iow(VOID *pNcp, P_FSENSE, NCLINK_SREC *prec); + + +If an application wishes to determine the channel activity occuring within the syssNncpP process the +statistical information contained in an NCLINK_sREC structure can be obtained. + + +The prec parameter is assumed to point to an aray of 8 NCLINK_SREC structures, one for each of the +possible channels that the syssncp process can handle. Channel 0 is used by the syssncp process and the +information in that array entry should be discarded. + + +All syssncp defines and structure definitions can be found in sys$ncp.h. + + +The P_FSENSE request cannot fail and returns zero. + + +P_FSTOP Request the SYS$NCP terminate + + +INT p_iow(VOID *pNcp, P_FSTOP); + + +If an application process wishes to terminate the syssncp process and all connected client server +applications it should use the P_FsTop service. + + +When the syssncp process receives this request it will fail all outstanding requests on all open channels +immediately with a E_FILE_D1Isc completion status then tell the remote syssncp process that it is about to +terminate. Any further requests made by any application proces on any channel will fail with the +E_GEN_NOPROC completion status. + + +The syssncp process will not terminate until all channels have been closed by all the application +processes. + + +Server processes will typically always have an outstanding P_FREAD request or be processing a request the +result of which is required to be sent back to the client. In both cases it will make a request on the ncP: +channel that will fail. If the error handling is as suggested in the P_rFREAD and P_FWRITE error section then +the server will terminate gracefully. + + +Client processes on the other hand tend not to make any requests until user input requires them to, hence +typically do not have any outstanding or make any requests on the ncp: channel. + + +In a high quality system the client should close its cp: channel as soon as it is informed that the syssncp +process is about to terminate. + + +If the client process is the one that makes the p_rstop request is not too much of a problem for it to know +to close its channel. + + +If the client does not make the request it will not know to close its channel. A solution to this is for a +client process to always have a P_FREAD request outstanding even though it may never read any data from +the remote process. If it does read data from the remote process (presumably after writing a request to the +remote process to make the data available) then it can still use the outstanding p_rReap to read this data. + + +nn EEE +Example + + +This example is for a client server application which allows a process to be run on a remote machine. The +full path name is specified. The connection establishment and data transfer phases are illustrated in as +simple a manner as is possible. For clarity the code does not implement the full error handling required in +a working application. + + +10 - 10 + + +The client side + + +GLDEF_C VOID main(VOID) +{ +WORD len,nlen, pid; +VOID *pNcp; +TEXT *p; +TEXT srvName [20]; +TEXT cmd[80] + + +if (pid=p_pidfind("LINK.*") ) <0) +p_exit (1); +if (p_open(&pNcp, "NCP:",-1) ) +p_exit (1); +p_scpy (&srvName[0],"EXECSRV") ; +p=(&srvName[0]); +if (p_msendreceivew (pid, LNKMSG_LOADREMOTE, &p) <0) +p_exit (1); +len=p_get1l("Name and command line", &cmd[0],80); +if (len) +{ +nlen=p_slen(&srvName[0])+1; +if (!p_iow(pNcp, P_FCONNECT, &ésrvName[0], &nlen) ) +{ +if (!p_iow(pNcp, P_FWRITE, &cmd[0], &len) ) +{ +if (!p_iow(pNcp, P_FREAD, &cmd[0], &len) ) +{ +pid=cmd[0]+(cmd[1]<<8); +if (pid>0) +p_printf("Remote pid %x",pid); +else +p_puts ("No such process"); + + +} +p_iow (pNcp, P_FDISCONNECT) ; +} +} +p_close(pNcp) ; +p_exit (0); +} + + +The server side + + +GLDEF_C VOID main(VOID) +{ +WORD len, pid; +VOID *pNcp; +TEXT *pname, *pcmd; +TEXT cmd[80] + + +if (p_open(&pNcp, "NCP:",-1) ) +p_exit (1); +if (!p_iow(pNcp,P_FREAD, &cmd[0], &len) ) +{ +pname=p_skipwh (&cmd[0]); +pcemd=p_skipch (pname) ; +if (*pcmd) +{ +*pcmd++=0; /* zero terminate proc name */ +pemd=p_skipch (pcmd) ; +} + + +pid=p_exec (pname, pcmd, p_slen(pcmd) ) ; + + +cmd [0]=pid; +cmd[1]=pid>>8; /* return pid or error */ +len=2; + + +p_iow(pNcp, P_FWRITE, &cmd[0],é&len) ; +} + +p_close(pNcp); + +p_exit (0); + +} + + +10 NCP AND LINK + + +10-11 + + +CHAPTER 11 + + +CRADLE AND DOCKING STATION + + +Introduction + + +This chapter refers to two units: the HC cradle and the docking station for HC and Workabout computers. +In this document the term ‘Cradle’ refers to the HC cradle, (which connects to the side pins of older HC +models). The term ‘Docking Station’ refers both to the HC docking station, (which connects to an HC LIF +interface fitted to the bottom of the HC), and to the Workabout docking station. The term ‘computer’ +refers to an HC or Workabout. + + +This chapter describes the services which are supported by the Cradle/Docking Station device driver +(crD:). The Fast Charger services provided by the Docking Station are described in the Fast Charger +chapter. + + +The Cradle/Docking Station device driver (cRD:) reports changes of state when a computer is inserted or +removed from the Cradle or Docking Station. It is supplied to allow a program to perform specific +operations automatically when the computer is inserted into the Cradle or Docking Station and to ‘tidy up' +when the computer is removed. + + +Notes: + + +1. the Cradle/Docking Station device does not have to be open to use the Cradle/Docking +Station expansion port. The operating system will automatically stop and start active devices +in the cradle. + + +2. the "Cradle/Docking Station in" signal is generated when the computer first touches the +connector, but software running on the computer must wait until the connection is fully +home before attempting to access any device in the Cradle/Docking Station. + + +If a user inserts the computer into the cradle slowly, EPOC may not recognise that the +Cradle/Docking Station expansion port is present. It such a case it may be prudent to open +and close an expansion device using the Cradle/Docking Station device as an indicator of the +connection state. If an attempt to open a device when the computer is inserted into the +Cradle/Docking Station fails, a retry can be attempted after a delay of, say, two seconds. + + +Cradle/Docking Station services + + +p_open(CRD:) Open the device +INT p_open(VOID **ppcb,"CRD:",-1); + + +Open a channel to the current Cradle or Docking Station device, as set by any previous call to the P_FsET +service. If there has been no previous call to this service, or if the machine has just been reset, it will open +a channel to the Cradle/Docking Station. + + +Returns zero if the device is opened successfully, otherwise a negative error. Errors include: + + +E_GEN_NOMEMORY failed to allocate memory for control block +E_FILE_LOCKED or port is already open or +E_GEN_INUSE in use + + +11-1 + + +I/O DEVICES REFERENCE + + +p_close Close the channel + + +INT p_close(VOID *pcb) + + +Close the channel. Returns zero. + + +P_FREAD Read from the device + + +VOID p_ioc(VOID *pcb, P_FREAD, WORD *pstat, UWORD *pcstate); +INT p_iow(VOID *pcb, P_FREAD, UWORD *pcstate) ; + + +Read a change of state from the Cradle/Docking Station, writing the new state to *pcstate. + + +When called for the first time after opening the device it will complete immediately, reporting the current +state. Thereafter it will complete whenever the computer is removed from or inserted into the +Cradle/Docking Station. + + +On completion *pcstate is TRUE if the computer is currently in the Cradle/Docking Station and Fats if +the computer is out of the Cradle/Docking Station. + + +Panics if a P_FREAD request is currently outstanding, or if pcb is not a valid channel handle. + + +The completion status code is returned by the synchronous p_iow(P_FREAD) and written to *pstat by +asynchronous calls. The completion status code is zero if the P_FREAD request completed successfully, or +E_FILE_CANCEL if the read was cancelled. + + +P_FCANCEL Cancel a read + + +INT p_iow(VOID *pcb,P_FCANCEL) ; + + +Cancel any outstanding P_FREAD request. Performing a cancel is harmless if no read request is +outstanding. + + +Returns zero. + + +P_FSET Set the device type + + +INT p_iow(VOID *pcb,P_FSET,WORD *pctype) ; + + +If *pctype 1s TRUE, sets all future cRD: operations to apply to the Docking Station and all accesses to port +C and related ports to apply to any expansion fitted into the Docking Station. It will also check that a valid +Docking Station expansion is fitted to the bottom of the HC. Since this call requires use of the high speed +serial channel on the bottom if the HC and affects all port C devices, it will fail with E_cEN_1nusE if +anything is open on port B or port C. + + +If *pctype is FALSE, sets all future cRD: operations to apply to the Cradle and all accesses to port C and +related ports to apply to any expansion fitted into the Cradle. Since this call affects all port C devices, it +will fail with E_cEN_InusE if anything is open on port C. + + +Note: This setting will remain even after the crp: device is closed. It will remain in force until it is +changed by another call to p_FsEt, or until the machine is reset. It is envisaged that one call will be made +to this function when an application first runs, and that this will set the device type for the life of the +application. + + +E_GEN_NOMEMORY failed to allocate memory for the control block +E_GEN_INUSE the port is in use (e.g. TT Y:B is open when trying to set to the Docking Station, +or TTY:C in the Docking Station is open when trying to set to the Cradle) + + +P_FSENSE Sense the device type + + +INT p_iow(VOID *pcb,P_FSENSE,WORD *pctype) ; + + +The current device type is returned in *pctype. If set to TRUE then the Docking Station is the current type, +if set to FALSE then the Cradle is the current type. + + +Note: This service does not check if the hardware is actually present (e.g. if an HC LIF interface is fitted) +and therefore may be called at any time. To check if the hardware is present, use the P_FSET service. + + +Returns zero. + + +11-2 + + +CHAPTER 12 + + +HC MAGNETIC CARD READER + + +Introduction + + +The HC Magnetic Card Reader (vcr: ) device driver is built into the HC's operating system. + + +The MCR interface may be fitted to the top (wcr:a) or bottom (Mcr:8B) of the HC, or in the cradle (wcr:c). + + +MCR services + + +p_open(MCR:) Open the MCR device +INT p_open(VOID **ppcb, "MCR:A",-1); +Open a channel to a Magnetic Card Reader device. + + +Returns zero if the device was opened successfully, otherwise a negative error. Errors include: + + +E_GEN_NOMEMORY failed to allocate memory for control block + +E_FILE_DEVICE no interface found in specified slot + +E_FILE_NAME invalid device name + +E_FILE_LOCKED or port is already open or + +E_GEN_INUSE in use + +p_close Close the channel + + +INT p_close(VOID *pcb) +Close the Magnetic Card Reader device channel. + + +Returns zero. + + +P_FREAD Read from the MCR device + + +VOID p_ioc(VOID *pcb, P_FREAD, WORD *pstat, UBYTE *bufl, UBYTE *buf2); +INT p_iow(VOID *pcb, P_FREAD, UBYTE *bufl, UBYTE *buf2); + + +Read either or both tracks of a card. Track 1 is read into *bufi and track 2 into *buf2, where each buffer +must be at least 256 bytes long. The data in each buffer is written as leading byte count ASCII text. The +leading byte count is zero if the read was not successful. + + +Either buf1 or buf2 may be passed as NULL to disable reading of the relevant track. For example, to read +only track 2: + + +UWORD stat; +UBYTE buf[256]; + + +p_ioc(pcb, P_FREAD, &stat, NULL, &buf[0]); +p_waitstat (&stat); + + +I/O DEVICES REFERENCE + + +Track 1 usually contains alphanumeric data (card holder's name and account number) while track 2 +contains numeric data only. The most common MCRs read only track 2. + + +Panics if a P_FREAD request is currently outstanding, or if pcb is not a valid channel handle. + + +The completion status code is returned by the synchronous p_iow(P_FREAD) and written to *pstat by +asynchronous calls. The completion status code is zero if the P_FREAD request completed successfully, or +one of the following negative error numbers: + + +E_FILE_READ an error was detected decoding the data +E_GEN_OVER device driver buffer overflow +E_FILE_CANCEL the read was cancelled + + +P_FCANCEL Cancel a read + + +INT p_iow(VOID *pcb,P_FCANCEL) ; + + +Cancel any outstanding P_FREAD request. Performing a cancel is harmless if no read request is +outstanding. + + +Returns zero. + + +P_FSET Set the pull-up resistors +VOID p_iow(VOID *pcb, P_FSET, UWORD *mask); + +This service is only available in EPOC versions 2.32 or later. + +Set the programmable pull-up/pull-down resistors on the five MCR reader lines. + + +The MCR device contains programmable 100k ohm pull-up/pull-down resistors on each of the reader +lines DATA1, CLK1, DATA2, CLK2 and cus. By default when the MCR device is opened these are set to pull +down. + + +The resistor on each line is controlled by a bit in «mask. If the bit is set to 1 the resistor is programmed to +pull-up, if the bit is cleared to 0 the resistor is programmed to pull-down. + + +The bits which control each line should be defined in the application source file, according to the +following table: + + +Symbol Value (binary) Line + +M_DATA1PU 00000001 Track 1 data +M_CLK1PU 00000010 Track 1 clock +M_DATA2PU 00000100 Track 2 data +M_CLK2PU 00001000 Track 2 clock +M_CLSPU 00010000 Card present signal + + +All other bits are ignored. + + +12-2 + + +CHAPTER 13 + + +HC BAR CODE READER + + +Hardware Description + + +The Bar code reader interface module + + +The bar code interface module is a grey plastic moulding which is designed to fit into one of the slots at +either end of the HC. To insert the module you will need to open the rear door of the HC, and unlock one +of the interface slots to remove the existing module or blank. Place the bar code reader module into the +slot and gently ease it home making sure it fits snugly. Once this is done you will need to lock the module +in place by moving the black switch into the locked position. After this close the door again otherwise the +HC will refuse to switch on. + + +The interface may be fitted to the top (BaR:a) or bottom (BaR:8B) of the HC. + +The bar code reader wand. + +The bar code wand is supplied with a locking mini-din plug which fits into the mini-din socket in the top +of the bar code module. Simply lining up the grooves and pushing the plug home will lock the plug into +place. The locking plug type is used so that if the HC is accidentally suspended by the bar code reader +cable, the machine will not come off the connector. To remove the wand from the module grip the plastic + + +moulding which surrounds the plug and pull gently. The plastic cover will slide back slightly releasing its +grip on the module. From there the plug should easily slide out. + + +[Me a Sees +Device drivers + + +At the time of writing, there is no bar code device driver or decoding software built into the HC's +operating system. Bar code readers are supported by separate device driver files which must be loaded by +the application code, by means of either the PLIB p_toadida function or the OPL DevLoadLpp call. + + +There are currently five combined decoder/device drivers: + + +BAREAN . LDD supports EAN8, EAN13, UPC and UPCE decoding +BARC39.LDD supports CODE 39 decoding + +BARITF.LDD supports Interleaved 2 of 5 (ITF) decoding +BAR128.LDD supports CODE 128 decoding + +BARMPLES . LDD supports Modified Plessey decoding + +BARRAW. LDD supports raw decoding + + +None of the currently available drivers supports auto discrimination of bar codes. + + +Installing the LDD optional component of the SDK copies these files into the \sibosdkNlib directory. The +required LDD must be copied into the appropriate directory on the HC using MCLINK. + + +A device driver may be loaded, for example, by: +p_loadldd("BARC39.LDD") ; + +To remove the device (and free the memory it uses) you should call +p_devdel ("BAR") ; + +or the equivalent OPL DevDelete call. + + +The bar code device driver software is updated from time to time; update information is available from +Psion Support. + + +13-1 + + +1/0 DEVICES REFERENCE + + +SSS ee | +Bar code driver services + + +p_open(BAR:) Open the bar code device +INT p_open(VOID **ppcb, "BAR:",-1); +Open a channel to a bar code device by means of a previously loaded bar code device driver. + + +Returns zero if the device was opened successfully, otherwise a negative error. Errors include: + + +E_GEN_NOMEMORY failed to allocate memory for control block +E_FILE_DEVICE no interface found in specified slot +E_FILE_NAME invalid device name + +E_FILE_LOCKED or port is already open or in use + + +E_GEN_INUSE + + +p_close Close the channel +INT p_close(VOID *pcb) +Close the bar code device channel. + + +Returns zero. + + +P_FREAD Read from the MCR device + + +VOID p_ioc(VOID *pcb, P_FREAD, WORD *pstat, UBYTE *buf); +INT p_iow(VOID *pcb, P_FREAD, UBYTE *buf) ; + + +Read a bar code into *buf, which must be at least 256 bytes long. The data is written as leading byte count +ASCII text. The leading byte count is zero if the read was not successful. The first character of the text +indicates the type of the bar code: + + +EAN8 or EAN13 +UPC + +Code 39 + +ITF + +Code 128 +Modified Plessey +UPCE + + +az 7t0aNwS + + +The remainder of the text is the decoded bar code data. +Panics if a P_FREAD request is currently outstanding, or if pcb is not a valid channel handle. + + +The completion status code is returned by the synchronous p_iow(P_FREAD) and written to *pstat by +asynchronous calls. It is zero if the P_FREAD request completed successfully, or one of the following +negative error numbers: + + +E_GEN_OVER device driver buffer overflow +E_FILE_CANCEL the read was cancelled + + +P_FCANCEL Cancel a read + + +INT p_iow(VOID *pcb,P_FCANCEL) ; + + +Cancel any outstanding p_FREAD request. Performing a cancel is harmless if no read request is +outstanding. + + +Returns zero. + + +13-2 + + +CHAPTER 14 + + +HC INTELLIGENT BAR CODE READER/RS232 PORT + + +See the HC Bar Code Reader chapter, for the description of the device driver for an alternative HC bar +code reader expansion module. + + +RS232/intelligent bar code reader module + + +The RS232/intelligent bar code reader is an expansion module which contains an intelligent bar decoding +micro controller. The module is fully compatible with the HC, HC-DOS and RWAN series of computers. + + +The expansion module provides one serial port connection to the HC computer, and this port is shared +between the two interfaces. The serial port may be configured by software to open a channel either to the +PC-AT style RS232 interface, or to the intelligent bar code scanner interface; both interfaces cannot be +used simultaneously. This module has been designed to allow an HC computer to read bar code labels, +using a wand attached to the bar code reader interface. Data collected from bar code scans may then be +transferred to an external computer (such as an IBM PC-AT compatible machine) from the HC computer, +via the RS232 serial port interface. + + +The bar code reader interface contains an intelligent micro controller that will automatically read and +decode data from a bar code wand (or a wand emulator) connected to the expansion module. The unit can +read and automatically discriminate between the following bar code formats: + + +e EAN/JAN 8 +e EAN/JAN 13 +e UPCA + +e UPCE + +e Codabar + +© Code 128 + + +e Interleaved 2 of 5 +e Code 39 (standard or extended) + + +The interface may be programmed to verify scanned data against check digits/characters on bar code +labels and to read, or to ignore any supplement digits in a bar code, as required. + + +The micro controller will transmit bar code data to the HC computer as an ASCII string of characters: + +i.e. each digit or character read from a bar code label will be transmitted to the HC computer as one +ASCII-coded character. The order of the bar code data will always be transmitted to the HC computer in +the correct order (i.e. reading from left to right across the bar code label), irrespective of the direction that +the bar code label was actually scanned. By default, the end of each complete bar code scan will be marked +by a single ASCII carriage return character. + + +The micro controller inside the expansion module is programmable. It may be instructed to decode only a +subset of the bar code symbologies that it recognises, to transmit check digits and check characters with +each bar code scan, read or ignore supplement digits, as well as many other bar code symbology-specific +options. The micro controller can also be programmed to mark the end of each scan with a customised +ASCT terminating string of up to four characters, in place of the default carriage return termination +character. This document contains detailed information on how to program the micro controller from + +C, and from OPL programs. + + +14-1 + + +I/O DEVICES REFERENCE + + +You may connect this expansion module either to the top slot, or to the bottom slot of an HC computer. + +When the expansion module has been plugged into the top slot on the computer, the RS232 port can be + +accessed by opening TTy:a, and the bar code interface may be accessed by opening TTy:p; if the module +has been connected to the bottom slot on the computer, then the RS232 port can be accessed by opening +TTy:B and the bar code interface may be accessed by opening TTyY:E. + + +The bar code interface communicates to the host computer at the following (standard HC Comms) +settings: + + +e Baud +e data bits +e — stop bit + + +e Xon/Xoff handshaking (No hardware handshaking) + + +The expansion module possesses two, male 9-pin D-type connectors: the RS232 connector is a standard +PC-AT type connector!; the bar code interface connector is a standard click-lock D-type connector for a +bar code wand. + + +To reduce power consumption, the bar code interface and the RS232 port interface are only powered up +when the channel to the serial port is open. + + +The RS232 serial port interface + + +The RS232 interface provides standard RS232 level signals to a 9-pin D-type male connector. The +connector is PC-AT compatible, although pin 9 (normally the Rr pin) is not driven by the interface. When +the interface unit has been connected to the top slot of the HC, then the RS232 port may be accessed by +opening the try:a device. If the unit has been connected to the bottom slot of the HC, then the RS232 port +may be accessed by opening TTY:B. + + +The table below displays the pinout for the PC-AT type RS232 serial port. + + +DCD input + +RX input + +TX output + +DTR output + +Ground (ov) + +DSR input + +RTS output + +CTS input + +Optional vsup connection + + +OMANDNKRWNKH + + +Power consumption + + +The RS232 port is only powered up when the appropriate channel is open. The interface will draw +approximately 10mA, plus the current drawn by the device connected to the other end of the RS232 cable. +If the remote device is a PC-AT type computer, then the total current drawn by the interface will typically +be 20mA, although this figure may vary from one PC to another. + + +When the HC computer is also powering an external device through the RS232 port, then that external +device should not draw more than: + + +e =250mA from the HC if no other expansion modules are attached to the HC, or +e 200mA from the HC if another expansion module is attached to the HC and is powered up. + + +Please note also that external device will draw current from the HC computer even when the HC computer +has been switched off. Consequently, the external device ought to have its own on/off switch, and to avoid +excessive battery drain, the external device should be switched off when it is not in use. + + +'The ringing indicator (Rt) pin has not been implemented on the RS232 port. It may, however, be +connected permanently to the HC computer vsup power supply rail, if required. This action will allow an +external unit such as an infrared laser scanner to have power supplied to it through the RI connection in +the serial link cable, from the HC computer. + + +14-2 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +Powering the HC from an external power source + + +The HC computer may be powered by an external source through pin 9 of the RS232 interface. To do this, a +2-pin header on the RS232/bar code interface expansion module PCB should be shorted together with a jumper. +(The 2-pin header is located at the extreme bottom left-hand side of the PCB, if the expansion module is oriented +so that the electrical components are uppermost and the two D-type connectors face upwards.) + + +This alteration will route the vsup main power supply rail from pin 9 of the serial port to the HC +computer. The external vsup power supply should be in the range of 7-10v. The external power supply +should be diode-isolated from the HC to prevent any power drain from the HC computer. + + +Please note that the main battery inside the HC computer will not be charged if power is supplied to the +HC from the RS232 port. + + +DSR auto wakeup switch + + +If required, the interface and HC computer may be woken up by an external device whenever the psp pin +of the RS232 link is asserted. To enable this facility, move the PCB switch (located at the bottom left-hand +corner of the circuit board) to the left-hand position. (If you hold the module with the component side of +the PCB facing you and the D-type connectors facing upwards, the switch is located to the bottom left +hand corner of the PCB.) + + +The bar code interface + + +The bar code reader interface contains a Hewlett-Packard HBCR-1610 series bar decoding micro +controller which is capable of reading and discriminating between the following bar code formats: +EAN/JAN 8, EAN/JAN 13, UPC A, UPC E, Codabar, Code 128, Interleaved 2 of 5 and standard or +extended Code 39 bar labels. + + +The interface possesses a 9-pin D-type click-lock male connector which may be attached to many standard +digital wands and wand emulating scanner units. However undecoded laser scanners (HHLC) are not +supported by this interface. + + +When the interface unit has been connected to the top slot of the HC, then the bar code port may be +accessed by opening the rry:p device. If the unit has been connected to the bottom slot of the HC, then the +bar code port may be accessed by opening trv:&. To conserve power, the bar code interface is only +powered up while the serial port is open. + + +The bar code interface communicates to the host computer with the following settings: +e Baud +e data bits, no parity and 1 stop bit +e Parity errors are not ignored + + +These are the default serial port settings for the HC computer. However, in addition, the bar code port +must also be set up so that: + + +e the tmask parameter of the serial port characteristics identifies the last character in the +terminating string for each incoming message, from the bar code interface. The default +terminating string is a single carriage return character: i.e. tmask=2000. + + +e the cts/rts handshaking protocol is disabled, by setting the 1cn_cts flag. + + +Full details are given later in this section, which describe how tmask and 1cN_cts may be set from within +a C or an OPL program. Please note that these two settings are only required to configure the bar code +ports Try:p and rry:& for the bar code interface; they do not apply to the RS232 ports rry:a and Try:B. + + +The table below displays the pinout for the two expansion module ports. + + +DCD input + +Bar data input + +Not connected + +Switched vsup output + +DSR input + +DTR output + +Ground (ov) + +Ground (ov) + +Switched 5v regulated output + + +OMDANANDNHRWNF + + +I/O DEVICES REFERENCE + + +Power consumption + + +External units should not draw more than: +e =250mA from the HC if no other expansion modules are attached to the HC, or +e 200mA from the HC if another expansion module is attached to the HC, and is powered up. + + +The bar code port draws an idle current of 1OmA, and typically 24mA when a scan is in progress. This +figure does not include the additional current drawn by the wand, or scanner, attached to the interface. To +conserve power, the RS232 interface is only powered up while the serial port is open. + + +Powering a bar code wand from the HC + + +The HC computer can supply a 5v ( +5%) regulated supply and a vsup (6-10v) supply to an external bar +code wand, or a wand emulating device (such as an RS232 laser scanner). These two power supplies are +available on pin 9 and pin 4, respectively, on the bar code interface connector. + + +To allow the HC to supply power an external unit a simple adjustment must be made to the expansion +module: a 2-pin header on the PCB of the RS232/bar code interface expansion module must be shorted +together with a jumper. (The 2-pin header is located at the extreme bottom left-hand side of the PCB, if +the expansion module is oriented so that the electrical components are uppermost and the two D-type +connectors are facing upwards.) + + +The two power supply outputs on the bar code interface (and the decoding IC) are switched on only when +the port is open. As a result, the power will be switched off when the HC computer powers down - if it is +left unused for longer than the timeout period. Please note that all of the custom settings programmed into +the bar code interface with escape sequences will be lost when the port is closed, or if the HC auto-powers +down. + + +Please note that the 2-pin header should only be taken if the external unit must be powered by the HC, or +if the HC must be powered by the external device. + + +[eyeee TS +Bar code symbologies + + +The bar code reader interface will transmit data from each bar code scan as a stream of ASCII text data. +Each data stream will be terminated by the default termination string (a carriage return character, 00d). +Alternatively, the interface may be programmed to terminate each stream of scan data with a custom +termination string of up to four characters. + + +Bar code data will always be transmitted to the host computer in the correct order (i.e. from left to right), +irrespective of the direction in which the bar label was originally scanned. Bar code labels containing +supplement digits can only be scanned in the forwards direction (i.e. from left to right); all other bar code +labels may be scanned either forwards or backwards. The interface may be programmed to include, or +strip out, check characters and ID characters in the transmitted data, as desired. The maximum scanning +rate for any bar code format is 30 ips + + +The remainder of this section will now describe each bar code format that may be scanned by the +interface. In each case, the programmable options that are associated with each format will also be +described. + + +Code 128 + + +Code 128 labels contain a variable number of digits, and one check character. There are three types of +Code 128 bar code labels that may be decoded by the bar code interface: code A, code B and code C. Both +Code A and Code B labels may contain a maximum of 31 characters; Code C labels may contain a +maximum of 62 characters. + + +No user-definable options are available to alter Code 128 bar code data. The bar code reader interface will +always check the label data against the check character on the bar code label, but the check character will +never be transmitted as part of the scanned data. + + +14-4 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +Codabar + + +Codabar labels contain one start character, a number of digits and one stop character. Only one user- +definable option exists with Codabar format data: the bar code reader interface may be programmed to +transmit, or to ignore any start and stop characters in the label data. + + +The start and stop characters may be any of the following four upper case characters: 'A', 'B', 'C’, or 'D'. A +start character does not have to be the same as the stop character. + + +The table below illustrates the effect that each Codabar option will have on the output data from the bar +code interface. + + +Start/stop chars Input label data Output data +Transmit A123456B 123456 +Ignore A123456B A123456B + + +Interleaved 2 of 5 + + +An Interleaved 2 of 5 bar code will always contain an even number of digits (including the check digit) +and no characters. It may also contain a number of additional check sum digits also. The maximum +number of digits that may be contained within a label is 32; the minimum number is 2. The interface may +be programmed to read either: + + +e any Interleaved 2 of 5 labels containing any even number of digits within the range of 2 and 32 +digits, +e only Interleaved 2 of 5 labels containing 6 or 14 digits, or + + +e only Interleaved 2 of 5 labels containing a preset, even number of digits. + + +There will always be one check digit at the end of the bar code label. The bar code scanner interface may +be programmed to verify the scanned data against this check digit, and it may also be programmed either +to transmit the check digit as part of the output data string, or to omit the check digit from the output data. + + +In the table below, 123456 represents a bar code scan containing the valid check digit 6 and 123457 +represents a scan that contains the invalid check digit 7. The output generated by the bar code interface is +displayed in the right-hand column. + + +Input data Verify the check Transmit the check digit ? Output data +digit? +23456 No Yes or No 23456 +123457 No Yes or No 23457 +123456 Yes No 2345 +123457 Yes No No output +23456 Yes Yes 23456 +123457 Yes Yes No output +Code 39 + + +A Code 39 bar code label may contain a minimum of one character and a maximum of 32 characters. It +will contain no digits. The bar code reader interface may be programmed to verify the label check +character, and to transmit the check character in the output data message, or strip the check character +from the output data. + + +In the following table, ancx represents a Code 39 label containing the valid check character x, and the +string apcp represents a Code 39 label containing an invalid check character p. + + +14-5 + + +1/0 DEVICES REFERENCE + + +Input label data Verify the check Transmit the check Output data +character? character +ABCD No Yes or No ABCD +ABCX No Yes or No ABCX +ABCD Yes No No output +ABCX Yes No ABC +ABCD Yes Yes No output +ABCX Yes Yes ABCX + + +The user interface may be programmed in Code 39 scans may be converted as character pairs (as defined +by the Code 39 symbology) or alternatively, each character in the scan may be decoded individually. + + +The UPC/EAN bar code formats + + +The UPC/EAN bar code family all contain a fixed number of digits, and all contain one check digit. The +bar code reader interface may be programmed to verify this check digit against the rest of the scanned +data. The interface may also be programmed to transmit the check digit as part of the bar code, or to omit +the check digit from the output data. + + +There twelve variants in the UPC/EAN family of bar codes. Note that JAN 8 labels are equivalent to EAN +8 format labels and JAN 13 labels are equivalent to EAN 13 format labels. + + +UPC E + + +The UPC E bar code label format contains a leading ID character, one number system digit, six data digits +and one check digit. The leading ID character must be an ASCII 'E’. The check digit will be followed by 2 +supplement digits in UPC E + 2 digit labels, and with 5 supplement digits in UPC E + 5 digit labels. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the data +transmitted to the host computer. UPC E bar code label data may also be expanded into UPC A bar code +format automatically by the interface unit - in which case the six existing data digits will be expanded to +ten digits, and the leading ID character will become an ASCII'A'. Refer to the UPC A section in this +chapter for more information about this label format. + + +The following table displays the four different user-definable options available for modifying the output +data from UPC E scans. + + +Transmit ID char Transmit check digit Standard output (UPC E) Expanded output (UPC A) + + +No No dddddd ndddddddddd + +Yes No Endddddd Andddddddddd + +No Yes dddddd nddddddddddc + +Yes Yes Endddddd Anddddddddddc +where + + +gE = an ID character 'E' (0x45) +a =an ID character 'A' (0x41) +d= one data digit + +n = one number system digit + + += one check digit + + +Q + + +a + + += one supplement digit + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +UPC E + 2 digits + + +As its name suggests, the UPC E + 2 bar code label format contains a leading ID character, one number +system digit, six data digits, one check digit and two supplement digits. The leading ID character must be +an ASCIL'E'. UPC E bar code label data may also be expanded into UPC A bar code format automatically +by the interface unit - in which case the six existing data digits will be expanded to ten digits, and the +leading ID character will become an ASCII 'A’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID char Transmit check digit Standard output (UPC E) Expanded output (UPC A) + + +No No ddddddss nddddddddddss + +Yes No Enddddddss Anddddddddddss + +No Yes ddddddss nddddddddddcss + +Yes Yes Enddddddss Anddddddddddcss +where: + + +gE = an ID character 'E' (0x45) +a =an ID character 'A' (0x41) +a = one data digit + +n = one number system digit +c = one check digit + + +s = one supplement digit + + +UPC E + 5 digits + + +As its name suggests, the UPC E + 5 bar code label format contains a leading ID character, one number +system digit, six data digits, one check digit and five supplement digits. The leading ID character must be +an ASCII 'E'. UPC E bar code label data may also be expanded into UPC A bar code format automatically +by the interface unit - in which case the six existing data digits will be expanded to ten digits, and the +leading ID character will become an ASCII 'A’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID char Transmit check digit Standard output (UPC E) Expanded output (UPC A) + + +No No ddddddsssss nddddddddddsssss + +Yes No Enddddddsssss Anddddddddddsssss + +No Yes ddddddsssss nddddddddddesssss + +Yes Yes Enddddddsssss Anddddddddddcsssss +where: + + +gE = an ID character 'E' (0x45) +a=an ID character 'A' (0x41) +d = one data digit + +n = one number system digit +c = one check digit + + +s = one supplement digit + + +14-7 + + +I/O DEVICES REFERENCE + + +EAN 8 bar code format + + +The EAN 8 bar code label format contains the following components: two leading ID characters, two flag +digits, five data digits and one check digit. The two leading ID characters will be the upper case string: +"ER w t. + + +The bar code interface may be programmed to remove the two ID characters, or the check digit from the +output data transmitted to the host computer. The following table displays the four different options +available: + + +Transmit ID chars Transmit check digit Output + + +No No ffddddd + +Yes No FFf£fddddd + +No Yes ffddddde + +Yes Yes FF £fdddddc +where: + + +F = an ID character 'F' (0x46) +f = one flag digit + +d = one data digit + +c = one check digit + + +EAN 8 + 2 digits + + +The EAN 8 + 2 bar code label format contains the following components: two leading ID characters, two +flag digits, five data digits, one check digit and two supplement digits. The two leading ID characters will +be the upper case string "FF". + + +The bar code interface may be programmed to remove the two ID characters, or the check digit from the +output data transmitted to the host computer. The following table displays the four different options +available: + + +Transmit ID chars Transmit check digit Output + + +No No ffdddddss + +Yes No FFf£fdddddss + +No Yes ffdddddess + +Yes Yes FFf£fdddddcss +where: + + +F = an ID character 'F' (0x46) +£ = one flag digit + +d = one data digit + +c = one check digit + + +s = one supplement digit + + +EAN 8 + 5 digits + + +The EAN 8 + 5 bar code label format contains the following components: two leading ID characters, two +flag digits, five data digits, one check digit and five supplement digits. The two leading ID characters will +be the upper case string "FF". + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +The bar code interface may be programmed to remove the two ID characters, or the check digit from the +output data transmitted to the host computer. The following table displays the four different options +available: + + +Transmit ID chars Transmit check digit Output + + +No No ffdddddsssss + +Yes No FFffdddddsssss + +No Yes ffdddddcsssss + +Yes Yes FFf£ffdddddcsssss +where: + + +Fr = an ID character 'F' (0x46) +f = one flag digit + +a = one data digit + +c = one check digit + + +s = one supplement digit + + +EAN 13 + + +The EAN 13 bar code label format contains the following components: a leading ID character, two flag +digits, ten data digits and one check digit. The leading ID character will be an ASCII upper case 'F’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID char Transmit check digit Output + + +No No ffdddddddddd + +Yes No Fff£dddddddddd + +No Yes ffddddddddddc + +Yes Yes Ff fdddddddddde +where: + + +Fr =an ID character 'F' (0x46) +f = one flag digit + +ad = one data digit + +c = one check digit + + +EAN 13 + 2 digits + + +The EAN 13 + 2 bar code label format contains the following components: a leading ID character, two +flag digits, ten data digits, one check digit and two supplement digits. The leading ID character will be an +ASCII upper case 'F’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID char Transmit check digit Output + + +No No ffddddddddddss +Yes No Fffddddddddddss +No Yes ffddddddddddess +Yes Yes Fffddddddddddecss + + +14-9 + + +I/O DEVICES REFERENCE + + +where: +F = an ID character 'F' (0x46) +£ = one flag digit +d = one data digit +c = one check digit + + +s = one supplement digit +EAN 13 + 5 digits + + +The EAN 13 + 5 bar code label format contains the following components: a leading ID character, two +flag digits, ten data digits, one check digit and five supplement digits. The leading ID character will be an +ASCII upper case 'F’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID chars Transmit check digit Output + + +No No ffddddddddddsssss + +Yes No Fffddddddddddsssss + +No Yes ffddddddddddesssss + +Yes Yes Fffddddddddddesssss +where: + + +F = an ID character 'F' (0x46) +f = one flag digit + +d = one data digit + +c = one check digit + + +s = one supplement digit +UPCA + + +The UPC A bar code label format contains a leading ID character, one number system digit, ten data +digits and one check digit. The leading ID character must be an ASCII 'A’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID chars Transmit check digit Output + + +No No ndddddddddd + +Yes No Andddddddddd + +No Yes ndddddddddde + +Yes Yes Anddddddddddc +where: + + +a=an ID character 'A' (0x41) +n = one number system digit +d = one data digit + + +c = one check digit + + +14-10 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +UPC A + 2 digits + + +The UPC A + 2 bar code label format contains a leading ID character, one number system digit, ten data +digits, one check digit and two supplement digits. The leading ID character must be an ASCII 'A’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID chars Transmit check digit Output + + +No No nddddddddddss + +Yes No Anddddddddddss + +No Yes nddddddddddcss + +Yes Yes Anddddddddddcss +where: + + +a =an ID character 'A' (0x41) +n = one number system digit +a = one data digit + +c = one check digit + + +s = one supplement digit + + +UPC A + 5 digits + + +The UPC A +5 bar code label format contains a leading ID character, one number system digit, ten data +digits, one check digit and five supplement digits. The leading ID character must be an ASCII 'A’. + + +The bar code interface may be programmed to remove the ID character, or the check digit from the output +data transmitted to the host computer. The following table displays the four different options available: + + +Transmit ID chars Transmit check digit Output + + +No No nddddddddddsssss + +Yes No Anddddddddddsssss + +No Yes nddddddddddesssss + +Yes Yes Anddddddddddcsssss +where: + + +a=an ID character 'A' (0x41) +n = one number system digit +d = one data digit + +c = one check digit + + +s = one supplement digit + + +Bar code commands + + +This section describes the commands that may be used to program the HC bar code reader interface. + + +The bar code interface is programmed by writing an escape sequence to the interface unit via a serial port. +With two exceptions, each escape sequence consists of a short text string in the following format: + + +-y + + +14-11 + + +I/O DEVICES REFERENCE + + +1. is the escape character (0x1b) + +2. - isa'-' character (0x2d) + +3. y isa'y' character (0x79) or a'y' character (0x59) +4 + + + is a parameter to the command, consisting of sequence of one to three numeric digit, +representing a decimal number between zero and 255. + + +5. is an upper case alphabetic character identifying the command to be executed. +The two exceptions are the hard reset command: +E + + +and the command to set the data termination string, which includes additional text following the letter +that identifies the command: + + +-y +In all cases the escape sequence must not contain any embedded spaces. + + +Commands to the bar code reader interface do not have to be issued individually. The /ssuing multiple +commands section in this chapter describes how several commands may be issued as a multiple escape +sequence, within one text string. + + +Multiple options in a command + + +Many of the bar code interface commands offer more than one option, selected by the value. To +select multiple options from a single command, simply sum all the required individual values +together, and then pass this summed value as the value within the escape sequence. + + +For example, the Select bar code symbology command -yF (described later in this chapter) +contains options to select five different bar code formats. For example, a value of | selects Code + +39, a value of 4 selects Codabar and a value of 8 selects UPC/EAN. You can select all three formats in a +single command by setting the value to 1+4+8 = 13, as follows: + + +-y13F + + +Issuing multiple commands + + +Several individual escape sequence commands may be concatenated together and be transmitted to the bar +code interface as a single escape sequence. To do this, append one or more additional +character sequences to the end of a standard, single, escape sequence. + + +When issuing multiple commands, all of the intermediate ASCII characters must be lower case +letters, and the terminating character must be an upper case ASCII character. + + +As with a single command, the escape sequence must not contain any embedded spaces. + + +For example, following three commands: + + +-y13F Select Codabar, UPC/EAN and Code 39 symbologies +-y2H Do not transmit Codabar start and stop characters +-y1D Insert a 10 ms delay between each data character + + +may be concatenated into a single escape sequence: +-y13£2h1D + + +The order of issuing commands is usually not important, so that the following three escape sequences are +all functionally identical: + + +-y13f£2h1D +-y2h1d13F +-y1d13£2H + + +Exceptions to this rule are mentioned explicitly in the following descriptions of the individual commands. + + +14-12 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +Serial intercharacter delay -yD + + +Enable or disable a ten millisecond delay between the transmission of each data character in the bar code +data string. + + + Option +0 No delay +1 Turn 10 millisecond delay on + + +The default value is equivalent to the command -yop. + + +Hard reset E +Perform a hard reset and run a self-test. + + +A hard reset will take approximately one second to complete. During this time, the bar code reader +interface will not react to any further commands that may be written to it. + + +All previous escape sequence commands sent to the bar code interface will be aborted when a hard reset is +executed. After the reset has taken place, all of the interface options will revert to their default values. + + +If the interface has failed its self-test, it will immediately transmit one of the following four messages: +ROM SELF TEST FAILED +PROCESSOR SELF TEST FAILED +LOWER RAM SELF TEST FAILED +UPPER RAM SELF TEST FAILED +No message will be issued if the interface has passed the self-test. + + +Note that the diagnostic messages will always be terminated by a carriage return (0x0d) and line feed +(0x0a) character pair, regardless of any previous command to set the termination characters. + + +All subsequent messages from the interface will be terminated with a (default) single carriage return +character. + + +A Hard Reset will not normally be issued as part of a multiple instruction escape sequence, because it will +cause all prior commands to be overridden by default settings, and all subsequent commands within the +escape sequence to be ignored by the bar code reader interface while it resets itself. + + +Select bar code symbology -yF +Set the barcode reader to recognise one or more barcode formats, as indicated in the following table: + Enable bar code format: + +1 Code 39 + +2 Interleaved 2 of 5 + +4 UPC/EAN + +8 Codabar + +16 Code 128 + + +For example, to read Code 39 and UPC/EAN bar codes only, use: +-y5F + + +If a bar code format has not been enabled, then the bar code reader will ignore all scans in that code +format. + + +The default setting for this option is equivalent to the command -y31F. + + +Note that it may be necessary to set additional interface options to enable the interface to read certain bar +code formats. + + +14 - 13 + + +1/0 DEVICES REFERENCE + + +Check character options -yG + + +Enable or disable verification/check digits and check characters within bar code scans. The precise action +of this command is dependent upon the bar code format being scanned, as indicated below. + + +The default state corresponds to the command -y0c. +Code 39 and Interleaved 2 of 5 + + +For Code 39 and Interleaved 2 of 5 bar codes, the bar code reader may be programmed to verify, or to +ignore check characters in the bar code scan. In addition, the bar code reader may be programmed to +transmit, or to omit the verification character from the scan data when it is transmitted to the host +computer. + + + Option + +0 Do not verify check characters + +1 Verify Code 39 check characters + +2 Verify Interleaved 2 of 5 check characters + +8 Transmit Code 39 and Interleaved 2 of 5 check characters + + +UPC/EAN + + +The contents of UPC/EAN bar code scans are always checked against the check digit. However, the bar +code reader may be programmed to transmit, or to omit the check digit when the scan data is transmitted +to the host computer. Note that the check digit in a UPC E bar code is never transmitted to the host +computer. + + +The bar code reader may also be programmed to decode UPC E 0 bar codes, or it may be programmed to +automatically discriminate between UPC E 0 and UPC E 1 version bar codes. + + + Option + +0 Read UPC E 0 only, transmit UPC/EAN check digit + +32 Do not transmit UPC/EAN check digit + +64 Read both UPC E 0 and UPC E 1 + +Decoding options -yH + + +This command provides several assorted programming options to the programmer. For UPC/EAN bar +code scans, the bar code reader may be programmed to accept (zero, two or five) supplemental digits in +the code, and to expand UPC E bar codes automatically into a UPC A code format, if required. + + +The bar code reader may also be programmed using this command to decode Code 39 bar codes in +standard, or in extended mode. If the extended option is selected, then the bar code reader will encode +each character pair into the corresponding ASCII characters; if standard mode is selected, then each +character in the scan data is decoded individually. + + +The bar code reader may also be programmed to retain (or discard) Codabar start and stop characters in +the scan data it transmits to the host computer. + + + Option + +1 Extended Code 39 + +0 Standard Code 39 + +2 Do not transmit Codabar start and stop characters +0 Transmit Codabar start and stop characters + +4 Read UPC bar codes only + +0 Read both UPC and EAN bar codes + +8 Decode UPC/EAN 2 digit supplement data + +0 Do not decode UPC/EAN 2 digit supplement data +16 Decode UPC/EAN 5 digit supplement data + +0 Do not decode UPC/EAN 5 digit supplement data + + +32 Expand UPC E bar codes into UPC A bar codes + + +14-14 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +0 Do not expand UPC E bar codes + +64 Auto discriminate UPC/EAN supplementals +0 Require UPC/EAN supplementals + +128 Transmit UPC/EAN ID characters + +0 Do not transmit UPC/EAN ID characters + + +The default setting is equivalent to the command -y0H. + + +Notes + + +When the option is set to decode UPC/EAN 2 digit (or 5 digit) supplement data, then the bar code label +must be scanned in the forwards direction only. + + +Only UPC/EAN bar codes containing supplement digits may be read by the interface if either, or both of +these options has been enabled. Both the 2 digit and 5 digit options may be enabled together to allow both +types of bar code scans to be read by the interface, if required. + + +If the supplement digit options are not enabled by this command, then bar code labels containing +supplement digits may still be scanned, and they may be scanned in both directions (i.e. forwards or +backwards). However the supplement digit data is not transmitted to the host computer. + + +Single read mode -yJ + + +This command will force the bar code reader to abort any current scan and not transmit that scan data to +the HC. + + +Enabling Single read mode means that the bar code reader will read a single bar code label each time a +Single read control command is issued. + + +When Single read mode is disabled, the bar code reader will attempt to read a bar code label whenever a +label is scanned. + + + Option +1 Single read mode is enabled +0 Single read mode is disabled + + +The default value is equivalent to the command -you. + + +Single read control -yK + + +This command will force the bar code reader to abort any current scan and not transmit that scan data to +the HC. + + +When Single read mode has been enabled (see above), the-Single read control may be used to enable the +bar code reader, so that it then will read one scan. + + + Option +1 Read next scan +Set Interleaved 2 of 5 length -yM + + +This command presets the length of Interleaved 2 of 5 bar code read by the bar code reader. + + +There are three length checking options available: + + + Option + +0 The bar code may have a variable length, between 4 and 32 digits +1..32 The bar code is digits long (even values only) + +33 The bar code may only contain either 6 or 14 digits + + +The default setting is equivalent to the command -yom. + + +14-15 + + +I/O DEVICES REFERENCE + + +Notes + + +Although the Interleaved 2 of 5 bar code length may be set to the minimum setting (i.e. two digits), short +Interleaved 2 of 5 bar codes may well appear in other, longer bar codes. As a result, false readings may be +given when other formats of bar code label are scanned, which may be misinterpreted as two digit +Interleaved 2 of 5 labels. Consequently, the minimum setting of 2 digits in this option is not +recommended. + + +An Interleaved 2 of 5 bar label must contain an even number of digits. If is set to an odd number +between one and thirty one, then the micro controller will automatically round up the value to the next +higher even number. + + +Set termination string -yO + + +This command will force the bar code reader to abort any current scan and not transmit that scan data to +the HC. + + +Append the termination string to the end of every bar code data message transmitted to the +HC computer by the micro controller, to mark the end of that message. + + +The default termination string is a single carriage return character (0x0a). However, a user-defined +termination string may be defined with this command, which will be used to terminate all subsequent +message transmitted by the bar code reader interface. An example escape sequence, which substitutes the +characters "stop" as the terminating string in place of the default value, is: + + +-y4Ostop + + +A termination string may contain a maximum of four characters and a minimum of zero characters. The +total number of characters contained within the termination string must be passed as the argument +of the escape sequence. + + +The default termination string transmitted by the bar code reader is a single carriage return character +(0x0d). + + +Unlike all other sequence commands described in this document, the ASCII characters for the termination +string follow the command identifier character that normally terminates a command. As a result this +command must be positioned last, if issued within an escape sequence that contains more than one +command (even if the terminating string contains zero characters). + + +For example, consider the commands: + +-y4Ostop Set the termination string to "stop" + +-y1D Insert a 10 ms delay between each data character + +If these commands are combined in a single escape sequence, that sequence must be: + + +-yl1d40stop + + +Code ID characters -yQ + + +Instruct the bar code reader to add a lower case ID character to the data message transmitted to the HC, to +identify the symbology of the bar code. This ID code character is transmitted before the bar label data. + + +The following values will enable, and disable this option: + + + Option +1 Transmit ID characters +0) Do not transmit ID characters + + +The table below displays which lower case ASCII character ('a' - 'e') is used to identify each type of bar +code label: + + +ID character Bar code format + + +Code 39 +Interleaved 2 of 5 +UPC/EAN/JAN +Codabar + +Code 128 + + +o0oaadaas ow + + +The default state is equivalent to the command -y0o. + + +14 - 16 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +Status request -yS + + +This command will force the bar code reader to abort any current scan and not transmit that scan data to +the HC. + + +Return a data string to the host computer, containing information about the status of the firmware inside +the bar code reader. + + + Option + +1 Transmit the status message + +The status message that is transmitted back to the HC in response to this instruction is: +HBCR-161X Version 15.x + + +followed by the current termination string, where "15.x" represents the present revision level of the +firmware inside the bar code reader interface. + + +Scanner enable -yW + + +This command will force the bar code reader to abort any current scan and not transmit that scan data to +the HC. + + +Enable or disable the bar code reader. + + +When disabled, the bar code scanner will not read data from any bar code labels. + + + Option +1 Enable the bar code scanner +0 Disable the bar code scanner + + +The default is for the bar code scanner to be enabled. + + +RS232 port/bar code driver services + + +The RS232 port/bar code device driver supports all the services that are described in the Serial Port +chapter of this manual. This section describes only those services that provide modified or additional +behaviour when used with the bar code reader interface. These include services to open the port, write +data to the bar code interface and read data from a bar code wand connected to the port. + + +p_open(TTY:) Open the device +INT p_open(VOID **ppcb, "TTY:B",-1); +Open a channel to the RS232 port/bar code device. + + +The table below displays which device should be accessed to open the RS232 port or the bar code reader +interface, when the expansion module has been inserted into either of the the top and bottom slots of the HC. + + +Slot RS232 port _Bar code port +Top TTY:A TTY2¢ +Bottom TTY:B TTY:D + + +On opening a channel, RS232 port, the bar code reader interface and any connected wand or scanner will +all be powered up automatically. + + +Returns zero if the device was opened successfully, otherwise a negative error. + + +For example, the following code fragment illustrates the opening of a channel to the bar code interface +with the device in the top slot of the HC. + + +LOCAL_D VOID *pHandle; +INT result; + + +result=p_open (&pHandle, "TTY:D",-1); + + +14-17 + + +1/0 DEVICES REFERENCE + + +p_close Close the channel +INT p_close (VOID *pcb) + +Close the channel to the RS232 port/bar code device. + +Returns zero. + + +Closing the channel will also cause the RS232 port/bar code interface to be powered down. To save battery +power, a device should be closed as soon as it is no longer required. + + +Note that when the device is closed, or when the HC automatically powers down, all of the information +programmed into the bar code interface will be lost. If you do not wish to use the default settings of the +bar code reader interface, then you will need to reprogram your custom settings back into the interface +when the device is next opened. + + +P_FSENSE Sense serial port characteristics + + +INT p_iow(VOID *pcb, P_FSENSE, P_SRCHAR *pserial); + + +Sense the serial port characteristics, writing them to the P_sRcuar struct (defined in p_serial.h) pointed to +by pserial. + + +The P_FSENSE service cannot fail and returns zero. + + +If using the bar code interface, the serial port characteristics must be altered once a channel is opened, to +allow the interface to communicate successfully with the HC. See the description of the P_Fset service for +further details. + + +P_FSET Set serial port characteristics +INT p_iow(VOID *pcb, P_FSET, P_SRCHAR *pserial); + +Set the serial port characteristics from the P_sRcHar struct (defined in p_serial.h) pointed to by pserial. +Returns zero if the P_FSET service completed successfully, otherwise returns a negative error. + + +If using the bar code interface, the serial port characteristics must be altered once a channel is opened, to +allow the interface to communicate successfully with the HC. Since the bar code interface does not use +RTS/cTS handshaking, the cts line in the serial port must be disabled. + + +The following code fragment illustrates the use of the P_FsENSE and P_FSET services to disable RTS/cTS +handshaking: + + +#include + + +LOCAL_D P_SRCHAR srChar; +LOCAL_D VOID *pHandle; + + +f_leave (p_open (&pHandle, "TTY:D",-1)); + +p_iow(pHandle,P_FSENSE,&srChar); /* read default settings into srChar */ +srChar.hand=P_IGN_CTS; /* suspend RTS/CTS handshaking */ + +p_iow (pHandle, P_FSET, &srChar) ; /* set up port with new settings */ + + +Note that this code assumes that it is called under the protection of p_enter. + + +P_FREAD Read from device + + +VOID p_iow (VOID *pcb, INT P_FREAD,VOID *buf,UINT *plen)j; +VOID p_ioc (VOID *pcb, INT P_FREAD,WORD *pfstat,VOID *buf,UINT *plen)j; + + +Read up to *plen bytes of data from the device into the buffer pointed to by buf. The buffer is assumed to +be of sufficient length to receive the data. If using an asynchronous P_FREAD service, it is the caller's +responsibility to preserve the data space pointed to by buf and plen until the service completes. + + +The result is returned by a call to p_iow and written to *pfstat by the asynchronous call. The result is +zero if the service completed successfully, otherwise it is a negative error. + + +14 - 18 + + +14 HC INTELLIGENT BAR CODE READER/RS232 PORT + + +A read operation may take an indefinite time to complete and it should therefore be executed +asynchronously within a quality system. For clarity, the following example code uses synchronous reads. + + +define MAX_BARCODE 128 +define TERMINATE_CHAR 0x0d + + +VOID *pHandle; + +TEXT *p; + +NT len; + +UINT count; + +TEXT buf [MAX_BARCODE+2]; + + +len=0; +count=1; +p=ébuf [0]; +FOREVER + + +{ + +p_iow(pHandle,P_FREAD,p, &count) ; + +lent+=1; + +if ( (*p++==TERMINATE_CHAR) | | (len>=MAX_BARCODE_LEN) ) +{ + + +*--p=0; /* convert to a zero-terminated string */ +len-=1; +break; +} +} + + +p_printf("Bar code is %s, containing %d bytes", &ébuf[0],len); + + +P_FWRITE Write to device + + +INT p_iow(VOID *pcb, INT P_FWRITE,VOID *buf,UINT *plen); +VOID p_ioc(VOID *pcb, INT P_FWRITE,WORD *pfstat,VOID *buf,UINT *plen); + + +Write up to *pien bytes of data from the buffer pointed to by buf to the device. If using an asynchronous +P_FWRITE Service, it is the caller's responsibility to preserve the data space pointed to by buf and plen +until the service completes. + + +The result is returned by a call to p_iow and written to *pfstat by the asynchronous call. The result is +zero if the service completed successfully, otherwise it is a negative error. + + +A write operation may take an indefinite time to complete and should therefore be executed +asynchronously within a quality system. For clarity, the following example uses a synchronous write. + + +The following code fragment transmits the escape sequence —y1d24f2u to the bar code reader +interface: + + +#define MAX COMMAND 64 + + +VOID *pHandle; +UINT len; +UBYTE command [MAX_COMMAND+2]; + + +p_scpy (&command[0],"\033-y1d24f£2H") ; + + +len=p_slen(&command[0]) ; +p_iow (pHandle, &command [0], &len) ; + + +14-19 + + +I/O DEVICES REFERENCE + + +An example program + + +The program listed below will operate a bar code interface connected to either the top, or the bottom of the +HC. The program will read scanned bar code data from the reader interface, display that information on +the screen and then await a key press. The scanning operation may be repeated as many times as required. +Press the X key after a scan to exit the program; pressing the V key will display the firmware status of the +software inside the bar code interface. + + +This program is only given here as a simple example of how to program the micro controller and read +scan data: a quality system should carry out more rigorous testing for errors, and should also use +asynchronous operations to read and write the data. + + +#include +#include + + +#define MAX _STRING 128 +LOCAL_D VOID *pHandle; + + +GLDEF_C INT main (void) +{ +P_SRCHAR srChar; +INT len, onebyte,result, reply; +TEXT buffer [MAX_STRING+2]; +/* Try to open a port */ +if (p_open(&pHandle, "TTY:D",-1) <0) +{ +if ((result=p_open (&pHandle, "TTY:E",-1) ) <0) +p_panic(result); +} + +/* Set up serial port characteristics */ +p_iow (pHandle, P_FSENSE, &srChar) ; +srChar.hand=P_IGN_CTS; +p_iow (pHandle, P_FSET, &srChar) ; +buffer[0]='\0'; +onebyte=1; +do + +{ + +/* Display menu on screen */ +p_printf(" BAR CODE SCANNER") ; +p_printf("%s",buffer) ; +p_printf("\npress V for Version,"); + + +p_printf Le X to eXit"); +p_printf (* or any other key"); +p_printf Cy to scan a label"); + + +reply=p_tofold(p_getch()); + + +if (reply=='V') +p_write (pHandle, "\033-y1S",5); +if (reply!='X"') +{ /* Read input from the bar code interface */ +len=0; +do +{ +p_iow (pHandle, P_FREAD, &buffer[len],é&onebyte) ; +} while (buffer[lent+]!=13 && len + + +ifndef EPOC +GLREF_D P_DEVICE p_serial,p_file,p_keyb,p_timer; + + +endif + +LOCAL_D VOID *pIr; + +LOCAL_D UBYTE buf[256]; + +LOCAL_D TEXT connData[64]=" "; + +LOCAL_D TEXT printstring[24]="Welcome to IR printing!"; +LOCAL_D UWORD slots; + +LOCAL_D INT readlen,writelen,ret,i; + +LOCAL_D UBYTE devName [24]; + +LOCAL_D ULONG devAddr; + + +LOCAL_C HANDLE LoadIrdaServer (TEXT *name) +INT err; + +TEXT serverPath[P_FNAMESIZE]; +HANDLE serverPid=NULL; + + +/* Start the IRDA stack as a separate process and store its pid */ +p_printf ("Trying to start %s",name) ; +if ((serverPid=p_pidfind(name) ) ==E_FILE_NXIST) +{/* Try to load irda from M first */ +f_fparse (name, "LOC: :M:\\", &serverPath[0],NULL) ; +if ((serverPid=p_execc(&serverPath[0], +(UBYTE *)&serverPid, sizeof (serverPid) ) ) <0) +{/* Try to load irda from ROM */ +f_fparse (name, "ROM::\\",&serverPath[0],NULL) ; +if ((serverPid=p_execc(&serverPath[0], +(UBYTE *)&serverPid, sizeof (serverPid) ) ) <0) +{/* Error ! No irda */ +return (0); +} +} +if ((err=p_presume (serverPid) ) <0) +return (0); +} +p_sleept (5L); /* Give irda a chance to get going */ +return (serverPid) ; + + +} + + +LOCAL_C VOID PrintMenu () +{ +D2 PLEINCE (MAREE ARE RES REA A ERIN) 7 +p_printf ("Press \'p\' to make station primary"); +p_printf ("Press \'s\' to make station secondary"); +p_printf ("Press \'q\' to quit"); + + +Pp DLLME ECU AREER EAR ARR RRR EAE HRI MY ; + + +} + + +16-7 + + +1/0 DEVICES REFERENCE + + +LOCAL_C INT DiscoverDevices () + +{ + +p_printf ("Doing a discovery"); + +slots=6; + +p_iow(pIr, 6, &buf[0],&slots); /* P_FIRDISCOVER */ + +p_printf ("Devices found = %d",slots); + +if (slots>0) +{/* We have discovered at least one device */ +devAddr= *((ULONG *) (&buf[4])); +/* Discovery nickname is last 23 bytes of info */ +p_bcpy (devName, &buf[12],23); + + +i=0; +while (devName[i]>=0x20 && i<23) +itt+; +devName[i]='\0'; +p_printf ("Remote devAddr = 0x%08X",devAddr) ; +p_printf ("Remote device = %s",devName) ; + + +return (0); +} + + +else + + +p_printf ("Trying again"); +return (-1); + + +LOCAL_C INT ConnectToFirstDevice() +{ +p_printf ("Selecting machine"); +ret=p_iow(pIr,7,&devAddr); /* P_FIRSELECT */ +p_printf ("Connecting to machine %08X",devAddr) ; +if ((ret=p_iow(pIr,8,"Test",&connData[0]) ) <0) /* P_FIRMAKECONNECT */ +{ +p_printf("Connect failed with ret = %d",ret); +p_getch(); +return (0); +} + + +p_printf ("Successfully connected machine") ; + + +} + + +LOCAL_C VOID TransmitData() +{ +INT ret; +p_printf ("Writing keypresses to IR port - ESC to cancel"); +writelen=1; +while ((ret=p_getch()) !=27) +{/* OK as long as not escape */ +buf [0]=ret; +p_iow(pIr,2, &buf[0],&writelen) ; /* P_FWRITE */ +p_print ("%s", &buf[0]); +} + + +LOCAL_C INT WaitForConnect () + +{ + +INT ret; + +p_printf ("Connecting as a secondary"); + +if ((ret=p_iow(pIr,5,"Test",&connData[0])) <0) /* P_FIRAWAITCONNECT */ +{ +p_printf ("Wait for connect failed with ret = %d",ret); +p_getch (); +return(-1); +} + +p_printf ("Accepted a connection"); + + +} + + +16-8 + + +16 THE ACCESSIR API + + +LOCAL_C INT ReadData() + +{ + +readlen=1; + +if ((ret=p_iow(pIr,1,é&buf[0],&readlen) ) <0) /* P_FREAD */ +{ +p_printf ("Error on reading"); +if (ret==DisconnectErr) + +p_printf ("Primary has disconnected") ; + +return (ret); +} + +p_print ("%s", &buf[0]); + +return (1); + + +} + + +LOCAL_C VOID Disconnect () + + +p_printf ("Disconnecting") ; +p_iow(pIr,4); /* P_FIRDISCONNECT */ + + +GLDEF_C INT main(VOID) + + +TEXT servername[20]="SYSSIRDA.IMG"; + + +#ifndef EPOC +p_inst (&p_file, &ép_serial, &p_keyb, &p_timer, NULL) ; +#endif + + +p_printf("Psion Software (c) October 1996"); +PUPBENEL (MAA AAAAAAAK AAA RAK AKA RAK KAA RA RAK ARE RARE ) - + + +p_printf("Starting simple AccessIr beaming app"); +if ((ret=LoadIrdaServer (servername) ) ==NULL) +{ +p_printf ("Problem loading Irda stack"); +p_getch(); +return (0); +} +p_printf ("Successfully kicked open the irda stack as separate process"); +if ((ret=p_open(&pIr, "AIR:",-1)) <0) +{ +p_printf ("Cannot open AccessIr driver ret = %d",ret); +p_getch(); +return (0); +} +p_printf ("Successfully opened AccessIr driver"); +startLoop: +PrintMenu () ; +ret=p_getch(); + + +switch (ret) + +{ + +case 'p!: + +case 'P'; +/* PRIMARY STATION - TRANSMITTER */ +if ((ret=DiscoverDevices ()) <0) + +goto startLoop; + +ConnectToFirstDevice () ; +TransmitData(); +Disconnect (); +break; + + +16-9 + + +1/0 DEVICES REFERENCE + + +case 's!': +case 'S': +/* SECONDARY STATION - RECEIVER */ +if ((ret=WaitForConnect () ) <0) +break; + + +while ((ret=ReadData())>0) +/* Keep reading until failure */ ; +break; +case 'q': +case 'Q': +p_printf ("Terminating program") ; +break; +default: +goto startLoop; +break; +} +p_close(pIr); /* This also kills the IrDA process */ +p_printf("End of program — Hit key to esc"); +p_getch(); +return (0); + + +} + + +16 - 10 + + +CHAPTER 17 + + +THE IRMUX API + + +Using the IrMUX API + + +Prerequisites + + +It is essential that the Introduction to Psion Infrared Communications chapter has been read before this +chapter. + + +Introduction to using the IrMUX API + + +The IrMUX API facilitates Infrared communication between two Psion machines (Series 3c and/or Siena). + + +This section explains how to use each call that can be made to the IrMUX server using IPC on a SIBO +(EPOC/16) based computer system. This API is more difficult to use than the AccessIr API, but +potentially gives more flexibility. For simple IR communication applications it is recommended that the +AccessIr API is used. + + +With the IrMUX API connectionless or connection-oriented calls are available. + + +This set of protocols uses machine addresses and port IDs (rather than application names as for the +AccessIr API). + + +The packets of data used must be exactly the right size, there is no error correction and there is no +guarantee of transfer. +Initialising the IR protocol stack + + +Before the IR protocol stack can be used it must be initialized, by doing a p_execc. The protocol stack is +started as a separate process. This is done in exactly the same way as when using the AccessIr API. When +the last application has logged off, the protocol stack will clean up and terminate itself automatically. + + +17-1 + + +I/O DEVICES REFERENCE + + +The argument *name is SySSIRDA. IMG in the example code segment below: + + +LOCAL_C HANDLE loadIRDAserver (TEXT *name) +{ +INT err; +TEXT serverPath[P_FNAMESIZE]; +HANDLE server_pid=NULL; +/* Start the IR process & store its server_pid in property */ +if (E_FILE_NXIST==(server_pid=p_pidfind (name) ) ) +{ /* Load from M, then from wherever we are... */ +f_fparse (name, "LOC: :M:\\", &serverPath[0],NULL) ; +if ((server_pid=p_execc(&serverPath[0], +(UBYTE*) &server_pid, +sizeof (server_pid) ) ) <0) +{ +f_fparse (name, "ROM::\\",&serverPath[0],NULL) ; +if ((server_pid=p_execc(&serverPath[0], +(UBYTE*) &Server_pid, +sizeof (server_pid) )) <0) +{ /* Error...no irda! */ +return (0); +} +} +if (0!=(err=p_presume (server_pid) ) ) +return (0); +} +p_sleept (5L); /* Give IRDA a chance to get going! */ +return (server_pid); + + +} + + +Logging on to and logging off from the IrMUX server +Before an application can use IrMUX services it must log on. When it has finished it must log off. + + +Logging on to the IrMUX server + + +The LM_Logon function call is used to log on to the ITMUX server. + + +Logging off from the IrMUX server + + +The tm_Logof¢ function call is used to log off from the IrMUX server. + + +Registering/unregistering applications with the LM-IAS server +This is independent of the process of sending or receiving data. An application can either: + +e register iself in the LM-IAS database + +¢ unregister iself from the LM-IAS database +Registering the port with the LM-IAS server +The tM_RegisterPort function call is used to register the application with the LM-IAS server. +Unregistering the port with the LM-IAS server + + +The LM_UnRegisterPort function call is used to unregister the application with the LM-IAS server. + + +LM-IAS services + + +The LM_GetValueByClass message has not been implemented as a direct IPC service, but an IAS Get +Value By Class frame must be passed from the LM-IAS server of the primary station to the LM-IAS +server of the secondary station. The secondary station replies with another specially formatted frame of +data. + + +The LM-IAS server on a remote machine is reached by starting a connection to the remote machine, +(using the LM_connectRequest function), with a remote port of zero. + + +17-2 + + +17 THE IRMUX API + + +The IAS Get Value By Class service can only be used with a connection to a remote LM-IAS server. +Direct read and write access to a remote LM-IAS port has not been blocked in order to allow future +expansion. A client should not attempt to send frames directly to a remote LM-IAS connection (other than +the Get Value By Class message) without a full understanding of the implications of such actions. +Developers should study the IrDA IrLMP specification. + + +The IAS Get Value By Class message frame + + +The format of the frame that must be sent from the primary station is: + + +byte 0x84 + +byte name length + +n bytes application name, not including zero terminator +byte 0x12 + +byte “IrDA: IrLMP:LsapSel” + + +The IAS Get Value By Class reply frame + + +The format of the frame returned by the LM-IAS server on the secondary station is: + + +byte AND with ox3r and compare with 4; if not equal to 4, failed +byte 0 + +byte non-zero + +byte don’t care + +byte don’t care + +byte don’t care + +byte 1 + +byte 0 + +word 0 + +byte port number + + +Connectionless calls + +Data may either be sent or received in a connectionless manner. This process involves one step: +e Queue a connectionless read or write request + +The first application to read the transmitted data is the one that gets it. + + +Reading and writing data + + +The LM_cLReadRequest function call is used to queue a connectionless read request. + + +The LM_cLwriteRequest function call is used to queue a connectionless write request. + + +Connection-oriented calls +The steps in the process for a secondary station are: +1. Register the application with the secondary station’s LM-IAS server +2. Wait for the primary station to connect +The steps in the process for a primary station are: +1. Discover and log the remote machines +2. Connect to the LM-IAS server on the selected remote machine + + +3. Ask for a particular registered application (by preparing and sending a LM_GetvalueByClass +message) + + +4. Wait for the reply (the secondary station returns a port ID for the required application) +5. Close the LM-IAS connection + + +17-3 + + +I/O DEVICES REFERENCE + + +6. Reconnect using the port ID previously returned for the required application on the +secondary station + + +7. Send or accept data (either reliably or unreliably) +8. Disconnect +Discovery + + +The LM_DiscoverDevicesRequest function call is used by the primary station to return information about +machines within transmission range. + + +Connection - first time + + +The bm_connectRequest function call is used by the primary station (with a remote port of zero) to +attempt to connect to the LM-IAS server of the remote machine. + + +If successful the primary station sends an IAS Get Value By Class frame to the secondary station. The +secondary station sends back a frame containing the ID of the port for the application required (previously +registered by the secondary station with its LM-IAS server). + + +Disconnecting - first time + + +The LM_DisconnectRequest function call is used by the primary station to disconnect the two +communicating machines, before subsequent reconnection. + + +Connection - second time + + +The bm_connectRequest function call is used by the primary station to attempt to re-connect to the remote +machine, using the port ID for the required application, returned previously. + + +Reading and writing data + + +Reading and writing data may be done either reliably or unreliably. If unreliable red/write is used then the +data is only sent once. + + +The LM_ReadRequest function call is used to queue a connection-oriented read request. + +The LM_writeRequest function call is used to queue a connection-oriented write request. + +The tM_UReadRequest function call is used to queue an unreliable connection-oriented write request. +The bM_UwriteRequest function call is used to queue an unreliable connection-oriented write request. + + +Disconnecting - second time + + +The bM_DisconnectRequest function call is used by the primary station to disconnect the two +communicating machines. + + +Using Exclusive mode + + +If an application on the primary station wants to be sure of control over the link then it should use +Exclusive mode. A call to bM_AccessModeRequest gives exclusive access to ITMUX. This means that only +that one application can talk, and all other applications are blocked. + + +If you want to stop other applications from placing IrMUX into Exclusive mode, then the connection +(which always starts in Idle mode) can be put into Active mode, by using the LM_IdleRequest function +call. This should only be done during critical periods of communication. The connection should be put +back in Idle mode when the critical period has finished, by using another call to LM_tdleRequest. + + +When in Exclusive mode, if the client application is not responding to incoming data quickly enough, the +number of retries to be used on each data frame can be changed (from the default of 1), using the +LM_SetHandshakingLevel function call. The number of retries must be set back to 1 when IrMUX leaves +Exclusive mode. + + +When exclusive use of IrMUX is no longer required, another call to bm_AccessModeRequest should be +made. + + +The current status of the link can be found with a call to tM_statusRequest. + + +17-4 + + +17 THE IRMUX API + + +The IrMUX API + + +IrMUX message format + + +The muxmessace struct has the format shown below. + + +typedef struct +{ + + +E_MESSAGE Mess; // Message Control +VOID * MessConn; // Connection Handle +VOID * MessArgl; // Argument 1 + +VOID * MessArg2; // Argument 2 + +UINT MessArg3; // Argument 3 + + +} MUXMESSAGE + +The £_messace struct has the format shown below. + +typedef struct message + +{ +struct message next; +UBYTE *status; +UINT type; // Message Number +HANDLE pid; +} E_MESSAGE; + + +The Message Number specified for each function below should be used as the type 1n an E_MESSAGE +struct, itself used as the mess field of a muxmEssacE struct. + + +Argument 1, Argument 2 and Argument 3 refer to the three muxmessace fields MessArg1, MessArg1 and +MessArgl. + + +For a full description of how to use these structs with the server function p_mreceive, see the chapter +Processes and Inter-Process Messaging in the PLIB Reference manual, and also the chapter Inter-Process +Communication in the OLIB Reference manual. + + +Unless specified below the argument values are unchanged when the function call returns. + + +Errors from IrLAP (returned in the status element of the z_messace struct) are documented in the IrDA +Serial Infrared Link Access Protocol (IrLAP) standard document. + + +LM_Logon Log on to the IrMUX server +Message Number 1 + + +Use this function call to log on to the IrMUX server. + + +LM_Logoff Log off from the IrMUX server +Message Number 2 + + +Use this function call to log off from the ITMUX server. This will stop any connections still held open by +the client. + + +LM_RegisterPort Register a port number with the LM-IAS server +Message Number 10 +Use this function call to register an application with the LM-IAS server. + + +The application name must be less than twenty five characters in length and zero terminated. + + +17-5 + + +1/0 DEVICES REFERENCE + + +Arguments + +Connection Handle Pointer to a vorp*; on return contains the LM- +IAS entry handle + +Argument 1 Pointer to a buffer containing the application +name + +Argument 2 Irrelevant + +Argument 3 The port number + +Value of status in the E_MESSAGE struct on return: + +OKAY Register successful + +E_GEN_NOMEMORY No memory to complete request + +E_GEN_RANGE Errors from IrLAP + +LM_UnRegisterPort Free registered port with LM-IAS server + + +Message Number 11 + + +Use this function call to free a registered port number with the LM-IAS server. + + +Arguments + +Connection Handle Entry handle + +Argument | Pointer to buffer containing class name +Argument 2 Irrelevant + +Argument 3 Irrelevant + +LM_CLReadRequest Queue a connectionless read request +Message Number 4 + + +Use this function call to queue a connectionless read request. + + +It should be noted that in the case of all reads, if a frame is received which is longer than the requested +data size the frame will be truncated and data will be lost. If a received frame is smaller than the length +requested the actual amount of data received will be placed into the urnt pointed to by argument2. + + +Arguments + +Connection Handle Irrelevant + +Argument | Pointer to a buffer to receive the data; on return +contains the received data + +Argument 2 Pointer to a uInT containing the number of +bytes required; on return the urnt contains the +actual amount of data returned + +Argument 3 Irrelevant + + +Value of status in the = _mMEeSSAGE Struct on return: + + +OKAY Read complete +E_GEN_INUSE Read already queued +E_MUX_ABORT IrMUX has been destroyed + + +17 - 6 + + +LM_CLWriteRequest +Message Number 5 + + +17 THE IRMUX API + + +Queue a connectionless write request + + +Use this function call to queue a connectionless write request. + + +Arguments +Connection Handle +Argument 1 +Argument 2 + + +Argument 3 + + +Value of status in the E_MESSAGE struct on return: + + +OKAY +E_GEN_NOMEMORY + + +(various) + + +LM_DiscoverDevicesRequest +Message Number 6 + + +Irrelevant +Pointer to a buffer containing the data to send; + + +Pointer to a uInT containing the number of +bytes to send + + +Irrelevant + + +Write successful +No memory to complete request + + +Errors from IrLAP + + +Return info on in-range machines + + +Use this function call to return information about machines within transmission range. + + +IrMUX will either instruct IrLAP to perform a discovery operation or will return the results of a previous + + +discovery. +Arguments +Connection Handle + + +Argument 1 + + +Argument 2 + + +Argument 3 + + +Value of status in the E_MESSAGE struct on return: + + +MUX_DISCOVERY_COMPLETE +MUX_CACHE_USED +E_GEN_NOMEMORY + + +E_MUX_ABORT + + +LM_ConnectRequest +Message Number 9 + + +Irrelevant + + +Pointer to a buffer of size at least +slots*sizeof (DISCOVERY_LOG) ; on return +contains the discovery log + + +Pointer toa urnT containing the number of +slots; on return contains the number of +discoveries + + +Irrelevant + + +Discovery complete +Results of previous discovery used +Could not complete request + + +IrMux has been destroyed + + +Attempt to connect to a remote machine + + +Use this function call to attempt to connect to a remote machine. Supplying a home Port number of -1 will +cause IrMUX to generate one for you. A remote port number of zero is used to connect to the remote LM- +IAS server. See the appropriate IrDA IrLAP document for details of the connect_stRuct and how to set + + +port numbers and other connection parameters. + + +17-7 + + +1/0 DEVICES REFERENCE + + +Arguments + +Connection Handle Pointer to a vorp* to receive the connection +handle on return + +Argument | Pointer to a CONNECT_STRUCT containing +connect parameters; on return the +CONNECT_STRUCT contains the actual connection +parameters + +Argument 2 Pointer to a buffer of 60 bytes of connection +data; on return the buffer contains connection +data from the other machine + +Argument 3 Irrelevant + + +Value of status in the E_MESSAGE struct on return: + + +OKAY Connection complete + +E_GEN_NSUP Unsupported parameters or port number + +E_GEN_INUSE Port number in use by another client + +E_MUX_BUSY A discovery is in process + +E_MUX_EXCLUSIVE Another connection already has exclusive +access to IrMUX + +E_GEN_NOMEMORY Insuffient Memory to make connection + +E_MUX_REMOTEDISCONNECT Remote forced disconnection + +E_MUX_TIMOUTDISCONNECT Forced disconnection, timout + +E_MUX_LOGOFFDISCONNECT Forced disconnection, client logoff + +E_MUX_USERDISCONNECT User cancelled connection + +E_MUX_LAP IrLAP cannot complete this request + +LM_WaitForConnection Wait for remote machine to connect + + +Message Number 8 + + +Use this function call to get a remote machine to wait for connection through a specified port number. + + +Arguments + +Connection Handle Pointer to vorp* to receive connection handle +on return + +Argument | Pointer to a CONNECT_STRUCT containing +connect parameters; on return the +CONNECT_STRUCT contains the actual connection +parameters + +Argument 2 Pointer to a buffer of 60 bytes of connection +data; on return the buffer contains connection +data from the other machine + +Argument 3 Irrelevant + + +17-8 + + +Value of status in the E_MEeSSAGE Struct on return: + + +OKAY + +E_GEN_NSUP + +E_GEN_INUSE +E_GEN_NOMEMORY +E_MUX_REMOTEDISCONNECT +E_MUX_TIMOUTDISCONNECT +E_MUX_LOGOFFDISCONNECT + + +E_MUX_USERDISCONNECT + + +LM_StatusRequest +Message Number 21 + + +17 THE IRMUX API + + +Connection complete + +Unsupported parameters or port number +Port number in use by another client +Insuffient memory to make connection +Remote forced disconnection + +Forced disconnection, timout + +Forced disconnection, client logoff + + +User cancelled connection + + +Return the status of the link + + +Use this function call to return the status of the link and where abouts IrLAP is holding un-ACKed data. + + +Arguments +Connection Handle + + +Argument 1 + + +Argument 2 + + +Argument 3 + + +Value of status in the E_MESSAGE struct on return: + + +OKAY + + +E_MUX_NOCONNECTION + + +LM_ReadRequest +Message Number 24 + + +Connection handle + + +Pointer to an rntT to hold the link quality on +return + + +Pointer to an int to hold the number of un- +ACKed frames on return + + +Irrelevant + + +Request complete + + +Connection handle invalid or connection +removed by other end + + +Queue a read request on a connection + + +Use this function call to queue a read request on a connection. + + +This function will panic the client process if a read is already queued on that connection. + + +Arguments +Connection Handle +Argument 1 +Argument 2 + + +Argument 3 + + +Connection handle +Pointer to a buffer to receive the data on return + + +Pointer to a uINT containing the number of +bytes required; on return the urnt contains the +amount of data returned + + +Irrelevant + + +17-9 + + +1/0 DEVICES REFERENCE + + +Value of status in the = _mMesSAGE Struct on return: + + +OKAY Read complete + +E_MUX_REMOTEDISCONNECT Remote forced disconnection + +E_MUX_TIMOUTDISCONNECT Forced disconnection, timout + +E_MUX_LOGOFFDISCONNECT Forced disconnection, client logoff + +E_MUX_USERDISCONNECT User cancelled connection + +E_MUX_NOCONNECTION Connection handle invalid or connection +removed by other end + +E_MUX_ABORT IrMUX has been destroyed + +LM_WriteRequest Queue a write request on a connection + +Message Number 25 + + +Use this function call to queue a write request on a connection. + + +The maximum length of a data frame that can be sent is returned as part of the connection +parameters from a connect request. Do not exceed this length. + + +Arguments + +Connection Handle Connection handle + +Argument | Pointer to a buffer containing the data to send + +Argument 2 Pointer to a uInT containing the number of +bytes to send + +Argument 3 TRUE if more data is to follow + + +Value of status in the = _mMesSAGE Struct on return: + + +OKAY Write successful +E_GEN_NOMEMORY No memory to complete request +E_MUX_NOCONNECTION Connection handle invalid or connection + + +removed by other end + + +(various) Errors from IrLAP +LM_UReadRequest Queue an unreliable read request +Message Number 26 + + +Use this function call to queue an unreliable read request on a connection. +In unreliable reading, data is sent only once. + + +This function will panic the client process if a read is already queued on that connection. + + +Arguments + +Connection Handle Connection handle + +Argument | Pointer to a buffer to receive the data on return + +Argument 2 Pointer to a urnT containing the number of +bytes required; on return the urnt contains the +actual amount of data returned + +Argument 3 Irrelevant + + +17 - 10 + + +17 THE IRMUX API + + +Value of status in the = _mMesSSAGE Struct on return: + + +OKAY Read complete + +E_MUX_REMOTEDISCONNECT Remote forced disconnection + +E_MUX_TIMOUTDISCONNECT Forced disconnection, timout + +E_MUX_LOGOFFDISCONNECT Forced disconnection, client logoff + +E_MUX_USERDISCONNECT User cancelled connection + +E_MUX_NOCONNECTION Connection handle invalid or connection +removed by other end + +E_MUX_ABORT IrMUX has been destroyed + +LM_UWriteRequest Queue an unreliable write request + +Message Number 27 + + +Use this function call to queue an unreliable write request on a connection. + + +In unreliable writing, data is sent only once. + + +Arguments + +Connection Handle Connection handle + +Argument | Pointer to a buffer containing the data to send + +Argument 2 Pointer to a uInT containing the number of +bytes to send + +Argument 3 TRUE if more data to follow + + +Value of status in the = _MESSAGE Struct on return: + + +OKAY Write successful +E_GEN_NOMEMORY No memory to complete request +E_MUX_NOCONNECTION Connection handle invalid or connection + + +removed by other end + + +(various) Errors from IrLAP +LM_AccessModeRequest Obtain/release exclusive access +Message Number 22 + + +Use this function call to obtain/release exclusive access to ITMUX. + + +Arguments + +Connection Handle Connection handle + +Argument 1 LM_ExclusiveMode to obtain exclusive access or +LM_Mult iplexMode to release exclusive access +to IrMUX + +Argument 2 Irrelevant + +Argument 3 Irrelevant + + +17-11 + + +1/0 DEVICES REFERENCE + + +Value of status in the = _MESSAGE Struct on return: + + +OKAY Request complete + +E_GEN_MEMORY Not enough memory to complete the request + +E_GEN_INUSE Unable to enter exclusive mode + +E_MUX_BUSY Another client is attempting to enter exclusive +mode + +E_MUX_EXCLUSIVE Another client already has exclusive access + +E_MUX_NOCONNECTION Connection handle invalid or connection +removed by other end + +E_MUX_ABORT IrMUX is being destroyed + +E_GEN_NSUP Argument | does not contain either + + +LM_ExclusiveMode Of LM_MultiplexMode + + +E_MUX_REMOTEDISCONNECT Remote forced disconnection +E_MUX_TIMOUTDISCONNECT Forced disconnection, timout +E_MUX_LOGOFFDISCONNECT Forced disconnection, client logoff +E_MUX_USERDISCONNECT User cancelled connection +LM_IdleRequest Place the connection into Idle/Active mode +Message Number 23 + + +Use this function call to place the connection into Idle/Active mode. + + +This implementation does not follow the IrMUX specification in that communication can be carried out in +both Active and Idle modes. Being in active mode simply acts as a block to other clients placing IIMUX +into Exclusive mode. + + +A connection always starts in Idle mode. To stop other clients gaining exclusive access to I1MUX by +entering Active mode, a client must put its own connection into Active mode. It is recommend that Active +mode is only used during critical periods of data communication. + + +Arguments + +Connection Handle Connection handle + +Argument 1 Irrelevant + +Argument 2 Irrelevant + +Argument 3 TRUE for Idle mode, ratse for Active mode + + +Value of status in the E_MESSAGE struct on return: + + +OKAY Mode change successful +E_MUX_BUSY Connection busy +E_MUX_NOCONNECTION Connection handle invalid or connection + + +removed by other end + + +LM_SetHandshakingLevel Set retries on each data frame +Message Number 28. + + +Use this function call to set the number of retries on each data frame, if the client application is not +responding to incoming data quickly enough. + + +This should only be enabled when in Exclusive mode. When use of exclusive mode has finished +LM_SetHandshakingLevel should be used to reset the number of retries to 1. + + +17 - 12 + + +Arguments +Connection Handle +Argument 1 +Argument 2 +Argument 3 + + +LM_DisconnectRequest +Message Number 20 + + +17 THE IRMUX API + + +Connection handle +Irrelevant +Irrelevant + + +The number of times to resend each frame, +0 (zero) for inactive. + + +Disconnect + + +Use this function call to disconnect. This will cancel any requests on the connection. + + +Arguments + +Connection Handle + +Argument 1 + +Argument 2 + +Argument 3 + +Value of status in the = _mMEesSSAGE Struct on return: +OKAY + + +E_MUX_NOCONNECTION + + +E_MUX_BUSY + + +Connection handle +Irrelevant +Irrelevant + + +Irrelevant + + +Disconnect complete + + +Connection handle invalid or connection +removed by other end + + +IrMUX is busy. The application shoul wait a +short time and try again. May be ignored if +logging off. + + +17 - 13 + + +CHAPTER 18 + + +FAST CHARGER + + +Introduction + + +This chapter describes Fast Charger services for the HC and Workabout docking stations. + + +In this document the term ‘Docking Station’ refers both to the HC docking station, (which connects to an +HC LIF interface fitted to the bottom of the HC), and to the Workabout docking station. The term +‘computer’ refers to an HC or Workabout. + + +Docking Station services + + +There are two variants of the docking station: one model has been designed for the HC computer and one +model has been designed for the Workabout computer. The docking station may be used to fast charge the +battery inside the "docked" computer. + + +The docking station Fcc: device driver may be used to charge (or discharge) the main battery under the +direct control of an HC/Workabout computer which has been inserted in the docking station holster. The +device driver may also be used to supply that computer with information about the battery charge status. + + +Notes: +1. the HC/Workabout docking station expansion port cannot be used whilst using the (Fcc:). + + +2. the HC/Workabout docking station will charge batteries without any external software +control from a docked computer. + + +See also the Cradle and Docking Station chapter for details of the cradle device driver crp:. + + +Using the Docking Station +Use of the Docking Station is complicated by the fact that one high speed serial channel is used to +communicate to three possible interfaces. + +1. The interface in the bottom of the HC (1.e. Barcode, RS232 etc.) + +2. The electronics in the device + +3. Any expansion fitted to the device. + + +As a result of this, only one interface at a time can be opened on this channel, 1.e. either the RS232 in the +HC bottom expansion (port TTY:B) or the RS232 in the Docking Station expansion slot (port TTY:C). + + +HC/Workabout docking station fast charger services + + +The Fcc: device driver will allow a C application running on a machine in the docking station holster to +monitor and control the state of the docking station fast charger circuitry. The docking station is capable +of charging , discharging and performing a capacity check of the main battery inside the computer in a +variety of operating modes. It may also be used to charge (but not discharge) a spare battery installed in +the spare battery compartment of the docking station. + + +Important note: the fast charger circuit in the docking station will charge batteries automatically without +requiring any explicit calls to the rcc: device driver; only in a few circumstances should it actually be + + +18-1 + + +I/O DEVICES REFERENCE + + +necessary to use FCG: (as described in this chapter) to give implicit instructions to the docking station. In +normal circumstances, it is not necessary to run software on the SIBO machine to control or monitor the +battery charging/discharging process. + + +There are two variants of the fast charger device driver, where each driver is tailored for use with one +specific SIBO computer and docking station. The fast charger device driver which may be used with an +HC computer is called sys$chgh.ldd; the fast charger device driver which may be used with a Workabout +computer is called sys$fchg.ldd. Both device drivers may be found in the path \sibosdk\lib\ on installation +of the relevant SIBO C Software Development Kit optional components onto your PC (from the /dd.zip +file). + + +The library file fcharge.h (located in the path \sibosdk\include\) contains C constant declarations which +may be used with either the sys$chgh.ldd or the sys$fchg.ldd device driver. + + +The fast charger does not allow a direct measurement of the status of each battery. As a result, the Fcc: +device drive will determine the status of each battery indirectly by measuring the charge pulses applied +by the charger circuitry to the battery pack over a short period of time. For this reason, some of the Fcc: +I/O operations may take a number of seconds to complete. + + +The fast charger device driver will only run if the Psion computer is resting in the docking station holster. + + +Fast charging batteries + + +The docking station may be used to charge the battery inside the "docked" computer, or a battery located +in the spare battery compartment on the top of the docking station. Only one battery pack can be charged +at any one time. + + +The fast charge circuitry possesses four modes of charging: + + +fast charge charge the battery pack with a preset current, and for a preset charge period (or +shorter, depending upon the charge status of the battery). + + +top off the battery pack is now 90-95% fully-charged; supply a lower current (typically C/10) +after completion of the fast charge, to fully-charge the cells + + +trickle charge supply a small charge current (typically C/30) to maintain the charge in a fully- +charged battery pack + + +discharge discharge the main battery at a fixed discharge current + + +If you wish to control the fast charger explicitly from a C program running on the "docked" Psion +computer, then the program should carry out the following steps: + + +1. open a channel to the fast charger device driver with the call p_open(voID **ppcb, +"PCG:A",-1); + + +2. set up the charge current and maximum charging time period with a call to +FCHG_SETCHARGEMODE (if this step is omitted, then default settings will be used). + + +3. instruct the device driver to charge the main battery (or the spare battery) with +FCHG_FASTCHARGEx. This command will commence the charging of the battery at a default +current and over a default time period. + + +4. close the channel to Fcc: with p_close (VOID *pcb) + + +Whilst the Fcc: channel is open, the C program may also monitor the progress of the charging process, if +required. Calls to FCHG_FASTCHARGEx may be omitted if the C program wishes only to monitor the progress +of the charging process. + + +The maximum charge time period set with a FCHG_SETCHARGEMODE call is used as a backup safety feature +to ensure that the fast charging process terminates before any damage can occur to the battery pack. For +this reason, it is essential that the charge time is set correctly, in relation to the charge rate which +you wish to use. The two main terminators used by the fast charge circuitry to detect the end of the +charging process are voltage and temperature slope. These two terminators are managed by the fast +charger hardware. + + +IMPORTANT: Never charge a standard Psion battery pack with a charge rate that exceeds 1C + + +without first contacting the battery supplier for advice. High charge rates in excess of 1C will +reduce the life of the battery pack and may create a risk of explosion or fire. + + +18 -2 + + +18 FAST CHARGER + + +Measuring battery capacity + + +The Fcc: device driver may be used to determine the charge capacity of a battery pack. If the time taken to +fully-discharge a fully-charged battery pack is measured, then the relative battery charge capacity may be +determined from the following equation: + + +M=(10* T, *I-)/(*C,) +where: +e M-= the reduction in battery charge capacity of the battery under test (%) +e Ty, = measured discharge time (minutes) +e I. =discharge current (mA) +e C, =rated battery capacity of battery under test (mAh) + + +Rated charge capacity of standard Psion battery packs + + +The rated charge capacity for the standard Psion HC and Workabout battery packs is displayed in the +table below. This table also contains the standard discharge time and the standard discharge current for +each variant of the docking station. . + + +Docking station Rated capacity C; (mAh) Discharge time T,, (mins) Discharge current I, + + +(mA) +HC 650 130 300 +Workabout 845 175 290 + + +Example calculations + + +Example 1: If a fully-charged HC battery pack takes 100 minutes to discharge, at the (fixed) discharge +current of 300mA, then the measured capacity of that HC battery pack is 77%. + + +ie. M= (10 * T,)* 1,)/ (6 * C. ) = (10 * 100 * 300) / (6 * 650) = 77% + + +Example 2: If a fully-charged Workabout battery pack takes 120 minutes to discharge, at the (fixed) +discharge current of 290mA, then the measured capacity of that Workabout battery pack is 69%, + + +Le. M=(10 * 120 * 290) / (6 * 845) = 69% + + +The charge capacity of custom batteries may also be determined using the same equation. Care must be +taken to use the correct value of I, in the equation, where I, is defined by the docking station variant that +is being used to discharge the custom battery pack. + + +p_open(FCG:A) Open the fast charger device +INT p_open(VOID **ppcb,"FCG:A",-1); +Open a channel to the docking station fast charger device. + + +Returns zero if the device is opened successfully, otherwise a negative error. The p_open operation will +fail if the docking station is not present. + + +If the channel is opened successsfully, the charging current and charging time will be preset to the default +settings. The device driver will then immediately begin polling the status of the battery. This polling +operation may take up to forty seconds to complete. + + +Errors include: + + +E_GEN_NOMEMORY failed to allocate memory for control block +E_FILE_LOCKED port is already open + +E_GEN_INUSE port in use + +E_FILE_DEVICE device does not exist + + +1/0 DEVICES REFERENCE + + +p_close Close the channel +INT p_close (VOID *pcb) ; + +Close the fast charger device channel. + +Any outstanding FCHG_xxx operations will be cancelled by p_close. + + +Returns zero. + + +FCHG_SETCHARGEMODE Set battery charge mode + + +#include “fcharge.h” +INT p_iow(VOID *pcb,FCHG_SETCHARGEMODE, WORD *pmode) ; + + +Set the charge current and the maximum charging time period. + +Two pieces of information must be passed to the docking station fast charger circuitry (in pmode): +e the current which will be used to charge the battery +e the maximum period of time which the battery will be charged. + + +The contents of pmode should contain a value which is constructed from two integers. The three least +significant bits in pmode should identify the charge time period; the four most significant bits in pmode +should identify the charge current. (The present charge mode may be read by calling the +FCHG_READCHARGEMODE function.) + + +This information may be selected from the fixed options that are supported by the docking station. The +minimum charging current that one could select should not be less than a quarter of the battery capacity +(unless the battery pack is known to be already partially charged). + + +Example: The capacity of the standard Workabout battery is 850mA. The minimum charging current that +one could use is 0.25 X 850 = 212mA (approx. 200mA = FcHG_ccLow2). + + +Please refer to the tables below for information about the discrete charge currents which may be supplied +by the docking station. This table also contains the names of the C constants, defined in fcharge.h, that +are associated with each charge current setting for the docking station. + + +Charging Psion battery packs + + +The following tables display suggested combinations of charge current and charge times that are suitable +for the standard Psion HC and Workabout battery packs: + + +Charge period Charge current for standard Charge current for standard +Psion HC battery pack Psion Workabout battery pack + +1C 700mA 850mA + +C/2 350mA 500mA + +C/4 175mA 200mA + + +The above charge period/charge currents correspond to the following C constants in fcharge.h: + + +Charge period Charge current for standard Charge current for standard +Psion HC battery pack Psion Workabout battery pack + +FCH_CTIME1C FCHG_DEFAULTCC FCHG_DEFAULTCC + +FCH_CTIMEC2 FCH_CC350mA FCH_CC500mA + +FCH_CTIMEC4 FCH_CCLOW2 FCH_CCLOW2 + + +High charging currents should only be selected in situations where special, high capacity, fast charge +battery packs are being used. Lower charging currents are recommended in circumstances where the +ambient temperature is above 35°C, or where lower capacity battery packs are used. + + +The minimum charging current that may be selected should not be less than a quarter of the battery +capacity (unless the battery pack is known to be already partially-charged). Incorrect settings will result in +under-charge or damage to batteries. + + +18-4 + + +18 FAST CHARGER + + +Charging custom battery packs + + +The docking station may also be used to charge custom battery packs with different charge-current +requirements. + + +The fast charger device driver and docking station support the following charge times: + + +Charge period Jfcharge.h constant Maximum charge period (minutes) +2C FCHG_CTIME2C 45 + +1C FCHG_CTIME1C 90 + +C/2 FCHG_CTIMEC2 180 + +C/4 FCHG_CTIMEC4 360 + + +The fast charger device driver and docking station support the following charge currents: + + +fcharge.h constant HC docking station current Workabout docking station current +FCHG_CCLOW1 100mA 130mA +FCHG_CCLOW2 175mA 200mA +FCHG_CC350mA 350mA 350mA +FCHG_CC500mA 500mA 500mA +FCHG_CC650mA 650mA 650mA +FCHG_DEFAULTCC 700mA 850mA +FCHG_CC850mA 850mA 850mA +FCHG_CC1000mA 1A 1A +FCHG_CC1100mA LIA LIA +FCHG_CCHIGH1 1.2A 1.3A +FCHG_CCHIGH2 1.4A 1.5A + + +IMPORTANT: Never charge a standard Psion battery pack with a charge rate that exceeds 1C + + +without first contacting the battery supplier for advice. High charge rates in excess of 1C will +reduce the life of the battery pack and may create a risk of explosion or fire. + + +Notes: + + +1. The standard power supply that is provided with the Workabout docking cradle has a +maximum current rating of 1A. As a result, battery charge currents in excess of 850 mA +cannot be supported by the standard power supply provided with the docking station. + + +If you wish to fast charge batteries using currents greater than 850 mA, a 2A power supply +must be used with the Workabout docking station. Suitable power supplies are available +from Psion; for further details please contact the Psion Sales staff. + + +The HC docking station is provided with a 2A power supply and hence is capable of +handling the entire charge current range supported by the device driver. + + +2. Charging currents below or equal to 200mA have a tolerance of + 30% and +currents greater then 300mA have a tolerance of + 15%. + + +18-5 + + +I/O DEVICES REFERENCE + + +FCHG_READCHARGEMODE Read battery charge mode + + +#include “fcharge.h” +INT p_iow(VOID *pcb,FCHG_READCHARGEMODE,WORD *pmode) ; + + +Read the charge current and the maximum charging time period settings. +The present charge rate and the required charging period will be returned to pmode. + + +The contents of pmode will contain a value which is constructed from two integers. The three least +significant bits in pmode will identify the charge time period; the four most significant bits in pmode will +identify the charge current. The charge mode may be altered by calling the FcHc_SETCHARGEMODE function. + + +The table that appears in the FcHG_SETCHARGEMODE section (above) contains all of the valid combinations +of charge current/charge period settings for HC and Workabout machines. + + +Zero is returned if the FcHG_SETCHARGEMODE request completed successfully, or a negative value if an error +has occurred. + + +FCHG_READSTATUS Read the battery status + + +#include “fcharge.h” +INT p_iow(VOID *pcb, FCHG_READSTATUS,WORD *pstatel,WORD *pstate2); + + +Read the present charge status of each battery from the docking station device, writing the new charge +states to pstatel and pstate2. + + +The status of the main battery inside the computer held in the holster is returned in pst ate1; if a spare +battery has been inserted in the spare battery compartment of the docking station, then the status of this +battery will be returned to pstate2. + + +On completion, pstate1 and pstate2 may contain one of the following integer values: +FCHG_UNKNOWN the battery is in an unknown state + + +FCHG_NOTCHARGING the battery is not charging. +If the docking station has been instructed to discharge the main battery, then +FCHG_READSTATUS will return a FCHG_NOTCHARGING value to indicate that the +battery is indeed being discharged + + +FCHG_FASTCHARGING The battery is fast charging + + +FCHG_TOPPINGOFF The battery is now charged to 90-95% of its maximum capacity and it is now +being topped off by the fast charger circuitry + + +FCHG_TRICKLE The battery is being trickle charged + + +The Fcc: device driver calculates the present charge status of a battery by measuring the duration of +charge pulses that the battery receives from the docking station. A charge pulse from the docking station +may last 40 seconds; as a result, it is possible that a call to FcHc_READSTATUS may not be able to determine +the present charge status of a battery at the precise moment in time when the call is made. + + +In this situation, a FCHG_UNKNowN status message will be returned for the status of that battery. This does +not mean that the battery charge status is indeterminate; another FCHG_READSTATUS call in the future may, +however, be able to return a valid status value for the charge status of that battery. + + +Zero is returned if the FcHG_READSTATUS request completed successfully, or a negative value if an error has +occurred. + + +18 - 6 + + +18 FAST CHARGER + + +FCHG_ASYNCHREAD Read the battery status asynchronously + + +#include “fcharge.h” +INT p_ioc(VOID *pcb,FCHG_ASYNCHREAD, WORD *pstatel,WORD *pstate2); + + +Read the present charge status of each battery from the docking station device asynchronously, writing the +new charge states to pstate1 and pstate2 when the charge status of either battery alters. + + +The rFcHG_ASYNCHREAD operation may be cancelled at any time by a call to FcHG_CANCEL. + + +FCHG_ASYNCHREAD Will return immediately after initiating a request to receive battery status information +when the status of either battery changes. At some time in the future, the new status of the main battery +inside the computer in the holster will be returned in pstate1; if a spare battery has been fitted inside the +compartment in the top of the docking station, then the status of this battery will be returned to pstate2. + + +Panics if pcb is not a valid channel handle, or if an FcHG_ASYNCHREAD operation is outstanding. + + +Returns zero if the rcHG_ASYNCHREAD request completed successfully, or a negative value if an error has +occurred. + + +FCHG_CANCEL Cancel an asynchronous read + + +#include “fcharge.h” +INT p_iow(VOID *pcb,FCHG_CANCEL) ; + + +Cancel any outstanding rcHG_ASYNCHREAD request. Performing a cancel is harmless if no read request is +outstanding. + + +Returns zero. + + +FCHG_FASTCHARGE1 Fast charge the main battery + + +#include “fcharge.h” +INT p_iow(VOID *pcb, FCHG_FASTCHARGE1) ; + + +Begin fast charging the main battery that is inside the computer fitted to the docking station holster. + + +The present settings for the charge current and charge time period (as set by p_open or +FCHG_SETCHARGEMODE) will be used by the fast charger circuitry to charge the battery. + + +FCHG_FASTCHARGE1 will return zero if it completes successfully, or a negative value if an error occurs. + + +Please note: only one battery may be charged at any one time; 1.e. the main battery cannot be charged +while a battery in the spare battery compartment is being charged. + + +If you wish to charge the main battery and the spare battery, then the software which calls rce: should +charge one battery, sense when that battery is charged sufficiently, and then charge the second battery. + + +FCHG_FASTCHARGE2 Fast charge the spare battery + + +#include “fcharge.h” +INT p_iow(VOID *pcb, FCHG_FASTCHARGEZ2) ; + + +Begin fast charging the battery that is in the spare battery compartment of the docking station. + + +The present settings for the charge current and charge time period (as set by p_open or +FCHG_SETCHARGEMODE) will be used by the fast charger circuitry to charge the battery. + + +FCHG_FASTCHARGE2 will return zero if it completes successfully, or a negative value if an error occurs. + + +Please note: only one battery may be charged at any one time; i.e. a battery in the spare battery +compartment cannot be charged while the main battery is being charged. + + +If you wish to charge the main battery and the spare battery, then the software which calls rce: should +charge one battery, sense when that battery is charged sufficiently, and then charge the second battery. + + +Note: if the main battery is charging and the spare battery is waiting, then the rcuc_FASTCHARGE2 function +will over-ride the status of the main battery and start charging the spare battery instead. + + +18 -7 + + +I/O DEVICES REFERENCE + + +FCHG_DISCHARGE1 Discharge the main battery + + +#include “fcharge.h” +INT p_iow(VOID *pcb, FCHG_DISCHARGE1) ; + + +Begin discharging the main battery fitted inside the computer fitted to the docking station holster. + + +The FCHG_DISCHARGE1 command will initiate a sequence of operations which will take a few seconds to +complete. If any additional calls are made to Fcc: in this period, those commands will return a negative +completion code and the instructions will be ignored. + + +The discharging current is fixed by the fast charger circuitry and may therefore not be altered by software. +The discharge current for the HC docking station is set to 300 mA +3%. The discharge current for the +Workabout docking station is set to 290 mA +3%. + + +FCHG_DISCHARGE1 will return zero if it completes successfully, or a negative value if an error occurs. +Notes: + + +1. when the docking station has been instructed to discharge a battery, subsequent +FCHG_READSTATUS operations will each return a FCHG_NOTCHARGING status code - which +should be interpreted as meaning that the battery is discharging (as expected). + + +2. The spare battery cannot be discharged by Fce:. + + +Example program + + +An example C application may be found in the file path \sibosdk\wkdemo\, on installation of this SDK +onto your PC. + + +charger.c is a Workabout computer program which monitors and controls the fast charger circuitry in the +docking station. This program allows the main battery, or spare battery to be charged, or the main battery +to be discharged, and the status of both batteries to be monitored. + + +Note: This program will only run if the Workabout computer has been placed into the holster of a docking +station. + + +/* Fastcharger for Workabout */ +/* Example application */ +/* (C) Copyright Psion Software PLC 1997 */ + + +include +include +include +include +include + + +include "fcharge.h" + + +GLREF_D VOID *winHandle; + + +LOCAL_C VOID State(WORD Val) + + +switch (Val) +{ + +case 0: +p_printf(" Unknown") ; +break; + +case l: +p_printf(" Not Charging") ; +break; + +case 2: +p_printf(" Fast Charging"); +break; + +case 3: +p printf (" Topping Off"); +break; + +default: +p_printf(" Trickle"); + + +18-8 + + +GLDEF_C VOID main(VOID) + + +/* + + +{ +VOID *pcb; +WORD One, OldOne; +WORD Two, OldTwo; +WORD KStat,Disch; +WORD LogOne[100]; +WORD LogTwo[100]; +WORD P1=0,P2=0, Temp; +ULONG TTime; +P_CON_KBREC Key; +TEXT X1Str[1l]; +WORD X1=0; +ULONG XE=0,DischTime; +TEXT *X1Ptr; +INT Item; +for (Item=0; Item<100; Item++) +{ +LogOne [Item] =0; +LogTwo [Item] =0; +} + + +p_devdel ("FCG",E_LDD) ; + +p_printf ("Loading"); + +if (p_loadldd("m:\\sys$fchg.1dd") <0) +p_panic(0); + +p_printf ("Opening test"); + +if (p_open (&pcb, "FCG:A",-1) <0) +p_panic(1); + +p_printf ("Closing test"); + +if (p_close (pcb) <0) +p_panic(2); + +p_printf ("Opening test part II"); + +if (p_open (&pcb, "FCG:A",-1) <0) +p_panic (3); + +p_printf ("Cant remove test"); + +if (p_devdel ("FCG:",E_LDD) >=0) +p_panic(4); + +p_printf ("Setting the charge Mode"); + + +p_iow (pcb, P_FCHG_READCHARGEMODE, &One) ; +if (One!=(P_FCHG_DEFAULTCC | P_FCHG_CTIME1C) ) + + +p_panic(5); +p_printf ("Test the charge Mode"); + + +if (p_iow (pcb, P_FCHG_SETCHARGEMODE, &One) !=0) + + +p_panic(6); +p_printf("Set Rubbish charge Mode"); +One=-1; + + +if (p_iow (pcb, P_FCHG_SETCHARGEMODE, &One) ==0) + + +p_panic(7); + + +p_iow (pcb, P_FCHG_READSTATUS, &One, &Two) ; + + +p_print ("Battery one:"); +State (One) ; +p_print ("Battery two:"); +State (Two) ; + + +p_printf("Asynch test1"); + + +p_iow (pcb, P_FCHG_ASYNCHREAD, &One, &Two) ; + + +p_print ("Battery one:"); +State (One) ; +p_print ("Battery two:"); +State (Two) ; +p_printf("Asynch test2"); + + +p_iow (pcb, P_FCHG_ASYNCHREAD, &One, &Two) ; + + +p_print ("Battery one:"); +State (One) ; + +p_print ("Battery two:"); +State (Two) ;* + + +18 FAST CHARGER + + +18-9 + + +1/0 DEVICES REFERENCE + + +18 - 10 + + +p_ioc4 (winHandle, P_FREAD, &KStat, &Key) ; +TTime=p_date(); +Disch=0; +DischTime=0; +FOREVER +{ + + +if (KStat!=E_FILE_PENDING) /* Was it the keyboard */ + + +{ + + +p_iowait(); /* not really the way to do this -oh well */ + + +if (Key.keycode=='Q' | | Key. keycode=='q' +p_exit (0); + + +|| Key.keycode==27) + + +else if (Key.keycode=='D' | | Key. keycode=='d"') + + +{ + +p_printf ("Start discharge"); + +TIime=p_date(); + +if (p_iow(pcb,P_FCHG_DISCHARGE) ) +p_panic(8); + +Disch=1; + +} + + +else if (Key.keycode=='F' || Key.keycode=='f') + + +p_printf("Start Fastchargel") ; +TTime=p_date(); + +if (p_iow(pcb,P_FCHG_FASTCHARGE1) ) +p_panic (9); + + +else if (Key. keycode=='G' | | Key. keycode=='g') + + +p_printf("Start Fastcharge2") ; +TTime=p_date(); + +if (p_iow(pcb,P_FCHG_FASTCHARGEZ2) ) +p_panic(9); + + +else if (Key. keycode=='C'! | | Key. keycode=='c"') + + +p_getl("Current: ",&X1Str[0],10); +X1Ptr=&X1Str[0]; +p_stoi(&X1Ptr,&X1); + +} + + +else if (Key.keycode=='/' | | Key. keycode=='?') + + +{ +if (Disch==1) + + +p_printf("Discharging: %d", (p_date()-TTime) ); + + +else + + +{ + + +p_printf("Discharge Time: %d1",DischTime) ; + + +if (X1>0 && DischTime>0) +{ +XE= (850*60*60*10) /X1; +XE= (DischTime*100*10) /XE; + + +p_printf("Capacity (Cell) %d%%", (UWORD) (XE) ); + + +} + + +} + + +else if (Key. keycode=='1') +{ +p_printf("Battery one Log"); +Temp=0; +while (Temp0) +State (LogOne[Temp-1]); +} +else if (Key. keycode=='2') +{ +p_printf ("Battery two Log"); +Temp=0; +while (Temp0) +State (LogTwo[Temp-1]); + + +18 FAST CHARGER + + +else if (Key.keycode=='H' | | Key.keycode=="'h' | | Key. keycode==290 | | +Key. keycode==291) +{ +p_printf£(""); +p_printf("C...Enter Discharge current"); +p_printf("D...Start Discharge"); +p_printf("F...Fastcharge Batteryl"); +p_printf("G...Fastcharge Battery2"); +p_printf("?...Show Discharge time"); +p_printf("1...Show Batteryl Log"); +p_printf("2...Show Battery2 Log"); +poipraent ft ((C"On-. 2QUrt™): 3. +p_printf£(""); +} +p_ioc4 (winHandle, P_FREAD, &KStat, &Key) ; +} +OldOne=One; +OldTwo=Two; +p_iow (pcb, P_FCHG_READSTATUS, &One, &Two) ; +if (OldOne!=One || OldTwo!=Two) +{ +if (OldOne==1 && Disch==1 && One!=1) +{ +Disch=0; +DischTime=(p_date()-TTime) ; +p_printf ("Discharge Time: %d",DischTime) ; +} +p_printf("Time: %d", (p_date()-TTime) ); +if (One!=O0ldOne) +{ +if (P1>50) +P1=0; +LogOne [P1++]=One; +} + + +if (Two!=OldTwo) + +{ + +if (P2>50) + +P2=0; + +LogTwo [P2++]=Two; + +} +p_print ("Battery one:"); +State (One) ; +p_print ("Battery two:"); +State (Two) ; +} + + +18 - 11 + + +INDEX + + +.wve files + +digital sound files, 5-1 +A_FTIMED + +alarm device, 6-2 +A_FTIMED_X + +alarm device, 6-3 +A_FUNTIMED + +alarm device, 6-3 +A_FUNTIMED_X + +alarm device, 6-4 +AccessIr + +infrared API, 16-1 +AccessIr API + +infrared, 15-4 +AIR: + +infrared device, 15-4, 16-1, 16-2 + +loading on Siena, 16-1 +alarm + +device I/O introduction, 6-1 + +note sequence SND: device, 5-3 +alarm device + +A_FTIMED, 6-2 + +A_FTIMED_X, 6-3 + +A_FUNTIMED, 6-3 + +A_FUNTIMED_X, 6-4 + +ALM: introduction, 6-1 + +p_close, 6-2 + +P_FCANCEL, 6-2 + +p_open(ALM:), 6-2 + +panics, 6-2 + +services additional S3a, 6-3 + +services $3 S3a & MC, 6-2 +alarm services + +time application $3 S3a, 6-2 +ALM: device + +introduction, 6-1 + +see alarm device, 6-1 +asynchronous + +I/O functions, 1-1 +bar code + +Codabar start and stop characters, 14-5 + +maximum scanning rate, 14-4 + +supplement digits, 14-4 +bar code command syntax + +HC bar code/RS232 module, 14-11 +bar code commands + +HC bar code/RS232 module, 14-11 +bar code formats UPC/EAN + +HC bar code/RS232 module, 14-6 +bar code interface + +comms settings, 14-2 + +HC bar code/RS232 module, 14-3 + + +bar code symbologies +HC bar code/RS232 module, 14-4 +bar code wand connector +HC bar code/RS232 module, 14-2 +BAR: device +see HC bar code reader, 13-1 +battery capacity +docking station fast charger, 18-3 +HC, 18-3 +Workabout, 18-3 +baud rates +infrared, 15-3 +beaming +infrared communications application, +15-6 +bottom slot +HC bar code/RS232 module, 14-2 +CLIB +programs CON: device use of, 2-1 +Codabar +start and stop characters, 14-5 +communications +infrared application, 15-6 +CON: device +automatic opening, 2-1 +CLIB based programs, 2-1 +example code, 2-14 +explicit opening, 2-3 +handle of, 2-2 +introduction, 2-1 +OPL programs, 2-1 +PLIB based programs, 2-2 +see console device, 2-1 +Condor chip +serial infrared, 15-3 +connection +second time (LM-IAS server) +infrared, 17-4 +connection first time (LM-IAS server) +infrared, 17-4 +connectionless calls +infrared, 17-3 +connectionless read request +infrared, 17-3 +connectionless write request +infrared, 17-3 +connection-oriented calls +infrared, 17-3 +console device +automatic opening of CON: device, 2-1 +example code, 2-14 +explicit opening of CON: device, 2-3 +handle of, 2-2 +I/O, 2-1 +p_close, 2-4 +P_EVENT_READ, 2-9 +P_EVENT_TEST, 2-10 +P_FCANCEL, 2-5 +P_FEDIT, 2-6 +P_FFLUSH, 2-6 +P_FINQ, 2-10 +P_FREAD, 2-5 +P_FSENSE, 2-6 + + +1/0 DEVICES REFERENCE + + +P_FSET service call convention, 2-3 +P_FTEST, 2-5 +P_FWFLUSH, 2-10 +p_open(CON:), 2-3 +P_SCR_ATTRB, 2-11 +P_SCR_CANCEL_CAPTURE_KEY, +2-13 +P_SCR_CAPTURE KEY, 2-13 +P_SCR_CLIENT_FOREGROUND, 2-12 +P_SCR_CLR, 2-7 +P_SCR_COMPATIBILITY, 2-9 +P_SCR_CSET, 2-10 +P_SCR_CURSOR, 2-8 +P_SCR_DISABLE_READS, 2-12 +P_SCR_ESCAPE, 2-9 +P_SCR_FLUSH, 2-12 +P_SCR_FONT, 2-11 +P_SCR_GREY, 2-9 +P_SCR_LAST_LINE_WRAP, 2-12 +P_SCR_NEL, 2-8 +P_SCR_POSA, 2-8 +P_SCR_POSR, 2-8 +P_SCR_SCROLL, 2-7 +P_SCR_SLOCK, 2-8 +P_SCR_WLOCK, 2-8 +P_SCR_WSET, 2-7 +p_write, 2-4 +panics, 2-3 +services, 2-3 +services additional, 2-9 +cradle device +introduction, 11-1 +introduction HC, 11-1 +p_close(CRD:), 11-2 +P_FCANCEL, 11-2 +P_FREAD, 11-2 +P_FSENSE, 11-2 +P_FSET, 11-2 +p_open(CRD:), 11-1 +services, 11-1 +CRC +XYmodem device, 9-1 +CRD: device +introduction, 11-1 +see cradle device, 11-1 +services, 11-1 +data transfer +link I/O, 10-1 +database +world application services $3 S3a, 8-2 +device driver +FCG: docking station, 18-2 +infrared accessir.ldd, 16-1 +serial port LDD, 4-1 +serial port PDD, 4-1 +Siena infrared printing, 15-7 +devices +AJR: infrared, 15-4, 16-1, 16-2 +alarm I/O introduction, 6-1 +ALM: introduction, 6-1 +BAR: introduction, 13-1 +CON: introduction, 2-1 +console I/O, 2-1 + + +ii + + +CRD: introduction, 11-1 +FCG: docking station, 18-1 +FRC: I/O introduction, 7-1 +FRC: introduction, 7-1 +HC bar code reader I/O introduction, 13-1 +HC bar code/RS232 module, 14-1 +HC cradle I/O introduction, 11-1 +HC docking station I/O introduction, 11-1 +HC intelligent bar code Reader, 14-1 +HC magnetic card reader I/O, 12-1 +I/O introduction, 1-1 +I/O Introduction, 1-1 +IRP: infrared printing, 15-7 +MCR: introduction, 12-1 +NCP I/O introduction, 10-1 +PAR: introduction, 3-1 +parallel port I/O, 3-1 +serial port I/O introduction, 4-1 +SIR: infrared, 15-2, 15-3 +SND: introduction, 5-1 +sound I/O introduction, 5-1 +TTY: introduction, 4-1 +WLD: introduction, 8-1 +Workabout docking station I/O +introduction, 11-1 +world database I/O introduction, 8-1 +XMD: introduction, 9-1 +Xmodem I/O introduction, 9-1 +Ymodem I/O introduction, 9-1 +dial tones +sound device DTMF, 5-4 +disconnecting first time (LM-IAS server) +infrared, 17-4 +disconnecting second time +infrared, 17-4 +discovery +infrared, 15-5, 17-4 +DISCOVERY_LOG +structure infrared, 15-5 +docking station +battery capacity calculations, 18-3 +device introduction HC, 11-1 +device introduction Workabout, 11-1 +fast charger, 18-1 +FCG: device, 18-1 +FCG: device driver, 18-2 +FCHG_ASYNCHREAD, 18-7 +FCHG_CANCEL, 18-7 +FCHG_DISCHCHARGE, 18-8 +FCHG_FASTCHARGE 1, 18-7 +FCHG_FASTCHARGE2, 18-7 +FCHG_READCHARGEMODE, 18-6 +FCHG_READSTATUS, 18-6 +FCHG_SETCHARGEMODE, 18-4 +p_close, 18-4 +p_open, 18-3 +docking station device +p_close(CRD:), 11-2 +P_FCANCEL, 11-2 +P_FREAD, 11-2 +P_FSENSE, 11-2 +P_FSET, 11-2 +p_open(CRD:), 11-1 + + +INDEX + + +services, 11-1 +DTMF +sound device dial tones, 5-4 +E_FALARM +sound device, 5-3 +E_FDIAL +sound device, 5-4 +E_FSSOUNDCHANNELn +sound device, 5-3 +E_MESSAGE struct +structure infrared, 17-5 +example application +infrared transfer, 16-7 +example program +fast charger Workabout, 18-8 +infrared transfer, 16-7 +exclusive mode +infrared, 17-4 +expansion module +HC bar code/RS232 module, 14-2 +extension file +world database, 8-9 +fast charger +docking station, 18-1 +example program Workabout, 18-8 +FCHG_ASYNCHREAD, 18-7 +FCHG_CANCEL, 18-7 +FCHG_FASTCHARGE I, 18-7 +FCHG_FASTCHARGE2, 18-7 +FCHG_FASTDISCHARGE I, 18-8 + + +FCHG_READCHARGEMODE, 18-6 + + +FCHG_READSTATUS, 18-6 + +FCHG_SETCHARGEMODE, 18-4 + +introduction, 18-1 + +p_close(FCG:A), 18-4 + +p_open(FCG:A), 18-3 + +services, 18-1 +FCG: + +device, 18-1 +FCHG_ASYNCHREAD + +fast charger, 18-7 +FCHG_CANCEL + +fast charger, 18-7 +FCHG_FASTCHARGE1 + +fast charger, 18-7 +FCHG_FASTCHARGE2 + +fast charger, 18-7 +FCHG_FASTDISCHARGE1 + +fast charger, 18-8 +FCHG_READCHARGEMODE + +fast charger, 18-6 +FCHG_READSTATUS + +fast charger, 18-6 +FCHG_SETCHARGEMODE + +fast charger, 18-4 +file format + +world database, 8-9 + +world database extension, 8-10 +FRC: device + +I/O introduction, 7-1 + +introduction, 7-1 + +p_close, 7-2 + +P_FCANCEL, 7-2 + + +P_FREAD, 7-2, 7-3 +P_FSTART, 7-2 +p_open(FRC:), 7-1 +services $3a & Workabout, 7-1 +free running counter +see FRC: device, 7-1 +get value by class frame +infrared, 17-2 +infrared IAS, 17-3 +get value by class reply frame +infrared IAS, 17-3 +handshaking level +infrared, 17-4 +HC +battery capacity calculation, 18-3 +HC bar code device +p_close, 13-2 +P_FCANCEL, 13-2 +P_FREAD, 13-2 +p_open(BAR:), 13-2 +HC bar code reader +device driver, 13-1 +hardware description, 13-1 +interface module, 13-1 +services, 13-2 +wand, 13-1 +HC bar Code reader +device I/O introduction, 13-1 +HC bar code/RS232 module +2-pin header, 14-3, 14-4 +5v regulated power supply, 14-4 +auto power-off HC, 14-4 +bar code command syntax, 14-11 +bar code commands, 14-11 +bar code formats UPC/EAN, 14-6 +bar code symbologies, 14-4 +bar code wand connector, 14-2 +bottom slot, 14-2, 14-3 +charging the main battery, 14-3 +CTS input, 14-2 +DCD input, 14-2, 14-3 +device introduction, 14-1 +diode isolation, 14-3 +DSR auto wakeup switch, 14-3 +DSR input, 14-2, 14-3 +DTR output, 14-2, 14-3 +example code, 14-20 +expansion module, 14-2 + + +HBCR-1610 series micro controller, 14-3 + + +idle current of interface, 14-4 + + +IGN_CTS serial port characteristic, 14-3 + + +interface comms settings, 14-3 + + +losing micro controller program data, + + +14-4 + +maximum output current, 14-2 +optional Vsup connection, 14-2 +p_close, 14-18 + +P_FREAD, 14-18 + +P_FSENSE, 14-18 + +P_FSET, 14-18 + +P_FWRITE, 14-19 +p_open(TTY:), 14-17 + +power consumption, 14-2 + + +1/0 DEVICES REFERENCE + + +power consumption wand, 14-4 +powering an external device, 14-4 +programming, 14-1 + +RI pin of the RS232 port, 14-2 +RS232 port pinout table, 14-2 +RTS output, 14-2 + + +RTS/CTS handshaking protocol, 14-3 + + +RX input, 14-2 + + +scanning current for the interface, 14-4 + + +services, 14-17 + +switched Sv regulated output, 14-3 +switched Vsup output, 14-3 +switching off the external unit, 14-2 + + +tmask serial port characteristics, 14-3 + + +top slot, 14-2, 14-3 + +TTY:A, 14-2 + +TTY:B, 14-2 + +TTY:D, 14-2, 14-3 + +TTY:E, 14-2, 14-3 + +TX output, 14-2 + +undecoded laser scanners, 14-3 + + +Vsup input voltage supply range, 14-3 + + +wand emulator, 14-1 +Xon/Xoff handshaking, 14-2 +HC cradle device +introduction, 11-1 +see cradle device, 11-1 +HC docking station +device introduction, 11-1 +HC intelligent bar code reader +device introduction, 14-1 +see HC bar code/RS232 module, 14-1 +HC magnetic card device +introduction, 12-1 +p_close, 12-1 +P_FCANCEL, 12-2 +P_FREAD, 12-1 +P_FSET, 12-2 +p_open(MCR:), 12-1 +services, 12-1 +HC magnetic card reader +device I/O, 12-1 +HWIM +infrared applications, 15-6 +I/O devices +introduction, 1-1 +see devices, 1-1 +I/O function +asynchronous, 1-1 +p_ioc, 1-1 +p_ioca, 1-1 +p_iow, 1-1 +synchronous, 1-1 +TAS +infrared, 15-4 +idle mode +infrared, 17-4 +include file +infrared constants p_file.h, 16-2 +infrared +AccessIr API, 15-4, 16-1 +AIR: device, 15-4, 16-1, 16-2 +AIR: device on Siena, 16-1 + + +iv + + +baud rates, 15-3 + +beaming communications application, +15-6 + +communications AccessIr API, 16-1 +communications application, 15-6 +communications IrMUX API, 17-1 +Condor serial chip, 15-3 + +connection first time (LM-IAS server), +17-4 + +connection second time (LM-IAS server), +17-4 + +connectionless calls, 17-3 +connectionless read request, 17-3 +connectionless services IrLAP, 15-4 +connectionless write request, 17-3 +connection-oriented calls, 17-3 +connection-oriented services IrLAP, 15-4 +constant P_FIRAWAITCONNECT, 16-3 +constant P_FIRDISCONNECT, 16-3 +constant P_FIRDISCOVER, 16-3 +constant P_ FIRMAKECONNECT, 16-3 +constant P_FIRSELECT, 16-3 + +constant P_FREAD, 16-3 + +constant P_FWRITE, 16-3 + +constants p_file.h, 16-2 + +device driver accessir.ldd, 16-1 +disconnecting first time (LM-IAS server), +17-4 + +disconnecting second time, 17-4 +discovery, 15-5, 17-4 + +example application, 16-7 + +exclusive mode, 17-4 + +handshaking level, 17-4 + +HWIM applications, 15-6 + +TAS, 15-4 + +IAS get value by class frame, 17-2, 17-3 +IAS get value by class reply frame, 17-3 +idle mode, 17-4 + +IPCS methods, 17-1 + +IrDA protocol model, 15-1 + +IrDA standard, 15-1 + +IrLAP, 15-1 + +IrLAP layer, 15-2, 15-3 + +IrLAP services, 15-4 + +IrLMP, 15-1, 15-4 + +IrLMP layer, 15-3 + +IrMUX API, 15-4, 17-1 + +IrMUX message format, 17-5 + +IrMUX server logoff, 17-2 + +IrMUX server logon, 17-2 + +ISO OSI layers, 15-1 + +link control, 15-6 + +link paste, 15-6 +LM_AccessModeRequest, 17-4, 17-11 +LM_CLReadRequest, 17-6 +LM_CLWriteRequest, 17-7 +LM_ConnectRequest, 17-2, 17-4, 17-7 +LM_DisconnectRequest, 17-4, 17-13 +LM_DiscoverDevicesRequest, 17-4, 17-7 +LM_GetValueByClass, 17-2 +LM_IdleRequest, 17-12 + +LM_Logoff, 17-2, 17-5 + +LM_Logon, 17-2, 17-5 + + +INDEX + + +LM_ReadRequest, 17-4, 17-9 +LM_RegisterPort, 17-2, 17-5 +LM_SetHandshakingLevel, 17-4, 17-12 +LM_StatusRequest, 17-9 +LM_UnRegisterPort, 17-2, 17-6 +LM_UReadRequest, 17-4, 17-10 +LM_UWriteRequest, 17-4, 17-11 +LM_WaitForConnection, 17-8 +LM_WriteRequest, 17-4, 17-10 +LM-IAS, 15-4 + +LM-IAS server registering, 17-2 +LM-IAS server unregistering, 17-2 +LM-MUxX, 15-4 + +loadIRDAserver() example code, 16-2 +message number | (IrMUX), 17-5 +message number 10 (IrMUX), 17-5 +message number 11 (rMUX), 17-6 +message number 2 (IrMUX), 17-5 +message number 20 (IrMUX), 17-13 +message number 21 (IrMUX), 17-9 +message number 22 (IrMUX), 17-11 +message number 23 (IrMUX), 17-12 +message number 24 (IrMUX), 17-9 +message number 25 (IrMUX), 17-10 +message number 26 (IrMUX), 17-10 +message number 27 (IrMUX), 17-11 +message number 28 (IrMUX), 17-12 +message number 4 (IrMUX), 17-6 +message number 5 (IrMUX), 17-7 +message number 6 (IrMUX), 17-7 +message number 8 (IrMUX), 17-8 +message number 9 (IrMUX), 17-7 +multiplexing, 15-6 + +MUXMESSAGE structure, 17-5 +OSI layers, 15-1 + +p_close, 16-2, 16-4 +P_FIRAWAITCONNECT, 16-3, 16-5 +P_FIRDISCONNECT, 16-3, 16-6 +P_FIRDISCOVER, 16-2, 16-4 +P_FIRMAKECONNECT, 16-3, 16-5 +P_FIRSELECT, 16-2, 16-4 +P_FREAD, 16-3, 16-6 + +P_FWRITE, 16-3, 16-6 + +p_mreceive, 17-5 + +p_open(AIR:), 16-2, 16-3 + +primary station, 15-4 + +printer IRP: device, 15-7 + +printer IRP: device Siena, 15-7 +protocol stack - initializing, 17-1 +protocol stack example code, 17-2 +protocol stack SYS$IRDA.IMG, 16-2, +17-2 + +Psion protocol model, 15-2 + +read request, 17-4 + +read request unreliable, 17-4 + +retries, 17-4 + +secondary station, 15-4 + +SIR, 15-1 + +SIR: device, 15-2, 15-3 +SYS_IR_POWER_LEVEL, 15-6 +SYS_PRINTER_IR, 15-6 + +unreliable read request, 17-4 + + +unreliable write request, 17-4 +write request, 17-4 +write request unreliable ), 17-4 +infrared communication +introduction to Psion IR, 15-1 +IPCS +infrared methods, 17-1 +IrDA +infrared protocol model, 15-1 +standard, 15-1 +IrLAP +infrared, 15-1 +infrared layer, 15-2, 15-3 +IrLAP services +infrared, 15-4 +IrLMP +infrared, 15-1, 15-4 +infrared layer, 15-3 +IrmMUxX +infrared API, 17-1 +IrMUX API +infrared, 15-4 +IrMUX message format +infrared, 17-5 +IrMUX server +infrared logoff, 17-2 +infrared logon, 17-2 +IRP: +infrared printer device, 15-7 +ISO OST layers +infrared, 15-1 +key code +W_KEY_IR_BRING, 15-6 +W_KEY_IR_LINK, 15-6 +W_KEY_IR_SEND, 15-6 +Link +data transfer, 10-1 +example code, 10-10 +inter-process messages, 10-3 +panics, 10-1 +process, 10-1 +protocol, 10-1 +protocol I/O introduction, 10-1 +LINK +process, 10-3 +link control +infrared, 15-6 +link paste +infrared, 15-6 +LM_AccessModeRequest +infrared, 17-4, 17-11 +LM_CLReadRequest +infrared, 17-6 +LM_CLWriteRequest +infrared, 17-7 +LM_ConnectRequest +infrared, 17-2, 17-4, 17-7 +LM_DisconnectRequest +infrared, 17-4, 17-13 +LM_DiscoverDevicesRequest +infrared, 17-4, 17-7 +LM_GetValueByClass +infrared, 17-2 + + +I/O DEVICES REFERENCE + + +LM_IdleRequest +infrared, 17-12 +LM_Logoff +infrared, 17-2, 17-5 +LM_Logon +infrared, 17-2, 17-5 +LM_ReadRequest +infrared, 17-4, 17-9 +LM_RegisterPort +infrared, 17-2, 17-5 +LM_SetHandshakingLevel +infrared, 17-4, 17-12 +LM_StatusRequest +infrared, 17-4, 17-9 +LM_UnRegisterPort +infrared, 17-2, 17-6 +LM_UReadRequest +infrared, 17-4, 17-10 +LM_UWriteRequest +infrared, 17-4, 17-11 +LM_WaitForConnection +infrared, 17-8 +LM_WriteRequest +infrared, 17-4, 17-10 +LM-IAS +infrared, 15-4 +LM-IAS server + + +LM-MUX +infrared, 15-4 +loadIRDAserver() + + +infrared example code, 16-2 + + +magic static + + +CON: device handle winHandle, 2-2 + + +magnetic card device + + +see HC magnetic card device, 12-1 + + +main world file +location, 8-9 + +maximum scanning rate +bar codes, 14-4 + +MCR: device +introduction, 12-1 + + +see HC magnetic card device, 12-1 + + +multiplexing + +infrared, 15-6 +MUXMESSAGE structure +infrared, 17-5 +NCP +panics, 10-1 + + +NCP device + +I/O introduction, 10-1 +NCP: device + +example code, 10-10 +p_close, 10-4 +P_FCANCEL, 10-7 +P_FCONNECT, 10-4 + + +P_FDISCONNECT, 10-6 + + +P_FINQ, 10-9 +P_FREAD, 10-6 + + +infrared registering, 17-2 +infrared unregistering, 17-2 + + +process SYS$NCP, 10-1 + + +P_FRSUPER, 10-7 +P_FSENSE, 10-10 +P_FSTOP, 10-10 +P_FWRITE, 10-7 +p_open(NCP:), 10-3 +process SYS$NCP, 10-2 +services, 10-3 +note sequence +SND: device, 5-3 +OPL +CON: device use of, 2-1 +OSI layers +infrared, 15-1 +p_close +alarm device, 6-2 +console device, 2-4 +FRC: device, 7-2 +HC bar code device, 13-2 +HC bar code/RS232 module, 14-18 +HC magnetic card device, 12-1 +infrared, 16-2, 16-4 +NCP: device, 10-4 +parallel port, 3-1 +serial port, 4-6 +sound device, 5-2 +world device, 8-2 +XYmodem device, 9-8 +p_close(CRD:) +close device, 11-2 +p_close(FCG:A) +fast charger device, 18-4 +P_EVENT_READ +console device, 2-9 +P_EVENT_TEST +console device, 2-10 +P_FCANCEL +alarm device, 6-2 +cancel read from device, 11-2 +console device, 2-5 +FRC: device, 7-2 +HC bar code device, 13-2 +HC magnetic card device, 12-2 +NCP: device, 10-7 +parallel port, 3-2 +serial port, 4-8 +sound device, 5-2 +world device, 8-2 +P_FCONNECT +NCP: device, 10-4 +XYmodem device, 9-8 +P_FCTRL +serial port, 4-9 +P_FDISCONNECT +NCP: device, 10-6 +XYmodem device, 9-10 +P_FEDIT +console device, 2-6 +P_FFLUSH +console device, 2-6 +serial port, 4-9 +p_file.h +infrared constants, 16-2 + + +INDEX + + +P_FINQ + +console device, 2-10 + +NCP: device, 10-9 + +serial port, 4-10 +P_FIRAWAITCONNECT + +infrared, 16-3, 16-5 + +infrared constant, 16-3 +P_FIRDISCONNECT + +infrared, 16-3, 16-6 + +infrared constant, 16-3 +P_FIRDISCOVER + +infrared, 16-2, 16-4 + +infrared constant, 16-3 +P_FIRMAKECONNECT + +infrared, 16-3, 16-5 + +infrared constant, 16-3 +P_FIRSELECT + +infrared, 16-2, 16-4 + +infrared constant, 16-3 +P_FREAD + +console device, 2-5 + +FRC: device, 7-2, 7-3 + +HC bar code device, 13-2 + +HC bar code/RS232 module, 14-18 + +HC magnetic card device, 12-1 + +infrared, 16-3, 16-6 + +infrared constant, 16-3 + +NCP: device, 10-6 + +read from device, 11-2 + +serial port, 4-7 + +XYmodem device, 9-11 +P_FRSUPER + +NCP: device, 10-7 +P_FSENSE + +console device, 2-6 + +HC bar code/RS232 module, 14-18 + +NCP: device, 10-10 + +parallel port, 3-2 + +sense the device type, 11-2 + +serial port, 4-9 + +sound device, 5-2 +P_FSET + +HC bar code/RS232 module, 14-18 + +HC magnetic card device, 12-2 + +parallel port, 3-2 + +serial port, 4-9 + +service call convension, 2-3 + +set the device type, 11-2 + +sound device, 5-2 +P_FSTART + +FRC: device, 7-2 +P_FSTOP + +NCP: device, 10-10 +P_FTEST + +console device, 2-5 + +serial port, 4-9 +P_FWFLUSH + +console device, 2-10 +P_FWRITE + +HC bar code/RS232 module, 14-19 + +infrared, 16-3, 16-6 + +infrared constant, 16-3 + +NCP: device, 10-7 + + +parallel port, 3-2 + +serial port, 4-8 + +XYmodem device, 9-12 +p_ioc + +I/O function, 1-1 +p_ioca + +I/O function, 1-1 +p_iow + +I/O function, 1-1 +p_mreceive + +infrared, 17-5 +p_open(AIR: + +infrared) + +infrared, 16-2 + +p_open(AIR:) + +infrared, 16-3 +p_open(ALM:) + +alarm device, 6-2 +p_open(BAR:) + +HC bar code device, 13-2 +p_open(CON:) + +console device, 2-3 +p_open(CRD:) + +open device, 11-1 +p_open(FCG:A) + +fast charger device, 18-3 +p_open(FRC:) + +FRC: device, 7-1 +p_open(MCR:) + +HC magnetic card device, 12-1 +p_open(NCP:) + +NCP: device, 10-3 +p_open(PAR:) + +parallel port, 3-1 +p_open(SND:) + +sound device, 5-2 +p_open(TTY:) + +HC bar code/RS232 module, 14-17 + +serial port, 4-6 +p_open(WLD:) + +world device, 8-2 +p_open(XMD:) + +XYmodem device, 9-8 +P_SCR_ATTRB + +console device, 2-11 +P_SCR_CANCEL_CAPTURE_KEY + +console device, 2-13 +P_SCR_CAPTURE KEY + +console device, 2-13 +P_SCR_CLIENT_FOREGROUND + +console device, 2-12 +P_SCR_CLR + +console device, 2-7 +P_SCR_COMPATIBILITY + +console device, 2-9 +P_SCR_CSET + +console device, 2-10 +P_SCR_CURSOR + +console device, 2-8 +P_SCR_DISABLE_READS + +console device, 2-12 +P_SCR_ESCAPE + +console device, 2-9 + + +I/O DEVICES REFERENCE + + +P_SCR_FLUSH + +console device, 2-12 +P_SCR_FONT + +console device, 2-11 +P_SCR_GREY + +console device, 2-9 +P_SCR_LAST_LINE_WRAP + +console device, 2-12 +P_SCR_NEL + +console device, 2-8 +P_SCR_POSA + +console device, 2-8 +P_SCR_POSR + +console device, 2-8 +P_SCR_SCROLL + +console device, 2-7 +P_SCR_SLOCK + +console device, 2-8 +P_SCR_WLOCK + +console device, 2-8 +P_SCR_WSET + +console device, 2-7 +p_write + +console device, 2-4 +panics + +alarm device, 6-2 + +console device, 2-3 + +Link, 10-1 + +NCP, 10-1 + +parallel port device, 3-1 + +serial port device, 4-1 + +sound device, 5-1 +PAR: device + +example code, 3-3 + +introduction, 3-1 + +see parallel port, 3-1 +parallel port + +device I/O, 3-1 + +example code, 3-3 + +p_close, 3-1 + +P_FCANCEL, 3-2 + +P_FSENSE, 3-2 + +P_FSET, 3-2 + +P_FWRITE, 3-2 + +p_open(PAR:), 3-1 + +panics, 3-1 +parity errors + +HC bar code/RS232 module, 14-3 +PC-AT style RS232 port + +HC bar code/RS232 module, 14-1 +PLIB + +programs CON: device use of, 2-2 +power consumption + +HC bar code/RS232 module, 14-4 +primary station + +infrared, 15-4 +printer device + +IRP: infrared, 15-7 +protocol + +Link introduction, 10-1 +protocol stack + +infrared - initializing, 17-1 + + +Psion infrared +protocol model, 15-2 +read request +infrared, 17-4 +read request unreliable +infrared, 17-4 +retries +infrared, 17-4 +RI pin of the RS232 port +HC bar code/RS232 module, 14-2 +RS232 device +see serial port, 4-1 +RS232 port pinout table +HC bar code/RS232 module, 14-2 +secondary station +infrared, 15-4 +serial infrared +Condor chip, 15-3 +serial port +baud rate, 4-2 +character frame, 4-2 +control flags, 4-5 +device driver LDD, 4-1 +device driver PDD, 4-1 +device I/O introduction, 4-1 +errors, 4-5 +example code, 4-11 +handshaking, 4-3 +HC TTL levels, 4-1 +p_close, 4-6 +P_FCANCEL, 4-8 +P_FCTRL, 4-9 +P_FFLUSH, 4-9 +P_FINQ, 4-10 +P_FREAD, 4-7 +P_FSENSE, 4-9 +P_FSET, 4-9 +P_FTEST, 4-9 +P_FWRITE, 4-8 +p_open(TTY:), 4-6 +panics, 4-1 +parameters, 4-1 +parity, 4-3 +services, 4-6 +terminator characters, 4-5 +Siena infrared +printer IRP: device driver, 15-7 +SIR +infrared, 15-1 +SIR: +infrared device, 15-2, 15-3 +SND: device +example code, 5-5 +introduction, 5-1 +see sound device, 5-1 +sound +buzzer emulator, 5-1 +buzzer piezo, 5-1 +device I/O introduction, 5-1 +digital files, 5-1 +HC machines, 5-1 +MC machines, 5-1 + + +INDEX + + +S3 machines, 5-1 + +S$3a machines, 5-1 +sound device + +E_FALARM, 5-3 + +E_FSSOUNDCHANNEL1, 5-3 + +example code, 5-5 + +p_close, 5-2 + +P_FCANCEL, 5-2 + +P_FSENSE, 5-2 + +P_FSET, 5-2 + +p_open(SND:), 5-2 + +panics, 5-1 + +services, 5-2 + +services additional HC MC S3a, 5-3 + +services additional S3 S3a, 5-4 + +SND: introduction, 5-1 +structures + +DISCOVERY_LOG infrared, 15-5 + +E_MESSAGE infrared, 17-5 + +MUXMESSAGE infrared, 17-5 +supplement digits + +bar codes, 14-4 +synchronous + +I/O functions, 1-1 +SYS$IRDA.IMG + +infrared protocol stack, 16-2, 17-2 +SYS$NCP + +process, 10-1, 10-2 +SYS_IR_POWER_LEVEL + +infrared, 15-6 +SYS_PRINTER_IR + +infrared, 15-6 +time application + +alarm services $3 S3a, 6-2 +top slot + +HC bar code/RS232 module, 14-2 +TTY: device + +example code, 4-11 + +introduction, 4-1 + +parameters, 4-1 + +see serial port, 4-1 +TTY:A + +HC bar code/RS232 module, 14-2 +TTY:B + +HC bar code/RS232 module, 14-2 +TTY sD + +HC bar code/RS232 module, 14-2 +TTY:E + +HC bar code/RS232 module, 14-2 +unreliable read request + +infrared, 17-4 +unreliable write request + +infrared, 17-4 +W_KEY_IR_BRING + +key code, 15-6 +W_KEY_IR_LINK + +key code, 15-6 +W_KEY_IR_ SEND + +key code, 15-6 +wand emulator + +HC bar code/RS232 module, 14-1 +winHandle + +magic static CON: device handle, 2-2 + + +WLD: device +introduction, 8-1 +see world device, 8-1 +Workabout +battery capacity calculation, 18-3 +Workabout docking station +device introduction, 11-1 +see docking station device, 11-1 +world application +database S3 S3a, 8-2 +world database +contents, 8-1 +file extension, 8-9 +file format, 8-9 +file format extension file, 8-10 +file types and locations, 8-9 +see also world device, 8-1 +world database device +see world device, 8-1 +world device +database contents, 8-1 +file extension, 8-9 +file format, 8-9 +file format extension file, 8-10 +file types and locations, 8-9 +I/O introduction, 8-1 +introduction, 8-1 +mode, 8-1 +p_close, 8-2 +P_FCANCEL, 8-2 +p_open(WLD:), 8-2 +services, 8-2 +WR_BACK, 8-3 +WR_CALC, 8-8 +WR_EXTRA, 8-5 +WR_FIND_CITY, 8-2 +WR_FIND_COUNTRY, 8-2 +WR_FIND_EXACT, 8-3 +WR_GET_CITY_DATA, 8-6 +WR_GET_COUNTRY_DATA, 8-7 +WR_GET_DEFAULT_COUNTRY, 8-4 +WR_GET_DIAL_STRING, 8-4 +WR_GET_HOME, 8-3 +WR_NEXT, 8-3 +WR_NEXT_LOCK, 8-9 +WR_SET_DEFAULT_COUNTRY, 8-4 +WR_SET_EXTRA, 8-5 +WR_SET_HOME, 8-3 +world file +extension, 8-9 +format, 8-9 +format extension file, 8-10 +main, 8-9 +world.dat +location, 8-9 +WR_BACK +world device, 8-3 +WR_CALC +world device, 8-8 +WR_EXTRA +world device, 8-5 +WR_FIND_CITY +world device, 8-2 + + +ix + + +I/O DEVICES REFERENCE + + +WR_FIND_COUNTRY + +world device, 8-2 +WR_FIND_EXACT + +world device, 8-3 +WR_GET_CITY_DATA + +world device, 8-6 +WR_GET_COUNTRY_DATA + +world device, 8-7 +WR_GET_DEFAULT_COUNTRY + +world device, 8-4 +WR_GET_DIAL_STRING + +world device, 8-4 +WR_GET_HOME + +world device, 8-3 +WR_NEXT + +world device, 8-3 +WR_NEXT_LOCK + +world device, 8-9 +WR_SET_DEFAULT_COUNTRY + +world device, 8-4 +WR_SET_EXTRA + +world device, 8-5 +WR_SET_HOME + +world device, 8-3 +write request + +infrared, 17-4 +write request unreliable + +infrared), 17-4 +XMD: device + +introduction, 9-1 + +see XYmodem device, 9-1 +Xmodem device + +I/O introduction, 9-1 + +see XYmodem device, 9-1 +Xon/Xoff handshaking + +HC bar code/RS232 module, 14-2 +XYmodem device + +checksum CRC, 9-1 + +checksum one byte, 9-1 + +device driver, 9-1 + +device I/O, 9-1 + +example connect code, 9-10 + +example disconnect code, 9-10 + +example file receive code, 9-11 + +example file recieve code, 9-12 + +example file send code, 9-10, 9-13 + +p_close, 9-8 + +P_FCONNECT, 9-8 + +P_FDISCONNECT, 9-10 + +P_FREAD, 9-11 + +P_FWRITE, 9-12 + +p_open(XMD:), 9-8 + +protocol problems, 9-7 + +protocols, 9-1 + +services, 9-8 + +Xmodem protocol, 9-2 + +Ymodem protocol, 9-4 +Ymodem device + +I/O introduction, 9-1 + +see XYmodem device, 9-1 + + diff --git a/docs/2-04 The SIBO Debugger 2.10_djvu.txt b/docs/2-04 The SIBO Debugger 2.10_djvu.txt new file mode 100755 index 0000000..95dc1b0 --- /dev/null +++ b/docs/2-04 The SIBO Debugger 2.10_djvu.txt @@ -0,0 +1,3286 @@ +THE SIBO DEBUGGER + + +Version 2.10 + + +February 3, 1995 + + +(C) Copyright Psion PLC 1990-95 + + +All rights reserved. This manual and the programs referred to herein are copyrighted works of Psion +PLC, London, England. Reproduction in whole or in part, including utilization in machines capable of +reproduction or retrieval, without express written permission of Psion PLC, is prohibited. Reverse +engineering is also prohibited. + + +The information in this document is subject to change without notice. + + +Psion and the Psion logo are registered trademarks, and Psion, Psion MC, Psion HC, Psion Series 3, +Psion Series 3a and Psion Workabout are trademarks of Psion PLC. + + +TopSpeed is a registered trademark of Clarion Software Corporation. IBM, IBM XT and IBM AT are +registered trademarks of International Business Machines Corp. Microsoft and MS-DOS are registered +trademarks of Microsoft Corporation. Apple and Macintosh are registered trademarks of Apple Computer +Inc. VAX and VMS are registered trademarks of Digital Equipment Corporation. Brief is a registered +trademark of Underware Inc. Psion PLC acknowledges that some other names referred to are registered +trademarks. + + +LES SSS ae ee ee eS ee ee ea +Contents + + +—_— —__ ror —— + + +TD AM OGUCHON 6 2.c025nitiecnoban eects wdtaciyngctececoduceiessceasahee he Oeseee eete Ree vee cece 1 +DEBUG OINGINOGES S. Cinicursonautatiane tostoesetune satid eewcaaess ides tee naaeet eer ocaibne eae 1 +SIBO