Cognew questions...
Rayman
Posts: 14,801
1.· Can you COGNEW a routine in an included object?· I tried it and it worked, but then rebooted!
··· I'm playing a wav file in the background...· This code works as expected:
···
··· but, if I try the commented line in "PlayBackgroundWav", the file plays and then the system reboots...
··· I tried making the stack very big, but it didn't help...
2.· Can I use the stack space to return some values by storing things there at the end of the proceedure that the CogNew calls?· Anybody tried this?
··· I'm playing a wav file in the background...· This code works as expected:
···
Pub PlayBackgroundWav(sFilename) 'play wav file in background using a cog return cognew(PlayForegroundWav(sFilename),@stack) 'return cognew(wav.play(sFilename),@stack) Pub PlayForegroundWav(sFilename):bOK 'play a wave and return status after playing return wav.play(sFilename)
··· but, if I try the commented line in "PlayBackgroundWav", the file plays and then the system reboots...
··· I tried making the stack very big, but it didn't help...
2.· Can I use the stack space to return some values by storing things there at the end of the proceedure that the CogNew calls?· Anybody tried this?
Comments
2) Never tried
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
You can do this ...
The @stack+N in the CogNew allocates a common passing area for the separately running cog. The only thing I can't remember is how to determine the stackbase. I recall it's simply a matter of 'stackBase := @return - X' but cannot remember what X is !
Put a "long[noparse][[/noparse] $7FF0 ] := @return" in RunsInOwnCog then print "long[noparse][[/noparse] $7FF0 ] - @stack" in the main and you'll be able to determine the X.
As the stack is used for internal operations I do not see how to work with such things dangerlessly....
What you can do - but for what reason? - is
Now 4711 can easily be retrieved in "aStack".
Post Edited (deSilva) : 1/29/2008 7:55:10 PM GMT
just before the cog is stopped?
Especially the FIRST elements will contain most relevant internal data.
But, it doesn't seem to mind me setting stack[noparse][[/noparse]2]...