Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Runer112 on August 30, 2013, 11:13:32 pm

Title: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on August 30, 2013, 11:13:32 pm
The latest version is attached at the bottom of this post.


GrayLib v1.0


== BASICS ==

What is GrayLib? GrayLib is an Axe library, designed for Axe 1.2.1, to provide nearly perfect grayscale and tons of useful related functions to Axe programmers with extensive customizability.


== FEATURES ==



== EXAMPLE PROGRAMS ==

To get a basic idea for how to use GrayLib, I have created a few example programs. One is a very basic wrapper for the default tuner, one is a screensaver-style bouncing text program, and one is a fairly complicated recreation of the movement engine from the first-generation Pokemon games, set in Pallet Town. Every example program comes in two forms: a smaller version, which contains just the code, and a larger "Commented" version. The commented versions contain detailed comments explaining exactly how each piece of the code works, and can be good resources for both learning how to use GrayLib and simply learning Axe coding approaches and tricks.

Spoiler For Animated screenshots!:
83+
84+
GRAYTUNE
GRAYTUNE
(http://i.imgur.com/fuH2WxU.gif)
(http://i.imgur.com/6XlWakX.gif)
GRAYTEXT
GRAYTEXT
(http://i.imgur.com/30zYdyP.gif)
(http://i.imgur.com/EVMOubM.gif)
GRAYPKMN
GRAYPKMN
(http://i.imgur.com/cJpweLV.gif)
(http://i.imgur.com/vuG9IyW.gif)

They look less flickery on real calculators, although more blurry.


== LEARNING TO USE GRAYLIB ==

GrayLib itself also comes in a small version and a commented version. The small version is good to store on your calculator if you don't need a reference on your calculator about how to use the library. Whether or not you want to store the commented version on your calculator, THE COMMENTED VERSION IS CRUCIAL TO LEARNING THE MYRIAD OPTIONS AND COMMANDS IN GRAYLIB.


== FEEDBACK ==

If you have any questions, comments, concerns, feature requests, or bug reports, make a post here and I (or somebody else who knows the library) will try to reply as soon as possible!


== CHANGELOG ==

1.0 (August 31, 2013)
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on August 31, 2013, 02:22:00 am
Pretty awesome, nice job!/me expects more grescale axe games now :P
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on September 01, 2013, 05:31:47 am
Wait so it's written in Axe ? O.O I thought it was an Axiom. Awesome job Runer !
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: nikitouzz on September 01, 2013, 05:40:46 am
awesome runer :D
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: TIfanx1999 on September 01, 2013, 07:49:49 am
Looks great Runer! :D
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on September 01, 2013, 10:38:27 am
Wait so it's written in Axe ? O.O I thought it was an Axiom. Awesome job Runer !

Axioms unfortunately don't offer the customizability that can be achieved by using constants as options, which is why I chose to go with a regular Axe library. Almost all of the code is actually Axe and not assembly anyways. :)
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on September 01, 2013, 10:41:46 am
Wait, what? O.O
That makes it even more awesome O.O
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: TIfanx1999 on September 01, 2013, 12:41:20 pm
Wait so it's written in Axe ? O.O I thought it was an Axiom. Awesome job Runer !

Axioms unfortunately don't offer the customizability that can be achieved by using constants as options, which is why I chose to go with a regular Axe library. Almost all of the code is actually Axe and not assembly anyways. :)

Hmm... interesting. I guess you would be able to make it quite optimized though, due to how familiar you are with the source. :P
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: XiiDraco on September 02, 2013, 01:02:41 am
This looks awesome! Now if I only knew how to use it...
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on September 02, 2013, 03:01:46 am
This looks awesome! Now if I only knew how to use it...

Well, try perusing the commented version of GrayLib with some computer 8xp viewer and check out the option constants and functions, which should all have comments explaining what they do. Also, check out the examples I provided, which should show a few examples of how a program interfaces with the library. If you have questions after that, I can answer them here. :)
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: pimathbrainiac on September 02, 2013, 12:39:30 pm
I thanketh thee very much. Also: thanks for putting up with my badgering, I'm sorry about that.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: DJ Omnimaga on September 02, 2013, 04:18:59 pm
Wow pretty nice! It's impressive too that you managed to get such quality grayscale in Axe and 4 level too.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: willrandship on September 10, 2013, 05:21:06 am
That is beautiful. Any chance for an 8-level (or higher) version?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on September 10, 2013, 07:50:35 am
pimath made one here: http://ourl.ca/19535
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on September 10, 2013, 09:33:15 am
Okay, I made him crash forever. I tried to set the darkest contrast setting I vould get, aaaand, GTune() now crash my calc! :D
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on September 11, 2013, 07:52:12 pm
Are you sure it actually crashed? The contrast settings wrap around, so it seems likely to me that you may have wrapped around from the darkest to the lightest setting, making the screen look blank and as if the calculator crashed.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on September 12, 2013, 02:25:08 am
Nevermind i did'nt understand what to use, I used Gon, and not GLoad... By the way, 'should do a tutorial or something like this.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: willrandship on September 12, 2013, 04:02:12 am
Aren't example programs included? That's all the tutorial you should need, along with proper AI docs.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on September 15, 2013, 05:54:24 am
I digged into them! I just didn't read correctly...

After some tests, this lib s fantastic, but too heavy for Hinawa.my fps drops to 1.5 fps if I use them... Don't draw too much with this lib!
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on September 15, 2013, 02:21:01 pm
Yeah, it uses a lot of processing time. Perhaps I should've mentioned this somewhere, but updating the screen at 60Hz drops the effective CPU speed down to only about 33%, so 2MHz for Normal and 6MHz for Full.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Aspiring on October 08, 2013, 07:08:10 pm
This is awesome!  :thumbsup:  Just tried it on my calc. I was able to make the flicker completely go away!
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: ClrDraw on November 26, 2013, 10:52:26 pm
I'm a little confused with this, could I see some example code to draw a grayscale sprite and display it please?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on November 27, 2013, 01:21:18 am
The simple answer is just draw them to a front buffer and back buffer like normal, but use GB1 and GB2 as the front and back buffers, respectively.

I whipped up the classic single-sprite-moving-around-on-the-screen demo for GrayLib. Code and screenshots and stuff below. The code is also attached in 8xp form, one file with the comments below and one with them stripped out.


(http://imageshack.us/a/img856/6356/q97.gif)


Code: [Select]
.GRAYSPRT
.An example GrayLib program by Runer112

.==GrayLib==

.4-level grayscale, 83+ support, GDisp(), GDisp() clears, GTune() (and first run auto run), GWait(), getKey support (always on)
1→°G4→°GS83→°GID→°GDC→°GIGT→°GIW→°GSGK
prgmGRAYLIB


.==SETUP==

.Enable grayscale
GLoad()
.Sprite X and Y positions
16→X→Y


.==MAIN==

.Main loop
While 1
 .Increment or decrement X by 2 if right or left is pressed, respectively, and increment or decrement Y by 2 if down or up is pressed, respectively, not letting the sprite go offscreen, and draw the first layer of the 8x8 grayscale sprite
 Pt-Off(getKey(3)*2+X-(?getKey(2)*2)+(≤88-1*2)→X,getKey(1)*2+Y-(?getKey(4)*2)+(≤56-1*2)→Y,Pic0,GB1)
 .Draw the second layer of the 8x8 grayscale sprite
Pt-Off(X,Y,Pic0+8,GB2)
 .Wait until the last frame has been fully dispalyed with each dither mask
 GWait()
 .Mark the new frame for display
 GDisp()
 .If VARS was pressed, run grayscale tuner
 !If getKey  xor 23
  GTune()
 End
.End the main loop if CLEAR was pressed
End!If  xor 24


.==TEARDOWN==

.Disable grayscale and quit
Goto GUnload


.==DATA==

.8x8 grayscale sprite
[FFFFC3C3C3C3FFFFFF81BDA5A5BD81FF]→Pic0
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: ClrDraw on November 27, 2013, 11:30:20 am
Perfect, thanks  ;D
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on November 27, 2013, 11:53:35 am
It sounds pretty simple to use. I'll have to check it out when I make a low resources greyscale prog.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on November 27, 2013, 02:16:15 pm
Runer, the scrolling mask you did in the Pokemon demo should be an actual function in your lib. That makes the rendered result quite clearer.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on November 27, 2013, 02:18:39 pm
Runer, the scrolling mask you did in the Pokemon demo should be an actual function in your lib. That makes the rendered result quite clearer.

That's a pretty good idea. Perhaps I should turn the whole 2D tilemapping engine from the Pokemon demo into an extension of GrayLib?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on November 27, 2013, 02:19:58 pm
Holy yes! A full powered grayscale lib! Oo
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Matrefeytontias on November 27, 2013, 02:43:34 pm
What Pokemon demo is that you're talking about ?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on November 27, 2013, 02:44:38 pm
I'm saying yes. O.O
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on November 27, 2013, 02:44:42 pm
Dig in the zip file, there is three examples source files.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Matrefeytontias on November 27, 2013, 02:47:15 pm
Oh I see O.O that's awesome ! +1 for full 4-lvl grayscale tilemapping engine !
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on November 27, 2013, 02:49:17 pm
Oh I see O.O that's awesome ! +1 for full 4-lvl grayscale tilemapping engine !
Well, I made one too. But it's dead as of now.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Eiyeron on November 27, 2013, 03:14:30 pm
Yeah, as long as Runer wants to do something  in Axe, you can't do better...
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on November 27, 2013, 03:40:39 pm
Yeah, as long as Runer wants to do something  in Axe, you can't do better...
I... guess so ? XD
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on April 25, 2014, 06:35:07 pm
How does one write text with the small font to the screen using GrayLib?
EDIT: Is it just me or is archive/unarchive broken with GrayLib on?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on April 26, 2014, 08:00:41 am
How does one write text with the small font to the screen using GrayLib?

Assuming that you actually mean writing text to the buffers (since direct writing to the screen with the interrupt running would be promptly overwritten), you want to use included gray text printing commands. Set the °GIT (GrayLib Include Text) constant to nonzero (preferably 1) to include the string printing core routines, GStr(), GStrG(), GChar() and GCharG(), and optionally set °GIDEC (GrayLib Include DEC) to include the GDec() and GDecG() routines and/or set °GITOK (GrayLib Include TOK) to include the GTok() and GTokG() routines. Each routine expects the value of the appropriate type to be printed in r1 (or simply given if the routine is a G...G() routine) and the color code to be in r2. One slight deviation to this rule is that the token printing commands expect a pointer to the token to be printed.

Because color codes were a structure entirely of my own design, I should probably explain them a bit. The commented version does mention that a color code is of the form 0b0000FFTT, where FF is the fill color and TT is the text color. To clarify that a bit, that means that fill color is a value from 0-3 that represents the desired background color (since text printing clears the area behind it), text color is also a value from 0-3, and the two should be combined into one number of the form fill_color*4+text_color. And to be super clear, the values 0-3 represent increasingly dark colors. When using 3-level grayscale, 0 is white, 1 is gray, and both 2 and 3 are black. When using 4-level grayscale, 0 is white, 1 is light gray, 2 is dark gray, and 3 is black.

EDIT: Is it just me or is archive/unarchive broken with GrayLib on?

It's possible, I'm not really sure how well those commands handle a third-party interrupt running when they're called. It may just be necessary to temporarily disable grayscale when performing them. Simply using FnOff followed by FnOn may work well enough, but if not, use the full-blown GOff() followed by GOn().
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on April 27, 2014, 08:29:22 am
Thanks!
Also, I had to use GOff() and GOn(), with FnOff and FnOn it still froze my calc.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on April 29, 2014, 12:28:09 pm
Didn't you mention that Graylib used L4 which is used by Archive/Unarchive commands ?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on April 29, 2014, 12:29:26 pm
L4 minus something IIRC, but I made GrayLib use other RAM areas anyways.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on April 29, 2014, 12:36:22 pm
Well... :blah:
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on April 29, 2014, 01:06:06 pm
Didn't you mention that Graylib used L4 which is used by Archive/Unarchive commands ?

It's mentioned in the comment for the related constant flag that determines whether or not GrayLib should automatically assign buffer storage locations.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: DJ Omnimaga on May 08, 2014, 01:22:54 pm
Some minor issue I noticed with Graylib when setting up grayscale frequency in Reuben Quest: If the frequency is set too low on the 84+, the calc keys becomes unresponsive and you have to remove a battery.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on May 08, 2014, 01:28:52 pm
It's normal because the CPU is almost 100%'d byt the interrupt. There should be a limit to prevent from getting too low or high.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: DJ Omnimaga on May 08, 2014, 01:50:38 pm
Yeah that's what I thought actually. Unfortunately, however, for some calcs this might actually be the best-looking grayscale setting, so removing that particular setting might hurt quality for some people. Maybe there could be something like a timer based on CPU usage where if you didn't press any key for a certain amount of time it exits automatically?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Streetwalrus on May 08, 2014, 02:48:34 pm
If it's set to that, all the game is slowed down. So it's safer to exclude it I think. Plus reading some theory in ThePenguin's tutorial on perfect grayscale, only a specific range is worth using. The best frequency is about 60Hz, the setting that slows the calc down is way beyond that.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on May 08, 2014, 05:09:45 pm
I can probably safely cap it at around 80Hz or 90Hz. If your screen's refresh rate is anywhere near that high, you can forget perfect grayscale anyways, there's not enough CPU time for it.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: c4ooo on April 20, 2015, 07:13:11 am
I have several things:
1) Can you replace all the lower case letters with uppercase ones in the commented version? they take up a lot of MEM. (lowercase letters are two bytes right?)
2)If i don't know weather my user is using a ti83 or a ti84 then how do i compile? Should i just fallback upon the ti83 method? Is there a way for greylib, when run, to automatically choose the correct setting?
3) Can i strip out every thing i don't need to just leave the timer/inturupt stuff.
4)Is there any advantage of using the Crystal timer (84 method) verses just using interrupts?
5)Doest using the Crystal timer (84 method) mess with the cpu speed?
AND LAST BUT NOT LEAST:
Your library can render text with all shades of back/fore ground. And yet when i asked about the ti84 and the location of the sprite sheets, you "At least, I hope that information's correct. I haven't tried any of this, but this would be my best guess as to doing it correctly." (https://www.omnimaga.org/general-calculator-help/where-does-ti-(84)-os-store-the-sprite-sheets-for-chars/msg399940/#msg399940). So how exactly do you render text? ("performs magic" is not a good enoufe explanation for me   ;) )
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Sorunome on April 20, 2015, 07:47:58 am
I have several things:
1) Can you replace all the lower case letters with uppercase ones in the commented version? they take up a lot of MEM. (lowercase letters are two bytes right?)
I recommend putting the uncommented version on your calculator, you can open the commented one in one of the many online editors there are
Quote
2)If i don't know weather my user is using a ti83 or a ti84 then how do i compile? Should i just fallback upon the ti83 method? Is there a way for greylib, when run, to automatically choose the correct setting?
You do that with
1->^^oGS83
before including the lib via prgmGRAYLIB
The library will handle all the differences for you!
Quote
3) Can i strip out every thing i don't need to just leave the timer/inturupt stuff.
That happens automatically while compiling!
Quote
4)Is there any advantage of using the Crystal timer (84 method) verses just using interrupts?
The gray will look way better if you use the crystal timers as the frequency can be adjusted way better. Again, graylib handles all that
Quote
5)Doest using the Crystal timer (84 method) mess with the cpu speed?
Well, any interrupt messes with the CPU speed, as while the interrupt is running the normal code can't run. So there's no way around that when using gray.
Quote
AND LAST BUT NOT LEAST:
Your library can render text with all shades of back/fore ground. And yet when i asked about the ti84 and the location of the sprite sheets, you "At least, I hope that information's correct. I haven't tried any of this, but this would be my best guess as to doing it correctly." (https://www.omnimaga.org/general-calculator-help/where-does-ti-(84)-os-store-the-sprite-sheets-for-chars/msg399940/#msg399940). So how exactly do you render text? ("performs magic" is not a good enoufe explanation for me   ;) )
sorry don't have an answer on that one :P
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on April 20, 2015, 04:45:05 pm
I have several things:
1) Can you replace all the lower case letters with uppercase ones in the commented version? they take up a lot of MEM. (lowercase letters are two bytes right?)

If you're trying to read and understand GrayLib in the calculator editor, you're probably going to have a bad time. It's a huge library that doesn't display well on a tiny screen, so navigating around in on a calculator isn't fun. Consider the lowercase letters taking up extra space a deterrent against trying to learn the library on-calc. :P

On a computer, you can also open multiple programs at once. Doing something like opening an example program and GrayLib together and looking at how they interact is probably the best way to get a feel for how to use the library. And the examples cover basically all the included commands and ramp up in difficulty, from simply invoking the built-in tuner, to screensaver-like bouncing text, to a very faithful clone of the first-generation Pokemon games' overworld movement engine.

2)If i don't know weather my user is using a ti83 or a ti84 then how do i compile? Should i just fallback upon the ti83 method? Is there a way for greylib, when run, to automatically choose the correct setting?

As Sorunome said, if both the 83+ and 84+ grayscale methods are included, the library will automatically choose the appropriate one based on which calculator the program is run on.


3) Can i strip out every thing i don't need to just leave the timer/inturupt stuff.

What Sorunome said about unused things being stripped out during compilation isn't exactly true. Axe doesn't have "real" functions, so the compiler doesn't have enough information to be able to remove unused code. But it does have preprocessor conditionals that allow the programmer to specify simple logic for whether or not to compile sections of the program. That's why there are so many options starting with GI, which stands for GrayLib Include. You'll notice that only the most essential two are included by default: saving/loading settings in an appvar across runs and "allocating" the four buffers. Even these can be disabled if you desire, but you'd need to implement your own logic to replace them.

4)Is there any advantage of using the Crystal timer (84 method) verses just using interrupts?

As Sorunome said, the crystal timer method provides much finer tuning. This makes it possible to minimize tearing artifacts, usually seen as a rolling horizontal line of garbled pixel values, much more. It may also provide more consistent tuning across different levels of battery charge.

5)Doest using the Crystal timer (84 method) mess with the cpu speed?

The CPU speed is unchanged by GrayLib. However, as Sorunome mentioned, the effective CPU speed of your code is greatly lessened because lots of CPU time is used by GrayLib. Your code probably only gets access to about 25% of the CPU time, which is unfortunate, but unavoidable. At least, it is on the 83+; I've been working on something to free up more CPU time with the crystal timer method, so stay tuned for that. :)

AND LAST BUT NOT LEAST:
Your library can render text with all shades of back/fore ground. And yet when i asked about the ti84 and the location of the sprite sheets, you "At least, I hope that information's correct. I haven't tried any of this, but this would be my best guess as to doing it correctly." (https://www.omnimaga.org/general-calculator-help/where-does-ti-(84)-os-store-the-sprite-sheets-for-chars/msg399940/#msg399940). So how exactly do you render text? ("performs magic" is not a good enoufe explanation for me   ;) )

The "magic" is a lot of assembly to somewhat efficiently convert the character bitmap (not an Axe bitmap!) produced by B_CALL(_LoadPattern) into sprite data that is then displayed with Axe's Pt-Mask(X,Y,PIC)ʳ (masked 8x8 sprite) command. This is done for each buffer, setting blank and invert flags (explained in a moment) as necessary to get the correct values for that buffer. Included in this "magic" is logic to blank out the character bitmap if the blank flag is set and logic to invert the character bitmap if the invert flag is set. Combinations of these two flags give the four possible combinations of black-on-white, white-on-white, white-on-black, and black-on-black.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: c4ooo on April 24, 2015, 07:11:39 am
-snip-
Ok thanks. But by "stip out" i litraly ment take all the Asm() opcodes out and insert them into my program.  :P

Ps: why cant you just make a small PDF for this, as i think it will be the easiest option for everybody.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on April 24, 2015, 08:45:31 am
Ok thanks. But by "stip out" i litraly ment take all the Asm() opcodes out and insert them into my program.  :P

I'm not sure why you'd want to try to manually extract code from the library. It seems more difficult to manage than just including the library with the desired settings. Even the absolute minimum required to make the library work requires code from at least half a dozen different places in the library.

Ps: why cant you just make a small PDF for this, as i think it will be the easiest option for everybody.

I'm not great at making fancy documentation... But I guess I could at least pull out all the definitions and their comments into a separate file to be able to see every setting and routine available without code cluttering it up.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: TIfanx1999 on April 24, 2015, 04:33:21 pm
-snip-
Ok thanks. But by "stip out" i litraly ment take all the Asm() opcodes out and insert them into my program.  :P

Ps: why cant you just make a small PDF for this, as i think it will be the easiest option for everybody.

The whole idea of a library is to make things easier. I don't see why you'd want to pick it apart to reuse the code just to do the same thing either. ???
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: c4ooo on April 26, 2015, 08:04:04 pm
-snip-
-snip-

The whole idea of a library is to make things easier. I don't see why you'd want to pick it apart to reuse the code just to do the same thing either. ???
So that I have a clear understanding of what is going on at any given moment. ^-^

Update: I've played around with it and it seems cool, but as a previous post mentions it takes like 33% of the cpu and even for a main menu of a prototype, the button controls are so sluggish it's kindof sad.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: c4ooo on April 30, 2015, 09:23:32 pm
Yes I know this is a double post, but I've successfully torn out the juicy asm codes and put them in my program. Just want to make sure that you will be ok with me doing so? I will credit you for "writing the greyscale interrupt code" in my programs. Also can you pls explain what exactly Gwait() does? <sarcastic comment> waiting seems the best thing to do when the interupt  takes up a third of the cpu time!</sarcastic comment>.
Ps, in an earlier post on this thread you said you where writing a more efficient timer interrupt. Was that implemented or is it still coming?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on April 30, 2015, 09:54:16 pm
I've successfully torn out the juicy asm codes and put them in my program. Just want to make sure that you will be ok with me doing so? I will credit you for "writing the greyscale interrupt code" in my programs.

I'm still not sure why you wanted to manually pull the library apart to include bits of it in your program instead of simply letting the library and its preprocessor conditionals handle it for you, but I guess that's your prerogative. The point of the library is for people to be able to use the code after all, although you've done so in a strange way.

Also can you pls explain what exactly Gwait() does?

GWait() waits until the frame most recently offered up for display with GDisp() has been "fully" displayed. This means displayed twice for 3-level grayscale and displayed three times for 4-level grayscale, as that's how many grayscale updates it takes to go through all the phases of the dithering mask so all of the pixels have been displayed for the correct ratio of time. Whether or not this actually improves the visual quality, I'm not totally sure. But it's also useful as a timing mechanism to keep your program running at a constant rate.

<sarcastic comment> waiting seems the best thing to do when the interupt  takes up a third of the cpu time!</sarcastic comment>.

One third? I think you might be dreaming. The interrupt takes more like three fourths of the CPU time. I should probably add this information to the first post/readme to clarify for potential users that "perfect" grayscale is a very expensive feature.

Ps, in an earlier post on this thread you said you where writing a more efficient timer interrupt. Was that implemented or is it still coming?

I'm still experimenting with it. Nothing I can put into the library yet, but work is being done.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: c4ooo on May 01, 2015, 06:17:03 am
-snip-
Alright thanks!  :thumbsup:
One third? I think you might be dreaming. The interrupt takes more like three fourths of the CPU time.
I ment two-thirds but somehow I managed to loos the "two". :w00t:

Moderator edit: Fixed malformed quote BBCode.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Haobo on May 05, 2015, 11:41:48 am
When I used GIHB for some before hooks, I think it didn't work for me. Used it a while ago, so don't know the specifics of what was wrong. When I looked at the code, it also called up a subprogram called GHB0(), which does not exist. Is it a typo with the last label of GHB?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: Runer112 on May 05, 2015, 12:26:08 pm
When I used GIHB for some before hooks, I think it didn't work for me. Used it a while ago, so don't know the specifics of what was wrong. When I looked at the code, it also called up a subprogram called GHB0(), which does not exist. Is it a typo with the last label of GHB?

Yes, this was a typo. I fixed it a while ago in my local development copy of GrayLib, but seeing as it took until now for someone else to run into the issue, I didn't think it was worth a new release to fix it.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: c4ooo on May 05, 2015, 03:47:15 pm
Hay runer, why does the interrupt call tin84() every time it is executed? I know it probably does not take much cpu time, but its not like the user's calculator will switch from a ti84+ to ti83+ or vice versa wile the program is being executed.  x.x

Edit: read the IRC log. Still, after being used to the philosophy that every last cpu cycle counts, your throwing several away several amazes me.
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: ibid on December 29, 2017, 03:12:59 am
Doing a zoom compile with the °GIT set to 1 throws an ERROR: Undocumented on the "performs magic" line of GreyLib.

Why is this?
Title: Re: [AXE LIBRARY] GrayLib: (nearly) perfect grayscale
Post by: E37 on December 30, 2017, 03:34:13 pm
Doing a zoom compile with the °GIT set to 1 throws an ERROR: Undocumented on the "performs magic" line of GreyLib.

Why is this?
It is a bug with the compiler. There probably is a hacky solution, but I don't know what it would be. You just can't use zoom compile with it for now.