149

The Easy Guide to Your Commodore 64

Embed Size (px)

Citation preview

Page 1: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 1/148

Page 2: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 2/148

Page 3: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 3/148

T H E A S YG U I D E T Y O U RC O M M O D O R E 6

Page 4: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 4/148

Page 5: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 5/148

T H E A S YG U I D E T Y O U RC O M M O D O R E 6 4

J O S E P H K A S C M E R

B e r k e l e y P a r i s D i i s s e l d o r f

Page 6: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 6/148

C o v e r a r b S a t o Y a m a m o t oB o o k d e s i g n b I n g r i d O w e n

C o m m o d o r e 6 4 V I C - 2 0 , a n d D a t a s s e t t e a r t r a d e m a r k s o C o m m o d o r e B u s i n e s sM a c h i n e s , I n c .C P / M i r e g i s t e r e d t r a d e m a r k o D i g i t a l R e s e a r c h , I n c .

S Y B E X i n o a f f i l i a t e d w i t h a n m a n u f a c t u r e r .

E v e r y e f f o r t h a b e e n m a d e t s u p p l y c o m p l e t e a n a c c u r a t e i n f o r m a t i o n . H o w e v e r ,S Y B E X a s s u m e s n r e s p o n s i b i l i t y f o r i t u s e , n o f o a n i n f r i n g e m e n t s o f p a t e n t s o r o t h e rr i g h t s o t h i r d p a r t i e s w h i c h w o u l d r e s u l t . M a n u f a c t u r e r s r e s e r v e t h e r i g h t t o c h a n g e s p e c if i c a t i o n s a a n t i m e w i t h o u t n o t i c e .

C o p y r i g h t © 1 9 8 3 S Y B E X I n c . W o r l d R i g h t s r e s e r v e d . N p a r t o t h i s p u b l i c a t i o n m a b s t o r e d i r e t r i e v a l s y s t e m , t r a n s m i t t e d , o r e p r o d u c e d i a n w a y , i n c l u d i n g b u n o l i m i t e d t p h o t o c o p y , p h o t o g r a p h , m a g n e t i c o o t h e r r e c o r d , w i t h o u t t h e p r i o r a g r e e m e n ta n w r i t t e n p e r m i s s i o n o t h p u b l i s h e r .

L i b r a r y o f C o n g r e s s C a r d N u m b e r : 8 3 - 4 0 2 3 2I S B N 0 - 8 9 5 8 8 - 1 2 6 - 8P r i n t e d i t h U n i t e d S t a t e s o A m e r i c a1 9 8 7 6 5 4 3 2 1

Page 7: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 7/148

T o J . A K u b o k a w a , a r e s e a r c h e r a n p h o t o g r a p h e rw i t h p a s s i m f o q u a l i t y .

Page 8: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 8/148

C O N T E N T SA c k n o w l e d g e m e n t s i P r e f a c e

C O M I N G I N T O P O W E RM a s t e r a n S e r v a n t M e e tS e t t i n g U t h C o m p u t e rC o n t r o l f r o m t h K e y b o a r d

V I D E O P R I N T I N G 1 S c r e e n C o n t r o l 1 V i d e o P r i n t i n g 1 3

P L A N S A N P R O G R A M S 1 S c h e d u l i n g C o m m a n d s 1 S t a n d - i n s F o N u m b e r s 2 N u m e r i c a l P r e d i c t i o n s 2 C o m m a n d s i G r o u p s

Page 9: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 9/148

D E C I S I O N M A K I N G B C O M P U T E R 2 U s i n g j u d g e m e n t 2 S i m u l a t i o n s 3 1

P R O G R A M C O N T R O L 3 P r o g r a m e d K i o C o m m a n d s 3

C o m m a n d s f o M o v i n g A m o n g S t a t e m e n t s 4 R e p e a t i n g W i t h i n L i m i t s 4

H A N D L I N G W O R D S A N DI N F O R M A T I O N 5

S t r i n g s : W o r d s f r o m t h C o m p u t e r 5 I n s i d e I n f o r m a t i o n 5 7T h C l o c k I n s i d e 6 O u t s i d e C o n t a c t 6

E C O N O M Y C L A S S S T O R A G E — T A P E S 7 U s i n g P r o g r a m s o n C a s s e t t e T a p e s 7 F a c t s a n F i l e s o T a p e 7

H I G H S P E E D S T O R A G E — D I S K S 7 M a r r i a g e o M a c h i n e s 7

U s i n g P r e r e c o r d e d D i s k s 8 P r o g r a m s f r o m C o m p u t e r t D i s k 8 U s i n g M o r e T h a n O n D i s k D r i v e 9 F a c t s a n F i l e s o D i s k 9

Page 10: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 10/148

B U I L D I N G A N R E B U I L D I N GP R O G R A M S 9

A d d i n g P r o g r a m P a r t s 9 R e b u i l d i n g B o r r o w e d P r o g r a m s 1 0

1 T H I N S I D E S T O R Y 1 1 S t e p P a s t t h T r a n s l a t o r s 1 1

W h a t I t h C o m m o d o r e 6 4 1 1 E x p a n d i n g t h C o m p u t e r 1 1

A P P E N D I C E S 1 2 S p e c i a l - P u r p o s e C o m m a n d s 1 2

J a r g o n P h r a s e G u i d e 1 2

I n d e x 1 2

Page 11: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 11/148

I

A C K N O W L E D G E M E N T S

T h a n k s t J a m e s C o m p t o n f o h i e d i t i n g a n t t h o s e i t h e d i t o r i a la n p r o d u c t i o n d e p a r t m e n t s a S y b e x w h w e r e a c t i v e i n t u r n i n g m m a n u s c r i p t i n t o t h i s b o o k .

S p e c i a l t h a n k s t H e i d i M i l l e r f o p r e p a r i n g t h i n d e x a n t B i l l M l o t o kf o b r i n g i n g h i t e c h n i c a l k n o w l e d g e , c l a s s r o o m e x p e r i e n c e , a n g o o d s e n s et v a l u a b l e r e v i e w o t h b o o k ' s c o n t e n t .

A l s o t h a n k s t P a u l L o s n e s s o P C o m p u t e r s i E C e r r i t o , C A f o p r o v i d i n g i n f o r m a t i o n .

T h p o e t r y o p a g e 1 i b P h i l i p J a m e s B a i l e y , f r o m h i F e s t u s . T h v e r s e o p a g e s 1 2 - 1 3 i f r o m R o b e r t W S e r v i c e ' s " T h e L a o t h Y u k o n . "

Page 12: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 12/148

P R E F A C E

T h i s b o o k i a b o u t c o n t r o l l i n g y o u r p e r s o n a l c o m p u t e r . I i y o w i l ld i s c o v e r h o y o c a a c h i e v e c o n t r o l o v e r c o m p u t e r i f e d a y s . J a g o a n t h e o r i e s o c o m p u t e r s c i e n c e d o n ' t h e l p i t h i s a i m , a n i t h i sb o o k y o u w o n ' t b b u r d e n e d w i t h t h e m . T d i r e c t t h c o m p u t e r a a e x t e n s i o n o y o u r o w m i n d , y o n e e d n s p e c i a l b a c k g r o u n d i m a t h em a t i c s o b e n t f o p r o g r a m m i n g . I f a c t , y o c a c o n t r o l c o m p u t e r j u s ta e a s i l y a y o u d o a n a u t o m o b i l e o t y p e w r i t e r . A y o l e a r n d i e e s s e nt i a l s , t h o p e r a t i o n b e c o m e s s i m p l e r .

I y o h a v e p a r t i c u l a r u s f o t h C o m m o d o r e 6 4 o i y o u ' r e i n t e re s t e d i f i n d i n g o u a b o u t c o n t r o l o p e r s o n a l c o m p u t e r , t h i s b o o k i f o y o u .

B e c a u s e y o c a u s c o m p u t e r i d i f f e r e n t w a y s , y o c a n a p p r o a c ht h i s b o o k f r o m m o r e t h a n o n d i r e c t i o n :

C h a p t e r i b r i e f i n t r o d u c t i o n t e l l i n g w h e r e t h c o n t r o l s a r e , h o t p l u g y o u r c o m p u t e r s y s t e m t o g e t h e r , a n w h a t b u t t o n s t p u s h a n n o t p u s h . N m a t t e r w h a t y o p l a n t u s y o u r c o m p u t e r f o r , a r u n t h r o u g ht h i s c h a p t e r w i l l p u y o a e a s e w i t h t h b o i f r o n t o y o u .

I y o p l a n t u s e o n l y p r e r e c o r d e d p r o g r a m s a n w i s h t a v o i d w r i t i n gc o m p u t e r d i r e c t i o n s y o u r s e l f , y o c a s k i p a h e a d t C h a p t e r i t h p r g r a m s a r o c a s s e t t e t a p e , o t C h a p t e r i t h e y a r o d i s k s . A n i y o u ' d l i k e t m a k e f u l l u s o t h p r o g r a m s o d i s k s , r e a d t h s e c o n d p a r to C h a p t e r 9 S i n c e t h C o m m o d o r e 6 i s n ' t y e a s w e l l s u p p l i e d w i t hc o m m e r c i a l s o f t w a r e a s o m e o l d e r p e r s o n a l c o m p u t e r s , y o m a n o w a n t t o l i m i t y o u r s e l f t t h e s e c h a p t e r s .

I y o u ' d l i k e t w r i t e y o u r o w d i r e c t i o n s t t h c o m p u t e r , y o s h o u l dr e a d C h a p t e r s 2 , 3 , 4 a n 6 a n a l s o t h f i r s t p a r t o C h a p t e r 9 T h m o s t o p t i o n a l c h a p t e r o f t h b o o k i C h a p t e r 1 0 I y o u ' d l i k e m o r e

Page 13: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 13/148

X

c o n t r o l o v e r t h C o m m o d o r e 6 t h a n i p r o v i d e d t h r o u g h t h B A S I Cc o m m a n d s , o h a v e a i n t e r e s t i h o t h c o m p u t e r w o r k s a n d w h a t e l s ec a n b e d o n e w i t h m o r e c u s t o m i z e d c o m p u t e r , r e a d C h a p t e r 1 0 I w i l lh e l p y o t u n d e r s t a n d t h m a c h i n e a n t e x p a n d y o u r a b i l i t i e s w i t h i t F o u s i n g t h C o m m o d o r e 6 4 h o w e v e r , i t ' s n o e s s e n t i a l .

T h c h a p t e r s c o n c e n t r a t e o t h c o m m a n d s a n o p e r a t i o n s m o s t u s e f u lt t h g e n e r a l r e a d e r . Y o u ' l l f i n d o t h e r a v a i l a b l e c o m m a n d s b u i l t i n t o t h C o m m o d o r e 6 l i s t e d i A p p e n d i x a c c o r d i n g t o t h e i r t y p e a n u s e .

I t h i n t e r e s t o c l a r i t y a n e a s e o c o m p r e h e n s i o n , j a r g o n h a b e e na v o i d e d t h r o u g h o u t t h c h a p t e r s o t h i s b o o k . H o w e v e r , y o m a e n c o u nt e o t h e r c o m p u t e r u s e r s , s a l e s p e r s o n s o b o o k s l a p s i n g i n t o t h d i a l e c t .A p p e n d i x c a h e l p m a k e t h e m i n t e l l i g i b l e t y o u .

d e c a d e b e f o r e t h e f i r s t C o m m o d o r e 6 w a b u i l t , t h e i d e a o " p e rs o n a l c o m p u t e r " w i t h s u c h c a p a b i l i t i e s w a u n h e a r d o f I t c u r r e n t a v a i la b i l i t y i m e a s u r e o t h c h a n g e s b r o u g h t a b o u t b t h t e c h n o l o g yd e v e l o p e d i t h i n t e r v e n i n g y e a r s . M o r e c h a n g e s l i a h e a d , a n i l e a r ni n t c o n t r o l c o m p u t e r , y o a r t a k i n g f i r s t s t e p t o w a r d p r e p a r i n g f o t h o s e c h a n g e s .E d i t o r ' s N o t e

T g e t h m o s t o u o t h i s b o o k , y o s h o u l d r e a d i w i t h y o u r c o m p u t e ri n f r o n t o y o u , s e u a n c o n n e c t e d t v i d e o m o n i t o r o T s e a d e s c r i b e d i C h a p t e r 1 A e a c h n e c o m m a n d , g r o u p o c o m m a n d s , o s a m p l e p r o g r a m i p r e s e n t e d , t y p e i i e x a c t l y a p r i n t e d t o s e e t h r e s u l t s o y o u r s c r e e n . B s u r e t t y p e i e a c h c h a r a c t e r t h a t y o s e e : l e t t e r s , n u b e r s , p u n c t u a t i o n m a r k s , a n s p a c e s . ( I t y p e s e t p r o g r a m l i n e s , t h s p a c ee q u i v a l e n t t o n s t r o k e o t h s p a c e b a o y o u r k e y b o a r d w i l l v a r ys l i g h t l y , b u i w i l l a l w a y s b a p p r o x i m a t e l y e q u a l t t h s p a c e b e t w e e nw o r d s i t h i s s e n t e n c e . ) T h s p a c e s a r n o a b s o l u t e l y e s s e n t i a l ; a n p r g r a m w i l l r u w i t h o u t t h e m , b u t y o w i l l f i n d t h e s c r e e n d i s p l a y m u c he a s i e r t r e a d i y o i n c l u d e t h e m .

A f t e r y o t y p e i a s a m p l e p r o g r a m , a n b e f o r e y o r u i t c h e c k w h a ty o h a v e t y p e d a g a i n s t t h e b o o k . I y o f i n d y o h a v e m a d e m i s t a k e , g b a c k a n c o r r e c t i t ( Y o u ' l l s e h o t d t h a t i C h a p t e r 2 . T h p r g r a m s h a v e a l b e e n c a r e f u l l y t e s t e d , a n w i l l r u a d e s c r i b e d i e n t e r e dc o r r e c t l y .

F i n a l l y , y o w i l l s e e t h a t t h C o m m o d o r e 6 4 ' s c o m m a n d w o r d s ( o " r e s e r v e d " w o r d s ) h a v e b e e n s e i b o l d f a c e t y p e . B o l d f a c i n g i s i m p l yt y p o g r a p h i c a l c o n v e n t i o n , m e a n t t c a l l y o u r a t t e n t i o n t o t h e s e w o r d s a n dh e l p y o t r e m e m b e r t h e m . Y o w i l l n o s e t h i s e f f e c t o y o u r s c r e e n ,a n d y o u n e e d n o t r t r e p r o d u c e i t

Page 14: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 14/148

Page 15: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 15/148

M A S T E R A N S E R V A N T M E E TF a c i n g c o m p u t e r f o t h f i r s t t i m e , p e o p l e o f t e n f e e l p o w e r l e s s o v e r

t h m a c h i n e — a n d f o g o o d r e a s o n . A f t e r a l l , w h e n i c o m e s t c o p u t e r s , k n o w l e d g e i p o w e r , a n w a l s t a r t o f i g n o r a n t .

w o r k e r o i n c r e d i b l e s p e e d a n u n i m a g i n a b l e p r e c i s i o n , t h c o m p u t e ri n o n e t h e l e s s c o m p l e t e l y o b e d i e n t s e r v a n t . I o n l y n e e d s d i r e c t i o n s , s t a t e di t e r m s i w a b u i l t t r e c o g n i z e . Y o c a c o m m a n d t h C o m m o d o r e 6 w i t h v o c a b u l a r y n l a r g e r t h a n t h a t u n d e r s t o o d b h i g h l y - t r a i n e dc a n i n e . c o m p u t e r f o l l o w i n g y o u r c o m m a n d s c a c h o o s e a m o n g a l t e r n at i v e s , o r g a n i z e i n f o r m a t i o n , s e a r c h f o f a c t s a n p a t t e r n s , a n c o n t r o ld e v i c e s . I c a b o r d e r e d t b e g i n a n d u t y i r e s p o n s e t s i n g l e w o r d o b t h e t r i g g e r i n g o s i n g l e e v e n t .

N c o m p u t e r i a l l - p o w e r f u l o a l l - k n o w i n g , a n t h e r e a r e l i m i t s t o t h o p e r a t i o n o f a n m a c h i n e . B u t h o s e l i m i t s a r i s e f r o m t h d e s i g n a n s p e e d o t h c o m p u t e r a n t h s i z e o i t m e m o r y .

A l t h o u g h y o c a g a i n c o n t r o l o f t h e C o m m o d o r e 6 i s h o r t t i m e , t d s o y o u m u s t f i r s t l e a r n t b e c o m e i t m a s t e r . T h r o u g h t h i s b o o k y o u ' l lf i n d c l e a r w a t d j u s t t h a t .

S E T T I N G U T H C O M P U T E RT h C o m m o d o r e 6 c o m p u t e r c a b s e u b a n y o n e w h c a p o s i

t i o n t y p e w r i t e r a n h o o k u t e l e v i s i o n . I c a w o r k a n y w h e r e t y p ew r i t e r m i g h t , i a n p l a c e u n d i s t u r b e d b s t r o n g v i b r a t i o n s , o e x t r e m e so f t e m p e r a t u r e , d u s t , o h u m i d i t y . I f a c t , t h C o m m o d o r e 6 w i l l w o r k

Page 16: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 16/148

T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

i m o s t p l a c e s w h e r e i t o p e r a t o r i c o m f o r t a b l e . t y p i c a l s e t - u p i s h o w n i F i g u r e 1 . 1 . T h t e l e v i s i o n ( o v i d e o m o n i t o r ) y o u ' l l u s f o d i s p l a y s c r e e n c a s i a n y w h e r e r e a c h e d b t h c a b l e f r o m t h c o m p u t e r .

Y o c a p r e p a r e t h C o m m o d o r e 6 f o u s b c o n n e c t i n g o n l y t w e l e c t r i c a l c o r d s , o n f o p o w e r a n d o n f o t h t e l e v i s i o n o m o n i t o r . O n e n o e a c h c o r d p l u g s i n t o t h c o m p u t e r . O t h r i g h t s i d e o t h C o m m od o r e 6 4 s h o w n i F i g u r e 1 . 2 , y o u ' l l s e e s w i t c h m a r k e d O N a n c i r c ul a j a c k n e x t t t h l a b e l P O W E R . I n t o t h a t j a c k y o c a p l u g t h s l e e v e - l i k e e n o t h p o w e r c o r d . W i t h t h s w i t c h t u r n e d t O F F , y o c a p l u gt h t h r e e - p r o n g e d e n o t h p o w e r c o r d i n t o w a l l o u t l e t t o c o m p l e t e t h p o w e r c o n n e c t i o n .

T h c o n n e c t i o n t t e l e v i s i o n i j u s t a s i m p l e . N e a r t h e c e n t e r o t h c o m p u t e r ' s b a c k p a n e l , a n n e x t t s m a l l s w i t c h , y o u ' l l f i n d s m a l l ,p r o j e c t i n g m e t a l j a c k , w h i c h t a k e s t h t e l e v i s o n c a b l e . T h c a b l e h a t h s a m e p o s t - i n - a - s l e e v e m e t a l p h o n o p l u g a e a c h e n d . O n e n p l u g s i n t ot h m e t a l t e l e v i s i o n j a c k a t h b a c k o t h c o m p u t e r ; t h o t h e r e n f i t si n t o j a c k o s m a l l b o t h a t a l l o w s y o t s w i t c h t h m o n i t o r b e t w e e nt e l e v i s i o n r e c e p t i o n a n c o m p u t e r d i s p l a y . F r o m t h a t b o ( k n o w n a " s w i t c h b o x " ) c o m e w i r e l e a d s t h a t y o c a a t t a c h t t h t e l e v i s i o n i p l a c e o t h v h f a n t e n n a l e a d s . I y o n e x t c o n n e c t t h v h l e a d s t t h o t h e r s i d e o t h s w i t c h b o x , y o c a s w i t c h b e t w e e n t e l e v i s i o n r e c e p t i o n

F i g u r e 1 . 1 : t y p i c a l C o m m o d o r e 6 c o m p u t e r s e t - u p .

Page 17: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 17/148

C O M I N G I N T O P O W E R

a n c o m p u t e r d i s p l a y . F i g u r e 1 . s h o w s t h s y s t e m c o n n e c t e d f o c o p u t e r u s e o n l y .

T h f i n a l a d j u s t m e n t s i n c l u d e s e t t i n g y o u r t e l e v i s i o n t u n e r t o e i t h e rc h a n n e l o c h a n n e l 4 w h i c h e v e r o n i n o u s e d f o b r o a d c a s t i y o u r

F i g u r e 1 . 2 : P o w e r c o n n e c t i o n t t h c o m p u t e r .

F i g u r e 1 . 3 : C o n n e c t i o n s b e t w e e n c o m p u t e r a n t e l e v i s i o n .

Page 18: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 18/148

T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

a r e a . A l s o s e t h c h a n n e l o t h c o m p u t e r . I c h a n n e l i u n u s e d , s l i d et h s m a l l , r e c e s s e d s w i t c h a t h b a c k o t h c o m p u t e r ( n e x t t t h m e t a lt e l e v i s i o n j a c k ) t o w a r d t h j a c k . I i t ' s c h a n n e l 3 , s l i d e i a w a y f r o m t h

j a c k .N o t h a t t h c o n n e c t i o n b e t w e e n c o m p u t e r a n t e l e v i s i o n i c o m p l e t e ,

y o c a u s t h c o m p u t e r b s e t t i n g t h e s w i t c h o t h b o t C O P U T E R . T u s t h t e l e v i s i o n f o t v r e c e p t i o n , s l i d e t h e s w i t c h t T E L EV I S I O N .

I y o u s v i d e o m o n i t o r , d i f f e r e n t c a b l e — o n e e n d i n g i f i v e - p i np l u g a t h c o m p u t e r e n a n p h o n o p l u g a t h m o n i t o r e n d — c o n n e c t st f l a t , c i r c u l a r v i d e o j a c k a t h b a c k o t h c o m p u t e r , n e x t t t h t e l e v is i o n j a c k , a s h o w n i F i g u r e 1 . 4 .

O n c e c o n n e c t e d t t e l e v i s i o n o m o n i t o r , t h c o m p u t e r b e f o r e y o i p a r t o f u l l y o p e r a t i o n a l s y s t e m t h a t c a d i s p l a y o t h e s c r e e n w h a t e v e ry o t y p e .

C O N T R O L F R O M T H K E Y B O A R DA l y o n e e d t c o m m a n d t h c o m p u t e r s i t s b e f o r e y o u . T h k e y b o a r d

i l a i d o u l i k e t y p e w r i t e r ' s , b u h a a f e w e x t r a k e y s t h a t g i v e y o m o r ec o n t r o l t h a n i p o s s i b l e w i t h t y p e w r i t e r .

B e f o r e t u r n i n g o p o w e r t t h c o m p u t e r , c o n s i d e r s i m p l e , c o m f o r t i n gf a c t : N o t h i n g y o c a d f r o m t h k e y b o a r d w i l l d a m a g e t h c o m p u t e r .W i t h s o m e o t h c o m m a n d s y o u ' l l f i n d i t h i s b o o k , y o c a n c h a n g e t h s c r e e n d i s p l a y , t h c o n t e n t s o t h c o m p u t e r ' s a c t i v e m e m o r y , o e v e n t h

F i g u r e 1 . 4 : T h v i d e o m o n i t o r j a c k .

Page 19: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 19/148

C O M I N G I N T O P O W E R

w a t h c o m p u t e r w o r k s , b u t w h e n y o t u r n t h p o w e r t t h C o m m od o r e 6 o f a n t h e n o a g a i n , y o w i p e d e a n t h c h a n g e s y o u ' v e m a d e .T h c o m p u t e r t h e n g r e e t s y o i n r e a d i n e s s , a l p r e v i o u s k e y b o a r d m a n i pu l a t i o n s f o r g o t t e n .

T h s i n g l e m o s t u s e f u l b i o a d v i c e w h i l e y o u ' r e l e a r n i n g t o p e r a t e t h c o m p u t e r f r o m t h k e y b o a r d i t h i s : I s o m e t h i n g i n t e r e s t s y o u , t r i t T h w o r s t t h a t c a h a p p e n w i l l b t h l o s s o s o m e c o m m a n d , i n f o r m a t i o n o rc a l c u l a t i o n . I t h e a r l i e s t s t a g e s , w h i l e y o u ' r e e x p e r i m e n t i n g , s u c h l o s si p a r t o l e a r n i n g t c o n t r o l t h b e a s t . N m a t t e r w h a t h a p p e n s , t h c o p u t e r w i l l e m e r g e f r o m h u m a n k e y b o a r d e r r o r o c u r i o s i t y c o m p l e t e l yu n d a m a g e d .

W h e n y o s w i t c h o f i r s t t h m o n i t o r o t e l e v i s i o n , t h e n t h c o m p u t e r ,p r i n t i n g w i l l a p p e a r o t h s c r e e n . A c r o s s t h t o p , i a l i c o n n e c t e d a n w o r k i n g p r o p e r l y , t h r e e l i n e s w i l l b p r i n t e d a l i g h t l e t t e r s o a d a r ks c r e e n , a s i F i g u r e 1 . 5 .

T h C u r s o rA t h u p p e r l e f t o t h s c r e e n y o w i l l s e e t h e w o r d R E A D Y , a n b e l o w

t h a t c h a r a c t e r - s i z e d f l a s h i n g s q u a r e ; t h e s e a r s i g n a l s f r o m t h c o m p u t e r

* * * * C 0 M K 0 D 0 R E 8 8 A S I C U * * * *S 4 R A M S V S T E M 3 8 9 1 1 8 A S I C 8 Y T E S F U Z E

R E A O V .

F i g u r e 1 , 5 : D i s p l a y o t h e s c r e e n a f t e r t h e c o m p u t e r i f i r s t t u r n e d o n

Page 20: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 20/148

T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

t h a t i t ' s r e a d y t r e a d w h a t e v e r y o t y p e f r o m t h k e y b o a r d . T h f l a s h i n gs q u a r e m a r k s w h e r e t h n e x t c h a r a c t e r f r o m t h k e y b o a r d w i l l a p p e a r o t h s c r e e n , a n i k n o w n a t h c u r s o r .

T h C o m m o d o r e 6 i d e s i g n e d t d i s p l a y i m m e d i a t e l y w h a t ' s t y p e df r o m t h k e y b o a r d , a n w i l l p r i n t l i g h t b l u e l e t t e r s o a d a r k b l u e s c r e e n a y o t y p e t h e m . T h w o r d R E A D Y i s i g n a l f r o m t h c o m p u t e r t h a t i t ' sp r e p a r e d t a c c e p t c o m m a n d . B u w h e t h e r y o t y p e o n o t h s c o r e s o c o m m a n d s t h C o m m o d o r e 6 c a a c o o l i n e o p o e t r y , y o u r t y p i n gw i l l a p p e a r i m m e d i a t e l y o t h s c r e e n . A n a y o t y p e , t h c o m p u t e rw a i t s f o s i g n a l f r o m y o t h a t w i l l t e l l i t o a c t o t h c o m m a n d y o u ' v ej u s t t y p e d .

T h R E T U R N K e Y o s i g n a l t h c o m p u t e r t o a c t o t y p e d c o m m a n d b p r e s s i n g t h

R E T U R N k e y . I f t h c o m m a n d i n m o r e t h a n t w l i n e s l o n g a n t h c u r s o r i o o n o t h o s e l i n e s , t h c o m p u t e r w i l l c o m p a r e t h t y p e d c o m a n d w i t h s e o b u i l t - i n d i r e c t i o n s , a n t a k e a c t i o n . B u i y o m e r r i l yt y p e a l o n g w i t h o u t p r e s s i n g t h e R E T U R N k e y , t h c o m p u t e r w i l l f o l l o wd i r e c t i o n s t h a t t e l l i t s i m p l y d i s p l a y c h a r a c t e r s o t h v i d e o s c r e e n .

T h S H I F T a n C K e y sL i k e t y p e w r i t e r , t h C o m m o d o r e 6 c a d i s p l a y b o t h u p p e r c a s e a n

l o w e r c a s e l e t t e r s . B u u n l i k e t y p e w r i t e r , i c a a l s o d i s p l a y c e r t a i n g r a p hi c s y m b o l s . T h e s e a r t h s m a l l b o x e d d e s i g n s o t h f r o n t o m o s t o t h k e y s . W h e n y o f i r s t s w i t c h o n p o w e r t t h C o m m o d o r e 6 4 t h c o p u t e r i a u t o m a t i c a l l y r e a d i e d t d i s p l a y t h e u p p e r c a s e o a n l e t t e r k e t h a t y o p r e s s . P r e s s n u m b e r k e a n t h n u m b e r w i l l b d i s p l a y e d .P r e s s k e w i t h p u n c t u a t i o n a n t h a t m a r k w i l l b d i s p l a y e d . B p r e s s i n gc e r t a i n c o m b i n a t i o n s o k e y s , y o c a a l s o t y p e t h g r a p h i c s d e s i g n ss h o w n o n t h e f r o n t o e a c h k e y . I f y o h o l d d o w n t h S H I F T k e w h i l ep r e s s i n g a k e y w i t h g r a p h i c s s y m b o l s , t h s y m b o l o t h r i g h t o t h k e w i l l b d i s p l a y e d . H o l d d o w n t h k e ( o " C o m m o d o r e " k e y ) , n e x tt t h S H I F T k e y , w h i l e p r e s s i n g k e y , a n t h s y m b o l o t h l e f t o t h k e w i l l b d i s p l a y e d .

E a c h t i m e y o t u r n o p o w e r t t h c o m p u t e r , i i a u t o m a t i c a l l y s e t r e c o g n i z e k e y s t r o k e s i t h u p p e r c a s e - g r a p h i c s m o d e . Y o c a s w i t c h i i n t o a n o t h e r k e y s t r o k e m o d e b p r e s s i n g d o w n t h S H I F T a n k e y st o g e t h e r o n c e , a n t h e n r e l e a s i n g t h e m . O n c e t h i s i d o n e , t h c o m p u t e rt r e a t s s o l i t a r y k e y s t r o k e a s i g n a l t o d i s p l a y l o w e r c a s e c h a r a c t e r .P r e s s i n g t h S H I F T k e a n l e t t e r k e w i l l n o p r o d u c e a u p p e r c a s e

Page 21: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 21/148

C O M I N G I N T O P O W E R

c h a r a c t e r , a n p r e s s i n g t h k e a n g r a p h i c s s y m b o l k e w i l l p r d u c e t h e c h a r a c t e r s h o w n o t h l e f t o t h a t k e y , a i d i b e f o r e .

Y o s w i t c h o u o t h i s l o w e r c a s e - a n d - u p p e r c a s e m o d e a n b a c k t t h u p p e r c a s e - a n d - g r a p h i c s m o d e b p r e s s i n g S H I F T a n a g a i n . I f a c t , e a c h t i m e y o p r e s s t h e S H I F T a n k e y s t o g e t h e r y o s w i t c h t h c o m p u t e r f r o m o n d i s p l a y m o d e t t h o t h e r . A n t y p i n g a l r e a d y o t h s c r e e n w i l l a l s o c h a n g e w h e n t h c o m p u t e r i s w i t c h e d f r o m o n d i s p l a y t t h o t h e r . T o g e t h e r , t h e S H I F T a n k e y s a c a y o u r s w i t c h t c o n t r o lt h d i s p l a y f r o m t h c o m p u t e r .

T h S H I F T L O C K k e c a n b e s e t e i t h e r o t w p o s i t i o n s . W h e np r e s s e d d o w n a n a l l o w e d t c l i c k i n t o l o w e r e d p o s i t i o n , i t e f f e c t i t h s a m e a h o l d i n g d o w n t h S H I F T k e y . P r e s s e d a g a i n , t h S H I F T L O C Kk e w i l l c l i c k i n t o r a i s e d p o s i t i o n , a n t h e r e i n s u c h e f f e c t .M o v i n g t h C u r s o r : t h U P / D O W N a n R I G H T / L E F T k e y s

T r e a t i n g t h s c r e e n o t h C o m m o d o r e 6 l i k e t h v i d e o e q u i v a l e n t o s h e e t o p a p e r i t y p e w r i t e r , y o c a t y p e o i a n y w h e r e w i t h i n i t

p r e s e t m a r g i n s . W i t h d i t w a r r o w k e y s i t h e l o w e r - r i g h t c o r n e r o f t h k e y b o a r d , y o c a m o v e t h e f l a s h i n g c u r s o r t a n l o c a t i o n o t h s c r e e n ,a n w h a t e v e r y o t y p e w i l l a p p e a r a t h a t p o i n t . W h e n y o p r e s s i a l o n e ,t h k e m a r k e d w i t h u p - a n d - d o w n a r r o w s ( w e ' l l c a l l t h i s t h C U R S O RU P / D O W N k e y ) m o v e s t h c u r s o r d o w n o t h s c r e e n . L i k e w i s e , t h k e m a r k e d w i t h r i g h t - a n d - l e f t a r r o w s ( w e ' l l c a l l t h i s o n C U R S O RR I G H T / L E F T ) m o v e s t h c u r s o r t t h r i g h t . I f h e l d d o w n , b o t h o t h e s ek e y s c o n t i n u e t h i s c u r s o r m o v e m e n t u n t i l r e l e a s e d . W h e n e i t h e r t h S H I F T , S H I F T L O C K o k e i h e l d d o w n w h i l e t h C U R S O RU P / D O W N k e i p r e s s e d , t h c o m p u t e r m o v e s t h c u r s o r u t h s c r e e n .L i k e w i s e , t h C U R S O R R I G H T / L E F T k e m o v e s t h c u r s o r t t h l e f tw h e n i t ' s u s e d i c o m b i n a t i o n w i t h a n o t h o s e t h r e e k e y s . O n c e t h c u s o i a t h b o t t o m o t h s c r e e n , t h d o w n a r r o w c r a n k s u a l t h t y p e dl i n e s l i k e p r i n t e d l i n e s o n a n e n d l e s s r o l l o p a p e r b e i n g f e t h r o u g h t y p ew r i t e r .

I n s e r t i n g , D e l e t i n g , a n C l e a r i n g : I N S T / D E L a n C L R / H O M ET w o t h e r k e y s a l l o w y o t c o n t r o l t h d i s p l a y f u r t h e r . T h k e i t h

u p p e r - r i g h t c o r n e r o t h k e y b o a r d m a r k e d I N S T D E s e r v e s t w f u n ct i o n s . I c a i n s e r t o d e l e t e . W h e n p r e s s e d b i t s e l f , i d i r e c t s t h e c u r s o r t e r a s e a n c l o s e u o n s p a c e t t h l e f t o t h c u r s o r . W h e n p r e s s e d w h i l et h S H I F T k e i h e l d d o w n , i d i r e c t s t h c o m p u t e r t o p e n a s p a c e t t h l e f t o t h c u r s o r a n m o v e t h c u r s o r t h e r e , s a n o t h e r c h a r a c t e r c a b

Page 22: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 22/148

T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

t y p e d . I y o h o l d d o w n t h i s k e i n e i t h e r m o d e o o p e r a t i o n , i w i l l r e p e a tt h e f f e c t u n t i l y o r e l e a s e i t

T h k e m a r k e d C L R / H O M E , n e x t t i t w o r k s i t w w a y s a l s o . Y o c a u s i t d i r e c t t h c o m p u t e r t s e n d t h c u r s o r " h o m e , " t t h e u p p e r - l e f t c o r n e r . O r , p r e s s i n g S H I F T a n t h a t k e t o g e t h e r( S H I F T - C L R / H O M E ) , y o c a d i r e c t t h c o m p u t e r t o c l e a r t h s c r e e na n s e n d t h c u r s o r u t t h a t c o r n e r .

M o r e K e y s f o C o n t r o lT h t h r e e k e y s m a r k e d R U S T O P , C O N T R O L , a n R E S T O R E

c a b u s e d t a l t e r t h c o m p u t e r ' s a c t i o n s w h e n i t ' s u n d e r t h c o n t r o l o p r o g r a m o c o m m a n d s .

T h f o u r r i g h t m o s t k e y s , m a r k e d f f 2 f f 4 f f 6 a n f f 8 c a e a c hb c a l l e d o b p r o g r a m s t c o n t r o l t h e c o m p u t e r i s p e c i a l l y p r g r a m m e d w a y s .

R E T U R N R e v i s i t e dB s e n d i n g a s i g n a l t o t h c o m p u t e r t a c o w h a t y o u ' v e t y p e d a t h

k e y b o a r d , t h R E T U R N k e y w o r k s a y o u r m e s s e n g e r i r o u t i n g k e b o a r d s t a t e m e n t s i n t o t h t r a n s l a t o r o t h C o m m o d o r e 6 4 W h e n y o p r e s st h R E T U R N k e a f t e r t y p i n g s o m e t h i n g i r e s p o n s e t R E A D Yp r o m p t , t h c o m p u t e r ' s t r a n s l a t o r c o m p a r e s w h a t y o u ' v e s e n t w i t h t h v o c a b u l a r y o w o r d s b u i l t i n t o i t I t h f o r m o y o u r t y p e d s t a t e m e n tm a t c h e s c o m m a n d , t h t r a n s l a t o r p a s s e s t h e o r d e r s o t t h p r o c e s s o rp a r t o t h c o m p u t e r , w h i c h t a k e s a c t i o n a c c o r d i n g t b u i l t - i n d i r e c t i o n s .

Y o c a m o v e t h e c u r s o r a n y w h e r e a r o u n d t h s c r e e n a n t y p e a n t h i n g y o l i k e . I y o p r e s s t h R E T U R N k e a n t h t r a n s l a t o r d o e s n ' tm a t c h y o u r i n s t r u c t i o n s w i t h i t v o c a b u l a r y , t h e c o m p u t e r w i l l s i g n a l y o t h a t t h e r e i a m i s m a t c h . I t h C o m m o d o r e 6 t h i s s i g n a l t a k e s t h f o r m ," P S Y N T A X E R R O R " . T h i s t y p e o f " e r r o r " r e p l y f r o m t h c o m p u t e rs i m p l y m e a n s t h e r e h a b e e n m o m e n t a r y l a p s e i c o m m m u n i c a t i o n .( " S y n t a x " r e f e r s t o t h e e x a c t f o r m o s e q u e n c e i w h i c h t h c o m p u t e re x p e c t s c o m m a n d s t b g i v e n . ) I a n c a s e , t h R E T U R N k e i o n y o u ' l l f i n d u s e f u l w h e n y o u ' r e r e a d y t g i v e c o m m a n d s t t h c o m p u t e r .

S u m m a r y o K e y b o a r d O p e r a t i o n s

E a c h k e h a a e f f e c t ( p r i n t s c h a r a c t e r o r s e n d s c o m m a n d ) , a n s o m e h a v e s e v e r a l d i f f e r e n t e f f e c t s w h e n u s e d i c o m b i n a t i o n . Y o c a a c q u i r e p r o g r a m s ( s e t s o c o m m a n d s ) t h a t w i l l c h a n g e t h e f f e c t o a n o

Page 23: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 23/148

C O M I N G I N T O P O W E R

a l o t h k e y s . P r e s s i n g a n k e s i m p l y p r o v i d e s s i g n a l t o t h c o m p u t e r ,w h i c h r e s p o n d s t t h a t s i g n a l b p r i n t i n g c h a r a c t e r o t a k i n g s o m e p r p l a n n e d a c t i o n . A l t h k e y s a r s h o w n i F i g u r e 1 . 6 .

W h e t h e r y o a r u s i n g p r e r e c o r d e d c o m m a n d s ( f r o m t a p e s o d i s k s , a e x p l a i n e d i C h a p t e r s a n 8 o d i r e c t c o m m a n d s , y o u l t i m a t e l y c o t r o l t h C o m m o d o r e 6 4 t h r o u g h t h k e y b o a r d . T h k e y b o a r d s e r v e s a sr e i n s a n b r i d l e t o t h c o m p u t e r a n a n d e v i c e s a t t a c h e d t i t

F i g u r e 1 . 6 : T h C o m m o d o r e 6 k e y b o a r d .

Page 24: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 24/148

J o h a n n G u t e n b u r g s e t h s t a n d a r d f o p r i n t i n g f i v e h u n d r e d y e a r sa g o , a n i r e a l l y h a s n ' t c h a n g e d m u c h u n t i l r e c e n t l y . I f a c t , o n l y t h i n t r o d u c t i o n o f t h e c o m p u t e r i n t h e l a s t f e y e a r s h a h a m a j o r i m p a c t .T y p e s e t t i n g b c o m p u t e r p u t s t h p r i n t e d p a g e o s c r e e n b e f o r e i g o e so p a p e r . W i t h y o u r C o m m o d o r e 6 4 y o c a c r e a t e s c r e e n d i s p l a y s c o t r o l l e d b c o m m a n d .

S C R E E N C O N T R O LI s i m p l y r e l a y i n g y o u r k e y s t r o k e s t t h v i d e o s c r e e n , y o u r C o m m o

d o r e 6 d r a w s u p o n n o n e o i t r e a l c a p a b i l i t i e s . W i t h c o m m a n d s m a t c hi n t h o s e t w h i c h i r e s p o n d s , h o w e v e r , y o c a d i r e c t t h c o m p u t e r i p r e p l a n n e d d i s p l a y s . T s o m e c o m m a n d s , t h c o m p u t e r r e a c t s i n s t a n t l yw h e n y o s e n d t h e m w i t h p r e s s o t h R E T U R N k e y . A m o n g t h e s e" i m m e d i a t e " c o m m a n d s a r e t h o s e w h i c h e n a b l e y o t f a s h i o n t h e s c r e e nd i s p l a y .

Y o c a f i l l t h e s c r e e n w i t h a n c h a r a c t e r s y o l i k e b t y p i n g o a n d o nf r o m t h k e y b o a r d w i t h o u t s e n d i n g t h c o m p u t e r r e c o g n i z a b l e c o m a n d . I y o t y p e m o r e t h a n s c r e e n f u l , t h c o m p u t e r w i l l m o v e t h e n t i r e d i s p l a y u o n l i n e t o m a k e r o o m f o t h m o s t r e c e n t l i n e , a n l o s et h t o p m o s t l i n e f r o m t h s c r e e n .

Y o c a d i r e c t t h C o m m o d o r e 6 w i t h s i n g l e k e y s t r o k e c o m m a n d s a w e l l a s t y p e d w o r d c o m m a n d s . P r e s s i n g t h S H I F T a n C L R / H O M Ek e y s a t h s a m e t i m e , f o i n s t a n c e , d i r e c t s t h c o m p u t e r t c l e a r t h

Page 25: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 25/148

V I D E O P R I N T I N G 1

s c r e e n o a l p r i n t i n g a n t m o v e t h f l a s h i n g c u r s o r t t h u p p e r l e f t c o n e r . W h e n g i v e n t h i s c o m m a n d , t h c o m p u t e r p r e s e n t s b l a n k s c r e e n ,r e g a r d l e s s o w h a t w a t y p e d t h e r e b e f o r e . I y o w a p o e t i c , f o r i n s t a n c e ,a n t y p e o n t o t h s c r e e n s o m e t h i n g l i k e t h l i n e s i F i g u r e 2 . 1 , y o c a r e m o v e w h a t y o u ' v e t y p e d a o n c e b d o i n g t h f o l l o w i n g :

( p r e s s S H I F T a n C L R / H O M E )D i r e c t e d b t h i s k e y s t r o k e c o m m a n d , t h c o m p u t e r e r a s e s a l p r i n t i n g ,

l e a v i n g b l a n k s c r e e n w i t h t h c u r s o r f l a s h i n g i t h u p p e r - l e f t c o r n e r —t h v i d e o e q u i v a l e n t o f r e s h s h e e t o p a p e r a n p o i s e d p e n .

W h e n y o t y p e k e y b o a r d c h a r a c t e r s , t h c o m p u t e r s e n d s t h e m t t h s c r e e n a s l i g h t - c o l o r e d d o t f o r m a t i o n s o a d a r k b a c k g r o u n d . I a n s w e r sy o i t h s a m e w a y , w i t h l i g h t - o n - d a r k d i s p l a y i c h o o s e s a u t o m a t i c a l l y .T h e r e a r e , h o w e v e r , a l t e r n a t i v e w a y s o f p r e s e n t i n g t e x t o t h s c r e e n , u s f u i v a r y i n g t h d i s p l a y o c a l l i n g a t t e n t i o n t p a r t i c u l a r p a r t s o t e x t .

I y o u w a n t d a r k c h a r a c t e r s t a p p e a r , e a c h o i t o w l i g h t - c o l o r e db a c k g r o u n d , y o c a d i r e c t t h C o m m o d o r e 6 t p r i n t t h e m t h a t w a w i t h t h k e y s t r o k e c o m m a n d :

( p r e s s C T R L a n 9

a n e v e r y t h i n g t h a t f o l l o w s o t h s c r e e n w i l l b p r i n t e d i w h a t i c a l l e d

F i g u r e 2 . 1 : O n p o s s i b l e s c r e e n d i s p l a y .

Page 26: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 26/148

1 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

t h " r e v e r s e - v i d e o " m o d e . T h C T R L - 9 c o m m a n d c o n t r o l s t h c o p u t e r l i k e s w i t c h , s o t h a t u n t i l s o m e o t h e r c o m m a n d i s e n t t c h a n g e t h s c r e e n d i s p l a y ( o t h R E T U R N k e i p r e s s e d ) , a l n e p r i n t i n g o t h s c r e e n w i l l a p p e a r a d a r k - o n - l i g h t c h a r a c t e r s . C h a r a c t e r s t y p e d b e f o r et h C T R L - 9 k e y p r e s s c o m m a n d w a s e n t r e m a i n a s l i g h t - o n - d a r k , t h " n o r m a l " d i s p l a y m o d e t h c o m p u t e r a l w a y s p r e s e n t s a u t o m a t i c a l l y , u n t i lo t h e r w i s e d i r e c t e d . T h p o e t R o b e r t W S e r v i c e , g i v i n g t h C T R L - 9c o m m a n d a t h b e g i n n i n g o v e r s e , w o u l d h a v e s e e n s c r e e n l i k e t h a t i F i g u r e 2 . 2 .

Y o c a s w i t c h t h e c o m p u t e r b a c k i n t o t h n o r m a l l i g h t - o n - d a r k d i p l a y m o d e w i t h t h k e y s t r o k e c o m m a n d :

( p r e s s C T R L a n 0

w h i c h d i r e c t s t h c o m p u t e r t p r i n t l i g h t - o n - d a r k e v e r y c h a r a c t e r t y p e da f t e r t h a t c o m m a n d i s e n t . T h s a m e p o e t , a d v a n c i n g t h r o u g h h i p o e ma f t e r p r e s s i n g C T R L a n 0 w o u l d s e t h e s c r e e n d i s p l a y s h o w n i F i u r 2 . 3 .

Y o c a a l s o c r e a t e m u l t i c o l o r e d d i s p l a y s o t e x t . U s i n g t h k e y s n u b e r e d t h r o u g h 8 w i t h t h C T R L k e y , y o c a c h o o s e d i f f e r e n t c o l o r s f o rc h a r a c t e r s p r i n t e d o t h s c r e e n . T g e y e l l o w l e t t e r s , f o r i n s t a n c e , y o

O T H E I P L A IT H I S I T H L A A N E U E f i S H H S E N D H O V O U RS E H O H V O U R S R

F i g u r e 2 . 2 : t h e f f e c t o t h C T R L - 9 c o m m a n d :

Page 27: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 27/148

V I D E O P R I N T I N G 1

S E N O M S T R O N G

H E N . " M H A R G R I T T T H E C O R E ;S W I F T A T H P A N T H E R I T R I U M P H ,F I E R C E A T H B E A R I O E F E A T ,S I R E D O B U L L D O G P A R E N T ,S T E E L E D I T H F U R N A C E H E A T .

F i g u r e 2 . 3 : T h e f f e c t o t h C T R L - 0 c o m m a n d .c a p r e s s t o g e t h e r t h e C T R L a n k e y s :

( p r e s s C T R L a n 8

I t h c o m p u t e r i i l i g h t - o n - d a r k d i s p l a y m o d e , a l c h a r a c t e r s t y p e da f t e r t h C T R L - 8 c o m m a n d w i l l a p p e a r a l i g h t y e l l o w l e t t e r s o a d a r kb l u e s c r e e n . I t h c o m m a n d f o r e v e r s e c h a r a c t e r d i s p l a y i g i v e n ,C T R L - 9 , t h e d i s p l a y w i l l b d a r k b l u e l e t t e r s , e a c h o i t o w y e l l o wb l o c k . Y o c a s w i t c h t h c h a r a c t e r d i s p l a y i n t o o t h e r c o l o r s b p r e s s i n gt h C T R L k e t o g e t h e r w i t h a n o t h o t h e r n u m b e r k e y s . W h e n y o p r e s s t h e k e a n o n o t h n u m b e r e d k e y s , t h c o m p u t e r w i l l d i p l a y e v e n m o r e c o l o r s .

V I D E O P R I N T I N GT h C o m m o d o r e 6 4 l i k e a n y c o m p u t e r w o r t h i t c i r c u i t s , c a d m o r e

t h a n d i s p l a y y o u r k e y s t r o k e s o v i d e o s c r e e n . I f a c t , m u c h o t h C o m o d o r e 6 4 ' s c o m p u t i n g p o w e r l i e s i t h b u i l t - i n o p e r a t i o n s i w o r k s o f u r i o u s l y a y o u r c o m m a n d , w i t h o u t g i v i n g s m u c h a c l u e t w h a t i t ' sd o i n g . T h s i m p l e s t e x a m p l e c a b s e e n w i t h e l e m e n t a r y a r i t h m e t i c ,w h i c h t h C o m m o d o r e 6 w o r k s o a u t o m a t i c a l l y a n u n s e e n w h e n s

Page 28: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 28/148

1 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

d i r e c t e d . T h f a m i l i a r c a l c u l a t o r f u n c t i o n s o a d d i t i o n , s u b t r a c t i o n , m u l t ip l i c a t i o n , a n d i v i s i o n a r c o m m a n d e d f r o m t h k e y b o a r d w i t h t h s y b o l s * a n / I y o d i r e c t t h c o m p u t e r t m u l t i p l y a n 4 b t y p i n g :

- 2 * 4y o w o n ' t s e t h r e s u l t , j u s t P S Y N T A X E R R O R r e p l y a n a n o t h e rR E A D Y p r o m p t . T s e t h r e s u l t s o t h a t m u l t i p l i c a t i o n , y o u m u s t a d dc o m m a n d .

T h P R I N T C o m m a n dT h c o m m a n d t h a t d i r e c t s t h c o m p u t e r t d i s p l a y t h e r e s u l t s o a r i t h m e t i c o p e r a t i o n s o t h e s c r e e n i P R I N T . I c a b u s e d w i t h a

" o p e r a t o r " c o m m a n d l i k e t h e m u l t i p l i c a t i o n s i g n , * t d i s p l a y o n o t h c o m p u t e r ' s i n t e r n a l o p e r a t i o n s . Y o t y p e t h i s u s e f u l c o m m a n d f i r s t ,b e f o r e t h o p e r a t i o n y o u ' d l i k e d i s p l a y e d , l i k e t h i s :

P R I N T - 2 * 4A u s e d h e r e , t h P R I N T c o m m a n d d i r e c t s t h c o m p u t e r t d i s p l a y t h er e s u l t o t h m u l t i p l i c a t i o n t h a t f o l l o w s i t A f t e r s e n d i n g t h i s c o m m a n d b p r e s s i n g t h R E T U R N k e y , y o u ' d s e t h v a l u e o t h s c r e e n a n n e R E A D Y p r o m p t b e l o w t h a t , s i g n a l l i n g t h c o m p u t e r ' s r e a d i n e s s f o a n o t h e r c o m m a n d , a s h o w n i F i g u r e 2 . 4 .

Y o c a p u t h P R I N T c o m m a n d i n t o s e r v i c e f o r a n c o m b i n a t i o n o a r i t h m e t i c c o m m a n d s a c c o r d i n g t t h r u l e s o a l g e b r a , t o p e r a t e y o u rs o p h i s t i c a t e d C o m m o d o r e 6 a s i m p l e c a l c u l a t o r , w i t h e n t r i e s l i k e t h i so n e :

P R I N T 9 8 - 7 * 6 / 5T h c o m p u t e r a u t o m a t i c a l l y f o l l o w s a p r e d e t e r m i n e d o r d e r o o p e r a t i o n si i n t e r p r e t i n g a r i t h m e t i c e x p r e s s i o n s l i k e t h a b o v e . F i r s t m u l t i p l i c a t i o n ,t h e n d i v i s i o n , a n f i n a l l y a d d i t i o n a n s u b t r a c t i o n a r c a r r i e d o u t , i n t h i sc a s e t g i v e t h r e s u l t 8 . o s c r e e n . T c h a n g e t h i s b u i l t - i n s e q u e n c e o o p e r a t i o n s , p a r e n t h e s e s a r u s e d t o d i r e c t t h c o m p u t e r t w o r k o u t h v a l u e s i n s i d e t h e m f i r s t , l i k e t h i s :

P R I N T ( 8 - 7 ) * 6 / 5f o r e s u l t t h a t w i l l a p p e a r , b e l o w t h P R I N T s t a t e m e n t , a 1 2

B u t h P R I N T c o m m a n d ' s u s e f u l n e s s g o e s b e y o n d s i m p l y d i s p l a y i n gm a t h e m a t i c a l m a n i p u l a t i o n s ( a l l o w h i c h a r l i s t e d i A p p e n d i x A )

Page 29: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 29/148

V I D E O P R I N T I N G 1

F i g u r e 2 . 4 : T h e f f e c t o t h P R I N T c o m m a n d .P R I N T i c o m m a n d y o c a u s o f t e n . A w e l l a s a p p l y i n g i t o d i r e c ts o m e i n t e r n a l o p e r a t i o n o n t o t h s c r e e n , y o c a u s i t e x p r e s s s e n t im e n t , a t h o u g h t , o f a c t o t h s c r e e n i t h m i d s t o s o m e o t h e r c o p u t e r a c t i o n . T h P R I N T c o m m a n d i y o u r t y p i s t .

Y o c a d i r e c t t h c o m p u t e r t p r i n t o t h e s c r e e n n e a r l y a n y t h i n g y o t y p e i q u o t a t i o n m a r k s f o l l o w i n g t h P R I N T c o m m a n d . F o e x a m p l e :

P R I N T " S g l a d t b h e r e . "

T h c o m p u t e r ' s r e s p o n s e a f t e r y o p r e s s t h R E T U R N k e w i l l b t h w o r d s ,

S g l a d t b h e r e .

o t h l i n e f o l l o w i n g t h e c o m m a n d .W o r d s a n n u m b e r s c a b c o m b i n e d i P R I N T s t a t e m e n t . F o

i n s t a n c e , y o c a m a k e t h e s t a t e m e n t :P R I N T " T h e w i n n i n g n u m b e r i s . . . " 3

a n s e t h c o m p u t e r r e p l y :

T h w i n n i n g n u m b e r i s . . . 3

Page 30: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 30/148

1 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

Y o c a n e v e n s l i p c a l c u l a t i o n i n t o p r i n t e d s e n t e n c e , l i k e t h i s :P R I N T 2 " o r " 3 " i m o r e t h a n I ' w i l l i n g t p a y . B u t " 1 0 + 5" s o u n d s r i g h t . "

f o t h d i s p l a y f r o m t h c o m p u t e r :2 o 3 i m o r e t h a n I ' w i l l i n g t p a y . B u t 1 5 s o u n d s r i g h t .

K e y s t r o k e C o m m a n d s i n t h e P R I N T S t a t e m e n tY o c a l o a d P R I N T s t a t e m e n t w i t h k e y s t r o k e c o m m a n d s , e n c l o s i n g

t h e m w i t h i n q u o t a t i o n m a r k s , a n t h c o m p u t e r w o n ' t p e r f o r m t h e mu n t i l y o p r e s s t h e R E T U R N k e t s e n d t h e n t i r e P R I N T c o m m a n d .O n P R I N T s t a t e m e n t c a t h u s h o l d d i r e c t i o n s t d s e v e r a l t h i n g s . F o i n s t a n c e , y o c a i n s t r u c t t h c o m p u t e r t c l e a r t h s c r e e n , s w i t c h t h e d i p l a y t " r e v e r s e t y p e " ( d a r k - o n - l i g h t c h a r a c t e r s ) , s w i t c h i t y e l l o w , t h e np r i n t p h r a s e , s w i t c h t w h i t e , a n f i n a l l y p r i n t a n o t h e r p h r a s e , a l w i t hc o m m a n d l i k e t h f o l l o w i n g :

P R I N T " ( p r e s s S H I F T - H O M E ) ( p r e s s C T R L a n 9 ( p r e s s C T R L a n 8 1 T A K E I T ( p r e s s C U R S O R U P / D O W N ) ( p r e s s C U R S O R U P / D O W N )

( p r e s s C T R L a n 2 ) F R O M T H T O R "

T A B — A r r a n g i n g t h S c r e e n D i s p l a yI y o g i v e c o m m a n d f r o m t h k e y b o a r d , l i k e S H I F T - C L R / H O M E ,

w i t h i n q u o t e s i P R I N T s t a t e m e n t , t h c o m p u t e r w i l l r e c o r d t h a t c o m a n d i a c o d e d w a y , i t h i s c a s e w i t h h e a r t s y m b o l , b u w i l l n o c a r r y i o u u n t i l t h R E T U R N k e i p r e s s e d . Y o c a u s t h i s t d e l a y t t a i l o rd i s p l a y w i t h t h P R I N T c o m m a n d . O n c e y o r e a l i z e t h a t t h c o m p u t e rh a n d l e s t e x t o t h s c r e e n a g r i d o 4 c o l u m n s b 2 r o w s , y o c a a r r a n g e d i s p l a y s t s u i t t h e y e . h a n d y l i t t l e c o m m a n d u s e d w i t h i nP R I N T s t a t e m e n t d i r e c t s t h c o m p u t e r t t a ( o s p a c e o v e r t s p e c i f i e dc o l u m n ) b e f o r e a c t u a l l y p r i n t i n g o t h s c r e e n . T h f o r m i T A B ( ) , w h e r et h c o l u m n s a r n u m b e r e d , l i k e t y p e w r i t e r ' s , f r o m l e f t t r i g h t , t h l e f tm o s t a a n t h r i g h t m o s t a s 3 9 . Y o c a a d t h T A c o m m a n d b e f o r et h i t e m t b p r i n t e d , l i k e t h i s :

P R I N T " H E Y ! " T A B ( 1 5 ) " L O O K " T A B ( 3 0 ) " A T T H I S -

T h c o m p u t e r a c t s o t h i s s t a t e m e n t b r e a d i n g i a c r o s s a s s e r i e s o c o m m a n d s , a n p r i n t s :H E Y ! L O O K A T H I S « -

Page 31: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 31/148

V I D E O P R I N T I N G 1

I c o m m a n d i a l r e a d y d i s p l a y e d o t h e s c r e e n y o c a r e p e a t i b m o v i n g t h c u r s o r ( w i t h t h e C U R S O R U P / D O W N k e y ) t t h e s c r e e nr o i w h i c h t h a t c o m m a n d i f o u n d . I y o p r e s s t h R E T U R N k e t h e n , y o w i l l a g a i n s e n d t h c o m m a n d f o t h c o m p u t e r t o a c t o n Y o c a n e v e n a l t e r d i s p l a y e d c o m m a n d , a n t h e n s e n d i b p r e s s i n g t h R E T U R N k e y .

Y o c o u l d , f o i n s t a n c e , m o v e t h c u r s o r b a c k u t h s c r e e n t t h P R I N T c o m m a n d d e s c r i b e d a b o v e , u s i n g t h S H I F T a n C U R S O RU P / D O W N k e y s . U s i n g t h C U R S O R R I G H T / L E F T k e t m o v e t h c u r s o r h o r i z o n t a l l y , a n t h S H I F T a n I N S T / D E L k e y s t i n s e r t s p a c e s ,y o c a c h a n g e t h e s t a t e m e n t . O n w a t c h a n g e t h s t a t e m e n t w o u l d b s o t h a t t h d i s p l a y r e a d :

H E Y ! T A K E L O O K A T H I S «

T d t h i s y o i n s e r t t h w o r d s T A K E w i t h i n t h s e c o n d s e o q u o t e s .Y o c a d t h i s b p l a c i n g t h c u r s o r o v e r t h l e t t e r i t h w o r d L O O K ,a n t h e r e i n s e r t i n g s e v e n s p a c e s , f o t h w o r d s T A K E a n t h b l a n ks p a c e b e t w e e n t h e m . T i n s e r t t h s p a c e s , y o j u s t p r e s s t h S H I F T a n I N S T / D E L k e y s s e v e n t i m e s t o g e t h e r .

( p r e s s S H I F T a n I N S T / D E L ) ( p r e s s S H I F T a n I N S T / D E L ) ( p r e s sS H I F T a n I N S T / D E L ) ( p r e s s S H I F T a n I N S T / D E L ) ( p r e s s S H I F T a n I N S T / D E L ) ( p r e s s S H I F T a n I N S T / D E L ) ( p r e s s S H I F T a n d I N S T / D E L )

T h e n y o c a m a k e y o u r i n s e r t i o n :

T A K E ( p r e s s S P A C E B A R )

T h c o m m a n d t h a t r e m a i n s a f t e r t h e s e c h a n g e s i s

P R I N T " H E Y ! " T A B ( 1 5 ) " T A K E L O O K " T A B ( 3 0 ) " A T T H I S « - "

I y o p r e s s t h e R E T U R N k e y n o w , y o u ' l l s e c h a n g e d d i s p l a y r e s u l t :

H E Y ! T A K E A L O O K A T T H I S «

Y o c a u s s u c h a a p p r o a c h t s e n d a n c o m m a n d f r o m t h e s c r e e ni n t o t h c o m p u t e r f o r a c t i o n . I f t h c o m m a n d s t a t e m e n t t a k e s u t w l i n e so t h s c r e e n , y o c a s e n d i b p o s i t i o n i n g t h c u r s o r a n y w h e r e o e i t h e r o t h l i n e s , a n t h e n p r e s s i n g t h e R E T U R N k e y .

Page 32: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 32/148

1 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

M o r e C o m m a n d s .T w p u n c t u a t i o n m a r k s c a n b e u s e d a s h o r t h a n d c o m m a n d s w i t h i n

P R I N T s t a t e m e n t . C o m m a s t y p e d b e t w e e n i t e m s i P R I N T c o m m a n dw i l l d i r e c t t h c o m p u t e r t s p a c e t h i t e m s f o u r a c r o s s t h e s c r e e n , a t h o u g h f o l l o w i n g s u c c e s s i o n o T A B ( 2 ) , T A B ( 1 2 ) , T A B ( 2 2 ) , a n T A B ( 3 2 ) c o m m a n d s . S e m i c o l o n s t y p e d b e t w e e n i t e m s w i l l s e p a r a t e t h e mi t h e s t a t e m e n t , b u n o i t h p r i n t i n g . A l s o , t h c o m p u t e r a u t o m a t ic a l l y a d d s s p a c e b e f o r e a n a f t e r n u m b e r s t h a t i p r i n t s .

T h c o m p u t e r a n i t s c r e e n p r o v i d e m o r e c o n t r o l l a b l e d i s p l a y t h a nt h f a m i l i a r t y p e w r i t e r a n p a p e r . Y o c a d i r e c t c o l o r d i s p l a y s , a n e v e n

r a p i d s u c c e s s i o n o d i s p l a y s b i m p l a n t i n g s c r e e n - c l e a r i n g c o m m a n d sb e t w e e n d i s p l a y s .

B u s i n g s t i l l m o r e v a r i a b l e c o m m a n d s , y o c a g u i d e t h s e r v i l e c o p u t e r i o n d i r e c t i o n o a n o t h e r . B u s i n g c o m m a n d s i c o m b i n a t i o n ,y o c a n e v e n s e n d i o f f t o d y o u r b i d d i n g o i t o w n .

Page 33: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 33/148

S C H E D U L I N G C O M M A N D ST h c o m p u t e r , l o n g r e g a r d e d a a a w e s o m e a c c u m u l a t o r o i n f o r m a

t i o n a n s e c r e t k e e p e r o f i l e s , i b a s i c a l l y f o r g e t f u l . T h a t i s i t ' s b u i l t t oa c o n c o m m a n d s , a n t h e n a u t o m a t i c a l l y l e a v e t h e m b e h i n d t r e a d yi t s e l f f o m o r e c o m m a n d s . H u m a n b e i n g s o f t e n w o r k m u c h t h s a m e w a y ,r e t u r n i n g t d i m l y - r e m e m b e r e d l o c a t i o n s o n l y b t h g r a c e o s t r e e ta d d r e s s e s w r e c a l l .

I i t o w w a y , t h c o m p u t e r c a r e t u r n t " a d d r e s s e s " h e l d i i t m e m o r y . I c o m m a n d s w a i t a s u c h a d d r e s s e s , i w i l l t h e n a c o t h e m a i y o h a j u s t s e n t t h e m . Y o c a p r o v i d e s u c h a d d r e s s e s b s t a r t i n g e a c hg r o u p o c o m m a n d s w i t h n u m b e r .

P l a c e d a t h b e g i n n i n g o a g r o u p o c o m m a n d s , n u m b e r t e l l s t h c o m p u t e r t r e t a i n t h o s e c o m m a n d s a p a r t o p r o g r a m , p o s s i b l y t b u s e d a g a i n . F o e x a m p l e , t m a r k s t a t e m e n t o d i s p l a y c o m m a n d s i t h i s w a y , y o c o u l d s e n d t h e f o l l o w i n g c o m m a n d :

1 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) " T A B ( 1 2 ) " N U M B E R S A N T H E I R U S E S "

Y o u ' l l n o t i c e , w h e n y o p r e s s t h R E T U R N k e a f t e r t y p i n g n u b e r e d s t a t e m e n t l i k e t h i s , t h a t t h c o m p u t e r r e p l i e s w i t h f l a s h i n g c u r s o r ,w i t h o u t a c t i n g o t h c o m m a n d s . A c t u a l l y , t h s t a t e m e n t i s e n t i n t o s t o ra g i t h c o m p u t e r ' s m e m o r y , w h e r e i i k e p t o f i l e b n u m b e r . H e r e ,

Page 34: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 34/148

Page 35: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 35/148

P L A N S A N P R O G R A M S 2

A R H O P f t Q G f t f lM I M G .P R O G R A M E N D S H E R E

R E A O V .

F i g u r e 3 . 1 : T h r e s u l t o r u n n i n g a p r o g r a m o d i s p l a y c o m m a n d s ,t h c o m p u t e r , e a c h t i m e y o i s s u e t h R U c o m m a n d , t p r o d u c e t h s a m e p r i n t i n g d i s p l a y . C h a n g e t h s t a t e m e n t s i t h p r o g r a m a n d y o c h a n g e i t r e s u l t s . F o i n s t a n c e , t h e r e v e r s e - v i d e o r o t h a t d e c l a r e s :

T H I S L I N E W I L L B R E M O V E D .

w i l l b a b s e n t f r o m t h s c r e e n d u r i n g p r o g r a m r u i y o e r a s e l i n e 2 0 i w h i c h y o o r d e r e d i t p r i n t i n g . T e r a s e l i n e f r o m t h c o m p u t e r ' s p r g r a m m e m o r y , y o c a s i m p l y t y p e t h l i n e n u m b e r a n p r e s s t h eR E T U R N k e y :

2

T h c o m p u t e r s t a n d s r e a d y t a c c e p t n e s t a t e m e n t , a n p r e p a r e s t s t o r e s e o c o m m a n d s u n d e r t h n u m b e r 2 w h e n y o d t h i s . W h e ny o s e n d o n l y t h n u m b e r , i r e p l a c e s t h f o r m e r s t a t e m e n t u n d e r t h i sn u m b e r w i t h t h n e w , b l a n k s t a t e m e n t . S i n c e b l a n k s t a t e m e n t g i v e s n i n s t r u c t i o n , l i n e 2 c e a s e s t e x i s t i t h p r o g r a m m e m o r y .

W h e n y o R U t h p r o g r a m , y o u ' l l f i n d t h e r e v e r s e - v i d e o t e x t p r d u c e d b l i n e 2 a b s e n t . W h e n y o L I S T t h p r o g r a m , y o u ' l l f i n d o n l yl i n e s 1 0 3 0 a n 4 r e m a i n i n g i m e m o r y , a i l l u s t r a t e d i F i g u r e 3 . 2 .

Page 36: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 36/148

Page 37: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 37/148

P L A N S A N P R O G R A M S 2

t h e i r l i n e n u m b e r s , o c o m m a n d t h c o m p u t e r t e r a s e t h e m a l l . Y o c a d i r e c t t h i s e r a s u r e b s e n d i n g t h s i m p l e c o m m a n d :

N E O r e c e i v i n g t h i s c o m m a n d , t h c o m p u t e r p r e p a r e s f o n e p r o g r a m b ye r a s i n g a l p r o g r a m l i n e s f r o m i t m e m o r y . I y o w r i t e n e p r o g r a ma n d o n ' t c l e a r o u t h e o l d p r o g r a m f r o m m e m o r y , o l p r o g r a m l i n e n u b e r s n o r e p l a c e d b n e o n e s w i l l t a a l o n g f r o m t h o r i g i n a l p r o g r a m ,g i v i n g d i r e c t i o n s w i t h i n t h n e p r o g r a m y o m a n o h a v e p l a n n e d .

S T A N D - I N S F O N U M B E R SN u m b e r s , y o u ' v e n d o u b t n o t i c e d , a r a s u s e f u l w i t h i n c o m m a n d s a t h e y a r i m a r k i n g p r o g r a m l i n e s . A m u c h a t h c o m m a n d s t h e m

s e l v e s , n u m e r i c a l v a l u e s h e l p c o n t r o l t h e c o m p u t e r ' s o p e r a t i o n s . c h a n g ei t h v a l u e o f n u m b e r c h a n g e s t h e a c t i o n o t h C o m m o d o r e 6 i n f o e x a m p l e , t h d i r e c t i o n s g i v e n b T A c o m m a n d o t h m u l t i p l i c a t i o no r d e r e d w i t h a a s t e r i s k ( * c o m m a n d .

s i n g l e n u m b e r c a b p a s s e d a r o u n d w i t h i n p r o g r a m b t h c o p u t e r t b u s e d i d i f f e r e n t c o m m a n d s , i y o u s s y m b o l t h a t s t a n d s f o t h n u m b e r y o u ' d l i k e a c t e d o i t h c o m m a n d s t h a t a c o i t I y o i n s t r u c t t h c o m p u t e r e a r l y i n t h p r o g r a m t h a t s y m b o l i s t a n d i n g i f o

n u m b e r , t h c o m p u t e r w i l l s u b s t i t u t e t h n u m b e r a e a c h c o m m a n d i w h i c h i s u b s e q u e n t l y e n c o u n t e r s t h a t s y m b o l , a n t h e n a c o i t

T h h a n d i e s t s y m b o l t u s a s t a n d - i n f o n u m b e r i l e t t e r . Y o c a u s t h l e t t e r i a l c o m m a n d s w h e r e y o u w o u l d o t h e r w i s e h a v e u s e dt h n u m b e r . F o e x a m p l e , i y o w e r e c o n s i d e r i n g t e x t p l a c e m e n t o s c r e e n , y o m i g h t p u s u c h s u b s t i t u t e i T A c o m m a n d w i t h i n p r g r a m , l i k e t h i s :

2 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "3 P R I N T T A B ( A ) " H O W D O E S T H I S L O O K ? "

T h l e t t e r s u b s t i t u t e s f o r n u m b e r i t h T A c o m m a n d h e r e . I y o s e n t t h e R U c o m m a n d t t h c o m p u t e r f o t h i s t w o - l i n e p r o g r a m w i t ho u f i r s t a s s i g n i n g v a l u e t A i w o u l d f o l l o w b u i l t - i n d i r e c t i o n s a n r e p l a c e t h e l e t t e r w i t h t h v a l u e z e r o .

T h A s s i g n m e n t S t a t e m e n tT h c o m m a n d b w h i c h y o g i v e v a l u e t s y m b o l i k n o w n a t h

" a s s i g n m e n t s t a t e m e n t . " I i r e p r e s e n t e d b a e q u a l s i g n = ) a n t

Page 38: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 38/148

2 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

d i r e c t t h c o m p u t e r t o s u b s t i t u t e v a l u e o 1 f o i t h i s p r o g r a m , y o c o u l d s e n d t h c o m m a n d :

1 1

W h e n y o R U t h i s t h r e e - l i n e p r o g r a m , t h r e s u l t w i l l b t h w o r d s" H O W D O E S T H I S L O O K ? " p r i n t e d b e g i n n i n g a c o l u m n 1 2

H a v i n g s n a m e d n u m b e r u s e d i t h p r o g r a m , y o c a c h a n g e t h o p e r a t i o n o f t h p r o g r a m w i t h o u t c h a n g i n g t h l i n e t h a t d i r e c t s t h a t o p e ra t i o n . C h a n g e t h v a l u e o i l i n e 1 0 , l i k e t h i s :

1 2

a n t h c o m p u t e r w i l l p r i n t a c o l u m n 2 0 U s e d i t h i s w a y , t h l e t t e ra c t s a v a r i a b l e s y m b o l t h a t c a s t a n d f o w h a t e v e r n u m b e r y o s p e c i f yw i t h a e q u a l s i g n .

Y o c a u s v a r i a b l e i n a s m a n y c o m m a n d s i y o u r p r o g r a m a y o w a n t . I y o a d t h c o m m a n d :

2 P R I N T " C O L U M N A

t t h p r o g r a m , t h c o m p u t e r w i l l r e s p o n d w h e n y o R U t h p r o g r a mb p r i n t i n g

C O L U M N 2

T h e n i w i l l p r i n t t h q u e s t i o n s t a r t i n g a c o l u m n 2 0 b e l o w t h a t l i n e .A g a i n , i y o c h a n g e t h v a l u e o f a n t h e n g i v e t h c o m m a n d R U N ,t h c o m p u t e r w i l l p o s i t i o n t h e p r i n t i n g a c c o r d i n g l y , b c o l u m n n u m b e r :

1

v a r i a b l e l e t t e r l i k e c a b u s e d a n n u m b e r o f t i m e s i p r o g r a mt s t a n d i f o n u m b e r . I t h i s p r o g r a m y o u c a u s i t t r o u d i f f e r e n ts c r e e n - p r i n t i n g p l a c e m e n t s b r e t y p i n g o n l y t h s i n g l e s h o r t p r o g r a m l i n e1 0 I m o r e c o m p l e x p r o g r a m s , t h e f f e c t o c h a n g i n g a v a r i a b l e ' s v a l u eb c h a n g i n g a a s s i g n m e n t c o m m a n d c a b p r o f o u n d .

T h a s s i g n m e n t c o m m a n d c a b t r a n s l a t e d a d i r e c t i o n t t h c o p u t e r t w o r k i n t e r n a l l y t r e p l a c e t h s y m b o l o t h l e f t o t h e q u a l s i g n( w h e r e v e r t h a t s y m b o l i e n c o u n t e r e d ) w i t h t h n u m e r i c v a l u e o t h r i g h to t h s i g n .

Page 39: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 39/148

P L A N S A N P R O G R A M S 2

N U M E R I C A L P R E D I C T I O N ST h c o m p u t e r c a a c o m o r e t h a n o n s y m b o l i c v a r i a b l e i p r

g r a m , i y o i n c l u d e a a s s i g n m e n t s t a t e m e n t f o e a c h . T h i s c a p a b i l i t yg i v e s y o u e n o r m o u s p o w e r i w r i t i n g p r o g r a m s t a n a l y z e o r p r e d i c t v a r io u s i t u a t i o n s . I y o c a d e s c r i b e s i t u a t i o n w i t h n u m b e r s , y o c a d i r e c t t h c o m p u t e r t s i m u l a t e t h s i t u a t i o n w i t h a n o a l o i t a s p e c t sc h a n g e d . Y o c a n , f o i n s t a n c e , c o m p a r e t h r e s u l t s o d i f f e r e n t s a l a r yo f f e r s , o t h f i l l i n g o r e s e r v o i r s b e h i n d d i f f e r e n t d a m s .

p r e d i c t i o n o t h f i l l i n g o d a o y o u r b a n k a c c o u n t c o u l d b m a d eb f o r m i n g a n u m e r i c a l m o d e l o t h f a c t o r s k n o w n t b a w o r k . T h e n ,s e n d i n g v a l u e s f o t h e s e f a c t o r s t o t h c o m p u t e r w i t h a s s i g n m e n t s t a t em e n t s , y o c a s e w h a t t h m o d e l p r e d i c t s a r e s u l t . Y o c a e a s i l yp r e d i c t t h a m o u n t o w a t e r i r e s e r v o i r o t h a m o u n t o m o n e y i y o u ra c c o u n t a f t e r , s a y , n i n e m o n t h s , i y o k n o w t h a m o u n t a l r e a d y t h e r e a n t h a v e r a g e m o n t h l y r a t e a w h i c h m o r e a c c u m u l a t e s . Y o c a d i r e c t t h c o m p u t e r t p r i n t t h e s e v a l u e s a n t h e n t p r i n t t h c a l c u l a t i o n o t h t o t a la m o u n t n i n e m o n t h s l a t e r w i t h t h f o l l o w i n g p r o g r a m . ( B s u r e t s e n dt h N E c o m m a n d t o c l e a r t h l a s t p r o g r a m f r o m m e m o r y b e f o r e t y p i n gt h i s o n e . ) I i t t h o r i g i n a l a m o u n t i s y m b o l i z e d b t h l e t t e r A a n t h m o n t h l y r a t e o a c c u m u l a t i o n b t h l e t t e r B

N E 3 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "4 P R I N T " S T A R T I N G W I T H "5 P R I N T " A N D G A I N I N G " " E A C H M O N T H "6 P R I N T " Y O U ' L L H A V E " ( B * 9 ) " A F T E R M O N T H S . "

I y o c o m m a n d t h c o m p u t e r t R U t h i s p r o g r a m n o w , i w i l l a u t om a t i c a l l y s u b s t i t u t e z e r o f o t h v a r i a b l e s a n B B u i y o a s s i g n v a u e f o t h a m o u n t p r e s e n t a n t h r a t e o a c c u m u l a t i o n , t h c o m p u t e rw i l l d i s p l a y t h o s e v a l u e s a n d , t h r o u g h t h d i r e c t i o n s i n p r o g r a m l i n e 6 0 p r i n t p r e d i c t i o n o t h e f u t u r e a m o u n t . Y o c a g i v e v a l u e s t t h e v a r i ab l e s w i t h t h p r o g r a m l i n e s :

1 2 2 0 02 3 5

T h c o m p u t e r w i l l r u t h c o m p l e t e p r o g r a m w i t h 2 2 0 0 a t h s t a r t i n ga m o u n t ( g a l l o n s o w a t e r , o d o l l a r s ) a n 3 5 a t h m o n t h l y i n c r e a s e , t p r o d u c e t h e d i s p l a y s h o w n i F i g u r e 3 . 3 .

Page 40: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 40/148

2 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

F i g u r e 3 . 3 : T h r e s u l t s o p r e d i c t i o n p r o g r a m .

Y o c a n , o c o u r s e , c h a n g e t h s i m u l a t i o n b c h a n g i n g t h v a l u e sa s s i g n e d i l i n e s 1 a n 2 0 a n s m a k e p r e d i c t i o n s f o d i f f e r e n t c i r c u ms t a n c e s . T h i s p r o g r a m w a w r i t t e n t p r o d u c e p r e d i c t i o n f o n i n em o n t h s , b u i c a b a l t e r e d b r e p l a c i n g t h e s p e c i f i c v a l u e w i t h v a r ia b l e , t h r o u g h w h i c h y o c a n p r o d u c e a p r e d i c t i o n f o a n n u m b e r o m o n t h s . T d t h i s , y o c a m o d i f y l i n e 6 0 w h i c h p r o d u c e s t h e d i s p l a ya n c a l c u l a t i o n . Y o c a a s s i g n t h v a r i a b l e t t h n u m b e r o m o n t h s :

6 P R I N T " Y O U ' L L H A V E " A + ( B * C ) " A F T E R " M O N T H S . "

B a d d i n g a n o t h e r a s s i g n m e n t c o m m a n d , y o c a s p e c i f y a n o t h e r l e n g t ho t i m e , s a 1 m o n t h s :

2 1

W h e n y o r u t h p r o g r a m t h r o u g h t h c o m p u t e r n o w , i w i l l d i s p l a y t h o r i g i n a l a m o u n t o f 2 2 0 0 , a n p r e d i c t a i n c r e a s e o 3 5 e a c h m o n t h , o v e r

p e r i o d o f 1 m o n t h s .Y o c a d i r e c t t h c o m p u t e r t o s u b s t i t u t e o n v a r i a b l e l e t t e r f o a n o t h e r , o f o a " e x p r e s s i o n , " c o n s i s t i n g o v a r i a b l e s a n o p e r a t o r s . I

Page 41: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 41/148

C O M I N G I N T O P O W E R 2

t h i s p r o g r a m i y o w a n t e d s h o r t h a n d w a o n a m i n g t h f i n a l a m o u n tp r e d i c t e d , y o c o u l d r e n a m e t h a t a m o u n t , s f a r e p r e s e n t e d b t h v a l u eo ( C ) i s e p a r a t e s t a t e m e n t , c a l l i n g i F

2 7 ( B * C )

N o t h a t t h f i n a l v a l u e h a s i m p l e n a m e , y o u c a o r d e r t h c a l c u l a t i o na n d i s p l a y o t h d i f f e r e n c e b e t w e e n t h o r i g i n a l a n f i n a l v a l u e s , a n F w i t h t h i s s i m p l e s t a t e m e n t :

7 P R I N T " T H E G A I N I S F -

Y o c o u l d t h e n s t r e a m l i n e t h e p r o g r a m ' s a p p e a r a n c e b i w i t h s u b s t i t ut i o n i n l i n e 6 0

6 P R I N T " Y O U ' L L H A V E " " A F T E R " " M O N T H S . "

Y o c a a g a i n c h a n g e t h d e t a i l s o t h i s m o d e l b y c h a n g i n g t h v a l u e s i l i n e s 1 0 , 2 0 a n 2 5

A l t h o u g h w h a v e u s e d o n l y w h o l e n u m b e r s s f a r , t h c o m p u t e r i a l s od e s i g n e d t w o r k w i t h d e c i m a l n u m b e r s . I c a t a k e v a l u e s s t a t e d i f i n ed e t a i l — f o r e x a m p l e , 2 2 0 0 . 3 5 . I c a a l s o h a n d l e f r a c t i o n s i t h e y ' r et r e a t e d a s d i v i s i o n s . T h v a l u e f o 1 a n 3 / m o n t h s , f o e x a m p l e , w o u l db s t a t e d a s 1 4 3 / 4 .

C O M M A N D S I G R O U P SC o m m a n d s w o r k p e r f e c t l y w e l l o n t n u m b e r e d p r o g r a m l i n e . B u

y o c a a l s o c o m b i n e s e v e r a l t o g e t h e r f o c o n v e n i e n c e o f o e a s e o p l a n n i n g .

T h t h r e e a s s i g n m e n t s t a t e m e n t s f r o m t h p r e v i o u s p r o g r a m :

1 2 2 2 B 3 5 2 1

c a n b e g r o u p e d u n d e r s i n g l e p r o g r a m l i n e n u m b e r , i y o p r e f e r . I c o m a n d s a r s e p a r a t e d f r o m e a c h o t h e r b c o l o n s , t h c o m p u t e r w i l l a c o

Page 42: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 42/148

2 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

e a c h c o m m a n d i g r o u p e d s e o n a t i m e , a t h o u g h e a c h w e r e o i t o w n u m b e r e d l i n e . Y o c o u l d r e p l a c e t h o s e t h r e e l i n e s w i t h s i n g l e l i n e ,l i k e t h i s :

1 2 2 0 0 : B = 3 5 5 : C 1 A n t h e n e r a s e t h t w n o w - r e d u n d a n t l i n e s b s e n d i n g e m p t y l i n e n u b e r s w i t h t h R E T U R N k e y :

2 2

T h e n e w l i n e n u m b e r 1 0 h o l d i n g g r o u p o c o m m a n d s , t h e n r e p l a c e s t h e a r l i e r l i n e s 1 0 2 0 a n 2 5 T h c o m p u t e r w i l l h o l d t h s a m e i n f o r m a t i o ni i t m e m o r y a n c a r r y o u t h p r o g r a m c o m m a n d s e x a c t l y t h e s a m ew a y . Y o c a g r o u p a m a n y c o m m a n d s i s i n g l e p r o g r a m l i n e a w i l l f i i t h 8 c h a r a c t e r s o f s p a c e t h c o m p u t e r r e c o g n i z e s f o c o m m a n de n t r i e s .

A l t h o u g h b o t h m e t h o d s o g r o u p i n g c o m m a n d s p r o d u c e t h s a m er e s u l t s w h e n p r o g r a m i r u n , y o m a p r e f e r o n t t h o t h e r . W i t h i np r o g r a m w r i t t e n w i t h o n c o m m a n d t s t a t e m e n t l i n e , y o c a m o r ee a s i l y f i n d p r o b l e m s t h a t c a l l f o r e w r i t i n g o r a l t e r a t i o n — t h e a c c i d e n t a lm i s s p e l l i n g o c o m m a n d l e a d i n g t ? S Y N T A X E R R O R " r e p l y d u i n p r o g r a m r u n , f o e x a m p l e . O t h o t h e r h a n d , g r o u p i n g s e v e r a lc o m m a n d s t l i n e n u m b e r m a b a e a s i e r w a t c o m p o s e p r o g r a mf r o m m u l t i p l e c o m m a n d s t a t e m e n t s . E i t h e r w a y , t h c h o i c e i y o u r s .

Page 43: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 43/148

U S I N G J U D G E M E N TL i k e v i g i l a n t s e n t r y , y o c a w a t c h o v e r y o u r c o m p u t e r , d e c i d i n g

w h e n y o w o u l d l i k e c e r t a i n c o m m a n d s r e p e a t e d , o v a l u e s c h a n g e d , o w h e n y o u ' d l i k e t i n t e r r u p t p r o g r a m r u n . B u t h a t m e a n s y o u ' r ea t t e n d i n g t t h c o m p u t e r r a t h e r t h a n h a v i n g i a t t e n d t y o u .

F o r t u n a t e l y , s u c h v i g i l a n c e i s n ' t n e c e s s a r y . Y o u r d e c i s i o n s c a b r e f l e c t e d w i t h i n p r o g r a m , s o t h a t w h e n t h c o m p u t e r e n c o u n t e r s s p e c i f i cc o n d i t i o n s y o u ' v e d e s c r i b e d , i w i l l t a k e t h e a c t i o n y o u ' v e d i r e c t e d . T h C o m m o d o r e 6 c a e x a m i n e n u m e r i c c o m p a r i s o n ( t h a t i s s t a t e m e n tt h a t o n v a l u e i e q u a l o n o t e q u a l t o o g r e a t e r o l e s s t h a n , a n o t h e rv a l u e ) , a n " e v a l u a t e " i a e i t h e r t r u e o f a l s e . I t h s t a t e m e n t i t r u e , t h i n s t r u c t i o n t h a t i m m e d i a t e l y f o l l o w s w i l l b e x e c u t e d . I n o t , t h c o m p u t e rw i l l s k i p o v e r t h a t i n s t r u c t i o n a n p r o c e e d t t h n e x t n u m b e r e d l i n e .

T h c o m m a n d t h a t a l l o w s t h i s d e c i s i o n - m a k i n g i t h I F - T H E N s t a t em e n t , w h i c h t a k e s m u c h t h s a m e f o r m a t h " i f . . . t h e n " c o n d i t i o n a ls t a t e m e n t i e v e r y d a y E n g l i s h : " I i t ' s r a i n i n g n o w , t h e n g b c a r . " I f t h es t a t e m e n t i t r u e , t h e n t a k e t h e a c t i o n n a m e d . ( I n o t , t h e n d o n ' t . ) T h c o m p u t e r c o m m a n d l o o k s l i k e t h i s :

I ( c o m p a r i s o n ) T H E N ( i n s t r u c t i o n )

W e ' l l s e s o m e s p e c i f i c e x a m p l e s a l o n g t h w a y .Y o c a u s t h I F - T H E N c o m m a n d i n e p r o g r a m t e v a l u a t e

s u o t h r e e n u m b e r s r e p r e s e n t e d i t h e f o l l o w i n g w a y :1 5 : 8 :

Page 44: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 44/148

3 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

2 T = + Y o c a t h e n a r r a n g e f o t h c o m p u t e r t d i s p l a y s t a t e m e n t i t h s u i 1 0 0 , w i t h t h c o m m a n d :

3 I 1 0 T H E N P R I N T " S U O F H U N D R E D "w h i c h w i l l i n s t r u c t t h c o m p u t e r t o p r i n t t h s t a t e m e n t o n l y w h e n t h c o d i t i o n 1 0 o c c u r s .

W h e n t h i s p r o g r a m i r u t h r o u g h t h C o m m o d o r e 6 4 t h q u o t a t i o nw i l l b p r i n t e d . I l i n e 1 i c h a n g e d s o t h a t t h e v a l u e s a d t s o m e t h i n ge l s e , t h c o m p u t e r w i l l s k i p p a s t T H E N a n i t P R I N T c o m m a n d , i t h i sc a s e t t h p r o g r a m ' s e n d .

O e n c o u n t e r i n g a I F - T H E N s t a t e m e n t , t h c o m p u t e r f o l l o w s b u i l t -i d i r e c t i o n s t e v a l u a t e t h c o n d i t i o n s t a t e d t t h r i g h t o t h w o r d I W h e n t h a t c o n d i t i o n i t r u e , t h c o m p u t e r f o l l o w s t h c o m m a n d t t h r i g h t o t h w o r d T H E N . W h e n i i f a l s e , t h c o m p u t e r s k i p s t t h n e x tp r o g r a m l i n e .

Y o c a d i r e c t t h c o m p u t e r i t h i s d e c i s i o n - m a k i n g p r o c e s s t h r o u g ha n m a t h e m a t i c a l r e l a t i o n i i b u i l t t u n d e r s t a n d . T h f o l l o w i n g c h a n g et t h p r o g r a m , f o i n s t a n c e , t e s t s t h n u m b e r s o g u e s t s a r r i v i n g i g r o u p s a g a t h e r i n g :

3 I 1 0 T H E N P R I N T " T H E R O O M I G O I N G T B C R O W D E D "

H e r e , t h t e s t i n o w h e t h e r i e q u a l t p a r t i c u l a r v a l u e , b u w h e t h e r i i g r e a t e r t h a n t h e v a l u e .

W h e n i e n c o u n t e r s n u m b e r a f t e r t h w o r d T H E N , t h c o m p u t e rt r a n s l a t e s t h n u m b e r a d i r e c t i o n t c a r r y o w i t h t h p r o g r a m f r o m t h c o m m a n d s i n t h a t l i n e n u m b e r . T h u s , b e s i d e s i n s t a n t l y f o l l o w i n g c o m a n d i t h I F - T H E N s t a t e m e n t , t h e c o m p u t e r c a b s e n t t a n o t h e rp a r t o t h p r o g r a m b l i n e n u m b e r , a i t h e f o l l o w i n g p r o g r a m :

N E 1 A = 2 0 : B 1 5 : C2 T 3 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) W I T H G R O U P S

O F " A " A N D " B " A N D " C " T H E R O O M W I L L H A V E ' T" P E O P L E I I T

4 I T 7 T H E N 1 0 5 P R I N T " ( p r e s s C U R S O R U P / D O W N ) N P R O B L E MA C C O M M O D A T I N G T H A T M A N Y6 E N

Page 45: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 45/148

D E C I S I O N - M A K I N G B C O M P U T E R 3

1 0 P R I N T " T H A T ' S M O R E T H A N T H R O O M W I L LH O L D ! "

U s i n g t h e v a l u e s a s s i g n e d i l i n e 1 0 , t h c o m p u t e r w i l l p r i n t t h q u o t at i o n s i n l i n e s 3 a n 5 0 t h e n s t o p c a r r y i n g o u t c o m m a n d s o r e a c h i n g t h E N s t a t e m e n t . I w i l l s k i p p a s t t h c o m m a n d t h a t w o u l d r e d i r e c t i t l i n e 1 0 f r o m l i n e 4 0 T H E N 1 0 0 . I y o c h a n g e l i n e 1 s o t h a t t h s u e x c e e d s 7 5

1 0 A = 1 9 : B 2 3 : C 3 a n r u t h p r o g r a m a g a i n , t h c o m p u t e r w i l l c a r r y o u t h c o m m a n da f t e r T H E N a n s k i p p a s t l i n e s 5 a n 6 t c a r r y o u t h P R I N T s t a t em e n t o l i n e 1 0 0 .

T d i r e c t t h C o m m o d o r e 6 t l i n e n u m b e r f r o m a n I F - T H E Ns t a t e m e n t , y o c a a l s o i n c l u d e t h e o p t i o n a l c o m m a n d w o r d G O T O . T h f o l l o w i n g r e v i s i o n o l i n e 4 0

4 I T 7 T H E N G O T 0 1 0 0p r o d u c e s t h s a m e r e s u l t s a i t p r e d e c e s s o r , b u m a b l i t t l e e a s i e r t r e a d a n u n d e r s t a n d .

I d i r e c t i n g t h c o m p u t e r f o r w a r d t h r o u g h p r o g r a m a c c o r d i n g t v a u e i e n c o u n t e r s , o d i r e c t i n g i t s o m e i m m e d i a t e c o m m a n d w i t h i n a I F - T H E N s t a t e m e n t , y o c a n c h a n g e t h w a t h c o m p u t e r e x e c u t e sp r o g r a m . B d i r e c t i n g t h c o m p u t e r b a c k w a r d t a e a r l i e r l i n e n u m b e rf r o m a I F - T H E N s t a t e m e n t , y o c a m a k e i r e p e a t e a r l i e r c o m m a n d s ,w i t h v a r i a t i o n s i y o l i k e .

S I M U L A T I O N SA I F - T H E N s t a t e m e n t w i t h l i n e n u m b e r i l i k e f i n g e r p o i n t i n g

b a c k w a r d o f o r w a r d . T h i s a b i l i t y t p o i n t t o d i f f e r e n t c o u r s e s o a c t i o nc a n b e e s p e c i a l l y u s e f u l i n s i m u l a t i n g d i f f e r e n t s c e n a r i o s . Y o c a a p p l y i t f o i n s t a n c e , t t h p r o b l e m o f i l l i n g p a r t y r o o m w i t h g u e s t s a r r i v i n g i g r o u p s w i t h o u t e x c e e d i n g t h r o o m ' s c a p a c i t y .

I s i t u a t i o n l i k e t h i s , t h e r e a r t h r e e v a l u e s t c o n s i d e r : t h e c a p a c i t y o ft h r o o m , w h i c h y o c a c a l l t h v a r i a b l e C t h n u m b e r o g u e s t s a t h p a r t y , w h i c h y o c a c a l l G ; a n d t h r a t e a w h i c h n e g u e s t s a r r i v e e a c ht r i p — c a l l t h i s R I y o w a n t t k n o w h o m a n y t r i p s w i l l f i l l , b u n o c r o w d , t h p a r t y , y o c a u s a I F - T H E N s t a t e m e n t t o i n s t r u c t t h c o p u t e r t c o n s i d e r t r i p a f t e r t r i p , a n t h e n s i g n a l y o w h e n t h s i m u l a t e dt r i p t h a t f i l l s t h r o o m f i n a l l y o c c u r s .

Y o c a b e g i n t h i s n e p r o g r a m w i t h s t a t e m e n t d e f i n i n g t h r o o m

Page 46: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 46/148

3 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

s i z e , t h n u m b e r o g u e s t s a t h e s i m u l a t i o n ' s b e g i n n i n g , a n t h r a t e o n e a r r i v a l s :

N E 1 2 0 0 : G 2 0 : R

T h c o m p u t e r w i l l p r e p a r e t h s c r e e n a n d i s p l a y t h e a v a i l a b l e r o o m f r o mt h e s e c o m m a n d s :

2 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) " . .3 P R I N T " A F T E R " N ' T R I P S " " P R E S E N T & R O O M F O R "

I l i n e 3 0 t h e v a r i a b l e w i l l s e r v e a c o u n t e r f o t h n u m b e r o t r i p st h r o u g h w h i c h t h p r o g r a m h a d i r e c t e d t h c o m p u t e r . Y o m a k ec o u n t e r a n k e e p G t h n u m b e r o g u e s t s , u t d a t e w i t h t h e s ec o m m a n d s :

4 1 : T h c r u c i a l c o m m a n d i t h o n t h a t d i r e c t s t h c o m p u t e r e i t h e r t c o t i n u e o t s t o p c o n s i d e r i n g t r i p s :

5 I F G < C T H E N 3 0T h i s l i n e i n s t r u c t s t h c o m p u t e r t o e i t h e r r e t u r n t t h s e q u e n c e a l i n e 3 ( i i l e s s t h a n C o r c o n t i n u e t t h f i n a l l i n e , w h i c h s i g n a l s y o t h a tl i m i t h a b e e n r e a c h e d :

6 P R I N T : P R I N T F I L L E D A F T E R T R I P "

W h e n y o r u i t t h i s p r o g r a m w i l l d i r e c t t h c o m p u t e r t r e p e a t t h eq u o t a t i o n i l i n e 3 w i t h d i f f e r e n t v a l u e s u n t i l t h r o o m ' s l i m i t i r e a c h e d .F i g u r e 4 . s h o w s t h s t e p s t h a t t h p r o g r a m r u t a k e s .

F i r s t , t h c o m p u t e r s t o r e s t h v a l u e s f o C G a n ( s t a t e d i l i n e 1 0 i i t m e m o r y , t h e n c l e a r s t h s c r e e n a n p o s i t i o n s t h c u r s o r f o t h P R I N T s t a t e m e n t i l i n e 3 0 W h e n t h a t s t a t e m e n t i f i r s t e n c o u n t e r e d ,t h v a l u e o h a b e e n a u t o m a t i c a l l y s e a z e r o . T h i s r e p r e s e n t s t h e c o d i t i o n o t h r o o m b e f o r e t h f i r s t t r i p o n e w c o m e r s :

A F T E R T R I P S 2 P R E S E N T R O O M F O 1 8

E n c o u n t e r i n g l i n e 4 0 , t h e c o m p u t e r c o n s i d e r s t r i p n u m b e r 1 w h i c hi n c r e a s e s t h n u m b e r o g u e s t s t o 2 6 . T h e n , a l i n e 5 0 i c o m p a r e s t h n u m b e r o g u e s t s t t h r o o m ' s c a p a c i t y a n d , f i n d i n g o t h i s f i r s t p a s s t h a tt h n u m b e r i s m a l l e r , i f o l l o w s t h I F - T H E N d i r e c t i o n t l i n e 3 0 A c t i n g

Page 47: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 47/148

D E C I S I O N - M A K I N G B C O M P U T E R 3

6 A F T E R5 A F T E R4 A F T E R4 A F T E R3 A F T E R3 A F T E R2 A F T E R1 A F T E R1 A F T E R

2 2 2 2 2 2 2 2 2

F I L L E D

T R I P ST R I P ST R I P ST R I P ST R I P S

T R I P ST R I P ST R I P S

P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E N TP R E S E N T

R O O M F O R O O M F O

A F T E R T R I P t 3 ♦ > ♦ - « ■ ♦ * -t E A O V .

F i g u r e 4 . 1 : T h o u t c o m e o s i m u l a t i o n p r o g r a m .a g a i n o l i n e 3 0 t h c o m p u t e r d i s p l a y s t h v a l u e s o a n a f t e r t h a tf i r s t t r i p :

A F T E R T R I P S 2 P R E S E N T & R O O M F O 1 7

B l i n d t i t p o o r g r a m m a r , t h c o m p u t e r g o e s o t c o n s i d e r t h s e c o n dt r i p a t l i n e 4 0 a n r e p e a t s t h e p r o c e s s . I p r i n t s t h s a m e s t a t e m e n t a e a c ht r i p u n t i l t h p a s s a w h i c h t h n u m b e r o g u e s t s r e a c h e s t h c a p a c i t y ,w h e n i 3 0 O e n c o u n t e r i n g t h I F - T H E N c o m m a n d a t h a t p o i n t ,t h c o m p u t e r a d v a n c e s t l i n e 6 0 p r i n t i n g t h e m e s s a g e t h a t t h r o o mw o u l d b f i l l e d a f t e r t h a t t r i p .

Y o c a a d h a n d y f e a t u r e t t h i s p r o g r a m b y d i r e c t i n g i t d i s p l a yt h c o n d i t i o n s y o s t a t e d i l i n e 1 0 :

7 0 L I S T 1

T h i s c o m m a n d w i l l p r i n t l i n e 1 0 a i F i g u r e 4 . 2 . Y o c a n o r e t y p e t h l i n e t r e f l e c t l a r g e r r o o m , C , d i f f e r e n t n u m b e r o g u e s t s a l r e a d yp r e s e n t , G o d i f f e r e n t r a t e o a r r i v a l , R

U n d e r t h d i r e c t i o n o a I F - T H E N c o m m a n d s e n d i n g i b a c k w a r d ,t h c o m p u t e r c o n j u r e s i t r e p e t i t i v e p o w e r s . A c t i n g u n d e r o t h e r c o m a n d s , t h c o m p u t e r c a b s e n t i a n d i r e c t i o n t o y e o t h e r c o m m a n d s ,

Page 48: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 48/148

3 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

5 A F T E R 2 4 A F T E R 2 4 A F T E R 2 3 A F T E R 2 3 A F T E R 2 2 A F T E R 2

1 A F T E R 2 1

T R I P ST R I P S

T R I P S

T R I P S

P R E S E N T R O O M F O R lP R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E M T R O O M F O P R E S E N T R O O M F O P R E S E N T R O O M F O P R E S E M T R O O M F O P R E S E N T R O O M F O

F I L L E D A F T E R T R I P 3 1 C = 2 Q 0 G = 2 0 R =

E A O Y .

F i g u r e 4 . 2 : s i m u l a t i o n p r o g r a m t h a t d i s p l a y s t h c o n d i t i o n s w h i c h d i r e c t e d i t

f r o m o n e p r o g r a m l i n e t a n o t h e r . C o m p l e x r o u t e s c a b f o r m e db e t w e e n p r o g r a m s t a t e m e n t s , e a c h o w h i c h a s k s t h c o m p u t e r t d s o m e t h i n g d i f f e r e n t .

Page 49: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 49/148

s e r v i l e m a c h i n e , t h c o m p u t e r c a a c c e p t a n o b e y s c o r e s o c o m a n d s . I w i l l a c o t h e m i i t o w d u l l - w i t t e d b u m e t i c u l o u s w a y . W i t ht h e s e c o m m a n d s , y o c a n p u t t h m a c h i n e t w o r k o n t a s k s y o m i g h to t h e r w i s e f i n d t o o t e d i o u s o r e p e t i t i v e , t o o n i t p i c k i n g o p r e c i s e , t o l o n go t i m e - c o n s u m i n g . W h e n s c o m m a n d e d i a l a n g u a g e i r e c o g n i z e s ,y o u r c o m p u t e r c a r e p e a t g i v e n t a s k e n d l e s s l y o a s o f t e n a y o s a y . I c a h a n d l e w o r d s o n u m b e r s , t e a r i n g t h e m a p a r t o d e l i c a t e l y a s s e mb l i n g t h e m , i c a c a r r y o u t h m o s t c u m b e r s o m e c a l c u l a t i o n s , o i c a q u i c k l y p r o d u c e s c r e e n d i s p l a y s o c o m p l e x i t y t h a t w o u l d o t h e r w i s e b p o s s i b l e o n l y b d a y s o h a n d - w o r k .

P R O G R A M M E R ' S K I O C O M M A N D SH u m a n b e i n g s a r e i m p e r f e c t : w c h a n g e o u r m i n d s , w m a k e m i

t a k e s , a n w a r p r o n e t f o r g e t . T h p r o g r a m s w d e v i s e a r e s u b j e c t t o u i n t e r e s t i n g a n i m p e r f e c t n a t u r e , a n a l l o w f o t h i s n a t u r e , y o c a m a r k , s t o p , a n r e s t a r t t h p r o g r a m s y o u s e . Y o c a b o r r o w u s e f u ls t a t e m e n t s o c o m m a n d s f r o m o t h e r p r o g r a m s , a n t i n k e r t h e m i n t o t h s h a p e y o w a n t .

R E M : P r o g r a m m e r ' s N o t e b o o kI y o p u t o g e t h e r m a n y p r o g r a m s , y o u ' l l f i n d h a n d y c o m m a n d t h a t

m a r k s p r o g r a m l i n e s w i t h o u t a f f e c t i n g t h c o m p u t e r ' s o p e r a t i o n . T h a tc o m m a n d i R E M , w h i c h s t a n d s f o " r e m a r k . " Y o c a a p p r e c i a t e i t u s e f u l n e s s b c o n s i d e r i n g t h e f o l l o w i n g g r a p h i c s p r o g r a m , w h i c h d i r e c t s

Page 50: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 50/148

3 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

t h d r a w i n g o c h e c k e r e d p a t t e r n l i k e t h a t s h o w n i F i g u r e 5 . 1 . T h p a t e r n i m a d e b f i r s t d r a w i n g v e r t i c a l l i n e s i w h i t e i e v e n - n u m b e r e dc o l u m n s ( i p r o g r a m l i n e s 2 t h r o u g h 6 0 ) , a n t h e n s l i c i n g t h r o u g h t h e mw i t h h o r i z o n t a l l i n e s o f b l a c k ( i l i n e s 7 t h r o u g h 1 2 0 ) . N o t i c e t h a t l i n e 7 u s e s t h e C L R / H O M E k e w i t h o u t S H I F T , t s e n d t h c u r s o r " h o m e "w i t h o u t c l e a r i n g t h s c r e e n .

N E 1 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "2 3 P R I N T T A B ( A ) " ( p r e s s C a n + ) ( p r e s s S H I F T a n C U R S O R

U P / D O W N ) "4 2 : I F A < 2 5 T H E N 3 05 P R I N T6 B : I F B < 2 0 T H E N 2 07 P R I N T " ( p r e s s C L R / H O M E ) "8 9 P R I N T T A B ( M ) " ( p r e s s S P A C E B A R ) ( p r e s s S H I F T a n C U R S O R

U P / D O W N ) "1 0 1 : I F M < 2 5 T H E N 9 01 1 P R I N T " ( p r e s s C U R S O R U P / D O W N ) "1 2 2 : I F V < 2 0 T H E N 8 0

W h a t t h i s p r o g r a m d o e s i n o i m m e d i a t e l y o b v i o u s t a n y o n e r e a d i n gi t I n s t e a d o r u n n i n g t h p r o g r a m t h r o u g h t h c o m p u t e r e a c h t i m e y o w i s h t s e w h a t i d o e s , y o c a i d e n t i f y i w i t h l a b e l i n g " r e m a r k " l i n e ,w h i c h , a n o t e t w h o e v e r r e a d s t h p r o g r a m , i n o a c t e d o n b y t h c o m p u t e r . T s m a r k t h i s p r o g r a m , a d l i n e t h a t s t a r t s w i t h R E M :

R E P R O G R A M F O T H C O M M O D O R E 6 T H A T M A K E S AC H E C K E R E D P A T T E R N .

W h e n t h c o m p u t e r e n c o u n t e r s t h i s R E l i n e i p r o g r a m , i t a k e st h c o m m a n d R E t m e a n : " M o v e o t t h n e x t p r o g r a m l i n e ; w h a tf o l l o w s i r e m a r k f o t h p e r s o n r e a d i n g t h i s p r o g r a m . " A l t h o u g h p r g r a m m a m a k e p e r f e c t s e n s e t y o w h e n y o t y p e i t f e w w e e k s l a t e r —o s o m e t i m e s a s h o c k i n g f e m i n u t e s l a t e r — i t m a s e e m n o t h i n g b u b a f f l i n g a s s o r t m e n t o c o m m a n d s u n l e s s y o u ' v e t a g g e d i w i t h a n o t e .

S i n c e t h R E c o m m a n d c a b p u a n y w h e r e i a p r o g r a m , y o c a d e s c r i b e s e c t i o n s o i n d i v i d u a l c o m m a n d l i n e s o p r o g r a m i y o l i k e .F o i n s t a n c e , i n t h c a s e o t h c h e c k e r e d p r o g r a m , y o c a a d n o t e sb e f o r e t h s t a t e m e n t s t h a t d i r e c t t h c o m p u t e r t p r o d u c e t h v e r t i c a l l i n e s ,

Page 51: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 51/148

P R O G R A M C O N T R O L 3

i l

£ $ s & & * & * $ » $ a s *

: ? *

5 . 1 : c h e c k e r e d p a t t e r n p r o d u c e d b p r o g r a m .a n a l s o b e f o r e t h s t a t e m e n t s t h a t p r o d u c e t h e h o r i z o n t a l l i n e s :

1 R E T H N E X T F I V E P R O G R A M S T A T E M E N T S D R A WV E R T I C A L L I N E S I C H A R A C T E R C O L O R

6 R E T H N E X T S I P R O G R A M S T A T E M E N T S D R A WH O R I Z O N T A L L I N E S I B A C K G R O U N D C O L O R

p r o g r a m m a r k e d i t h i s w a w i l l b e a s i e r t o i d e n t i f y a n a l t e r , l a t e r .R E s t a t e m e n t s a r s u b j e c t t t h s a m e 8 0 - c h a r a c t e r l e n g t h l i m i t a o t h e rp r o g r a m s t a t e m e n t s ; l i n e 6 i a l o n g a R E l i n e c a b e

I n t e r r u p t i n g P r o g r a m R u W h i l e t h i s p r o g r a m i r u n n i n g , y o m i g h t d e c i d e y o u ' d l i k e s l i g h t l y

d i f f e r e n t p a t t e r n . T s t o p t h e p r o g r a m i m i d - s t r i d e , y o c a u s a n o t h r e e c o m m a n d s . T h p l a n n e d w a i t i n c l u d e c o m m a n d t t h a t e f f e c tw i t h i n t h p r o g r a m i t s e l f . T h p r o g r a m c o m m a n d t h a t w i l l i n t e r r u p tr u i S T O P . Y o c a s t r a t e g i c a l l y i n c l u d e i t s t o p t h p r o g r a m r u a f t e rt h v e r t i c a l l i n e s h a v e b e e n d r a w n b y p r o g r a m s t a t e m e n t s 2 t h r o u g h 6 0 l i k e t h i s :

6 S T O P

Page 52: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 52/148

3 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

I y o r u t h p r o g r a m w i t h t h i s a d d i t i o n a l l i n e , t h c o m p u t e r w i l l s t o pf o l l o w i n g p r o g r a m c o m m a n d s o e n c o u n t e r i n g t h s t a t e m e n t , a n w i l li n f o r m y o t h a t f o r c e d b r e a k i t h r u h a b e e n o r d e r e d , w i t h t h r e p l y :

B R E A K I 6 T h S T O P c o m m a n d d i f f e r s f r o m t h E N c o m m a n d o n l y i n t h a t t h c o m p u t e r r e p l i e s w i t h m e s s a g e . S T O P c a b p a r a p h r a s e d a s " P r i n tB R E A K I a n t h i s l i n e n u m b e r , a n w a i t f o d i r e c t i o n s f r o m t h k e y b o a r d . "

A a d v a n t a g e o t h S T O P c o m m a n d i t h a t y o c a n , a y o u r c o n v en i e n c e , c o m m a n d t h c o m p u t e r t p r o c e e d w i t h t h p r o g r a m r u n , b s e n d i n g t h c o m m a n d :

C O N Tw h i c h c a n b e p a r a p h r a s e d " C o n t i n u e c a r r y i n g o u t c o m m a n d s a t h p r g r a m l i n e f o l l o w i n g t h e i n t e r r u p t i o n . " O c o u r s e , i t h S T O P c o m m a n di r e m o v e d f r o m a p r o g r a m ( h e r e b r e m o v i n g l i n e 6 5 ) , t h p r o g r a m w i l lr u s t r a i g h t t h r o u g h w i t h o u t p a u s e .

T h s e c o n d w a t s t o p a r u n n i n g p r o g r a m i d i r e c t l y f r o m t h k e b o a r d , w i t h t h c o m m a n d t h a t m i m i c s t h S T O P c o m m a n d i a i m m ed i a t e , u n p l a n n e d w a y . T s t o p p r o g r a m a a n p o i n t i i t o p e r a t i o n ,p r e s s t h e R U S T O P k e y . A f t e r r e c e i v i n g t h i s k e y s t r o k e c o m m a n d , t h c o m p u t e r w i l l r e p l y w i t h t h " B R E A K I N m e s s s a g e . O n c e s t o p p e d i p r o g r a m r u w i t h t h R U S T O P c o m m a n d , t h c o m p u t e r w i l l a l s or e s u m e c a r r y i n g o u t p r o g r a m c o m m a n d s w h e n s e n t t h C O N T c o m a n d . T h S T O P c o m m a n d , i m p l a n t e d i p r o g r a m , a n t h R U S T O P c o m m a n d , s e n t f r o m t h k e y b o a r d , b o t h a f f e c t t h c o m p u t e r ' so p e r a t i o n i t h s a m e w a y .

Y o c a u s e i t h e r o n t s t o p t h e c o m p u t e r a t l i n e 5 o t h c u r r e n tp r o g r a m , j u s t a f t e r t h b o t t o m e d g e s o t h v e r t i c a l l i n e s h a v e b e e n d r a w n ,t c o n s i d e r v a r y i n g t h p a t t e r n . O n w a t c h a n g e t h d i s p l a y i t s e l e c ta n o t h e r c h a r a c t e r o c o l o r f o t h r o w s d r a w n b l i n e s 7 t h r o u g h 1 2 0 .E v e n b l a c k - a n d - w h i t e s c r e e n w i l l s h o w c h a n g e s i s h a d i n g s a m o n gc o l o r s .

N o t h a t y o u ' v e i n t e r r u p t e d t h e p r o g r a m . . . I n t e r r u p t i n g p r o g r a mc a s o m e t i m e s g i v e y o i d e a s f o r i n t e r e s t i n g v a i r i a t i o n s . F o e x a m p l e , y o c a c h a n g e p r o g r a m l i n e 1 2 s o a s t d r a w c o l u m n s o s p a c e s o n l y a f a d o w n a r o 1 8

1 2 2 : I F V < 1 8 T H E N 8 0

Page 53: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 53/148

P R O G R A M C O N T R O L 3

Y o c a c r e a t e h o r i z o n t a l r o w s o c i r c l e s w i t h t h i s r e v i s i o n :9 P R I N T T A B ( M ) " ( p r e s s S H I F T a n W ( p r e s s S H I F T a n C U R S O R

U P / D O W N ) "O c o u r s e , y o c a n k e e p r e v i s i n g u n t i l t h e p a t t e r n i o n y o l i k e . P e r h a p st h i s r e v i s i o n o p r o g r a m l i n e s 8 a n 1 0 w i l l a d t h f i n i s h i n g t o u c h :

8 1 0 2 : I F M < 2 0 T H E N 9 0

T h e s e t h r e e c h a n g e s w i l l p r o d u c e a p r o g r a m t h a t d i s p l a y s t h p a t t e r n o l i n e s a n c i r c l e s s h o w n i F i g u r e 5 . w h e n r u n .

T h R U S T O P - R E S T O R E C o m m a n dT h t h i r d a n m o s t i n t r u s i v e w a o f s t o p p i n g r u n n i n g p r o g r a m

d i r e c t s t h c o m p u t e r t l e a v e t h e p r o g r a m c o m p l e t e l y . T h p r o g r a m i r e t a i n e d i m e m o r y , b u n " m a r k e r " i l e f t i n t h e r u n . T s t o p p r o g r a mr u w i t h t h i s e m e r g e n c y - b r a k e c o m m a n d , w h i c h o p e r a t e s f r o m t h k e b o a r d , y o p r e s s t h R U S T O P a n R E S T O R E k e y s t o g e t h e r . S i n c et h c o m p u t e r f o r g e t s i t p l a c e i t h p r o g r a m , t h C O N T c o m m a n d i s n ' t

u s e f u l w a t p i c k u t h s e q u e n c e a g a i n i t h i s c a s e .

F i g u r e 5 . 2 : T h r e s u l t o r e v i s i n g t h p r o g r a m t h a t p r o d u c e d F i g u r e 5 . 1 .

Page 54: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 54/148

4 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

Y o c a u s u a l l y s l o w p r o g r a m , o a n r e s p o n s e o f t h c o m p u t e r , b p r e s s i n g t h C T R L k e a n h o l d i n g i d o w n . W h e n y o r e l e a s e i t h c o m p u t e r r e t u r n s t n o r m a l s p e e d .

W e ' v e n o s e e n t h f u l l s e o c o m m a n d s y o h a v e f o r e s t r u c t u r i n ge x i s t i n g p r o g r a m s i t h B A S I C l a n g u a g e . T h e r e a r m o r e c o m m a n d s f o b u i l d i n g t h p r o g r a m s t h e m s e l v e s .

C O M M A N D S F O M O V I N G A M O N G S T A T E M E N T S

T h G O T O C o m m a n dW e ' v e s e e n s o m e c o m m a n d s t h a t d i r e c t t h C o m m o d o r e 6 o u t s i d e i t

u s u a l c o u r s e t h r o u g h h i g h e r l i n e n u m b e r s i p r o g r a m ; t h e r e a r s t i l lm o r e . O n e , G O T O , i e v e n s i m p l e r i a c t i o n t h a n t h I F - T H E N c o m a n d . W e ' v e a l r e a d y u s e d i i v e r s i o n o t h a t c o m m a n d , I F - T H E N -G O T O . Y o c a a l s o u s t h G O T O c o m m a n d b i t s e l f , t d i r e c t t h c o m p u t e r b a c k t s o m e e a r l i e r s t a t e m e n t i p r o g r a m , a g a i n a n a g a i n ,c r e a t i n g a u n e n d i n g b o o c o m p u t e r a c t i o n . I d e a l f o r r e p e t i t i o u s t a s k s ,t h i s s o r t o l o o p c a b s t o p p e d o n l y w i t h o n o t h e t h r e e p r o g r a m -s t o p p i n g m e t h o d s d e s c r i b e d i t h p r e v i o u s s e c t i o n .

T h f o l l o w i n g p r o g r a m w i l l , i y o l e i r u n , c o m m a n d t h c o m p u t e r t p r o d u c e a " e n d l e s s " m u l t i p l i c a t i o n a n d i v i s i o n t a b l e . ( A c t u a l l y , y o w o u l d e v e n t u a l l y r e a c h n u m b e r g r e a t e r t h a n t h C o m m o d o r e 6 c a h a n d l e , a n g e a O V E R F L O W E R R O R m e s s a g e . ) I l i n e 1 t h n u m b e r t b m u l t i p l i e d a n d i v i d e d i s e a f i v e .

N E 1 2 P R I N T " ( p r e s s S H I F T a n H O M E ) - T H E N U M B E R "

A 3 P R I N T " N T A B ( 5 ) " M U L T I P L I E D B N T A B ( 2 2 ) " D I V I D E D B N 4 P R I N T5 6 P R I N T T A B ( 1 0 ) A T A B ( 2 5 ) A / 7 G O T O 4

T h f i n a l c o m m a n d , i l i n e 7 0 d i r e c t s t h r e p e t i t i o n o t h p r o g r a mf r o m l i n e 4 o n W i t h o u t t h a t G O T O d i r e c t i o n , t h p r o g r a m w o u l d s i p l r u t h r e e r o w s o p r i n t i n g — t h e h e a d i n g f r o m l i n e 2 0 t h s u b h e a d i n gf r o m l i n e 3 a n t h f i r s t p a s s a t h c o u n t e r n u m b e r ( w h e n i t ' s r a i s e df r o m z e r o t o n e ) , t h m u l t i p l i c a t i o n o a n d i v i s i o n o A / f r o ml i n e 6 0 W h e n t h c o m p u t e r f i n i s h e s w i t h t h c o m m a n d s o l i n e 6 a n

Page 55: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 55/148

P R O G R A M C O N T R O L 4

t r a n s l a t e s t h c o m m a n d G O T O 4 o l i n e 7 0 h o w e v e r , i j u m p s b a c ki n t o t h s e q u e n c e a l i n e 4 0 T h e r e a f t e r i a u t o m a t i c a l l y f o l l o w s i n c r e a s i n gl i n e n u m b e r s u n t i l i a g a i n e n c o u n t e r s l i n e 7 0 w h i c h d i r e c t s i o u o s e q u e n c e t l i n e 4 a g a i n . E a c h t i m e t h c o m p u t e r p e r f o r m s l i n e 5 ( 4 - 1 ) , t h " c o u n t e r , " n e v a l u e i a p p l i e d t t h p r i n t i n g , m u l t ip l i c a t i o n a n d i v i s i o n o l i n e 6 0

T h u n t i r i n g c o m p u t e r w i l l p e r f o r m t h c o m m a n d s b e t w e e n p r o g r a ml i n e s 4 a n 7 a g a i n a n a g a i n u n t i l y o s t o p i w i t h R U S T O P o R U S T O P - R E S T O R E c o m m a n d f r o m t h k e y b o a r d ( o r , o c o u r s e ,s w i t c h o f p o w e r ) .

A l t h o u g h y o c a a l s o d i r e c t t h c o m p u t e r t s k i p f o r w a r d t h r o u g h t h p r o g r a m t h i g h e r - n u m b e r e d l i n e , t h e r e ' s n a d v a n t a g e i d o i n g s o s i n c e t h c o m m a n d s o i n t e r v e n i n g s t a t e m e n t s w o u l d b m i s s e d f o r e v e r .W h i l e s e c o n d G O T O c o m m a n d c o u l d s e n d t h c o m p u t e r b a c k t a e a r l i e r l i n e t h a t h a b e e n s k i p p e d , t h a t m e t h o d o p r o g r a m m i n g o f f e r s n c o n t r o l t h a t c o u l d n ' t b a c h i e v e d m o r e s i m p l y b s i n g l e G O T O c o m a n d c o n t r o l l i n g t h t y p e o r e p e a t i n g l o o p s e e n a b o v e .

I t h i s p r o g r a m , y o c a a s s i g n a n v a l u e t i l i n e 1 0 , a n t h e no b s e r v e t h r e s u l t i n g c a l c u l a t e d v a l u e s a t h e y a p p e a r o t h s c r e e n i y o u ' r e l o o k i n g f o p a r t i c u l a r v a l u e . I y o u ' d l i k e t k n o w w h e n , f o i n s t a n c e , t h d i v i s i o n d r o p s b e l o w s o m e v a l u e , v a r i a t i o n o t h G O T Oc o m m a n d c a d i r e c t t h c o m p u t e r t d t h a t l o o k i n g f o y o u . T h i s c o m a n d i f a i r l y r i g i d l y s t r u c t u r e d , b u e a s y t u s o n c e y o u n d e r s t a n d i t f o r m a t . T h r o u g h t h O N - G O T O c o m m a n d , t h c o m p u t e r i d i r e c t e d t c o m p a r e v a r i a b l e s y m b o l s w i t h b u i l t - i n n u m b e r r a n g e , t h e n i s e n t t p r o g r a m l i n e . I w o r k s m u c h l i k e a I F - T H E N - G O T O s t a t e m e n t , e x c e p tt h a t t h e c o n d i t i o n i t h f i r s t h a l f o t h c o m m a n d i p r e s e t t n u m e r i c a lr a n g e s : o g r e a t e r b u l e s s t h a n 2 o g r e a t e r b u l e s s t h a n 3 a n s o n T h d i r e c t i o n s i n t h G O T O h a l f o t h c o m m a n d p o i n t t l i n e n u m b e r sy o a r r a n g e a c c o r d i n g t t h o s e p r e s e t r a n g e s .I y o w a n t e d t h c o m p u t e r t o s i g n a l y o w h e n t h v a l u e o f t h e d i v i s i o nA / N , f o i n s t a n c e , f a l l s b e l o w t w o , t h r e e , a n f o u r y o c o u l d a d c o m a n d t d t h a t a f t e r l i n e 6 0 l i k e t h i s :

6 O A / G O T O 1 0 0 , 2 0 0 , 3 0 0w h i c h d i r e c t s t h c o m p u t e r t e v a l u a t e A / N , c o m p a r e i w i t h t h b u i l t - i nr a n g e s a n t h e n t p r o c e e d w i t h t h a p p r o p r i a t e p r o g r a m l i n e — 1 0 0 , 2 0 0 ,o 3 0 0 — a c c o r d i n g t t h a t v a l u e . I t h i s c a s e , y o c a p u P R I N T s t a t em e n t s s t a r t i n g a p r o g r a m l i n e s 1 0 0 , 2 0 0 , a n 3 0 t a l e r t y o t t h v a u e p r o d u c e d b e a r l i e r l i n e s o t h p r o g r a m a n A / N . I y o h a n i n t e r e s t i v a l u e s l e s s t h a n t w o , f o i n s t a n c e , y o c o u l d g i v e t h e f o l l o w i n g

Page 56: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 56/148

4 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

c o m m a n d s t s i g n a l a n s t o p t h p r o g r a m :1 0 P R I N T T A B ( 2 0 ) " V A L U E B E L O W T W O "1 1 S T O P

w h i c h w i l l p r i n t " V A L U E B E L O W T W O " i t h A / c o l u m n , a n t h e ns t o p t h c o m p u t e r w i t h t h m e s s a g e " B R E A K I 1 1 0 . "

L i k e w i s e , i y o w a n t e d t h c o m p u t e r t c o n t i n u e t h p r o g r a m r u a n m e r e l y s i g n a l y o w h e n t h v a l u e A / s l i p p e d b e l o w f o u r a n t h e na g a i n b e l o w t h r e e , y o c o u l d a d s t a t e m e n t s s t a r t i n g a 3 0 a n 2 0 0 ,r e s p e c t i v e l y :

3 0 P R I N T T A B ( 2 0 ) " ( p r e s s C O N T R O L a n G ) ( p r e s s C O N T R O L a n G V A L U E B E L O W F O U R "

3 1 G O T O 4 a n

2 0 P R I N T T A B ( 2 0 ) " ( p r e s s C O N T R O L a n G ( p r e s s C O N T R O L a n G V A L U E B E L O W T H R E E "

2 1 G O T O 4 D u r i n g t h e x e c u t i o n o f t h i s p r o g r a m , e a c h o t h e s e p a i r s o f s t a t e m e n t ss i g n a l s t h a p p e a r a n c e o t h v a l u e y o u ' r e l o o k i n g f o r , t h e n d i r e c t s t h c o m p u t e r b a c k i n t o t h m u l t i p l i c a t i o n - d i v i s i o n - p r i n t i n g l o o p a l i n e 4 0

Y o c a u s t h O N - G O T O c o m m a n d t s e a r c h o u a n a c o s p c i f i c v a l u e s . B p u t t i n g v a r i a b l e s i n t o a f o r m t h a t f a l l s w i t h i n t h e r a t h e rp a r t i c u l a r v a l u e r a n g e s o f t h f i r s t h a l f o t h i s c o m m a n d , y o c a d i r e c tt h c o m p u t e r i n t o d i v e r s i o n s a n e x i t s f r o m n o r m a l s e q u e n t i a l p r o g r a mr u n s .

Y o c a s p e c i f y a c t i o n o a n n u m b e r o r a n g e s . D i r e c t i o n s t l i n en u m b e r s , e a c h m a t c h e d t p a r t i c u l a r r a n g e , c a b u s e d t s e n d t h c o m p u t e r t w o r k o n m a n y m o r e s t a t e m e n t s . T h O N - G O T O c o m m a n df o l l o w s t h i s p l a n : e a c h l i n e n u m b e r l i s t e d a f t e r t h w o r d G O T O c o r r es p o n d s i n s t e p t p r o g r e s s i v e l y r i s i n g r a n g e s o t h v a l u e o f t h v a r i a b l ea f t e r t h w o r d O N

Y o c o u l d u s s t a t e m e n t l i k e :O A / G O T O 1 0 0 , 2 0 0 , 3 0 0 , 4 0 0 , 5 0 0

a n s o n t c o v e r l a r g e r a n l a r g e r v a l u e s o f A / N .

R E P E A T I N G W I T H I N L I M I T SY o m a w a n t t r e p e a t u s e f u l s e o c o m m a n d s , p e r h a p s n o e n d l e s s l y

Page 57: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 57/148

P R O G R A M C O N T R O L 4

( a d o n e b t h G O T O s t a t e m e n t ) , n o c o n d i t i o n a l l y ( a d o n e b t h I F - T H E N s t a t e m e n t ) , b u t s i m p l y f o s p e c i f i c n u m b e r o t i m e s . T h C o m m o d o r e 6 w i l l r e s p o n d t p a i r o c o m m a n d s t h a t d t h i s . O n c o u n t s o f t h r e p e t i t i o n s , t h o t h e r d i r e c t s t h c o m p u t e r b a c k t t h f i r s tc o m m a n d . T h e s e c o m m a n d s a r F O a n N E X T . Y o c a s l i p t h e m i n o n b e f o r e s t r e t c h o s t a t e m e n t s y o u ' d l i k e r e p e a t e d , t h e o t h e r a f t e r .

H e r e ' s a p r o g r a m t w h i c h y o c a a d t h i s p a i r o c o m m a n d s i v a r i e t y o w a y s t p r o d u c e a v a r i e t y o d i s p l a y s . I d i r e c t s t h c o m p u t e r t d r a w a a r r o w s h a p e .

N E 1 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "2 3 P R I N T T A B ( X ) " ( p r e s s S H I F T a n M ) 4 P R I N T T A B ( X ) " ( p r e s s S H I F T a n Z ) 5 P R I N T T A B ( X ) " ( p r e s s S H I F T a n N )

T h r o u g h t h v a l u e y o t y p e f o a c o l u m n n u m b e r i l i n e 2 0 y o c a l o c a t e t h a r r o w d r a w n b t h d i r e c t i o n s i n l i n e s 3 0 4 a n 5 i a n h o r iz o n t a l p o s i t i o n . N o w , t d r a w t h a r r o w s e v e r a l t i m e s a t d i f f e r e n t p l a c e s ,t h c o m p u t e r n e e d s d i r e c t i o n s t o r e p e a t l i n e s 3 0 4 0 a n 5 f o r d i f f e r e n tv a l u e s o X s o t h a t t h e s a m e p a t t e r n i p l o t t e d f r o m d i f f e r i n g s t a r t i n gp o i n t s .

Y o c a g i v e t h e s e d i r e c t i o n s w i t h t h f i r s t s t a t e m e n t o f t h c o u n t i n gp a i r . I t h i s s t a t e m e n t y o s t a t e s t a r t i n g v a l u e , a e n d i n g v a l u e , a n ( o p t i o n a l l y ) t h s i z e o t h j u m p s t h c o m p u t e r s h o u l d m a k e i g o i n g f r o mo n v a l u e t t h o t h e r . I t h i s g r a p h i c s p r o g r a m , y o c a s p e c i f y c o l u m nn u m b e r r e p r e s e n t e d b X t b e c h a n g e d a e a c h p a s s s t h a t t h a r r o ww i l l b d r a w n a e a c h o s e v e r a l p l a c e s a l o n g a s i n g l e r o w , s p a c e dc o l u m n s a p a r t , w i t h t h s t a t e m e n t :

2 F O T 3 S T E PT h o t h e r m e m b e r o t h i s c o m m a n d p a i r w i l l a u t o m a t i c a l l y d i r e c t t h c o m p u t e r b a c k t t h p r o g r a m l i n e o w h i c h t h F O R - T O - S T E P c o m a n d i f o u n d :

5 N E X T XT d i r e c t t h c o m p u t e r t p u e a c h s u b s e q u e n t a r r o w o t h s a m e h o r i

z o n t a l l i n e a t h o n p r e v i o u s l y d r a w n , y o c a a d s t a t e m e n t t h a ts e n d s t h c u r s o r b a c k u t t h l i n e o w h i c h i b e g a n . S u c h s t a t e m e n tw o u l d t a k e t h e f o r m :

Page 58: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 58/148

4 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

2 P R I N T " ( p r e s s S H I F T a n C U R S O R U P / D O W N ) ( p r e s s S H I F T a n C U R S O R U P / D O W N ) ( p r e s s S H I F T a n C U R S O R U P / D O W N )( p r e s s S H I F T a n C U R S O R U P / D O W N ) "

W h e n y o r u t h i s p r o g r a m , a l c o m m a n d s l o c a t e d b e t w e e n t h F O R -T O - S T E P a n N E X T s t a t e m e n t s a t l i n e s 2 a n 5 w i l l b r e p e a t e d u n t i lt h l i m i t s e a f t e r t h w o r d T i r e a c h e d , a i F i g u r e 5 . 3 .

I t h i s c a s e , l i n e s 3 0 4 0 a n 5 ( t h e d r a w i n g c o m m a n d s ) , a n d l i n e 2 ( t h e r o w - p o s i t i o n i n g c o m m a n d ) , a r e r e p e a t e d . T h c o m p u t e r w i l l b e g i nd r a w i n g a e a c h o f f o u r l o c a t i o n s a l o n g s i n g l e r o a t h t o o t h s c r e e n . T h f i r s t a r r o w s t a r t s f r o m t h p o s i t i o n s e b T A o 1 a n t h l a s t a T A o 2 5 T h v a l u e o f a s s i g n e d i t h F O R - T O - S T E Ps t a t e m e n t r e p l a c e s t h i n i t i a l o n e f r o m l i n e 2 0 a n e a c h s u c c e s s i v e v a l u eo r e p l a c e s t h o n b e f o r e i t

U s i n g t h F O R - T O - S T E P , N E X T c o m m a n d p a i r , n o y o h a v ep r o g r a m t h a t d r a w s r o o a r r o w s . W i t h s m o t h e r p a i r o F O R - T O -S T E P , N E X T c o m m a n d s r a n g i n g o v e r v a l u e s o f Y y o c a e x p a n d t h p r o g r a m t d r a w s i m i l a r g r o u p o a r r o w s a m o r e r o w s , a n t f i l l t h s c r e e n w i t h t h e m . T r e p e a t t h f i r s t r o o f a r r o w s , t h s e c o n d p a i r o c o m m a n d s s h o u l d b r a c k e t t h s t a t e m e n t s t h a t d r a w t h r o w , i n c l u d i n g t h F O R - T O - S T E P a n N E X T p a i r f o t h v a l u e s o f X T h u s , t h a r r o w s a

F i g u r e 5 . 3 : r o o r e p e a t e d a r r o w s d r a w n b p r o g r a m .

Page 59: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 59/148

P R O G R A M C O N T R O L 4

e a c h l o c a t i o n c a b d r a w n f o d i f f e r e n t l o c a t i o n s ( r o w s ) . T d i r e c tt h c o m p u t e r d o w n t d r a w a n o t h e r r o w y o u c a u s c o m m a n d t h a tm o v e s t h c u r s o r l i k e t h i s :

2 P R I N T " ( p r e s s C U R S O R U P / D O W N ) ( p r e s s C U R S O R U P / D O W N )( p r e s s C U R S O R U P D O W N ) ( p r e s s C U R S O R U P / D O W N ) "

A n t o d i r e c t t h c o m p u t e r t r e p e a t t h d r a w i n g a f o u r d e s c e n d i n g r o w s ,y o c a a d a n o t h e r p a i r o f r e p e a t i n g c o m m a n d s , l i k e t h i s :

2 F O R Y 1 T O 46 N E X T Y

W h e n i e n c o u n t e r s F O R - T O c o m m a n d w i t h o u t t h S T E P p a r t , t h c o m p u t e r a s s u m e s a " d e f a u l t " S T E P v a l u e o f 1 T h p r o g r a m n o i m e m o r y d i r e c t s t h c o m p u t e r t r e p e a t t h e c o m m a n d s t h a t p r o d u c e d t h f i r s t r o o a r r o w s , t m e a s u r e d o w n f o u r l i n e s f r o m t h f i r s t r o a n d r a w r o o f a r r o w s , t h e n m o v e d o w n a n o t h e r f o u r l i n e s a n d d r a wa n o t h e r r o o a r r o w s , a n s o u n t i l f o u r t h r o h a b e e n r e a c h e d .T h e n t h c o m p u t e r s t o p s d r a w i n g , a n f o u r r o w s o f o u r a r r o w s e a c h f i l lt h s c r e e n , a s s h o w n i F i g u r e 5 . 4 .

F i g u r e 5 . 4 : F i l l i n g t h s c r e e n w i t h a r r o w s b a l t e r i n g t h e p r o g r a m o F i g u r e 5 . 3 .

Page 60: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 60/148

4 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

S i n c e t h e f f e c t o l i n e 2 ( w h i c h a s s i g n e d v a l u e t X h a b e e n c a c e l l e d b l i n e 2 5 y o c a n d r o p t h a t s t a t e m e n t a e x c e s s b a g g a g e :

2

( I y o L I S T t h p r o g r a m n o w , y o u ' l l s e t h n e s t e d p a i r s o F O R - T O -S T E P a n N E X T c o m m a n d s a t h e y a p p e a r i F i g u r e 5 . 5 . ) T h f i r s tN E X T s t a t e m e n t , a l i n e 5 5 d i r e c t s t h c o m p u t e r t t a k e a c t i o n o l i n e2 5 w h e r e t h v a l u e o f i c h a n g e d .

T h c o m p u t e r c a a c t u a l l y d i s t i n g u i s h o n N E X T s t a t e m e n t ' s d i r e ct i o n s f r o m a n o t h e r ' s e v e n i y o d o n ' t l a b e l e a c h N E X T s t a t e m e n t w i t ht h e v a r i a b l e f r o m i t F O R - T O - S T E P l i n e ; l i n e s 5 a n 6 c o u l d a l s o h a v eb e e n w r i t t e n a s

5 N E X T6 N E X T

H o w e v e r , y o c a k e e p t r a c k o t h F O R - T O - S T E P , N E X T g r o u p i n g sm o r e e a s i l y i y o u d o l a b e l t h e m .

Y o c a e n v i s i o n t h F O R - T O - S T E P , N E X T l o o p a " n e s t e d "i n s i d e t h F O R - T O - S T E P , N E X T l o o p . W h e n o n l o o p i n e s t e dw i t h i n a n o t h e r i a p r o g r a m , t h c o m m a n d s i t h i n n e r l o o p a r c a r r i e do u f i r s t , a m a n y t i m e s a d e t a i l e d i t h F O R - T O - S T E P c o m m a n d , a t h f i r s t v a l u e o f t h o u t e r l o o p , t h e n t h r o u g h t h s e c o n d v a l u e o f t h o u t e rl o o p , a n s o n

H e r e ' s s u m m a r y o h o t h c o m p u t e r i d i r e c t e d b t h i s p r o g r a m :I l i n e 1 0 , t h e s c r e e n i c l e a r e d a n t h c u r s o r i p o s i t i o n e d a t h u p p e r

l e f t c o r n e r . I l i n e 2 2 , t h e c o m p u t e r p r e p a r e s t o s u b s t i t u t e v a l u e o f f o e a c h i e n c o u n t e r s . I l i n e 2 4 t h c u r s o r i s e n t d o w n f o u r l i n e s i p r e pa r a t i o n f o d r a w i n g . I n l i n e 2 t h c o m p u t e r p r e p a r e s t o s u b s t i t u t e t h v a l u e f o e a c h X I l i n e 2 t h c u r s o r i m o v e d u f o u r v e r t i c a l r o w s .T h e f f e c t s o t h v e r t i c a l m o v e m e n t i p r o g r a m l i n e s 2 a n 2 c o m ep a r t i c u l a r l y i n t o p l a y i p o s i t i o n i n g a r r o w s d r a w n o n a f t e r s m o t h e r . I l i n e s 3 0 4 0 a n 5 0 t h s u b s t i t u t i o n s a r m a d e , a n t h r e s u l t i n g p r i n tc h a r a c t e r s a r e d r a w n f r o m t h T A B ( l ) l o c a t i o n . T h a t p r o d u c e s t h f i r s ta r r o w o t h s c r e e n .

F r o m l i n e 5 5 t h c o m p u t e r i s e n t b a c k t t h F O R - T O - S T E P s t a t em e n t o l i n e 2 5 w h e r e t h v a l u e i a d d e d t t h l a s t X a n t h n e v a l u eo i s u b s t i t u t e d i l i n e s 3 0 , 4 0 , a n 5 0 T h c o m p u t e r d r a w s t h s e c o n da r r o w f r o m c o l u m n n u m b e r o t h f i r s t r o w .

W h e n i n e x t e n c o u n t e r s l i n e 5 5 t h c o m p u t e r i s e n t a g a i n t t h F O R - T O - S T E P s t a t e m e n t i l i n e 2 5 a n t h e p r o c e s s r e p e a t s w i t h v a l u e

Page 61: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 61/148

P R O G R A M C O N T R O L 4

1 P R I N T ' L T2 2 F O R V = l T 2 P R l N T l K J t t U i 1 12 5 F O R X = i T O 3 2 p r i n t ' o t t ^ '3 p r i n t t a b c x ) 1 1* p r i n t t a b ( x ) 1 15 p r i n t t a 8 ( x ) "5 N E X T6 N E X TR E A D V .

3 S T E P

F i g u r e 5 . 5 : T h e p r o g r a m t h a t J i l l s t h e s c r e e n w i t h a r r o w s .

o e q u a l t 1 s u b s t i t u t e d i n t h T A c o m m a n d s .T h i s g o e s o u n t i l t h v a l u e o f 3 f o i p a s s e d . T h a t h a p p e n s a f t e r

t h f o u r t h a r r o w i d r a w n , w h e n t h N E X T s t a t e m e n t o l i n e 5 p a s s e st h c o m p u t e r o t t h e f o l l o w i n g l i n e , n u m b e r 6 0 L i n e 6 s e n d s t h c o p u t e r t t h F O R - T O - S T E P s t a t e m e n t a t l i n e 2 2 w h e r e i a d d e d t t h v a l u e o f Y W i t h Y 2 t h c o m p u t e r t h e n m o v e s t l i n e 2 4 w h i c h s e n d st h c u r s o r d o w n f o u r r o w s .

T h e n , e n c o u n t e r i n g t h F O R - T O - S T E P s t a t e m e n t o l i n e 2 5 t h c o m p u t e r r e s e t s t h v a l u e o t 1 a n p r o c e e d s t l i n e 2 7 T h i s s t a t em e n t k e e p s e a c h s e o f o u r a r r o w s o v a r y i n g T A B ( X ) v a l u e s o t h s a m er o w . W i t h o u t i t t h c o m p u t e r w o u l d a u t o m a t i c a l l y a d v a n c e t t h n e x tp r i n t l i n e a f t e r d r a w i n g e a c h a r r o w a e a c h T A B ( X ) p o s i t i o n , a n e a c ha r r o w w o u l d a p p e a r s e p a r a t e l y o d i f f e r e n t r o w .

R u n n i n g t h r o u g h t h c o m m a n d s o l i n e s 2 t h r o u g h 5 a i d i b e f o r e ,t h c o m p u t e r d r a w s a s e c o n d r o o a r r o w s , i d e n t i c a l t t h f i r s t , b u b e l o w i t A f t e r t h l a s t a r r o w o t h i s s e c o n d r o h a b e e n d r a w n a n de x c e e d s 3 0 t h c o m p u t e r i s e n t o t t h N E X T s t a t e m e n t , d r o p p i n gt h r o u g h l i n e 5 t l i n e 6 0 w h i c h s e n d s i t l i n e 2 2

T h F O R - T O - S T E P , N E X T s t a t e m e n t s o f l i n e 2 a n 6 t h e n k e e pt h c o m p u t e r b u s y o t h t h i r d , a n f i n a l l y t h f o u r t h , r o w s o a r r o w su n t i l t h a n v a l u e s ( 3 a n 4 h a v e b o t h b e e n p a s s e d . T h u s , y o a r

Page 62: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 62/148

4 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

l e f t w i t h s c r e e n f u l l o f o u r r o w s o f o u r a r r o w s e a c h .A y o m i g h t s u s p e c t , i t w n e s t e d l o o p s o F O R - T O - S T E P , N E X T

s t a t e m e n t s c a b h e a p e d t o g e t h e r i n t o t h c o m p u t e r , t h e n t h r e e o m o r ea r a l s o p o s s i b l e . W i t h t h C o m m o d o r e 6 4 ' s p r i n t g r a p h i c s , y o c a u s t h i s f e a t u r e t c r e a t e m o v i n g i m a g e s o c h a n g i n g c o l o r s .

I a n p r o g r a m , a l o o p c o n t r o l s a l t h s t a t e m e n t s c o n t a i n e d w i t h i n t h a tl o o p , i n c l u d i n g a n n u m b e r o o t h e r l o o p s . I c o m m a n d s a r a d d e d t h a tp r i n t b l a n k s p a c e s o v e r a a r r o w j u s t b e f o r e a n o t h e r a r r o w i d r a w n o t h s c r e e n , t h f i r s t a r r o w w i l l a p p e a r t b e r a s e d , a n t h s e c o n d a r r o w w i l la p p e a r b i t s e l f u n t i l i t t o o , i d r a w n o v e r , d i s a p p e a r i n g f r o m t h s c r e e n t b r e p l a c e d b t h n e x t . T h r e s u l t i a e l e m e n t a r y f o r m o f a n i m a t i o n .

T d i r e c t t h c o m p u t e r t d r a w o v e r e a c h a r r o w i n t u r n , y o c a a d s e o t h r e e s t a t e m e n t s , w i t h i n t h F O R - T O - S T E P l o o p , t h a t p r i n ts p a c e s o v e r e a c h a r r o w , l i k e t h i s :

5 P R I N T T A B ( X ) " ( p r e s s S P A C E B A t i m e s ) "5 P R I N T T A B ( X ) " ( p r e s s S P A C E B A t i m e s ) "5 P R I N T T A B ( X ) " ( p r e s s S P A C E B A t i m e s ) "

T p o s i t i o n t h b l a n k p r i n t i n g b a c k o t h s a m e r o w o n w h i c h t h a r r o ww a d r a w n , y o c a a d c u r s o r - p o s i t i o n i n g s t a t e m e n t b e f o r e i t l i k e t h i s :

5 P R I N T " ( p r e s s S H I F T a n C U R S O R U P / D O W N t i m e s ) "W h e n y o r u t h p r o g r a m n o w , t h r e s u l t s w i l l b a b e f o r e , e x c e p t t h a ti m m e d i a t e l y a f t e r e a c h a r r o w a p p e a r s i w i l l d i s a p p e a r a n t h n e x t a r r o ww i l l b e d r a w n . T h r e s u l t w i l l b a a r r o w r a c i n g f r o m l e f t t o r i g h t a c r o s so n r o a f t e r a n o t h e r .

A n o t h e r c l e v e r u s o t h F O R / N E X T l o o p i w o r t h n o t i n g , a i a d d s ad e l a y , w h i c h c a b u s e f u l i n a n p r o g r a m i w h i c h y o u w o u l d l i k e t a l l o w t i m e f o s o m e o n e t v i e w t h p r o g r a m ' s e f f e c t s . Y o m i g h t h a v ea l r e a d y n o t i c e d t h a t t h c o m p u t e r , i n c o m p r e h e n s i b l y f a s t t h o u g h i i s d o e s t a k e p e r c e p t i b l e t i m e t d t h i n g s . T h m o r e c o m p l e x o c o m p l ic a t e d t h t a s k , t h l o n g e r i t a k e s . K n o w i n g t h i s , y o c a u s e s u c h d e l a yt y o u r a d v a n t a g e , b c o n t r o l l i n g i t Y o c a a d l o o p c o n t a i n i n g n r e a l a c t i v e c o m m a n d . A n t h o u g h t h e r e m a b n c o m m a n d t r e p e a t i s u c h l o o p , t h c o m p u t e r w i l l g d u t i f u l l y t h r o u g h i t t a k i n g t i m e t t r a n sl a t e a n p r o c e s s t h e F O R - T O - S T E P a n N E X T c o m m a n d s .

T s l o w t h a n i m a t i o n p r o g r a m , t h e n , y o c a a d a e m p t y l o o p( k n o w n a " t i m i n g l o o p " ) a f t e r t h b l a n k - s p a c e - p o s i t i o n i n g l i n e , l i k et h i s :

5 P R I N T " ( p r e s s S H I F T a n C U R S O R U P / D O W N ) ( p r e s s S H I F T a n

Page 63: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 63/148

P R O G R A M C O N T R O L 4

C U R S O R U P / D O W N ) ( p r e s s S H I F T a n C U R S O R U P / D O W N )( p r e s s S H I F T a n C U R S O R U P / D O W N ) " : F O T 2 0 0 :N E X T T

O n c e a g a i n , t h e S T E P p a r t o t h c o m m a n d i o p t i o n a l — i f y o l e a v e i o f f , a i d o n e h e r e , t h e c o m p u t e r a u t o m a t i c a l l y t a k e s s t e p s o 1

I t h i s p r o g r a m , t h c o m p u t e r p a u s e s b r i e f l y b e f o r e e a c h e r a s u r e a i r u n s s e n s e l e s s l y t h r o u g h i t e m p t y l o o p . T h i s t y p e o F O R - T O , N E X Ts t a t e m e n t c a b i n s e r t e d a n y w h e r e i p r o g r a m t s l o w o r f r e e z ea d v a n c i n g a c t i o n .

B j u d i c i o u s l y r e m o v i n g s t a t e m e n t s , y o c a s o m e t i m e s c r e a t e e f f e c t sq u i t e d i f f e r e n t f r o m t h o r i g i n a l p r o g r a m . F o i n s t a n c e , b r e m o v i n g t h

F O R - T O , N E X T l o o p a n t h a c c o m p a n y i n g p o s i t i o n i n g c o m m a n df r o m t h i s p r o g r a m , y o c a c r e a t e d i s p l a y t h a t s h o w s a a r r o w d e s c e n di n d i a g o n a l l y a c r o s s t h s c r e e n . R e m o v i n g l i n e s 2 2 2 7 , a n d 6 0 l i k e t h i s :

2 2 6

w i l l p r o d u c e s u c h a p r o g r a m .

Page 64: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 64/148

B i t n a t u r e , t h e c o m p u t e r u n d e r s t a n d s h o t h a n d l e n u m b e r s — t h e yd i r e c t a l l i t s o p e r a t i o n s , a n o r d e r c o m m a n d s . B u e v e n t h o u g h i i b l i n dt t h e i r m e a n i n g s , t h C o m m o d o r e 6 4 — w i t h b i o p r o g r a m m i n gh e l p — c a n h a n d l e w o r d s a n i n f o r m a t i o n i a n t y p e d f o r m , t r e a t i n g a n e v e n g e n e r a t i n g t h e m a y o u r d i r e c t i o n . Y o u r c o m p u t e r c a a c c e p t i n f o rm a t i o n i n s e v e r a l w a y s , a n e v e n s t o p i n t h m i d d l e o p r o g r a m r u t g e i t W o r d s , n u m b e r s a n g r a p h i c s s y m b o l s c a n a l b o b j e c t s o m a n i p ul a t i o n s y o d i r e c t .

S T R I N G S : W O R D S F R O M T H C O M P U T E RI m u c h t h s a m e w a a i h a n d l e s n u m b e r s , t h C o m m o d o r e 6 c a

h a n d l e w o r d s a n k e y b o a r d c h a r a c t e r s . I c a p r i n t t h e m , a n i c a t a k et h e m a p a r t a n p i e c e t h e m t o g e t h e r . O c o u r s e , a h u m a n b e i n g s , w h a v ea e d g e o v e r t h c o m p u t e r , s i n c e w e a c h u n d e r s t a n d a b o u t 4 0 , 0 0 0 m o r ew o r d s t h a n t h C o m m o d o r e 6 4 ' s m e a g e r v o c a b u l a r y o l e s s t h a n h u n d r e dc o m m a n d s . B u t , l i k e b l i n d n e w s t a n d v e n d o r w h c a h a n d l e m a g a z i n e sh c a n ' t r e a d , t h e C o m m o d o r e 6 c a h a n d l e t h o u s a n d s o w o r d s i w i l ln e v e r u n d e r s t a n d .

A l t h o u g h t h c o m p u t e r c a t r e a t k e y b o a r d c h a r a c t e r s — w o r d s , n u b e r s , a n o t h e r s y m b o l s — i n v a r i o u s c o m p l e x w a y s , i g r o u p s t h e s e s y b o l s i n t o o n l y t w c a t e g o r i e s . W h e n t h c o m p u t e r e n c o u n t e r s s e o w o r d s a n s y m b o l s e n c l o s e d i q u o t a t i o n m a r k s , i t r e a t s t h a t g r o u p o c h a r a c t e r s l i k e b u s l o a d o p a s s e n g e r s , t b c a r r i e d a b o u t a y o u , t h t o u r l e a d e r , d i r e c t . B u c h a r a c t e r s t y p e d w i t h o u t s u r r o u n d i n g q u o t e s a r

Page 65: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 65/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 5

i n t e r p r e t e d a c o m m a n d s , f r o m w h i c h t h c o m p u t e r t a k e s d i r e c t i o n s , j u s ta c a d r i v e r p i c k s u p a s s e n g e r s f r o m s t r e e t c o r n e r a n t a k e s d i r e ct i o n s f r o m t h e m .

g r o u p o c h a r a c t e r s e n c l o s e d i q u o t e s i k n o w n a s i r i n g . V a r i a b l es y m b o l s c a n b u s e d t s t a n d i f o s t r i n g s , j u s t a s t h e y d f o n u m b e r s .T h C o m m o d o r e 6 r e c o g n i z e s t h e q u a l s i g n a s c o m m a n d a s s i g n i n gv a r i a b l e t w o r d s a w e l l a s t n u m b e r s . I r e c o g n i z e s t h e s e s t r i n g s b " t a g g e d " v a r i a b l e s y m b o l . v a r i a b l e i n t e n d e d f o s t r i n g i m a r k e d w i t h

d o l l a r s i g n ( $ ) , s i g n i f y i n g s t r i n g o c h a r a c t e r s , r a t h e r t h a n n u m e r i cv a r i a b l e . S i n c e t h c o m p u t e r t r e a t s s p a c e s a s c h a r a c t e r s , g r o u p o w o r d ss e p a r a t e d b s p a c e s w i l l b t r e a t e d a s o n l o n g w o r d - s t r i n g b t h C o m o d o r e 6 4

Y o c a c o m m a n d t h c o m p u t e r t s u b s t i t u t e s e n t e n c e ( o a n g r o u po c h a r a c t e r s ) w h e r e v e r i e n c o u n t e r s s t r i n g v a r i a b l e i p r o g r a ms t a t e m e n t :

N E 1 A $ " W O R D S W I T H O U T T H O U G H T S N E V E R T O

H E A V E N G O . "

Y o c a t h e n u s e t h s t r i n g v a r i a b l e , A $ i p l a c e o t h s t r i n g i t s e l f w h e ny o g i v e s u b s e q u e n t c o m m a n d s :

2 P R I N T A

E n c o u n t e r i n g l i n e 2 w h e n t h i s b r i e f p r o g r a m i r u n , t h e c o m p u t e r p r i n t sS h a k e s p e a r e ' s w o r d s o t h s c r e e n , j u s t a i w o u l d p r i n t n u m b e ra s s i g n e d t n u m e r i c v a r i a b l e .

C o m b i n i n g S t r i n g s : T h P l u s S i g nA l t h o u g h s t r i n g s p o s s e s s n o n e o t h n u m e r i c c h a r a c t e r i s t i c s t h a t t h

c o m p u t e r w a b u i l t t w o r k w i t h , t h e y c a n e v e r t h e l e s s b o b j e c t s o c a l c ul a t i o n a n m a n i p u l a t i o n . U s i n g s t r i n g v a r i a b l e s , y o c a o r d e r t h c o p u t e r t c o m b i n e s t r i n g s , c u t h e m o d e r i v e n u m e r i c v a l u e s f r o m t h e m .

T h c o m p u t e r t r e a t s s t r i n g v a r i a b l e s i n c o m b i n a t i o n m u c h a i t r e a t sn u m b e r s i n a d d i t i o n . I t h i s c a s e , t h f i n a l r e s u l t w i l l b l o n g e r s t r i n gr a t h e r t h a n l a r g e r n u m b e r . T a d s t r i n g s t e a c h o t h e r , y o u s t h p l u ss i g n ( + a c o m m a n d t t h c o m p u t e r t p r o d u c e n e s t r i n g , c o m b in a t i o n o f t h s t r i n g s o e i t h e r s i d e o t h p l u s s i g n .

Page 66: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 66/148

5 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

A d d i n g t w m o r e s t r i n g s t t h i s p r o g r a m , y o c a p r e p a r e t h c o p u t e r t c o m b i n e t h e m , b a s s i g n i n g t h e m t o s t r i n g v a r i a b l e s :

1 B " W I L L I A M S H A K E S P E A R E "1 C " H A M L E T , A C I I I , S C E N E 3

T s e t h e s e s t r i n g s p r i n t e d i c o m b i n a t i o n , y o c a r e t y p e l i n e 2 a s

2 P R I N T A B C W h e n t h p r o g r a m i r u n , t h c o m p u t e r w i l l r e s p o n d w i t h t h d i s p l a ys h o w n i F i g u r e 6 . 1 .

C o u n t i n g C h a r a c t e r s I S t r i n g s : L E Y o c a e x t r a c t n u m e r i c v a l u e f r o m s t r i n g w i t h c o m m a n d t h a t

c o u n t s t h n u m b e r o c h a r a c t e r s , i n c l u d i n g s p a c e s , w i t h i n i t S u c hc o m m a n d c a n b e u s e f u l i n a n y p r o g r a m t h a t m a n i p u l a t e s s t r i n g s . T h c o m m a n d t h a t d i r e c t s t h c o m p u t e r t c o u n t c h a r a c t e r s t a k e s t h f o r mL E N ( ) I p r o g r a m , y o c a a s s i g n s t r i n g l e n g t h v a l u e t n u m e r i cv a r i a b l e w i t h a i n s t r u c t i o n l i k e t h i s n e v e r s i o n o l i n e 2 0

2 L E N ( A $ )

F i g u r e 6 . 1 : T h e f f e c t o p r o g r a m t h a t a d d s w o r d - s t r i n g s .

Page 67: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 67/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 5

T h i s l i n e c a n b e p a r a p h r a s e d a " S e t t h v a l u e o f t h n u m e r i c v a r i a b l ee q u a l t t h n u m b e r o c h a r a c t e r s i t h s t r i n g A $ . " I d i r e c t s t h c o p u t e r t o s u b s t i t u t e t h n u m b e r o c h a r a c t e r s i n s t r i n g A w h e r e v e r i e n c o u n t e r s t h s y m b o l i p r o g r a m r u n . Y o c a t h e n u s t h i s v a l u e i a n o t h e r s t a t e m e n t , l i k e t h i s :

3 P R I N T " Q U O T E " C H A R A C T E R S L O N G B B a n a l s o a d s t a t e m e n t t d i s p l a y t h q u o t a t i o n i t s e l f a f t e r s p a c i n gc o u p l e o r o w s :

4 P R I N T : P R I N T : P R I N T A

T a k i n g S t r i n g s A p a r t : L E F T $ , R I G H T $ , a n M I D $T h r e e c o m m a n d s t e l l t h c o m p u t e r t p i c k c h a r a c t e r s f r o m w i t h i n

s t r i n g s . U s i n g t h e m , y o c a t a k e a p a r t w o r d s o g r o u p s o c h a r a c t e r s ,a n r e b u i l d t h e m a c c o r d i n g t y o u r o w p r e f e r r e d p a t t e r n s . T h t h r e es t r i n g - s l i c i n g c o m m a n d s a r s i m i l a r i f o r m a n e a c h c u t s o u a s e g m e n tf r o m t h s t r i n g .

O n o t h e s e c o m m a n d s , L E F T $ , i n s t r u c t s t h c o m p u t e r t s l i c e o f g i v e n n u m b e r o c h a r a c t e r s f r o m t h l e f t o s t r i n g . C h a r a c t e r s a r c o u n t e d f r o m t h l e f t q u o t a t i o n m a r k . I y o w a n t e d n e s t r i n g , c a l l e dD $ f o r m e d f r o m t h f i r s t f i v e c h a r a c t e r s o t h q u o t e h e r e , y o w o u l dn a m e a n d i r e c t i t f o r m a t i o n w i t h t h c o m m a n d :

4 D L E F T $ ( A $ > 5 )Y o c o u l d t h e n d i s p l a y t h e n e s t r i n g w i t h t h c o m m a n d :

5 P R I N T D W h e n t h p r o g r a m i r u i p r o d u c e s t h e d i s p l a y s h o w n i F i g u r e 6 . 2 .

Y o c a c r e a t e n e s t r i n g s o i n c r e a s i n g l e n g t h ( u t t h f u l l l e n g t h o fA $ o u o t h o r i g i n a l s t r i n g , b i n c l u d i n g t h L E F T S c o m m a n d i F O l o o p w i t h c o u n t e r v a r i a b l e :

3 F O R I 1 T O A4 D L E F T $ ( A $ , I )6 N E X T

T h p r o g r a m n o " b r a c k e t s " t h s t r i n g - c u t t i n g s t a t e m e n t o l i n e 4 a n t h P R I N T c o m m a n d a t l i n e 5 i F O R - T O - N E X T l o o p t h a t c o u n t sf r o m t t h f u l l l e n g t h o t h o r i g i n a l q u o t a t i o n . W h e n t h p r o g r a m i r u n , t h c o m p u t e r w i l l p r i n t o n r o a f t e r a n o t h e r ; e a c h o n b e g i n s w i t h

Page 68: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 68/148

5 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

F i g u r e 6 . 2 : T h e f f e c t o t h s t r i n g - s l i c i n g c o m m a n d L E F T $ .

t h f i r s t c h a r a c t e r o t h s t r i n g a n i o n c h a r a c t e r l o n g e r t h a n i t p r e d ec e s s o r . W h e n t h l a s t c y c l e i r e a c h e d ( w h e n A ) D w i l l b a s s i g n e dt h v a l u e o f L E F T $ ( A $ , A ) , w h i c h i t h f u l l l e n g t h o A $ D w i l l b t h s a m e a A $ a n t h l a s t l i n e p r i n t e d w i l l b t h e n t i r e q u o t e , a s h o w n i F i g u r e 6 . 3 .

B a d d i n g a n o t h e r s t a t e m e n t , y o c a c i t e t h s o u r c e o t h e q u o t a t i o n :

7 P R I N T C

Y o c a m a k e t h i s p r o g r a m i n t o t e s t o r e c o g n i t i o n b s l o w i n g p r i n t i n gw i t h a e m p t y F O R - T O - N E X T l o o p , l i k e t h i s :

3 F O = T 5 0 0 : N E X T

N o w , w i t h a n q u o t a t i o n a s s i g n e d t A $ y o c a r u t h p r o g r a m , s t o pp i n g i f r o m t h k e y b o a r d w i t h R U S T O P k e y s t r o k e c o m m a n d a n a d v a n c i n g i w i t h t h C O N T c o m m a n d .

T h s e c o n d s t r i n g - s l i c i n g c o m m a n d , R I G H T $ , d i r e c t s t h c o m p u t e r t c o u n t o f a n s l i c e s e c t i o n s o s t r i n g s f r o m t h r i g h t . O u c u r r e n t p r o g r a mw i l l p r i n t s e c t i o n s o A c o u n t e d f r o m t h l a s t l e t t e r o t h s t r i n g , i t h

Page 69: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 69/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 5

W O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D SW O R D S0

M 1 H U U 1U I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U TW I T H O U T

H U U t i n l T H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T ST H O U G H T S

N N E N E U EN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E RN E U E R

T T T T T T T

T T T

H H E H E A UH E A U EH E A U E NH E A U E NH E A U E NH E A U E NH E A U E N

I R E A O Y

F i g u r e 6 . 3 : T h e f f e c t o p r o g r a m t h a t g e n e r a t e s i n c r e a s i n g l y l o n g e r s t r i n g sf r o m t h L E F T S c o m m a n d .

f o l l o w i n g r i g h t - s l i c i n g c o m m a n d t a k e s t h e p l a c e o t h l e f t - s l i c i n g o n i l i n e 4 0

4 D R I G H T $ ( A $ , I )

D r i v e n b t h s a m e F O l o o p , t h c o m p u t e r w i l l n o p r i n t e a c h l i n e o n c h a r a c t e r l o n g e r t h a n i t p r e d e c e s s o r , b u i w i l l s t a r t f r o m t h r i g h t q u o t em a r k , a s h o w n i F i g u r e 6 . 4 .T h t h i r d s t r i n g - s l i c i n g c o m m a n d , M I D $ , d i r e c t s t h c o m p u t e r t s n i p

s e c t i o n f r o m t h e c e n t e r o s t r i n g . T u s t h i s c o m m a n d , y o i n c l u d e t h n a m e o t h s t r i n g f r o m w h i c h s e c t i o n i t b e x c i s e d , t h l e f t m o s t c h a ra c t e r ' s p o s i t i o n ( a c o u n t e d f r o m t h l e f t s i d e o t h s t r i n g ) , a n t h n u b e o c h a r a c t e r s ( t b c o u n t e d a n c u t t h r i g h t ) . T h c o m m a n d t a k e st h f o r m M I D $ ( A $ , s , n ) , w h e r e i t h s t a r t i n g p o i n t , a n i t h n u m b e ro c h a r a c t e r s i t h s e c t i o n . I f f o i n s t a n c e , y o w e r e t c u t t h e e i g h t - l e t t e rw o r d T H O U G H T S , w h i c h b e g i n s s i x t e e n s p a c e s f r o m t h l e f t q u o t e ,f r o m t h q u o t a t i o n o l i n e 1 0 , t h e x c i s i n g c o m m a n d w o u l d b M I D $ ( A $ , 1 6 , 8 ) . I y o i n s e r t t h i s c o m m a n d i p l a c e o t h o t h e r s t r i n g -c u t t e r s , a g a i n a t l i n e 4 0 t h c o m p u t e r w i l l p r o d u c e a n o t h e r l i s t o s t r i n g s ,

Page 70: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 70/148

5 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

I U G H T S N E V E R T H E A U E H G O H O U G H T S H E U E R T H E A U E H G O T H O U G H T S H E U E R T H E r t U E H G O T H O U G H T S H E U E R T H E A U E H G O T H O U G H T S H E U E R T H E A U E H G O U T H O U G H T S H E U E R T H E A U E H G O O U T H O U G H T S H E U E R T H E A U E H G O H O U T T H O U G H T S H E U E R T H E A U E H G O T H O U T T H O U G H T S H E U E R T H E A U E H G O I T H O U T T H O U G H T S H E U E R T H E A U E H G O W I T H O U T T H O U G H T S H E U E R T H E A U E H G O W I T H O U T T H O U G H T S H E U E R T H E A U E H G O W I T H O U T T H O U G H T S N E U E R T H E A U E H G O O W I T H O U T T H O U G H T S N E U E R T H E A U E H G O R D W I T H O U T T H O U G H T S H E U E R T H E A U E H G O O R D S W I T H O U T T H O U G H T S H E U E R T H E A U E H G W O R O S W I T H O U T T H O U G H T S H E U E R T H E A U E H^ H A M L E T , A C I I I , S C E H E

F i g u r e 6 . 4 : T h e f f e c t o p r o g r a m t h a t g e n e r a t e s i n c r e a s i n g l y l o n g e r s t r i n g sf r o m t h R I G H T S c o m m a n d .

t h i s t i m e g r o w i n g o u t w a r d f r o m t h m i d d l e o t h o r i g i n a l s t r i n g , A $ i b o t h d i r e c t i o n s .

T u s t h M I D $ c o m m a n d t p r o d u c e s t r i n g s g r o w i n g s y m m e t r i c a l l yf r o m t h m i d d l e o t h o r i g i n a l s t r i n g , h o w e v e r , r e q u i r e s t w i s t o a r i t h m e t i c . Y o c a c o n t r o l t h e l e n g t h o f t h s t r i n g w i t h t h e v a r i a b l e I w h i c h i g i v e n v a l u e b t h F O R - T O - N E X T s t a t e m e n t , a i w a i t h L E F T $ a n R I G H T S c o m m a n d s . T h c o m p u t e r f i n d s t h m i d d l e o t h s t r i n g A b d i v i d i n g i t t o t a l l e n g t h ( a f o u n d i l i n e 2 0 L E N ( A $ ) )i h a l f : b A / 2 . T h c o m p u t e r f i n d s h a l f t h n u m b e r o c h a r a c t e r s , I t b p r i n t e d a e a c h p a s s , b 1 / 2 . H a l f o t h e c h a r a c t e r s w i l l b p r i n t e d f r o m t h r i g h t s i d e , a n h a l f f r o m t h l e f t o t h c e n t e r . S i n c e t h l e f t m o s t c h a r a c t e ro s t r i n g i n u m b e r e d 1 t h l e f t b o u n d a r y c a n b e s p e c i f i e d a s A / 1 / - I 1 T h u s , y o c a d i r e c t t h c o m p u t e r w i t h t h M I D $ c o m m a n d t p r

d u c e s t r i n g s f r o m t h m i d d l e o t h o r i g i n a l q u o t e , A $ w i t h t h f o l l o w i n gc o m m a n d a t l i n e 4 0

4 D M I D $ ( A $ , A / 2 - 1 / 2 1 , 1 )

l i s t o s y m m e t r i c a l l y g r o w i n g s t r i n g s w i l l b p r i n t e d , a s i n F i g u r e 6 . 5 .

Page 71: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 71/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 5

T H Q U T T H O U G H T S N E V E R T H I T H Q U T T H O U G H T S N E V E R T H I T H O U T T H O U G H T S N E V E R T H E W I T H O U T T H O U G H T S N E V E R T H E W I T H O U T T H O U G H T S N E V E R T H E A VW I T H O U T T H O U G H T S N E V E R T H E A UW I T H O U T T H O U G H T S N E V E R T H E A V EW I T H O U T T H O U G H T S N E V E R T H E A U EW I T H O U T T H O U G H T S N E V E R T H E A V E ND U I T H O U T T H O U G H T S N E V E R T H E A V E NO W I T H O U T T H O U G H T S N E V E R T H E A V E NR D W I T H O U T T H O U G H T S N E V E R T H E A V E NR O S W I T H O U T T H O U G H T S N E V E R T H E A V E NO R O S W I T H O U T T H 0 U 6 H T S N E V E R T H E A V E NO R O S W I T H O U T T H O U G H T S N E V E R T H E A V E N G

W O R D S W I T H O U T T H O U G H T S N E V E R T H E A V E NW O R D S W I T H O U T T H O U 6 H T S N E V E R T H E A V E N

H A M L E T , A C I I I , S C E N ER E A O V .

F i g u r e 6 . 5 : T h e f f e c t o p r o g r a m t h a t g e n e r a t e s i n c r e a s i n g l y l o n g e r s t r i n g sf r o m t h M I D $ c o m m a n d .

I N S I D E I N F O R M A T I O NL i k e v e r s a t i l e a c t o r s w i t h i n p l a y , v a r i a b l e s y m b o l s f o n u m b e r s a n

c h a r a c t e r s c a p l a y m a n y c h a n g i n g r o l e s w i t h i n a p r o g r a m . T h e q u a ls i g n d i r e c t s t h e s e v a r i a b l e s i n t o t h e i r r e s p e c t i v e r o l e s o f t h e m o m e n t . B u t h C o m m o d o r e 6 r e c o g n i z e s a n o t h e r w a o a s s i g n i n g v a l u e s t v a r i ab l e s , w h i c h i s o m e w h a t t h w a s t a g e c o m p a n y ' s a c t o r s a r g i v e n t h e i ra s s i g n m e n t s — t o g e t h e r . Y o c a a s s i g n v a l u e s t s e v e r a l v a r i a b l e s a o n c ew i t h p a i r o c o m m a n d s , D A T A a n R E A D , i w h i c h y o l i s t t h v a l u e st b s e n t t t h c o m p u t e r , a n t h v a r i a b l e s t w h i c h t h e y a r a s s i g n e d ,r e s p e c t i v e l y . A n n u m b e r o v a l u e s c a b s e n t t t h c o m p u t e r w i t h t h c o m m a n d t h a t h a n d l e s t h i n f o r m a t i o n l i s t , D A T A . Y o c a u s i t s e n dt h v a l u e s o f s t r i n g a n t w n u m b e r s , C H O K E B E R R Y , 1 5 a n 3 0 w i t h t h f o l l o w i n g c o m m a n d :

N E 1 D A T A C H O K E B E R R Y , 1 5 , 3 0

Page 72: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 72/148

5 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

T h e n u s t h c o m m a n d t h a t m a k e s t h a s s i g n m e n t s f r o m t h l i s t o v a l u e s ,R E A D , t a s s i g n t h o s e v a l u e s t t h v a r i a b l e s N $ A a n B r e s p e c t i v e l y ,w i t h t h i s c o m m a n d :

2 R E A D N $ , A , BY o c a n o u s t h e s e a s s i g n m e n t s , w h i c h a r t h e q u i v a l e n t o t h c o m a n d s :

N C H O K E B E R R Y1 3

i P R I N T s t a t e m e n t l i k e t h i s o n e :

3 P R I N T N " A F T E R " " M O N T H S "N o a d l i n e s 1 0 2 0 a n 3 t s e o c o m m a n d s i w h i c h o n v a l u e , B i u s e d t c o n t r o l P R I N T d i s p l a y :

1 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "4 F O R X 1 T O B5 P R I N T T A B ( X ) " ( p r e s s a n + ) 6 P R I N T " ( p r e s s S H I F T a n C U R S O R U P / D O W N ) ( p r e s s S H I F T

a n C U R S O R U P / D O W N ) "7 N E X T X

T h a b o v e l i n e s d i r e c t t h c o m p u t e r t d r a w h o r i z o n t a l b a o l e n g t hc o r r e s p o n d i n g t t h v a l u e o f g i v e n i t h D A T A s t a t e m e n t o f l i n e 1 0

R u n n i n g t h i s p r o g r a m a i i s y o u ' l l s e t h h e a d i n g :

C H O K E B E R R Y A F T E R 1 M O N T H Sa n b e l o w i h o r i z o n t a l b a r , 3 c o l u m n s l o n g .

T h e s e t w o i n f o r m a t i o n - h a n d l i n g c o m m a n d s , o n e f o r m i n g a i n f o r m at i o n l i s t , t h o t h e r d r a w i n g f r o m t h a t l i s t , c a n b e u s e d a n y w h e r e w i t h i np r o g r a m . O n e c o m m a n d n e e d n o p r e c e d e t h o t h e r . I f y o p l a c eR E A D s t a t e m e n t b e f o r e D A T A s t a t e m e n t , t h c o m p u t e r w i l l s e e k o u t h D A T A s t a t e m e n t w h e n i e n c o u n t e r s R E A D , a n m a k e t h a s s i g nm e n t o v a l u e s t t h v a r i a b l e s . B e c a u s e i m a k e s s u b s t i t u t i o n s e a c h t i m e i e n c o u n t e r s R E A D s t a t e m e n t , y o c a u s l o o p t c o m m a n d t h c o p u t e r t s u b s t i t u t e s e v e r a l s e t s o v a l u e s t a k e n f r o m a D A T A s t a t e m e n t f o

s i n g l e s e o v a r i a b l e s l i s t e d i i t a c c o m p a n y i n g R E A D s t a t e m e n t .

Page 73: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 73/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 5

T h p r o g r a m j u s t r u c a b m o d i f i e d t h a n d l e g r o u p o v a l u e s ,a c t i n g o e a c h g r o u p , t h e n r e t u r n i n g t t h R E A D s t a t e m e n t f o n e a s s i g n m e n t s f o t h v a r i a b l e s . Y o c a e a s i l y a d m o r e n a m e s a n v a l u e st t h D A T A s t a t e m e n t :

1 D A T A C H O K E B E R R Y , 1 5 > 3 0 , V E T C H , 2 5 , 1 4 , B E A R D W O R T , 1 7 , 2 7 ,C H I C K W E E D , 9 , 2 1 , T H Y M E . 1 1 , 2 5

B u i y o r u t h p r o g r a m n o w , t h c o m p u t e r w i l l r e s p o n d a b e f o r e ,p r i n t i n g o n l y t h i n f o r m a t i o n a b o u t t h e c h o k e b e r r y , s i n c e i a c t s o t h R E A D s t a t e m e n t o n l y o n c e . T d i r e c t i t h r o u g h t h R E A D s t a t e m e n te n o u g h t i m e s t s u b s t i t u t e v a r i a b l e f o e a c h t h r e e - p i e c e s e o i n f o r m at i o n i t h D A T A s t a t e m e n t , y o c a a d F O R - T O , N E X T p a i r o c o m m a n d s t r e p e a t l i n e s 2 0 t h r o u g h 7 0

1 F O R I 1 T O 58 N E X T

B i n c l u d i n g t h R E A D - D A T A c o m m a n d s i F O l o o p , y o c a d i r e c t t h c o m p u t e r t i n t r o d u c e d i f f e r e n t v a l u e s f r o m t h D A T A s t a t em e n t i n t o a n o f t e n - u s e d s e r i e s o c o m m a n d s . T s l o w t h p l o t t i n g a n p r i n t i n g p a c e , y o c a a d d a n e m p t y l o o p b e f o r e t h c o m p u t e r m o v e s t a n o t h e r s e o v a l u e s :

7 F O R T = 1 T O 2 5 0 0 : N E X T T

F i n a l l y , b e c a u s e t h l o o p o l i n e s 1 t 8 i n c l u d e s c u r s o r c o n t r o l s ,w h i c h p r e s e n t n o r m a l l i n e r e t u r n a f t e r e a c h b a i d r a w n , b l a n kP R I N T s t a t e m e n t m u s t b a d d e d :

2 P R I N T

W h e n y o r u t h i s p r o g r a m , t h c o m p u t e r c l e a r s t h s c r e e n a n m o v e st h c u r s o r t t h t o l e f t c o r n e r . I t h e n a s s i g n s t t h e v a r i a b l e s N $ A a n

t h f i r s t t h r e e v a l u e s i t h D A T A s t a t e m e n t , C H O K E B E R R Y , 1 5 a n 3 0 r e s p e c t i v e l y . I n e x t p r i n t s t h s t a t e m e n t f r o m l i n e 3 0 a n t h e nf o l l o w s t h d i r e c t i o n s f o d r a w i n g t h h o r i z o n t a l b a r . A f t e r r u n n i n gt h r o u g h t h e m p t y F O R - T O , N E X T l o o p i l i n e 7 5 t h c o m p u t e r i n e x ts e n t b a c k f r o m l i n e 8 t t h R E A D s t a t e m e n t a l i n e 2 0 w h i c h a s s i g n s t t h v a r i a b l e s N $ a n t h n e x t t h r e e v a l u e s i t h D A T A s t a t e m e n t( V E T C H , 2 5 , 3 3 ) a n r e p e a t s t h p r i n t i n g , p l o t t i n g , a n p a u s i n g . T h N E X T c o m m a n d i l i n e 8 o n c e a g a i n s e n d s t h c o m p u t e r b a c k t h r o u g h

Page 74: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 74/148

Page 75: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 75/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 6

Y o c a d i r e c t t h c o m p u t e r t b r i n g t h e m i n t o p r o g r a m s t a t e m e n t b n u m b e r , w i t h t h e s e l i n e s :

3 P R I N T N $ ( l ) " A F T E R " A ( l ) " M O N T H S "4 F O R X 1 T O I

T h r e s u l t i n g p r o g r a m w i l l p r o d u c e t h s a m e r e s u l t s a i t u n s u b -s c r i p t e d p r e d e c e s s o r . B u t h a d v a n t a g e i t h a t y o c a d i r e c t t h c o p u t e r t u s t h e s e n u m e r i c a l l y - n a m e d v a r i a b l e s i v a r i o u s w a y s ,a c c o r d i n g t n u m b e r s c a l c u l a t e d o r a s s i g n e d i o t h e r p r o g r a m s t a t e m e n t s .Y o c a n , f o i n s t a n c e , d i r e c t t h e t a b u l a r p r i n t i n g o t h p l a n t s ' n a m e s a n p e r f o r m a n c e s o v e r t i m e . N o t h e s u b s c r i p t e d v a r i a b l e s , A ( I ) a n B ( I ) ,c o m e i h a n d y i c o m b i n a t i o n o P R I N T a n F O R - T O , N E X T s t a t em e n t s , w h i c h w i l l d i s p l a y a l t h i n f o r m a t i o n :

8 P R I N T9 F O R I 1 T O 5

1 0 P R I N T N $ ( I ) " G R E W T B ( l ) " A F T E R A ( l ) " M O N T H S1 1 N E X T I

T h p r o g r a m w i l l n o d i r e c t f i r s t t h e p r i n t i n g a n b a g r a p h s a i d i b e f o r e , t h e n t h e p r i n t i n g o l i s t o f t h e p l a n t s ' p e r f o r m a n c e s , a s h o w n i F i g u r e 6 . 7 .

I y o h a v e a u s f o v a r i a b l e s w i t h m o r e t h a n s i n g l e n u m e r i c t a e a c h , y o c a a d m o r e t a g s . T h v a r i a b l e s N $ ( I , J ) , A ( I J ) , a n B ( I J )c o u l d b n a m e d b w r a p p i n g a n o t h e r F O R - T O , N E X T l o o p , o n t h a tc o u n t s w i t h t h v a r i a b l e J , a r o u n d t h l o o p s . T h n u m b e r s f o c o u l ds t a n d f o t h w a t e r i n g i n t e r v a l o e a c h p l a n t , f o r e x a m p l e , a n c o u l d r a n g ef r o m t 3 Y o c a u s s e v e r a l l o o p s i t h i s w a t o i n s t r u c t t h c o m p u t e rt n a m e s e r i e s o v a r i a b l e s i t h f o r m N $ ( I , J , K , L , M ) , i w h i c h

w o u l d b e c o d e n u m b e r f o t h p l a n t , m i g h t b e i t w a t e r i n g p e r i o d ,t h a m o u n t , t h a m o u n t o f e r t i l i z e r , a n t h t i m e a l l o w e d , f o

e x a m p l e .E a c h l o o p o f F O R - T O , N E X T s t a t e m e n t s t h a t y o u s t a s s i g n v a l u e s

t s u b s c r i p t e d v a r i a b l e n a m e s m u l t i p l i e s t h n u m b e r o v a r i a b l e s . E a c hD A T A s t a t e m e n t o u g h t t c o n t a i n a m a n y v a l u e s a r e q u e s t e d b t h a c c o m p a n y i n g R E A D s t a t e m e n t . W h e n t h c o m p u t e r e n c o u n t e r s aR E A D c o m m a n d a s k i n g f o m o r e i n f o r m a t i o n t h a n i p r o v i d e d b D A T A c o m m a n d , i w i l l s t o p t h p r o g r a m a n d p r i n t t h m e s s a g e :

O U O D A T A E R R O R

Page 76: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 76/148

6 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

: H 0 K E 8 E R R V A F T E R 1 M O N T H S

I E T C H A F T E R 2 M O N T H S

B E A R D W O R T A F T E R 1 M O N T H S

C H I C K W E E D A F T E R M O N T H S

T H V h E A F T E R 1 M O N T H S

C H 0 K E 8 E R R Y G R E W T 3 A F T E R 1 M O N T H SU E T C H G R E W T 1 A F T E R 2 M O N T H SB E A R D W O R T G R E W T 2 A F T E R 1 M O N T H SC H I C K W E E D G R E W T 2 A F T E R M O N T H ST H V M E G R E W T 2 A F T E R 1 M O N T H S

F i g u r e 6 . 7 : A n o t h e r u s o t h D A T A a n R E A D v a l u e s f r o m t h p r o g r a m t h a tp r o d u c e d F i g u r e 6 . 6 .

W h e n t h c o m p u t e r f i r s t e n c o u n t e r s s u b s c r i p t e d v a r i a b l e t h a t i n o n u m b e r e d , i a u t o m a t i c a l l y s e t s a s i d e s p a c e f o a m a n y a e l e v e nn u m e r i c a l l y t a g g e d v a r i a b l e s t h a t m i g h t l a t e r b p r o d u c e d . I t h i s w a y , i r e s e r v e s p l a c e s i n i t v o l u m i n o u s m e m o r y f o e a c h o t h a s s i g n m e n t s —A ( l ) = A ( 2 ) = a n s o n — t h a t y o u r p r o g r a m m i g h t g e n e r a t e f r o mD A T A a n R E A D c o m m a n d s . T h e l e v e n v a r i a b l e s w i l l b n u m b e r e dt h r o u g h 1 0 f o e a c h s e o s u b s c r i p t s . T h u s , w h e n e v e r t h c o m p u t e re n c o u n t e r s v a r i a b l e A ( I ) , i r e s e r v e s s p a c e f o t h v a r i a b l e s A ( 0 ) , A ( l ) ,a n s o t A ( 1 0 ) .

I y o w a n t t h c o m p u t e r t h a n d l e v a r i a b l e s n u m b e r e d o u t s i d e t h i sr a n g e , y o c a d i r e c t i t p u a s i d e s p a c e f o t h e m . W i t h t h D I c o m a n d , y o n a m e t h v a r i a b l e , a n g i v e t h s u b s c r i p t t h h i g h e s t n u m b e ry o u w o u l d l i k e t a l l o w f o r . T r e s e r v e s p a c e f o t h v a r i a b l e s N $ ( 0 )t h r o u g h N $ ( 5 0 ) , f o i n s t a n c e , y o c a s e n d t h c o m m a n d :

D I N $ ( 5 0 )

Page 77: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 77/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 6

F o e x a m p l e , i y o u ' r e c o n s i d e r i n g f i f t y p e o p l e w h c a e a c h w o r k o n o t h r e e d i f f e r e n t s h i f t s , a n d y o u w i s h t r e s e r v e s p a c e f o a l p o s s i b l ea r r a n g e m e n t s o n a m e s , t i m e s , a n p e r f o r m a n c e s , t h v a r i a b l e s r e s u l t i n gc o u l d t a k e a n o t h f o r m s b e t w e e n N $ ( l , l ) , A ( l , l ) , B ( l , l ) a n N $ ( 5 0 , 3 ) , A ( 5 0 , 3 ) , B ( 5 0 , 3 ) . Y o c a u s t h D I c o m m a n d t s a v es p a c e f o a l o t h e s e v a r i a b l e s a n v a l u e s b s e n d i n g t h d i r e c t i o n s :

D I N $ C 5 O V 3 ) , 4 ( ^ , 5 ) , B ( 5 0 , 3 )

i s t a t e m e n t a t h b e g i n n i n g o t h p r o g r a m . O e n c o u n t e r i n g t h i sc o m m a n d , t h c o m p u t e r w i l l s e a s i d e a " a r r a y " o s p a c e s i i t m e m o r y ,s t a r t i n g w i t h N $ ( 0 , 0 ) a n e n d i n g w i t h N $ ( 5 0 , 3 ) . N s p a c e p r o b l e m s w i l lb e f a l l p r o g r a m t h a t r u n s w i t h o u t u s i n g a l t h e s p a c e s s e a s i d e b D I s t a t e m e n t , b u t h p r o g r a m t h a t t r i e s t c r o w d i v a r i a b l e s w i t h o u tr e s e r v a t i o n s — a n N $ ( 5 1 , 3 ) , f o e x a m p l e — w i l l b s t o p p e d i i t t r a c k s b a i n t o l e r a n t c o m p u t e r , w i t h t h r e p l y :

B A S U B S C R I P T E R R O R I ( l i n e n u m b e r )

T H C L O C K I N S I D EW h e n e v e r y o s w i t c h o t h c o m p u t e r , e v e n i y o d o n ' t t o u c h t h k e b o a r d , t h C o m m o d o r e 6 s e c r e t l y b u s i e s i t s e l f , k e e p i n g t i m e . A i n t e r

n a l , e l e c t r o n i c d o c k b e g i n s r u n n i n g t h i n s t a n t p o w e r i s w i t c h e d o n , a n r u n s a l o n g a t h p o w e r i u n i n t e r r u p t e d .

T h t i m e , i t h f o r m o s i x - d i g i t n u m b e r r e p r e s e n t i n g h o u r s , m i u t e s a n s e c o n d s , c a n b e r e a d b d i r e c t i n g t h c o m p u t e r t d i s p l a y i t v a l u e . T h a t v a l u e i s t o r e d , a n c o n t i n u a l l y u p d a t e d , u n d e r t h n a m eT I M E $ . T c h e c k i a a n m o m e n t y o c a g i v e t h c o m m a n d :

P R I N T T I M E $

T h d o l l a r s i g n i T I M E $ i n d i c a t e s t h a t t h c o m p u t e r s t o r e s t h i s v a l u e ,t h o u g h n u m e r i c , a s t r i n g v a r i a b l e , l i k e w o r d . Y o c a t u r n t h c o p u t e r i n t o d i s p l a y i n g c l o c k w i t h t h i s s h o r t p r o g r a m :

N E 1 P R I N T " ( p r e s s C L R / H O M E ) n2 P R I N T T I M E S3 G O T 0 1 0

w h i c h , w h e n r u n , w i l l s h o w t h s e c o n d s t i c k i n g b a t h t o p o f t h s c r e e n .

Page 78: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 78/148

6 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

Y o c a i n c l u d e i p r o g r a m a I F - T H E N c o m p a r i s o n t h a t d i r e c t s t h c o m p u t e r t c h e c k t h v a l u e o f T I M E $ ( w h i c h c a a l s o b w r i t t e n a T I $ )a n a c w h e n i r e a c h e s c e r t a i n v a l u e . S u c h s t a t e m e n t m i g h t t a k e t h f o r m :

I T I M E $ " 0 1 3 5 2 0 " T H E N P R I N T " Y O U R T I M E I U P S T O P

w h i c h , w h e n e n c o u n t e r e d b t h c o m p u t e r o n h o u r , t h i r t y - f i v e m i n u t e s ,a n t w e n t y s e c o n d s a f t e r t h p o w e r i s w i t c h e d o n w i l l d e c l a r e o t h s c r e e n Y O U R T I M E I U a n s t o p t h p r o g r a m r u n .

Y o c a a l s o a d j u s t t h e c l o c k , s e t t i n g i t t h c u r r e n t t i m e m u c hl i k e a n o t h e r . F o i n s t a n c e , y o c o u l d s y n c h r o n i z e t h c o m p u t e r ' s c l o c kw i t h o n t h a t g a v e t h t i m e a h i g h n o o n , w i t h t h i s s i m p l e a s s i g n m e n ts t a t e m e n t :

T I M E $ " 1 2 0 0 0 0 "

O U T S I D E C O N T A C TE v e n w h i l e i t ' s w o r k i n g o t h c o m m a n d s o a p r o g r a m , t h C o m m o

d o r e 6 i n o e n t i r e l y b l i n d t w h a t ' s h a p p e n i n g o u t h e r e w h e r e y o a r e .I c a r e s p o n d t d i r e c t i o n s m o r e s u b t l e a n i n f o r m a t i v e t h a n t h t h r o tt l i n g i n t e r r u p t i o n y o g i v e i b p r e s s i n g R U S T O P o s w i t c h i n g o f t h p o w e r . B u t h c o m p u t e r , u n i m a g i n a t i v e a n s e r v i l e , h a t b p o i n t e d i t h r i g h t d i r e c t i o n b e f o r e i c a k n o w w h a t y o h a v e t t e l l i t

T h I N P U T C o m m a n dY o c a a d c o m m a n d t p r o g r a m s o t h a t t h c o m p u t e r w i l l s t o p ,

t a k e t h e i n f o r m a t i o n y o h a v e f o i t a n t h e n p r o c e e d w i t h t h r u u s i n gw h a t y o u p r o v i d e d . T h a t c o m m a n d i I N P U T . S c o m m a n d e d , t h c o p u t e r c a i n t e r a c t w i t h p e r s o n a t h k e y b o a r d o w i t h d e v i c e s t w h i c h i i c o n n e c t e d . T h I N P U T c o m m a n d d i r e c t s t h c o m p u t e r t " p r i m ei t s e l f " b s e t t i n g a s i d e o n o m o r e v a r i a b l e s , a n t h e n " s i p h o n " t h v a u e t y p e d a t h k e y b o a r d . I t h e n p r o c e e d s w i t h t h p r o g r a m , s u b s t i t u t i n gt h o s e v a l u e s a t h o u g h i w e r e r e s p o n d i n g t a a s s i g n m e n t c o m m a n d o p a i r o D A T A , R E A D c o m m a n d s .

U s i n g s i m p l e f o r m o t h I N P U T c o m m a n d , y o c a d i r e c t t h c o p u t e r t t e l l y o t h a t i t ' s w a i t i n g f o i n f o r m a t i o n , a n t h e n t a k e w h a t y o t y p e i ( w i t h p r e s s o t h R E T U R N k e y ) a n i n c l u d e i i t h p r o g r a m .

Page 79: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 79/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 6

T h c o m m a n d t a k e s t h f o r m o s i m p l e r e q u e s t f o v a r i a b l e ' s v a l u e .Y o c a u s i t d i r e c t , f o e x a m p l e , a i n s t a n t d o u b l i n g o w h a t e v e rn u m b e r y o s e n d f r o m t h k e y b o a r d i t h i s s h o r t p r o g r a m :

N E 1 I N P U T2 P R I N T A

T h s t a t e m e n t , I N P U T A d i r e c t s t h c o m p u t e r t p r i n t q u e s t i o n m a r ko t h e s c r e e n a s i g n a l t o y o t h a t i t ' s w a i t i n g f o r e p l y f r o m t h k e b o a r d . I y o u d o n o t h i n g , t h c o m p u t e r w i l l r e m a i n f r o z e n i i t o p e r a t i o na t l i n e 1 0 , w a i t i n g . I y o t y p e n u m b e r , s a 5 3 7 , a n t h e n p r e s s t h eR E T U R N k e y , t h c o m p u t e r r e c e i v e s t h a t n u m b e r , m a k e s t h a s s i g nm e n t 5 3 7 , a n t h e n c a r r i e s o u t h c o m m a n d s o t h n e x t l i n e . I t h i s c a s e , t h e m u l t i p l i c a t i o n 5 3 i p r i n t e d o t h n e x t r o a 1 0 7 4 .

T h I N P U T c o m m a n d t r a n s l a t e s a s " P r i n t q u e s t i o n m a r k , t h e n t a k et h n e x t v a l u e s e n t f r o m t h k e y b o a r d , a n s u b s t i t u t e i f o t h e v a r i a b l e i t h s t a t e m e n t s t h a t f o l l o w . " T h I N P U T c o m m a n d c a a l s o d i r e c t t h c o m p u t e r t a c o s t r i n g s i t h s a m e w a y , a i t h i s s h o r t p r o g r a m :

1 I N P U T A 2 P R I N T A A + A

w h i c h w i l l s t a m m e r t h r e e t i m e s w h a t e v e r y o s e n d .L i k e D A T A a n R E A D , s i n g l e I N P U T c o m m a n d c a b u s e d t

d i r e c t t h c o m p u t e r t a c o b o t h s t r i n g s a n n u m b e r s , a s i n t h i s p r o g r a m :

1 I N P U T A $ 2 P R I N T T A B ( A ) A $

I y o u r u n t h i s p r o g r a m , a n t h e n r e s p o n d w i t h :F R O M T H K E Y B O A R D , 2

t h c o m p u t e r w i l l t h e n p r i n t t h w o r d s F R O M T H K E Y B O A R Db e g i n n i n g a c o l u m n 2 0

Y o c a u s t h I N P U T c o m m a n d l i k e t h D A T A a n R E A D c o m a n d s , t y p i n g v a l u e s a f t e r t h q u e s t i o n m a r k ( a s a f t e r D A T A c o m a n d ) a n s e t t i n g v a r i a b l e s f o a s s i g n m e n t a f t e r t h I N P U T c o m m a n d( a s a f t e r R E A D c o m m a n d ) . T h e r e i d i f f e r e n c e , h o w e v e r : u s i n g a I N P U T s t a t e m e n t , y o c a s e n d n e v a l u e s d u r i n g e a c h p r o g r a m r u w i t h o u t c h a n g i n g l i n e o t h p r o g r a m .

Page 80: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 80/148

6 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

s e c o n d f o r m o t h I N P U T c o m m a n d a l l o w s y o t d i r e c t t h c o m p u t e r i c o n v e n i e n t w a y , b c o n d e n s i n g t w c o m m a n d s i n t o o n e .T h i s f o r m o t h c o m m a n d d i r e c t s p r i n t i n g o t h s c r e e n , i p l a c e o t h s i m p l e q u e s t i o n m a r k , b e f o r e w a i t i n g f o r e p l y f r o m t h k e y b o a r d . Y o c a u s i b t y p i n g , a f t e r t h w o r d I N P U T a n w i t h i n q u o t e s , q u e s t i o no s t a t e m e n t y o u ' d l i k e d i s p l a y e d , f o l l o w e d b s e m i c o l o n t s e p a r a t e t h ev a r i a b l e s y o u ' r e d i r e c t i n g d i c o m p u t e r t a s f o r .

A f t e r s e n d i n g N E c o m m a n d t o c l e a r t h l a s t p r o g r a m f r o m m e o r y , y o c a b u i l d p r o g r a m f r o m t h i s f o r m o t h I N P U T c o m m a n d ,s t a r t i n g w i t h :

1 I N P U T " W H A T ' S T H C O D E P L E A S E " ; A $

w h i c h d i r e c t s t h c o m p u t e r t p r i n t y o u r q u e s t i o n , " W H A T ' S T H C O D E P L E A S E ? " a n t h e n w a i t f o s t r i n g t h a t c a n b e s u b s t i t u t e d f o A $ T h i s f o r m o t h I N P U T s t a t e m e n t , a l t h o u g h i t ' s m o r e g r a c e f u l , i e x a c t l y e q u i v a l e n t t t h e f o l l o w i n g c o m m a n d s :

1 P R I N T " W H A T ' S T H C O D E P L E A S E " : I N P U T A B a d d i n g c o n d i t i o n a l ( I F - T H E N ) s t a t e m e n t , y o c a p r o g r a m t h

c o m p u t e r ' s p r i n t e d r e s p o n s e s t v a r y a c c o r d i n g t y o u r " p a s s w o r d "r e p l i e s f r o m t h k e y b o a r d . Y o c a a r r a n g e p r o g r a m s t h a t t h c o p u t e r e n c o u n t e r s c o n d i t i o n a l I F - T H E N c o m m a n d a f t e r a I N P U Tc o m m a n d h a p u l l e d k e y b o a r d i n f o r m a t i o n i n t o t h p r o g r a m t b e u s e d i o t h e r c o m m a n d s . D o i n g t h i s , y o c a m a k e t h p r o g r a m t w o - w a ye x c h a n g e o i n f o r m a t i o n , a i n t e r a c t i v e c o n v e r s a t i o n w i t h y o u r c o m p u t e r .

T b u i l d s u c h p r o g r a m f r o m t h e c u r r e n t I N P U T s t a t e m e n t , l i n e 1 0 y o c a a d a I F - T H E N c o m m a n d a n d t w o p o s s i b l e r e s p o n s e s , l i k e t h i s :

2 I F A $ = " T H E A N C I E N T M A R I N E R S E N T M E T H E N 4 3 P R I N T : P R I N T " I D O N T T A L K W I T H S T R A N G E R S . " : G O T 0 1 04 P R I N T : P R I N T " O K I ' L L T A L K T Y O U . T H I S C O M P U T E R

R U N S O 6 5 1 0 C H I P . "5 P R I N T " I ' M J U S T A I N T E R P R E T E R F O R T H E P R O C E S S O R

C H I P T H A T R E A L L Y R U N S T H E "6 P R I N T " S H O W A R O U N D H E R E . W H E N Y O G I V E C O M M A N D S

I T ' S T H 6 5 1 0 C H I P T H A T "7 P R I N T " M A K E S T H I N G S H A P P E N . "

W h e n y o r u n a p r o g r a m l i k e t h a b o v e , t h c o m p u t e r i d i r e c t e d t t a k ev a l u e ( o i t h i s c a s e s t r i n g o c h a r a c t e r s ) f r o m t h k e y b o a r d , a n t h e n

c o m p a r e t h a t v a l u e w i t h a n o t h e r a n a c a c c o r d i n g t t h c o m p a r i s o n .

Page 81: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 81/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 6

T h I N P U T c o m m c i n d t a k e s t h e s t r i n g s e n t f r o m t h k e y b o a r d a n a s s i g n s i t A $ T h I F - T H E N c o m m a n d c o m p a r e s i a g a i n s t t h o r i g in a s t r i n g . I t h e r e i n m a t c h , t h n e x t c o m m a n d , l i n e 3 0 d i r e c t sr e b u f f , " D O N ' T T A L K W I T H S T R A N G E R S " , a n s e n d s t h c o p u t e r t o a c t o t h I N P U T s t a t e m e n t a t l i n e 1 0 w h i c h a g a i n a s k s ," W H A T ' S T H E C O D E P L E A S E ?

W h e n t h e r e p l y s e n t f r o m t h k e y b o a r d ( a n d a s s i g n e d t A $ m a k e s t h I c o n d i t i o n t r u e , t h c o m p u t e r i s e n t b t h T H E N c o m m c i n d t l i n e4 0 t P R I N T t h c o m p u t e r ' s i n n e r s e c r e t s , a f t e r w h i c h t h p r o g r a me n d s . W h e n r e p l y a f t e r r e p l y f r o m t h k e y b o a r d d o e s n ' t m a t c h t h c o n d it i o n o t h I F - T H E N s t a t e m e n t , h o w e v e r , t h c o m p u t e r i t r a p p e d i t h l o o p o f l i n e s 1 t h r o u g h 3 t h r o u g h 1 0 p r i n t i n g t h e r e b u f f a n r e q u e s t i n gt h p a s s w o r d o v e r a n o v e r . T h C o m m o d o r e 6 i p a r t i c u l a r l y s t u b b o r nw i t h I N P U T s t a t e m e n t s . M o s t o t h e r p r o g r a m s c a b s t o p p e d w i t h t h R U S T O P c o m m a n d . N o s w i t h p r o g r a m s w a i t i n g f o r e p l y t a I N P U T c o m m a n d . T s t o p s u c h a p r o g r a m , y o m u s t u s t h f i r m e rR U S T O P - R E S T O R E c o m m a n d , w h i c h d i r e c t s t h c o m p u t e r t s t o pt h p r o g r a m r u a n r e t a i n t h p r o g r a m i i t m e m o r y .

T h G E C o m m a n dY o d e t e r m i n e t h c o m p u t e r ' s a c t i o n s , o c o u r s e , w h e n y o w r i t e p r

g r a m , b u y o c a a l s o m a k e t h a c t i o n d e p e n d o t h r e s u l t o n u m e r i cc a l c u l a t i o n o o s o m e o t h e r v a l u e g i v e n t t h p r o c e s s o r t h r o u g h s o m ee x t e r n a l d e v i c e . T h e r e i a n o t h e r c o m m a n d , b o r n o t h s a m e n e e d f o i n f o r m a t i o n a t h I N P U T c o m m a n d , t h a t d i r e c t s t h c o m p u t e r i s i m i l a r ,b u t e r s e r , m a n n e r : G E T . W i t h i t y o c a c o m m a n d t h C o m m o d o r e 6 t o a c t o a k e y p r e s s e d a t h k e y b o a r d , w i t h o u t w a i t i n g f o t h R E T U R Nk e y . I d i r e c t s i m m e d i a t e s u b s t i t u t i o n s a n c a o r d e r v a l u e s f o r s e v e r a lv a r i a b l e s a o n c e , b u i p r i n t s n m e s s a g e i n q u o t e s , o q u e s t i o n m a r k .T h m a i n l i m i t a t i o n o t h i s c o m m a n d i t h a t i t a k e s o n l y o n e c h a r a c t e r —n u m b e r o s t r i n g — f o r e a c h v a r i a b l e .

Y o c a u s t h c o m m a n d i p r o g r a m o i t o w n , l i k e t h i s :

N E P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "

1 G E T A $2 P R I N T " ( p r e s s C L R / H O M E ) " A 3 G O T 0 1 0

Page 82: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 82/148

6 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

W h e n t h i s s h o r t p r o g r a m i r u t h r o u g h t h C o m m o d o r e 6 4 t h c o m p u t e r a s s i g n s t h f i r s t k e p r e s s e d t t h v a r i a b l e A $ t h e n m o v e s t h c u r s o r t t h u p p e r - l e f t c o r n e r o t h s c r e e n , a n p r i n t s t h e c h a r a c t e r o w h i c h e v e r k e i p r e s s e d . I m o r e t h a n s i n g l e k e i p r e s s e d , a s i n t h i sr e p l y :

T O E R R I H U M A N

t h c o m p u t e r w i l l t a k e t h f i r s t l e t t e r t y p e d , T a n d i s p l a y i t T h e n ,b e c a u s e o t h G O T O c o m m a n d a t l i n e 3 0 , t h e c o m p u t e r w i l l r e t u r n t l i n e s 1 a n 2 t r e a d a n d i s p l a y e a c h l e t t e r a i t ' s t y p e d , o n a t i m e .T h l e t t e r s w i l l r e p l a c e e a c h o t h e r i t h c o r n e r i m m e d i a t e l y , s i n c e t h c o m p u t e r r e a d s m u c h f a s t e r t h a n a n p e r s o n c a t y p e . I f a c t , t u s G E T , y o w i l l a l w a y s h a v e t p u i i n t o l o o p t m a k e i r e p e a t c o n t i nu a l l y . U n l i k e I N P U T , s i n g l e G E c o m m a n d w i l l n o t w a i t l o n g e n o u g hf o y o t i n p u t e v e n a s i n g l e c h a r a c t e r . T s e t h i s f o y o u r s e l f , d e l e t e l i n e3 a n t r t h p r o g r a m a g a i n .

T h f e a t u r e s t h a t m a k e t h G E c o m m a n d e i t h e r u s e f u l o b o t h e rs o m e , d e p e n d i n g o y o u r p o i n t o v i e w , a r e t w o : i d i r e c t s t h c o m p u t e r t i g n o r e a n y t h i n g m o r e t h a n t h v a r i a b l e i t ' s s e t o a s s i g n , a n i a c t s w i t ho u t w a i t i n g f o t h R E T U R N k e t b p r e s s e d .

T h A S C C o m m a n dE a c h k e p r o v i d e s i n f o r m a t i o n t t h c o m p u t e r e a c h t i m e i i p r e s s e d .

T h a t i n f o r m a t i o n t r a v e l s a n u m e r i c c o d e , o w h i c h t h c o m p u t e r t a k e ss o m e a c t i o n : r e l a y i n g t h l e t t e r t t h s c r e e n d i s p l a y ( p r e s s Z ) , o s t o pp i n g a p r o g r a m i p r o g r e s s ( p r e s s R U S T O P ) , f o e x a m p l e . Y o c a s e t h n u m b e r e a c h k e s e n d s b u s i n g c o m m a n d t h a t d i r e c t s t h r e a d i n go e a c h k e n u m e r i c a l l y . T h a t c o m m a n d i A S C ( " " ) a n i p r o d u c e s t h c o d e n u m b e r o t h f i r s t c h a r a c t e r o t h s t r i n g t y p e d i p a r e n t h e s e s . F o i n s t a n c e , A S C ( " Z " ) i 9 0 Y o c a u s t h G E s t a t e m e n t i p r o g r a mt h a t w i l l d i s p l a y t h e c o d e n u m b e r o e a c h k e a y o p r e s s i t l i k e t h i s o n e :

N E 1 G E T A $ : I F A $ = " " T H E N 1 02 P R I N T A $ T A B ( 5 ) A S C ( A $ )3 G O T 0 1 0

W h e n y o r u t h i s p r o g r a m , t h c h a r a c t e r a n t h c o d e n u m b e r o e a c hk e y o p r e s s w i l l b p r i n t e d o t h s c r e e n a y o p r e s s i t

Page 83: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 83/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 6

L i n e 1 d i r e c t s t h c o m p u t e r t s e a r c h f o t h n e x t k e p r e s s e d . I n o n ei p r e s s e d d u r i n g t h i n s t a n t i t a k e s t p e r f o r m s i n g l e G E o p e r a t i o n ,t h e n A h a n v a l u e ( A " " a n t h c o m p u t e r i s e n t b a c k t s e a r c ha g a i n . W h e n a k e y i p r e s s e d , A i g i v e n v a l u e a n t h c o m p u t e r m o v e st l i n e 2 0 w h e r e i t ' s d i r e c t e d t p r i n t t h e k e p r e s s e d a n t h e n , s p a c i n go v e r , t h n u m e r i c c o d e . L i n e 3 r e s t a r t s t h p r o c e s s .

A t h i s p r o g r a m r u n s , y o u ' l l f i n d t h a t e a c h k e y s t r o k e c o m b i n a t i o n( e x c e p t t h R U S T O P a n R E S T O R E k e y s , w h i c h a c t u a l l y s t o p t h eo p e r a t i o n o t h p r o g r a m ) p r o d u c e s c o d e n u m b e r . I f a c t , f o u r k e y s w i l ls h o w a c o d e n u m b e r e a c h , b u n v a l u e . T h e s e f o u r , m a r k e d f 2 f f 4

f 6 a n f 8 a r k n o w n a j u n c t i o n k e y s , a n t h e y w e r e p u o t h k e b o a r d n o t a f f e c t t h s c r e e n d i s p l a y , b u t s e r v e a p r o g r a m m a b l es w i t c h e s y o c a u s t o s i g n a l t h c o m p u t e r w h i l e k e e p i n g t h o t h e r , d i p l a y k e y s f r e e f o u s e .

I y o p r e s s f l y o u ' l l s e e t h a t i c o r r e s p o n d s t t h c o d e 1 3 3 , a n t h a tS H I F T - f l ( w h i c h y o c a t h i n k o f a s f 2 c o r r e s p o n d s t 1 3 7 . K n o w i n gt h i s , y o c a u s a n o t h e f u n c t i o n k e y s a t r i g g e r f o r s o m e a c t i o n w h i l e

p r o g r a m i r u n n i n g . B a d d i n g t h f o l l o w i n g s t a t e m e n t s t t h p r o g r a ma b o v e , y o c a d i r e c t t h c o m p u t e r t b r e a k o u o t h l o o p a n t a k es m o t h e r a c t i o n :

2 I F A S C ( A $ ) 1 3 3 T H E N 4 04 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) " T I M E $

Y o c a u s o t h e r k e y s t r o k e s i n s i m i l a r w a y s . F o e x a m p l e , t m a k ef u r t h e r u s e o f t h e f u n c t i o n k e y o c a a d d :

2 7 I F A S C ( A $ ) 1 3 7 T H E N 5 05 P R I N T " N O W Y O U ' V E D O N E I T ! "6 G O T O 5

T h P E E K C o m m a n dT h C o m m o d o r e 6 c a r e a c h b e y o n d t h k e y b o a r d f o i n f o r m a t i o n t

a c o n I d o e s t h i s t h r o u g h i t c i r c u i t r y , b u y o n e e d n o c a l l a e l e c t r i c i a no t a k e o u s o l d e r i n g g u n . I n f a c t , i y o p l u g p a i r o g a m e p a d d l e s i n t ot h s i d e o t h C o m m o d o r e 6 a t h j a c k m a r k e d C O N T R O L P O R T 1 s h o w n i F i g u r e 6 . 8 , y o c a o p e n a n o t h e r l i n e o i n f o r m a t i o n .T h C o m m o d o r e 6 h a t h a b i l i t y t o e l e c t r o n i c a l l y s e n s e t h e p o s i t i o n s o

Page 84: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 84/148

7 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

F i g u r e 6 . 8 : C O N T R O L P O R T 1 , t h g a m e - p a d d l e s o c k e t .

t h p a d d l e s o j o y s t i c k , a n t i n t e r p r e t t h o s e p o s i t i o n s a s n u m b e r s , f r o mt 2 5 5 . Y o c a d i r e c t t h c o m p u t e r t t a k e v a l u e s f r o m t h p a d d l e p o s i

t i o n s , f o e x a m p l e , w i t h t h c o m m a n d s t h a t i n t r o d u c e t h e m i n t o a p r og r a m , P E E K ( 5 4 2 9 7 ) a n P E E K ( 5 4 2 9 8 ) . T h e n , a c t i n g a i t h o s e v a l u e sh a b e e n a s s i g n e d i a n o t h o t h e r w a y s a l r e a d y s e e n , t h c o m p u t e r c a t r e a t t h e m a i c o u l d a n o t h e r v a l u e . T h c o m p u t e r c a n r e a d o n n u m e r i c v a l u e f r o m e a c h p a d d l e . U s i n g t h P E E K c o m m a n d t r e a d t h e l e c t r i c a l s t a t u s o p a d d l e , y o c a d i r e c t t h c o m p u t e r t a s s i g n t h a tv a l u e t v a r i a b l e , w h i c h c a t h e n b a c t e d o i t h p r o g r a m .T h P E E K c o m m a n d s c a b u s e d i s t a t e m e n t l i k e t h o n b e l o w ,w h i c h a s s i g n s t h v a l u e o f e a c h o t h p a d d l e s t t h v a r i a b l e s a n Y

N E 1 P E E K ( 5 4 2 9 7 ) : Y P E E K ( 5 4 2 9 8 )

T h c o m m a n d s P E E K ( 5 4 2 9 7 ) A N P E E K ( 5 4 2 9 8 ) e a c h t r a n s l a t e a s " G e n e r a t e a n u m b e r f r o m t h e l e c t r i c a l v a l u e o f t h e p a d d l e . W h e n t h p a d d l e i t u r n e d c o m p l e t e l y c o u n t e r c l o c k w i s e , t h v a l u e i 0 w h e n i i c l o c k w i s e , t h v a l u e i 2 5 5 ; g e n e r a t e v a l u e s i b e t w e e n a c c o r d i n g t p o s i t i o n . "

Page 85: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 85/148

H A N D L I N G W O R D S A N I N F O R M A T I O N 7

T h s t a t e m e n t i l i n e 1 0 p r e p a r e s t h c o m p u t e r t o s u b s t i t u t e t h v a l u ef r o m o n e p a d d l e f o t h v a r i a b l e X a n t h v a l u e f r o m t h o t h e r p a d d l ef o v a r i a b l e Y Y o c a f i n d o u w h i c h i w h i c h b y t r y i n g t h e m w i t h p r g r a m l i k e t h o n t h a t f o l l o w s . Y o c a a d p r i n t i n g , s c r e e n - c l e a r i n g , a n p o s i t i o n i n g s t a t e m e n t s , a n r e p e a t i n g l o o p c o m m a n d , l i k e t h i s :

P R I N T " ( p r e s s C L R / H O M E ) "2 P R I N T T A B ( 1 0 ) X T A B ( 2 0 ) Y3 G O T 0 1 0

W h e n y o r u t h i s p r o g r a m , t h p a d d l e s f e e d i v a l u e s t h r o u g h t h P E E K c o m m a n d s . P r o g r a m l i n e 2 d i r e c t s t h c o m p u t e r t p r i n t t h v a l u e o f e a c h p a d d l e ' s p o s i t i o n n e a r t h t o p o f t h s c r e e n . I n c i d e n t a l l y , v a u e b e l o w 1 0 w i l l a p p e a r i t h r e e d i g i t s , a 9 9 0 , 9 8 0 , e t c . , o t h s c r e e n .

Y o c a a d s t a t e m e n t t e r a s e t h e p r e v i o u s v a l u e a n s k e e p o n l yt h c u r r e n t v a l u e d i s p l a y e d , l i k e t h i s :

1 P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "

O e n c o u n t e r i n g t h G O T O s t a t e m e n t , t h c o m p u t e r i d i r e c t e d b a c kt t h c o m m a n d t h a t a s s i g n s t h p a d d l e v a l u e s t v a r i a b l e s . T h u s , t h v a u e p r i n t e d o t h s c r e e n k e e p p a c e w i t h t h e c u r r e n t p a d d l e p o s i t i o n s .

A t h i s p r o g r a m i r u n , t h e v a l u e s y o s e o t h e s c r e e n a r g e n e r a t e df r o m p h y s i c a l d e v i c e a c t i n g a a e x t e n s i o n o t h c o m p u t e r . T h i s i t h e s s e n c e o c o m p u t e r m o n i t o r i n g .

Y o c a u s t h e s e v a l u e s w i t h i n p r o g r a m j u s t a s y o u ' d u s e v a l u e s g e e r a t e d o s u p p l i e d w i t h i n i t W i t h t w s e a s i l y m a n i p u l a t e d v a l u e s , y o c a s e i m o t i o n a l k i n d s o a c t i o n . F o i n s t a n c e , y o c a d r a w d i r e c t l yw i t h t h p a d d l e s b d e r i v i n g T A a n v e r t i c a l s p a c i n g v a l u e s f r o m p a d d l ep o s i t i o n s . B u i l d i n g f r o m p r o g r a m l i n e 1 a g a i n , y o c a u s t h e f o l l o w i n gp r o g r a m t d t h a t :

P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) "P R I N T " ( p r e s s C L R / H O M E ) "

1 P E E K ( 5 4 2 9 7 ) : P E E K ( 5 4 2 9 8 )2 3 0 / 2 5 5 * X : V 2 0 / 2 5 5 * Y3 F O R I 1 T O V : P R I N T : N E X T I4 P R I N T T A B ( H ) " ( p r e s s S H I F T a n Q ) 5 G O T O

Page 86: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 86/148

7 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

T h a s s i g n m e n t c o m m a n d s o l i n e 2 s c a l e t h v a l u e s t a k e n f r o m t h p a d d l e s t t h d i m e n s i o n s o t h s c r e e n . T h l o o p f o r m e d b y t h c o m a n d s o l i n e 3 c a r r i e s o u s p a c i n g f u n c t i o n a c c o r d i n g t t h v a l u e o o n o t h p a d d l e s .

Page 87: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 87/148

U S I N G P R O G R A M S W I T H C A S S E T T E T A P E SP e o p l e t r a v e l a c r o s s c o u n t r y b b o t h a i r p l a n e a n b u s . O n w a i

f a s t e r a n c o s t s m o r e ; t h o t h e r i l e s s c o n v e n i e n t a n s l o w e r , b u i r e l at i v e l y i n e x p e n s i v e . T h s a m e s o r t o c h o i c e i a v a i l a b l e w h e n i c o m e s t s t o r i n g a n u s i n g p r o g r a m s a n i n f o r m a t i o n f i l e s , b o t h p r e - p a c k a g e d a n y o u r o w n . d i s k s y s t e m w i l l m o v e p r o g r a m s a n i n f o r m a t i o n m o r eq u i c k l y ; c a s s e t t e t a p e s y s t e m m o r e s l o w l y b u a m u c h l o w e r c o s t .

Y o c a p u y o u r p r o g r a m s o c o m m o n c a s s e t t e r e c o r d i n g t a p et h r o u g h C o m m o d o r e c a s s e t t e r e c o r d e r . T h i s i s p e c i a l l y - w i r e d t a p er e c o r d e r ( c a l l e d D A T A S S E T T E ™ t h a t p l u g s i n t o t h b a c k o t h C o m o d o r e 6 4 a s h o w n i F i g u r e 7 . 1 . B o p e r a t i n g i a c c o r d i n g t t h i n s t r u c t i o n s t h a t a p p e a r o t h e s c r e e n w h e n e v e r y o u s t h r e c o r d e r , y o c a s t o r e a n y t h i n g t h a t r e s i d e s i n t h c o m p u t e r ' s p r o g r a m m e m o r y o i n e x p e n s i v e c a s s e t t e t a p e s .

T h C o m m o d o r e 6 r e c o g n i z e s s i m p l e c o m m a n d s f o t r a n s f e r r i n g p r g r a m s t a n f r o m c a s s e t t e t a p e . W h a t ' s r e q u i r e d o y o u r p a r t i b i o b u t t o n - p u n c h i n g o t h r e c o r d e r a o n - s c r e e n d i r e c t i o n s g u i d e y o u .

Y o c a u s t h c a s s e t t e t a p e i t h s a m e w a a i y o w e r e r e c o r d i n gs p e e c h o m u s i c . T m a k e f u l l u s o f c a s s e t t e t a p e , m a k e s u r et h e r e c o r d i n g - p r o t e c t n o t c h e s a t h e d g e o t h c a s s e t t e c a s e a r c o v e r e do b l o c k e d , a n t h a t t h t a p e h a b e e n r e w o u n d t t h b e g i n n i n g , b u s h o w s t h d u l l b r o w n t a p e t h r o u g h t h w i n d o w a t h b u s i n e s s - e n d o t h c a s s e t t e .

S l i d e t h c a s s e t t e i n t o t h p l a s t i c t r a c k s o t h r e c o r d e r ' s l i d . T h e n c l o s e

Page 88: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 88/148

7 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

F i g u r e 7 . 1 : T h c o n n e c t i o n b e t w e e n t h c o m p u t e r a n t h c a s s e t t e r e c o r d e r .

t h l i a n y o u ' r e r e a d y t u s t h t a p e f o p r o g r a m s t o r a g e . T h p o w e r t d r i v e t h e r e c o r d e r c o m e s f r o m t h c o m p u t e r i t s e l f . Y o c a u s t h c o u n t e r t k e e p t r a c k o w h e r e y o u r p r o g r a m s a r b y m a k i n g n o t e o p r o g r a m a n n u m b e r , j u s t a y o m i g h t o a n t a p e r e c o r d e r . T h i s i g o o d i d e a , s i n c e t h t a p e s y s t e m o s t o r a g e w o n ' t a u t o m a t i c a l l y m a k ed i r e c t o r y o p r o g r a m s c o n t a i n e d o t h t a p e . T h p r o g r a m s w i l l i n s t e a db t r e a t e d m u c h l i k e s e r i e s o s h o r t s o n g s o r s p e e c h e s r e c o r d e d o n a f t e ra n o t h e r t h r o u g h m i c r o p h o n e .

T h p r o c e d u r e f o r e c o r d i n g p r o g r a m i f a i r l y d i r e c t . I y o h a v ep r o g r a m i t h c o m p u t e r ' s m e m o r y t h a t y o w a n t t s a v e u n d e r t h n a m e E N C H A N T M E N T , f o e x a m p l e , y o c a g i v e t h e c o m m a n d :

S A V E " E N C H A N T M E N T "T h c o m p u t e r w i l l r e s p o n d , i n t u r n , w i t h t h p r o m p t :

P R E S S R E C O R D P L A Y O T A P E

I y o t h e n p r e s s t h o s e t w k e y s o t h r e c o r d e r t o g e t h e r , t h c o m p u t e r w i l lq u i c k l y r e s p o n d w i t h :O S A V I N G E N C H A N T M E N T

T h s c r e e n w i l l b b l a n k e d , t h t a p e r e c o r d e r ' s m o t o r w i l l t u r n , a n r e l i g h t o t h r e c o r d e r w i l l l i g h t . W h e n t h c o m p u t e r h a f i n i s h e d r e c o r d i n gt h p r o g r a m , i w i l l r e t u r n t h d i s p l a y s c r e e n a n p r e s e n t R E A D Yp r o m p t a n d f l a s h i n g c u r s o r . A t h i s p o i n t , u n l e s s y o u w a n t t s a v ea n o t h e r p r o g r a m o t a p e , y o c a p r e s s t h S T O P k e o t h r e c o r d e r .T h p r o g r a m n o r e s i d e s i n t w o p l a c e s — o n t h t a p e a n i t h c o p u t e r ' s m e m o r y .

Page 89: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 89/148

Page 90: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 90/148

Page 91: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 91/148

E C O N O M Y - C L A S S S T O R A G E — T A P E S 7

T h c o m p u t e r w i l l r e s p o n d w i t h t h e q u e s t i o n :N A M E O F I L E ?

I y o t h e n t y p e i n a m e o y o u r c h o o s i n g , s a y W O R M S , a n p r e s sR E T U R N , t h c o m p u t e r w i l l p r o m p t y o u t r e a d y t h t a p e r e c o r d e r :P R E S S R E C O R D P L A Y O T A P E

T h e n , a f t e r y o u ' v e d o n e s o t h s c r e e n w i l l g b l a n k , t h e r e c o r d e r ' s r e l i g h t w i l l g l o w , a n t h e t a p e w i l l t u r n . A t h i s p o i n t t h e c o m p u t e r i d i r e c ti n t h n a m e W O R M S o n t o t h t a p e a f i l e n a m e . W h e n t h i s h a h a p e n e d , t h e s c r e e n w i l l r e a p p e a r w i t h p r i n t i n g a n t h n e l i n e s :

O

T h q u e s t i o n m a r k i p r o m p t f r o m t h c o m p u t e r f o t h f i r s t i t e m i t h f i l e . I y o t y p e a i t e m , l i k e N I G H T C R A W L E R , a n t h e n p r e s s t h eR E T U R N k e y , t h c o m p u t e r w i l l p r o m p t y o f o t h n e x t i t e m w i t ha n o t h e r q u e s t i o n m a r k :

I y o t y p e a n o t h e r i t e m , s a S I L K W O R M , a n s e n d i w i t h t h R E T U R N k e y , t h q u e s t i o n - m a r k p r o m p t w i l l a g a i n a p p e a r . T h i sp r o g r a m c a a c c e p t 1 0 i t e m s . ( L i n e 1 1 c r e a t e d a " a r r a y " o 1 0 v a r ia b l e s f o a n s w e r s . ) Y o c a s e n d i t e m a f t e r i t e m u n t i l y o u ' v e p u t i t h n u m b e r y o w a n t . A t h a t p o i n t , y o j u s t r e p l y t t h q u e s t i o n - m a r kp r o m p t w i t h C L O S E F I L E , a n t h c o m p u t e r w i l l e n c o d e t h e n t i r e l i s to i t e m s o t h t a p e .

T h s c r e e n w i l l g b l a n k , t h r e l i g h t o t h r e c o r d e r w i l l c o m e o n a n t h t a p e w i l l t u r n . W h e n t h l a s t i t e m h a b e e n l o a d e d , t h t a p e w i l l s t o p a n t h R E A D Y p r o m p t w i l l a p p e a r o t h s c r e e n . Y o u r l i s t w i l l b o t h t a p e .

Y o c a p u a n n u m b e r o f i l e s o t h t a p e t h i s w a y , o n a f t e r t h o t h e r . O c o u r s e , e n c o d e d a t h e y a r e , t h e s e f i l e s a r o l i t t l e u s t y o u .B u w i t h a n o t h e r p r o g r a m t o d i r e c t t h t a p e s y s t e m , y o c a p u l l t h i t e m so u o f i l e a n d i s p l a y t h e m o n t h s c r e e n . T h f o l l o w i n g p r o g r a m w i l lr e t r i e v e f i l e b n a m e f r o m t a p e a n l i s t e a c h i t e m o t h s c r e e n .

2 0 R E P R O G R A M T H A T R E T R I E V E S F I L E F R O M T A P E2 1 0 D I M A $ ( 1 0 0 )2 2 I N P U T N A M E O F I L E " ; F 2 3 O P E N 1 , 1 , 0 , F $2 4 I N P U T # 1 , A $ ( I )

Page 92: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 92/148

7 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

2 5 P R I N T I T A B ( 5 ) A $ ( I )2 6 2 7 I S T 6 T H E N 2 4 2 8 C L O S E

N o t i c e t h I N P U T c o m m a n d i l i n e 2 4 0 . T h i s c o m m a n d i v a r i a n tf o r m o I N P U T , u s e d t r e a d i t e m s f r o m t a p e o r d i s k m e m o r y i n s t e a d o f r o m t h k e y b o a r d .

W h e n y o u r u n t h i s p r o g r a m t o s e e t h i t e m s o t a p e f i l e , s u c h a s t h eW O R M S f i l e w e ' v e c r e a t e d , y o u ' l l s e e t h q u e s t i o n :

N A M E O F I L E ?O n c e y o t y p e t h n a m e o t h f i l e y o u ' r e l o o k i n g f o r , a n p r e s sR E T U R N , t h c o m p u t e r w i l l g i v e y o d i r e c t i o n s t o p e r a t e t h e r e c o r d e r :

P R E S S P L A Y O T A P EA f t e r y o d t h a t , t h s c r e e n w i l l g b l a n k a n t h t a p e w i l l t u r n u n t i l t h f i l e n a m e a n t h i t e m s h a v e b e e n f o u n d . I y o r u t h p r o g r a m w h e nt h t a p e i w o u n d t i t b e g i n n i n g a n t h f i l e i a t h e n o t h t a p e , t h c o m p u t e r w i l l s e a r c h o v e r e a c h n a m e u n t i l i f i n d s t h n a m e y o r e q u e s t e d . ( I t h n a m e i c o n t a i n e d w i t h i n l o n g e r f i l e n a m e , t h c o p u t e r w i l l r e t r i e v e t h a t f i l e i n s t e a d o t h o n y o r e q u e s t e d . F o e x a m p l e ,t h f i l e H A P P E N C H A N C E , i e n c o u n t e r e d f i r s t , w o u l d b r e t r i e v e d i t h f i l e H A P P E N w a r e q u e s t e d . ) F i n a l l y t h t a p e w i l l s t o p , a n t h c o p u t e r w i l l d i s p l a y t h n u m b e r a s s i g n e d t e a c h i t e m i t h l i s t , a n t h i t e m i t s e l f , a i p r i n t s l i s t o t h s c r e e n .

Y o c a u s t h e s e p r o g r a m s s e p a r a t e l y t s t o r e a n g a t h e r f i l e s w i t ht a p e , a n y o c a i n c o r p o r a t e t h e m i n t o y o u r o w p r o g r a m s , a l o n g a y o u r p r o g r a m s a s s i g n v a r i a b l e s t i t e m s i t h f o r m A $ ( I ) .

Page 93: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 93/148

S o o n a f t e r i t a p p e a r a n c e , g a l l a n t a n e f f e c t i v e P o n y E x p r e s s y i e l d e di t s e r v i c e o f t h e g r o w i n g f r o n t i e r t o t h f a s t e r a n t e c h n o l o g i c a l l y s u p e r i o rt e l e g r a p h . L i k e w i s e , i m a n y c o m p u t e r a p p l i c a t i o n s , t h t a p e s t o r a g e s y t e w d i s c u s s e d i C h a p t e r i g i v i n g w a t n e s y s t e m . t e c h n o l o gi c a l i m p r o v e m e n t o v e r t h t a p e s y s t e m o s t o r a g e , d i s k s y s t e m o f f e r ss p e e d o a c c e s s t h a t c a b i m p o r t a n t w h e n f r e q u e n t e x c h a n g e s o p r g r a m s a n i n f o r m a t i o n m u s t b m a d e b e t w e e n c o m p u t e r a n s t o r a g em e d i u m .

M A R R I A G E O M A C H I N E Sd i s k s y s t e m o p e r a t e s u n d e r t h e l e c t r i c a l a n l o g i c a l c o n t r o l o t h

C o m m o d o r e 6 a a e x t e n s i o n o t h c o m p u t e r ' s o w m e m o r y , w a r eh o u s e o p r o g r a m s a n i n f o r m a t i o n . E a c h e l e m e n t o t h i s s y s t e m p r o v i d e sm o r e t h a n t w i c e t h e m e m o r y c a p a c i t y o t h C o m m o d o r e 6 4 w h i c h i 6 k i l o b y t e s . W i t h d i s k s t o r a g e s y s t e m , y o c a p u a s i d e a n u s a g a i ny o u r o w p r o g r a m s a n o t h e r p r o g r a m s a l r e a d y w r i t t e n f o t h C o m m od o r e 6 4

M o r e c o m p l e x t h a n t h c a s s e t t e t a p e s y s t e m , t h d i s k s t o r a g e s y s t e mw o r k s t h r o u g h b o a b o u t t h s i z e o t h c o m p u t e r t h a t c o n t a i n s i t o w c i r c u i t r y a n s m a l l m e m o r y . W o r k i n g u n d e r t h c o m p u t e r ' s d i r e c t i o n ,t h i s d i s k d r i v e m a g n e t i c a l l y e n c o d e s p r o g r a m s a n i n f o r m a t i o n o n t o t h t h i n p l a s t i c c i r c l e s k n o w n a d i s k s , e a c h c o n t a i n e d l o o s e l y w i t h i n s q u a r ep l a s t i c e n v e l o p e .

T h e s e d i s k s a r c o a t e d w i t h m a g n e t i c a l l y - s e n s i t i v e m a t e r i a l a n

Page 94: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 94/148

8 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

r e s p o n d l i k e r e c o r d i n g t a p e t a e l e c t r o m a g n e t i c d e v i c e t h a t s c a n s t h e i rs u r f a c e s i n s i d e t h d i s k - d r i v e b o x . T h d i s k d r i v e i n c l u d e s m o t o r f o s p i n n i n g t h d i s k s w i t h i n t h e i r e n v e l o p e s , p h o n o g r a p h - s t y l e . S i n c e t h e s ed i s k s c a b r u i d r i v e o n a t i m e , a n t h e n r e m o v e d a n r e p l a c e db o t h e r d i s k s , t h e y f o r m a i n t e r c h a n g e a b l e a n u n l i m i t e d s e o r e p o s it o r i e s f o p r o g r a m s a n i n f o r m a t i o n p a s s i n g t o f r o m t h c o m p u t e r .

F i g u r e 8 . s h o w s d i s k d r i v e a n s o m e d i s k s .O n c e c o n n e c t e d t t h c o m p u t e r e l e c t r i c a l l y , t h d i s k s y s t e m a l s o

r e s p o n d s t c o m m a n d s t h a t a r e n ' t p a r t o t h v o c a b u l a r y o t h C o m m od o r e 6 4 T h r o u g h t h e s e c o m m a n d s , y o c a d i r e c t t h c o m p u t e r t p u a s i d e p r o g r a m o i n f o r m a t i o n f r o m i t m e m o r y o d i s k a n t o p u l lf r o m d i s k i n t o i t m e m o r y .

T h C o m m o d o r e 6 4 w h i c h c o m m u n i c a t e s w i t h o n d i s k a t i m e , w i l la c c o m m o d a t e f i v e d i s k d r i v e s , b u y o c a h a n d l e m o s t d i s k u s e s c o n v en i e n t l y w i t h o n l y t w o . I f a c t , s i n g l e d i s k d r i v e w i l l s u f f i c e f o r m o s t d i s ku s e s , a l t h o u g h l e s s c o n v e n i e n t l y , a t i m e s r e q u i r i n g m o r e i n s e r t i n g a n w i t h d r a w i n g o d i s k s o y o u r p a r t .

T h d i s k s y s t e m a n t h c o m p u t e r c a e x c h a n g e c o n t r o l o e a c h o t h e ri n t e r a c t i v e l y . Y o u r c o m m a n d s c a d i r e c t t h c o m p u t e r t p a r t i c u l a r d i s kd r i v e ( i m o r e t h a n o n i i n s t a l l e d ) a n t p a r t i c u l a r p r o g r a m o f i l e o t h e d i s k i t h e d r i v e . I n c o n v e r s e f a s h i o n , p r o g r a m d i r e c t i n g t h e

F i g u r e 8 . 1 : d i s k d r i v e a n s o m e t y p i c a l d i s k s .

Page 95: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 95/148

H I G H S P E E D S T O R A G E — D I S K S 8

c o m p u t e r ' s a c t i o n f r o m d i s k c a g u i d e i t c a r r y o u c o m m a n d s o s e q u e n c e s j u s t a s y o u w o u l d f r o m t h k e y b o a r d .

E a c h p r o g r a m o r i n f o r m a t i o n f i l e b r o u g h t o u f r o m d i s k i f i r s t f e i n t o t h c o m p u t e r ' s m e m o r y b e f o r e a n a c t i o n i t a k e n o i t T h i n f o rm a t i o n m a k e s i t w a b e t w e e n d i s k d r i v e a n m e m o r y b m e a n s o a s i mp l e l e c t r i c a l c a b l e .

E a c h d i s k d r i v e c o n t a i n s t h e c i r c u i t r y f o r u n n i n g i t m o t o r a n m o v i n gt h m a g n e t i c d r i v e h e a d . I f a c t , t h e d i s k d r i v e h a i t o w s m a l l p a r c e l o m e m o r y s p a c e f o r e t a i n i n g p r o g r a m s a n i n f o r m a t i o n , a n i t o w p o w e r s u p p l y a w e l l .

Y o w o n ' t n e e d a e l e c t r i c i a n t o c o n n e c t t h i n g s . H e r e ' s w h a t t d o F i r s t , t u r n o f t h p o w e r t t h c o m p u t e r . W i t h t h p o w e r o f f , y o c a n ' td a m a g e t h m a c h i n e . T h c o r d p a c k e d w i t h t h e d i s k d r i v e h a m e t a ls l e e v e a e a c h e n d , s u r r o u n d i n g s i p i n s . P l u g o n e e n o t h i s c o r d i n t o t h b a c k o t h e d r i v e b o x , i n t o t h j a c k j u s t a b o v e t h f i i s e . Y o t h e n p l u g t h o t h e r e n i n t o t h r o u n d j a c k f u r t h e s t f r o m t h p o w e r l i g h t a t t h b a c k o t h c o m p u t e r . T h f i n a l c o n n e c t i o n t m a k e i t h 3 - p r o n g e d p o w e r c o r d .P l u g t h b o x y e n d i n t o t h e t h b a c k o t h e d i s k d r i v e , a n t h s t a n d a r d e n i n t o p o w e r o u t l e t . T h c o n n e c t i o n s a r s h o w n i F i g u r e 8 . 2 .

A f t e r y o s w i t c h o f i r s t t h d i s k d r i v e p o w e r ( a t h r e a r o t h e d r i v eb o x ) , t h e n t h c o m p u t e r p o w e r , t h e l e c t r i c a l c o n n e c t i o n b e t w e e n c o p u t e r a n d i s k d r i v e s y s t e m i c o m p l e t e . Y o c a p o s i t i o n t h e p a r t s o t h s y s t e m — c o m p u t e r , d i s k d r i v e s a n m o n i t o r o t e l e v i s i o n — w h e r e v e r t h w i r e s w i l l r e a c h .

D I S K D R I V EP O W E R C O R D

C A B L E P L LF i g u r e 8 . 2 : T h c o n n e c t i o n b e t w e e n c o m p u t e r a n d i s k d r i v e .

Page 96: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 96/148

8 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

U S I N G P R E R E C O R D E D D I S K SF i r s t , w o r d a b o u t h o t o t r e a t d i s k s . L i k e p a p e r , d i s k s c o m e i t w

f o r m s , b l a n k a n w r i t t e n o n . Y o c a n c o p y r e c o r d e d d i s k s , w r i t e o b l a n kp a r t s o r e c o r d e d d i s k s , a n w r i t e o v e r , o e r a s e , p a r t s o r e c o r d e d d i s k s .Y o c a a l s o p r o t e c t t h e c o n t e n t s o d i s k , a y o m i g h t p u w r i t t e np a p e r i b i n d e r s t h a t i w o n ' t b e u n e x p e c t e d l y w r i t t e n o n T h s q u a r ee n v e l o p e a r o u n d t h e d i s k p r o t e c t s t h m a g n e t i c w r i t i n g f r o m e r a s u r e o a l t e r a t i o n i n t h d r i v e i t h a t e n v e l o p e i c o m p l e t e l y s e a l e d a r o u n d a l e d g e s a n l a c k s c u t - o u t n o t c h , c a l l e d w r i t e - e n a b l e n o t c h . I s u c h n o t c hi e x p o s e d o a e n v e l o p e , a i l l u s t r a t e d i F i g u r e 8 . 3 , t h e d i s k d r i v e w i l lb s w i t c h e d o u o r e a d i n g - o n l y m o d e o o p e r a t i o n . Y o c a t h e n d i r e c tt h c o m p u t e r t r e c o r d y o u r t y p i n g o t h d i s k .

Y o c a " f r e e z e " a l t h p r o g r a m s a n i n f o r m a t i o n o d i s k b e a r i n gs u c h n o t c h , b c o v e r i n g t h a t n o t c h w i t h s t u r d y p i e c e o f o i l t a p e , w h i c hi u s u a l l y p r o v i d e d w i t h b l a n k d i s k s . W h e n t h m e c h a n i s m s o t h e d i s kd r i v e s e n s e t h a t t h i s s p a c e i c o v e r e d , t h e d r i v e w i l l b s w i t c h e d t t h r e a do n l y m o d e .

A t h e i r n e a r l y t o t a l e n c l o s u r e s u g g e s t s , d i s k s a r f a i r l y f r a g i l e . E v e nw h e n d i s k h a e n d u r e d s o m e m i s h a p w i t h n v i s i b l e d a m a g e , i t m a g n e t i c a l l y - s e n s i t i v e s u r f a c e m a h a v e b e e n d a m a g e d . M a g n e t i c f i e l d s ,e x t r e m e s o t e m p e r a t u r e ( t h o s e o u t s i d e o u c o m f o r t r a n g e ) , b e n d i n g o

F i g u r e 8 . 3 : T h w r i t e - e n a b l e n o t c h o d i s k .

Page 97: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 97/148

H I G H S P E E D S T O R A G E — D I S K S 8

f o l d i n g , a n c o n t a m i n a t i o n b d i r t , d u s t , s k i n o i l s , a n t h l i k e a r a l h a a r d s . I n f o r m a t i o n a n p r o g r a m s r e c o r d e d o t h d i s k s u r f a c e i i n v i s i b l em a g n e t i c p a t t e r n s c a n b e c r i p p l i n g l y a l t e r e d b a i m p e r c e p t i b l e s c r a t c ho r c o n t a m i n a t i o n . H i d d e n i i t e n v e l o p e , n e a r l y a l o t h e d i s k i p r t e c t e d f r o m c o n t a m i n a t i o n a a n o n t i m e ; y o c a h a n d l e t h e n v e l o p ew i t h o u t c o n c e r n . B u t h d r i v e h e a d r e a d s w h e r e t h d i s k s u r f a c e i t s e l fp e e k s t h r o u g h a o v a l s l o t , a n t h r o u g h t h a t s l o t c a p a s s d u s t a n c o t a m i n a n t s a w e l l .

Y o c a e a s i l y a v o i d c o m m o n d i s k p r o b l e m s b t a k i n g t w s i m p l e p r c a u t i o n s : A l w a y s r e m o v e d i s k s f r o m t h e d r i v e b e f o r e t u r n i n g o f t h e d i s kd r i v e o t h c o m p u t e r ; a n a l w a y s m a r k l a b e l s f o r d i s k s b e f o r e y o s t i c kt h e m o n t o t h e d i s k e n v e l o p e s .

T h d i s k a n i t p l a s t i c e n v e l o p e a r e s t o r e d i a p a p e r j a c k e t , w h i c hd o e s n ' t q u i t e c o v e r t h e n v e l o p e . T h i s p a p e r s l e e v e s h i e l d s t h o t h e r w i s ee x p o s e d d i s k s u r f a c e a t h e o v a l c u t o u t w h e n i t ' s o u t o f t h d r i v e .

T h m a g n e t i c h e a d i t h e d i s k d r i v e , r e c o r d i n g a n r e a d i n g a l o n gs h o r t t r a c k , m a k e s c o n t a c t w i t h t h e d i s k t h r o u g h t h e n v e l o p e s l o t w h i l et h e d i s k i t s e l f i s p i n n i n g i n s i d e t h e n v e l o p e . B e c a u s e t h e d i s k e n v e l o p e i s q u a r e a n t w o - s i d e d , t h e r e a r e i g h t p o s s i b l e w a y s t p u i i n t o t h d r i v e .O n l y o n w a w i l l p o s i t i o n t h e d i s k c o r r e c t l y .

T h d r i v e h e a d i i t h r e a r h a l f o t h d r i v e , s t h s l o t t e d e n o t h d i s k e n v e l o p e g o e s i f i r s t . O n s i d e o t h e d i s k e n v e l o p e i u n l a b e l e d a n r e l a t i v e l y u n f i n i s h e d - l o o k i n g ; t h e o t h e r s i d e i l a b e l e d a n s m o o t h . I t h i sl a b e l e d s i d e f a c e s t h l i t t l e d o o r a t h f r o n t o t h d r i v e , t h m a g n e t i c s i d eo t h e d i s k w i l l f a c e t h e d r i v e h e a d .

T h u s , y o i n s e r t t h d i s k i n t o a e m p t y , o p e n e d d r i v e b o l i k e t h i s : s l o ti f i r s t , l a b e l e d s i d e f a c i n g t h e d o o r . T h e n a l y o d i s l i d e t h d i s k g e n t l ya l t h w a i n u n t i l i c a t c h e s i t h r e c e s s . Y o c a t h e n p u s h d o w n o t h d r i v e d o o r u n t i l i c a t c h e s t o c l o s e o v e r t h e c e n t e r o t h o p e n i n g .

Y o r e m o v e t h d i s k b p u s h i n g t h d o o r u n t i l i t ' s p u l l e d u p b y s p r i n ga c t i o n . T h d i s k i t s e l f w i l l s l i d e h a l f w a y o u t o f t h d r i v e b o x u n d e r t h s a m e s p r i n g a c t i o n .

I n s e r t i n g d i s k i d r i v e b o a n c l o s i n g t h d o o r p h y s i c a l l y c o m p l e t e st h c o m p u t e r - d i s k s y s t e m . B u u n l e s s i t ' s g i v e n t h s p e c i a l c o m m a n d s t h a td i r e c t t h d i s k d r i v e , t h s y s t e m i a b o u t a s u s e f u l a a i l l i t e r a t e l i b r a r i a n .E v e n w h e n i i p h y s i c a l l y a n e l e c t r i c a l l y c o n n e c t e d w i t h d i s k s y s t e m ,t h c o m p u t e r m u s t s t i l l b t o l d w h a t t d w i t h t h i s a p p a r a t u s .

T h c o m p u t e r c a r e s p o n d t y o u r d i s k c o m m a n d s , a s w e l l a s t t h B A S I C p r o g r a m m i n g c o m m a n d s b u i l t i n t o i t D i s k d i r e c t i o n s a u t o m a t ic a l l y c o m p i l e l i s t i n g o p r o g r a m s a n f i l e i n f o r m a t i o n a t h e y a r p u o n t o t h d i s k . T h T E S T / D E M O d i s k , s u p p l i e d w i t h C o m m o d o r e d i s k

Page 98: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 98/148

8 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

d r i v e s , h o l d s s e v e r a l p r o g r a m s a l r e a d y , t h o u g h i t ' s n o n e a r l y f i l l e d . W e ' l lu s t h T E S T / D E M O d i s k t g e s t a r t e d . Y o c a c o m m a n d l i s t i n g o t h p r o g r a m s o t h a t ( o r a n o t h e r ) d i s k , a n t h c o m p u t e r w i l l r e s p o n dw i t h d i s p l a y s h o w i n g t h n a m e g i v e n t t h d i s k a n l i s t i n g o i t p r g r a m s a n f i l e s . E a c h i p r e c e d e d b n u m b e r i n d i c a t i n g t h e a m o u n t o s p a c e i o c c u p i e s o t h d i s k .

Y o c a d i r e c t t h c o m p u t e r t d i s p l a y t h i s l i s t w i t h t h c o m m a n d :

L O A D " $ " ,

T h c o m p u t e r w i l l r e s p o n d w i t h a m e s s a g e o t h s c r e e n , a n t h d i s kd r i v e ' s r e l i g h t w i l l g l o w a s i g n a l t h a t t h e d r i v e i i o p e r a t i o n . Y o c a a l s o t a k e t h i s g l o w i n g r e l i g h t a a r e m i n d e r n o t r e m o v e t h d i s k a t h i st i m e .

I t h c o m p u t e r - a n d - d i s k - d r i v e s y s t e m d o e s n ' t r e c o g n i z e t h e d i s k c o m a n d s e n t t i t t h r e l i g h t o t h e d r i v e w i l l f l a s h , a s i g n a l t h a t t h l a s td i s k c o m m a n d h a s n ' t b e e n c a r r i e d o u t . T h s y s t e m w i l l s u b s e q u e n t l ya c c e p t a n c o m m a n d i r e c o g n i z e s a n t h e n e x t i n g u i s h t h l i g h t a f t e r p e f o r m i n g t h c o m m a n d .

I y o u ' v e s e n t t h c o m m a n d a b o v e , t h m e s s a g e y o u ' l l s e e i s

S E A R C H I N G F O

T h d o l l a r s i g n , $ i s h o r t h a n d n a m e f o t h d i r e c t o r y . O n c e t h d i r e ct o r y i f o u n d , t h c o m p u t e r w i l l r e p l y w i t h t h m e s s a g e :

L O A D I N G

T h a t m e a n s t h c o m p u t e r i c o p y i n g i n f o r m a t i o n f r o m t h e d i s k ( i t h i sc a s e , t h d i r e c t o r y l i s t i n g ) i n t o i t o w m e m o r y . W h e n t h c o m p u t e r h a f i n i s h e d c o p y i n g , i w i l l d i s p l a y t h e f a m i l i a r s i g n a l :

R E A D Y

Y o c a t h e n d i r e c t t h c o m p u t e r t p r i n t o n - s c r e e n t h d i r e c t o r y j u s tl o a d e d , w i t h t h c o m m a n d :

L I S T

T h s c r e e n w i l l f i l l w i t h l i s t l i k e t h a t s h o w n i F i g u r e 8 . 4 .d i r e c t o r y l i s t i n g c a h a v e m o r e i t e m s t h a n w i l l f i o s i n g l e s c r e e n .

Page 99: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 99/148

H I G H S P E E D S T O R A G E — D I S K S 8

L I S T

" H O H P A R T T W O 1 1' " U l C - Z e W E D G E "" C - 6 4 W E D G E "" D O S 5 I 1 I " C O P Y / A L L "" P R I N T E R T E S T "" D I S K A D O R C H A N G E "" D I R "" U I E U B A f f 1" C H E C K D I S K "1 4 " D I S P L A V T & S "" P E R F O R M A N C E T E S T "" S E Q U E N T I A L F I L E "1 " R A N D O M F I A L "" S E Q T E S T F I L E5 5 B L O C K S F U Z E .R E A O V .

P R P R P R P R P R P R P R P R P R P R P R P R P R P R S E

F i g u r e 8 . 4 : T h T E S T / D E M O d i s k d i r e c t o r y .

T h C o m m o d o r e 6 w i l l d i s p l a y t h e e n t i r e l i s t i n g b " s c r o l l i n g " t h f i r s ti t e m s o t h l i s t u a n o f t h s c r e e n t m a k e r o o m f o l a t e r i t e m s p r i n t e da f t e r t h f i r s t s c r e e n f u l . O n c e i h a d i s p l a y e d t h f i n a l i t e m o t h d i r e ct o r y , t h c o m p u t e r s i g n a l s i t r e a d i n e s s f o y o u r n e x t c o m m a n d w i t h t h R E A D Y p r o m p t . Y o c a s t o p t h e l i s t i n g a a n p o i n t w i t h t h R U S T O P k e y p r e s s c o m m a n d .

Y o c o n t r o l t h d i s k d r i v e t h r o u g h t h c o m p u t e r w i t h c o m m a n d s g i v e ni t h s a m e f o r m a t h L O A D c o m m a n d a b o v e . T h c o m p u t e r w i l l r e o g n i z e t h e s e c o m m a n d s i t h e y e a c h f o l l o w t h e p a t t e r n : f i r s t t h c o m a n d , t h e n t h n a m e o t h p r o g r a m i q u o t e s , t h e n c o m m a , t h e n t h n u m b e r 8 w h i c h o p e n s p a t h t t h e d r i v e c o n n e c t e d t t h c o m p u t e r .

T h e s e c o m m a n d s i n c r e a s e i c o m p l e x i t y a y o o r d e r m o r e c o m p l e xt a s k s . H o w e v e r , o n e o t h p r o g r a m s o t h T E S T / D E M O d i s k c a n s i mp l i f y t h c o m m a n d s y o g i v e t o p e r a t e t h e d i s k d r i v e . A f t e r y o u ' v ed i r e c t e d t h c o m p u t e r t l o a d a n t h e n r u t h i s p r o g r a m , t h C o m m od o r e 6 w i l l r e s p o n d t o e i t h e r t h o s e r a t h e r c u m b e r s o m e d i s k c o m m a n d si t ' s b u i l t t a c o n o a n o t h e r , s h o r t h a n d s e o s y m b o l i c c o m m a n d s . T h d i r e c t i o n s f o t h e s e s h o r t h a n d c o m m a n d s a r s t o r e d i a a r e a o t h c o p u t e r m e m o r y a p a r t f r o m t h u s u a l p r o g r a m m e m o r y , s y o c a u s t h e m o v e r a n o v e r w i t h o u t i n t e r f e r i n g w i t h t h p r o g r a m s o f i l e s y o p u i t h c o m p u t e r .

Page 100: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 100/148

8 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

Y o u ' l l f i n d t h i s p r o g r a m l i s t e d i t h e d i e c t o r y u n d e r t h n a m e C - 6 4W E D G E . T h C - 6 4 W E D G E p r o g r a m w i l l c o n t r o l t h e d i s k d r i v e s o t h a t

s e o d i r e c t i o n s c o r r e s p o n d i n g t t h e s e s h o r t h a n d c o m m a n d s i s t o r e d i t h " r e s e r v e d " p a r t o t h c o m p u t e r ' s m e m o r y . T h e s e d i r e c t i o n s w i l lr e s p o n d t y o u r s h o r t h a n d d i s k c o m m a n d s , a n w i l l r e m a i n i m e m o r ye v e n a f t e r t h c o m m a n d N E e r a s e s w h a t e v e r p r o g r a m y o u ' v e p u t i n t om e m o r y .

W i t h t h T E S T / D E M O d i s k i t h d r i v e , y o c a p u t h C - 6 4W E D G E p r o g r a m i n t o e f f e c t b d i r e c t i n g t h c o m p u t e r t l o a d i t

L O A D " C - 6 4 W E D G E " , 8O n c e t h c o m p u t e r h a c o m p l e t e d i t s e a r c h a n l o a d e d t h p r o g r a m i n t om e m o r y , y o u ' l l s e t h f a m i l i a r R E A D Y p r o m p t . Y o c a t h e n d i r e c t t h c o m p u t e r t r u t h p r o g r a m , a n p u t h d i r e c t i o n s f o i t s h o r t h a n dc o m m a n d s a s i d e i n m e m o r y , b c o m m a n d i n g :

R U A t h p r o g r a m r u n s y o u ' l l s e t h r e e - l i n e d i s p l a y o t i t l e a n c r e d i t s , a f t e rw h i c h t h f a m i l i a r R E A D Y p r o m p t a p p e a r s a s i g n a l t h a t d i s k d i r e ct i o n s f o r t h s h o r t h a n d c o m m a n d s a r a v a i l a b l e i m e m o r y .

T h c o m p u t e r w i l l n o r e s p o n d t o e i t h e r s e o c o m m a n d s . T h l o n g e r ,m o r e c u m b e r s o m e c o m m a n d s a r a l w a y s a v a i l a b l e f r o m t h c o m p u t e r .T h s h o r t h a n d C - 6 4 W E D G E c o m m a n d s a r t h e r e w h e n e v e r y o l o a da n r u t h a t p r o g r a m f r o m t h T E S T / D E M O d i s k .

S i n c e y o m a b u s i n g e i t h e r t y p e o f c o m m a n d , b o t h a r s h o w n i t h e x p l a n a t i o n s t h a t f o l l o w , a l t h o u g h y o m a p r e f e r t u s t h W E D G Ec o m m a n d s f o c o n v e n i e n c e . T h l o n g e r c o m m a n d s a r s h o w n h e r e i i t a l i c s a a l t e r n a t i v e s .

Y o c a n o l o a d a n l i s t t h d i r e c t o r y w i t h s i n g l e c o m m a n d :@

w h i c h g i v e s t h s a m e d i r e c t i o n s a s L O A D " $ " , 8L I S T

Y o c a r u t h f i r s t p r o g r a m o t h T E S T / D E M O d i s k , d i s p l a y p r g r a m c a l l e d H O T U S E , w i t h t h W E D G E a n p r o g r a m c o m m a n d s :

/ H O W T U S R U

T h s l a s h s y m b o l , / s e r v e s h e r e a a a b b r e v i a t e d f o r m o t h c o m m a n d

Page 101: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 101/148

H I G H S P E E D S T O R A G E — D I S K S 8

L O A D . Y o c o u l d g e t h s a m e r e s u l t s w i t h t h s t a n d a r d d i s k c o m m a n d s :L O A D " H O W T U S E " , 8R U

A t h i s p r o g r a m r u n s , y o u ' l l s e d e s c r i p t i o n o t h p r o g r a m s o t h T E S T / D E M O d i s k a n d i r e c t i o n s o t h e i r u s e . Y o c a s t o p t h e d i s p l a ya y o c o u l d a n p r o g r a m , b p r e s s i n g t h e R U S T O P k e y .

T h a n L O A D c o m m a n d s e a c h d i r e c t t h c o m p u t e r t e r a s e i t p r g r a m m e m o r y a n t c o p y o n t o i p r o g r a m f r o m t h d i s k . T h e i r e f f e c t i l i k e t y p i n g N E a n p r o g r a m . ( Y o u c a u s a n o t h e r s y m b o l i c c o m a n d , % t r u n p r o g r a m s w r i t t e n i t h m a c h i n e ' s o w n u m e r i c l a g u a g e , n o i B A S I C . )

T h W E D G E p r o g r a m c o n t a i n s d i r e c t i o n s t h a t a l l o w y o t g i v e b o t ht h L O A D a n t h R U c o m m a n d t o g e t h e r , i n a e v e n m o r e a b b r e v ia t e d f o r m . I t a k e s t h f o r m t a n c a b u s e d t g i v e t h s a m e r e s u l t s a a b o v e , t h o u g h m o r e q u i c k l y . Y o a d i r e c t t h c o m p u t e r t i m m e d i a t e l yb e g i n a c t i n g o t h c o m m a n d s o p r o g r a m f r o m t h e d i s k d r i v e b g i v i n gt h a t s i n g l e c o m m a n d . I y o u w a n t t h c o m p u t e r t f i n d , l o a d , a n r u p r o g r a m l i k e H O T U S o t h T E S T D E M O , y o c a g i v e t h c o m m a n d :

H O T U S T h c o m p u t e r w i l l t h e n s k i p l i n e a n s i g n a l y o w i t h t h s t a t e m e n t :

S E A R C H I N G F O H O T U S T h e n s m o t h e r l i n e w i l l t e l l y o t h c o m p u t e r i b r i n g i n g t h p r o g r a m i n t oi t m e m o r y :

L O A D I N GA f t e r t h i s , t h c o m p u t e r w i l l i m m e d i a t e l y b e g i n c a r r y i n g o u t h c o m a n d s o t h p r o g r a m . I t h i s c a s e , i d i s p l a y s t h e s c r e e n t i t l e d D I S KE T T E I N S T R U C T I O N S .

T h a n c o m m a n d s a r a l y o n e e d t u s p r e r e c o r d e d d i s k so p e r a t i n g u n d e r t h d i r e c t i o n s o t h T E S T / D E M O W E D G Ec o m m a n d s .

P R O G R A M S F R O M C O M P U T E R T O D I S KY o c a r e c o r d p r o g r a m s a n i n f o r m a t i o n o a n d i s k t h a t h a r e c o g

n i z e d m a g n e t i c p a t t e r n e t c h e d o n t o i t d i s k i t h d r i v e w i t h o u t t h i s p a t e r n i a u s e l e s s t y o u s i n g t h c o m p u t e r a b a r e d e s k t w r i t e r w i t h a

Page 102: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 102/148

8 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

p e n . W i t h t h e m , t h e d i s k i l i k e b l a n k s h e e t o l i n e d p a p e r , l y i n g r e a d y o t h d e s k t o p .

Y o c a d i r e c t t h i s m a g n e t i c e t c h i n g o d i s k w i t h s i n g l e c o m m a n df r o m t h W E D G E p r o g r a m . I t h p r o c e s s , y o w i l l e r a s e a n i n f o r m at i o n a l r e a d y o t h d i s k , a n p u o i s e c t i o n e d p a t t e r n , i w h i c h p r g r a m s a n i n f o r m a t i o n c a b s t o r e d . A t h s a m e t i m e , t h e d i s k w i l l b g i v e n n a m e . T h c o m p u t e r - d i s k s y s t e m a l s o l o o k s f o t w o - c h a r a c t e rc o d e o e a c h d i s k a i i f i r s t s c a n n e d . Y o c a p r o v i d e t h i s c o d e w i t h i nt h s a m e s i m p l e c o m m a n d .

T p r e p a r e d i s k t h i s w a y , g i v i n g i t h n a m e T H F I R S T , a n t h c o d e A l y o c a s e n d t h f o l l o w i n g c o m m a n d :

@ N : T H E F I R S T . A 1

o

O P E N 1 5 , 8 , 1 5

t h e nP R I N T # 1 5 , " N 0 : T H E F I R S T , A 1 "C L O S E 1 5 , 8 , 1 5

T h c o m p u t e r w i l l t a k e c o n t r o l o t h d i s k d r i v e , a n y o u ' l l h e a r t h s o u n do m a g n e t i c f o r m a t t i n g ( l i k e f a b r i c t e a r i n g ) f o r s e v e r a l m o m e n t s . W h e n a l i q u i e t a g a i n a n t h r e d i s k d r i v e l i g h t g o e s o f f , t h d i s k h a b e e n " i n it i a l i z e d , " a n i a y o u r s e r v i c e . T h n e w l y - p r e p a r e d d i s k c a h o l d p r g r a m a n i n f o r m a t i o n f i l e s , j u s t a t h T E S T / D E M O d i s k c a n . Y o c a s e l e c t i v e l y p u u s e f u l p r o g r a m s f r o m a n o t h e r C o m m o d o r e 6 d i s k ( l i k et h T E S T / D E M O d i s k ) o n t o a n i n i t i a l i z e d d i s k e t t e .

T r e c o r d p r o g r a m o n d i s k , y o f i r s t t y p e i i n t o t h c o m p u t e r . A n p r o g r a m w i l l d o — t h e H a m l e t q u o t a t i o n f r o m C h a p t e r 6 o o n o y o u ro w i n v e n t i o n . Y o c a t y p e i p r o g r a m y o u ' d l i k e t o s t o r e o d i s k , j u s ta y o w o u l d b e f o r e r u n n i n g i t o y o c a l o a d p r o g r a m f r o m a n o t h e rd i s k o f r o m c a s s e t t e t a p e . Y o c a n , o c o u r s e , r u t h p r o g r a m t s e t h a t t h c o m p u t e r d o e s w h a t y o u w a n t w i t h i t a n m a k e a n n e c e s s a r yc h a n g e s . W h e n y o u ' v e g o t t h e p r o g r a m a y o l i k e i i m e m o r y , e v e r yt h i n g i r e a d y f o t h d i s k c o m m a n d t h a t w i l l p r e s e r v e i o u t s i d e t h ec o m p u t e r .

A l l t h a t r e m a i n s i f o y o t n a m e t h p r o g r a m . T h d i s k d i r e c t i o n s t e l lt h c o m p u t e r t h a n d l e n a m e s u p t 1 c h a r a c t e r s l o n g . I y o w a n t t c a l ly o u r p r o g r a m C O L D S T O R A G E , f o e x a m p l e , y o c a d i r e c t t h c o p u t e r t s t o r e i u n d e r t h a t n a m e b t h c o m m a n d :

Page 103: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 103/148

H I G H S P E E D S T O R A G E — D I S K S 8

♦ C O L D S T O R A G Eo

S A V E " C O L D S T O R A G E " ,T h d i s k d r i v e w i l l m a k e i t f a b r i c - t e a r i n g s o u n d s . W h e n t h c o m m o

t i o n s t o p s a n t h r e l i g h t g o e s o f f , t h p r o g r a m e x i s t s i t w p l a c e s .M a g n e t i c a l l y e n c o d e d , i t ' s o t h d i s k . A n a s b e f o r e , i t ' s i t h c o p u t e r ' s p r o g r a m m e m o r y . I h a s n ' t m o v e d , i t ' s b e e n c o p i e d .

I y o t y p e L I S T , t h p r o g r a m s t a t e m e n t s w i l l a p p e a r o t h s c r e e n .Y o c a t y p e N E t e r a s e t h p r o g r a m m e m o r y a n s t i l l r u t h p r g r a m , t h i s t i m e f r o m t h d i s k , w i t h t h c o m m a n d :

C O L D S T O R A G Eo

L O A D " C O L D S T O R A G E " ,t h e n

R U I w i l l t h e n b f r e s h l y l o a d e d i n t o t h p r o g r a m m e m o r y o t h c o

p u t e r . Y o c a r e m o v e t h d i s k , t u r n o f t h c o m p u t e r , s e n d t h e d i s kr o u n d - t r i p t C h i c a g o i y o l i k e , a n d — o n i t r e t u r n — p u t t h a t d i s k i t h d r i v e b o x , t u r n o t h c o m p u t e r a n t y p e :

C O L D S T O R A G Eo

L O A D " C O L D S T O R A G E " ,t h e n

R U a n t h p r o g r a m w i l l m a n i f e s t i t s e l f .

T h c o m p u t e r w a q u i e t l y f o l l o w i n g a n o t h e r d i s k d i r e c t i o n w h e n y o c o m m a n d e d « C O L D S T O R A G E . I p u t h n a m e o t h p r o g r a m ,p r e c e d e d b n u m b e r i n d i c a t i n g t h a m o u n t o f s p a c e i t a k e s , o t h d i r e c t o r y . I y o n o s e n d t h d i r e c t o r y c o m m a n d :

@ o

L O A D " $ " , 8

Page 104: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 104/148

9 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

t h e nL I S T

a t h e n o t h d i r e c t o r y , y o u ' l l s e e :( n u m b e r l i k e 2 C O L D S T O R A G E P R G

Y o c a n c h a n g e t h n a m e o p r o g r a m w i t h a n o t h e r d i s k c o m m a n d .D i r e c t e d b t h i s c o m m a n d , t h c o m p u t e r l o o k s f o t h p r o g r a m u n d e r t h f i r s t n a m e l i s t e d , t h e n s u b s t i t u t e s f o r i t h s e c o n d n a m e .

T c h a n g e t h n a m e o t h p r o g r a m C O L D S T O R A G E t S T O W -A V \ W Y , f o e x a m p l e , y o c a s e n d t h c o m m a n d :

@ R : S T O W A W A Y C O L D S T O R A G Eo

O P E N 1 5 , 8 , 1 5t h e n

P R I N T # 1 5 , " R 0 : S T O W A W A Y = C O L D S T O R A G EC L O S E 1 5 , 8 , 1 5

S d i r e c t e d b t h R E N A M E c o m m a n d , t h c o m p u t e r c h a n g e s o n l y t h a tp r o g r a m ' s n a m e , l e a v i n g t h p r o g r a m i t s e l f a n i t p o s i t i o n i t h C A T AL O u n a f f e c t e d .

T h e r e ' s n n e e d t c l u t t e r d i s k w i t h p r o g r a m y o u n l o n g e r w a n t .T e r a s e p r o g r a m o n c e a n f o a l l , y o c a g i v e c o m m a n d l i k e t h i s :

@ S : S T O W A W A Yo

O P E N 1 5 , 8 , 1 5t h e n

P R I N T # 7 5 , " S 0 : S T O W A W A Y "T h c o m p u t e r , u n d e r d i s k d i r e c t i o n s , w i l l o p e r a t e t h e d r i v e t f i n d t h ep r o g r a m , e r a s e i e n t i r e l y , a n d r e m o v e i t n a m e f r o m t h d i r e c t o r y .

Y o c a m o v e p r o g r a m s i n d i v i d u a l l y f r o m o n d i s k t a n o t h e r u s i n gt h c o m m a n d s t h a t l o a d ( / ) , s a v e ( * - ) , a n d e l e t e ( @ S : ) . F i r s t y o l o a dt h p r o g r a m f r o m o n d i s k i n t o t h c o m p u t e r ' s m e m o r y , t h e n s a v e i b s e n d i n g i f r o m t h p r o g r a m m e m o r y t a n o t h e r d i s k , a n f i n a l l y d e l e t e i f r o m t h d i s k o w h i c h i o r i g i n a t e d .

T m o v e p r o g r a m l i k e S T O W W V i \ Y f r o m o n d i s k t a n o t h e r u s i n g

Page 105: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 105/148

H I G H S P E E D S T O R A G E — D I S K S 9

o n e - d r i v e s y s t e m , y o c a f i r s t b r i n g i i n t o t h c o m p u t e r ' s p r o g r a mm e m o r y :

/ S T O W A W A Yt h e n r e m o v e i t d i s k f r o m t h d r i v e , i n s e r t a s e c o n d d i s k — o n e e q u i p p e dw i t h i t o w m a g n e t i c e t c h i n g — a n d s e n d t h c o m m a n d :

^ S T O W A W A Yt h e n r e i n s e r t t h o r i g i n a l d i s k a n h a v e i e r a s e d w i t h t h c o m m a n d :

@ S : S T O W A W A YT h r o u g h t h s a v e , l o a d , d e l e t e , a n d r e n a m e d i s k c o m m a n d s , y o c a

j u g g l e a n r e s h a p e p r o g r a m s o d i s k s q u i t e f r e e l y . A n y m a gn e t i c a l l y - p r e p a r e d d i s k c a h o l d p r o g r a m a n d i n f o r m a t i o n f i l e s , j u s t a t h T E S T / D E M O d i s k c a n . Y o c a s e l e c t i v e l y p u u s e f u l p r o g r a m s f r o ma n o t h e r C o m m o d o r e 6 d i s k ( l i k e t h T E S T / D E M O d i s k ) o a n i n i t i a li z e d d i s k e t t e .

Y o c o u l d c o p y p r o g r a m l i k e S E Q U E N T I A L F I L E , f o i n s t a n c e ,w i t h t h c o m m a n d :

/ S E Q U E N T I A L F I L Eo

L O A D " S E Q U E N T I A L F I L E " ,

T h e n , r e p l a c i n g t h T E S T / D E M O d i s k w i t h a i n i t i a l i z e d o n o w h i c h y o u ' d l i k e t s t o r e t h p r o g r a m S E Q U E N T I A L F I L E , y o c o u l dg i v e t h c o m m a n d :

S E Q U E N T I A L F I L Ea n t h c o m p u t e r w o u l d d u p l i c a t e t h a t p r o g r a m o t h d i s k y o h a i n t i a l i z e d .

U s i n g t h i s p r o c e d u r e , y o c a d u p l i c a t e s e l e c t i v e l y a n m o v e p r o g r a m sa r o u n d y o u r d i s k e t t e s a s y o f i n d u s e f u l . I p a r t i c u l a r , y o c a c o p y t h i n f o r m a t i o n - a n f i l e - h a n d l i n g p r o g r a m o S E Q U E N T I A L F I L E o n t o ad i s k t h a t w i l l b u s e d f o s p e c i a l p u r p o s e , l i k e h o l d i n g i n f o r m a t i o n f i l e s .

U S I N G M O R E T H A N O N D I S K D R I V EJ u s t a s e v e r a l d i s k s c a s e r v e y o a r e s e r v o i r o p r o g r a m s a n i n f o r

m a t i o n , s e v e r a l d i s k d r i v e s e x p a n d t h n u m b e r o p a t h w a y s f o i t e m sm o v i n g i a n o u o f t h e c o m p u t e r m e m o r y . W i t h t w d r i v e s , f o

Page 106: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 106/148

9 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

i n s t a n c e , y o c a l o a d p r o g r a m s f r o m , o r s t o r e t h e m o n t h e d i s k s i ne i t h e r d r i v e .

T c o n n e c t s e c o n d d r i v e t t h s y s t e m , s i m p l y t a k e t h e s i x - p r o n g e dc o r d t h a t c o m e s w i t h t h d r i v e , a n p l u g o n e n i n t o t h s o c k e t o v e r t h f u s e h o l d e r o t h s e c o n d d r i v e ; t h e n p l u g t h e o t h e r e n i n t o t h s o c k e tr e m a i n i n g o t h e d r i v e y o u ' v e a l r e a d y c o n n e c t e d d i r e c t l y t t h c o m p u t e r .T h e l e c t r i c a l c o n n e c t i o n w i l l t h e n r u n f r o m t h c o m p u t e r d i r e c t l y t o n d r i v e , a n f r o m t h a t d r i v e t t h s e c o n d d r i v e . T h p o w e r c o r d f r o m t h s e c o n d d r i v e c o n n e c t s t a o u t l e t i t h s a m e w a a f o t h f i r s t d r i v e .

T h c o m p u t e r c a n o c o m m u n i c a t e w i t h e i t h e r d r i v e . I f y o t u r n o t h c o m p u t e r a n e i t h e r o n o t h d r i v e s , l e a v i n g t h o t h e r t u r n e d o f f , t h c o m p u t e r w i l l c a r r y o u t h c o m m a n d s d e s c r i b e d a b o v e t o p e r a t e t h d r i v e w h i c h i p o w e r e d .

I y o s w i t c h e d o b o t h d r i v e s a n g a v e c o m m a n d , l i k e t h a t t o l o a dt h d i r e c t o r y , t h c o m p u t e r w o u l d b s t y m i e d . W i t h o u t i n s t r u c t i o n s f o w h i c h o t h t w d i s k d r i v e s t s e a r c h f o t h d i r e c t o r y , i m a a r b i t r a r i l yc h o o s e o n o t h o t h e r , o i m a l o c k u p g i v i n g y o t h m e s s a g e t h a t i t ' ss e a r c h i n g f o t h d i r e c t o r y , $ w h e n i f a c t i t ' s n o c o n t r o l l i n g e i t h e r d r i v e .I t h a t c a s e , y o u ' d h a v e l o s t c o n t r o l o f t h e c o m p u t e r b s e n d i n g i o f t m a k e d e c i s i o n f o w h i c h i h a d n ' t b e e n p r o g r a m m e d .

T h k e t a v o i d i n g t h i s p r o b l e m i t r e a l i z e t h a t b u i l t - i n d i r e c t i o n s t e l lt h c o m p u t e r t h a t e a c h d r i v e i i d e n t i f i e d b t h s a m e n u m b e r . T h i sd e v i c e n u m b e r i a u t o m a t i c a l l y s e a 8 a n d y o u c a s e i i c o m m a n dl i k e L O A D " $ " , 8 . A n d r i v e c o n n e c t e d t t h c o m p u t e r , d i r e c t l y o t h r o u g h a n o t h e r d r i v e , i i d e n t i f i e d b t h i s n u m b e r a u t o m a t i c a l l y . B u t h c o m p u t e r c a b d i r e c t e d t o l a b e l a n d r i v e w i t h n u m b e r o y o u r o w c h o o s i n g t h r o u g h c o m m a n d s t h a t r e - l a b e l e a c h d r i v e . T h e s e c o m m a n d sa r n u m b e r - l a d e n a n a b s t r u s e , a n i n v o l v e s e t t i n g u c o m m a n d c h a nn e l s a n f i l e s , b u y o d o n ' t n e e d t u n d e r s t a n d t h d e t a i l s o h o t h e yw o r k t u s t h e m .

T c h a n g e t h d e v i c e n u m b e r b w h i c h c o n n e c t e d d i s k d r i v e w i l l b c a l l e d f r o m t h c o m p u t e r , h e r e ' s w h a t y o u c a d o F i r s t , s w i t c h o f e a c hd r i v e e x c e p t t h o n y o w i s h t r e n u m b e r .

S e n d t h f o l l o w i n g s t a t e m e n t ( w i t h t h R E T U R N k e y , o c o u r s e ) :

O P E N 1 5 , 8 , 1 5

T h e n s e n d t h i s s t a t e m e n t , i y o u w a n t t h d i s k d r i v e t b n u m b e r e d 9 f o e x a m p l e :

P R I N T # 1 5 , " M - W " C H R $ ( 1 1 9 ) C H R $ ( 0 ) C H R $ ( 9 3 2 ) C H R $ ( 9 6 4

Page 107: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 107/148

H I G H S P E E D S T O R A G E — D I S K S 9

I y o w i s h t r e n u m b e r a n o t h e r d r i v e , s w i t c h i o a n r e p e a t t h e c o m a n d s a b o v e , s u b s t i t u t i n g s m o t h e r n u m b e r f o i t h l a s t t w s e t s o p a r e n t h e s e s . I f f o i n s t a n c e , y o w i s h t o l a b e l a n o t h e r d r i v e a s 2 2 , y o c a t u r n i o a n f o l l o w t h i s s e q u e n c e :

O P E N 1 5 , 8 , 1 5P R I N T # 1 5 , " M - W " C H R $ ( 1 1 9 ) C H R $ ( 0 ) C H R $ ( 2 ) C H R $ ( 2 2 3 2

C H R $ ( 2 2 + 6 4 T h d e v i c e n u m b e r y o a s s i g n t e a c h d i s k d r i v e w i l l t h e n b r e c o g n i z e d

b t h c o m p u t e r u n t i l i i a g a i n c h a n g e d , o u n t i l p o w e r i s w i t c h e d o f f .S i n c e t h W e d g e c o m m a n d s a s s u m e d r i v e n u m b e r e d 8 t h e y w i l l b

e f f e c t i v e o n l y f o t h e d r i v e a u t o m a t i c a l l y g i v e n t h a t n u m b e r , o f o o n a s s i g n e d t h a t n u m b e r . I n u m b e r s a n a r a s s i g n e d t t w d r i v e s , f o re x a m p l e , y o c a u s t h l o n g f o r m o t h d i s k c o m m a n d s t c o n t r o l e a c ho t h d r i v e s , a n t h W e d g e c o m m a n d s t c o n t r o l d r i v e 8

Y o c o u l d c o p y p r o g r a m f r o m o n d i s k i d r i v e 8 f o r i n s t a n c e , t a n o t h e r i d r i v e w i t h s e q u e n c e o c o m m a n d s l i k e t h i s . F i r s t t y p e

L O A D " S E Q U E N T I A L F I L E " , 8t h e n w a i t f o t h R E A D Y p r o m p t , a n t y p e

S A V E " S E Q U E N T I A L F I L E " , 9

F A C T S A N F I L E S O D I S KP r o g r a m s a r u s e f u l e n o u g h , b u t l e t ' s f a c e i t w h a t y o u r e a l l y w a n t t h

c o m p u t e r t d i h a n d l e i n f o r m a t i o n — d a t a , f a c t s , f i g u r e s , n a m e s ,a d d r e s s e s , t i m e s , p l a c e s , q u a n t i t i e s , d e s c r i p t i o n s .

A n i n f o r m a t i o n t h a t c a b t y p e d c a n b e p u o d i s k . Y o c a s t o r e i u n d e r n a m e o t h d i r e c t o r y l i s t i n g a n b r i n g i o u t h r o u g h t h c o p u t e r t t h s c r e e n . Y o c a d i r e c t t h c o m p u t e r t w o r k o n i t m a n i p u l a ti n i a c c o r d i n g t p r o g r a m s t a t e m e n t s .

L i k e f i l e s i c a b i n e t , i n f o r m a t i o n o d i s k i a y o u r d i s p o s a l t o p u l lo u f o r e a d i n g , o t u s i p r o g r a m s i p l a c e o D A T A a n I N P U Ts t a t e m e n t s . H o w e v e r , t h c o m p u t e r n e e d s m o r e d e t a i l e d d i r e c t i o n s f o p u t t i n g i n f o r m a t i o n t h a t ' s n o t o r g a n i z e d a p r o g r a m o n d i s k , a n f o p u l l i n g t h a t i n f o r m a t i o n b a c k i n t o i t m e m o r y .

O n o t h p r o g r a m s o t h T E S T / D E M O d i s k h a n d l e s i n f o r m a t i o nf i l e s o d i s k . I h a t w f u n c t i o n a l p a r t s . O n p a r t d i r e c t s t h c o m p u t e r t p u k e y b o a r d i n f o r m a t i o n o a i n i t i a l i z e d d i s k ; t h o t h e r p a r t d i r e c t s i t r e a d i n f o r m a t i o n f r o m d i s k .

M o r e e l a b o r a t e p r o g r a m s , w h i c h d i r e c t t h c o m p u t e r i c o m p l e x

Page 108: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 108/148

9 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

m a n i p u l a t i o n s o f i n f o r m a t i o n f i l e s , a r c o m m e r c i a l l y a v a i l a b l e o p r e r ec o r d e d d i s k s . I s o i n c l i n e d , y o c a w r i t e s o m e y o u r s e l f b b u i l d i n g f r o mt h T E S T / D E M O d i s k f i l e p r o g r a m . I p r o v i d e s s e o c o m m a n d s t h a td i r e c t t h c o m p u t e r i i n f o r m a t i o n t r a n s f e r s .

I c a r r y i n g i n f o r m a t i o n f i l e s — a l s o k n o w n a t e x t f i l e s — t o a n d f r o md i s k , t h C o m m o d o r e 6 t r e a t s t h e m j u s t a i t r e a t s s t r i n g s o w o r d s i p r o g r a m . W h e t h e r y o d i r e c t n u m b e r s , w o r d s , c o m m a n d s , o d e c l a r at i o n s o e m o t i o n i n t o t h e s e t e x t f i l e s , t h c o m p u t e r w i l l t r e a t t h e m a s i p l g r o u p o c h a r a c t e r s .

Y o c a u s t h f i l e p r o g r a m w i t h o u t s t u d y i n g h o i w o r k s . Y o c a a l s o l i s t t h p r o g r a m a n d s t r i p a w a y a l b u t h e s s e n t i a l f i l e f e a t u r e s t f a s h i o n s t r e a m l i n e d s e q u e n c e o f i l e - h a n d l i n g s t a t e m e n t s . T h i s s e q u e n c ec a t h e n b e a d d e d t o t h e r p r o g r a m s f o m a n i p u l a t i n g i n f o r m a t i o n a n p e r h a p s m a k i n g n e f i l e s , i y o l i k e .

T h p r o g r a m t h a t d i r e c t s t h c o m p u t e r i f o r m i n g i n f o r m a t i o n f i l e s i l i s t e d o t h T E S T / D E M O d i s k a S E Q U E N T I A L F I L E . Y o c a u s i m o s t e a s i l y i y o f i r s t c o p y i o n t o d i s k y o u ' v e " i n i t i a l i z e d " w i t hm a g n e t i c a l l y - e t c h e d p a t t e r n . T h e n , w h e n y o c o m m a n d :

S E Q U E N T I A L F I L E

o

L O A D " S E Q U E N T I A L F I L E " , 8R U

t h c o m p u t e r c l e a r s t h e s c r e e n a n p r i n t s d e s c r i p t i o n s a n d i r e c t i o n s f o t h p r o g r a m ' s u s e . A t h i s p o i n t y o c a i g n o r e t h f i r s t c o u p l e o l i n e s a n f o l l o w t h d i r e c t i o n s a f t e r t h e m , E N T E R W O R D , C O M M A , N U B E R . I y o u w a n t t e n t e r , a f i r s t o t h l i s t , t h n a m e A M B R O S E a n t h n u m b e r 1 y o c a t h e n t y p e a f t e r t h p r o m p t A $ , B :

A M B R O S E Sa n t h e n s e n d i t t h c o m p u t e r b p r e s s i n g t h e R E T U R N k e y . Y o c a t h e n s e n d a n o t h e r n a m e a n n u m b e r s i m i l a r l y :

B R E T . 3 5 7

a n t h i r d n a m e a n n u m b e r :M A R K . 2

I y o u ' d l i k e t h l i s t t c o n t a i n j u s t t h e s e t h r e e i t e m s , y o c a s i g n a l t h

Page 109: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 109/148

H I G H S P E E D S T O R A G E — D I S K S 9

c o m p u t e r t o c l o s e t h l i s t w i t h t h e r e s p o n s e :E N

s e n t b p r e s s o t h R E T U R N k e y . p a i r o q u e s t i o n m a r k s w i l l a p p e a ra p r o m p t . I y o p r e s s t h e R E T U R N k e a g a i n , t h e c o m p u t e r , a c t i n gu n d e r t h S E Q U E N T I A L F I L E p r o g r a m ' s c o m m a n d s , w i l l t a k e i a s i g n a l t h a t y o u ' v e f i n i s h e d t h f i l e . F o l l o w i n g t h d i r e c t i o n s f r o m t h s e o n p a r t o t h i s p r o g r a m , t h C o m m o d o r e 6 w i l l p r i n t t h e l i n e , R E A DS E Q T E S T F I L E . A t h i s p o i n t , S E Q T E S T F I L E i t h n a m e t h p r g r a m h a g i v e n t t h l i s t o f i t e m s y o u ' v e t y p e d . F i n a l l y , t h c o m p u t e r w i l lp r i n t o n - s c r e e n t h l i s t o f i t e m s a n n u m b e r s .

Y o u ' l l f i n d , a f t e r r u n n i n g t h S E Q U E N T I A L F I L E p r o g r a m , t h a t t h c o m p u t e r h a a d d e d t h f i l e t t h e n o t h d i r e c t o r y l i s t i n g u n d e r t h n a m e S E Q T E S T F I L E . T h f i l e l i s t i n g a p p e a r s a s

" S E Q T E S T F I L E " S E T h f i l e i n f o r m a t i o n h a b e e n c o p i e d i t e m - b y - i t e m i n t o t h c o m p u t e r

f r o m t h d i s k , a t h o u g h i r e s p o n s e t k e y b o a r d t y p i n g a f t e r a I N P U Ts t a t e m e n t , a n i s t i l l p r e s e n t o t h d i s k .

Page 110: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 110/148

p r o g r a m c a h a v e a r a t h e r u n c e r t a i n e x i s t e n c e . I c a n b e r u r e p e a te d l y , p e r f o r m i n g t h s a m e f u n c t i o n e a c h t i m e , o a l t e r e d t o f i d i f f e r e n to c c a s i o n s . T h c l e v e r a n c r e a t i v e w a t u s y o u r c o m p u t e r i n o t w r i t e n e p r o g r a m f o e a c h n e p r o j e c t , b u r a t h e r t a d a p t a n b u i l df r o m p r o g r a m s a n p a r t s o p r o g r a m s t h a t h a v e p r o v e n t h e i r u s e f u l n e s s .H o m u c h e a s i e r i i t s t a r t w i t h g r o u p s o c o m m a n d s w h o s e e f f e c t s a r k n o w n t h a n t b e g i n e a c h p r o j e c t f a c i n g b l a n k s c r e e n !

A D D I N G P R O G R A M P A R T SY o c a d i r e c t t h C o m m o d o r e 6 t p i e c e t o g e t h e r p r o g r a m s ( o r p a r t s

o p r o g r a m s ) y o f i n d p a r t i c u l a r l y u s e f u l o i n t e r e s t i n g . P r o g r a m p a r t sc a n b e a d d e d w i t h i n t h c o m p u t e r ' s m e m o r y . Y o c a d t h i s e v e n i y o u n d e r s t a n d l i t t l e m o r e t h a n t h c o n n e c t i o n s a m o n g p r o g r a m s o p r o g r a mp a r t s . T c r e a t e y o u r o w s t y l e o p r o g r a m m i n g , y o c a c a l l o r e a d y -m a d e , o f t e n - u s e d s t a t e m e n t s e q u e n c e s . U s i n g s u c h a a p p r o a c h , y o c a t a k e s e q u e n c e s y o u ' r e c o n f i d e n t o f a n s p l i c e t h e m i n t o p r o g r a m y o ud e s i g n t t a k e a d v a n t a g e o e a c h p a r t .

F o e x a m p l e , t d i s p l a y n a m e a t h b o t t o m c e n t e r o t h s c r e e n , y o c a d i r e c t t h c o m p u t e r w i t h t h i s t w o - l i n e p r o g r a m :

N E 1 D A T A B O N A P A R T E T H E A M B I T I O U S

1 0 0 0 R E A D A $ P R I N T " ( p r e s s S H I F T a n C L R / H O M E ) " A $

Page 111: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 111/148

B U I L D I N G A N R E B U I L D I N G P R O G R A M S 9

Y o c a u s t h s c r e e n - c l e a r i n g , p o s i t i o n i n g a n p r i n t i n g f e a t u r e s o l i n e1 0 0 0 a g a i n , b d i r e c t i n g t h c o m p u t e r t c a r r y o u t h c o m m a n d s o t h a t

l i n e f o o t h e r n a m e s ( i . e . , o t h e r v a l u e s o A $ ) . T h p a i r o c o m m a n d s ,G O S U B a n R E T U R N , t h a t d i r e c t t h c o m p u t e r t l i n e 1 0 0 0 a n b a c kc a n b e a d d e d t t h p r o g r a m , w i t h t h e s e s t a t e m e n t s :

2 G O S U B 1 0 0 01 0 1 0 R E T U R N

t h i r d s t a t e m e n t , E N D , w i l l s t o p t h e c o m p u t e r f r o m a c t i n g o l i n e 1 0 0 0a g a i n . I c a b p l a c e d a n y w h e r e b e f o r e l i n e 1 0 0 0 , l i k e t h i s :

1 0 E N O e n c o u n t e r i n g t h G O S U B c o m m a n d , t h c o m p u t e r s k i p s a n i n t e rv e n i n g l i n e s o s t a t e m e n t s a n a c t s o l i n e 1 0 0 0 i m m e d i a t e l y . T h e n , i n o r m a l s e q u e n c e , i p e r f o r m s t h c o m m a n d s o a n l i n e s t h a t f o l l o w 1 0 0 0 .W h e n t h c o m p u t e r e n c o u n t e r s t h c o m m a n d R E T U R N , i t ' s d i r e c t e db a c k t o w a r d t h G O S U B s t a t e m e n t a n t h l i n e i m m e d i a t e l y a f t e r i t H a v i n g c a r r i e d o u t h c o m m a n d s b e t w e e n l i n e 1 0 0 0 a n t h R E T U R Ns t a t e m e n t , t h c o m p u t e r r e s u m e s t h s e q u e n c e a l i n e 1 0 0 , w h i c h d i r e c t s i t s t o p .

T h G O S U B c o m m a n d c a b t r a n s l a t e d a s " M a r k t h l i n e n u m b e ro t h i s s t a t e m e n t i y o u r m e m o r y , t h e n c a r r y o u t h c o m m a n d s b e g i nn i n g a t h l i n e n u m b e r i n d i c a t e d . " T h R E T U R N c o m m a n d t r a n s l a t e sa s " R e t u r n t t h m a r k e r m a d e b t h G O S U B c o m m a n d t h a t s e n t y o u ,a n t h e n c o n t i n u e a c t i o n w i t h t h n e x t l i n e n u m b e r f o l l o w i n g i t . "

U s i n g t h i s p a i r o c o m m a n d s , y o c a d i r e c t t h c o m p u t e r t a g r o u p o s t a t e m e n t s a n y w h e r e i t h p r o g r a m . T h G O S U B c o m m a n d c a b u s e d s e v e r a l t i m e s i p r o g r a m t d i r e c t t h c o m p u t e r t g r o u p o s t a t em e n t s , a i t h e f o l l o w i n g s e q u e n c e :

1 D A T A B O N A P A R T E T H A M B I T I O U S1 G O S U B 1 0 0 02 D A T A A L B E R T T H E U N D E R R A T E D2 G O S U B 1 0 0 03 D A T A M E L V I L L E T H M A G N I F I C E N T3 G O S U B 1 0 0 0

1 0 E N A e a c h p l a c e w h e r e i a p p e a r s , t h G O S U B 1 0 0 0 c o m m a n d d i r e c t s t h

c o m p u t e r t a c o l i n e 1 0 0 0 a n a n l i n e s t h a t f o l l o w i t T h R E T U R Ns t a t e m e n t d i r e c t s i b a c k t t h m a i n s e q u e n c e o D A T A a n G O S U B

Page 112: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 112/148

Page 113: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 113/148

B U I L D I N G A N R E B U I L D I N G P R O G R A M S 9

B e c a u s e i s e n d s t h c o m p u t e r t a n o t h e r l i n e n u m b e r , G O S U B c o m a n d c a b e u s e d w i t h i n o n s u b r o u t i n e t d i r e c t t h c o m p u t e r t a n o t h e r . I s u c h c a s e , t h c o m p u t e r w i l l p a s s t h r o u g h t h f i r s t g r o u p o c o m m a n d s t t h s e c o n d . E n c o u n t e r i n g t h R E T U R N c o m m a n d o t h s e c o n d g r o u p , i w i l l b s e n t b a c k t t h f i r s t g r o u p . W h e n i e n c o u n t e r st h R E T U R N c o m m a n d o t h f i r s t g r o u p , i w i l l b s e n t b a c k t t h m a i n p r o g r a m s e q u e n c e .

U s i n g t h G O S U B - R E T U R N c o m m a n d p a i r i t h i s w a y , y o c a a d s u b t l e t i e s a n c o m p l e x i t i e s t p r o g r a m s i s i m p l e , " m o d u l a r " f a s h i o n .F o e x a m p l e , y o c a e n h a n c e t h g r a p h i n g f e a t u r e o t h i s p r o g r a m b a d d i n g g r i d l i n e s a g a i n s t w h i c h t c o m p a r e e a c h o t h p l o t s . s e q u e n c eo c o m m a n d s t h a t w i l l d t h i s c o u l d b e g r o u p e d a t w s u b r o u t i n e s , o n t h a t d r a w s v e r t i c a l l i n e s s t a r t i n g a t l i n e 3 0 0 0 :

3 0 0 0 P R I N T " ( p r e s s C L R / H O M E ) ( p r e s s C U R S O R U P / D O W N ) "3 0 1 0 F O R V = 1 T O 2 03 0 2 0 F O = T 3 S T E P3 0 3 0 P R I N T T A B ( I ) " ( p r e s s C a n G ) ( p r e s s S H I F T a n C U R S O R

U P / D O W N ) ( p r e s s S H I F T a n C U R S O R U P / D O W N )( p r e s s S H I F T a n C U R S O R U P / D O W N ) "

3 0 4 0 N E X T I3 0 5 0 P R I N T3 0 6 0 N E X T V3 0 7 0 R E T U R N

a n a n o t h e r s e q u e n c e o c o m m a n d s t h a t d r a w s h o r i z o n t a l l i n e s a n n u m b e r s c a l e , s t a r t i n g a l i n e 4 0 0 0 :

4 0 0 0 P R I N T " ( p r e s s C L R / H O M E ) ( p r e s s C U R S O R U P / D O W N ) ( p r e s sC U R S O R U P / D O W N ) "

4 0 1 0 F O R Y 0 T O 2 0 S T E P 54 0 2 0 F O R X 3 T O 3 54 0 3 0 P R I N T 2 T A B ( X ) " ( p r e s s a n @ ( p r e s s S H I F T a n

C U R S O R U P / D O W N ) "4 0 4 0 N E X T X4 0 5 0 I Y 2 T H E N 4 0 7 04 0 6 0 F O S T 5 P R I N T : N E X T4 0 7 0 N E X T Y4 0 8 0 R E T U R N

Y o c a d i r e c t t h c o m p u t e r t d r a w t h g r i d , j u s t a f t e r i r e a d s t h e v a l u e s

Page 114: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 114/148

1 0 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

f r o m d i r e c t i o n s i n t h s u b r o u t i n e b e g i n n i n g a l i n e 1 0 0 0 , b a d d i n g t h i ss t a t e m e n t :

1 0 0 7 G O S U B 3 0 0 0 : G O S U B 4 0 0 0W h e n y o r u t h i s p r o g r a m , f i r s t t h e s c r e e n w i l l c l e a r a n t h n a m e" B O N A P A R T E T H A M B I T I O U S " w i l l a p p e a r a t h t o p . T h e n t h

c o m p u t e r w i l l d r a w g r i d l i n e s . N e x t i w i l l p l o t t h v a l u e s f r o m t h f i r s tD A T A s t a t e m e n t , a s h o w n i F i g u r e 9 . 1 . T h s c r e e n w i l l c l e a r a g a i n , a n t h p r o c e s s w i l l b e g i n f o t h e v a l u e s f r o m t h n e x t D A T A s t a t e m e n t . I w i l lc o n t i n u e u n t i l e a c h s e o v a l u e s f r o m t h e t h r e e D A T A s t a t e m e n t s h a b e e nh a n d l e d , a n t h c o m p u t e r s t o p s a t h l a s t d i s p l a y .

T h c o m p u t e r a c t s o G O S U B a n R E T U R N c o m m a n d s i p a i r s . I i e n c o u n t e r s R E T U R N s t a t e m e n t w i t h o u t h a v i n g f i r s t e n c o u n t e r e dG O S U B s t a t e m e n t , i w i l l f o l l o w i t b u i l t - i n d i r e c t i o n s t o s i g n a l y o w i t ha e r r o r m e s s a g e :

R E T U R N W I T H O U T G O S U B E R R O R I ( l i n e n u m b e r )T h i s p r o b l e m w o u l d r e s u l t f r o m t h c o m p u t e r ' s u s u a l p r o g r e s s t h r o u g hh i g h e r l i n e n u m b e r s t h i g h - n u m b e r e d s u b r o u t i n e . Y o c a a v o i d i b p u t t i n g a E N o S T O P s t a t e m e n t a f t e r t h m a i n s e q u e n c e b u b e f o r et h f i r s t o t h s u b r o u t i n e s t a t e m e n t s . I t h i s c a s e , w e ' v e p u a E N a l i n e 1 0 0 .

F i g u r e 9 . 1 : p l o t c r e a t e d b f o u r s u b r o u t i n e s .

Page 115: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 115/148

B U I L D I N G A N R E B U I L D I N G P R O G R A M S 1 0

L i k e t h G O T O c o m m a n d , G O S U B d i r e c t s t h c o m p u t e r t t h l i n en u m b e r l i s t e d i t h c o m m a n d . Y o u c a u s v a r i a t i o n o t h G O S U B -R E T U R N c o m m a n d p a i r t d i r e c t t h c o m p u t e r , i c o n d i t i o n a l w a y , i a n o u o t h m a i n s e q u e n c e o s t a t e m e n t s . J u s t a a O N - G O T O c o m a n d d i r e c t s t h c o m p u t e r t d e p a r t f r o m t h n o r m a l s e q u e n c e o c e r t a i nn u m e r i c c o n d i t i o n s , s o a O N - G O S U B c o m m a n d d i r e c t s t h c o m p u t e rt p a r t i c u l a r s u b r o u t i n e s . Y o c a u s t h i s c o m m a n d t o d i r e c t t h c o p u t e r t o n o s e v e r a l c o m m a n d g r o u p s , f r o m w h i c h i w i l l l a t e r b s e n tb a c k t r e s u m e t h m a i n s e q u e n c e a g a i n .

T h O N - G O S U B s t a t e m e n t c a b u s e d i t h p l o t t i n g p r o g r a m , f o i n s t a n c e , t s e l e c t i v e l y d r a w p a r t s o t h e g r i d p a t t e r n a g a i n s t w h i c h t h i n f o r m a t i o n w i l l b g r a p h e d . O n g r o u p o c o m m a n d s , l i k e t h o s e b e g i nn i n g a t l i n e 3 0 0 0 , c a d i r e c t t h c o m p u t e r t d r a w v e r t i c a l l i n e s . A n o t h e rg r o u p , l i k e t h o s e b e g i n n i n g a l i n e 4 0 0 0 , c a d i r e c t t h d r a w i n g o h o r iz o n t a l l i n e s .

B c h a n g i n g p r o g r a m l i n e 1 0 0 7 t s t a t e m e n t w h o s e d i r e c t i o n s t t h c o m p u t e r a r e c o n d i t i o n a l y o c a n , a c c o r d i n g t t h c h o i c e m a d e d u r i n ge a c h p r o g r a m r u n , e i t h e r u s o p a s s o v e r t h s u b r o u t i n e s b e g i n n i n g a 3 0 0 0 o 4 0 0 0 , o r n e o n a l i n e 5 0 0 0 . T h i s s u b r o u t i n e p r o d u c e s t h f u l lg r i d , b s e n d i n g t h c o m p u t e r t d r a w v e r t i c a l , t h e n h o r i z o n t a l , l i n e s .T h f u l l g r i d c o u l d b d r a w n t h r o u g h t h e s e s t a t e m e n t s :

5 0 0 0 G O S U B 4 0 0 05 0 1 0 G O S U B 3 0 0 05 0 2 0 R E T U R N

T h c o m m a n d t h a t s e n d s t h c o m p u t e r t e a c h o t h o s e s u b r o u t i n e s , o c e r t a i n v a l u e s o t h v a r i a b l e D i s

1 0 0 7 O G O S U B 3 0 0 0 , 4 0 0 0 , 5 0 0 0T h i s d i r e c t s t h c o m p u t e r l i k e t h O N - G O T O c o m m a n d , c o m p a r i n g t h v a l u e o f t h v a r i a b l e w i t h t h O N - G O S U B c o m m a n d ' s b u i l t - i n r a n g e s o v a l u e : o n o g r e a t e r b u l e s s t h a n t w o , a n s o n Y o c a i n s t r u c t t h c o m p u t e r t r e q u e s t t h e v a l u e o f D b a d d i n g p r o m p t a n d a n I N P U Ts t a t e m e n t , l i k e t h e s e :

1 0 0 5 P R I N T " P R E S S T H N U M B E R O T H D I S P L A Y Y O U ' D L I K E : "1 0 0 6 I N P U T " 1 - V E R T I C A L ; 2 - H O R I Z O N T A L ; 3 - F U L L G R I D " ; D

R u n n i n g t h p r o g r a m , y o u ' l l s e e t h I N P U T r e q u e s t a t h t o o t h s c r e e n . I c h o i c e i t h r a n g e 1 2 o i s e n t , t h c o m p u t e r w i l l f i r s td r a w t h g r a p h l i n e s a c c o r d i n g t c h o i c e , t h e n p l o t t h v a l u e s f r o m t h D A T A s t a t e m e n t . I c h o i c e o u t s i d e t h e r a n g e i t y p e d , t h e c o m p u t e r w i l l

Page 116: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 116/148

Page 117: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 117/148

B U I L D I N G A N R E B U I L D I N G P R O G R A M S 1 0

Y o n e e d n o u n d e r s t a n d a l t h d e t a i l s o t h p r o g r a m t m a k e u s o i a n i t p a r t s . F o i n s t a n c e , i y o l o o k a t h e n t i r e l i s t i n g o S E Q U E N T I A L F I L E , s c r e e n f u l a t i m e , y o c a s e t h a t t h p r g r a m i d i v i d e d i n t o f o u r p a r t s , e a c h s e p a r a t e d b t h n o t e s o f a g r o u p o R E s t a t e m e n t s .

T h f i r s t g r o u p o R E s t a t e m e n t s , n u m b e r e d t h r o u g h 6 d e s c r i b e st h f u n c t i o n o t h p r o g r a m t h a t f o l l o w s , A E X A M P L E R E A DW R I T E S E Q U E N T I A L D A T A F I L E . T h s t a t e m e n t s t h a t f o l l o wt h a t g r o u p o r e m a r k s , l i n e s 1 t h r o u g h 9 ( s h o w n i F i g u r e 9 . 2 ) , h o l dc o m m a n d s c o m m o n t b o t h f u n c t i o n s o t h p r o g r a m .

T h n e x t g r o u p o r e m a r k s , n u m b e r e d 1 0 t h r o u g h 1 0 5 , d e s c r i b e sr a t h e r t e r s e l y t h p a r t o f t h p r o g r a m t h a t d i r e c t s t h f o r m a t i o n o d i s kf i l e , W R I T E S E Q T E S T F I L E . T h o s e s t a t e m e n t s o c c u p y l i n e s 1 1 t h r o u g h 1 6 0 . ( S e e F i g u r e 9 . 3 . )

T h r e m a r k s f r o m l i n e s 2 0 t h r o u g h 2 0 d e s c r i b e t h s t a t e m e n t s , l i n e s2 0 t h r o u g h 4 2 0 , t h a t d i r e c t t h r e a d i n g i n t o t h c o m p u t e r o i n f o r m a t i o nf r o m t h f i l e , S E T E S T F I L E , p r o d u c e d b t h f i r s t h a l f o t h p r g r a m , R E A D S E Q T E S T F I L E . ( S e e F i g u r e 9 . 4 . )

F i n a l l y , t h n o t e s i l i n e s 1 0 0 0 t 1 0 0 6 d e s c r i b e s e q u e n c e o c o n t i ng e n c y c o m m a n d s i s u b r o u t i n e , s t a t e m e n t s 1 0 1 0 t h r o u g h 1 0 6 0 , t h a t w i l l

R E » E E X A M P L ER E R E A D W R I T ER E S E Q U E N T I A LR E D A T A F I L ER E a w * * * * * * * * * * * *1 P R I N T ' ^ i f c l M J I N I T I2 8 0 I M A $ < 2 5 >3 0 I M B < 2 5 )4 Q £ M L ,6 8 G Q S U B i t ) & 87 8 C R $ = C H R $ ( I 3 )8 8 P R I N T9 P K I N T 1 i L ! U R I T9 P R I N T U R I T E S E T E S T F I L E 1

F i g u r e 9 . 2 : T h s t a t e m e n t s o t h S E Q U E N T I A L F I L E p r o g r a m t h a t p r e p a r et h c o m p u t e r t h a n d l e f i l e .

Page 118: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 118/148

1 0 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

1 0 R E M x x x x x x x x x x x x x1 9 R E r t1 9 R E r t W R I T E S E 1 0 R E T E S T F I L E1 0 4 R E M1 0 R E x x x x x x x x x x x x x1 1 0 P E N 2 , 8 . 2 . i l 0 0 S E Q T E S T F I L E , S , W "1 1 G 0 S U 8 1 0 0 01 1 P R I N T " E N T E R W 0 R 0 . C O M t t h , M U M 8 E R '1 1 P R I H T M E N T E R W O R D ' £ * £ > ' T S T O P 1 '1 4 P R I H T t * 2 . A $ l l , I I S T R $ ( B ) C R $ ;1 4 G 0 S U 8 1 & 8 01 5 G O T O 1 2 1 6 C L O S E

F i g u r e 9 . 3 : T h s t a t e m e n t s o t h S E Q U E N T I A L F I L E p r o g r a m t h a t s e n di n f o r m a t i o n t d i s k f i l e .

R E R E R E » R E A D S E R E T E S T F I L ER E R E * * P R I N TP R I N T " R E A D S E Q T E S T F I L E "P R I N T0 P E H 2 , 8 . 2 " 8 : S E Q T E S T F I L E , S , R '2 R S = S T6 0 S U 8 1 8 8 9 P R I N T r t $ < I ) . B ( I )I F 6 T I 4 E N 3 8 I R S O 8 T H E N 4 3 81 G O T O 2 2 C L O S E

R E A O V

F i g u r e 9 . 4 : T h s t a t e m e n t s o t h S E Q U E N T I A L F I L E p r o g r a m t h a t t a k ei n f o r m a t i o n j r o m a d i s k f i l e .

Page 119: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 119/148

Page 120: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 120/148

1 0 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

1 0 8 8 R E x x x x x x x x x x x x1 8 8 1 R E M *1 8 8 2 R E R E A D1 8 8 3 R E T H E R R O R1 0 8 4 R E C H A N N E L1 0 8 5 R E M1 0 8 6 R E M x x x x x x x x x x x x1 0 1 8 I N P U T t t l 5 , E N . E H $ , E T , E S

1 1 H I S i a1 8 5 0 C L O S E1 8 6 0 E N R E f l O Y .

F i g u r e 9 . 5 : T h s t a t e m e n t s o t h S E Q U E N T I A L F I L E p r o g r a m t h a t a c t o d i s k p r o b l e m .

P R I N T s t a t e m e n t o f l i n e 1 0 a n t h r e m a r k s a n s p a c i n g o l i n e s 9 t h r o u g h 1 0 5 . ( K e e p i m i n d , h o w e v e r , t h a t y o o a n o t h e r u s e r m i g h tl a t e r a p p r e c i a t e h a v i n g t h R E l i n e s p r e s e r v e d . )

T h p r o g r a m t h a t r e m a i n s a f t e r t h i s t r i m m i n g w i l l d i r e c t t h c o m p u t e rt f o r m d i s k f i l e t h r o u g h y o u r i n t e r a c t i o n . I y o r u i m o r e t h a n o n c et c r e a t e d i f f e r e n t f i l e s , h o w e v e r , i w i l l g i v e e a c h s e o f d a t a t h s a m en a m e , S E Q T E S T F I L E . B a l t e r i n g t w s t a t e m e n t s , y o c a m o d i f y t h p r o g r a m t a s s i g n n a m e o y o u r c h o o s i n g t e a c h f i l e y o c r e a t e w i t h t h i sp r o g r a m .

A l i n e 1 1 i t h s t a t e m e n t t h a t n a m e s t h f i l e t b p u o d i s k . Y o c a m a k e i m o r e g e n e r a l b s i m p l y c h a n g i n g t h p a r t t h a t n a m e s t h f i l et v a r i a b l e . T d t h i s r e q u i r e s t h e k i n d o a d d i t i o n t h a t y o c a p e r f o r mo w o r d s t r i n g s u s i n g p l u s s i g n . U s i n g t h v a r i a b l e F t r e p r e s e n t t h f i l e n a m e , y o c a r e p l a c e l i n e 1 1 w i t h t h e s t a t e m e n t :

1 1 O P E N 2 , 8 , 2 , " @ 0 : " F " , S , W "

N o t h p r o g r a m d i r e c t s t h c o m p u t e r t g i v e e a c h f i l e t h n a m e a s s i g n e dt t h v a r i a b l e F $ Y o c a m a k e t h i s a s s i g n m e n t w h e n t h p r o g r a m i r u n , i y o i n c l u d e s t a t e m e n t t h a t a s k s y o f o f i l e n a m e . A I N P U T

Page 121: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 121/148

B U I L D I N G A N R E B U I L D I N G P R O G R A M S 1 0

s t a t e m e n t i p l a c e o t h P R I N T s t a t e m e n t o f l i n e 9 w o u l d d t h a t :

9 I N P U T " N A M E O F I L E T B M A D E " ; F

N o t h c o m p u t e r h o l d s v e r s a t i l e p r o g r a m t h a t c a c r e a t e d i s k f i l ea f t e r d i s k f i l e i r e s p o n s e t y o u r e n t r i e s , a n c a a s s i g n t e a c h d i f f e r e n tn a m e . U s i n g t h i s p r o g r a m y o u c a c r e a t e m a n y f i l e s , e a c h o w h i c h w i l lb l i s t e d b n a m e o t h d i r e c t o r y o t h d i s k i i s t o r e d o n

T h r e s u l t i n g p r o g r a m y o u ' l l s e o s e n d i n g t h c o m m a n d L I S T ( a s h o w n i F i g u r e 9 . 6 ) , i t r i m m e d a n t t h p o i n t . I w i l l d i r e c t t h c o p u t e r t a s y o f o t h n a m e o f i l e y o w i s h t p r o d u c e , a n t h e n ,t h r o u g h t h p r o m p t s o i t I N P U T s t a t e m e n t , w i l l c o l l e c t a n f i n a l l y s e n dt t h d i s k d r i v e t h e l e m e n t s y o s u p p l y f r o m t h k e y b o a r d .

Y o c a s a v e t h i s p r o g r a m a i i s b p u t t i n g i o d i s k o w h i c hy o u ' d l i k e t o s t o r e f i l e s . Y o m i g h t p u i t h e r e u n d e r t h n a m e M A K EF I L E , f o i n s t a n c e :

^ ■ M A K E F I L Eo

S A V E " M A K E F I L E " , 8

O t h e o t h e r h a n d , y o c a i n c l u d e t h i s p r o g r a m i l a r g e r p r o g r a m , i y o l i k e , o m a k e s o m e f u r t h e r a d j u s t m e n t s t i t

A i w a o r g i n a l l y w r i t t e n , t h e f i l e - h a n d i n g p r o g r a m r e s e r v e s s p a c e f o o n l y 2 e n t r i e s . L i n e s 2 0 a n 3 m a k e t h i s a l l o c a t i o n :

2 D I M A $ ( 2 5 )3 D I M B ( 2 5 )

Y o c a e x t e n d t h n u m b e r o e l e m e n t s t b p u i t h f i l e s y o c r e a t e , b m o d i f y i n g t h o s e s t a t e m e n t s t r e s e r v e m o r e s p a c e i c o m p u t e r m e m o r y . I y o w a n t e d t r e s e r v e r o o m f o 1 0 i t e m s , f o i n s t a n c e , y o c o u l d s i m p l ys e n d n e s t a t e m e n t s t r e s e r v e s p a c e :

2 D I M A $ ( 1 0 0 )3 D I B ( 1 0 0 )

L i k e w i s e , t h e f o r m a t o t h i t e m s e n t e r e d c a b e c h a n g e d b c h a n g i n gt h I N P U T s t a t e m e n t o f l i n e 1 2 t a c c e p t a n n u m b e r o i t e m s .

B t h s a m e t h o u g h t f u l t a i l o r i n g , y o c a p r o d u c e a f i l e - r e a d i n g p r g r a m f r o m a n o t h e r p a r t o t h S E Q U E N T I A L F I L E p r o g r a m . I t h i sc a s e , y o l o a d t h S E Q U E N T I A L F I L E p r o g r a m i n t o t h c o m p u t e r

Page 122: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 122/148

1 0 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

2 0 i t f A $ ( 2 5 )3 8 0 I K 8 C 2 5 )4 O P E N i S . a . I S / ' I O "6 G 0 S U 8 1 0 0 07 C R S = C H R > ( 1 3 )1 I N P U T M H r t h E O P I L E T O B E M A O E " ; F $I l i O O P E N 2 . 8 . 2 / l l i a : " F $ + I \ S , W ' iI f P R I H T - E N T E R r t H O R O . C O H H A . N U I « « -1 1 P R I H T " E « T E R W O R D ' t « 0 ' T S T O P 1 11 2 I H P U T l l r t $ i . 8 l l ; A $ J 81 4 P R I H T t t 2 , A $ " , l l S T R $ ( B ) C R $ ;

F i g u r e 9 . 6 : t a i l o r e d f i l e - w r i t i n g p r o g r a m , d e r i v e d f r o m t h S E Q U E N T I A LF I L E d i s k p r o g r a m .

5 G O T O 1 2 1 8 C L O S E1 7 E H 1 8 8 0 R E m x 1 0 1 8 I N P U T H I0 3 P R I N T 1 '1 0 4 8 P R I M T E

[ 1 0 ' S O C L O S E1 0 6 0 E N ■ E A D Y .

[ E R R O R O D I S K 1$ ; E T ; E S

F i g u r e 9 . 6 , c o n t i n u e d .

Page 123: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 123/148

B U I L D I N G A N R E B U I L D I N G P R O G R A M S 1 0

m e m o r y a n b e g i n t r i m m i n g i t t h a t s i n g l e f u n c t i o n . A g a i n , l i n e st h r o u g h 1 c a b d r o p p e d :

1

L i n e s 7 0 t h r o u g h 2 0 6 , w h i c h d i r e c t f i l e f o r m a t i o n , c a a l s o b d r o p p e d :

7 8

2 0

S t a t e m e n t s 1 0 0 1 t h r o u g h 1 0 0 6 , w h i c h a r s i m p l y r e m a r k s , c a b d r o p p e d a e x c e s s b a g g a g e , t o o :

1 0 0 11 0 0 21 0 0 31 0 0 41 0 0 51 0 0 6

A i s t a n d s n o t h p r o g r a m w i l l d i r e c t t h c o m p u t e r t f i n d a n r e a di n t o m e m o r y t h i t e m s f r o m f i l e o d i s k , n a m e d S E Q T E S T F I L E . B c h a n g i n g t w s t a t e m e n t s , y o c a t a i l o r t h p r o g r a m t a s y o f o t h f i l en a m e , a n d t h e n t f i n d t h a t f i l e b y n a m e . T h l i n e t h a t d i r e c t s t h c o p u t e r t s e a r c h t h f i l e f o S E Q T E S T F I L E , l i n e 2 1 0 , c a b c h a n g e d s a t o d i r e c t i t s e a r c h o u f i l e o a n n a m e , s t o r e d u n d e r t h v a r i a b l eF $ l i k e t h i s :

2 1 O P E N 2 , 8 , 2 , " 0 : " F " , S , R "

Y o c a d i r e c t t h c o m p u t e r t a s y o f o f i l e n a m e , w i t h t h e s t a t e m e n t :2 0 I N P U T " N A M E O F I L E T B F O U N D " ; F

T h p r o g r a m n o i m e m o r y ( F i g u r e 9 . 7 ) w i l l s e a r c h d i s k f o t h f i l e

Page 124: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 124/148

Page 125: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 125/148

Page 126: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 126/148

T t h p e r s o n w h h a g a i n e d f a c i l i t y i u s i n g p r o g r a m s a n c o m a n d s , t h c o m p u t e r i n o t h u n m a n a g e a b l e c o n t r a p t i o n i o f t e n f i r s ta p p e a r e d . E v e n t h o u g h b l e a r n i n g t c o n t r o l t h C o m m o d o r e 6 y o c a g a i n a u n d e r s t a n d i n g o t h l o g i c b e h i n d t h m a c h i n e , m a n y o i t p o s s ib i l i t i e s l i b u r i e d i i t m e m o r y a n d e s i g n . T h e r e a r w a y s t h e s e s e c r e t sc a b u n c o v e r e d ; y o c a g f u r t h e r i n t o t h c o m p u t e r w i t h o u t f i n d i n gy o u r s e l f e l b o w - d e e p i m i c r o c h i p s a n t a n g l e d w i r e s . M o r e c o m m a n d sw i l l l e a d y o i n t o t h m a z e o n u m b e r c o d e s t h a t d i r e c t t h c o m p u t e r . A a s s o r t m e n t o e x t r a c i r c u i t r y w i l l m a k e t h C o m m o d o r e 6 i n t o s o m e t h i n gm o r e t h a n t h m a c h i n e i w a b u i l t t o b e . A n l o o k i n s i d e w i l l r e v e a l t h g u t s o p e r s o n a l c o m p u t e r u n d r e a m e d o j u s t f e y e a r s a g o .

S T E P P A S T T H T R A N S L A T O RT h c o m p u t e r ' s t r a n s l a t o r a c t s a b r i d g e b e t w e e n y o u a n d t h p r o c e s s o r ,

w h i c h d i r e c t s t h f l o w o i n f o r m a t i o n t h r o u g h t h c o m p u t e r ' s c i r c u i t s .T h e s e c i r c u i t s a r e t c h e d o m i c r o c h i p s , l i k e t h o n s h o w n i F i g u r e1 0 . 1 . T h p r o c e s s o r a n t h i n f o r m a t i o n r e s e r v o i r s ( t h e " m e m o r y c h i p s " )s i q u i t e a p a r t f r o m e a c h o t h e r i t h c o m p u t e r . T h c o m p u t e r ' s m e m o r yh a b e e n o r g a n i z e d s t h a t e a c h p i e c e o i n f o r m a t i o n i s t o r e d a c c o r d i n g t

n u m b e r , w h i c h r e p r e s e n t s t h e l o c a t i o n o t h a t d a t a . A l t h o u g h t h p r c e s s o r m a c h a n g e t h i n f o r m a t i o n i m e m o r y l o c a t i o n , t h a t n u m b e r e dl o c a t i o n c o n t i n u e s t e x i s t , r e g a r d l e s s o t h v a l u e c o n t a i n e d i i t — a f i x e da d d r e s s w i t h c h a n g i n g t e n a n t s .

Page 127: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 127/148

T H I N S I D E S T O R Y 1 1

' ■ ■ ' ■ ~ W ; - " ~ f m P l

f t : , ,S t

j R g w n e i 0 2 < 4 e n c a s e d m i c r o c h i p o t h t y p e u s e d i a l m i c r o c o m p u t e r s .

T h P E E K a n P O K E C o m m a n d sA l t h o u g h i e x p e c t s c o m m a n d s i t h c o m p u t e r l a n g u a g e B A S I C , t h

c o m p u t e r c a a l s o b d i r e c t e d t i n t e r n a l a d d r e s s e s . Y o c a a l t e r t h c o m p u t e r ' s a u t o m a t i c r e s p o n s e s b c h a n g i n g n u m e r i c v a l u e s i n t h e s el o c a t i o n s . O n c o m m a n d w i l l d i r e c t v a l u e s i n t o m e m o r y l o c a t i o n s , c i c u m v e n t i n g t h u s u a l t r a n s l a t i n g p r o c e s s .

D e v e l o p i n g a m a s t e r y o t h c o m p u t e r ' s o w n u m e r i c l a n g u a g e i s t u d y , d e m a n d i n g a n t e d i o u s , t w h i c h o t h e r b o o k s a r d e v o t e d . U n l e s sy o h a v e p a s s i o n f o g i v i n g y o u r c o m p u t e r d i r e c t i o n s t h a t g b e y o n dl a n g u a g e c o m m a n d s l i k e t h o s e i B A S I C , i t ' s s t u d y n o t r e c o m m e n d e d .

T h c o m p u t e r ' s n u m e r i c l a n g u a g e i a l s o e x p r e s s e d i a v o c a b u l a r y o c h a r a c t e r c o d e s , c o n s i s t i n g o n u m b e r s a n d l e t t e r s . T h e s e c o d e s c a r e p r es e n t e v e r y p o s s i b l e m e m o r y l o c a t i o n a n v a l u e i t h u s a b l e m e m o r y o t h C o m m o d o r e 6 4 I t h i s n u m e r i c l a n g u a g e , y o c a s e n d t h c o p u t e r t p a r t i c u l a r m e m o r y l o c a t i o n , A 6 5 E f o e x a m p l e , w h e r e s e o d i r e c t i o n s f o t h S H I F T - H O M E k e y s t r o k e c o m m a n d t e l l t h c o m p u t e rt c l e a r t h s c r e e n a n p o s i t i o n t h c u r s o r .

P r o g r a m s o t h e s e e n c o d e d d i r e c t i o n s c a f o r m s e e m i n g l y e n d l e s sl i s t s t h a t b l u r t h e v i s i o n a n d u l l t h e w i t s o a l b u t h m o s t d e t e r m i n e d

Page 128: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 128/148

1 1 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

e n t h u s i a s t s . T h i s s y s t e m o n o t a t i o n i k n o w n a h e x a d e c i m a l .F o r t u n a t e l y , t h e r e i a e a s i e r w a y . T h e r e i c o m m a n d a v a i l a b l e i n

B A S I C t h a t u s e s t h m o r e f a m i l i a r d e c i m a l n u m b e r s . Y o c a u s i t c h a n g e t h c o m p u t e r ' s b u i l t - i n d r e c t i o n s t o t h e r d i r e c t i o n s y o s p e c i f y .T h i s c o m m a n d i P O K E , w h i c h s e n d s t h c o m p u t e r t n u m b e r e d l o c at i o n , w h e r e t h n u m e r i c v a l u e y o d i r e c t i c h a n g e d .

T s e h o t h c o m m a n d c a b u s e f u l , c o n s i d e r a n e x a m p l e o c h a n g i n g t h s c r e e n d i s p l a y . T h C o m m o d o r e 6 a u t o m a t i c a l l y p r i n t sc h a r a c t e r s i l i g h t b l u e o a d a r k b l u e b a c k g r o u n d s u r r o u n d e d b l i g h tb l u e b o r d e r . T h i s s c r e e n d i s p l a y i d e t e r m i n e d b v a l u e s c o p i e d i n t o t h a c t i v e m e m o r y f r o m t h b u i l t - i n u n c h a n g i n g m e m o r y e v e r y t i m e y o t u r n t h p o w e r o n B c h a n g i n g t h e v a l u e s i n t h e s e a c t i v e m e m o r y l o c at i o n s , y o c a c h a n g e t h e p r i n t i n g p a t t e r n o t h s c r e e n . O n l o c a t i o n s e t st h e c o l o r o t h w i n d o w , a n o t h e r t h c o l o r o t h b o r d e r .

T h c o m p u t e r f o l l o w s i t o w b u i l t - i n d i r e c t i o n s i n s e t t i n g t h b a c kg r o u n d a n b o r d e r c o l o r s . B c h a n g i n g t h o s e d i r e c t i o n s , y o c a f o r md i s p l a y s o a n c o l o r c o m b i n a t i o n s . T d t h a t , y o c a u s t h P O K Ec o m m a n d , w h i c h s l i p s p a s t t h e t r a n s l a t o r t t a l k m o r e d i r e c t l y w i t h t h p r o c e s s o r . Y o c a c o m m a n d t h p r o c e s s o r t s e n e c o l o r f o t h b a c kg r o u n d b d i r e c t i n g i t p u a n o t h e r v a l u e i m e m o r y l o c a t i o n 5 3 2 8 1 ,w h e r e s c r e e n c o l o r v a l u e f o d a r k b l u e i a u t o m a t i c a l l y s t o r e d . I f y o w a n t t h c o l o r t b b l a c k , c o d e n u m b e r 0 y o c a u s t h c o m m a n d :

P O K E 5 3 2 8 1 , 0T h i s P O K E c o m m a n d t r a n s l a t e s a s " S e e k o u m e m o r y l o c a t i o n n u m b e r5 3 2 8 1 a n s t o r e t h v a l u e o f a t h a t a d d r e s s . "

Y o c a l i k e w i s e d i r e c t t h e p r o c e s s o r t s e t h b o r d e r o t h e d i s p l a y t b l a c k . T h p r o c e s s o r l o o k s f o r d i r e c t i o n s f o r t h i s p a r t o t h d i s p l a y a m e m o r y a d d r e s s n u m b e r 5 3 2 8 0 . Y o c a u s t h c o m m a n d :

P O K E 5 3 2 8 0 , 0I c o m b i n a t i o n , t h e s e t w c o m m a n d s a n t h v a l u e s w i t h i n t h e m

( b a c k g r o u n d c o l o r 0 a n b o r d e r c o l o r 0 d i r e c t t h c o m p u t e r t p r e s e n tb l a c k b a c k g r o u n d f o t h e n t i r e s c r e e n . T h e y l e y o e f f e c t i v e l y s e i z e c o t r o l f r o m t h b u i l t - i n a u t o m a t i c d i r e c t i o n s , a n s s w i t c h t h e c o m p u t e ri n t o m o d e o f o p e r a t i o n t a i l o r e d t o y o u r s p e c i a l n e e d s . A n o f t h e C o m o d o r e 6 4 ' s 6 5 , 5 3 6 a v a i l a b l e m e m o r y l o c a t i o n s w i l l b o p e n e d b t h P O K E c o m m a n d f o y o u r n e v a l u e s .

A t o o l f o r " c u s t o m i z i n g " a n r e p l a n n i n g t h c o m p u t e r ' s p e r f o r m a n c e ,t h P O K E c o m m a n d i p r o g r a m g i v e s y o a b s o l u t e c o n t r o l , d i r e c t i n g t h c o m p u t e r t c a r r y o u c h a n g e s b e f o r e a d v a n c i n g t t h n e x t l i n e .

Page 129: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 129/148

T H I N S I D E S T O R Y 1 1

Y o c a u s t h P E E K c o m m a n d , w h i c h w d i s c u s s e d i C h a p t e r 6 t l o o k a t h v a l u e i a n m e m o r y l o c a t i o n . I w i l l d i r e c t t h c o m p u t e r f i r s tt s e e k t h n u m b e r e d a d d r e s s y o h a v e g i v e n , a s t h P O K E c o m m a n dd o e s , b u t h e n t e x a m i n e t h v a l u e t h e r e a n l e a v e i u n c h a n g e d . T h v a l u e c a t h e n b e u s e d a p a r t o s o m e o t h e r c o m m a n d . F o e x a m p l e , t h c o m p u t e r f i n d s t h e p a d d l e - p o s i t i o n v a l u e s a m e m o r y l o c a t i o n s 5 4 2 9 7 a n 5 4 2 9 8 , s s t a t e m e n t l i k e :

P R I N T P E E K ( 5 4 2 9 7 ) T A B ( 2 0 ) P E E K ( 5 4 2 9 8 )w i l l d i s p l a y t h e s e v a l u e s o s c r e e n . T h i s c o m b i n a t i o n o c o m m a n d s d i r e c t st h c o m p u t e r i t w s t a g e s , o n c o m m a n d a f t e r t h o t h e r . T h P E E Kc o m m a n d s s e n d t h p r o c e s s o r t f i n d t h e v a l u e s , w h i c h t h P R I N T c o m a n d t h e n d i s p l a y s .

Y o w i l l f i n d t h e P E E K c o m m a n d m o s t u s e f u l i y o b e c o m e f a m i l i a rw i t h t h m e m o r y l o c a t i o n s u s e d b t h p r o c e s s o r t s t o r e d i r e c t i o n s . A t h c o m p u t e r i s e n t c o m m a n d s t c a r r y o u t , t h e v a l u e s i m e m o r y l o c at i o n s c h a n g e . W i t h t h P E E K c o m m a n d , y o c a s e w h a t t h o s e v a l u e sa r a a n p o i n t , o r u s e t h e m t f u r t h e r d i r e c t t h c o m p u t e r .

S o m e m e m o r y l o c a t i o n s h o l d t w v a l u e s i n s t e a d o j u s t o n e . F o t h e s el o c a t i o n s , m o r e c o m p l e x f o r m o t h P E E K c o m m a n d i n e e d e d , t p r o n v a l u e f r o m a n o t h e r . T h e s e m o r e c o m p l e x f o r m s r e q u i r e d e t a i l e dk n o w l e d g e o t h o r g a n i z a t i o n o t h m e m o r y , a n w w o n ' t d i s c u s s t h e mh e r e .

Y o c a a l s o u s t h m e m o r y - i n v a d i n g P O K E a n P E E K c o m m a n d sw i t h i n p r o g r a m s , a y o u w o u l d o t h e r c o m m a n d s .

T h S Y C o m m a n dA n o t h e r c o m m a n d , S Y S , s e n d s t h c o m p u t e r t s p e c i f i c m e m o r y l o c a

t i o n s , w h e r e i f i n d s t h e d i r e c t i o n s t h a t m a k e e a c h B A S I C c o m m a n dw o r k . F o i n s t a n c e , t h e d i r e c t i o n s f o t h k e y s t r o k e c o m m a n d R U S T O P - R E S T O R E b e g i n a l o c a t i o n A 6 5 E . Y o c a s e n d t h c o m p u t e rt t h a t l o c a t i o n , w h e r e i w i l l b e g i n c a r r y i n g o u t t h o s e d i r e c t i o n s , w i t h t h c o m m a n d :

S Y S A 6 5 ED r i v e n b S Y c o m m a n d , t h c o m p u t e r w i l l g t o d i r e c t i o n s a a n

l o c a t i o n i i t m e m o r y . A t s o m e o t h e s e a r e a u t o m a t i c a l l y s t o r e d t h e l i t t l en u m e r i c s u b r o u t i n e s t h a t s e r v e a s d i r e c t i o n s f o o t h e r B A S I C c o m m a n d s .Y o c a s t o r e y o u r o w m a c h i n e - l a n g u a g e r o u t i n e s a o t h e r s . I f y o d t h a t , k e e p i m i n d t h a t t h a d d r e s s m a r k s t h b e g i n n i n g o r o u t i n e . I f w i t h

Page 130: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 130/148

1 1 T H E A S Y G U I D E T O Y O U R C O M M O D O R E 6

S Y s t a t e m e n t , y o s e n d t h c o m p u t e r t a a d d r e s s i t h m i d d l e o o n o t h e s e s e q u e n c e s o d i r e c t i o n s , t h r e s u l t s m a b m a n g l e d . B u a f t e r g a i n i n gs o m e f a m i l i a r i t y w i t h t h e s e l o c a t i o n s , y o c a a v o i d s u c h s u r p r i s e s .

W H A T I T H C O M M O D O R E 6 4 T h C o m m o d o r e 6 i b a s e d o C o m m o d o r e ' s l a t e s t v e r s i o n o o n o

t h e m i c r o c i r c u i t r y c h i p s t h a t l a u n c h e d t h p e r s o n a l c o m p u t e r . T h c i r c u i tt h a t g i v e s t h C o m m o d o r e 6 i t o p e r a t i n g c h a r a c t e r i t h 6 5 1 0 p r o c e s s o r .T h 6 5 1 0 i d i r e c t e d b s a m e b u i l t - i n i n s t r u c t i o n s a s i t p r e d e c e s s o r , t h 6 5 0 2 , p r o c e s s o r c h i p f o u n d i t h e a r l i e r V I C - 2 0 , A p p l e I I a n A t a r ic o m p u t e r s .

I f a c t , t h s a m e p r o g r a m s w r i t t e n i t h B A S I C c o m p u t e r l a n g u a g ef o t h V I C - 2 0 c a b u s e d i t h C o m m o d o r e 6 4 p r o v i d e d t h e y d o n ' tr e f e r t h r o u g h P O K E , P E E K , a n S Y c o m m a n d s t t h d i f f e r e n t m e o r a d d r e s s e s i e a c h , o t d i f f e r e n c e s i s c r e e n d i s p l a y ( t h e V I C - 2 0 h a s c r e e n 2 c o l u m n s w i d e b 2 r o w s d e e p ) . F u r t h e r m o r e , s i n c e t h B A S I Cl a n g u a g e c o n s i s t s o e s s e n t i a l l y t h s a m e e l e m e n t s i n d i f f e r e n t c o m p u t e r s ,p r o g r a m s w r i t t e n f o o n c o m p u t e r c a s o m e t i m e s b e a d a p t e d s o a s t b u s e d i n a n o t h e r .

A p r o c e s s o r a n i n t e r n a l f o r e m a n , t h 6 5 1 0 c h i p c o n t r o l s t h e f l o w o fi n f o r m a t i o n t h r o u g h t h e o t h e r c h i p s . s i n g l e c i r c u i t - b o a r d h o l d s m o s t o t h e l e c t r o n i c s i t h C o m m o d o r e 6 4 O t h i s b o a r d s i e i g h t o t h e r c h i p s ,a p a r t f r o m t h p r o c e s s o r , a s s h o w n i F i g u r e 1 0 . 2 . E a c h o t h e s e c h i p sh o l d s 8 1 9 2 ( o 8 K l o c a t i o n s o m e m o r y , w h i c h c a b e i t h e r o c c u p i e d o e m p t y a c c o r d i n g t t h e p r o c e s s o r ' s d i r e c t i o n s . T h e s e e i g h t c h i p s t o g e t h e rh o l d t h C o m m o d o r e 6 4 ' s t o t a l a d j u s t a b l e m e m o r y o 6 5 , 5 3 6 , o 6 4 l o c a t i o n s .

T w o t h e r c h i p s i n t h i s c o m p u t e r e a c h p e r f o r m s p e c i a l t a s k s . T o n e ,t h V I c h i p , i g i v e n t h d u t y o h a n d l i n g f i n e - p o i n t g r a p h i c s a n p r g r a m m e d i l l u s t r a t i o n s , k n o w n a " s p r i t e s . " T h e s e s p r i t e s , o n c e s t o r e d i t h c o m p u t e r ' s m e m o r y , c a b p o s i t i o n e d a n y w h e r e o t h s c r e e n a n m a d e t o i n t e r a c t w i t h e a c h o t h e r . A n o t h e r c h i p h a n d l e s t h p r o d u c t i o n o s o u n d b t h c o m p u t e r ; w i t h i t s y n t h e s i z e d m u s i c a n s o u n d e f f e c t s c a b c r e a t e d .

T m a k e u s e o f e i t h e r o t h e s e c h i p s r e q u i r e s e i t h e r e l a b o r a t e p r o g r a mm i n g o m e m o r y l o c a t i o n s o t h u s o c o m m e r c i a l l y p r e p a r e d p r o g r a m s

Page 131: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 131/148

T H I N S I D E S T O R Y 1 1

F i g u r e 1 0 . 2 : T h p r o c e s s o r a n m e m o r y o t h C o m m o d o r e 6 4

t h a t t r a n s l a t e s i m p l i f i e d k e y b o a r d c o m m a n d s o p a d d l e o j o y s t i c k m o v em e n t s i n t o c h a n g e s i t h e s e m e m o r y l o c a t i o n s .

E X P A N D I N G T H C O M P U T E RY o u r C o m m o d o r e 6 w a s n ' t f i n i s h e d a t h f a c t o r y . L o o k a t h e m p t y

c o n n e c t o r s l o t , s o c k e t s , a n c a r d a t h b a c k a n p o w e r - s w i t c h s i d e , a n y o u ' l l s e t h i s . Y o c a f i n i s h c o n s t r u c t i o n b a d d i n g c i r c u i t r y c a r t r i d g e sa n p l u g g i n g i c a b l e s u n t i l t h m a c h i n e b e f o r e y o m o r e c l o s e l y m a t c h e sy o u r n e e d s .

S o m e o t h c a r t r i d g e s — c o n t a i n i n g " c a r d s " p a c k e d w i t h e l e c t r o n i c s —c a c h a n g e t h w a y o u r C o m m o d o r e 6 w o r k s . O n c r o w d s 8 0 c h a r a ct e r s o f t y p e o v i d e o s c r e e n w h e r e o n l y 4 w o u l d f i b e f o r e . A n o t h e rc a r t r i d g e a d d s a d i f f e r e n t p r o c e s s o r a n i t a t t e n d a n t c h i p s , a n s g r a f t ss e c o n d c o m p u t e r i n t o t h e t h e C o m m o d o r e 6 4 S t i l l a n o t h e r s e n d s i n f o rm a t i o n a n p r o g r a m s o u f r o m t h c o m p u t e r i n t o t e l e p h o n e l i n e s a n d i t a n t r e c e i v e r s . S o m e c a b l e s a n c i r c u i t r y r o u t e t h s c r e e n d i s p l a y t p r i n t e r s , w h i c h c a t u r n t h v i d e o s c r e e n i m a g e s i n t o p r i n t o p a p e r .

A n d , o c o u r s e , t h e r e a r e g a m e c a r t r i d g e s .T h e q u i p m e n t y o a d t t h c o m p u t e r c a n b e c o m b i n e d t p r o d u c e a

c o m p u t e r s y s t e m o y o u r o w p r e f e r e n c e . T h 8 0 - c o l u m n c a r t r i d g e i o n o s e v e r a l l i n k s t w o r d p r o c e s s i n g , p u f f e d - u p p h r a s e t h a t s i m p l y m e a n sm o v i n g w o r d s a r o u n d i a c o m p u t e r ' s m e m o r y , i n s t e a d o o s h e e t o p a p e r .

A n o t h e r l i n k i t h c h a i n , s e o d i r e c t i o n s f o w o r d - p r o c e s s i n g c o m a n d s , c o m e s m o s t c o n v e n i e n t l y o d i s k i t h f o r m o c o m m e r c i a l l y

Page 132: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 132/148

1 1 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

a v a i l a b l e w o r d - p r o c e s s i n g p r o g r a m s . I t h w o r d s s p r o c e s s e d a r t e v e n t u a l l y t a k e p h y s i c a l f o r m a i n o p a p e r , p r i n t e r w i l l b a t h e n o t h c h a i n . T h l i n k t h a t c o m p l e t e s t h c o n n e c t i o n b e t w e e n p r i n t e r a n c o m p u t e r t a k e s t h e f o r m o c a b l e — a n d , d e p e n d i n g o t h p r i n t e r , a e x t r a b i o c i r c u i t r y a t t a c h e d t t h a t c a b l e . T h e s e c i r c u i t s a c t a s g a t e w a y sb e t w e e n p r i n t e r a n c o m p u t e r .

T h C o m m o d o r e 6 o p e r a t e s u n d e r t h d i r e c t i o n s b u i l t i n t o i t 6 5 1 0p r o c e s s o r c h i p , b t a k i n g c o m m a n d s a n p r o g r a m s t h a t " s p e a k t o t h a tc h i p . A n o t h e r p r o c e s s o r c h i p , t h p o p u l a r Z 8 0 , h a b e e n w e l l p r o v i d e dw i t h a v a i l a b l e p r o g r a m s . B p l u g g i n g i c a r t r i d g e c o n t a i n i n g t h Z 8 a n i t e n t o u r a g e o c i r c u i t s , y o c a p u s e c o n d p r o c e s s o r i n t o t h C o m m o d o r e 6 4 T h i s o n c a u s t h C o m m o d o r e 6 4 ' s m e m o r y a n c a t a k e c o m m a n d s f r o m t h k e y b o a r d o d i s k . C o m m o d o r e 6 s e q u i p p e d c a n b e s w i t c h e d b a c k a n f o r t h b e t w e e n t h r e s i d e n t 6 5 1 0 c h i pa n t h Z 8 c h i p , t o r u p r o g r a m s w r i t t e n f o e i t h e r p r o c e s s o r . I e f f e c t ,y o u ' l l b s w i t c h i n g b e t w e e n t w c o m p u t e r s i o n b o x .

T h 6 5 1 0 c h i p p r o c e s s e s c o m m a n d s a n i n f o r m a t i o n a c c o r d i n g t d i r e c t i o n s c o n t a i n e d i t h C o m m o d o r e 6 4 ' s p e r m a n e n t m e m o r y .A n o t h e r s e o d i r e c t i o n s f o c o n t r o l l i n g p r o c e s s o r s ( k n o w n a a " o p e r a ti n s y s t e m " ) i o f t e n f e d i n t o c h i p s t h a t a c c e p t i t l i k e t h Z 8 0 , f r o m d i s k .T h i s s y s t e m i k n o w n b t h a c r o n y m C P / M ® a n d , a t o o l f o c o n t r o ll i n g t h p r o c e s s o r ' s o p e r a t i o n , h a b e c o m e v e r y p o p u l a r . I f a c t , m a n yp r o g r a m s w r i t t e n o d i f f e r e n t m a c h i n e s u s i n g t h C P / M o p e r a t i n g s y t e a r t r a n s f e r a b l e f r o m o n t y p e o c o m p u t e r t a n o t h e r w i t h n o f e r e v i s i o n s . W i t h Z 8 c a r t r i d g e i n s t a l l e d i t h C o m m o d o r e 6 4 y o c a l o a d C P / M i n t o t h c o m p u t e r . F o t h C o m m o d o r e 6 4 C P / M i p a c ka g e d a c a r d c o n t a i n i n g Z 8 c h i p , a l o n g w i t h d i s k e t t e .

A n o t h e r c a r t r i d g e , t h m o d e m , p l u g s i n t o t h C o m m o d o r e 6 a n f o r m s l i n k t t e l e p h o n e l i n e s . W i t h m o d e m i n s t a l l e d , y o u r c o m p u t e rb e c o m e s a e l e c t r o n i c t e l e t y p e , c o n n e c t i n g y o t p e o p l e a n d a t a b a n k si w a y s t h a t w e r e o n c e t h e e x c l u s i v e p r i v i l e g e o l a r g e c o r p o r a t i o n s a n g o v e r n m e n t s .

P e r h a p s t h m o s t p r o m i s i n g f e a t u r e o p e r s o n a l c o m p u t e r l i k e t h C o m m o d o r e 6 4 h o w e v e r , i t h a d a p t a b i l i t y o i t m a s t e r t o t h p o s s i b i l i t i e so t h i s n e w l y - a r r i v e d t o o l . T h c o m p u t e r i m e a n s t a e n d ; o n c ey o u ' v e l e a r n e d t o d i r e c t i t y o c a u s i a a e x t e n s i o n o f y o u r o w i n t e r e s t s a n i d e a s . Y o n e e d n o s t u d y t h e l e c t r o n i c s o l o g i c o t h c h i p st h a t d i r e c t t h m a c h i n e t r e a l i z e y o u r o w c a p a b i l i t i e s i u s i n g i t R a t h e r ,y o w i l l a d o n c a p a b i l i t y t a n o t h e r , t b u i l d t r u l y p e r s o n a l c o m p u t e rs y s t e m , o n t h a t i d i r e c t e d b y o u r o w h u m a n i n t e l l i g e n c e .

Page 133: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 133/148

Page 134: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 134/148

T h b u i l t - i n v o c a b u l a r y o t h C o m m o d o r e 6 i n c l u d e s c o m m a n d s o m o r e s p e c i a l i z e d u s e f u l n e s s t h a n t h o s e p r e s e n t e d i t h p r e c e d i n g c h a pt e r s . T h e s e c o m m a n d s m o s t l y i n v o l v e m a t h e m a t i c s a n n u m b e r t r e a tm e n t . M a n y o t h e m a r g r o u p e d b e l o w a c c o r d i n g t f u n c t i o n . A u n d e r l i n e i n d i c a t e s w h e r e y o c a ( a n d u s u a l l y m u s t ) i n c l u d e n u m b e ro v a r i a b l e i e a c h c o m m a n d .

M a t h e m a t i c a l a n T r i g o n o m e t r i cA B ) T u r n s n e g a t i v e n u m b e r p o s i t i v e , l e a v e s p o s i t i v e n u m b e ru n c h a n g e d .A T ) G i v e s t h t r i g o n o m e t r i c v a l u e a r c t a n g e n t o f n u m b e rg i v e n i r a d i a n s .C O ) G i v e s t h t r i g o n o m e t r i c v a l u e c o s i n e o n u m b e r g i v e n i r a d i a n s .E X ) G i v e s t h v a l u e o e 2 . 7 1 8 2 8 1 8 , r a i s e d t t h p o w e r o n u m b e r .I N ) G i v e s t h v a l u e o r o u n d i n g d o w n t t h e n e a r e s t i n t e g e rn u m b e r .

L O ) G i v e s t h l o g a r i t h m o n u m b e r .R N ) G i v e s a r a n d o m v a l u e b e t w e e n a n 1 . 0 , r e g a r d l e s s o n u m b e r .

Page 135: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 135/148

A P P E N D I X A S P E C I A L P U R P O S E C O M M A N D S 1 2

S G ) G i v e s t h s i g n o n u m b e r : i n u m b e r i n e g a t i v e ,i p o s i t i v e , i 0

S I ) G i v e s t h t r i g o n o m e t r i c v a l u e s i n e o n u m b e r g i v e n i r a d i a n s .S Q ) G i v e s t h s q u a r e r o o t o n u m b e r .T A ) G i v e s t h t r i g o n o m e t r i c v a l u e t a n g e n t o f n u m b e r g i v e ni r a d i a n s .

R a i s e s t h n u m b e r b e f o r e i t t h p o w e r o t h n u m b e ra f t e r i t

M u l t i p l i e s t h n u m b e r b e f o r e i b 1 t t h p o w e r o t h n u m b e r a f t e r i t

F ) G i v e s n u m b e r a c c o r d i n g t t h m a t h e m a t i c a l r e l a t i o ne s t a b l i s h e d w i t h D E c o m m a n d . S e D E F N F Z ( A ) , F Z ( B )a n F Z ( 5 ) , f o e x a m p l e , e a c h c a l l o t h s a m e r e l a t i o n s e a F

D E F F N D e f i n e s f u n c t i o n ; t h a t i s i e s t a b l i s h e s m a t he m a t i c a l e q u i v a l e n c e b e t w e e n t h v a r i a b l e i p a r e n t h e s e s a n t h m a t h e m a t i c r e l a t i o n a f t e r t h e q u a l s i g n . F o e x a m p l e , D E F X ( A ) + e s t a b l i s h e s f u n c t i o n F X ) w h i c h a d d s t h v a l u eo t t h v a l u e o v a r i a b l e i p a r e n t h e s e s .

C o m p a r i s o n sC o m p a r i s o n o p e r a t o r s p r o d u c e v a l u e s t h a t c o r r e s p o n d t t h t r u t h o

f a l s e h o o d o t h s t a t e m e n t m a d e w i t h t h e m . W h e n t h s t a t e m e n t i t r u e ,v a l u e o f i g i v e n ; w h e n i t ' s f a l s e , v a l u e o f 0 A t h e i r n a m e i m p l i e s , t h k i n d o f s t a t e m e n t t h e s e o p e r a t o r s m a k e i a l w a y s c o m p a r i s o n o v a l u e s .

( G r e a t e r t h a n ) G i v e s v a l u e o f i t h n u m b e r b e f o r e i i g r e a t e r t h a n t h n u m b e r a f t e r i t i o t h e r w i s e .

( L e s s t h a n ) G i v e s v a l u e o f i t h n u m b e r b e f o r e i i l e s st h a n t h n u m b e r a f t e r i t i o t h e r w i s e .

( E q u a l t o G i v e s v a l u e o f i t h n u m b e r b e f o r e i i t h s a m e a t h n u m b e r a f t e r i t i o t h e r w i s e .

< o ( N o t e q u a l t o G i v e s a v a l u e o f i t h n u m b e r b e f o r e i i n o t h s a m e a t h n u m b e r a f t e r i t i i t i s .

Page 136: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 136/148

1 2 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

o ( G r e a t e r t h a n o r e q u a l t o G i v e s v a l u e o fi t h n u m b e r b e f o r e i i g r e a t e r t h a n o r e q u a l t t h n u m b e r a f t e r

i t i i i s l e s s .o ( L e s s t h a n o r e q u a l t o G i v e s v a l u e o i

t h n u m b e r b e f o r e i i l e s s t h a n o r e q u a l t t h n u m b e r a f t e r i t i i t ' sg r e a t e r .

L o g i c ( B o o l e a n )_ A N D _ : G i v e s v a l u e o i t h n u m b e r o r e l a t i o n b e f o r e i a n t h o n a f t e r i a r b o t h g r e a t e r t h a n 0 i o n i 0 _ O R _ : G i v e s v a l u e o i e i t h e r t h n u m b e r o r e l a t i o n b e f o r e i o t h o n a f t e r i i a n t h o t h e r i o 0 i t h e y a r b o t h 0 N O T _ : G i v e s v a l u e e q u a l t t h n u m b e r o r e l a t i o n p l u s 1 m u l t ip l i e d b 1

O t h e rA S ( " ) G i v e s c o d e n u m b e r , c a l l e d t h A S C I I c o d e , f o t h f i r s t c h a r a c t e r o t h s t r i n g o c h a r a c t e r s .C L R : " C l e a r s " a l t h v a r i a b l e s i p r o g r a m ; r e p l a c e s t h e i r v a l u e sw i t h O .S T R $ D i r e c t s t h c o m p u t e r t t r e a t n u m b e r a s t r i n g c h a r a ct e r , i n s t e a d o n u m e r i c v a l u e .V A $ D i r e c t s t h c o m p u t e r t t r e a t n u m e r i c s t r i n g c h a r a c t e r a a n u m b e r .

Page 137: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 137/148

J a r g o n i t h c u r s e o t h s p e c i a l i z e d , a n e v e r y s p e c i a l t y h a i t j a r g o n .Y o w i l l e n c o u n t e r c o m p u t e r j a r g o n a m o n g e n t h u s i a s t s , s a l e s p e o p l e , a n p r o g r a m m e r s . J a r g o n s p e a k e r s , w h a r o f t e n m o r e k n o w l e d g e a b l e , c a p r o v i d e u s e f u l i n f o r m a t i o n n o o b t a i n a b l e f r o m s p e a k e r s o t h m o t h e rt o n g u e . T h p h r a s e g u i d e t h a t f o l l o w s c a h e l p i m a k i n g t h e i r d i a l e c ti n t e l l i g i b l e .A p p l i c a t i o n s p r o g r a m : s e o c o m m a n d s , u s u a l l y a v a i l a b l e o d i s k ,t h a t d i r e c t s t h c o m p u t e r i p e r f o r m i n g s o m e t a s k w h o s e r e s u l t s a p p e a r i

r e c o g n i z a b l e f o r m o u t s i d e t h e c o m p u t e r ' s m e m o r y .B a c k - u p : N o d i r e c t i o n s g i v e n t t r u c k d r i v e r , b u c o p y k e p t i c a s et h i t e m i u s s h o u l d f a i l . b a c k - u p c o p y o d i s k c a b k e p t , o b a c ku c o p y o f i l e o p r o g r a m c a b k e p t i a n o t h e r f o r m o o t h s a m ed i s k .B i t : N o t h e p a s t t e n s e o b i t e , b u t h s m a l l e s t p i e c e o i n f o r m a t i o n t h c o m p u t e r c a h a n d l e . b i a l w a y s h a s v a l u e o e i t h e r o 1 B o o t D i s k : N o a a c o a g g r a v a t i o n , b u t h a c o s e n d i n g d i r e c t i o n st h a t o p e r a t e d i s k s y s t e m i n t o t h c o m p u t e r f r o m d i s k i d r i v e . ( Y o ub o o t t h e d i s k b e f o r e s e n d i n g d i s k c o m m a n d s t t h c o m p u t e r . )B o o t D O S : S e B o o t D i s k .B u f f e r : s p e c i a l l y c o n t r o l l e d m e m o r y t h a t w i l l h o l d d a t a o c o m m a n d sb e i n g m o v e d b e t w e e n t h c o m p u t e r a n o t h e r e l e c t r o n i c d e v i c e s . I t ' s u s f u w h e n t h r a t e o f f l o w o u o o n i g r e a t e r t h a n t h r a t e i n t o t h o t h e r ,

Page 138: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 138/148

1 2 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

l i k e r e s e r v o i r c o l l e c t i n g r i v e r ' s w a t e r s f a s t e r t h a n i l e t s t h e m t h r o u g hf l o o d g a t e s .B u g : N o c r a w l i n g s i x - l e g g e d c r e a t u r e , b u a n y u n p l a n n e d r e s p o n s et h a t i n t e r f e r e s w i t h t h e x p e c t e d o p e r a t i o n o m a c h i n e . T h t e r m u s u a l l yr e f e r s t a u n p l a n n e d c o m m a n d p r o b l e m w i t h i n c o m p u t e r p r o g r a m .B y t e : T h b a s i c p a c k a g e o i n f o r m a t i o n s e n t t h r o u g h t h c o m p u t e r c i c u i t s , i w h i c h e a c h o e i g h t b i t s h a v a l u e o e i t h e r o 1 E a c h m e m o r yl o c a t i o n i n t h C o m m o d o r e 6 h o l d s o n b y t e .C O B O L : p r o g r a m m i n g l a n g u a g e i w i d e s p r e a d u s i b u s i n e s s s i n c eb e f o r e t h r i s e o s m a l l e r , p e r s o n a l c o m p u t e r s .C o p y - p r o t e c t e d : D e s c r i b e s p r o g r a m o n d i s k t h a t i n c l u d e s d i r e c t i o n sd e s i g n e d t t h w a r t a n e f f o r t s t c o p y t h a t p r o g r a m o n t o a n o t h e r d i s k .C P U : C e n t r a l P r o c e s s i n g U n i t , t h p r o c e s s o r i t h c o m p u t e r .C r a s h : I n p r o g r a m r u n , w h a t h a p p e n s w h e n t h c o m p u t e r s t o p s a c i n o n p r o g r a m c o m m a n d s s u d d e n l y , i a n u n p l a n n e d w a y , u s u a l l yb e c a u s e o d i r e c t i o n s t h c o m p u t e r c a n ' t f o l l o w .

D a t a - b a s e M a n a g e r : N o b a s e b a l l c o a c h , b u p r o g r a m t h a t o r g a n i z e si n f o r m a t i o n a c c o r d i n g t p r e s e t p l a n .D e f a u l t ( " d e a r B r u t u s , l i e s n o i o u s t a r s b u i n o u r s e l v e s " ) : T h a tv a l u e c h o s e n a u t o m a t i c a l l y b t h c o m p u t e r w h e n c h o i c e i n o m a d e b t h c o m p u t e r u s e r .

E n t e r : T s e n d d a t a o i n s t r u c t i o n s i n t o t h c o m p u t e r , u s u a l l y f r o m t h k e y b o a r d , a n f o l l o w e d b s u b s e q u e n t p r e s s o t h R E T U R N k e y .

E r r o r : A n y c o m m a n d o d a t a g i v e n t t h c o m p u t e r t h a t i i i n c a p a b l eo a c t i n g o n E s c a p e S e q u e n c e : T h u s e o f k e y b o a r d t y p i n g t s t o p t h e r u n n i n g o p r o g r a m o p a r t o p r o g r a m .F a t a l C r a s h : c r a s h t h a t r e s u l t s i t h l o s s o p r o g r a m c o m m a n d s o v a l u a b l e i n f o r m a t i o n f r o m c o m p u t e r m e m o r y .F i r m w a r e : T h o s e d i r e c t i o n s s t o r e d i b u i l t - i n m e m o r y t h a t c a n ' t b c h a n g e d f r o m t h k e y b o a r d . ( C o m p a r e w i t h h a r d w a r e a n s o f t w a r e . )F o r m a t : T e t c h m a g n e t i c p a t t e r n o n t o d i s k , s t h a t p r o g r a m s a n d a t a c a b s t o r e d o i t

Page 139: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 139/148

A P P E N D I X B J A R G O N P H R A S E G U I D E 1 2

F O R T R A N : c o m p u t e r p r o g r a m m i n g l a n g u a g e u s e d b s c i e n t i s t sa n e n g i n e e r s s i n c e t h d a y s o p u n c h c a r d s .F u n c t i o n : c o m m a n d t h a t m a n i p u l a t e s v a l u e s , o f t e n i s o m e u n s e e nw a y . T h c o m m a n d s 4 - * a n r e p r e s e n t a r i t h m e t i c f u n c t i o n s .H a r d w a r e : T h p h y s i c a l p a r t s o c o m p u t e r s y s t e m , a o p p o s e d t t h d i r e c t i o n s a n v a l u e s s t o r e d i n i t ( C o m p a r e w i t h f i r m w a r e a n s o f t w a r e . )H e x : N o w i t c h ' s c u r s e , b u a a b b r e v i a t i o n f o h e x a d e c i m a l , w a o r e p r e s e n t i n g n u m b e r s b h y b r i d o t h f i r s t s i ( h e n c e h e x ) l e t t e r s o t h a l p h a b e t a n t h t e ( h e n c e d e c i m a l ) n u m e r a l s .H i g h - l e v e l L a n g u a g e : N o t h K i n g ' s E n g l i s h , b u s e o c o m m a n d st h a t d i r e c t t h c o m p u t e r i r e l a t i v e l y c o m p l i c a t e d w a y s t p e r f o r m c o p l e x t a s k w i t h s i n g l e c o m m a n d . B A S I C i h i g h - l e v e l l a n g u a g e .H o u s e k e e p i n g : N o d u s t i n g a n m o p p i n g , b u t h c h o r e s d o n e b t h c o m p u t e r u s e r , o t h c o m p u t e r i t s e l f , t o p e r a t e s y s t e m o p r o g r a m .I n i t i a l i z e : T f o r m a t a d i s k a n a d d a n i n i t i a l p r o g r a m o c o m m a n d st h a t w i l l b a u t o m a t i c a l l y r u b t h c o m p u t e r w h e n t h e d i s k i f i r s ts c a n n e d .I n s t r u c t i o n : A n c o m m a n d o d i r e c t i o n g i v e n t t h c o m p u t e r .I n t e r f a c e : A a n o u n , t h c i r c u i t r y t h a t s e r v e s a s e l e c t r o n i c c o n n e c t i o n t t h c o m p u t e r , o r m e t h o d o c o m m a n d s t h a t c o n n e c t s d i f f e r e n t l o g i c s y st e m s . A v e r b , t c o n n e c t .I / O : T h f l o w o d a t a o c o m m a n d s t a n f r o m t h c o m p u t e r , f r o mI n p u t / O u t p u t .K W h e n r e f e r r i n g t t h n u m b e r o m e m o r y l o c a t i o n s , a a m o u n tr o u g h l y e q u a l t a t h o u s a n d ( i t s e x a c t v a l u e i 1 0 2 4 ) . 6 i e q u a l t 6 5 , 5 3 6 .L o g o : p r o g r a m m i n g l a n g u a g e d e s i g n e d f o e a s e o f u s e a n l e a r n i n g ,o f t e n c h i l d ' s i n t r o d u c t i o n t c o m p u t e r s .L o o p : s e r i e s o c o m m a n d s t h r o u g h w h i c h c o m p u t e r i d i r e c t e dr e p e a t e d l y .L o w - l e v e l L a n g u a g e : N o l o c k e r r o o m t a l k , b u s e o c o m m a n d s t h a td i r e c t t h c o m p u t e r i r e l a t i v e l y u n s o p h i s t i c a t e d w a y s , r e q u i r i n g s e v e r a lc o m m a n d s t d i r e c t c o m p l e x t a s k .M a c h i n e l a n g u a g e : T h c o d e s f o m e m o r y l o c a t i o n s p a r t i c u l a r t a n c o m p u t e r .

Page 140: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 140/148

1 2 T H E A S Y G U I D E T Y O U R C O M M O D O R E 6

M e n u : N o s e l e c t i o n o e n t r e e s a r e s t a u r a n t , b u l i s t o c h o i c e sg i v e n i p r o g r a m , f r o m w h i c h i t u s e r s e l e c t s d i f f e r e n t o p e r a t i o n s . P r g r a m s u s i n g t h e m a r c a l l e d m e n u - d r i v e n .M i c r o c o m p u t e r : c o m p u t e r b u i l t a r o u n d m i c r o p r o c e s s o r . T h C o m o d o r e 6 i m i c r o c o m p u t e r .M i c r o p r o c e s s o r : T h e l e c t r o n i c c i r c u i t r y c h i p t h a t c o n t r o l s t h r e s t o t h c o m p u t e r . T h 6 5 1 0 c h i p i t h C o m m o d o r e 6 c o m p u t e r ' s m i c r o p r oc e s s o r .

M i n i - F l o p p y D i s k e t t e : T h f o r m a l n a m e f o t h t y p e o d i s k , V i n c h e sa c r o s s a n f l e x i b l e , u s e d w i t h t h C o m m o d o r e 6 a n m o s t o t h e r p e r s o n a lc o m p u t e r s .

M M U : ( M e m o r y M a n a g e m e n t U n i t ) T h p a r t o t h c o m p u t e r t h a to r g a n i z e s t h f l o w o f i n f o r m a t i o n i n t o d i f f e r e n t p a r t s o m e m o r y a c c o r di n t p r e s e t p a t t e r n .M o d e m : d e v i c e t h a t c o u p l e s c o m p u t e r t t e l e p h o n e l i n e s .P a r a l l e l : T r a v e l l i n g c o n c u r r e n t l y , a s i n t h w a d a t a o c o m m a n di m p u l s e s c a b s e n t f r o m a c o m p u t e r t h r o u g h s e o p a r a l l e l w i r e s .( C o n t r a s t w i t h s e r i a l . )P a s c a l : c o m p u t e r p r o g r a m m i n g l a n g u a g e t h a t i p a r t i c u l a r l y p o p u l a ri a c a d e m i c c i r c l e s .P B o a r d : ( P r i n t e d - C i r c u i t B o a r d ) h a r d p l a s t i c o f i b e r b o a r d o w h i c h s t r i p s o b o n d e d f o i l s e r v e a e l e c t r i c a l p a t h w a y s i p l a c e o w i r e s ,a n o w h i c h e l e c t r o n i c s a r s e a t e d .P e r i p h e r a l : A n d e v i c e a t t a c h e d t c o m p u t e r t h a t c o n t r o l s i t o i c o t r o l l e d b i t

P i x e l : N o m i n c i n g d w a r f , b u t h s m a l l e s t d o c o m p u t e r c a c o n t r o lo v i d e o s c r e e n .P o w e r f u l L a n g u a g e : N o e p i t h e t s , b u s e o c o m m a n d s , e a c h o w h i c hc a g i v e d i r e c t i o n s t h a t w o u l d r e q u i r e s e v e r a l c o m m a n d s i " w e a k e r "l a n g u a g e .P o w e r f u l P r o g r a m : p r o g r a m t h a t d o e s l o w i t h l i t t l e p r o m p t i n g o c o n t r o l b i t u s e r .

R A M : A a c r o n y m f o R a n d o m - A c c e s s M e m o r y , t h c o m p u t e r m e o r l o c a t i o n s w h o s e v a l u e s c a n b e c h a n g e d f r o m t h k e y b o a r d .

Page 141: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 141/148

A P P E N D I X B J A R G O N P H R A S E G U I D E 1 2

R e a d : T d r a w i n f o r m a t i o n f r o m a n e n c o d e d f o r m , s u c h a d i s k .R e t u r n V a l u e : W h a t t h c o m p u t e r d o e s w h e n i d i s p l a y s , o s c r e e n o p r i n t e r , n u m b e r s o c h a r a c t e r s i r e s p o n s e t c o m m a n d s .R O M : A a c r o n y m f o R e a d - O n l y M e m o r y , t h c o m p u t e r m e m o r yl o c a t i o n s w i t h v a l u e s f i x e d i n m a n u f a c t u r e . I p r o v i d e s a l t h c o m p u t e r ' sb u i l t - i n d i r e c t i o n s .S e r i a l : O n a f t e r a n o t h e r , a s i n t h w a d a t a o r c o m m a n d i m p u l s e s c a b s e n t f r o m c o m p u t e r t h r o u g h a s i n g l e w i r e . ( C o n t r a s t w i t h p a r a l l e l . )S o f t w a r e : T h d i r e c t i o n s , s u c h a t h o s e a v a i l a b l e a s p r o g r a m s o d i s k ,t h a t c a n b e a d d e d t a n d r e m o v e d f r o m t h c o m p u t e r s y s t e m , a o p p o s e dt i t p h y s i c a l , f i x e d p a r t s . ( C o m p a r e \ A \ h f i r r n x v a x e a n d h a r d w a r e . )S p r e a d s h e e t : N o b e l i n e n h a n g i n g t o d r y , b u v i s u a l s y s t e m o o r g an i z i n g a n c a l c u l a t i n g d a t a , o f t e n b u s i n e s s o f i n a n c i a l , i n r o w s a n c o l u m n s . S e v e r a l s u c h s y s t e m s a r a v a i l a b l e a p r o g r a m s o d i s k s .U t i l i t y : N o t h g a c o m p a n y , b u t a p r o g r a m t h a t d i r e c t s t h c o m p u t e ri p e r f o r m i n g s o m e i n t e r n a l t a s k , l i k e m o v i n g d a t a a b o u t i t m e m o r y .W r i t e : T p u i n f o r m a t i o n i f o r m i w h i c h i c a b s t o r e d a n t h e n

r e t r i e v e d , a s i n t w r i t e t d i s k .W r i t e - e n a b l e N o t c h : s e c t i o n o t h e d i s k e n v e l o p e t h a t , w h e n u n c o v

e r e d , a l l o w s t h e d i s k d r i v e t a d o a l t e r i n f o r m a t i o n o t h d i s k .W r i t e - p r o t e c t i o n : T h p h y s i c a l f e a t u r e o d i s k t h a t p r e v e n t s i f r o m

h a v i n g i n f o r m a t i o n a d d e d o a l t e r e d . T h a b s e n c e o f o r t a p i n g o v e r o f n o t c h o t h e d i s k e n v e l o p e r e s u l t s i w r i t e - p r o t e c t i o n .

Page 142: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 142/148

I N D E XA d d i n g i n f o r m a t i o n t p r o g r a m s ,

5 7 - 6 3A d d i n g p r o g r a m p a r t s , 9 6 - 1 0 2A d d i n g s t r i n g s , 5 1 - 5 2A l t e r i n g d i s k p r o g r a m s , 1 0 2 - 1 1 1A n i m a t i o n , 4 8A r i t h m e t i c , 1 3 - 1 4A s s i g n m e n t c o m m a n d s , 2 3 - 2 4A u t o m a t i n g d e c i s i o n m a k i n g , 2 9 - 3 1

B A S I C , 1 1 B l a n k s t a t e m e n t , 2

C a t a l o g , 9 C a s s e t t e t a p e s , 7 3 - 7 8C h a n g i n g m o d e s ,C h i p s , m i c r o c i r c u i t r y , 1 1 C l e a r i n g t h s c r e e n , 1 0 - 1 1C l o c k , 6 C o m m a n d s

a s s i g n m e n t , 2 c o n d i t i o n a l , 2 d i r e c t ,

d i s p l a yc o m m a , 1

s e m i c o l o n , 1 k e y p r e s s , 1 - m a c h i n e l a n g u a g e , 1 1 p r e r e c o r d e d ,s e r i e s o f 2 7 - 2 8

C o n d i t i o n a l c o m m a n d , 2 I F - T H E N , 2

C o n n e c t i n g s e c o n d d r i v e , 9 C o n n e c t i o n s , c o m p u t e r t t e l e v i s i o n ,

2 - C o u n t i n g s t r i n g l e n g t h s , 5 2 - 5 3C P / M , 1 1

o p e r a t i n g s y s t e m , 1 1 C - 6 4 W E D G E d i s k c o m m a n d s , 8

C u r s o r , 5 - C u t t i n g s t r i n g s , 5 3 - 5 7

D A T A , 5 7 - 6 2D a t a b a n k s , 1 1 D e c i m a l c o d e , 1 1 D e c i s i o n m a k i n g , a u t o m a t i n g , 2 9 - 3 1D e l a y ( t i m e ) , 4 8 - 4 9D I M , 6 2 - 6 3D i s k s , 7

f o r m a t t i n g o f 8 i n i t i a l i z i n g o f 8 i n s e r t i n g , 8 p r e r e c o r d e d , 8 p r o g r a m s , a l t e r i n g o f 1 0 2 - 1 1 1T E S T / D E M O , 8 4 8 v u l n e r a b i l i t y o f 8 2 - 8 3

D i s k c o m m a n d s , 8 3 - 8 4C - 6 4 W E D G E , 8 % , 8 7t , 8 7D e l e t e ( @ S : ) , 9 S a v e , 8

D i s k d r i v e , 7 9 - 8 1D i s k p r o g r a m , e r a s i n g o f 9 D i s k s y s t e m , 7 9 - 8 1D r a w i n g a r r o w s , 4 3 - 4 9D r i v e h e a d , m a g n e t i c , 8 3

E l e c t r o n i c c o m b i n a t i o n l o c k , 6 9 - 7 1E m p t y l o o p , 5 E N D , 9 E r a s i n g c o m m a n d s , 2 1 2 E r a s i n g a d i s k p r o g r a m , 9 0

F i l es e q u e n t i a l , 9 4 - 9 5 , 1 0

F i l e , c o n t .t e x t , 9

F o r m a t t i n g d i s k , 8 F O R - N E X T l o o p , 4 3 - 4 9

n e s t e d , 4

G E T , 6 7 - 6 8

Page 143: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 143/148

1 2 G O S U B , 9 6 - 1 0 1G O T O , 4 0 - 4 1G r i d , 1

I n f o r m a t i o n , a d d i n g t f i l e s , 5 7 - 6 3I n f o r m a t i o n ( t e x t ) f i l e s , 9 4 - 9 5I n i t i a l i z i n g d i s k , 8 I n p u t , 6 4 - 6 6I n p u t l o o p , s t o p p i n g o f 6 I n t e r a c t i v e p r o g r a m , 6 6

K e y b o a r d , 4 8 - K e y s

a r r o w ,r e t u r n , 6 R U S T O P ,C O N T R O L ,R E S T O R E ,C L R H O M E , 7 - I N S T D E L , 7 - S H I F T , 6 - S H I F T L O C K , 6 - C = , 6 - 7

L E F T S , 5 3 - 5 4L E N , 5 L i n e e d i t i n g , 1 L I S T , 2 0L O A D o r ( / ) , 8 4L o o p

F O R - N E X T , 4 3 - 4 9n e s t e d , 4 i n p u t , s t o p p i n g o f 6

L o w e r c a s e ,

M a c h i n e l a n g u a g e c o m m a n d s , 1 1 M a g n e t i c d r i v e h e a d , 8 M e m o r y , 2 8 1 1 4 - 1 6

l o c a t i o n s , 1 1 M i c r o c i r c u i t r y c h i p s , 1 1 M I D $ , 5 5 - 5 7M o d e s , c h a n g i n g o f

N a m e l e n g t h , 8

N e s t e d F O R - T O - N E X T l o o p s , 4 N E W , 2 N u m b e r i n g , 2 N u m b e r s u b s t i t u t e s , 2 3 - 2 4N u m e r i c m o d e l , 2 5

O N - G O T O , 4 1 - 4 2O u t s i d e c o n t a c t , 6

P a d d l e u s e , 6 9 - 7 2d r a w i n g , 7 1 - 7 2

P E E K , 1 1 P R I N T , 1 4 - 1 7P r o c e s s o r , 1 1 P r o g r a m , 8 -

i n t e r a c t i v e , 6 l i n e s , r e p l a c i n g o f 2 p a r t s , a d d i n g o f 9 6 - 1 0 2r e m o v i n g o f 2 r e n a m i n g o f 9 r e s t a r t i n g , 3 s l o w i n g o f 4 s t o p p i n g o f 3 7 - 4 0

P r o g r a m b u i l d i n g , 9 P r o g r a m m e r ' s c o m m a n d s

C O N T , 3 R E M , 3 5 - 3 7S T O P , 3 7 - 3 9P r o m p t , R e a d y ,P O K E , 1 1

P o w e r t t h c o m p u t e r , 1 - P u n c t u a t i o n a s d i s p l a y c o m m a n d s

c o m m a , 1 s e m i c o l o n , 1 8

R E A D , 5 7 - 6 2R e m o v i n g p r o g r a m s , 2 3R E N A M E , 9 R e n a m i n g p r o g r a m s , 9 R e p e a t i n g w i t h i n l i m i t s , 4 R e p l a c i n g p r o g r a m l i n e s , 2 R e s e r v i n g s p a c e f o r v a r i a b l e s , 6 2 - 6 3R e s t a r t i n g p r o g r a m , 3 R e t u r n , 6

Page 144: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 144/148

1 3

R e u s i n g v a r i a b l e s , 6 R e v e r s e v i d e o , 1 2R I G H T S , 5 4 - 5 5R U N , 2 0 - 2 1

S c r e e nc l e a r i n g o f 1 0 - 1 1c o n t r o l , 1

S E Q U E N T I A L F I L E p r o g r a m ,9 4 - 9 5 , 1 0

S e r i e s o c o m m a n d s , 2 7 - 2 8S l o w i n g p r o g r a m , 4 0S t o p p i n g p r o g r a m , 3 7 - 3 9S t o p p i n g a i n p u t l o o p , 6 S t r i n g s , 5 0 - 5 2

a d d i n g s t r i n g s , 5 1 - 5 2c o u n t i n g s t r i n g l e n g t h s , 5 2 - 5 3c u t t i n g s t r i n g s , 5 3 - 5 7s e a r c h i n g f o r , 8

S u b r o u t i n e s , 9 S u b s c r i p t e d v a r i a b l e s , 6 0 - 6 3S w i t c h b o x ,S y n t a x e r r o r ,S Y S , 1 1 5 - 1 1 6

T a b , 1 6 , 1 8T E S T / D E M O d i s k , 8 4 8 5 - 8 7T e x t f i l e s , 9 4 - 9 5T i m e d e l a y , 4 8 - 4 9T r a n s l a t o r ,

U p p e r c a s e ,

V a r i a b l e , 2 r e s e r v i n g s p a c e f o r , 6 2 - 6 3r e u s i n g o f 6 s u b s c r i p t e d , 6 0 - 6 3

V i d e o m o n i t o r :j a c k , 3 - p o s i t i o n o f 1 -

V u l n e r a b i l i t y o d i s k s , 8 2 - 8 3

W o r d m a n i p u l a t i o n s , 5 1 - 5 7W o r d p r o c e s s i n g , 1 1

W r i t e - e n a b l e n o t c h , 8

Z 8 c a r t r i d g e , 1 1

Page 145: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 145/148

T h S Y B E X L i b r a r yF O Y O U R C O M M O D O R E 6 4 I V I C - 2 0

T H C O M M O D O R E 6 4 ™ / V I C - 2 0 ™ B A S I C H A N D B O O Kb D o u g l a s H e r g e r t , 1 4 p p . , R e f . 0 - 1 1 6

c o m p l e t e l i s t i n g w i t h d e s c r i p t i o n s a n i n s t r u c t i v e e x a m p l e s o e a c h o t h C o m m o d o r e 6 B A S I C k e y w o r d s a n d f u n c t i o n s . h a n d y r e f e r e n c e g u i d e ,o r g a n i z e d l i k e d i c t i o n a r y .

I N T R O D U C T I O N T C O M P U T E R SD O N ' T ( o H o t C a r e f o Y o u r C o m p u t e r )b R o d n a y Z a k s 2 1 p p . , 1 0 i l l u s t r . , R e f . 0 - 0 6 5T h c o r r e c t w a t h a n d l e a n c a r e f o a l e l e m e n t s o c o m p u t e r s y s t e m ,i n c l u d i n g w h a t t d w h e n s o m e t h i n g d o e s n ' t w o r k .Y O U R F I R S T C O M P U T E Rb R o d n a y Z a k s 2 5 p p . , 1 5 i l l u s t r . , R e f . 0 - 0 4 5T h m o s t p o p u l a r i n t r o d u c t i o n t s m a l l c o m p u t e r s a n t h e i r p e r i p h e r a l s : w h a tt h e y d a n h o t b u o n e .I N T E R N A T I O N A L M I C R O C O M P U T E R D I C T I O N A R Y1 2 p p . , R e f . 0 - 0 6 7A l t h d e f i n i t i o n s a n a c r o n y m s o m i c r o c o m p u t e r j a r g o n d e f i n e d i h a n d yp o c k e t - s i z e e d i t i o n . I n c l u d e s t r a n s l a t i o n s o t h m o s t p o p u l a r t e r m s i n t o t e l a n g u a g e s .

F O C O M P L E T E C A T A L O GO O U P U B L I C A T I O N S

U . S . A .S Y B E X , I n c . F R A N C E G E R M A N Y2 3 4 4 S i x t h S t r e e t S Y B E X S Y B E X - V E R L A GB e r k e l e y , P l a c e F e l i x - E b o u e H e y e s t r . 2 C a l i f o r n i a 9 4 7 1 0 7 5 5 8 3 P a r i s C e d e x 1 4 0 0 0 D i i s s e l d o r f 1 T e l : ( 8 0 0 ) 2 2 7 - 2 3 4 6 F r a n c e W e s t G e r m a n y

( 4 1 5 ) 8 4 8 - 8 2 3 3 T e l : 1 / 3 4 7 - 3 0 - 2 0 T e l : ( 0 2 1 1 ) 2 8 7 0 6 6T e l e x : 3 3 6 3 1 1 T e l e x : 2 1 1 8 0 1 T e l e x : 0 5 8 8 1 6 3

Page 146: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 146/148

Page 147: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 147/148

Page 148: The Easy Guide to Your Commodore 64

8/6/2019 The Easy Guide to Your Commodore 64

http://slidepdf.com/reader/full/the-easy-guide-to-your-commodore-64 148/148