andymwat wrote:
Waaangyi wrote:
I don't know if it is my code's problem or the toolchain has a bug, it shows that weird symbol, when I exit the program there is no ram clear, it appears as soon as I run the program. (I am pretty new to toolchain)

Code:
////////////////////////////////////////
// CFACTOR 1.0
// Author: Waaangyi
// License: None
// Description: Factor family version 6
////////////////////////////////////////

/* Keep these headers */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

/* Standard headers */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Other available headers: stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h */

/* Put function prototypes here */
void printText(const char *text, uint8_t xpos, uint8_t ypos);
void printTextSmall(const char *text, uint8_t xpos, uint8_t ypos);

/* Put all your code here */
void main(void)
{
    char a[10];
    char b[10];
    char c[10];
    uint8_t current_size = 0;
    const uint8_t delay_time=23;
    uint8_t times = 1;
    const char cleanup[26] = "                          ";
    bool first_input = true;
    const uint8_t max_size = 8;
    sk_key_t key = sk_Prgm;
    os_ClrHome();
    printText("THE FASTEST VERSION EVER!",0,0);
    printText("FINDER 2.0",0,1);
    printText("VERSION 6",0,2);
    printText("9 DIGIT MAX",0,3);
    printText("FORM:AX^2+BX+C",0,4);
key_input:
    first_input = true;
    printText(cleanup,0,6);
    printText(cleanup,0,8);
    if (times==1)
        printText("A:",0,5);
    if (times==2)
        printText("B:",0,5);
    if (times==3)
        printText("C:",0,5);
    while(key!=sk_Enter || current_size==0)
    {
        key = os_GetCSC();
        if (key==sk_1)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"1");
                if(times == 2)
                    strcpy(b,"1");
                if(times == 3)
                    strcpy(c,"1");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"1");
                    if(times == 2)
                        strcat(b,"1");
                    if(times == 3)
                        strcat(c,"1");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_2)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"2");
                if(times == 2)
                    strcpy(b,"2");
                if(times == 3)
                    strcpy(c,"2");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"2");
                    if(times == 2)
                        strcat(b,"2");
                    if(times == 3)
                        strcat(c,"2");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_3)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"3");
                if(times == 2)
                    strcpy(b,"3");
                if(times == 3)
                    strcpy(c,"3");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"3");
                    if(times == 2)
                        strcat(b,"3");
                    if(times == 3)
                        strcat(c,"3");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_4)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"4");
                if(times == 2)
                    strcpy(b,"4");
                if(times == 3)
                    strcpy(c,"4");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"4");
                    if(times == 2)
                        strcat(b,"4");
                    if(times == 3)
                        strcat(c,"4");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_5)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"5");
                if(times == 2)
                    strcpy(b,"5");
                if(times == 3)
                    strcpy(c,"5");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"5");
                    if(times == 2)
                        strcat(b,"5");
                    if(times == 3)
                        strcat(c,"5");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_6)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"6");
                if(times == 2)
                    strcpy(b,"6");
                if(times == 3)
                    strcpy(c,"6");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"6");
                    if(times == 2)
                        strcat(b,"6");
                    if(times == 3)
                        strcat(c,"6");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_7)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"7");
                if(times == 2)
                    strcpy(b,"7");
                if(times == 3)
                    strcpy(c,"7");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"7");
                    if(times == 2)
                        strcat(b,"7");
                    if(times == 3)
                        strcat(c,"7");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_8)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"8");
                if(times == 2)
                    strcpy(b,"8");
                if(times == 3)
                    strcpy(c,"8");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"8");
                    if(times == 2)
                        strcat(b,"8");
                    if(times == 3)
                        strcat(c,"8");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_9)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"9");
                if(times == 2)
                    strcpy(b,"9");
                if(times == 3)
                    strcpy(c,"9");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"9");
                    if(times == 2)
                        strcat(b,"9");
                    if(times == 3)
                        strcat(c,"9");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
        if (key==sk_0)
        {
            if (first_input)
            {
                if(times == 1)
                    strcpy(a,"0");
                if(times == 2)
                    strcpy(b,"0");
                if(times == 3)
                    strcpy(c,"0");
                first_input = false;
                current_size++;
            }
            else
            {
                if(max_size>=current_size)
                {
                    current_size++;
                    if(times == 1)
                        strcat(a,"0");
                    if(times == 2)
                        strcat(b,"0");
                    if(times == 3)
                        strcat(c,"0");
                }
            }
            if(times == 1)
                printText(a,0,6);
            if(times == 2)
                printText(b,0,6);
            if(times == 3)
                printText(c,0,6);
            delay(delay_time);
        }
    }
    current_size = 0;
    if (times!=3)
    {
        times++;
        goto key_input;
    }
    while(!os_GetCSC());
}

/* Draw text on the homescreen at the given X/Y location */
void printText(const char *text, uint8_t xpos, uint8_t ypos)
{
    os_SetCursorPos(ypos, xpos);
    os_PutStrFull(text);
}

/* Draw small text at the given X/Y location */
void printTextSmall(const char *text, uint8_t xpos, uint8_t ypos)
{
    os_FontSelect(0); // sets small font (1 == big, see docs)
    os_FontDrawText(text, xpos, ypos);
}




I haven't had time to look at your code in depth, but my first guess would be that your strings aren't null-terminated. Almost always, strings in C should end with '\0', AKA the "null terminator" character which indicates the end of the string. Without that character, functions that use the string will read past the end of the character array and produce garbage.

Thanks, I solved this problem. So I guess you donít have to look in-depth the code Smile
is there a way you can add 16bpp functions to the toolchain?
There's a way, but not a will.
Runer112 wrote:
There's a way, but not a will.

Can you please elaborate...
What is the process? How come no one wants to use 16bpp graphics? Confused
The process is that you reimplement basically all of GraphX. Considering the current 8bpp GraphX works well and will always be faster than a 16bpp version, I doubt any of the main contributors think this small payoff is worth the huge amount of time it would take.
Alvajoy123 wrote:
Runer112 wrote:
There's a way, but not a will.

can you please elaborate...
What is the process?
How come no one wants to us 16bpp graphics? Wink

Why do you need them? Convpng provides a custom palette that automatically matches the best possible 16 bit colors for a 256 color space. Literally there's no point behind 16bpp graphics; plus they are much slower.
Toolchain v8.6 is here! Some notable improvements include:

  • DrDnar has added another new 'Standard' CE C library, FontLibC. This library provides awesome support for working with and displaying different fonts and glyphs, and works alongside the fileioc library to load fonts dynamically from an appvar as well. There are a whole bunch of features, so see if you can integrate it into your next project!
  • Some bugs present in the fileioc and os_GetStringInput function have been repaired.
  • All the submodules (convpng, convfont, convcsv, convhex) have been updated with new features as well, to make development easier.

This will probably be the last v8 release before v9.0, which will include 3 USB libraries, namely usbdrvce, fatdrvce, and srldrvce. Stay tuned!

Latest CE C Toolchain: https://github.com/CE-Programming/toolchain/releases/latest
Latest CE C Libraries: https://github.com/CE-Programming/libraries/releases/latest
Toolchain v9.0 is here! Here's the standard links:

Latest CE C Toolchain: https://github.com/CE-Programming/toolchain/releases/latest
Latest CE C Libraries: https://github.com/CE-Programming/libraries/releases/latest

And here's the latest release notes, copied from GitHub:

Quote:
Getting Started

Read the Getting Started Guide.

CE Libraries

The CE C Toolchain can use the 'Standard' CE Libraries.
These libraries add runtime support for fast graphics, file access, keypad integration, and more.
Download them at the above link, and add the appropriate headers in your source to use the supplied functions.
Documentation for the libraries can be found here.

The major upgrade from ZDS to LLVM

The toolchain is from now on based on LLVM, an open-source retargetable compiler infrastructure, and @jacobly0 created an (e)z80 backend!
This is a major milestone as it allows the CE toolchain to move away from using the legacy Zilog ZDS compiler, which is closed-source, proprietary, only worked on Windows, and contained numerous bugs.
Thanks to LLVM, later standards of the C and C++ languages are supported (you're not stuck with C89 anymore!), code optimization actually works, and the compiler is able to run natively across multiple platforms. The fact that it is open-source and community-maintained means that bugs can actually be fixed and improvements/feedback can come from anyone.

Note: No STL is provided for C++ source code (i.e. no `std::string`, no `std::vector`, etc.). Currently only language support is offered.

Updating your projects for this new toolchain version

In programs you build with this new toolchain, you should notice performance or speed improvements, depending on the optimization level you choose ... or even both Smile

But the massive internal changes in the toolchain *do* mean that some programs might not compile right away anymore.
In fact, first, after installing the new toolchain, you'll have to update your projects' makefile. It's only a few lines, and a template makefile can be found here.

Regarding potential source code related migration, don't worry, it shouldn't be too difficult to fix your code. Here are some differences:

  • Old-style inline assembly will most likely not work, you'd have to write it like the compiler outputs it, in the format fasmg-ez80 expects. Update any assembly source modules with the guide described here.
  • Many new errors and warnings may be generated as the compiler is able to better infer. These should be fixed, and programs should compile without any warnings.
  • If your program was using 64-bit types (for instance `long long`), it may not build (link, more specifically) anymore. In fact, the ZDS compiler even made those 32-bit. If there's enough justified demand for actually supporting 64-bit types properly, we may work on it.
  • The convimg project has been updated to support a new YAML format that is easier for beginners and tooling. The previous toolchain release (v8.Cool also used a YAML format, however some slight modifications were made in order to make it standard-compliant. Example `convimg.yaml` conversion files can be found in the examples.


Other changes and improvements

You can find the a more detailed list of changes (and a link to the commits) in the changelog file, but here are the other important changes in addition to the compiler change:


  • Lots of cleanup and improvements to the standard includes and headers in general, made possible by the compiler change mentioned above.
  • New **fileioc** function: `ti_SetGCBehavior` to set routines to run before and after a garbage collect would be triggered.
  • New **keypadc** defines: many keypad key defines corresponding to the TI-83 Premium CE keypad were added for easier coding.
  • New **usb.h** function: `usb_BatteryCharging` to check if the battery is currently charging.
  • Revamped v/s/printf functions, now available if needed thanks to a light third-party library, see docs.
  • New: fileioc-powered (by default) implementation for file IO functions, see docs.
  • New C++ header-only "library" for easily manipulating "TI real" numbers (see this PR), making some math operations easier. See examples.
  • `abort()` doesn't generate code that would make CEmu open its debugger anymore - you can use the specific debug functions for that now.
  • Documentation improved and revamped. Available on online here, which replaces the repo's wiki.


Let's thank once again @jacobly0 for his spectacular work (years in the making), as well as everybody who contributed in one way or another, to this release 🥂

Happy coding!
Epic!
Thanks, everyone for all the work that has gone into this amazing toolchain.
I've had a lot of fun using it, and I'm sure others have too.
The toolchain release is, as always, very good. I can't seem to be able to use that usb_BatteryCharging() function though, and a quick look at the Github page suggests that the usb.h file is nowhere to be found. How can I use this function in my programs?
Apparently it's actually in tice.h, see here. So, boot_USBBatteryCharging.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 17 of 17
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement