The Amstrad Notepad Advanced User Guide
Total Page:16
File Type:pdf, Size:1020Kb
THE AMSTRAD NOTEPAD! ^ ADVANCED ■ s=7 USER GUIDE ■ THE AMSTRAD NOTEPAD ADVANCED USER GUIDE ROBIN NIXON Programs written and documented by Chris Nixon SIGMA PRESS - Wilmslow, United Kingdom Thi s One 5ZSR-LLP-2C3T Copyright ©, R. Nixon and C. Nixon, 1993 All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior written permission. First published in 1993 by Sigma Press, 1 South Oak Lane, Wilmslow, Cheshire SK9 6AR, England. British Library Cataloguing in Publication Data A CIP catalogue record for this book is available from the British Library. ISBN: 1-85058-515-6 Typesetting and design by Sigma Press, Wilmslow Printed in Malta by Interprint Ltd. Distributed by John Wiley & Sons Ltd., Baffins Lane, Chichester, West Sussex, England. Acknowledgement of copyright names Within this book, various proprietary trade names and names protected by copyright are mentioned for descriptive purposes. Full acknowledgment is hereby made of all such protection. PREFACE At first sight it might seem a step backwards and a rather surprising move for Amstrad to release a 64K Z80-based 'laptop'-type computer when the market definitely looks like PC-compatible is the way to go, and laptops being the fastest growth area. But maybe that's the point. There is a large group of people who know that all they need is a cheap, easy-to-use and (as the Notepads proudly proclaim) user-friendly interface - without having to learn about using DOS or Windows. Amstrad are renowned for using tried and tested formulae, which the Z80 certainly is - just look at how well they did with the PCW family. What's more, Z80s are cheap, as are the additional chip sets that go with them and, because of their low power consumption, you get up to 40 hours use out of an NC100 - about 10 times more than with most PC-compatible laptops. And Amstrad made a very sensible decision in their choice of software. By porting Protext across to it they have a top-selling word-processor also available on a number of platforms, including the Amstrad CPC and PCW, Archimedes, Atari ST, Amiga and PC compatibles. In one go, Amstrad have a product that can be file compatible with just about every other popular computer. By removing Protext's command mode (well, not entirely, as you'll see later), they came up with a very simple system of colour-coded key combinations so that, no matter where you are in the Notepad, you can move to any other in-built application at a key press. But, in my opinion, one of the best things to be incorporated was the BBC Basic ROM which allows you to adapt the computer fully to your own requirements. And that is what this book concentrates on. In it you will discover how you can use BBC Basic to write applications to complement seamlessly the in-built applications, with the user never even knowing they are in Basic. Even if you're not a programmer, the explanations of how the Notepad works should interest you, but if not a large proportion of this book is taken up with ready-made iv The Amstrad Notepad programs ready for you to type in and run. So, without needing to know a thing about programming, you can add a writing style checker to your Notepad, or there's a full scientific calculator, a food additive database, a graphical world time zone viewer, a mortgage calculator and a whole lot more. For the more technically minded, full details on the Notepad's firmware calls, input/output ports and system variables are provided, including how you can make use of them yourself. You'll even learn how to create enure system applications to run from a RAM card. Everything you need to know in order to do this is in this book, even down to a fully working Z80 disassembler you can type in and use immediately. In fact this book is packed with undocumented information about the Notepad (and even the Z80 microprocessor itself) that you are unlikely to find anywhere else. Along with the comprehensive index, you will find it to be a complete, one-stop reference to using and writing Notepad programs, as well as a valuable source of additional software for your Notepad. Thanks are due to Mark Tilley and Gavin Every at Arnor Ltd (the programming team) as well as to Cliff Lawson the Notepad Project Manager at Amstrad Pic for much of the technical information that appears here. Because these details came directly from the programmers you can be sure that they are as accurate as possible. Thanks also to John Blackburn for his invaluable assistance in the preparation of this book, and to Richard Russell, the author of the Notepad BBC Basic interpreter, for his assistance with the final manuscript. Robin Nixon To Julie and Naomi Contents SECTION 1 - THE PROGRAMS 1 THREE GOLDEN RULES 2 GET IT RIGHT 2 AUTO 3 USING THE PROGRAM 3 HOW IT WORKS 4 BIOMON.BAS 6 USING THE PROGRAM 6 HOW IT WORKS 7 CALC.BAS 12 USING THE PROGRAM 13 HOW IT WORKS 15 CH ART.B AS 22 USING THE PROGRAM 23 HOW IT WORKS 23 COOKIE.BAS 26 USING THE PROGRAM 26 HOW IT WORKS 27 DEVIL.BAS 33 USING THE PROGRAM 34 HOW IT WORKS 35 FOOD.BAS 47 USING THE PROGRAM 48 HOW IT WORKS 49 INKEY.BAS 56 USING THE PROGRAM 57 HOW IT WORKS 57 MORTGAGE.BAS 58 USING THE PROGRAM 59 HOW IT WORKS 59 vi The Amstrad Notepad READYREC.BAS 61 USING THE PROGRAM 62 HOW IT WORKS 63 SCALES.BAS 68 USING THE PROGRAM 69 HOW IT WORKS 69 STYLE.BAS 75 USING THE PROGRAM 76 HOW IT WORKS 77 TIMEZONE.BAS 88 USING THE PROGRAM 89 HOW IT WORKS 89 ZAP.BAS 100 USING THE PROGRAM 101 HOW IT WORKS 101 SECTION 2 - REFERENCE 121 1. CONTINUED . FROM THE NOTEPAD MANUAL 122 REGISTER VARIABLES 126 2. UNDOCUMENTED FEATURES 129 TRANSFERRING BBC BASIC PROGRAMS 129 QUICK MACRO ASSIGNING 129 LINE DRAWING CHARACTERS 130 PAGE DISPLAY MODE 130 USING THE FILE SELECTOR 131 PEEKING ABOUT 131 UNDOCUMENTED SELF-TEST 133 SAVING THE SCREEN 134 3. WRITING EXTERNAL PROGRAMS 145 USING THE NOTEPAD'S LCD DISPLAY 146 4. THE NOTEPAD'S INPUT/OUTPUT PORTS 151 5. THE JUMPBLOCK ENTRIES 157 KEYBOARD FUNCTIONS 158 SCREEN DISPLAY FUNCTIONS 160 PARALLEL AND SERIAL PORT FUNCTIONS 166 CLOCK FUNCTIONS 169 MEMORY ALLOCATION FUNCTIONS 170 FILE I/O FUNCTIONS 172 MISCELLANEOUS FUNCTIONS 178 Advanced User Guide vii 6. THE SYSTEM VARIABLES 182 BBC BASIC MAIN SYSTEM VARIABLES 185 7. RECOVERING FROM LOCK-OUTS 186 8. THE COMPLETE Z80 INSTRUCTION SET 188 9. THE UNDOCUMENTED Z80 INSTRUCTIONS 219 SECTION 3 - APPENDICES 225 APPENDIX 1: NC100 JUMPBLOCK ENTRY POINTS 226 APPENDIX 2: INPUT/OUTPUT PORTS (&0000 - &00FF) 229 APPENDIX 3: KEYBOARD SCAN CODES 230 APPENDIX 4: THE COMPLETE SET OF Z80 INSTRUCTION CODES. 232 APPENDIX 5: NEW NOTEPAD MODELS 247 APPENDIX 6: EXTRAS 248 GET CONNECTED WITH LAPCAT 248 EXPAND YOUR NOTEPAD WITH A RAM CARD 248 ORDER THE DISK OF THE BOOK 248 ORDER FORM 249 SECTION 1 THE PROGRAMS Whether or not you are a programmer, this collection of programs has been designed to accompany the applications provided with your Notepad. They have been written in such a way that no knowledge of programming is required to use them and you can call them up by simply pressing [Function] [B], so you don't even need to know any Basic commands. Just type in the programs, check them and save them. On the other hand, detailed descriptions accompany every program in this section, including line by line running commentaries, descriptions of the functions and procedures used, and an explanation of all the main arrays and variables. Using all this information in conjunction with the listings you will be able to pick up on the various methods used and then incorporate any ideas you like into your own programs. To this end the variety of programs has been kept as wide as possible and a broad range of programming styles and techniques have been used, covering areas such as using the built-in assembler, handling strings, variables and arrays, processing and storing data, directly accessing the display RAM, the non-standard Notepad VDU codes and much more. All the programs are written in BBC Basic and some contain sections of assembly language to achieve effects that, if written in Basic, wouldn't be possible, would take too much space to write, or would run unacceptably slowly. The programs are self-contained, and range from a useful scientific calculator to a world clock featuring a map of the earth. There's also a version of the classic game Towers of Hanoi to while away the odd hour, and if you are fond of writing you 2 The Amstrad Notepad might like to pass your efforts through the compact style checker and see how they measure up. Programmers may be particularly interested in the assembly language routine that performs an instant scan of the keyboard, in a similar fashion to BBC Basic's negative INKEY(-n), (as opposed to Basic's INKEY or INKEY$, which can only return keys at the speed of the current keyboard repeat rate). There's a full chart of the Notepad's character set - useful for designing screen layouts or games, and a complete Z80 disassembler so you can delve into the inner workings of other programs.