Commodore 64 Omnibus.Pdf

Total Page:16

File Type:pdf, Size:1020Kb

Commodore 64 Omnibus.Pdf THE COMMODORE 64 OMNIBUS PETER LUPTON & FRAZER ROBINSON CENTURY COMMUNICATIONS LONDON Copyright c Peter Lupton and Frazer Robinson 1984 All rights reserved First published in Great Britain in 1985 by Century Communications Ltd, 12 - 13 Greek Street, London WI V 5LE ISBN 0 7126 06769 Printed in Great Britain in 1984 by Billing & Sons Limited, Worcester. Typeset by Spokesman, Bracknell NOTE: The programs in this book have been typeset directly from the Commodore 64. CONTENTS Acknowledgements Introduction PART 1 INTRODUCING COM MODORE 64 PROGRAMMING 1 Computers and Programs 1 2 Setting up your 64 3 3 First Steps 8 4 Programming 18 5 Program Control 34 6 Data and Programs 52 7 Pieces ofStrlngs 59 8 Functions 73 9 Logical Thinking 82 10 Memory Management 89 11 Sound and Music - Part 1 93 12 Character Graphics 119 13 High Resolution Graphics 146 14 Sprites 158 15 Permanent Storage 184 16 Advanced Techniques 204 PART 2 ADVANCED COM MODORE 64 PROGRAMMING 17 BASIC and how it works 211 18 Machine code on the 64 234 19 Bit-Mapped Graphics - Part 1 262 20 Bit-Mapped Graphics - Part 2 280 21 Display Interrupts 301 22 Programs and People 315 23 Sound and Music - Part 2 331 24 The 1541 Disk Drive 348 25 Advanced Disk Operations 364 26 The MPS801 Printer 403 APPENDICES 1 Abbreviations 419 2 BASIC Commands 420 3 BASIC Tokens and Abbreviations 431 4 Summary of DOS Commands 434 5 BASIC Error Messages 435 6 DOS Error Messages 441 7 Speeding Up Programs 446 8 Colour Codes 448 9 Musical Notation 449 10 N umbering Systems 453 11 Kernal Routines 458 12 The 6510 Instruction Set 464 13 SID Registers 472 14 VIC ITRegi sters 474 15 Screen Memory Maps 476 16 Character Codes 478 17 System Memory Map 483 18 Graphics Loader Programs 484 Index 497 ACKNOWLEDGEMENTS It is customary at this point to mention all those people without whose help this book would not have been possible. We would like to acknowledge the support and enthusiasm of Peter Rhodes without whom none of our books would have been possible. We haven't been able to say so until now - Thanks Peter! INTRODUCTION This book is an omnibus edi tion of our two books, The Commodore 64 Handbook The Advanced Commodore 64 Handbook We have taken the opportunity to correct one or two errors which crept into the first editions, and to clarify some obscurities noticed by our readers. The combined volumes form a complete guide to the Commodore 64. The firstsection of this book provides a complete introduction to BASIC and the fe atures of the 64, while the second introduces machine code (providing a set of routines to speed up graphics) and describes the use of disk drives and printers. With this book at your side you will be fully armed for the great adventure of64 programming! Peter Lupton and Frazer Robinson 1984 THE COMMODORE 64 OMNIBUS PART 1 INTRODUCING COMMODORE 64 PROGRAMMI NG CHAPTER 1 COMPUTERS AND PROGRAMS Despite everything you may have heard about computers being hyperintelligent machines which are on the point of taking over the world, a computer is not really intelligent at all. A computer is at heart little more than a high-speed adding machine, similar to an electronic calculator, but with more sophisticated display and memory facilities. The feature that gives computers their immense flexibility and potential is this: they can store lists of instructions which they can read through and obey at very high speed. These lists of instructions are called programs, and most of this book is concerned with how these programs are written. The computer instructions which form programs must fo llow certain rules, or the computer will not be able to understand them. The rules for wri ting programs resemble the rules of a spoken language, and so the set of instructions is often said to form a programming language. There are many different computer programming languages; the one that the Commodore 64 understands (in common with most other personal computers) is called BASIC. (The name BASIC is an acronym for Beginners' All-purpose Symbolic Instruction Code.) A programming language is much simpler than a human language because computers, for all their power, are not as good at understanding languages as people are. The BASIC language used by the 64 2 The Commodore 64 Omnibus - Pa rt 1 has less than 80 words. The rules fo r combining the words - the (grammar' of the language - are much more strict than for a language like English, again because it is difficultto make computers that can use languages in the relaxed sort of way in which we speak English. These may seem like limitations, but in fact as you will discover BASIC is still a powerful language, and it is possible to write programs to perform very complex tasks. Finally, remember this. Your computer will not do anything unless you tell it to, so whatever happens, you're the boss. The 64 won't take over the world unless you make it! CHAPTER 2 SETTING UP YOUR 64 Before you can use your Commodore 64 you must connect it to a power supply and to a television. To t I I I + " \ +\ I I I \ \ Cartridge Tuning TV Audio & Serial Cassette User Socket Screw Lead Monitor Interface Interface Port The Commodore 64 Connectors - Rear View �,.� , rL/ I , Joystick On/Off Power Sockets Switch Socket The Commodore 64 Connectors - Side View load and save programs you will also need to connect a cassette unit to the 64. Before connecting anything, make sure you know what should plug in where. The diagrams above show all the connector sockets of the 64. 4 Th e Commodore 64 Omnibus - Part 1 There are several sockets through which the 64 passes and receives information, and one through which it gets the electrical power it needs to operate. The sockets are not all labelled, so be sure �o refer to the diagram before plugging anything In. POWER The 64 needs a low voltage DC supply, and this is obtained from the power supply unit supplied with your computer. Plug this power supply into the mains, and plug the output lead into the computer. The socket for the power supply is at the right­ hand side of the machine. Do not switch on yet! DISPLAY The Commodore 64 uses a standard domestic TV to communicate with you, and for this almost any TV will do. To get the best results, use a modern, good quality colour TV. If you use a black and white set, the colour displays produced by the computer will appear as shades of grey. To connect the 64 to the TV, plug the supplied aerial lead into the aerial socket of the TV, and plug the other end into the socket at the back of the computer (check the diagram). The lead has a different type of plug at each end, so take care that you don't try to force in the wrong one. CASSETTE RECORDER The Commodore 64, like most other small computers, uses cassette tapes to save programs or information, so that you don't have to type them in every time you need them. You cannot use an ordinary cassette recorder with the 64: you must use the special Commodore Setting up your 64 5 cassette unit, which is available at extra cost. The cassette unit plugs into a socket at the rear of the computer. No separate power supply is needed for the cassette unit as this is provided by the computer. DISK DRIVE Programs can also be stored on floppy disks. A floppy disk drive is faster than a cassette unit and is more flexible in use. (It is also much more expensive). The disk drive connects to the round serial interface socket at the rear of the computer. The disk unit requires its own power supply and so must also be plugged into the mains. PRINTER If you have a printer, its lead plugs into the serial interface socket at the rear of the computer. If you are also using a disk drive you should plug the printer lead into the spare socket at the rear of the disk drive. The printer also has a separate mains lead. SWITCHING ON When you have connected everything together, you are ready to switch on. The equipment must be switched on in the right order, or there is a risk of damaging the computer. First switch on the TV. Second, switch on the disk drive and then the printer. (Remember that you should never switch a disk unit on or off withdisks inside it.) Last, switch on the computer itself. 6 Th e Commodore 64 Omnibus - Part 1 Switching offshould be carried out in the reverse order: first the computer, then the disk drive and printer, and last of all the TV. TUNING To get a display to appear on the TV screen, tune to channel 36, or, on a pushbutton set, use a spare channel and keep tuning until you see this appear on the screen: **** COMMODORE 64 BASIC V2 **** 64K RAM SYSTEM 38911 BASIC BYTES FREE READY. If you are unable to tune the television, perform the fo llowing checks: 1 Check that the aerial lead is connected. 2 Make sure the computer is connected to the mains and switched on. The red power indicator should be on. 3 Try tuning the TV again, and - if possible - try a different TV. Setting up your 64 7 With a little time and careful tuning, it is possible to get a clear and stable display on nearly all types of TV.
Recommended publications
  • Questdata Volume 2, Issue 2
    tdatQ ___ _ Issue #2 THE TALKING ELF 6. Non Super Elf owners can connect the Q output to a speaker via a transistor driver or de cassette out line (Q) can be fed into the plxmo i.rJiut of a audio amplifier for optimum results. The program can be tested without the amplifier by playing a normal music cassette into the input line while the program is This will still allow reproduction am output of the information on the tape. You oou1d also record you own voice m a tape am play it through the cassette input line. · The following changes must be made to the program for use on an Elf II. location· Contents 0016 61 001D 35 by OO!F 3D Bobby R. lewis 0027 35 0029 3D OOSD 61 The following program will allow OCA-1802 users In addition, a speaker and amplifier must be to digitize voice information from a microphone connected to the Q output line. display the information graphically, ani reproduce it for output via a speaker. 'Ire only additional hardware required is a micropb:me ani mini-speaker amplifier. The program, as written. will nm on systems configured as follows: 1. EF3 - cassette input 2. Q - speaker output 3. EF4 - input switch 4. Continuous RAM memory from address <XXX> to OFFF. 5. The amplifier will be attached as f ollO'NS: a. Microphone to input b. Ext speaker output attached to the cassette inp..lt. C[B:VlC ClUB C£lSr:1ftC ClUB ClUB CDSr:lftC ClUB Page 2 OI'ERAI'OC JNSIRUCITOOS ADDR CODE LABEL OPCODE OPERAND COMMENT 1.
    [Show full text]
  • The New Digital Multimeters How to Make the Right Buying Judgments
    Popular Electronics WORLD'S LARGEST SELLING ELECTRONICS MAGAZINE FEBRUARY 1980 95C Audio Noise Source For Testing Hi -Fi How a Car "Econometer" Can Save Gas A Mastermind Controller for Photo Labs The New Digital Multimeters How to Make the Right Buying Judgments 94LII AN VIS N019ri1N1'4 t 1S ND19NN0) Lc. t) IH)37H) 2100 FM Tuner o9VIY 0111 960)LE00 0 3I) 956095 >00 Speaker System i =i iumnos PRO -20 Dynamic Processor 14024 14278 Issue Ki up Popular Electronics www.americanradiohistory.comAmericanRadioHistory.Com en qua i y counts Do not be fooled by the low prices, the brand Quality metal cases with machine screws and heavy new lab quality frequency counters have inportart guage black anodized aluminum provide RF shield - advantages over instruments costing much more. ing ,light weight and are rugged and attractive - not The models 7010 and 8010 we not old counters repack- economical plastic. aged but 100% new designs using the latest LSI For improved resolution there are 3 gate times state-of -tie -art circuitry. With only 4 IC's, our new "010 on the 7010 and 8 gate times on the 8010 with rapid offers a host of features including 10 Hz to 600 MHz display update. For example, the 10 second gate time operation, ç on digit display, 3 gate times and more. either model will update the continuous display every This outperrorms units using 10-15 IC's at several 10.2 seconds. Some competitive counters offering a times the size and power consumption. The older 10 second gate time may require 20 designs using seconds many more parts increase the possiblity between display updates.
    [Show full text]
  • Tymshare Manuals Instant Series Super Basic
    Price $1.50 TYMSHARE MANUALS INSTANT SERIES SUPER BASIC October 1968 TYMSHARE, INC. 525 UNIVERSITY AVENUE, SUITE 220 PALO ALTO, CALIFORNIA 94301 DIVISION OFFICES Los Altos, California -Inglewood, California - Arl ington, Virginia DISTRICT OFFICES Newport Beach, California - Englewood Cliffs, New Jersey San Francisco, California - Dallas, Texas - Seattle, Washington © 1968, TYMSHARE, I NC., Litho in U.S.A. CM4 iii CONTENTS Page PREFACE. ....................................... 1 SECTION 1 - INTRODUCTION TO SUPER BASIC. ............. .. 3 Defining The Problem 3 Flowcharting The Problem. ................................... .. 3 Entering The Computer And Calling SUPER BASIC 3 Computer Programming ... .................................. .. 5 Writing The Program In SUPER BASIC. .......................... .. 6 Direct And Indirect Statements .............................. .. 6 INPUT Statement .................. .. .................... .. 6 Variables .................... .. ........................ .. 6 Typing Numeric Data Into Variables. .......................... .. 6 Numbers. .............................................. .. 7 Strings. ................................................ .. 7 Typing Strings Into Variables. ............................... .. 7 Replacement Statements. .................................... .. 8 Arithmetic Operators And Their Priority Of Execution. ................ .. 8 Priority Of Execution. .................................... .. 8 Parentheses. ........................................... .. 8 PRINT Statement ........................................
    [Show full text]
  • MICROCOMPUTING for Business
    October 1979 S2.50 kilobaud MICROCOMPUTING for business . education . FUN! In This Issue—35 Articles Including: Special Emphasis on 6800 Systems Six Articles The World Power Systems Scam page 56 Exatron's Stringy Floppy: a Mass Storage Alternative page 98 Ulysses in Computerland: in Quest of Business Systems page 128 Inexpensive Logic Analyzer page 172 Complete Table of Contents on page 5. Fpcot PEflGCM One-Drive System: S399. (40-track) & $675. (77-track) Two-Drive System: S795. (40-track drives) & S1350. (77-track drives) Three-Drive System: $1195. (40-track drives) & S2025. (77-track drives) Requires Expansion Interface. Level II BASIC & 16K RAM Low Cost Add-On Storage for Your TRS-80*. In the Size You Want. When you're ready for add-on disk storage, we're ready for you. Ready with six mini-disk storage systems — 102K bytes to 591K bytes of additional on-line storage for your TRS-80*. • Choose either 40-track TFD-100™ drives Whether you need a single, 40- — 197K, 394K and 591K bytes for one-, or 77-track TFD-200™ drives. track TFD-100™ add-on or a three-drive two and three-drive systems. add-on with 77-track TFD-200™s, you PATCH PAK #1™, our upgrade • One-, two- and three-drive systems im- get more data storage for less money program for your TRSDOS*, not only mediately available. from Percom. extends TRSDOS* to accommodate 40- and 77-track drives, it enhances • Systems include Percom PATCH PAK Our TFD-100™ drive, for example, TRSDOS* in other ways as well. PATCH #1™, on disk, at no extra charge.
    [Show full text]
  • BASIC Zgrass--A ~Ophisticated Graphics Language for the Baliy Home Library Computer
    BASIC Zgrass--A ~ophisticated Graphics Language for the Baliy Home Library Computer Tom DeFanti, University of illinois at Chicago Circle Jay Fenton, Dave Nutting Associates Nola Donato, University of Illinois at Chicago Circle Abstract Home computer users are just now discovering arcade units, its projected cost, without color computer graphics. Modest extensions to BASIC al- tv, is about $750.00, including the arcade unit. low plotting but not much more. The Bally Home Zgrass itself takes up 16k bytes of ROM Library Computer, however, has hardware to aid im- storage and has 16k bytes of RAM for user storage plementation of video games. Custom integrated and system use. An additional 16k ROM (referred circuits working on a 160XI02 pixel (2 bits per to as the 'extension' below) plugs into the side pixel) color television screen allow certain forms and provides room for a compiler and other of animation in real time. To give this power to features. Audio cassette storage and modem link- the user, BASIC Zgrass has been designed and im- age to other computers is provided. Software for plemented. It is an extension of BASIC that al- driving optional intelligent floppy disk drives is lows parallel processes, picture objects that also built-in. Further hardware in this unit in- move, scale and group together as well as several cludes four hand controls, a 24-key pocket calcu- drawing modes. There are also software controls lator keyboard, a three-voice sound generator and of a three-voice music synthesizer, interactive an IEEE Bus interface. Zgrass is the operating input devices, a film camera and an IEEE bus in- system for this computer as well.
    [Show full text]
  • Index to Hp 2000 Series Contributed Library
    INDEX TO HP 2000 SERIES CONTRIBUTED LIBRARY • TIME-SHARED BASIC/2000 • ORDERING INFORMATION • COMPLETE LIST OF LmRAR'Y PROGRAMS • DOCUMENTATION FORM • 2000 NON-BASIC (FORTRAN, ALGOL, HP ASSEMBLY) • ORDERING INFORMATION • COMPLETE LIST OF LIBRARY PROGRAMS • HP SALES AND SERVICE OFFICES 5952-4369 (22) Printed in U.S.A. JULY 1974 CLASSIFICATION CODE CATEGORY (Not all categories have programs. Please refer to this INDEX for available programs.) 000 OPERATING AND PROGRAMMING SYSTEMS 500 SCIENTIFIC AND ENGINEERING APPLICATIONS ~01 TI"E.SHARED DPEHATING SVSTE~S 501 'OCIA~ AND BEHAVIDRA. SCIENCES 002 1/0. TE~!CDMMUNICAfIOH' 502 GEOPHVSlCS 003 1/0. SPECIA~ DEVICE '03 GEO~O" 004 110. STATUS PROCESSING 514 OCEANOGRAPHY 005 REPURT GENERATORS 51S 'HYlltS 006 110. INSTRUMENT 515 MEDICA~ SCIENCES' 007 DISC OPERATING SYSTE~S 517 CHEMUUY 008 PREPA"ATION O~ SYSTtMS 501 BI O~Or;y 009 110. PAPER TAPE 519 AITRONOMY AND CE~EITIA~ NAVIGATION 010 1/0. PUNCH CARD 511 PETRO~EUM ENGINEERING 011 1/0. PRINTER 511 HVDRAU~IC ENGINEERING 012 DATA ACQUISITION SYSTtMS '12 NUC~EAR ENGINEERING 013 110. AID. OIA 513 E~ECTRICA~ ENGINEERING 014 1/0. GRAPHIC '14 MECHANICA~ ENGINEERING 015 110. DISCIORUM 515 CIVI~ ENGINEERING 016 1/0. MAGNETIC TAPt 51' CHiMICA~ ENGINEERING 81 7 ~OAOERS '17 AERONAUTICA~ ENGINEERING 018 TRANS~ATDRS. ~ANGUAGE !I' 'TRUCTURA~ ENGINEERING 019 EXTERNA~ INTERRUPT PROCESSING 519 SVITEM THtORY 020 REA~ TIM! SYSTEMS 021 SYSTEM ~18RARIES 022 SYSTEM UTI~ITIES 600 MANAGEMENT SCIENCES AND OPERATIONS RESEARCH 100 DATA HANDLING 682 PERT III EDITING 113 CRIfICA~ PATH ANALVSIS 102 IN' ORMATION STORAGE AND RETRIEVA. el. OPTIMIZATION PROQRAMI 113 fAe~E HAND.ING el! ~INIAR PROQRAMMING 104 CHARACTERISYM80~ MANIPU~ATION 511 DISCRET! SYSTEMS SIMU~ATIDN 115 CODE/"AOIX CDNVERSIDN el7 CDNTINUOUS SVSTEMS SIMULATIDN II' OUP~ICATIDN els FORECASTING fECHNIQUI.
    [Show full text]
  • RCA 1802 BASIC Level 3 Ver. 1.1 User Manual
    RCA 1802 BASIC level 3 ver. 1.1 User Manual Last revised: March 18, 2018. Comments? Corrections? Questions? Contact Lee Hart <[email protected]> or Chuck Yakym <T he--E [email protected]> BASIC3 was written for the RCA 1802 by Ron Cenker in 1981. It was RCA's most powerful BASIC interpreter for the COSMAC 1802 family of microcomputers. It is a fast, full-featured floating-point BASIC, much like the Microsoft BASICs of the time. It was documented in RCA's “BASIC3 High-Level Language Interpreter User Manual”, MPM-841A. There were versions to run from RAM or ROM; for disk-based or cassette-based storage systems; versions with the complete interpreter, or that simply ran a compiled BASIC program from ROM for stand-alone applications. It was originally intended for RCA's 1802 products; their various development systems, the VIP, and RCA's line of Microboards. Ron graciously provided the source code, so it could be modified for other 1802 computers. These include the Netronics Elf-II, Quest Super Elf, COMX, Spare Time Gizmos Elf2k, and now the 1802 Membership Card <http://www.sunrise-ev.com/membershipcard.htm>. Thanks to the combined efforts of Lee Hart, Herb Johnson, Ed Keefe, and Chuck Yakym, we are proud to bring BASIC3 back to life on modern 1802 hardware! Please let us know how you like it, or if you find any bugs or have ideas for improvements. REQUIREMENTS The BASIC3 interpreter needs 12k of memory, plus room for the I/O drivers. It also needs at least 1k of RAM, but will use all it finds up to 32k.
    [Show full text]
  • Attention Elf Owners Announcing Quest Super
    P.O. Box 4430M Santa Clara, CA 95054 For will call only: (408) 988-1640 Same day shipment. First line parts only Factory tested Guaranteed money back 2322 Walsh Avetimp v•03 Quality IC's and other components at fac- tory prices INTEGRATED CIRCUITS V W' ELE CT R O NICS 7411211 740411 '11011 -4119 63 7470/1 742211 , 39 '430o 20 1442% 50 145/4 69 144711 60 14441/1 69 7450N 747111 29 717511 us 74159 68 748911 200 7410N IC SOCKETS .19291 Seder 714 Leo PerfoN '4939 43 2604207 ;10 ;IN lOP PIN IUP CIL0,00 LED .0oun600 Clop' •495/1 69 114346T 24 49 '410M1 90 293430 52 ,50 ;1 23 ATTENTION ELF OWNERS 7410711 29 11/350 50 234051 '6 '6 28 CONTINENTAL SPECIALTIES VoCI 3/ 1.M370 IS 204060 -• •412111 7, 91LO/A 10 27 36 51 Cf.p,elf kne treaapora .7,Tru 161238 59 484317 00 C134066 40 900765 20 79 40 57 11111111 1,911 F99 CU 8111 15 ANNOUNCING QUEST SUPER BASIC 7412% 39 04379 CO CD4068 69 1M381)11 00 C01069 40 OW. - 40 01( SIRRE "MAP TOOLS MAR At last a Full Size Basic for 1802 systems. A Tiny Basic Source now available $19.00 74150N 95 IM3111 60 104410 Ponabie 1161909818, 111 IN 7115114 69 184342 60 CD4021 complete function Basic including two dimen- S-100 Slot Expansion. Add 3 more S-100 slots to 7415% 100 1.147030 ix CO4D72 28 9- , 20 41'. 0/11AP 1011 3 7415711 69 48470946 28 204073 'II PIII SPECIAL PRODUCTS sional arrays, string variables, floating point.
    [Show full text]