How do I check for if appvars exist, and how do I make lists and matrices in C?
Still a noob at those parts, and I still don't know how I'd do basic list and matrix math (like copying data from one to another, goes for lists too).

Also, I don't know how to read and write to/from an appvar.

I guess this can be dedicated to those who might be just starting out...

EDIT: I saw this line in the docs:
if (ti_Write(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
But how can I just write to it, and not in an if statement. I feel dumb right now...

EDIT2: Major problem with for loops...
I used

Code:

for(y = 240; y < 280; y += 20) {
gfx_Sprite(wood, x, y);
}

...and I get (the background is fine)...
Ok so I'm getting a ram reset. And I think I found the area it's occurring in...
so first, I have:

Code:

void createVars(void) {
   char screenMap[20 * 15];
   uint8_t appvar;
   uint8_t xb;
   uint8_t x;
   uint8_t y;
   gfx_sprite_t* sprites[12] = { dirt, grass, stone, wood, wood2, water, lava, netherrack, fireball, traptile1, traptile2, sailcloth };
   ti_CloseAll();
   appvar = ti_Open("SrvMap00", "r");
   if ((!appvar) && (sizeof(appvar) != 317)) {
      ti_CloseAll();
      appvar = ti_Open("SrvMap00", "w");
      ti_Write(screenMap, 300, 1, appvar);
      ti_SetArchiveStatus(1, appvar);
      ti_CloseAll();
      start();                      // start() goes to void start(void) I made to attempt to "fix"...
   }
   
   if (appvar) {
      ti_Read(screenMap, 300, 1, appvar);
      xb = 0;
      for (y = 0; y < 15; y++) {
         for (x = 0; x < 20; x++) {
            if ((screenMap[xb] > 0))gfx_Sprite(sprites[screenMap[xb]], x * 16, y * 16);
            if ((screenMap[xb] == 0))gfx_FillRectangle(x * 16, y * 16, 16, 16);
            xb = xb + 1;
         }
      }
      ti_CloseAll();
   }
   
}


I think it's at the if (appvar) {} portion. But when I display the screen it's glitchy at first. Launch it again and it works. I think that's the write part...
Can someone help? I'm sure it's messy code and it's inaccurate...
  
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 UTC - 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