Author Topic: Post your Nspire routines here!  (Read 98437 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 #90 on: July 25, 2010, 04:14:34 pm »
Right. I mis-read your post :(

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #91 on: July 26, 2010, 03:40:24 am »
This one is courtesy of calc84maniac:
Code: [Select]
void clear_buffer(char* buffer)
{
  __asm__ __volatile__ (
     "mov r1,#120\n\t"
     "mvn r2,#0\n\t"
     "mvn r3,#0\n\t"
     "mvn r4,#0\n\t"
     "mvn r5,#0\n\t"
     "mvn r6,#0\n\t"
     "mvn r7,#0\n\t"
     "mvn r8,#0\n\t"
     "mvn r9,#0\n\t"
     "mvn r10,#0\n\t"
     "mvn r11,#0\n\t"
     "1:\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "stmia %0!,{r2-r11}\n\t"
     "subs r1,r1,#1\n\t"
     "bne 1b\t"
     :
     : "r"(buffer)
     : "r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r11"
   );
}
It clears a screen buffer very, very quickly.
NOTE: It can only clear a screen buffer, not a buffer of arbitrary size.

Edit by calc84maniac: potentially harmful typo
« Last Edit: July 26, 2010, 03:45:16 am by calc84maniac »

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 #92 on: July 28, 2010, 10:21:33 am »
Because of the release of Nleash and the ability to use Ndless on Touchpad Nspires, do we have the keypad mappings (or a new common.h file) for the touchpad.  In this case, we could just compile four versions of our programs (Non CAS Clickpad, CAS Clickpad, Non CAS Touchpad, CAS Touchpad) to be used on any Nspire.


Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Post your Nspire routines here!
« Reply #93 on: July 28, 2010, 10:27:00 am »
Actually, we wouldn't. You need a clickpad to run OS 1.1, no matter what hardware version.

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #94 on: August 04, 2010, 04:29:36 pm »
Here are some text output routines. The character map is courtesy of Armael on United TI, and the routines are inspired by his, too. Right now, all I have is a function akin to TI-BASIC's text() function - pass it a string and some coordinates, and it will draw it to the designated screen buffer.
There used to be more, but no program loader -> no static variables -> a real console becomes incredibly unwieldy :( I thought about passing pointers to the cursor coordinates to the functions, but that's a bit too unwieldy.

File descriptions:
charmap_8x12.h: the character map.
screen.h: contains functions putChar and drawStr.
stdarg.h: variable-length argument list header.
string.h: some string functions

Do we have entry points for vsprintf()? That would make writing a printf() so much easier.

Enjoy! And remember, this is a very in-progress set of routines, so don't use them for anything fancy.

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 #95 on: August 04, 2010, 04:58:35 pm »
Thanks bwang! :)

These look very nice and it are a good start until we get a program loader!


Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #96 on: August 05, 2010, 02:03:19 am »
Edited the first post and skeleton.zip to include the new text routines. I've found them rather useful, despite their limited abilities, so they've been integrated into skeleton.zip for the moment.
bsl and I (on United-TI) have found how to list files. This seems useful, so dirlist.h has been placed into skeleton.zip as well.
The syntax for dirlist() is:
Code: [Select]
int dirlist(char* path, char* pattern, char** result)
path: the folder you are looking in, e.g. "/documents/examples"
pattern: a search pattern, e.g. "*.tns"
result: a pointer to a char* (i.e. a list of strings) that will store the resulting filenames

return value: the number of files found

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: Post your Nspire routines here!
« Reply #97 on: August 06, 2010, 12:41:50 pm »
bwang, what about creating a static library for your useful functions?
Ndless.me with the finest TI-Nspire programs

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #98 on: August 06, 2010, 05:48:30 pm »
That is a good idea. I presume Ndless supports such things at the moment, despite the lack of a program loader?

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 #99 on: August 21, 2010, 09:28:33 pm »
bwang, does the Makefile in skeleton.zip support YAGARTO 4.5.0?  I was just looking at it (when I get my computer working again, I am going to start using the skeleton for my projects instead of the folder directly in Ndless), and I noticed that the prefix "arm-elf-..." is used.  If I am not mistaken, YAGARTO 4.5.0 uses "arm-none-eabi-...".


Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #100 on: August 22, 2010, 01:14:14 am »
Nope, the skeleton supports the arm-elf versions only. If you can modify it to work with 4.5.0 and post it, I'll attach it to the OP (I don't have a Windows machine to test on, so I can't update it).

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 #101 on: August 22, 2010, 12:45:13 pm »
Ok bwang, I try to modify it as soon as I can!


Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Post your Nspire routines here!
« Reply #102 on: August 25, 2010, 10:28:40 pm »
Updated the OP with a new skeleton.zip. filesize() should be useful for level loaders and the like.
apcalc, have you tested whether changing the Makefile works yet?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Post your Nspire routines here!
« Reply #103 on: August 26, 2010, 12:52:56 pm »
Nice to hear ^^

Offline Goplat

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 289
  • Rating: +82/-0
    • View Profile
Re: Post your Nspire routines here!
« Reply #104 on: August 26, 2010, 02:57:19 pm »
Easy ASCII input:

Code: [Select]
struct event {
unsigned int timestamp;
unsigned short type;
unsigned short ascii;
unsigned int key;
unsigned int unknown[3];
unsigned int control;
};

#ifdef CAS
#define get_event (_oscall(int, 0x100CBF78, struct event *))
#else
#define get_event (_oscall(int, 0x100CBF44, struct event *))
#endif

int getch() {
struct event event;
do {
get_event(&event);
} while (event.type != 8 || event.ascii == 0);
return event.ascii;
}
« Last Edit: August 26, 2010, 03:09:29 pm by Goplat »
Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo