terrapin Apple II Technical Manual Download Page 1

Summary of Contents for Apple II

Page 1: ...L O G 0 for the Apple 11 TECHNIC AL MANUA L ...

Page 2: ......

Page 3: ...L O G 0 forthe Apple11 TECHNICAL MANUAL Harold Abelson and Leigh Klotz Jr Logo Project Massachusetts Institute of Technology ...

Page 4: ...Terrapin Inc 222 Third Street Cambridge Massachusetts 02142 617 492 8816 Copyright 1982 1983 1984 Terrapin Inc Copyright 1981 Massachusetts Institute of Technology ...

Page 5: ... 1 3 Draw Mode 2 2 Editing 2 2 1 Line Editor 2 2 2 Screen Editor 2 3 Using Apple Peripherals 2 3 1 Printing Procedures on a Printer 2 3 2 Printing Pictures 2 4 Color Control 2 4 1 Drawing on Colored Backgrounds 2 4 2 Drawing without Color Control 2 5 The Logo File System 2 5 1 Disk Files 2 5 2 Saving Pictures 2 5 3 Configuring File Diskettes 3 Logo System Primitives 3 1 Graphics Commands 3 2 Numer...

Page 6: ...MINE and DEPOSIT 6 2 Writing Your Own Machine Language Routines 6 3 The Logo Assembler 6 3 1 Using the Assembler to Write 1 0 Routines 6 3 2 Syntax of Input to the Assembler 6 3 3 Saving Assembled Routines on Disk 6 4 Example Generating music 6 5 Useful Memory Addresses 7 Miscellaneous Information 7 1 Using the Logo System as a Text Editor 7 1 1 Printing Files 7 2 Self starting files 7 3 Printing ...

Page 7: ...een added MEMBER EMPTY ITEM COUNT LOCAL SETDISK MEMBER takes two inputs and outputs TRUE if the first is a member of the second MEMBER A QUARK outputs TRUE MEMBER A A B C outputs TRUE MEMBER Z A B CJoutputs FALSE EMPTY outputs TRUE if its input is the empty word or the empty list EMPTY outputs TRUE EMPTY J outputs TRUE EMPTY BOB outputs FALSE ITEM takes two inputs a number and a list word and outp...

Page 8: ...omatically run when the file is read in For example if you tell Logo MAKE STARTUP FOO and then save the workspace SAVE BAR Logo will run FOO whenever the file BAR is read in PO SAVE EDIT and ERASE can now take a list of procedures as input The PSAVE utility is thus obsolete now you may type SAVE FILENAME PROC1 PROC2 PROC3 instead You must type the parentheses The DOS primitive no longer supports t...

Page 9: ...setts Institute of Technology in a project that was partially supported by grants from the National Science Foundation The interpreter was implemented by Stephen Hain and Leigh Klotz The text editor graphics and file systems were implemented by Patrick Sobalvarro This work is based on previous Logo systems developed by members of the MIT Logo Group with support from the National Science Foundation...

Page 10: ......

Page 11: ... described on page 43 In addition to the Language diskette and the Utilities diskette you will need diskettes for saving programs that you write The procedure for creating Logo tile diskettes is explained in section 2 5 3 1 2 The Keyboard There are a few differences between the way that the Apple keyboard is used in Logo as opposed to other languages such as BASIC and Pascal These are explained in...

Page 12: ... key For example to type control G hold down the key marked CTRL and press the G key rather than trying to press both CTRL and G simultaneously Throughout this manual we specify control symbols by the prefix crnL as in CTRL G The arrow keys On the right hand side of the Apple keyboard there are two keys marked with left and right arrows These are used in editing to move the cursor to the left and ...

Page 13: ...ewer model Apples also have a switch that disables the RESET key and forces the user to type CTRL RESET in order to obtain the original RESET function Whatever solution you choose beware that pressing RESET while using Logo will cause you to lose all your work and necessitate reloading the system following the procedure given in section 1 3 1 3 Loading and Starting Logo The method for starting Log...

Page 14: ... Apple II and Version 1 1 still contains a few very obscure bugs that may cause the system to crash The clearest symptom of a bug is when the computer stops executing Logo and instead returns to the Apple monitor with the message CONGRATULATIONS YOUFOUND A BUG TYPE300 311 RETURN ANDWRITEDOWN THE RESULT THENTYPECTRL Y RETURN If you wish to report the bug write down the indicated information togethe...

Page 15: ...ately attempt to save your workspace in some temporary file then reload Logo from disk and read your procedures back in For very serious bugs the CTRL Y method may not work in which case the only safe recourse is to restart Logo using the procedure given in 1 3 ...

Page 16: ......

Page 17: ...he cursor You may type in command lines terminated with RETURN Logo executes the line and prints a response if appropriate Whenever the cursor is visible and blinking Logo is waiting for you to type something and will do nothing else untii you do The system includes a flexible line editor that allows you to correct any typing errors in a command line which you have typed in DRAW or NODRAW mode The...

Page 18: ...d NODRAW modes causes Logo to evaluate the line just typed See section 2 2 To edit the most recently defined procedure type just EDIT or its abbreviation ED 1 2 1 3 Draw Mode In draw mode you use the turtle for drawing on the screen If you attempt to execute any turtle command while in nodraw mode the system will enter draw mode before executing the command The NODRAW command abbreviated ND exits ...

Page 19: ...CREEN are provided for this purpose In draw mode Logo displays just four lines of text This is frequently an inconvenience since error messages are sometimes longer than four lines If you type CTRL Twhile in graphics mode the turtle picture will disappear and you can use the entire screen for text just as in nodraw mode The difference is that you are actually still in draw mode turtle commands can...

Page 20: ...ment if lists are being printed Typing any character other than CTRL W or CTRL G will resume normal processing Try CTRL Win conjunction with the repeat key to obtain slow motion effects See TRACE page 39 Causes Logo to pause You may type anything and Logo will execute it as if it were a line of the current procedure Type CO or CONTINUE to continue Restores output to the screen See OUTDEV page 36 T...

Page 21: ...typed to Logo may wrap around to the next screen line The editing commands will still work on them exactly as if the line did not spread over more than forty characters Logo remembers the most recently typed line in both draw and nodraw modes so that you can insert it into the current line by typing CTRL P Unfortunately in the current implementation RUN REPEAT DEFINE and all filing commands such a...

Page 22: ...e moves immediately to the next page of text To move back to the previous page type CTRL B If you are on the first page CTRL B will move to the top of it similnrly on the last page CTRL F will move to the end If the text you are editing is more than one page long you can use the CTRL Lcommand to center the current line on the screen To exit the editor and have the procedure you typed be defined ty...

Page 23: ...the editor Processes the edited text Deletes the character at the current cursor position that is the character over which the cursor is flashing Moves the cursor to the end of the current line When editing more than one screenful of text moves the cursor one screenful of text forward or to the end of the buffer if not that much text follows the cursor In edit mode exits the editor without process...

Page 24: ...cted at the device in the specified slot Unlike the BASIC PR command OUTDEVdoes not direct typein to the alternate device The Logo screen editor and top level line editor are unaffected Using OUTDEV with an input of O will reset the output device to screen Typing CTRL SHIFT M will redirect output to the screen It is equivalent to executing an OUTDEV 0 but takes effect immediately even if Logo is i...

Page 25: ... END HPO means hardcopy printout HPO ALL will list all procedures and names The following procedure takes a list of procedures as an input and prints them out on the printer in the order they appear in the list It s useful for final listings of programs where you want the procedures printed out in a certain order TO HPL LIST IF LIST STOP HPOFIRST LIST HPL BF LIST END Once you have defined HPO and ...

Page 26: ...pictures on disk and printing them later is by far the most common and inexpensive method of obtaining screen hardcopy You can store pictures on disk with the SAVEPICT p 23 command SAVEPICT saves the picture as an Apple DOS binary file to which PICT is appended to differentiate it from other files The turtle graphics screen is stored in memory in the primary high resolution graphics page Commercia...

Page 27: ...END The ascii character with code 17 is a request to the Silentype to print the screen You may find it more attractive to print the screen in inverse mode or to use other options See the Silentype documentation for the appropriate control information Experimentation has shown the following set of options to work well TO HC improved version for Silentype OU1DEV 7 DEPOSIT53008 7 D POSIT 53007 128 DE...

Page 28: ...r of the dot the turtle is passing over but in all cases reversing the color of a dot and then reversing it again will restore the original color PENCOLOR 6 is most useful with black and white graphics If you don t explicitly give any BACKGROUND or PENCOLOR commands Logo will default to BACKGROUND Oand PENCOLOR 1 2 4 1 Drawing on Colored Backgrounds When drawing on a colored background 2 through 5...

Page 29: ... if one drew only thin lines If you don t care about color you will obtain better looking drawings by using thin lines To do this select BACKGROUND 6 In BACKGROUND 6 PENCOLOR O gives black 1 through 5 give white and 6 gives reverse The reason that white is in quotes is that white lines may not always appear white on a color monitor 10 2 5 The Logo File System The Logo file system allows you to sav...

Page 30: ...me as input and reads the procedures and names from that file into the workspace The procedures and names will be added to the ones currently in workspace 11 Notice that the file names given as inputs to SAVE and READ are preceded by a quote and have no following quote The CATALOG command lists all the files on the disk Logo workspace files will be listed with the characters LOGO appended to the n...

Page 31: ...need the PICT if you access the file from outside of Logo To erase a picture from the disk use the ERASEPICT command which takes as input the name of the picture to be erased You can use any of a number of commercial software packages for printing saved picture files on printers Logo picture files are stored in the standard binary file format In memory they are located in the primary graphics page...

Page 32: ...IC Apples should use the following method for creating file diskettes 1 Remove the write protect tab from the Utilities Disk and insert it in the disk drive Turn on your Apple It will print LANGUAGE NOT AVAILABLE and a prompt Type the following commands 10 PRINT CTRL D CATALOG UNLOCK HELLO DELETE HELLO SAVEHELLO LOCK HELLO 2 IMPORTANT Remove the Utilities Diskette from the drive and replace its wr...

Page 33: ...LEARSCREEN Clears the graphics screen Does not change the turtle s position the pen state or the turtle being hidden or shown Abbreviated CS DRAW Clears the graphics screen homes the turtle to the center of the screen shows the turtle and puts the pen down It does not change the background or pen color FORWARD Moves the turtle in the direction in which it is pointing by the amount specified Abbrev...

Page 34: ...n 2 4 Abbreviated PC Causes the turtle to leave a trail when it moves This is the default state and it is changed by PENUP Abbreviated PD Causes the turtle to move without leaving a trail Abbreviated PU Rotates the turtle Takes an input that specifies the number of degrees to rotate Abbreviated RT Rotates the turtle to the direction specified Input determines number of degrees Zero is straight up ...

Page 35: ...ING TOWARDS X Y will make the turtle face towards point x y Compare with ATAN TURTLESTATE Takes no inputs Outputs a list of four items giving information about the state of the turtle The format of the list is as follows The first element is TRUE or FALSE for pen down or pen up then TRUE or FALSE for show or hide turtle then background color then pen color Abbreviated TS WRAP XCOR YCOR Places the ...

Page 36: ...egative it must be enclosed by parentheses Outputs the cosine of its input as an angle in degrees Takes one numeric input and outputs the integer part ignoring the fractional part Outputs TRUE if its input is a number See also WORD and LIST Outputs the integer quotient of its two inputs If the inputs are not integers it first rounds them to the nearest integer If the second input is negative it mu...

Page 37: ...quare root of that number 3 3 Word and List Operations BUTFIRST BUTLAST If both inputs are numbers compares them to see if they are numerically equal If both inputs are words compares them to see if they are identical character strings In this case a space is needed before the sign If both inputs are lists compares them to see if their corresponding elements are equal Outputs TRUE or FALSE accordi...

Page 38: ... default and outputs a list of the inputs Therefore if the first and second inputs are lists for example LIST A B C D the result will be A B C D See also FPUT LPUT and SENTENCE If there are more than two inputs there must be an opening parenthesis before LIST and a space and closing parenthesis after the last input Outputs TRUE if its input is a list See also WORD and NUMBER Takes two inputs Secon...

Page 39: ... 3 4 Defining and Editing Procedures DEFINE EDIT Takes two inputs First is a name second is a list Each element of this list must be a list itself The first element of the list is a list of inputs to the procedure If there are no inputs to the procedure the first element should be the empty list Each subsequent element is a list corresponding to one line of the procedure being defined For example ...

Page 40: ...rocedure being erased to erase a procedure called LOOKUP type ERASE LOOKUP Abbreviated ER To erase a list of procedures the following procedure can be used TO ERPROCS PROCLIST IF PROCLIST STOP RUNLIST ERASEFIRST PROCLIST ERPROCS BUTFIRST PROCLIST END Takes a name as input and removes that name from the library Signals an error if the name is not used Note that unlike ERASE the input to ERNAME is e...

Page 41: ... of evaluation THING XXX is equivalent to XXX Outputs TRUE if its input has a value associated to it 3 6 Conditionals ALLOF ANYOF ELSE IF Takes a variable number of inputs default is two and outputs TRUE if all are TRUE If there are more than two inputs there must be an opening parenthesis before ALLOF and a space and a closing parenthesis after the last input Takes a variable number of inputs def...

Page 42: ...eceding TEST was true Abbreviated IFT Outputs TRUE if its input is FALSE FALSE if its input is TRUE Tests a condition to be used in conjunction with IFTRUE and IFFALSE TEST takes one input which must be either TRUE or FALSE The result of the most recent TEST in each procedure is used by IFTRUE and IFFALSE and is local to the current procedure Used with IF THEN ELSE Takes a word as input and transf...

Page 43: ...O must be treated differently than other commands when they follow RUN For an example see the listing for ERASE and PO Causes the current procedure to stop and return control to the calling procedure 2 Aborts the current procedure and all calling procedures and returns control to toplevel 3 It is not used very often in Logo programming 2sTOP does not mean the same thing as END STOP is a primitive ...

Page 44: ... and outputs the character whose ASCII code is that integer CLEARTEXT Clears the text screen and homes the cursor CLEARINPUT Clears the character input buffer of any typed ahead characters CURSOR Takes two inputs column and row and positions the cursor there Columns are 0 39 rows are 0 23 0 0 is upper left See the CH and CV locations page 74 to find out how to determine the cursor s current positi...

Page 45: ...ocedure assuming the procedure will output something to print See also PRINTOUT Abbreviated PR Like PRINT but does not terminate output line with a return With multiple inputs does not print spaces between elements RC Outputs TRUE if a keyboard character is pending i e if READCHARACTER would output immediately without waiting for the user to press a key otherwise outputs FALSE READCHARACTER REQUES...

Page 46: ... of DOS commands WARNING This command is likely to be removed and replaced with individual primitives Removes from the disk a file saved with SAVE Takes file name as input which must begin with a II mark Removes a picture that has been stored on the disk using SAVEf ICT Takes picture name as input which must begin with a II mark If given a procedure name as input prints out the text of the procedu...

Page 47: ...disk the picture on the screen Takes picture name as input which must begin with a mark 3 10 Debugging CONTINUE PAUSE NOTRACE TRACE Resumes execution after a PAUSE or CTRL Z Abbreviated CO Stops execution and allows command lines to be evaluated in the current local environment Equivalent to interrupt character CTRL Z Execution is resumed with CONTINUE provided no errors have occurred Turns off tr...

Page 48: ...9 which is a cold start address to use after Logo has been started before and the warm start address 1BFC for attempting to recover after a system crash After restarting Logo at the cold start address all procedures are lost it is just like typing GOODBYE The warm start address leaves all variables and procedures intact 5 The best way to return to Logo is to type CTRL Yand RETURN Calls a machine l...

Page 49: ...ort of memory it might be because an old list from CONTENTS is around somewhere keeping Logo from recovering the storage associated with no longer needed words Takes two numeric inputs an address and a value and deposits a byte of data at a designated memory location See section 6 1 Takes one input Outputs the value of the byte at the specified address See section 6 1 Forces a garbage collection O...

Page 50: ... ...

Page 51: ... only four lines of text at a time You can type CTRL T to see the full text screen and CTRL S to return to the graphics screen To read a program from the disk type READ immediately followed by the name of the program Do not use a closing quotation mark and do not type LOGO at the end of the name Logo will then print out the name of each procedure in the file as it is read in and defined When it is...

Page 52: ... Terrapin They contain information used by other files on the Utilities Disk ASSEMBLER AMODES ADDRESSES OPCODES SHAPE EDIT FID The Logo assembler procedures See chapter 6 The file of names describing the 6502 addressing modes The file of names describing addresses in the Logo interpreter for the assembler The file of names describing the 6502 mnemonics for the assembler The Logo shape editor descr...

Page 53: ...VE type READ PSAVE To save procedures named CIRCLE SQUARE and TRIANGLE in the file DESIGN type PSAVE DESIGN CIRCLESQUARE TRIANGLE TEACH The Logo editor allows tremendous flexibility in defining procedures and editing but at the cost of being complex to new users The TEACH procedure allows the user to define procedures without entering the editor It has the additional advantages of prompting the us...

Page 54: ...ashing characters Makes characters be in inverse video black on white Restores the normal mode of white on black These procedures do not affect characters already on the screen only those printed out afterwards You can start a blank text file by typing TO followed by RETURN Then type whatever text you want When you are done type CTRL Gand then save the file using SAVETEXT To read a file back in us...

Page 55: ...s name Closes the open file All output will be written to the file DPRINT ITEM Will cause the item to be printed into the file OPEN FOR APPEND FILE Used in stead of OPEN Will cause everything printed with DPRINT to be appended to the existing file rather than writing over it The files created by these procedures can be printed and read into the editor by the procedures in the file TEXTEDIT If you ...

Page 56: ...s system parameters This procedure describes the procedures available for using the Turtle TFD DIST TBK DIST TLT ANGLE TAT ANGLE These procedures correspond to FORWARD BACK LEFT and RIGHT but control the floor turtle instead of the screen turtle EYESON EYESOFF HORNLO HORNHI HORNOFF TPU TPD FTOUCH LTOUCH These procedures turn off and on the LEDs attached to the Turtl Makes the Turtle sound its horn...

Page 57: ...ing routines The Logo variables FBIT LBIT BBIT and RBIT are names for the numbers this number is composed of See the Terrapin Apple Interface manual for clarification TCMD COMMAND ARGUMENT TCMD is the lowest level procedure for controlling the Turtle It sends the command and argument to the Turtle You can use it to make the Turtle do things that the above procedures don t support See the Terrapin ...

Page 58: ...program s knowledge about animals in an easily readable form This procedure is intended as a learning aid to be used with the discussion of the ANIMAL program mentioned above In its use of recursion it is similar to tree drawing programs since it actually follows the tree of the Animal program s knowledge as it prints it out Look at the procedures in this file as an example of recursive programmin...

Page 59: ...f RUN and DEFINE You can easily modify INSTANT to provide more complex commands Dynatrack The DYNATRACK program implements something called a dynamic turtle one which moves around with time This particular program simulates a ride around a frictionless racetrack Type DYNATRACK to start K rnuses the turtle to accelerate in the direction it was pointing L and R turn the turtle to the left and to the...

Page 60: ...ial also has an explanation and examples of its use lnspi The picture file INSPI was generated by running the following procedure four times with the turtle pointing at different angles and with different pen colors TO INSPI DISTANCE ANGLE INCREMENT FD DISTANCE RT ANGLE INSPI DISTANCE ANGLE INCREMENT INCREMENT END You can display the picture by typing READPICT INSPI TET The procedures in this file...

Page 61: ...ve around on the screen in place of the turtle To set up your own shape table deposit the location of the first element of the table in the address USHAPE See section 6 5 for explanation of Logo addresses The size of the turtle or of the created shape can be changed with the one byte size code contained in address SSIZE The default value 1 is best for the regular turtle however values of 2 or grea...

Page 62: ...cheme outlined above You can read in the procedures and use them as a guide to writing similar functions To use the shape editor read in the file SHAPE EDIT and type SETUP The file contains a real time shape editor and functions for changing the currently displayed turtle shape and its size To begin designing your own shape give the MAKESHAPE command This takes one input that is to be the narne of...

Page 63: ...o have that shape It first hides the turtle and then shows it If you want to restore the turtle to its original triangular shape type SETSHAPE 0 The internal procedure which SETSHAPE calls is SHAPE It too takes the shape as input but it doesn t hide the turtle first This is useful because Logo draws and erases the turtle by drawing the turtle shape in reverse mode i e pencolor 6 This implies that ...

Page 64: ... fresh Logo workspace with no procedures defined Then read in the shape editor and define a few shapes SAVESHAPES PARTS will create two files The first PARTS SHAPES will contain the shape table the actual appearance of the shape the second PARTS AUX LOGO will have the names of the shapes and the following procedures SETSHAPE SHAPE SIZE INITSHAPES and any procedures you have defined Unless you are ...

Page 65: ...efine another shape here SAVE SHAPES BLOCKS At this point Logo will ask you to place your files disk in the disk drive This disk should be the one you want to use to store the shapes and the program to use them After Logo saves the shapes it will ask you to put the disk containing the shape editor back into the drive You should then place the Utilities Disk or a copy of it into the drive and press...

Page 66: ...S SETSHAPE SHAPE and INITSHAPES Then save the file The following paragraph briefly describes a program that uses this technique of separating the files The Utilities Disk Example Rocket On the Utilities Disk there is a demonstration program called ROCKET Type READ ROCKET and execute the procedure ROCKET The ROCKET procedure READs the ROCKET AUX file described above and calls the procedure INITSHAP...

Page 67: ...mbler that aids in doing this Another hook built in to Logo allows you to create simple animation effects by supplying a new shape to be displayed in place of the Logo turtle Another hook allows you to modify the behavior of the Logo editor so that it can be used as a regular text editor rather than as a procedure editor and to access disk files in non standard ways 6 1 EXAMINE and DEPOSIT These t...

Page 68: ...d will cause unpredictable effects The 16K memory card occupies locations C080 C08F 49280 49295 6 2 Writing Your Own Machine Language Routines You can interface your own machine language routines to Logo by using the CALL primitive CALL takes two inputs the first is the address of the routine and the second is an integer input that the routine may examine The routine may output an integer or outpu...

Page 69: ... form Thus CALL 99AO 3 would result in the following values in memory NARG2 NAHG2 1 NARG2 2 NARG2 3 3 0 0 0 NARGI NARGl l NARG1 2 NARG1 3 AO 99 0 0 Substituting 1 for 3 would make NARG2 through NARG2 3 contain FF To output an integer stare the integer to be returned using the above format in the four locations with NARG2 through NARG2 3 and jump to location OTPFX2 If the number is stored in some o...

Page 70: ...hat would make it inappropriate to return to the Logo procedure that called it it can and jump to PPTTP which effectively executes the Logo TOPLEVEL primitive 6 3 The Logo Assembler The Logo assembler is a 6502 assembler that is written in the Logo language This program was designed and written by Leigh Klotz The assembler is stored on the Logo utilities disk in the file ASSEMBLER 3 To use the ass...

Page 71: ...N 0 6 3 1 Using the Assembler to Write 1 0 Routines While it is possible to use the EXAMINE and DEPOSIT primitives to operate most peripheral devices machine language routines are required for others If the peripheral device is one which has a built in driver then you can use the OUTDEV primitive OUTDEV takes as input a slot number 1 through 7 as an input and directs the Logo character input or ou...

Page 72: ...t Here is another example output routine This one causes all I characters to be printed as spaces TO IOCODE XCLOUT CMP I BNEOUTCHAR LOA 32 OUTCHAR JMP COUT END 6 3 2 Syntax of 1nput to the Assembler In order to take advantage of some aspects of the Logo language the Logo assembler uses a format slightly different from most assemblers Each assembly language program is stored as a Logo procedure alt...

Page 73: ...vided they are enclosed in square brackets Of course references to the values of labels inside square brackets must have dots before them and spaces have their normal significance All labels are Logo variables DOT is a Logo variable whose value is the current location being assembled The HIS and LOS procedures which return respectively the high and low eight bits of a number are also useful inside...

Page 74: ...POSIT and EXAMINE To invoke the above routine type CALL PASS 4 to beep the bell and CALL PASS anything but 4 to do nothing This is sort of a secret password pro gram If you try to assemble long programs you may run out of memory One way to get more memory is to load in only those instructions that your program uses In a fresh Logo read in the OPCODES file from the utilities disk and erase the inst...

Page 75: ...e by typing SAVE ROUTINES Then to reload your routine type READ ROUTINES and DOS BLOAD ROUTINES 6 4 Example Generating music This section presents an example of an assembly language extension to Logo Although this version of Logo has no primitives for playing music you can use the CALL feature to interface a machine language routine to produce pitches with the Apple II speaker The speaker produces...

Page 76: ...eps above or below a center pitch The durations should be lengths of time for the note to sound with 1 being the shortest 2 being twice as long and so on TO PLAY PITCIIES OURS Ir PITCHES STOP PLAY NOTE FIRST PITCHES FIRST OURS PLAY UF PITCIIES BF DU8S END Even though we re not exactly sure how notes will be played we can assume that PLAY NOTE actually plays a note given the pitch number and durati...

Page 77: ...1 PERIOD 4 MAKE R 16384 END TOMAKE OCTAVE PITCH OCTIND PERIOD IF PITCH O STOP MAKE WORD PITCH OCTIND PERIOD MAKE OCTAVE PITCH 1 OCTIND PERIOD 1 0596 END This is about as far as we can proceed in Logo before we know the specifics of the implementation of the note generating ro1 Jtine This machine language routine should sound a note with a specific period for a certain length of time As mentioned b...

Page 78: ...ations of all other pitches from that one our problems will be solved The number of times to call the CLICK routine for a given duration and period is DURATION BASE PERIOD PERIOD This scaling is called normalization It is much easier to do the required multiplication and division in Logo than in machine language so we ll calculate this scaling factor in Logo The machine language routine will take ...

Page 79: ... TONE EXIT RTS CLICK LOA PER L STA COUNT L LOA PER H STA COUNT H BIT COUNT H BVS PDLOOP LOASPKR Click PDLOOP LOA COUNT L ORA COUNT H BEQEXIT LOA COUNT L SEC SBC 1 STA COUNT L LOA COUNT H SBC 0 propagate carry STA COUNT H JMP PDLOOP PRINT LENGTH DOT ORG BYTES END 71 The loops that make up the body of the CLICK and TONE routines both have an interesting property every iteration takes the same amount...

Page 80: ...ms it calls If we arrange memory locations so that DUR L DUR H are the low two bytes of the input to CALL and PER L PER H the high two the following procedure will give the two inputs to machine language routines TO CALL 2 ADDR INPUTl INPUT2 CALL ADDR ROUND INPUT2 ROUND INPUT1 65536 END Note the use of the ROUND primitive Were it not called non integer periods would cause the result of the multipl...

Page 81: ...ge zero locations EPOINT ENDBUF SAVMOD BKTFLG Location of the current character in the edit buffer Used by the editor and the EDOUT routine The address of the last character in the edit buffer plus one The disk saving routines see SAVMOD save frqm 2000 to the address in this location See the example on page 81 If the contents of this location is 0 READ and SAVE work normally If it is non zero SAVE...

Page 82: ...tal cursor position See the CURSOR primitive page 36 Contains the address of the routine currently being used for character output Like OTPDEV but for character input Pointer to user defined turtle shape See section 5 Shape size for turtle or user shapes Default 1 Determines whether characters will be white on black default contents 255 black on white contents 0 or flashing contents 64 Second inpu...

Page 83: ...d disables Monitor ROM Referencing this location enables the Apple monitor ROM It is enabled during CALL execution unless explicitly disabled An al ernate exit for user machine language routines Jumping to this address runs the Logo primitive TOPLEVEL page 35 It is useful for to return to Logo in this manner when some error condition has occurred making it inappropriate to continue executing CALLi...

Page 84: ...ffer See PNTBEG EPOINT ENDBUF Routine to beep the bell Use PRINT1 CHAR 7 to beep from Logo Homes the cursor and clears the screen Clear from cursor position to end of screen Scroll Clear to end of line Contains length of last file loaded Start address of last file loaded EXAMINE VZZZZZ 256 EXAMINE VZZZZZ 1 outputs the lowest address available for user machine language programs Although this addres...

Page 85: ... to it Note For this reason the text will be saved and printed exactly as it appears It is not reformatted as procedures are However if you then edit a procedure enter graphics mode etc the text will be lost Therefore it is necessary to SAVE the buffer as a file on a disk As with other files any name can be used such as SAVE MYFILE However SAVE needs to be used differently than usual as described ...

Page 86: ...rk on at a later date READ ADDRESSES from the utilities disk type DEPOSIT SAVMOD 1 and READ MYFILE from your own disk Then type ED followed by a RETURN Do not type TO after reading the file or you will start in a new empty buffer and have to read in the file again 7 1 1 Printing Files Were there no means to print files the Logo screen editor would be useless for editing text The following procedur...

Page 87: ...cedure called SETUP to be run automatically every time you read in the file called GAME This can be accomplished by arranging things so that the command SETUP is executed automatically each time the GAME file is read in To do this define all the procedures needed for GAME Type EDIT ALL to get the entire workspace into the edit buffer Then go to the end of the buffer using CTRL F and insert command...

Page 88: ...e the following protocol for writing to the disk file The PSAVE program on the utilities disk uses this method Since this implementation of Logo doesn t support arbitrary reading from disk these procedures are useful only for a particular set of applications and are printed here mostly for information purposes The following Logo procedures supply a DPRINT facility for printing to disk files To use...

Page 89: ...age programmers The location ENDBUF is Logo s end of edit buffer pointer The edit buffer begins at location 2000 and extends to 3FFF PNTBEG merely sets ENDBUF to 2000 EDOUT is a routine that takes a chara ter in A and places it at the location pointed to by EPOINT and increments EPOINT The disk saving routine saves from 2000 to ENDBUF so CLOSE has to update ENDBUF from EPOINT by calling the ENDPNT...

Page 90: ...rtainly not necessary to know what is presented here in order to use Logo these topics are covered for the curious The Graphics Screen When pointing straight up the turtle can go 121 steps before wrapping around to the bottom of the screen It can go 120 steps downward before wrapping around to the top It can go 140 steps when pointing the the left and 140 when going to the right If you change the ...

Page 91: ... empty word unless that word is itself the empty word The READCHARACTER primitive abbreviated RC reads a key from the keyboard and outputs a single letter word There are certain interrupt keys that will never be output by RC These are CTRL F CTRL S CTRL T CTRL SHIFT M CTAL W CTRL Z and CTRL G The functions these keys provide are available whenever Logo is in draw or nodraw mode The following table...

Page 92: ...xecution of a procedure which temporarily changes OUTDEV to some other device all output from then on3 would be directed to the alternate device The following procedure which uses the NOINTP feature can be executed without fear of causing STOPPED or PAUSE messages to be sent to the device TO TCMD CMD ARG DE POSIT NOINTP 255 OUTDEV 7 device in slot 7 PRINT CMD ARG OUTDEV 0 DEPOSIT NOINTP 0 END Line...

Page 93: ...a memory location it takes it off of this list Since Logo can t do anything else like run your procedures when it is garbage collecting the process can interfere with certain programs where real time response is important If this becomes annoying place calls to the GCOLL primitive at natural pauses in the program 7 5 Memory Organization Chart This chart describes how the Logo system uses the avail...

Page 94: ...outines Buffer 2000 3FFf 2000 bytes Editor graphics buffer Logo 4000 999F 599F bytes 23K bytes Logo code User 99AO 9AA i 105 bytes User Machine Code DOS 9AA6 llFFF 255F bytes DOScode buffers 1 0 000 CFFF 1000 bytes Mapped I 0 addresses Nodearray 0000 r65F 2660 bytes 2456 nodes Nodespace Typearray F660 FFF7 998 bytes 2456 bytes Type codes Ghostmem DODO DFFF 1000 bytes Static storage Unused FFF8 FFF...

Page 95: ... 60 CONTENTS 41 DEPOSIT 41 59 EXAMINE 41 59 GCOLL 41 NODES 41 I 28 41 28 29 28 Addresses useful 73 ALLOF 33 Animal 50 ANYOF 33 Arcs 47 Arrow keys 4 15 ASCII primitive 36 ASCII values table of selected 83 ATAN 28 BACK 25 BACKGROUND 20 25 Beep 76 87 ...

Page 96: ...XT 36 co 39 Color 20 Commands editing 14 CONTINUE 39 Control characters 4 11 Coordinates graphics 82 cos 28 Cosine 28 cs 25 CTRL key 4 Ctrl A 15 Ctrl B 15 Ctrl C 10 15 Ctrl D 15 Ctrl E 15 Ctrl F 11 12 15 25 83 Ctrl G 10 12 15 83 Ctrl K 15 Ctrl L 15 Ctrl N 15 Ctrl 0 15 Ctrl P 16 Ctrl S 11 12 27 83 Ctrl shift M 12 16 36 83 Ctrl shift P 12 Ctrl T 11 12 27 83 Logo for the Apple II Technical Manual ...

Page 97: ...25 Draw mode 10 ED 32 Edit 12 31 Edit mode 9 Editing Commands 14 ELSE 33 Empty list 29 Empty word 29 END 32 ER 32 ERASE 32 ERASEFILE 22 38 ERASEPICT 23 38 ERNAME 32 ESC key 4 15 FD 25 Files 21 FIRST 30 FORWARD 25 FPUT 30 FULLSCREEN 11 25 Fullscreen mode 11 GO 34 GOODBYE 34 Grappler 18 Hain Stephen 1 Hardcopy 17 HEADING 25 HIDETURTLE 25 89 ...

Page 98: ... Leigh 1 LAST 30 LEFT 26 LIST 30 LIST 30 Listings 17 Logo starting 5 LPUT 30 LT 26 MAKE 33 Logo for the Apple I Technical Manual Memory addresses of interesting locations in 73 Minsky Henry 54 Mocies 9 Music 67 ND 10 26 NODRAW 10 26 Nodraw mode 9 NOT 34 NOTRACE 39 NOWRAP 26 NUMBER 28 OP 35 OPCODES 66 OUTDEV 16 36 63 OUTPUT 34 PADDLE 36 ...

Page 99: ...rimitives descriptions of 25 PRINT 37 PRINT1 37 Printers 17 Printing 17 PRINTOUT 38 Procedures Printing 17 PU 26 QUOTIENT 28 RANDOM 28 RANDOMIZE 29 RC 37 83 RC 37 READ 22 39 READCHARACTER 37 83 READPICT 23 39 REMAINDER 29 REPEAT 35 REPFAT key 4 REQUEST 37 RESET key 5 Restarting Logo 40 RIGHT 26 ROUND 29 RQ 37 RT 26 RUN 35 SAVE 22 39 SAVEPICT 23 39 91 ...

Page 100: ...SHIFT key 3 SHOWTURTLE 26 SIN 29 Sine 29 SIZE in shape editor 55 Sobalvarro Patrick 1 SPLITSCREEN 11 27 Splitscre en mode 10 SQRT 29 ST 26 STOP 35 System bugs 6 TEST 34 TEXT 32 TEXTEDIT 46 TEXTSCREEN 27 THEN 34 THING 33 THING 33 Tintinabulation 76 TO 32 TOPLEVEL 35 TOWARDS 27 TRACE 39 TS 27 Turtle floor 48 TURTLESTATE 27 Utilities Disk 43 WORD 31 WORD 31 WRAP 27 ...

Page 101: ...Index XCOR 27 YCOR 27 93 ...

Page 102: ......

Page 103: ... I ...

Page 104: ...Terrapin Inc 222 Third Street Cambridge Massachusetts 02142 617 492 8816 t ...

Reviews: