;This is an example of using PROCs.›;›;The program draws a border around›;the screen and plots a '*' and›;makes it move randomly.›;›;I hope by explaining it near the›;line where the command helps.››››;This PROC erases the old '*' and›;plots a new '*' in a new position.›;Notice how the parameters are used.››;The Position command works the same›;as it does in BASIC. It just places›;the cursor at the place on the›;screen when the next character will›;be printed.›››PROC move(BYTE oldx,oldy,newx,newy)›› › Position(oldx,oldy)› Print(" ")› Position(newx,newy)› Print("*")› ›RETURN››››PROC draw_screen(BYTE x,y)››;Here we draw the border and place›;the '*' at starting position x,y›;›;The 'Put(125)' simply clears the›;screen.››› BYTE i›› Put(125)› PrintE("+-----------------------------------+")› FOR i=1 TO 21› DO› PrintE("| |")› OD› PrintE("+-----------------------------------+")› Position(x,y)› Print("*")›››RETURN››PROC main()››;Here's the meat of the program.›;It will be explained as we get to ›;each line.››› BYTE x_rnum,› y_rnum,› old_xpos,› old_ypos,› new_xpos,› new_ypos›› CARD delay›› Poke(752,1) ;this turns off the cursor› ;Try deleting this line› ;to see what happens››››;here we set the starting position of›;the '*' and draw the screen. Notice›;how the paramters are sent›› › new_xpos=28› new_ypos=10› draw_screen(new_xpos,new_ypos)››› DO ›;an infinite loop. You must press›;RESET to exit.››› x_rnum=Rand(2)› y_rnum=Rand(2)››;get a random number from 0 to 1›;a 1 means move right or down›;a 0 means move left or up››› old_xpos=new_xpos›;so we can erase the old '*'›› IF x_rnum=1 THEN ;move right?› new_xpos==+1 ;yes, increase the x position› IF new_xpos>36 THEN ;are we out of range?› new_xpos=3 ;Yes, position '*' on the left› FI› ELSE ;x_rnum was a 0 so› new_xpos==-1 ;we move left› IF new_xpos<3 THEN ;are we out of range?› new_xpos=36 ;yes, move '*' to the right› FI› FI› › old_ypos=new_ypos›;also so we can erase the old '*'› › IF y_rnum=1 THEN ;should we move down?› new_ypos==+1 ;yes› IF new_ypos>21 THEN ;too far down?› new_ypos=2 ;reset to top of screen› FI› ELSE› new_ypos==-1 ;no, we have to move up› IF new_ypos<1 THEN ;can't above the top of the screen› new_ypos=21 ;move to the bottom› FI› FI› ››;here's where we move the '*'›;we send it old_xpos and old_ypos so›;the old '*' can be erased.›› move(old_xpos, old_ypos, new_xpos, new_ypos)›››;here we just delay the program by›;giving it something useless to do›;for a while. Like counting from 1›;to 3000. You can delete these lines›;to see how fast it runs without›;the delay›› FOR delay=1 TO 3000› DO› OD› › OD ;end of the infinite loop› ;RESET to end››RETURN››