Would you use SmartNotes CE when I finish it?
 21%  [ 3 ]
 14%  [ 2 ]
If you finish...
 64%  [ 9 ]
Total Votes : 14

So I have been working on a text editor for the TI 84 PCE in ICE recently, and just yesterday I started porting the program to C. I am very new to C, so pardon any n00b mistakes i have made, am making, and might (will) make in the future. Up to this point, I have only been working on the homescreen and file detector/shell (detects appvars starting with "TXT"). Here is a screenshot:

However, when porting the program to C, I encountered a strange error:

I encountered this earlier when programming in ICE but never found what caused it. right now i am using gfx_SetDraw(1) and gfx_SwapDraw() in a while loop.


#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <keypadc.h>
#include <compression.h>
#include <graphx.h>
#include <fileioc.h>

/*necessary information
-3 modes
   mode 1 = homescreen
   mode 2 = editor
   mode 3 = settings
-3 txt modes
   mode 1=Caps
   mode 2 = math
   mode 3 = lowercase


/* functon prototypes */
//char * input_string(char*, char*, uint8_t, uint8_t, uint8_t);
void exitFull();
void handleKeyPresses();
void dispButtons(uint8_t);
void dispFiles();
uint8_t waitForGetKey();
void archiveAll();

/* main loop */
int main() {
   uint8_t mode = 1; // 3 modes are homescreen, editor, and settings. DIFFERENT from txtMode
   // main homescreen loop. displays files, options, etc...
   while(1) {
      uint8_t numFiles = 0; // total number of files detected
      uint8_t numFilesShown = 0; // number of files currently shown on screen. can't be more than 10
      uint8_t fileSlot; // slot of currently detected file
      uint8_t numFile = 0; // number of currently detected file
      uint8_t fileY = 61; // y coord for currently detected file
      char * fileName; // pointer to name of currently detected file
      int fileSize = 0; // size of currently detected file
      uint8_t selectedNum = 0; // number of currently selected file
      char * selectedName; // pointer to name of selected file


      gfx_PrintStringXY("SMARTNOTES CE",115,5);
      gfx_PrintStringXY("VERSION 1.0 BY JOHNPAUL MALLOY",55,20);

      // displays the button options (delete, rename, settings, open, etc...)
      // dispButtons(mode);

      // close all open slots

      // vat offset for appvar detection loop
      void *search_pos = NULL;
      // loop to detect and display files
      while (((fileName = ti_Detect(&search_pos, "TXT")) != NULL) && (numFilesShown<10)) {

         // get file info, archive all text file appvars detected et cetera...
         fileSlot = ti_Open(fileName,"r");
         fileSize = ti_GetSize(fileSlot);

         // display currently selected file with highlighting rect
         if (selectedNum == numFile) {
            // check if should be deleted
         } else {

         // display detected file name & size
         // update search-dependant vars
         fileY += 15;
      // display when no appvars are found
      if (numFiles == 0) {
         gfx_PrintStringXY("--NO FILES FOUND--",93,80);
      // move selected down
      if ((getKey(1)) and (SELECTED<9) and (SELECTED<NUMBER-1))
      // move selected up
      if getKey(4) and (SELECTED>0)
      // button functions(new file, etc...)
      // create new file
      If getKey(50
         Call NEW
      // delete selected file (name = os_Str1)
      If getKey(51
         Call DELETE


      // move selected down
      if((kb_IsDown(kb_KeyDown)) && (selectedNum < numFiles)) {
      } else if((kb_IsDown(kb_KeyUp)) && (selectedNum > 1)) {
      } else if((kb_IsDown(kb_KeyClear))) {
      } else if((kb_IsDown(kb_KeyZoom) && (numFiles >0))) {
      } else {


// string input needs work. like a lot of work.
char * input_string(uint8_t min_len, uint8_t max_len, uint8_t x, uint8_t y) {
   while(1) {

   return string;

void dispFiles()
   uint8_t numFiles = 0; //total number of files detected
   uint8_t numFilesShown = 0; //number of files currently shown on screen. can't be more than 10
   uint8_t fileSlot; //slot of currently detected file
   uint8_t fileNum = 0; //number of currently detected file
   uint8_t fileY = 61; //y coord for currently detected file to be displayed at
   char * fileName; //pointer to name of currently detected file
   int fileSize; //size of currently detected file
   uint8_t selectedNum = 0; //number of currently selected file
   char * selectedName; //pointer to name of selected file

   void *search_pos = 0;
   //loop to detect and display files
   while (((fileName = ti_Detect(&search_pos, "TXT")) != NULL) && (numFilesShown<10)) {
      //have to do this before calling any file IO functions
      //get file info...
      fileSlot = ti_Open(fileName,"r");

      //display currently selected file with highlighting rect
      if (selectedNum == fileNum){
         selectedName = fileName;
      } else {
      //display detected file name & size
      //update search-dependant vars
      fileY += 15;

void dispButtons(uint8_t mode)
   int i = 0;
   if(mode == 1) {
      //button rects at bottom of screen
      for(i=0; i<320; i=i+64) {
      //button text

void handleKeyPresses(int mode)

void archiveAll()
   uint8_t fileSlot;
   char * fileName;
   int search_pos = NULL;
   while (((fileName = ti_Detect(&search_pos, "TXT")) != NULL)) {
      fileSlot = ti_Open(fileName, "r");
      ti_SetArchiveStatus(1, fileSlot);

void exitFull() {

Thank you in advance for any help I receive!
Edit: Jacobly reminded me to put gfx_Begin(); and it worked.
Here is the Github Repo: https://github.com/randomguy70/SmartNotesCE
I have only been coding in C for a few weeks, so please please tell me if I should format anything differently, or if I am making any n00b mistakes!
Thank you in advance!
I was asked about getting GetCSC scan codes using keypadc, so here you go:
uint8_t get_single_key_pressed(void) {
    static uint8_t last_key;
    uint8_t only_key = 0;
    for (uint8_t key = 1, group = 7; group; --group) {
        for (uint8_t mask = 1; mask; mask <<= 1, ++key) {
            if (kb_Data[group] & mask) {
                if (only_key) {
                    last_key = 0;
                    return 0;
                } else {
                    only_key = key;
    if (only_key == last_key) {
        return 0;
    last_key = only_key;
    return only_key;
progress update: i gave up on using appvar text data files, and am using some simple hexadecimal character arrays instead. now the input text function works. this is the first time in a while I have been able to work on this at all Smile.
Congrats Smile, on finishing the input routine.
Okay, so apparently this code is not working; it is supposed to copy the pointers to the names of every txt appvar to an array of string pointers.


uint8_t loadFileNames(char **buffer) {
   uint8_t numFiles = 0;
   char *namePtr;
   void *search_pos = NULL;

   while ((namePtr = ti_Detect(&search_pos, "TXT")) != NULL) {
      uint8_t i = 0;
         buffer[numFiles][i] = namePtr[i];
   return numFiles;

char fileNames[20][9] = {0};

thank you in advance1 Very Happy

Jacobly helped me to fix it.
are there any good monospace fonts that anybody would like to recommend? I think I will use monospace for this project because it would make my life a lot easier!😆
FiraCode is an awesome monospace font. You should definitely try using it.
does this string copying function work? I have issues with my code, so I am not sure if this is it.


char* strcopy(char* dest, const char* src) {
   uint8_t strPos = 0;
   while(src[strPos]!= '\0') {
      dest[strPos] = src[strPos];
   if(!strPos) {
      return NULL;
   } else {
      return dest;

following mateo's wise advice, i am now using strcpy
Why aren't you just using strcpy.
Well, I haven't had too much time to work on this recently, but I fixed the fileScrolling bugs, added file renaming, added and refined colors in my palette, cleaned up a ton of code, and created several sprites (which I haven't implemented yet). There are still several minor bugs which I will fix shortly, and then I will move on to opening files and displaying their actual text.
Well, in the past few days I added sprites, updated the gui graphics considerably, and am now going to start working on an extra menu for the home screen.
Here is the link to the main branch of the repo: https://github.com/randomguy70/SmartNotesCE
Here is the link to the working branch of the repo which I update more often: https://github.com/randomguy70/SmartNotesCE/tree/working_branch
randomguy wrote:
Well, in the past few days I added sprites, updated the gui graphics considerably, and am now going to start working on an extra menu for the home screen.

This is looking really great! I think the sprites definitely make it look better, and I love the stripey "Notecard" background. Keep up the great work!
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 1 of 1
» 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