COMMODORE MAGIC M Ic H a E L C a L L E R Y Is Vicc-President of Learningware Corpo Ration, a Firm Specializing in Software for Instruction and Training
Total Page:16
File Type:pdf, Size:1020Kb
COMMODORE MAGIC M ic h a e l C a l l e r y is vicc-president of Learningware Corpo ration, a firm specializing in software for instruction and training. He teaches about computers and computer graphics at the New School for Social Research, New York University, and Manhattan College. Mr. Callery is the author of many reviews and articles that have appeared in Computer Buying Guide, Computers & Programs, MicroKids, and SoftSide maga zines. He and his nine computers live happily in New York City. COMMODORE MAGIC Create Astonishing Graphics and Sound Effects for Your Commodore 64! MICHAEL CALLERY A HARD/SOFT PRESS BOOK E.P. DUTTON, INC. New York This one’s for Dad The author would like to thank the people at Hard/Soft Press for their encouragement, prodding, and most of all, trust. Special acknowledgment to Terry Nasta for her inestimable contributions to the manuscript. Diagrams by Shane Kelley Technical assistance: Rick Hoffman Copyright © 1984 bv Hard/Soft Inc. All rights reserved. Printed in the U.S.A. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system now known or to be invented, without permission in writing from the publisher, except by a reviewer who wishes to quote brief passages in connection with a review written for inclusion in a magazine, newspaper, or broadcast. Published in the United States by E. P. Dutton, Inc., 2 Park Avenue, New York, N.Y. 10016 Library of Congress Catalog Card Number: 84-70407 ISBN: 0-525-48120-6 Published simultaneously in Canada by Fitzhenrv & Whiteside Limited, Toronto 10 987654321 COBE First Edition CONTENTS 1 ________________ Getting Started The magic of Commodore graphics and sound. General program hints and tips, and a peek inside to see just how it works. A guide to the special Commodore keys. A Basic Potpourri Basic language highlights. The anatomy of a byte. Logic made easy. Snooping inside your memory Painless number conversions. Generating computer poetry. Tricks with Text 22 Mastering Commodore's text displays. How programmers create professional-looking screens. Flashy text, SHIFTy characters, and positioning FUNctionality. An Excursion into Color 32 Controlling the Commodore's dazzling palette of colors. Memory surprises and a program to fine-tune your monitor. A tour of its powerful video display chip and what it can do. | CONTENTS 5 An Introduction to Animation 40 Moving figures across the screen may look like magic, but here you'll find the simple secrets of sophisticated internal, one-frame, and multiframe text animation. 6 Quite a Character 47 How the Commodore produces and stores its characters, and how you can enhance and alter them with ease. Customizing tricks and shortcuts. Input/output magic and the phantom ROM, 7 The Character Set Editor 56 A step-Py-step guide to constructing a program that will let you create whole new sets of characters—while your computer does all the dirty work. And, meet an elegant decoder. 8 There Are Sprites at the Bottom of My Garden 71 Text may be fun, but sprites are pure magic. How to whip them together, glide them across your screen, and manipulate them most effectively. Sublime axis expansions and 3-D effects. 9 Building the Sprite Editor 84 Constructing and keeping track of sprites can be tricky business. This will teach your Commodore how to handle all the details for you. And add many user-friendly features. CONTENTS | vii 10 The Rainbow Revolution 96 Color, color, and more color. Characters and sprites can be far flashier than you've seen, when you discover multicolor and extended background modes. The importance of mastering masks. 11 Hi-Res Hijinks 105 With all 64,000 dots at your command you can create eye-popping displays. The joys of artifacting, aliasing, aspect correction, and multicolor hi-res. A handful of powerful programming tools. 12 Screen Maker 120 Your television set becomes an artist's canvas as you create a program to make hi-res drawing a snap. Using a joystick as a paintbrush. Mixing hi-res graphics and sprites. 13 Odds and Ends 138 Basic can't do everything by itself. A glimpse into assembler to let you harness the full power of your Commodore 64. New assembler subroutines to enhance the power of your programs. Techniques for effortless saving and loading. 14 Introducing SID 151 If you're impressed by the Commodore graphics, wait until you hear its sound! Put together your own masterful sound editor to create startling multivoice music and sound effects. Music theory without tears. CONTENTS 1 5 _______________ The Multilingual Commodore 174 Your Commodore 64 can speak many languages. Here well explore the graphics and sound abilities in several of the most popular ones—and discover new power for Basic. 1 6 _________________ Software Tools 197 Professional programmers are creating programs to help you make the most of your Commodore 64. Here well put them under the microscope and examine their good—and not so good—points. Appendix A: Programming Primer 211 Appendix B: Commodore Character Set 222 Appendix C: Selected References 229 Index 230 Getting Started D id you ever watch a really expert magician perform an astonishing trick right before your eyes, and all you could think of was “How in the world did he do that?” This book gives you a generous collection of graphics and sound tricks written expressly for the Commodore 64—and reveals the secrets behind them. Just follow the simple, step-by-step instructions, type in a few words of code, hit the RETURN key, and in seconds, your screen will be performing spectacular feats of computer magic. But best of all, you’ll learn techniques for inventing new' and different ones of your own. That way you can transfer your own creativity to the screen. Valuable Software Tools Whether you’re an old hand at computing or just starting out, Commo dore Magic will show you how to get the maximum graphics and sound horsepower out of your equipment—with plenty of interesting examples, tips, and tricks along the way. While most books limit you to the examples between their covers, we provide you with four sophisticated pieces of software—a powerful character editor, sound generator, hi-res graphics editor, and sprite editor—that you can use to create impressive sound and graphics programs of your own design. What’s more, you’ll also get a programmer’s tool kit of valuable mini programs and routines that make customizing and writing your programs a breeze. I 1 2 | COM M ODORE M AGIC Commodore Magic makes mastering graphics and sound painless, simple, and loads of fun. It’s like having a friend who’s a computer expert sitting next to you, showing you eye-popping tricks and pointing out how everything works. And when you’ve finished typing in the examples, you’ll have a reuseable collection of powerful software tools that rival those you can buy. A Magical Sampler In the following chapter we’ll clear up some of the mysteries of Basic, which is actually very easy once it’s been explained properly. With a good teacher, even young children can pick it right up. You may not know a PEEK from a POKE from a bowl of spaghetti before you start, but pretty soon you’ll be tossing bytes and Boolean binary bits around with ease and assurance. Ode to a Commodore With this book as a guide, you can even teach your computer how to write poetry. Okay, so maybe it won’t be Robert Frost, but I’ll bet your computer never handed you a poem before. We’ll also put together a program that converts our number system to the computer’s, and vice versa, to save you hours of pencil work later on. In Chapter 3, we’ll cover tricks with text. You’ll learn how to dance characters across your screen in dozens of inventive ways. Also, you’ll find out how to set the artist in your Commodore 64 free and create exotic, random displays. Chapter 4 takes you on an excursion into color. Your clever Commodore 64 can juggle 16 colors at once, which is many more than some expensive computers can. We’ll conjure up a professional-looking color bar chart, and then give your text vibrant rainbow hues. Kaleidoscopes were never this much fun. In the fifth chapter we’ll start experimenting with what is probably the most impressive of the Commodore’s bag of tricks—animation. We’ll intro duce you to our raster graphics swimmer, and have it do a few laps across your screen. You’ll learn how to flick out flicker, and generate some shimmery internal movements. Next, you’ll become an expert at taking out the computer garbage. You’ll need to, since you’ll be replacing it with vour own customized set of letters GETTING STARTED 3 and numbers. We’ll give you a smashing short-cut to making your own graphics building blocks, bv snooping deep inside one of your computer’s chips. And in the following chapter, we’ll build our first powerful software editor. With it, you’ll be able to write upside-down or backwards—or even in Greek—as easily as you type your name. Animation Magic In Chapter 8 you’ll get to know sprites, those magical little complex shapes that can dart around your screen. Sprites make graphics come alive. You’ll use one to create a space ship and launch it once around the galaxy.