Commodore_128_Reference_Guide_for_Programmers.pdf

(7481 KB) Pobierz
UDWJ8S!8H ., P!ADC
S.I8WWD.1&0.1d .101
ap1n0 8)U8.1818ll
®8~l
8.10pOWWO)
PNrfS
Commodore 128
Reference Guide
for Progrommers
David L. Heiserman
Howard W. Sams
&
Co.
A Division of Macmillan, lnc.
4300 West 62nd Street, lndianapolis, IN 46268 USA
©
1986 by David L. Heiserman
FIRST EDITION
FIRST PRINTING-1986
All rights reserved. No part of this hook shall be reproduced, stored in a
retrievalsystem, or transmitted by any means, electronic, mechanica!,
photocopying, recording, or otherwise, without written permission from the
publisher. No patent liability is assumed with respect to the use of the
information contained herein. While every precaution has been taken in the
preparation of this hook, the publisher and author assume no responsibility
for errors or omissions. Neither is any liability assumed for damages
resulting from the use of the information contained herein.
International Standard Book Number: 0-672-22479-8
Library of Congress Catalog Card Number: 86-60936
Acquisitions Editor:
Greg Michael
Editor:
Katherine Stuart Ewing
Designer:
T. R. Emrick
Illustrators:
Don Clemons
and
Ralph E. Lund
Cover Artist:
Gregg Butler
Compositor:
Shepard Foorman Communications, Indianapolis
Printed in the United Statesof America
Trademark Acknowledgments
All terms mentioned in this book that are known to be trademarks or service
marks are listed below. In addition, terms suspectedof being trademarks or
service marks have been appropriately capitalized. Howard W. Sams
&
Co.
cannot attest to the accuracy of this information. U se of a term in this
book should not be regarcled as affecting the validity of any trademark or
service mark.
CP/Mis aregistered trademark of Digital Research, Inc.
Amiga, Commodore 64, and Commodore 128 are registered
trademarks of Commodore Electronics, Limited.
Contents
Preface
ix
1
1
General Operating Procedures
The Three Main Operating Modes 2
Getting Familiar with the Keyboard 8
Quote-Mode Operations 16
Essential Disk Operations 17
2
BASIC Operations and Programming Procedures
Numeric and String Constants for BASIC 24
Numeric and String Variables in BASIC 28
Operators for Commodore BASIC 34
BASIC 7.0 Commands, Statements, and Functions 43
Keyboard Abbreviations of BASIC Operations 92
Dealing with BASIC Error Conditions 96
Tokenized BASIC Formats 106
23
3
DOS Operating and Programming Procedures
Preliminary Considerations 112
DOS-Related Commands, Functions, and Statements 113
DOS-Related Error Conditions 115
The Disk Directory 119
Disk Pormatting Procedures 121
Procedures for Saving Programs on Disk 125
Procedures for Loading Programs from Disk 132
Procedures for Copying Disk Files 138
Procedures for Cleaning Up Disks 140
Using the TEST/DEMO DISKETTE and DOS Shell 143
Sequentia! Text Files 144
Relative File Procedures 150
Direct-Access Disk Procedures 152
111
4
Monitor and Assembly Language Procedures
T~e
161
Monitor's Hexadecimal Format 162
Essential Monitor Operations 163
The Monitor' s Machine-Language Aids 170
vi
Contents
Summary of 8502 Op Codes 175
The 8502 Instruction Set 180
5
Introduetion to CP/M Procedures
Bringing Up CP/M on the Commodore 128 202
Help for Beginners 202
Summary of CP/M Commands 206
Makinga Backup Copy of the CP/M Disk 212
201
6
Text Screen Procedures
Preliminary Considerations 216
Switching Column Formats 220
Switching Character Sets 224
Setting the Normal/Inverse Character Format 229
Setting Screen and Character Colors 231
Using Cursor Control Features 241
Setting Alternative Text Windows 243
Using the Screen-Editing Features 250
Printing Text from Machine Language Programs 255
Working with the Character Sets 264
Working Directly with Screen Data 272
Using Alternative Screen RAM Locations 276
Writing Directly to the 80-Column Screen 279
215
7
Bit-Mapped Graphics Procedures
283
Bit-Mapped Screen Formats 284
Plotting Figures on the Graphics Sereens 290
Rescaling the Screen 300
Saving and Reloading Bit-Mapped Shapes 301
Setting Graphics Sereens from Machine Language Routines 304
Working Directly with Standard Bit-Mapped Sereens 307
Working Directly with the Multicolor Bit-Map Screen 314
8
Sprite Animation Procedures
Creating Sprite Figures 318
Saving and Reloading Sprites 322
Specifying, Positioning, a:qd Moving Sprites 323
Detecting Sprite Collisions' 329
Sprites and Machine Language Routines 337
317
9
Sound and Music Procedures
Preliminary Considerations 348
i
Using BASIC'sVOL and SOUND Staterne ts 351
U sing BASIC' s PLAY and TEMPO Staterne ts 356
Using the ENVELOPE Statement 360
Using the FILTER Statement 362
J
347
Zgłoś jeśli naruszono regulamin