Author Topic: Grammer 2-The APP  (Read 165193 times)

0 Members and 1 Guest are viewing this topic.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Grammer 2-The APP
« Reply #450 on: September 03, 2019, 01:44:56 pm »
Ok, you can stop now. Look, if you continue, you will convince me to use Grammer over Axe for all my non-game projects. How dare you tempt me away from our lord and savior Axe Parser.
I'm still around... kind of.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #451 on: September 03, 2019, 02:21:54 pm »
There are perks to both languages, that's for sure. I think Grammer is better for higher-level stuff, and Axe is better for faster, lower level stuff.

EDIT: Here is what the fancy menu looks like now:

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!.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #452 on: September 05, 2019, 08:16:30 pm »
Minor update to the above.
The menu routine is now more efficient on scrolling. I did actually take advantage of the "rectangle shift up/down" routines so now it makes fewer calls to the Grammer routines, improving performance.
Here is what it looks like now:


I also remade the rectangle routines. It is 112 bytes larger, but it is cleaner code, uses 4 bytes of already allocated RAM instead of 24 bytes of specially allocated RAM, and doesn't use shadow registers (so it 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). Now I just need to add in left/right rectangle shifts and world domination will be mine.

Attached is the .8xk for those who need the latest.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #453 on: September 13, 2019, 08:14:30 pm »
Hey folks, have the first official update in over seven years!
Since the last update, I've optimized some more and added in filled circle routines internally. With that, there are now 12 circle drawing methods, with various borders and fills (between white/black/invert/clear).



Download Grammer v2.50.6.3 :)

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #454 on: September 19, 2019, 07:39:33 pm »
This is just a quick update! I tracked down a critical bug in Grammer that has been around for a few of the mini releases (probably since last year). Send( was returning the wrong pointer, so if you started writing bytes to a file, you would almost certainly end up corrupting variables in RAM. Anyways, the link in the previous post now points to the corrected version :)

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #455 on: October 02, 2019, 10:08:44 pm »
I (re)updated the download in the Latest Releases thread with some more bug fixes. Also, I added in the arctangent routine after @E37 bugged me about it. It was a little more work than I was expecting, but it is useful. In fact, if you supply two arguments, it works as an arctan2 routine :)

So bug fixes:
- Another bug in Send( was fixed
- inString( was just plain broken, so I fixed that and had to adjust the Lbl routine to work with the fix.
- Vertical caused some exciting crashes, so I fixed that and even optimized it.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #456 on: November 25, 2019, 11:52:06 am »
Wooh, lots of bug fixes, a few new features! Latest Release.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #457 on: November 26, 2019, 07:11:12 pm »
I've been working on the built-in fonts!

As some may have noticed, the variable font was very sparsely populated, only containing some important characters. Part of the reason is that the old font format was... convoluted. Each character had its own width and height, which made it difficult to make an editor for it. I decided to go with a more sensible option, one that I had used in the past-- The fontset has a height-byte, and each char has its own width (which is allowed to be 0).

There were two advantages to this: one, it is easier to code the text routine, and two, DrDnar's Monochrome Font Editor already supports this format (Xeda's Format #2) which means I had an easy-to-use editor. So, with all of this, some motivation, and some free time, I completed the font and reworked the text routines:


I haven't have tested the Input routine with this, so I should work on that and it works, so I hope people like this ^~^
Also, if anyone wants to make their own fonts based on these, I have the "mfefont" files here:
Variable-width font (export this to Xeda Format #2)
Fixed 4x6 font (export to Xeda Format #1)

You can find the download in the GitHub project's /bin folder, or attached.

EDIT: Tested the input routine; it works ^~^
EDIT2: Oh my. Sweet. Baby. Carrots. Fonts can be BIG apparently. I tested a 16-pixel wide character and it works fine :0

EDIT3: More updates! I've gone bug hunting and I managed to fix the following:
  • The undocumented For <<constant>> can now be nested! This should be documented; it has been around for years.
  • An ooold bug report I found mentioned that For X,0,65535 would cause an infinite loop, so I fixed it!
  • Rounded square roots, via √(' were pretty broken. I had an old bug report that showed √('255 was returning 0, but that was fixed a few months ago when I totally rewrote the square root routine. But, I did botch the rounding, causing it to round up when it should have rounded down, and vice-versa. This is now fixed :)

I also overhauled the module documentation, and I realized I had to advance the module version since I broke some support with the original :(

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Grammer 2-The APP
« Reply #458 on: November 28, 2019, 10:34:26 am »
That looks quite nice. How does it work with font hooks? I was playing around with adding custom fonts to one of my games and I noticed that the font hook makes the OS's display routines way slower. I think that is because it bcalls the font hook and bcalls take forever. You might be using custom routines since you have variable-height font though. Do your display routines obey the font flags? (like inverse, erase behind etc.)

I can't quite figure out what you are using to display the font in the demos. It looks like you are just using the ti-basic style 'Disp' command (or PutC) since you can see the screen tearing a little when you scroll but that doesn't take variable-width font...

You should add in the clipped line routine you made if you haven't done so already. I have been using it for a while now and it works perfectly.
I'm still around... kind of.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #459 on: November 28, 2019, 11:36:11 am »
I use custom font routines and the text flags that Grammer uses are separate from the OS's flags. In the example, I put in DispGraphs every time I shift the screen up just so that people had a chance to actually see the font (since it doesn't fit on one screen for either font). I found that a custom font routine was much easier and faster than using the OS routines, but of course that meant I needed to make a font for it.


For the line routine, I actually went with a very different approach, but used the Axe routine as scaffolding. For Grammer, I wanted a line routine that was much more modular, so it actually takes IX as an argument that points to a plotting routine. Doing this is a bit slower than the other routine, but it doesn't need the additional clipping code (the plot routine just does nothing when OOB). It will also make it way easier to add new line drawing options in the future, like dotted lines, thick lines, etc.

Here is the line drawing routine (I only just realized that my editor got confused about the tabs from Axe's code :P) : https://github.com/Zeda/Grammer2/blob/master/src/gfx/line.z80

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #460 on: December 03, 2019, 11:08:53 pm »
Okay, I've fixed a few bugs

The following kind of code was broken:
Code: [Select]
If <condition>
Then
    <<do stuff>>
    <<While, Repeat, For, or If/Then (but not If/Then/Else)>>
End:End
If the condition evaluates false, Grammer would search for the matching End token. However, I tried to be clever, and combined it with the code for when it is If without Then, and so it seeked the end of the line (specifically the newline token, colons (":") didn't count). Unfortunately, this meant that the second End was skipped, causing an outer loop to End prematurely. Oof.

In fixing this bug, I noticed another clever optimization that I had made which was really not clever and had broken "!If" for a while! !If works now :)


An unrelated bug is with copying data from archive to RAM if it crossed a page boundary. Once again, I thought I'd be clever and I noticed that I had an "adc hl,bc" in a place where the carry flag was guaranteed reset, so I "optimized" it to "add hl,bc" to save 4cc and a byte. Whelp, it turned out that I was using "adc hl,bc" because that one affects the sign flag, whereas "add hl,bc" doesn't. Ouch.


For loops had an update, specifically fixing the previously undocumented command For <<expr>> which would loop <<constant>> number of times. Today, @NonstickAtom785 found a bug when trying to use a variable as the expression. In actuality, it was a For bug affecting any expression that started with a pointer var! I fixed this by simply checking if the token following the pointer var was a comma. If it isn't a comma, treat it as an expression, otherwise, treat it as a normal For loop.


There were some updates to modules, too: I moved the verification step. Before, every time a module command was run, the module would have its header verified (look for the 4-byte magic number, then make sure the version was compatible). Grammer now verifies when you first initialize it ("5MYMOD->$) and assumes for subsequent calls to module functions that the module is still valid. This removes some overhead, but module functions are still slow to call, and likely always will be :P

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #461 on: January 18, 2020, 11:01:45 am »
Wow, lots of updates to report:

The GitHub page is getting a lot more documentation, thanks to @NonstickAtom785 (both in documenting and bugging me to document stuff).

Bug Fixes:
  • Fixed bug with Param
  • Fixed bugs with Input
  • Fixed bug with PauseIf. This was allowing un-breakable infinite loops!
  • Fixed bugs with Archive/Unarchive (and similar bugs). These could cause crashes.
  • Fixed bugs with archiving in the main menu
  • Fixed bug with empty strings
  • Fixed bug with ending quotes on strings!
  • Fixed Omnicalc/Batlib fonts
  • Fixed bug with not implementing screen invert :|

Updates:
  • Optimized Dispgraph
  • Added new display methods that allow overlaying or masking multiple buffers
  • Added smooth-scrolling tilemap routines! This is long overdue; I reserved space for more tilemap commands and it took 8 years to actually do it >_>
  • Reimplemented degree token to temporarily set a buffer
  • Added TI-OS fonts to the text routines (request)
  • Updated variable-width font at request to look like it used to.
  • Reimplemented ' option for the Menu( command.
  • Added DS<( to complement IS>( (nonstickatom)

We are now up to version 2.50.9.4 :)
You can find documentation on the GitHub, but I'll attach the .8xk

EDIT: Here's a screenshot implementing the smooth-scrolling tilemap commands and new DispGraph techniques:

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer 2-The APP
« Reply #462 on: February 01, 2020, 10:42:28 am »
@NonstickAtom785 : You were looking for this I think.

When I updated Grammer to 2.50, I declined to make a program launcher thing. (I used to supply an assembly program that could be used to either run a Grammer program, or execute in-line Grammer code.)

I had fun with creating this .gif showing that you can basically mix Grammer code inside a BASIC program (aside: The other way around is more difficult):


For compatibility reasons, I renamed the assembly program to prgmG250.
Code: [Select]
Inputs:
    - Ans is a string: Then it is the name of the Grammer program to execute.
    - Ans is not a string: Then the code following Asm(prgmG250 is executed as Grammer code up to a Stop,
      then it continues as TI-BASIC code.

So, some things to consider: I know when I make Grammer programs, I put subroutines after the Stop. If you tried to in-line one of those programs this way, the TI-BASIC parser would pick up at the subroutines, almost certainly causing an error! Instead, you'll want to reorganize your code like:
Code: [Select]
  <TI-BASIC code>

Asm(prgmG250
  <Grammer code>
Goto Lbl "Stop
  <subroutines>

.Stop
Stop

  <TI-BASIC code>


Basically, just make sure that the Stop that your Grammer code reaches comes right before where you want the TI-BASIC parser to pick up. In the example gif, the program I ran had no subroutines, so I didn't ave to worry about the structure.

A final note, prgmG250 should be compatible with at least v2.50.0.2 and after. I didn't check 2.50.0.0 and 2.50.0.1, but it should work with those, too.

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Re: Grammer 2-The APP
« Reply #463 on: February 03, 2020, 08:50:08 am »
Cool! Thanks for the post example.  :P . I've been wanting to use Grammer like a like a library for BASIC. Although it's technically not one. I just want it for good graphics and stuff. And math related things. Things I can't figure out how to work around in Grammer.
Grammer2 is Good!