Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lkj

Pages: 1 ... 13 14 [15] 16 17 ... 33
211
TI-Nspire / Re: nTxt - Nspire Text Editor
« on: December 28, 2012, 06:21:58 pm »
How does nano do it? I only know Windows programs

212
TI-Nspire / Re: nTxt - Nspire Text Editor
« on: December 28, 2012, 06:08:15 pm »
Home and end added as ctrl+left and ctrl+right, but I just noticed that the cursor can't be placed after the last letter on a line longer than what fits on the screen the way I currently handle the cursor, as it's at the start of the next line then. Would you mind if I let it that way? Because else I'd have to do a hacky solution :S

213
TI-Nspire / Re: Game selection help
« on: December 28, 2012, 05:11:51 pm »
Make a game about BrainFuck :P

Zelda would also be cool, but it's probably much bigger than you're suspecting ;)

214
TI-Nspire / Re: Interpretor of BrainFuck
« on: December 28, 2012, 05:04:59 pm »
There's already a BF interpreter in nspire basic on ticalc http://www.ticalc.org/archives/files/fileinfo/433/43365.html ;)

I'll have to learn Brainfuck :D

215
TI-Nspire / Re: [Lua] UNO (THE [card]game)
« on: December 28, 2012, 11:57:22 am »
Why don't you have to take a card from the stack if you can't lay down one? Is that really the official rules, because I've never played it that way?
Also I think the AI sometimes (or always?) doesn't take 4 cards when I lay down a 4+.

yesterday sorunome said it looks like it's made in the 90's. I actually based it on an image from the original uno card set, which is indeed from that time, but i kinda like it this way. Should I change it?
I like it the way it is :)

216
TI-Nspire / Re: nTxt - Nspire Text Editor
« on: December 27, 2012, 08:56:12 pm »
Fixed your problem and added a filebrowser. It's still ugly, though. DON'T open themes.csv or files outside of /documents/, it will make your calc hang or crash as soon as you exit nTxt. And it doesn't display them correctly. I don't know exactly why, will look into this.

Can you take ctrl-left and ctrl-right? then you could make these home and end, and ctrl-shift-right/left to select them, just like normal pc's
Ok, I'll do that.

217
TI-Nspire / Re: [Lua] UNO (THE [card]game)
« on: December 27, 2012, 07:49:23 pm »
When you've won the game isn't finished, so you can let the AIs play on, and when only one of them is left, there seems to be some endless loop. The student software just stops to respond and I have to kill it in the taskmgr.

Nothing else, yet ;)

218
TI-Nspire / Re: nTxt - Nspire Text Editor
« on: December 27, 2012, 06:48:02 pm »
Thanks :)

But there's a weird thing : it became impossible to enter the "<" character.
Oops, I've broken all characters for which you have to press the ctrl key :(
But it's easy to fix, will be fixed in the next release.

Btw, do you have a suggestion for keys for an equivalent of HOME and END on the pc keyboard?

219
TI-Nspire / Re: [Lua] UNO (THE [card]game)
« on: December 27, 2012, 06:24:43 pm »
I will put that in the instructions in-game later. But was it too confusing, or was it still kinda self-explanatory?
I guess it would have been self-explanatory if I didn't know the original UNO cards or had known that you just display chars over the card sprites. But I assumed those cards were something new I didn't know yet. ;D

220
Calculator C / Re: Weird stat() error
« on: December 27, 2012, 06:16:02 pm »
I guess I'll just try fopen on the filenames and find out if it's a file like this, if no one knows what's wrong.

221
TI-Nspire / Re: [Lua] UNO (THE [card]game)
« on: December 27, 2012, 06:09:48 pm »
Looking nice, although I was confused by the #, ยง and X because I read what they meant only after I had tested it :P

great idea, what if i display 4 colored cards as you say, and to show which one is selected, i draw the colorChange icon (#) or +4 on the selected one. That'll make sure you got the right card and color.
It would be more beautiful if you displayed the selected card bigger than the other ones, but that may take up too much space.

222
Other Calculators / Re: A fullscreen image on a Nspire Color prototype?!!!
« on: December 26, 2012, 06:28:13 pm »
No store in my city sells graphing calculators anymore, whereas two years ago sold 68k, Z80 and Nspire calcs. You can only buy them on the internet over here.

223
Other Calculators / Re: A fullscreen image on a Nspire Color prototype?!!!
« on: December 26, 2012, 04:21:55 pm »
Did you ndless it? Or reflash the boot code somehow?

or for a future version of the nspire?
BTW, does anyone know if the Nspire series will be continued?

224
Calculator C / Weird stat() error
« on: December 26, 2012, 11:20:05 am »
I'm writing a file browser and use this piece of code to find out if something is a directory:
Code: [Select]
int is_dir(const char *path) {
struct stat filestat;
stat(path, &filestat);
printf("%s %i", path, filestat.st_mode);
return S_ISDIR(filestat.st_mode);
}

".." is reported as a directory in every directory except from /documents/, which most probably means in every directory in which ".." isn't the root directory. So I looked at hofa's code and saw he didn't handle this case separately and it still works in the prebuilt tns. But when I recompile his code, it doesn't work, either.

Do I have to write a workaround or is something wrong with my ndless, as the code apparently worked with an older revision?

Edit: sometimes it works, but most of the time not  ???

Edit2: it sometimes doesn't work for other folders, either

Spoiler For my filebrowser code:
Code: [Select]
#include <os.h>
#include "filebrowser.h"
#include "output.h"
#include "menu.h"

#define DIR_HEIGHT (CHAR_HEIGHT + 10)
#define DIR_DIRLIST_DIST CHAR_HEIGHT
#define FILENAME_WIDTH 200
#define FILEDATE_WIDTH 0
#define FILESIZE_WIDTH (SCREEN_WIDTH - FILENAME_WIDTH - FILEDATE_WIDTH)

#define FILES_SHOWN ((SCREEN_HEIGHT - DIR_HEIGHT) / CHAR_HEIGHT)

#define MENU_SELECTION_COLOR (has_colors?0b011101111111111:0x0)

//TODO: display long directory names correctly

//some parts are adapted from hoffa's code

int is_dir(const char *path) {
struct stat filestat;
stat(path, &filestat);
printf("%s %i", path, filestat.st_mode);
return S_ISDIR(filestat.st_mode);
}

void get_filesize(const char *path, char* buffer){
    struct stat filestat;
    stat(path, &filestat);
    int size = filestat.st_size;
    const char units[4][3] = {"B\0", "kB\0", "MB\0", "GB\0"};
    int i = 0;
    while (size >= 1024) {
        size /= 1024;
        ++i;
    }
    sprintf(buffer, "%d%s", size + 1, units[i]);
}

int get_filenames(const char* folder, char** result){
    DIR* dp;
    struct dirent* entryp;
    int i = 0;
    if((dp = opendir(folder)) == NULL){
        printf("opendir error\n");
        return 1;
    }
    while((entryp = readdir(dp)) != NULL){
        char* dirname = (char*) malloc(strlen(entryp->d_name)+1);
        strcpy(dirname, entryp->d_name);
        result[i] = dirname;
        i++;
    }
    return i;
}

int filebrowser(uint8_t* scrbuf, char* file){
    char currentdir[FILENAME_MAX];
    char* filenames[1024];
    int num_files;
    int filescroll = 0;
    int fileselected = 0;
    int i;
    NU_Current_Dir("A:", currentdir);
    num_files = get_filenames(currentdir, filenames);
    while(1){
        //disp:
        memset(scrbuf, 0xFF, SCREEN_BYTES_SIZE);
        dispHorizLine(scrbuf, 0, DIR_HEIGHT-1, 320, 0);
        dispString(scrbuf, 4, (DIR_HEIGHT-CHAR_HEIGHT)/2, currentdir);
        for(i = filescroll; i < filescroll + FILES_SHOWN && i < num_files; i++){

            //disp file symbol
            if(is_dir(filenames[i]) && strcmp(filenames[i], ".") && strcmp(filenames[i], ".."))
                putChar(scrbuf, CHAR_WIDTH*2, DIR_HEIGHT+DIR_DIRLIST_DIST+(i-filescroll)*CHAR_HEIGHT, '\\');
            //disp filename, filesize and selection
            if(i != fileselected){
                dispString(scrbuf, CHAR_WIDTH*3, DIR_HEIGHT+DIR_DIRLIST_DIST+(i-filescroll)*CHAR_HEIGHT, filenames[i]);
                if(!is_dir(filenames[i])){
                    char size[10];
                    get_filesize(filenames[i], size);
                    dispString(scrbuf, FILENAME_WIDTH, DIR_HEIGHT+DIR_DIRLIST_DIST+(i-filescroll)*CHAR_HEIGHT, size);
                }
            }
            else{
                filledRect(scrbuf, CHAR_WIDTH*3, DIR_HEIGHT+DIR_DIRLIST_DIST+(i-filescroll)*CHAR_HEIGHT-1, SCREEN_WIDTH - CHAR_WIDTH*4, CHAR_HEIGHT+2, MENU_SELECTION_COLOR);
                dispStringColor(scrbuf, CHAR_WIDTH*3, DIR_HEIGHT+DIR_DIRLIST_DIST+(i-filescroll)*CHAR_HEIGHT, filenames[i], has_colors?0xFFFF:0xF, MENU_SELECTION_COLOR);
                if(!is_dir(filenames[i])){
                    char size[10];
                    get_filesize(filenames[i], size);
                    dispStringColor(scrbuf, FILENAME_WIDTH, DIR_HEIGHT+DIR_DIRLIST_DIST+(i-filescroll)*CHAR_HEIGHT, size, has_colors ? 0xFFFF : 0xF, MENU_SELECTION_COLOR);
                }
            }

        }
        memcpy(SCREEN_BASE_ADDRESS, scrbuf, SCREEN_BYTES_SIZE);

        //input:
        if(isKeyPressed(KEY_NSPIRE_ESC))
            break;
        if(isKeyPressed(KEY_NSPIRE_ENTER)){
            if(is_dir(filenames[fileselected])){
                chdir(filenames[fileselected]);
                filescroll = 0;
                fileselected = 0;
                NU_Current_Dir("A:", currentdir);
                for(i = 0; i < num_files; i++)
                    free(filenames[i]);
                num_files = get_filenames(currentdir, filenames);
            }
            else{
                strcpy(file, filenames[fileselected]);
                for(i = 0; i < num_files; i++)
                    free(filenames[i]);
                return 0;
            }
        }
        if(isKeyPressed(KEY_NSPIRE_UP)){
            fileselected--;
            if(fileselected < 0){
                fileselected = num_files - 1;
                filescroll = num_files - FILES_SHOWN;
                if(filescroll < 0)
                    filescroll = 0;
            }
            else if(fileselected - filescroll <  0)
                filescroll--;
        }
        if(isKeyPressed(KEY_NSPIRE_DOWN)){
            fileselected++;
            if(fileselected >= num_files){
                fileselected = 0;
                filescroll = 0;
            }
            else if(fileselected - filescroll >= FILES_SHOWN)
                ++filescroll;
        }
        sleep(100);
    }
    for(i = 0; i < num_files; i++)
        free(filenames[i]);
    return 1;
}

225
Miscellaneous / Re: Christmas - what did you get?
« on: December 25, 2012, 04:02:09 pm »
I got some chocolate and other sweet stuff and tickets for a concert :)
Hopefully I can get a calculator for my birthday :P

Pages: 1 ... 13 14 [15] 16 17 ... 33