simulation stopping

lake

New Member
hi when i test my programming whichthere is nothing wrong with after about 30seconds the simulation stops as ive said my programming is fine because it runs throught it a few times before stopping is this anything to do with the gosubs thingy in the simulation ??? help please
 

lake

New Member
yes srry i havnt yet done the symbols but this shouldnt be a problem as it is code error or something that i dont knwo about :p yes like i said it runs for bout 30-40 secs then stops on one of the if...then....gosub... in the PONG: heading it always seems to stop here any help will be great thanks.
its a game where you have two paddles and a ball which you batt around wen you miss the other person gets a point first to three wins its played on a 8x8 dot matrix but only 7x8 is used for the game the top row is for the points that you get


main:
let b10=0
let b11=0
goto startvalues
startvalues:
let b6=28
let b7=28
let b8=-1
let b0=4
let b1=3
let b2=1
goto pong
pong:
do
let b9=b9+1
gosub inputbuttons
gosub positiondata
gosub outputs
loop until b9=2
goto ball2
inputbuttons:
let dirsc = %00000000
if pin0=1 then gosub up2
if pin1=1 then gosub dw2
if pin2=1 then gosub up
if pin3=1 then gosub dw
return
positiondata:
if b1=7 then gosub negb4
if b1=b8 then gosub posb4
if b0=7 then checkrightpad
if b0=0 then checkleftpad
return
outputs:
high portc 0
let pins=b6
low portc 0
let pins=%00000000
let pinsc=%00000000
high portc 7
let pins=b7
low portc 7
let pins=%00000000
let pinsc=%00000000
high portc b0
high b1
let pins=%00000000
let pinsc=%00000000
let dirsc = %00000000
high 7
high portc b10
let pinsc=%00000000
high portc b11
let pins=%00000000
let pinsc=%00000000
let dirsc = %00000000
return
ball2:
let b0=b0+b2
let b1=b1+b4
let b9=0
goto pong
posb4:
let b4=1
let b1=1
return
negb4:
let b4=-1
let b1=5
return
up:
if b6=112 then inputbuttons
b6=b6*2
return
dw:
if b6=7 then inputbuttons
b6=b6/2
return
up2:
if b7=112 then inputbuttons
b7=b7*2
return
dw2:
if b7=7 then inputbuttons
b7=b7/2
return
checkrightpad:
if b6=28 and b1=3 then middlebounce
if b6=112 and b1=5 then middlebounce
if b6=56 and b1=4 then middlebounce
if b6=14 and b1=2 then middlebounce
if b6=7 and b1=1 then middlebounce
if b6=28 and b1=4 then topbounce
if b6=112 and b1=6 then topbounce
if b6=56 and b1=5 then topbounce
if b6=14 and b1=3 then topbounce
if b6=7 and b1=2 then topbounce
if b6=28 and b1=2 then bottombounce
if b6=112 and b1=4 then bottombounce
if b6=56 and b1=3 then bottombounce
if b6=14 and b1=1 then bottombounce
if b6=7 and b1=0 then bottombounce
goto player1
checkleftpad:
if b7=28 and b1=3 then middlebounce2
if b7=112 and b1=5 then middlebounce2
if b7=56 and b1=4 then middlebounce2
if b7=14 and b1=2 then middlebounce2
if b7=7 and b1=1 then middlebounce2
if b7=28 and b1=4 then topbounce2
if b7=112 and b1=6 then topbounce2
if b7=56 and b1=5 then topbounce2
if b7=14 and b1=3 then topbounce2
if b7=7 and b1=2 then topbounce2
if b7=28 and b1=2 then bottombounce2
if b7=112 and b1=4 then bottombounce2
if b7=56 and b1=3 then bottombounce2
if b7=14 and b1=1 then bottombounce2
if b7=7 and b1=0 then bottombounce2
goto player2
middlebounce:
let b2=-1
let b0=6
goto ball2
middlebounce2:
let b2=1
let b0=1
goto ball2
topbounce:
let b4=1
let b2=-1
let b0=6
goto ball2
topbounce2:
let b4=1
let b2=1
let b0=1
goto ball2
bottombounce:
let b4=-1
let b2=-1
let b0=6
goto ball2
bottombounce2:
let b4=-1
let b2=1
let b0=1
goto ball2
player1:
let b10=b10*2+1
if b10=7 then player1win
goto startvalues
player2:
let b11=b11*2+1
if b11=7 then player2win
goto startvalues
player1win:
do
loop
player2win:
do
loop
 

lake

New Member
never mind me it my programming opps yes looking in to the gos command you can only have them 4 times (deep) so.

main:
gosub one
one:
gosub two
two:
gosub three
three:
gosub four
four:
gosub one

and whn it gets to FOUR: it will stop
as it has reached it limit diffent picaxe have different limits stupid me lol now i just have to find where it is over four deep which will be hard
 

inglewoodpete

Senior Member
I think you're on to the case already.

Have a look at "GoSub" in the commands manual. Due to the limited RAM available in PICAXE chips, the interpreter limits the depth of subroutines to 4 (8 on the x1 and x2). Page 46 of the command manual.
 
Top