* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: libcarrot -- a healthy alternative to fxlib  (Read 792 times)

0 Members and 1 Guest are viewing this topic.

Offline Cakeisalie5

  • New User
  • Join Date: Jul 2016
  • Location: France
  • Posts: 13
  • Post Rating Ratio: +2/-0
  • I like to pasta.
    • @thecakefive
    • cakeisalie5
    • Personal website
  • Gender: Male
libcarrot -- a healthy alternative to fxlib
« on: April 21, 2017, 12:10:50 am »
For making apps on GNU/Linux for the fx-9860G, we had two main libraries in the CASIO community:
  • the fx-9860G library (fxlib), which appeared in 2006 with the SDK and hasn't been updated since;
  • gint, some sort of "kernel library" which takes control of the machine for a better control over it.
Ideally, for making an app under GNU/Linux, you would just have to use gint; the fact is, gint is already a two-years old project and even if it is still in active development, some features are missing and will probably be for some time, such as serial/usb port management, so for quick hacking, I was using fxlib. Unfortunately, fxlib is not well done at all, the conversion to GNU/Linux is subject to some fails (sprintf doesn't work correctly), and is made to be C89-compliant where I like to develop using the C99/C11 standard, so headers such as inttypes.h are missing.

This library is a solution to all of these problems. It still uses the system for most things, such as hardware control, though re-implements some functions in the system such as drawing functions in order not to be too slow.

It is an in-development project I've had for a month now. Its sources are available on Github:

>> grab it! <<

The fact is, I'd like to focus more on the P7 project, and would like to hand this project over to someone else. In order to ease this, I made a contribution guide that describes more or less accurately the coding style I have been using up to now, and a TODO list. Is anyone here interested in taking over this project? I'd really like it :)
« Last Edit: April 21, 2017, 12:30:00 am by Cakeisalie5 »


  • Calculators owned: Graph 65, Graph 100, fx-9750GII-2, Graph 75+E
Leader of the P7 Project, for communication utilities with CASIO calculators.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18606
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: libcarrot -- a healthy alternative to fxlib
« Reply #1 on: April 21, 2017, 12:25:30 am »
Something cool, if it's possible, would be a  way to use those libs inside BASIC programs.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Cakeisalie5

  • New User
  • Join Date: Jul 2016
  • Location: France
  • Posts: 13
  • Post Rating Ratio: +2/-0
  • I like to pasta.
    • @thecakefive
    • cakeisalie5
    • Personal website
  • Gender: Male
Re: libcarrot -- a healthy alternative to fxlib
« Reply #2 on: April 21, 2017, 12:29:37 am »
To be honest, I'm not sure I understand what you mean. This lib is basically a libc, which is the "bare minimum" (what every C program should be able to use, whatever the platform) for any C program. It is made to write C programs for the fx-9860G. This lib in fact provides more, because it also includes other libraries (or, aims to).
If by this you mean writing an extensible Basic interpreter, well technically if it is written in C (or, if it is one day supported, C++), it can use this library. Making it accessible from Basic is a totally different story... x)
  • Calculators owned: Graph 65, Graph 100, fx-9750GII-2, Graph 75+E
Leader of the P7 Project, for communication utilities with CASIO calculators.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18606
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: libcarrot -- a healthy alternative to fxlib
« Reply #3 on: April 21, 2017, 04:38:50 am »
Well it can be hard to understand what I mean as a Casio-only programmer @Cakeisalie5 .

On the TI calculators, particularly the 83+ series, there are several assembly language programs which allows TI-BASIC programmers to use new commands such as sprites, drawing rectangles and such things, either via the Asm() command or via parser hooks added via an add-in. Unfortunately, this was never even attempted on Casio calculators, which I still don't get why, because I am fairly sure that there is a way to do it. This makes me think that C programmers in the Casio community hates BASIC programmers or BASIC itself and just don't want BASIC programmers to benefit from any language enhancements, instead wanting to force them to switch to C/ASM, even though both C and ASM are way too hard to learn for most BASIC programmers (like myself. I tried multiple times to no avail).
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 3010
  • Post Rating Ratio: +27/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • @juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: libcarrot -- a healthy alternative to fxlib
« Reply #4 on: April 21, 2017, 06:15:28 am »
Yeah, it's a bit hard to understand when you don't really know C. Seems Casio BASIC is so slow, even with libs a la 83+, devs prefer to learn C instead. If you want your C program to do anything remotely useful, you'll need a standard library (aka libc) containing all the basic functions your program will compile against. On calcs like Casios, this libc also includes functions to work with the screen, keypad, IO port, filesystem, etc. so programming for it will be easier. Most of those functions have BASIC equivalents, so making it a BASIC lib like DJ says kind of not makes sense or would probably not work within the usual BASIC interpreter without breaking everything. So yeah. Reimplementing BASIC or making a fast BASIC lib would be cool, yeah, but it's not really the point of this project, but such project will be able to use this one at its core.
« Last Edit: April 21, 2017, 06:25:59 am by Juju »
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
On hiatus until when the sun goes dark in plain day. Might be on once in a while, but don't count on it.
Won't have internet on Aug 21-23, so try to not kill each other during that time.
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

Offline Lephe

  • New User
  • Join Date: Mar 2017
  • Location:
  • Posts: 6
  • Post Rating Ratio: +0/-0
  • A nice, sharp blade.
Re: libcarrot -- a healthy alternative to fxlib
« Reply #5 on: April 21, 2017, 06:53:58 am »
I would like to answer DJ Omnimaga's remarks about enhancing BASIC programming using add-in applications. The Casio BASIC interpreter is already very slow on fx-9860G and the lack of some elementary functions such as "clear line" does not help. We even imagined that Casio could have willingly slowed it down; on fx-9860G we can't be really sure because older SH3 processors are not that fast and usually downclocked, but when it comes to more recent models such as fx-CP400, it is just unbelievable that a calculator than can handle a large screen's rotation in real time can fail to smoothly run a pong.

That was just to suggest how much we battle against this interpreter instead of using it. Our rule of thumb to estimate whether a drawing method will be fast is "the less parsing, the faster". The best method we currently have to draw sprites is to render a parametric graph whose functions are list-subscripts and take advantage of the rendered lines to display what we want. This is not convenient in any way, and there is no obvious method for optimally converting images into lists of points for this method.

I had known for some time that an Asm() command existed, but I was not sure that it actually allowed you to execute native code. Is it the case?

As for "parser hooks", I'd be glad to know how you do this, because we have virtually no power on the behavior of the Casio BASIC interpreter. The only real project about enhancing BASIC applications, which was called "PRGM2", was some kind of weird hack in the form of an add-in, that would set up a timer to run every 10 milliseconds or so, launch the original parser via the PRGM application using a syscall, and wait for the BASIC program to load a function number into variable F. The timer would regularly check this variable, and execute a predefined function if it was non-null. Which means that PRMG2 programs looked a bit like:

Code: [Select]
'PRGM2              # Indicate this is a PRGM2 program in a comment

64->X               # X center of circle
32->Y               # Y center of circle
16->R               # Radius
5->F                # Function 5: draw filled circle (for instance)
While F:WhileEnd    # Wait for PRGM2 to catch and execute request

Which is very hard to maintain. The greatest problem in this question of enhancing BASIC is that whatever we do, it requires add-in support and not everyone has a calculator that can execute add-ins. In fact, the most common model can't. But then if you have add-in support, you'd better write an add-in yourself. It would be faster and it could be shaped precisely the way you want using appropriate data structures, functions, dual-buffering, and more.

I think this pretty sums up the situation. It's true though, that C programmers statistically don't come back to BASIC after they managed to write a proper add-in, so only very few people are interested in BASIC enhancement using add-ins.
« Last Edit: April 21, 2017, 06:56:28 am by Lephe »

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18606
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: libcarrot -- a healthy alternative to fxlib
« Reply #6 on: April 21, 2017, 07:05:19 am »
Maybe @tr1p1ea might be able to explain how parser hooks are implemented on the TI models, as he's one of the guys who made parser hook-based apps on TI calcs, such as xLIB and parts of Doors CSE BASIC libs. They are very popular libraries because BASIC programmers can make JRPGs or puzzle games that looks as good as C games but without having to learn C itself.

As for the speed of Casio fx-9860G BASIC, it's pretty much the same as TI-83+ BASIC, although Locate is much faster than Output() (so fast that even grayscale is possible). But drawing commands are a bit slower. On the fx-CG10/20/50 it's a disaster.


I guess something like C.Basic or PRGM2 could work, although PRGM2 is dead and C.Basic is actually a brand new interpreter. But it still doesn't add features such as sprites, if I recall correctly, and it lacks fx-CG10/20/50 support.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 3010
  • Post Rating Ratio: +27/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • @juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: libcarrot -- a healthy alternative to fxlib
« Reply #7 on: April 21, 2017, 07:15:13 am »
Yeah, the thing with parser hooks, it's not that it's been attempted, but we don't know if it's even possible to do these just like on a TI. We're talking about a 32-bit system far more complex than the 8-bit CPU we have for TI's Z80 calcs, after all. In the end, better make a brand new interpreter, probably. We have Lua on it, like on the Nspire, which isn't bad.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
On hiatus until when the sun goes dark in plain day. Might be on once in a while, but don't count on it.
Won't have internet on Aug 21-23, so try to not kill each other during that time.
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

Offline Cakeisalie5

  • New User
  • Join Date: Jul 2016
  • Location: France
  • Posts: 13
  • Post Rating Ratio: +2/-0
  • I like to pasta.
    • @thecakefive
    • cakeisalie5
    • Personal website
  • Gender: Male
Re: libcarrot -- a healthy alternative to fxlib
« Reply #8 on: May 08, 2017, 09:42:53 pm »
I don't look for a maintainer anymore, I'm taking this project again, even though I'm reorganizing it and making something else from it (a general libc for all the platforms I want to port it to). ^^
  • Calculators owned: Graph 65, Graph 100, fx-9750GII-2, Graph 75+E
Leader of the P7 Project, for communication utilities with CASIO calculators.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18606
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: libcarrot -- a healthy alternative to fxlib
« Reply #9 on: May 09, 2017, 04:45:12 am »
Glad to hear. ^^
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games