Join us on Discord!
You can help CodeWalrus stay online by donating here.

[fx-9860G] libcarrot -- a healthy alternative to fxlib

Started by Cakeisalie5, April 21, 2017, 12:10:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cakeisalie5

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 :)
  • Calculators owned: Graph 65, Graph 100, fx-9750GII-2, Graph 75+E
Leader of the P7 Project, for communication utilities with CASIO calculators.

Dream of Omnimaga

Something cool, if it's possible, would be a  way to use those libs inside BASIC programs.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Cakeisalie5

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.

Dream of Omnimaga

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-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Yuki

#4
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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
Read Zarmina!
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

Lephe

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:

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

Dream of Omnimaga

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-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Yuki

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???)
  • Consoles, mobile devices and vintage computers owned: A lot
Read Zarmina!
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

Cakeisalie5

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.

Dream of Omnimaga

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Powered by EzPortal