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".
Code:
Lbl "GET→A
Lbl "SEL→B
Menu('"Title",2,34,59,27,A,B→M
Text('0,0,M
Stop
.GET
→X<26
If !
End
"ITEM A→Z
int(Z+5,X+65
Z
End
.SEL
+1
End
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