Programming Psion Computers
Total Page:16
File Type:pdf, Size:1020Kb
Programming Psion Computers by Leigh Edwards Programming Psion Computers Copyright ©1997, 1998, 1999 Leigh Edwards This book and all program code contained within, is supplied in the belief that the contents are correct and operate as specified, but the author and EMCC shall not be liable in any circumstances whatsoever for any direct or indirect loss or damage to property incurred or suffered by the customer or any other person as a result of any fault or defect in the information contained herein. The moral right of the author has been asserted. All rights reserved. Reproduction of this book in whole or in part, including utilisation in machines capable of reproduction or retrieval, is prohibited without the express written permission of EMCC. Many of the utility programs and larger code examples provided on disk are expressly covered by embedded shareware or copyright notices. Please do respect the copyrights of others. Since shareware is not freeware, please register any software that states it is shareware, if you intend to use it beyond a reasonable evaluation period. The information in this book or supplied on disk is subject to change without notice. ISBN 0 9530663 0 4 Published by: EMCC Software Limited 108 Manchester Road, Carrington, Manchester, M31 4BD, UK Tel +44 (0) 161 777 9700, Fax +44 (0) 161 777 9909 E-mail [email protected] www.emccsoft.com First printed October 1997, first reprint May 1998, second reprint January 1999, fourth reprint in Acrobat PDF form only June 2002. Psion and the Psion logo are registered trademarks, and Psion Series 3, Psion Series 3a, Psion Series 3c, Psion Siena, Psion Series 5, Psion 3Link, SIBO, EPOC16 and EPOC32 are trademarks of Psion PLC. TopSpeed is a registered trademark of TopSpeed Corporation. IBM and IBM PC are registered trademarks of International Business Machines Corp. Microsoft, Microsoft Windows, Microsoft Word and MS-DOS are registered trademarks of Microsoft Corporation. Apple and Macintosh are registered trademarks of Apple Computer Inc. EMCC acknowledges that some other names referred to are registered trademarks, and are given for information purposes only without commercial interests. Table of Contents 1 INTRODUCTION 1-1 Purpose and scope 1-2 Shareware, freeware and copyrights 1-3 Using this book 1-3 Terms used 1-3 Loading the disk information 1-4 Finding disk-based information 1-4 Other sources of information 1-5 Disclaimer 1-5 2 DEVELOPMENT OPTIONS 2-1 Introduction 2-1 Platforms, overview 2-1 SIBO system exclusively 2-2 DOS based Psion emulators 2-2 PC with a linked SIBO system 2-3 Language options 2-3 Assembly language 2-3 C programming 2-4 OPL 2-4 OVAL 2-4 Macros 2-4 Use of memory 2-5 Portability and re-use of source code 2-5 A typical development cycle 2-6 Languages and platforms, in detail 2-7 Assembly language options 2-7 C programming 2-8 OPL 2-11 OVAL 2-14 Macros 2-14 3 FUNDAMENTAL CONCEPTS 3-1 Introduction 3-1 SIBO architecture 3-2 Key components of SIBO systems 3-2 ASICs 3-2 Processor 3-3 Interrupts 3-3 Memory protection 3-3 Auto-switch-off 3-4 Storage capabilities 3-4 Display screens 3-7 Sound hardware 3-8 System time and date 3-9 External communication 3-9 The EPOC16 operating system 3-10 Key features 3-10 EPOC versions 3-11 The system screen 3-11 Processes and priorities 3-12 Processes, clients and servers 3-12 Processes, foreground and background 3-13 Events, an introduction 3-13 Multi-tasking and multi-threading 3-14 Applications 3-14 Memory 3-14 Inter-process communications (IPCS) 3-15 Files 3-15 I/O (input/output) system 3-16 4 PROCESSES, MEMORY AND 4-1 Processes 4-1 Process priorities 4-1 Semaphores 4-2 Asynchronous versus synchronous services 4-2 System processes 4-4 Process IDs and process control block 4-5 Process queues 4-5 Process names 4-6 Processes and auto-switch-off 4-7 Memory 4-9 Magic (or reserved) static variables 4-11 Re-entrant processes and functions 4-12 Shared code segments 4-12 Environment variables 4-13 Applications 4-14 Application types 4-14 Public name 4-19 Default extension 4-19 Default path 4-20 Icons 4-20 Help and other program resources 4-20 Aliasing applications 4-21 Application command lines 4-22 Messages from the system screen 4-27 Client server services 4-28 Inter-process communications (IPCS) 4-29 Errors 4-32 Fatal errors 4-32 5 USER INTERFACE 5-1 Application design 5-1 Interface style 5-1 Interface elements 5-1 Synchronous or asynchronous design 5-2 Keyboard input 5-2 Diamond key 5-3 Menus 5-3 Windows 5-4 Dialogs 5-4 Alerts 5-5 Input focus 5-6 Modal and non modal behaviour 5-6 System messages 5-6 Switch files messages 5-6 Shutdown & foreground/background changes 5-6 System messages - failure to respond 5-7 Application files 5-7 Location and naming 5-7 Change of files 5-8 Icons 5-9 Graphics 5-10 Screen sizes and compatibility 5-11 Bitmaps 5-11 Screen drawing, re-drawing and memory 5-13 Cursors 5-13 Sprites 5-13 Fonts 5-14 Status windows 5-15 Compatibility mode status window 5-16 Printing 5-16 Sound 5-16 Resource files 5-17 User help information 5-17 Multi-lingual applications 5-18 Co-operating programs 5-19 Bring or link paste 5-19 Attached applications 5-19 Running other programs 5-19 Aliasing applications 5-20 6 FILES IN EPOC16 6-1 Introduction 6-1 File specifications 6-1 File name selectors and editors 6-2 File name parsing 6-2 File name extensions, standard 6-3 Wildcards 6-3 Directories 6-4 Directory names, standard 6-4 General file management 6-5 The file server 6-5 Installable file systems and remote file access 6-5 File operations - asynchronous 6-6 File types and formats in EPOC16 6-7 Psion application file formats 6-7 Binary files 6-7 Text files 6-8 Binary or text file I/O 6-8 Database files 6-11 SSDs and robust applications 6-14 Flash friendly applications 6-14 7 I/O SYSTEM 7-1 Introduction 7-1 I/O devices 7-1 Device drivers 7-2 Using the I/O system 7-2 Handles 7-3 I/O functions 7-3 Closing the channel 7-4 Avoiding I/O errors 7-4 Synchronous I/O 7-4 Asynchronous I/O 7-5 Console services 7-8 File services 7-9 Parallel port 7-9 Serial port 7-9 Xmodem and Ymodem transfers 7-10 Link and NCP 7-10 Sound 7-10 Timers and processes 7-11 Alarms 7-13 World database 7-14 Infrared communications 7-15 Device drivers, in more detail 7-16 External device drivers 7-17 Writing device drivers 7-17 8 OPL PROGRAMMING 8-1 Introduction 8-1 OPL manuals 8-1 SIBO based development 8-2 SIBO with OPP/OPPDBG 8-2 PC based development 8-3 DOS based development 8-4 DOS based SIBO emulator 8-6 OPLCS Windows editor 8-6 ODE 8-7 ODE with OPP 8-8 The Psion SIBO OPL16 SDK 8-8 OPL16 SDK manuals 8-9 Source code protection 8-13 Anti-Revtran strategies 8-14 9 OPL REFERENCE 9-1 Introduction 9-1 Functions, commands and procedures 9-2 Notation used 9-2 Program control 9-4 Procedures 9-4 Program settings 9-7 Loops, branches and jumps 9-8 Error handling 9-13 Screen and keyboard control 9-17 Files 9-28 File management 9-28 Directory management 9-33 Database files 9-34 OPL program modules 9-48 OPL procedure cacheing 9-50 Dynamic library (DYL) handling 9-52 Memory management 9-54 Variable declaration 9-54 Memory, dynamic allocation 9-57 Memory, addresses & pointer arithmetic 9-59 Memory, reading and writing 9-60 Machine code calls 9-63 Operating system calls 9-64 Printing 9-66 Numeric functions 9-68 Trigonometric functions 9-68 General numeric functions 9-70 Statistical numeric functions 9-72 Numeric conversion 9-75 String handling 9-80 Date and time 9-84 Sound 9-89 Graphics 9-90 Window and bitmap manipulation 9-90 Window and bitmap characteristics 9-96 Window and bitmap information 9-100 Graphics ‘cursor’ positioning 9-103 Graphics text 9-104 Graphics drawing commands 9-106 Graphics sprites 9-124 Menus 9-126 Dialogs 9-132 Screen messages 9-145 OPL applications (OPAs) 9-146 Event handling 9-152 Status windows 9-156 I/O operations on files and devices 9-159 Object handling 9-167 10 OPL16 TECHNIQUES 10-1 Introduction to PPCOPL16 10-1 Techniques covered 10-1 Source files 10-3 Executable files 10-3 Language text 10-4 Structure overview 10-4 Initialisation in detail 10-5 Events and user input 10-9 Application functions 10-10 11 C PROGRAMMING 11-1 Introduction 11-1 ROM-resident libraries 11-1 C libraries 11-2 Object-oriented libraries 11-2 Psion SIBO C SDK 11-3 SIBO C SDK software 11-3 SIBO C SDK documentation 11-3 The development process 11-11 Programming options 11-12 Code and data size limits 11-16 Directories in the C SDK 11-18 Examples on disk 11-23 12 OVAL PROGRAMMING 12-1 Introduction 12-1 Developing in OVAL 12-1 OVAL platform 12-2 OVAL and events 12-2 OVAL IDE 12-2 Running applications 12-9 Manuals and documentation 12-10 Support 12-11 OVAL IDE examples 12-11 Examples on disk 12-12 Developing new OVAL controls 12-12 13 SERIES 5 13-1 Hardware 13-1 ARM processor and sub-systems 13-2 Hardware block diagram 13-4 Memory and storage 13-5 Screen 13-6 User input 13-6 Audio 13-8 Communications 13-9 Software 13-10 System interface 13-10 Series 5 applications 13-11 EPOC32 13-18 Threads and processes 13-19 The base 13-20 Support services 13-22 EIKON 13-31 EPOC32 variants 13-32 Software development 13-34 14 OPL32 TECHNIQUES 14-1 Introduction 14-1 OPL, the changes 14-1 Keywords removed 14-2 Keywords added 14-3 Keywords amended 14-4 OPA header changes 14-5 Toolbars 14-6 Graphics 14-6 Databases 14-7 Application help 14-7 OPXs 14-8 Series 5 OPL source files 14-10 Introduction to PPCOPL32 14-11 Techniques covered 14-12 Source files 14-13 Structure overview 14-13 Processing in detail 14-15 Events and user input 14-18 Menu options 14-21 Support procedures 14-26