Author Topic: C Q&A Thread  (Read 18874 times)

0 Members and 2 Guests are viewing this topic.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: C Q&A Thread
« Reply #15 on: August 08, 2011, 05:04:52 pm »
Ok, but shouldn't it be & 8? 4 in binary is 100, 8 is 1000.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: C Q&A Thread
« Reply #16 on: August 08, 2011, 05:06:43 pm »
Actually, it should be & 16 :P
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: C Q&A Thread
« Reply #17 on: August 08, 2011, 05:07:39 pm »
Good point, I forgot to start counting from zero.
EDIT: Works great, this needs to be added to the ndless SVN.
« Last Edit: August 08, 2011, 05:23:46 pm by t0xic_kitt3n »

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: C Q&A Thread
« Reply #18 on: August 10, 2011, 04:49:16 pm »
calc84maniac: oops, right :)

t0xic_kitt3n: sure! Commited as on_key_pressed().
« Last Edit: August 10, 2011, 04:49:40 pm by ExtendeD »
Ndless.me with the finest TI-Nspire programs

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: C Q&A Thread
« Reply #19 on: August 19, 2011, 04:58:48 pm »
I tried compiling my C code and I get an error when using for loops. It says they're only allowed in C99 mode. What do I do in my makefile to change to C99?
Edit: Never mind, a quick Google found it for me. Still weird, though.
« Last Edit: August 19, 2011, 05:25:08 pm by sammyMaX »

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: C Q&A Thread
« Reply #20 on: August 20, 2011, 01:37:16 am »
I suppose you were trying to declare a variable within the "for" statement.
Ndless.me with the finest TI-Nspire programs

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: C Q&A Thread
« Reply #21 on: August 20, 2011, 11:51:59 am »
Yes, that was the issue, but a simple change in the makefile fixed it.

I'm now looking for a good alphabet for displaying text. I stole a file from this program, http://www.ticalc.org/archives/files/fileinfo/430/43054.html, which has text similar to (or maybe the exact same as) the text seen in the GBC emulator when selecting a ROM. I truly appreciate the maker's hard work, but I am looking for a font that looks more like the default kind found on the Nspire OS.

In addition, my program has the potential to use a LOT of RAM, so is there any way to track how much RAM is left, or how much is being used? It would be convenient for users to know.

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: C Q&A Thread
« Reply #22 on: August 20, 2011, 02:42:51 pm »
You could edit the array with the font (though that will take quite a bit of work), but I think someone just discovered an OS routine to display text at an arbitrary location on the screen, which is worth looking at, but I don't remember the thread :(

I don't think it is possible to show the amount of free RAM right now, but unless you are using amounts into multiple megabytes, there shouldn't be a problem. How much RAM does your program use? The largest executable I made was 100kb in size, and that runs fine. Just keep away from large arrays of static variables and you'll be fine.

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: C Q&A Thread
« Reply #23 on: August 20, 2011, 04:15:12 pm »
Please point me to the thread if you find it! Anyways, my program is a bignum library, so it will use as much RAM as is available, so it would be useful if that were possible, but in the meantime I might just implement something that measures how much RAM my own program uses, or just skip RAM measurement entirely.

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: C Q&A Thread
« Reply #24 on: August 21, 2011, 12:42:48 pm »
Well, you should be fine then with at least hundred-thousand digit numbers.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: C Q&A Thread
« Reply #25 on: August 22, 2011, 12:50:07 pm »
Just try to malloc() or realloc() and check a NULL return.

We could also try to export in Ndless the Nucleus memory pool object used by the OS and make possible direct reads of the free space value from the structure.
Ndless.me with the finest TI-Nspire programs

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: C Q&A Thread
« Reply #26 on: August 22, 2011, 01:35:38 pm »
Trying malloc() is a good way of ensuring enough RAM is available, which I guess is the only thing that matters. Would the second thing you mentioned require a modification to Ndless itself?

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: C Q&A Thread
« Reply #27 on: August 22, 2011, 01:39:07 pm »
no, just another library, I believe. Ndless already has access to tons of OS calls.

I defer to any higher (any) authority on this matter though :P

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: C Q&A Thread
« Reply #28 on: August 22, 2011, 04:12:18 pm »
Actually yes, the OS variable is currently not exported.
Ndless.me with the finest TI-Nspire programs

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: C Q&A Thread
« Reply #29 on: August 22, 2011, 05:10:31 pm »
There's a higher authority for ya XD guess I was wrong again.