Author Topic: General Ndless Questions and Support  (Read 118028 times)

0 Members and 1 Guest are viewing this topic.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: General Ndless Questions and Support
« Reply #45 on: April 21, 2012, 11:54:36 am »
What are the screen dimensions?

How do I display integers (with nRGBlib)?


Offline ExtendeD

  • Project Author
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: General Ndless Questions and Support
« Reply #46 on: April 21, 2012, 01:22:51 pm »
The screen is 240x320.

Use something like this to convert it to a string:
char buf[20];
sprintf(buf, "%i", thenumber);

Then display the string with nRGBlib.
Ndless.me with the finest TI-Nspire programs

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: General Ndless Questions and Support
« Reply #47 on: April 21, 2012, 01:50:18 pm »
A smarter way to debug values on the handled is to user sprintf and show_msgbox =)
« Last Edit: April 21, 2012, 01:50:41 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: General Ndless Questions and Support
« Reply #48 on: April 21, 2012, 04:54:54 pm »
The screen is 240x320.

Use something like this to convert it to a string:
char buf[20];
sprintf(buf, "%i", thenumber);

Then display the string with nRGBlib.
So the string is called buf in this example?

Also, is there a way to save high scores?

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: General Ndless Questions and Support
« Reply #49 on: April 21, 2012, 06:24:07 pm »
Also, is there a way to save high scores?

Writting in a file ?

Code: [Select]
FILE * f = fopen("/documents/mygame_highscore.tns", "w+");
char buf[integerSize(highscore) + 2];
sprintf(buf, "%d", highscore);
fputs(buf, f);
fclose(f);
refresh_osscr(); // refresh OS screen so that we can see the created file when we exit the program

Code: [Select]
int integerSize(int n) {
  int i;
  for(i = 0; n > 0; n/= 10, i++);
  return n
}
« Last Edit: April 21, 2012, 06:28:37 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline ExtendeD

  • Project Author
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: General Ndless Questions and Support
« Reply #50 on: April 22, 2012, 02:52:07 am »
You can also use fwrite or fprintf for this (666th post!)
« Last Edit: April 22, 2012, 02:52:35 am by ExtendeD »
Ndless.me with the finest TI-Nspire programs

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: General Ndless Questions and Support
« Reply #51 on: April 22, 2012, 09:22:42 am »
I wonder... is self-modifying code possible in Ndless, as in highscores storing themselves inside their respective games rather than external files? I saw that happen often on the TI-83 Plus in the past.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: General Ndless Questions and Support
« Reply #52 on: April 22, 2012, 09:25:45 am »
I suppose so, but it isn't the most easy thing to do. Maybe someone can make a lib for it :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: General Ndless Questions and Support
« Reply #53 on: April 22, 2012, 09:28:53 am »
Actually I do not remember what was the main use on the TI-83 Plus since external data was often in appvar form anyway and did not take any space in the PRGM/apps menu, but on the TI-Nspire I notice that external files often clutter the TI-Nspire document explorer, and I remember people ranting about having too many files on the TI-83 Plus before, which tells me some TI-Nspire users might not like it very much to see their menu cluttered. It is particularly bad when you got 50 gbc4nspire ROMs with savestates. Of course there are folders, though.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: General Ndless Questions and Support
« Reply #54 on: April 22, 2012, 09:31:51 am »
I suppose so, but it isn't the most easy thing to do. Maybe someone can make a lib for it :)
That would be nice.
* epic7 thinks he'll skip high scores for now

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: General Ndless Questions and Support
« Reply #55 on: April 22, 2012, 09:52:49 am »
I wonder... is self-modifying code possible in Ndless, as in highscores storing themselves inside their respective games rather than external files? I saw that happen often on the TI-83 Plus in the past.

You can, but if the file size get modified, like if you recompile with extra stuff / updates, the highscore system will crash.
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: General Ndless Questions and Support
« Reply #56 on: April 22, 2012, 09:55:44 am »
Ok thanks for the info. :)

Also any executable code size limit or file size limit? On 68K calcs, I think it was 64 KB for both and on the 83+, a file cannot be larger than 65535 KB in archive and as large as the RAM allows in RAM, but the code limit on the 83+ for regular program files was 8.1 KB or 8.8 KB depending of where you ran it.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: General Ndless Questions and Support
« Reply #57 on: April 22, 2012, 09:59:25 am »
Levak, if you store the data on the end of the tns file, and you can get the size of it using Ndless there should not be any problem.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: General Ndless Questions and Support
« Reply #58 on: April 22, 2012, 02:23:11 pm »
Levak, if you store the data on the end of the tns file, and you can get the size of it using Ndless there should not be any problem.
But you will lose highscore on each modification, it was a part of what I meant.
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: General Ndless Questions and Support
« Reply #59 on: May 14, 2012, 09:06:32 am »
The fgets function seems to have a glitch:
Code: [Select]
char *fgets(char *str, int num, FILE *str2eam) {
char *str2 = str;
while (num--) {
char c = fgetc(str2eam); //THIS IS THE BUGGY LINE
if (c == EOF) {
*str2 = '\0';
return NULL;
}
*str2++ = c;
if (c == '\n')
break;
}
*str2 = '\0';
return str;
}

The c variable should be specified as an int, not a char -- it looks like the compiler treated the char as unsigned and optimized out the return NULL entirely! Plus, it is possible that an 0xFF character exists in the file, so signed char is not the way to go.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman