2806
Grammer / Re: Grammer 2-The APP
« on: November 21, 2011, 01:03:34 am »
Okay, so update-wise, before I make the next official release, I want to put this out for testing. It seems there have been a lot of issues lately (mostly sprites). I have been hard at work making sure these bugs have been fixed (I am not sure they have been, though) as well as making sure these next commands are safe and in working order. Anyway, here are the next commands:
sub( deletes data from a variable. The syntax is:
sub(#ofbytes,Offset,"VarName
So an example of using this might be to delete 7 bytes from the beginning of an appvar:
augment( is used to insert data into a variable. It has the same syntax as sub( and it will cause a memory error (see next command) if there is not enough memory available.
solve(3, is used to create a Custom Error Handler. The argument for this is a pointer to the error handler. Whenever Grammer throws an error (there is a Memory error and ON Break error), code will be diverted here. The error code is passed in Ans as either 0 for ON or 1 for Memory. For example, here is an error handler that will display the error if ON is pressed and then quit and a menu to quit or continue for a Memory error:
Here are the changes and bug fixes:
-Changed the Send( command so that it now creates a var filled with zeros (instead of unknown data)
-Changed UnArchive command to return a pointer to the var data in RAM
-Fixed Pt-On( and Pt-Off( command up (any bugs that I found).
So the negative effects of augment( and sub( deal with the fact that these might shift your program around in memory. Don't worry, this won't affect the parser, but what it can do is mess around with labels. For example, if you get the pointer to a label and store it to P, then you delete some data from a var and your program is shifted down some bytes, then P will no longer point to the correct location!
So here are proposed ideas on my part:
1) Make a "Relative Pointer Mode" that will use Goto , Return, Lbl , Func, and prgm, based on relative addressing. (This means that it won't matter where in memory the program is because these will all work as offsets from teh start of the program).
2) Add a ' modifier to the commands to tell it to use relative addressing. So Lbl '"Hello will find the offset into the program that the label .Hello is at. Then prgm' will call the offset into the program.
So technical stuff aside, here is the download, currently.
the circle command in this version will let you use an optional argument as the byte pattern for drawing >.> I don't know if this will be changed or not, so it is not documented. So don't use it in a game!
sub( deletes data from a variable. The syntax is:
sub(#ofbytes,Offset,"VarName
So an example of using this might be to delete 7 bytes from the beginning of an appvar:
Code: [Select]
sub(7,0,"UAvar
This code should not delete any data from outside the program. If you try to delete 7 bytes of the last 3 bytes of the var, only the last 3 are deleted. If you try to delete 4 bytes and there is only 1 byte left in the var, only that 1 byte is deleted. See below for negative effects.augment( is used to insert data into a variable. It has the same syntax as sub( and it will cause a memory error (see next command) if there is not enough memory available.
solve(3, is used to create a Custom Error Handler. The argument for this is a pointer to the error handler. Whenever Grammer throws an error (there is a Memory error and ON Break error), code will be diverted here. The error code is passed in Ans as either 0 for ON or 1 for Memory. For example, here is an error handler that will display the error if ON is pressed and then quit and a menu to quit or continue for a Memory error:
Code: [Select]
.0:
ClrDraw
0→A
solve(3,Lbl "EH
Repeat 0
augment(120,0,"EB
Text('0,0,A
A+1→A
DispGraph
End
.EH
→Ɵ' ;Stores the error code to Ɵ'
Disp π9872 ;so that we don't mess up the graph buffer
ClrDraw
If !Ɵ'
Text(º"ERR:BREAK":DispGraph:Stop
Text(º"ERR:MEM
Text(6,1,"Ignore
Text(12,1,"Quit
1→Z'
Repeat getKey(54 ;Use 2nd to select an option
Line(0,Z'*6,6,28,2
DispGraph
Line(0,Z'*6,6,28,2
Repeat getKey
End
2*getKey(1 +getKey(4
If ;There is a space here
→Z'
End
If Z'-1
Stop
Disp π9340
End
solve(3,0 will reset the handler so Grammer handles it.Here are the changes and bug fixes:
-Changed the Send( command so that it now creates a var filled with zeros (instead of unknown data)
-Changed UnArchive command to return a pointer to the var data in RAM
-Fixed Pt-On( and Pt-Off( command up (any bugs that I found).
So the negative effects of augment( and sub( deal with the fact that these might shift your program around in memory. Don't worry, this won't affect the parser, but what it can do is mess around with labels. For example, if you get the pointer to a label and store it to P, then you delete some data from a var and your program is shifted down some bytes, then P will no longer point to the correct location!
So here are proposed ideas on my part:
1) Make a "Relative Pointer Mode" that will use Goto , Return, Lbl , Func, and prgm, based on relative addressing. (This means that it won't matter where in memory the program is because these will all work as offsets from teh start of the program).
2) Add a ' modifier to the commands to tell it to use relative addressing. So Lbl '"Hello will find the offset into the program that the label .Hello is at. Then prgm' will call the offset into the program.
So technical stuff aside, here is the download, currently.
the circle command in this version will let you use an optional argument as the byte pattern for drawing >.> I don't know if this will be changed or not, so it is not documented. So don't use it in a game!