0% found this document useful (0 votes)
3 views

Basic_Programming_1979_Atari_US_a

Atari, Inc. offers a limited ninety-day warranty for its Game Program cartridges, ensuring they are free from defects in materials or workmanship. The warranty is void if the cartridge is misused, excessively worn, or damaged by unauthorized modifications. Additionally, any implied warranties are limited to ninety days, and some states may have different regulations regarding warranty limitations.

Uploaded by

Dinael Milani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Basic_Programming_1979_Atari_US_a

Atari, Inc. offers a limited ninety-day warranty for its Game Program cartridges, ensuring they are free from defects in materials or workmanship. The warranty is void if the cartridge is misused, excessively worn, or damaged by unauthorized modifications. Additionally, any implied warranties are limited to ninety days, and some states may have different regulations regarding warranty limitations.

Uploaded by

Dinael Milani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

BRSICPROGRRfI,IfI,IING

GAMEPROGRAMTM CARTRIDGE
LIMITEDNINETYDAYWARRANW
ATARI,INC.("Alari")warrantslotheorlglnalconsumerpurchaserthalyourATARlo GamePrognmcrnrldgr
ls free from any defects in materialorworkmanshlptorap6rlod of ninetydaysfrom thodetgof purch$a. ltlny
such dafect is dlscoverodwlthln the warranty poriod,Atari's sole obllgation wlll b6 to replecc lhc orrtrldga
fre€ of chargs on rocsiptof the cartrldge(chargesprepald,lf mailedor shippsd)wllh prool of datc ol purohrlc
at eltherlhe retall store whsre the cartridge was purchassd or at one ot the ATAFI Beglonal Scrvlcc Ccnlc.!
llsted below:
Atarl, Inc. Atarl. lnc.
1312Crossman Ave 43 Belmont Dr.
Sunnyvale, CA 9/086 Somerset, NJ 08873
Atari, Inc. Atarl. lnc.
5400 Newoort Dr. 21@ East Dlvlslon St
Suite 1 Arlington, TX 76001
Rolling Meadows, lL 60008
Thls warranty shall not apply if ths cartrldge(l) has been mlsussd or shows signs of sxcssslve wclri (ll) hl!
baan damaged by belng us6d wllh any products not supplled by ATARI,or (lll) has been damagadby balng
servlcedor modifled by anyono otherthan an ATARI RaglonalServiceCenter.
A N Y A P P L I C A B L EI M P L I E DW A R R A N T I E S .I N C L U D I N GW A R R A N T I E SO F M E R C H A N T A B I L I T Y
AND
FITNESS.ARE HEREBYLIMITEDTO NINETY DAYS FROM THE DATEOF PURCHASE.CONSEOUENTIAL
OR INCIDENTALDAMAGESRESULTINGFROM A BREACHOF ANY APPLICABLEEXPRESSOR IMPLIED
WARBANTIESARE HEREBYEXCLUDED.
Soms slates do not allow llmltatlons on how long an lmpllsd wananty lasts ordo not allow the cxclurlon ot
llmltatlons of incidsntal or consequentlaldamages,so ths abovs limltatlons orsxcluslonE may noi rpply lo
you.
Thls warranty glves you speclllc legal rlghts and you may also have othsr rlghts whlch v.ry trom rtrlc to
state.

/t\
ATARI'
A WarnerCommunicationsCompanV
@

A T A R Il,N C . ,C o n s u m e D
r ivision
P O Box 427, Sunnyvale, CA 94086

COMPLETEBASIC WRITEAND DISPLAY SAMPLEPROGRAMS


c016943-20REV 1 MANUAL,PROGRAM& AUDIOVISUALO 1979,ATARI,INC PrlntedrnUSA PROGMMMING PROGRAMS INCLUDED
INSTRUCTIONS
TABLEOF CONTENTS
I. INTRODUCNON

2. USING THE CONTR,OIIERS

3. CONSOTECONTnOF

4. DISPLAY R.EGIONS

5. THE CURSOR

6. R,UNNINGA PR.OGRAM

7. USING THE NOTE TUNCTION 10

8. USING THE KT,YAND PRINT TUNCTIONS 12

9. USING THE PRINT TUNCTION 13

IO. USING THt, GRAPHICSR,EGION 15

1 I. USING THE MOD TUNCTION 17


I
/
I2. SAMPII PR,OGRAMS 18

TE:Alwavsturntheconsolepowerswitchoff wheninserting or remov-


an ATARIbGameProgramrM Thiswillprotecttheelectronic
cartridge.
ponentsandprolongthe lifeof yourATARIVideoComputer SystemrM

andAudiovisual@ 1979,ATARI,lNC.
Program,
I. INTR,ODUCTION
BASICPROGRAMMING is an in- it needsto carrY
the instructions
to teach
tooldesigned
structional out somesimpletasks.
Keeoin mindthat BASICPRO-
GRAMMING hasa limitedamount
of memoryin comparison to more
sophisticatedcomputersystems.lt
an excellentinslruc-
is, however,
programs. theessen-
tionatdevicefor learning
tialsof computer programming.
Computer programsare simplya
Thepro-
seriesof instructions. NOTE:ThisGameProgramrM car-
gramscontroltheflowof informa- tridoemavcausesometelevision
tlonwithinthecomputer. BASIC lf thisoc-
scr6enstir "roll" slightly.
PROGRAMMING allowsyouto curs,adjustment of the VERTICAL
givetheVideoComputer System HOLDmaybe necessary.

2. USINGTHECONTR.OIIER.S 3. CONSOTECONTROLS
To connectthe two controllers,
slidethe tongueof the leftcon- GAMESELECTSWITCH
trollerintothe grooveon the right Pressgameselectto erasea switchis placedin thea position,
controller.Thetwo KeyboardCon- programandresetallvalues. thetitlesof eachregionwilldisap-
trollers,lockedtogether,forma pearfromthedisplay andthe
24-kevkevboardusedto enter GAMERESETSWITCH GRAPHICS regionwillcomeinto
yourprogiamand to controlthe vrew.
displayon yourtelevision screen. Pressingthegameresetswitch
erasesallvaluesandreturnsa 0ro- Therightdifficultyswitchhasno
Removethe Keyboard Controller gramto itsbeginning
withouteras- functionin thisGameProgram car-
labelsfromthe enveloPe. Place ingtheprogram. tridge.
the labelmarkedLEFToverthe
Keyboardpluggedintothe LEFT DIFFICULTY SWITCHES TVTYPESWITCH
CONTROLLER jackat the rearof yourprogram,
Placethe Beforebeginning Setthisswitchto color if youhave
vourcomputerconsole. placetheleft difficultyswitchin
\ labelmarkedRIGHToverthe set.Setit to bw if
a colortelevision
\ theb position.
Thiswillshowyou youareusinga blackandwhite
Keyboardpluggedintothe RIGHT whereeachregionis on yourdis-
CONTROLLER jack at the rearof play.Whentheleft difficulty set.
television
yourcomputerconsole.
4. DISPLAYREGIONS
Thedisplayis dividedintosix 4 . TheOUTPUTregionwill show coloredcommands or inoutson of the regions:STATUS,PRG
regions: youtheoutputbeingproduced your Keyboard.
Thewhitemodeis GRAM,STACK,VARIABLES,
as yourprogramis beingrun. usedto giveyourcomputer com- OUTPUT, andGRAPHICS. Let's
1. ThePROGRAM regionis used mands,the othermodesare used startwith the STATUSregion.
to givethe computeryour TheSTATUSregionshowsyou to insertsymbolsintoyourprogram. Pushthe STATUSkeyonceand
instructions. the amountof memory the STATUSregionwill disappear
at anytimefor your
available MOVINGTHECURSOR FROM fromthe screenandthe PRO-
2. TheSTACKregionwillgiveyou program.Thisregionwillalso
the temporaryresultsof your REGIONTO REGION GRAMregionwill moveto the top
Makesurethe left difficulty of the display.
switchis in the b oosition
andturn
vourconsoleunitoff andthenon Pushthe PROGRAMkeyand the
STATIJS Sr1'Flggl_g : rt3 bgain.Pushthe FoRWARDkey PROGRAM regionwilldisaPpear
SYf-lEEl-S :65 SFEEE:38 andthe STACKregionwill move
andthecursorwillmovefrom
1I
PROGRAMto STACK.PuShthE to the top of the display.Pushthe
FORWARD keyagainandthe cur- STACKkey and the STACKregion
sor will movefromSTACKto willdisappear andthe
VARIABLES. Pushthe keyagain VARIABLES regionwillmoveto
andthe cursorwillmovefrom thetop of thedisplay. Pushthe
VARIABLESto OUTPUT. VARIABLES keyandthe
VARIABLES regionwilldisappear
By pushingthe BACK\/ARD key causingtheOUTPUTregionto
vou can movethe cursorbackto moveto the top of the display.
ine PnOenRM region.TheFOR-
WARDand BACKWARDkeyscan Removethe oUTPUTregionby
programas the computeris giveyou the speedof execution be pushedoncefor eachregionor oushinq the OUTPUTkev.Thiswill
running it. of yourprogram. helddown. blsocaluse theGRAPHIeSregion
to be fullyvisibleon thedisplay.
3. TheVARIABLES regionwill 6. TheGRAPHICS regionhastwo Nowplacethe left difficulty PushtheGRAPHIGS keyto
giveyou thevalueof each coloredsquares whichcan be switchintothea position.The removetheGRAPHICSregion.
variable itemin yourprogram movedaroundunderyourPro- titlesof eachregionwilldisappear Yourdisplayshouldshowno regions.
as it is beingrun. gramcontrol. anda portionof theGRAPHIoS
regionwillappear.Stepthe cursor Nowpushthe STACKkey.The
througheachof the regionsagain. STACKregionwill reappearon
Noticethatthe cursorwillnot
5. THECURSOR moveintotheGRAPHICSregion.
yourdisplay.Removethe STACK
region,andbringup theOUTPUT
andVARIABLES You
regions.
Placethe left difficultyswitch times.Thecolorof thecursorwill REMOVING THEREGIONS maydisplayor removeany region
intothe b positionandturnyour changefromwhiteto red,fromred FROMTHE DISPLAY withthe left difficultyswitchin
consoleoff andthenon again.In to blue,fromblueto green,and Placethe left difficultyswitch eitherthea or b position.
the PROGRAM regionthereis a fromgreento whiteagain. intothe b position againandturn
whiterectangle. Thisis the cursor. yourconsoleunitoff andthenon. to notethatwhether
It is important
Locatethe shlft controlkey at the Thecursoris usedto inputyour On the left sideof the Keyboard or notthevariousregionsare dis-
centerof the bottomrowon the program. Eachof thefourcolors are a seriesof commands (white playedhasno effecton the execu-
Pushthiskeyfour
leftcontroller. to the
on the shiftkey corresponds mode)that correspond witfteach tionof a program.
A PR.OGR,AM
6. R,UNNING
Let'sdo a simpleprogram.Make Usingthe linethatyou havejust Thecursoris directlyto the right
surethe left dlfficultyswitchis in enteredintoyourprogram, let'sdo of the 2 in line2. Nowinout
the b positionand turnyourcon- an exercise. Pushthe ERASEkey PRINTusingthe greenmode.
soleunitoff andthenon again. once.Thecursorwillmovefrom Then,withthe bluemode,inputA
line2 directlyto the rightof the2 andgo to a NewLine.Your
Removethe STACKVARIABLES, on line1. Pushthe ERASEkey displaywilllooklikethis:
OUTPUT,and GRAPHICSregions againandthe2 will be erased
fromthe display.Thecursorwill fromthe program. Nowenter1,
be in the whitemodeand to the usingthe redmode.Changethe
rightof the number1 in the PRO cursorto the whitemodeandus-
GRAMregion.Changethecursor ingthe BAoKWARDkey,move STATIJS
to the bluemodeand pushthe A thecursoruntilit is directlyto the SYFIEDI-=}:54
key.TheletterA will appearon the riEhtof the B in the program. Push
displaynextto the 1. (Eachlineis the ERASEkeyandthe letterwill t-rFl+fl-t-t-
numbered, makingit possibleto be removedfromthe program. 2 F F i n tA
seewhereone lineendsandthe Nowreplaceit withA (bluemode). 3I
nextonebegins.)Nowchangethe In the whitemode,usethe FOR-
cursorto the red modeand push WARDkeyto moveto the endof
the * key.A smallarrowwill ap- line1 andinoutNew Line.
pearnextto the A. Nowgo back
to blueand inputB. Changing the Remember thatthecursorshould
cursorto red,input+ andthe not be on the symbolto be erased
number2. Nowgo backto the butdirectlyto the rightof it. Your
whitemodeandinputNew Line. screendisplaywillnowlooklike Now,withthe cursorin thegreen
You mustalwaysbe in thewhite this: mode,inputGOTOandthen,in
modein orderto starta new line the redmode,input1. Beforewe
In yourprogram. do anythingelse,let's lookat the
displayagain.
Yourdisplayshouldlooklikethis:

lf youmakean errorin entering


yourprogram,it can be erasedus-
=iTfiTlt=i ingthe ERASEkey.Noticethat STATI-|S ST#|TIJ=J
SYFlEOr-Ei:57 SYl'lEOl-S:52
the ERASEkeyis not colorcod- SYI-rB(f1-S:57
ed. lt can be usedwhenthe shift
aA+E-fA key is in any colormode. I_F|+-A-+l_
=- 2 Print A
SEiotoI-I
Noticethat the STATUSregion To stopthe programpress reset switch.Pushthe RUN/HALT Pressthe RUN/HALTkeyand
showswe have52 "bytes" or RUN/HALT. As notedbefore, keyand watchas the computer startthe program.In line2, the
symbols of memoryremaining.
The pressing thegameresetswitch runsthroughthe program. The comouteris instructed to PRINT
SPEEDis setat 30 (SPEED = 30). erasesall valuesin yourprogram computer willshowyouthe cur- A. Whenit reachesthiscommand,
Putthecursorintothewhitemode (without erasingtheprogram rentvalueof A at eachsteoof it will orintthe currentvalueof A
andpresstheSLOWERkey. itself),andreturnsthe programto yourprogram. YourscreendisplaY in the OUTPUTregion.Watchthe
Noticethateverytimeyoupress its beginning. will looklikethis: SYMBOLSArEAOfthESTATUS
the keythe speeddecreases. region.Eventhough1 showsin the
Pressthe FASTERkeyand the Let'sanalyze the programstepby OUTPUTregionon yourdisplay,
SPEEDwillincrease. stepas the computerrunsthrough the computeris stillprintingthe
it. Change SPEEDto 60.Withthe changing valueof A. Putthe left
Beforewe starttheprogram,input cursorin thewhitemodepressthe difficultyswitchin thea position.
SPEED= 1. NoworesstheSTACK STEPkey.ThiswilltakeeachPart Yourdisplaywillnowlook
key.Pressthe RUN/HALTkey of the programonestepat a time, I-Fl+-fl -|-l- something likethis:
twiceandthe program will begin. eachtimeit is oressed. 2 PFint A I
Youcanwatchthecomouter work
eachpartof the program. In line1 the programreadsA - A
+ 1. Thecomputerreadsthisas Frint -aa
A "becomes"A + 1. Watchthe t,AEIAEI_E
STACKregionas youstepthrough fiisl-l-
=iTATITS line1. In line2, youhavetoldthe
SYl-lEOl-S:4-|- comouter to PrintA. Thismeans
youwantthecomputer to Printthe
I_F|+-A-l-t_ lalue of A (asdetermined by line Stopthe programandclearthe
2 Frint A 1) in the OUTPUTregion. values(gamereset).Removethe
VARIABLES regionandbringup
We'llseehowthatworkslater. theoUTPUTregionon thedisplay.
A+-3 Line3 tellsthe computerto Goto I-
ChangeSPEEDto 60.Thedisplay z.
1. Thecomouteris to returnto line willnow looklikethis:
1 andfinda newvaluefor A. Each 3
4
timethe programis runthroughit
willfinda newvaluefor A, print
thatvalue,andthenreturnto line STfiTLIS
1. Thecomouter willcontinue
to SifFlE0l-s:52
runthroughthe programin this
manneruntilall the "memory"is
used.Theamountof remaining a A+- fl -{-.|-
2PrintAl
memoryis shownin theSYM-
BOLSareaof the STATUSregion.
Bringup theVARIABLES region
ChangetheSPEED
on the display.
to 1 andclearthe valuesof the
programby pressing the game
Howcan we showmoreof the Usingthe FoRWARDkey,move Brinsup STACK,VARIABLESand BASICPROGRAMMING canonly
OUTPUTregionon the disPlaY? the cursorto the endof line1, so OUTPUT.Leavethe left difficulty workwith twedigitnumbers,so as
REMOVE thESTATUS,PROGRAM, thatyourdisplaylookslikethis: switchin the a positionandstart it reaches99 it will "wraparound"
andSTACKregionsfromthe the program. As theprogram and beginagainshowing A's value
Yourdisplaywill looklike
display. oassesline2 CLEARit erasesthe to be 0.
this: valueof A in the OUTPUTregion
andthenorintsthe nextvalueof A
in line3.
I- I_ Ft+-A+I_I
2 Z P F a n tA
5
4
3 Gntn I-
7. USINGTHENOTEFUNCTION
5
t Eachtimethe programstoresa Stopthe programand inserta new
? line2 (inthewhitemode,move
a numberintoNOTE(redmode),a
I notefromthe musicalscalewillbe the cursorto the endof line1 and
lEl soundedby yourtelevision pressNEWLINE.Theprevious
11 speaker. line2 willbecomeline3).
Let'sdo someprogramsto demon- 2 lf Note> 6 ThenNote* 0
strate.lf you haveany programsin
yourVideoComputerSystem, Yourdisplaywilllooklikethis:
Supposewe don'twantto over- Nowpressthe NEWLINEkey. pressthe gameselect switchon (lf STACKandVARIABLES
loadthe OUTPUTregionof the We will inserta newcommand the consoleunit. regionsare removed.)
program? Stopthe programand here.InputCLEAR(greenmode).
erasethevalueswiththegame Yourdisplaywill looklikethis: Inputthefollowing:
reset switch.Removethe OUT-
PUTregionfromthedisplayand 1 Note* Note + 1
bringup the PROGRAM region. 2 Goto 1
I_ Fl+fi-l-1 I- l'lote+Hote*I-
Nowstartthe program.Slowthe
2
3
4
ElpnrI
Print A
Eotn .|-
il programdownand watchit being
workedin the STAGKregion.Also
2 If l{ote } 6f hen l{ote
+GlI
.5 Eoto -|-

,l noticethatthe programwillprint
the currentvalueof NOTEin the
VARIABLES region.

10
Withthe lF andTHENcommands, Runthe program.Noticethatthe In thisprogramwe havegiventwo In somecaseswe can puttwo
we are instructingthe program sameresultsare achieved,except IF/THENcommands. lf the condi- commands on oneline,as in line1
thatlF something happens THEN that the notesare spacedevenly. tionsset uo in thefirstcommand andline2 in theaboveprogram.In
else.In this
it is to do something lf you wantthe programto give are notmet(line4) the computer thiswaywe can savesomeof the
case,lF Noteis morethan6, vou the valueof c in the oUTPUT willmoveto the nextline(line5). memoryfor laterin the program.
THEN Noteis to be changedto 0. iegion,inputPrintG andClearas Givenenoughmemory, therecan
Startthe programandwatchit be instructionsanywhere in the pro- be severalcommandsbetween
ingworkedin the STACKregion. gram.To cut downon theflickerin anytwo IF/THENcommands.
Noticethat as the valueof Note theOUTPUTregionas the Pro-
gramis givingyouthevalue,insert
rs. ii{sfrN{;'tH#,Ktr,t'
reaches7, it becomesmorethan
( >) 6 andthe programchanges a comma,(greenmode)afterthe
thevalueto 0. valuein thePrintline.PrintC.
Let'sdo anotherprogramto You mayuse any letterof the ANffi ffffitrTNT
ffifl,IN€T"HSNS
achievethesameresultin a dif- alphabet for thevariablein your
ferentway.Inputthefollowing: programs. Thefollowing program TheKEYfunction(redmode)is Startthe programandpushsome
hasall the keyfunctionswe have usedto inouta variable whilethe of the keyson the rightsideof the
learnedso far andusesnearlyall programis running. Theprogram Keyboard. Withpracticeyoumay
the available "memory"in the willevaluateKEYand reolaceit be ableto playa tune.
I Hote +- C computer. Afterentering thispro witha numberthatyou inputfrom
2 C +-C{-a oram.removethe oroqramfrom
5If C>TThenC+-0 the rightsideof the Keyboard.lf TheKEYfunctioncan alsobe
4 Eoto -a t-hedisplay,bringdp t[e STATUS, no numberis inoutted, thenthe usedfor programming in the
STACK,andOUTPUTregions, programwillreadKEYas 0, GRAPHICS regionas we willsee
and runthe program. later.
Here'sa simpleprogramusingthe
KEYfunction: Trythisprogramusingthe KEY,
NOTE.andPRINTfunctions:

--
r SYI'|EOI-S:SEl II SYFlElll-S:54
a l9r+-.17 trlEEr r SPEEEI:5El
2 Flole.-fl Frint D I
.3 D+-E -I- r
I Fl +- ]c-Eg
4 If II ) 7 Then Eioto I- -|- If Hec > ElThEn l'{ote {- 2 l{ote {- Fl Print A
I l+.eg 3If A:Ef T h e nE l e a r
5 If Il { E}Then Eioto 2 r ZEotoI-I 4 Eoto I-
I

|
L--
Nowlet'smakea minormodifica- set the SPEEDat 8 and inputthe Let'schangethe programslightly
tionin the program.In line2, in- followingprogram: a comma(,)at the end
by inputting
serta comma(,)afterPrintA and of line1 andline2. Theprogram
starttheprogram. By inserting the now lookslikethis:
commahereyou havetoldthe pro-
gramthat you wantas manyof the
variablesprintedon onelineas
oossible. r I- Print "F|" I I- Frint "4",
r a Frint '|trs" I ? Frint "IS",
r 3 Fri.tfl 3 FrintA
r 4 H+-f|-|-t-r 4 Ft+ A -fI_ I
r s Etenr 5 trlenr
r 6 Eoto I- tE Eoto I-

L )

Now runthe programand watch Thecomma(,)in linet hasin-


theOUTPUTregion. Theprogram structedthe programthatwhat
printsthe wordyou haveinputted, ever is on line2 is to be displayed
but theyare "stacked." in the OUTPUTregionon the
samelineas the instruction on line
1. Thecommain line2 hasin-
structedthe programthatthe line
.|- PFant "tl" 3 instruction is to followline2.
2 Frtnt r'I5rl
.5 FrintA
4 A+-FT+I-I
5 trlenr
6 Eioto -a
F
I=;
L2
9. USINGTHEPRINTFUNCTION
As we showedin earlierprograms, alsobe usedto instructthe pro
youcan usethe PRINTfunctionto gramto printwordson the display.
instructthe programto printthe Wordsto be displayedmustbe
valueof a variablein the OUTPUT enclosed in quotation
marks(").
region.ThePRINTfunctioncan
13 14
can be shorten-
Theseinstructions The programcan be further Bothobjectsor squaresstartout Thisprogramwillmovethe red
the programto
ed by changing shortened: in the upperleftcornerof the blue squareto the right,onehorizontal
reao: field,withonlythe redsquare spaceat a time.Runthisprogram
showing. Theupperleftcorneris andyouwillseethe redsquare
thezero(0)position or origin. movingslowlyto the right.Check
Whenthevariables Hor 1, Ver 1, the VARIABLESregionandyou
I- Print -a Frint "tl IS". A Hor 2, andVer 2 arenot defined willseethevalueof Hor 1 increas-
,A z A+ ft -t-t- r (givenvalues)theyhavevaluesof ing.lt willincrease untilit reaches
U fi+-A-|-I-I 3 trlenr 0 (therefore
causingthe squares to 99, the largestnumberallowed,
5 trlenr 4 Eioto I- remainin the upperleftcorner and thendropbackto 0. When
4 Eoto -a position). Hor 1 reaches 99, the redsquare
Fl IS AC}
A IS .45
willhavereachedthefar rightside
Whena coordinate is assigneda of the bluefield.At thispoint,the
valueotherthan0, (e.9.Hor 1 * redsquare"wrapsaround"and
10),the objectinvolvedwilljump startsagainfromthe far leftside
to the correspondingpositionon of the field,withHor 1 at 0.
the bluefieldwhenthe programis
executed. Thehorizontal (Hor1
coordinates
andHor 2) then,rangefrom0 to
program:
Inputthe following 99. Theverticalcoordinates (Ver1
Writingthe programin thisfashion andVer 2) alsorangefrom0 to
willalsosavesomememory. 99,with0 beingthe position at the
top of the bluefield,and99 being
the positionat the bottom.
program:
Inputthefollowing
'lt'&{m, REGION
dffi. &SSmruG ffiffi,AffiffiHc,S -l- HorI-+-Horl{-1I -|- Horl+-Hor.|-# 6
2 Gntn .|- 2 Uer L+-Uer.|-* E!
TheGRAPHICSregionis the blue To movethe squaresyou must Hor I- is -a? 3 Hor2+-Hor2-|- 4
fieldon yourtelevision changetheircoordinates. Thered 4 l.JerZ+tJer2-#el
rectangular 5 If HitThEnHote.-2
screen.At firstglanceit appears squareis objectnumber1. lts E l s eJ { o t e + 7
to containone redsquarein the horizontalcoordinateis reore- 6 EiotoI-
upperleftcorner.Theredsquare sentedon the Keyboard by Hor 1
actuallycoversa whitesquareand andits verticalcoordinateby Ver
bothmaybe movedindependently 1. Hor 2 andVer 2 are the coor-
on thefieldunderyourprogram dinatesof objectnumber2, the
control. whitesouare.

to
15
Removethe programfrom the lF the squaresHlT,whichtheydo 1. x + (Highest) A 5+3x2Mod7
screenandmakesurethe periodically.
To HIT meansthe 2 . + - s :x 2 = 6
t h e f i r s t s t e p i3
GRAPHICS regionis fullyvisible. squaresmustoccupythe same 3. Mod the secondstepis: 5 + 6 = 1 1
Setthe speedat 60 and runthe coordinates.Otherwise (ELSE)the 4 . =
5. * (lewest) thethirdsteois: 11 Mod7 = 4
program.Thisprogramshowsyou computeris instructed to playthe A = 4
oneway to movethe squareson 7 note.whichit willdo untilthe
the field.lt alsorevealshowthe squareshit. UsingParenthesis However,the sameequationwith
HIT andELSEfunctions maybe Usingparenthesis (greenmode, parenthesis inserted,is workedout
put to use. (RemoveELSENOTE* 7 from givesprior-
left sideof Keyboard), differentlyandgivesa different
line5 andnote2 willbe played ity to whichevernumbersthe answerfor A.
In line5 the programis instructing whenthe souareshitand no other oarenthesis surroundwhenwork- A (5 + 3)x 2Mod7
thecomouter to soundthe2 note notewillbe sounded.) ingout an equation.
f i r s t s t e p : 5+ 3 = 8
Forexample, whenworkingout s e c o n d s t e o :x8 2 = 1 6
the following
equation: thirdstep:16 Mod7 = 2
I I. USINGTHEMOD FUNCTION A = 2

Mod is an arithmetic oDerator, secondnumber.So,14 Mod 5 is


muchlikethedivision
(+). BASICPROGRAMMING
operator 4. Fivedividesinto14 twice(mak-
ing 10)with4 leftover.Mod gets
12. SAMPLEPROGRAMS
employsintegerdivision, which the remainder leftover,therefore
meansit workswithwholenum- Mod is 4. Hereare somesampleprograms. Afterrunning the programsand
bersonly,andleavesno re- Theywill helpyouseethe wide becoming familiarwiththefun-
mainder. Forexample, whatis 14 Whatis 13 Mod 4? Theansweris rangeof possibilities
you haveto damentals of computerprogram-
+ 5? You mightsay 2 and 415,or 1 since1 is leftoverafterdividing workwith.Remember to payclose mingin general,you'llbe wellon
2, remainder 4. In BASICPRO- 4 into13 (whichmakes12).How attentionto howa particularcom- yourway towardwritingsomepro
GRAMMIN1 G4 + 5 i s 2 . about12 Mod4? In thiscase, mand(lF,THEN,HlT,ELSE, gramsof yourown.
Although 5 dividesinto14 twice Mod is 0 since4 dividesinto12 PRINT,KEY,etc.)affectsa pre HIT
(making10),with4 leftover, evenlywithnothingor 0 remaining. gram.Remember too thata KEY
BASICuseswholenumbers only, commandmaydependon yourin-
so the answerit givesyou is 2. Normally, by 0 is undefin-
dividing putf romthe rightsideof the
ed,mathematically speaking. In Keyboardfor successfuloperation I- Elenr FrantHit
Thecomputer willgiveyouthe BASICPROGRAMMING, dividing of the program. 2Hor Z+-HarZ,+I-l"lod
sameanswerlor 12 + 4 as it will by 0 just givesa resultof 0, so g=
for 13 + 4. Theanswerin bothin- that5+0is0. Whenever program
a particular SEuto .|-
stancesis 3, since4 willdivide confuses you,stopthe program,
intoboth12 and13,3 whole OperatorPriorities resetit to the beginning,and
times.Thecomputer willnot STEPthroughit. By watching the
recognize the remainder of 1 in In an equation,
the arithmetic programin the STACKregionand
thecaseof 13 + 4. ope'rators(+ - ,, x , + M o d , seeinghowthe computerworks
etc.)areworkedout in orderof an out eachstep,you shouldbe able
Nowfor the Mod function. Mod priority.BASICPRO-
established to understand whatis happening
getsthe remainder leftoverafter GRAMMINGusesthefollowing andwhy it is happening.
the firstnumberintothe
dividing operatorpriorityguide:
17 18
MUSIC CLOCK.LIKE PROGRAM PONG@ GAME
when runningtheClockprogram withoutsound
bringup theoUTPUTregiononly.
TheSPEEDmaybe setat 30 or
60.

r I- Hote+-If Hote)4 I r J- fi+Kes I r I- trlenr I- Hor 2 +- Hor2-|- Keg


r r aIfA>@Thenl'lote+-A t I
T h e nH o t e - l - I - Else t r zFl+ Fl +I_ l"lod 6'El 2If UerI- ) 9ElThen
r llote * I- r-a r .3lffl:ElThenE+-B*I- Uer I-{-E}E}
r r .3EotoI-I rl"lod60 3If Hit lhen Uer -|-{-9
2 Hote+J{ote*2
r .5 Hote +- Hote -2 I
r 4Frint El, A 4Upra+UerI--# If
r 4 Eoto r- r SEoto l-l Uer .|- l"lod 2 Then El Else
I I
92
!5Hor L+- HorI-*7
6Eiots I-I

L__ ) L )

PONG@GAME
(Ball & Paddle)

r I- Nole+l-lote*Kes{- r I- Fl+- fr-f I- r I- Hor.|-+Horl*Keg


Ir I I
. 7 r ZHote+-A I r 2Hor2+Hor2*Cl ;
I Z Goto J-I r .3If (Fl l'lodZ) :ElTherr I r 3Uer 2+
r Uer2-E
I
l'{ote + El Else J{ote +- 4 r 4IfHitThenUer2+-99
I 4Eioto I-I r ' Hrtr+?
I
r S Ento r-

L-_ ) L ) E__ )

19 20

You might also like