Author Topic: Post your Nspire routines here!  (Read 105460 times)

0 Members and 1 Guest are viewing this topic.

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #75 on: July 07, 2010, 10:18:40 pm »
Are you supposed to be able to use floats as arguments to the sprite routine?
No.
@apcalc: Post your modified scrollScreen().

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Post your Nspire routines here!
« Reply #76 on: July 07, 2010, 11:12:42 pm »
bwang, that was the problem.  I had SCREEN_BYTES_SIZE+bytesOffset, which probably made it larger that it could handle.  Thank you so much for your help, I feel so stupid when it is a simple error like this. :) You might want to modify the utils.h/.c header to include functions for scrolling the screen up and down.  Here are my (hopefully working :)) modified versions:

Code: [Select]

void scrollScreenDown(char* scrbuf, char* tmpbuf, int lines)
{
  int bytesOffset = 160 * lines;
  int cpysize = SCREEN_BYTES_SIZE - bytesOffset;
  memcpy(tmpbuf, scrbuf - bytesOffset, cpysize);
  memcpy(scrbuf, tmpbuf, cpysize);
  memset(scrbuf + cpysize, 0xFF, bytesOffset);
}

void scrollScreenUp(char* scrbuf, char* tmpbuf, int lines)
{
  int bytesOffset = 160 * lines;
  int cpysize = SCREEN_BYTES_SIZE - bytesOffset;
  memcpy(tmpbuf, scrbuf + bytesOffset, cpysize);
  memcpy(scrbuf, tmpbuf, cpysize);
  memset(scrbuf + cpysize, 0xFF, bytesOffset);
}

[\code]


Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #77 on: July 07, 2010, 11:26:18 pm »
Glad to hear its working :)
I should probably move the scroll functions to graphics.h.

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: Post your Nspire routines here!
« Reply #78 on: July 08, 2010, 01:11:29 am »
Glad it's working. I wish you good luck in your projects, if any (Starcraft Nspire... j/k ;D )

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Post your Nspire routines here!
« Reply #79 on: July 08, 2010, 09:14:02 am »
We really need some documentation for these functions. I've started on it, and will post it when I'm done.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Post your Nspire routines here!
« Reply #80 on: July 09, 2010, 11:39:32 am »
How do you convert an integer to a string? I wanted to display the score in a dialog box upon exiting my game.

Also, the documentation is almost complete for utils.h, except for fade, scrollscreen, and WAIT. What do all the arguments do in these functions?

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Post your Nspire routines here!
« Reply #81 on: July 09, 2010, 12:10:11 pm »
Hmm, to convert an integer to a string, don't you do sprintf(string_ptr,"%i",score)
"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: Post your Nspire routines here!
« Reply #82 on: July 09, 2010, 02:48:40 pm »
Unfortunately, sprintf hasn't been written yet. There was another, simpler function, itoa, but it depends on this standard library function.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Post your Nspire routines here!
« Reply #83 on: July 09, 2010, 03:07:36 pm »
I thought sprintf is part of the OS, and we are able to use it. Was I mistaken?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #84 on: July 09, 2010, 04:17:11 pm »
sprintf is part of the OS (at least it's defined in os.h).

scrollScreen() arguments:
Code: [Select]
scrollScreen(char* scrbuf, char* tmpbuf, int lines)
Scroll the screen buffer scrbuf up lines rows. tmpbuf is a temporary buffer of the same size as scrbuf used by the routine internally.
« Last Edit: July 09, 2010, 04:20:03 pm by bwang »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Post your Nspire routines here!
« Reply #85 on: July 10, 2010, 11:53:39 am »
I never thought of looking there for sprintf. Thanks!

Also, at least on windows, the windows and linux makeTNS binaries can coexist peacefully, and I have a hunch it will be the same on linux, though someone should confirm it.
« Last Edit: July 10, 2010, 01:25:44 pm by fb39ca4 »

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #86 on: July 22, 2010, 09:34:40 pm »
I updated the first post with a better graphics.h.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Post your Nspire routines here!
« Reply #87 on: July 23, 2010, 12:27:02 pm »
I found a small error in common.h.

The "?" key, named "KEY_NSPIRE_?" causes an error when compiling because of the ?.

I have attached a fixed version with this key named "KEY_NSPIRE_QUES"


Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #88 on: July 23, 2010, 09:06:09 pm »
Fixed in the first post :) Thanks for the bugfix!
Can someone verify whether the Linux and Windows versions of the tools can coexist in the same directory? That way I can merge the two skeletons.
« Last Edit: July 23, 2010, 09:06:57 pm by bwang »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Post your Nspire routines here!
« Reply #89 on: July 25, 2010, 02:17:44 pm »
I already said they can coexist on windows in a previous post here.