Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Floats are going to be a great addition to Grammer Smile
I've been fixing more bugs added at least one new command, and modified a few more. Of note:

    ▪ ▶Dec has been added to convert text to a float. This is particularly needed for user input (for example, with the Input command Razz). I struggled with this, because I want to add in an int-to-float conversion, but this seemed more important. I'm still not sure what token to use (or if I should just modify the ▶Dec token for both).

    ▪ I documented a bunch of the available float commands. Many of them have been available, but are still incomplete so I didn't want to document them.

    ▪ e and π can now act as floating-point constants. Of course, π is also used to prefix hexadecimal numbers, so this only works when π is not followed by a hexadecimal digit.

    ▪ I absorbed the Grampkg appvar into the main app for now. The appvar was made as a way to extend Grammer as available space got small. Now that I am using two app pages, this isn't necessary. The way it is set up, the appvar code is literally just sitting inside the app, so it still interfaces like the original appvar, just faster to locate.

Here is a screenshot that uses the ►Dec token to convert user input numbers (so that they don't need to use decimals as would be needed for expr( ):

Download Grammer v2.50.2.0
Weirdly enough, Grammer hasn't had real stack operations yet. In my most recent updates, I added two stack variables and three stack-related commands.

Initially, I wanted these to be mostly used for subroutines and parameter parsing and what not, and so I went with some tokens that look pretty similar to the word "parameter."

    Pmt_Bgn defines the base of the stack. When storing to Pmt_Bgn, the stack pointer will be reset to this value, too! In Grammer, this stack grows upward. The current default is saveSScreen+256, but this may change in the future.
    Pmt_End defines the top of the stack. The current default is saveSScreen+768, but this may change in the future.

These tokens are found in the finance app. Just press [up] on the first page and they are there.

Please note that saveSScreen is used by many routines as a scrap location. Inline assembly opcode snippets are copied there, the Menu( command stores info there, module routines are copied there, and I'm sure a bunch of other things. If you aren't using these routines, between push and pop operations, then you should be fine, otherwise your code might be unpredictable and you should relocate the stack to a safer location.

As for commands:

    Param uses the ? variable as a pointer to parameters and pares them. For example, in a subroutine called with prgm(Z,0,1+3,2, then ParamA,B,C will set A to 0, B to 4, and C to 2. This is a much cleaner and easier than the existing method.
    Param' pushes values to the stack. This takes expressions as arguments and is comma delimited.
    Param° pops values off the stack. This takes variable names as arguments and is comma delimited.

The Param token is in the mode menu as "PAR" or the first catalog entry under P.

So as an example of swapping vars:



Finally, we now have the ▶Nom( command which actually operates like a code block so it needs a matching End. It basically takes a list of variable names and pushes them to the stack. When its End is reached, it restores those variables.


:<<do stuff>>

While adding this in, I actually found a long-standing bug in the code that finds matching End tokens. It didn't skip over both bytes of the two-byte tokens, so if the second byte happened to be the same as, say, a While token, then it would look for one too many Ends.

Download v2.50.4.0
Grammer has undergone a bunch of updates!

As I've been updating z80float, I've been updating the float routines in Grammer. Since the last update here, I've also added a bunch of new routines. Here is a quick summary of changes for floats:

▪ sin( and cos( now have range reduction!
▪ division now has proper underflow/overflow detection
▪ Fixed a bug with the logarithm routines when the input's exponent was 0 (so on [1,2])
▪ Added in mean( to compute the mean of two numbers.
▪ I switched e^( to perform exp(), not 2^x (see note below)
▪ Added in 10^(, tan(, sinh(, cosh(, tanh(, sin-1(, cos-1(, tan-1(, sinh-1(, cosh-1(, tanh-1(.
▪ rand is a more mathematically correct!

I also changed the token hook so that e^( was no longer renamed 2^(. The regular routine still performs 2^n, but the float routine will compute exp(x).

I also rewrote the Input and Menu( routines, and updated Pt-Off( to allow wider sprites!
▪ Input does away with the highlighted input, but now has a blinking cursor.
▪ The Input buffer can now be relocated and resized! Below is a screenshot where I relocate the Input buffer to a within the source code, and limit it to 9 bytes (8 bytes plus a null byte).

▪ The two new "commands" are →Input (Sets the location of the input buffer) and →Input' (Sets the size of the input buffer).
▪ Pt-Off( draws a clipped sprite to pixel coordinates, but before now has only supported 8-pixel wide sprites with a width field reserved for future use. Well,

▪ Menu( is now a little more memory-friendly, and will scroll if there are too many items.
▪ Menu(' is a new menu routine where you supply pointers to two subroutines-- one routine that takes an index and returns a pointer to a string, and another that takes an index, and generates an output when the user selects an item.

As an example of the new Menu(', here is code that displays a menu with items names "ITEM A" to "ITEM Z".


Lbl "GET→A
Lbl "SEL→B

If !


And this is what it looks like:

For this one, each of the items is generated on-the-fly by a Grammer subroutine, and that contributes to it's slowness. It has to execute the subroutine every time the user moves up or down, as well as whenever an element is generated. In this implementation, every time the menu scrolls, it has to generate all of the elements from scratch. I might make it just scroll the contents up or down and generate a single item instead of the whole thing, but that's for future work. At least Grammer already has code for shifting rectangular regions of the screen up or down!.

Anyways, for the latest updates, check out the GitHub repository.

Download v2.50.6.1
Good to see that you keep working on Grammer 2 Smile
Thanks ^~^

i have a minor update in regards to the menu routine. The menu routine is now more efficient in scrolling. I did actually take advantage of the "rectangle shift up/down" routines so now it makes fewer calls to the Grammer parser, thus improving performance.
Here is what it looks like now:

I also remade the rectangle routines. Combined, they are 112 bytes larger, but it is cleaner code, they use 4 bytes of already allocated RAM instead of 24 bytes of specially allocated RAM, and they don't use shadow registers (so they doesn't need to disable interrupts). As well, I added two new methods-- they both invert the border, but one clears the inside, the other sets it to black. I have no idea why that might ever be desirable, but I have all the other methods of setting the border and fill to black/white/clear/invert, so why not? (and it didn't add much to the code).

For those who need the latest, Download (v2.50.6.2)
I added in filled circles to Grammer, so now there are 12 circle methods in all with various combinations of border and fill black/white/invert/clear:

Download v2.50.6.3.

EDIT: Using Cemetech download link Smile
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 4 of 4
» All times are GMT - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum