Blog Moved

February 28, 2011

I’ ve just moved the blog on a new domain: http://www.aureliomannara.it
This blog will no more updated, the next news will be posted on that new site :)

Working on MultiTasking

February 23, 2011

Yes, I am. DsOS will have multitasking :D

About The Wave Support

February 23, 2011

As I told you some days ago in the next DsOS APIs there will be wave support. Currently it can handle only mono audio with no compression. Tomorrow I’ll probably work on stereo support.

Network Support added to DsOS APIs

February 22, 2011

Hi! I recently added a network to DsOS APIs. Now with DsOS you can downloads files(more simultaneously) from internet with a speed of about 10 KB/s while you run other apps(kind of multi-tasking).
More cool things coming soon :)

What would like to see in the next DsOS?

February 9, 2011

As you can understand from the title, I would like to know what you want to see in the next DsOS. Please, give me lot of ideas.

Developing a new DsOS version

February 7, 2011

Hi, I’m currently working on the new version of the DsOS. All the applications will use proprietary APIs, to make them simple to develope and use.

At the moment the APIs can:

  • Handle truetype fonts
  • Handle some windows elements(buttons, text labels, checkboxes, etc.)
  • Handle files&directories
  • Handle hardware timers
  • Handle MIDI files
  • Handle WAV files
  • Handle JPEG/PNG/BMP files

I’m also creating a language that will allow users to simply develope their own application directly on their Nintendo DS.

Stay Tuned!

Merry Christmas

December 25, 2010

Hi! I know, it’s been a long time since I wrote my last post, so apologize me. This post is to wish you a Merry Christmas.

UTF8 to Unicode C

July 30, 2010

Hi, sorry for this long time without new posts.

This is a routine i wrote for reading Unicode from UTF8 data.

u32 UTF8_To_Unicode(u8* src2, u8* nbyte){
u8* src=src2;
*nbyte=1;
if(*src==0)return 0;
if((*src&128)==0)return *src;
u32 value=0;
u8 curbit=7;
*nbyte=0;
while(*src&(1<<curbit)){
*nbyte++;
curbit–;
}
if(*nbyte==0×02){
value|=(*src&31)<<6;
src++;
if((*src&192)!=128){
*nbyte=(u8)(src-src2);
return 32;
}
value|=(*src&63);
}else if(*nbyte==0×03){
value|=(*src&15)<<12;
src++;
if((*src&192)!=128){
*nbyte=(u8)(src-src2);
return 32;
}
value|=(*src&63)<<6;
src++;
if((*src&192)!=128){
*nbyte=(u8)(src-src2);
return 32;
}
value|=(*src&63);
}else if(*nbyte==0×04){
value|=(*src&7)<<18;
src++;
if((*src&192)!=128){
*nbyte=(u8)(src-src2);
return 32;
}
value|=(*src&63)<<12;
src++;
if((*src&192)!=128){
*nbyte=(u8)(src-src2);
return 32;
}
value|=(*src&63)<<6;
src++;
if((*src&192)!=128){
*nbyte=(u8)(src-src2);
return 32;
}
value|=(*src&63);
}
return value;
}

To use it just do something like this:

u8 buffer[3]={0xE2, 0×82, 0xAC}; //UTF8 value of €

u8 nbyte; //This will contain the byte length of the UTF8 character, this will be useful for jumping to the next character in a UTF8 sequence.

u32 unicode = UTF8_To_Unicode(buffer, &nbyte); //This will contain the unicode of your UTF8 character.

That’s all. Just a thing, remember that if the sequence has error the function will return 32(SPACE character, ‘ ‘).

Let me know about errors or tips.

Dir Delete and File Search complete project + BONUS

March 2, 2010

I’ve uploaded three projects that use my functions.

One uses the Dir Delete function, and one the File Search function.

The “bonus” project uses a function that compute the size of a directory(including sub-folders and sub-files).

Downloads:

DirDelete

FileSearch

DirSize

FileSearch Function

January 14, 2010

This C function find a file in a selected directory(you can also select the root of your disk).

/*
Copyright (C) 2009-2010 Aurelio Mannara

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <iostream>
#include <dirent.h>
#include <sys/stat.h>

using namespace std;

typedef struct{
char* fullpath;
}files_t;

files_t* searchfiles;
int searchcount;

int SearchWord(const char* text, const char* word){
int lent=strlen(text);
int lenw=strlen(word);
char check[lenw+1];
for(int i=0;i<lent;i++){
for(int j=0;j<lenw;j++){
check[j]=text[i+j];
}
check[lenw]=”;
if(strcmp(check, word)==0)return i;
}
return -1;
}

int Search(const char* dirn, const char* word){
DIR* dir;
struct dirent *dirp;
if((dir=opendir(dirn))==NULL){
return 0;
}
struct stat st;
if(searchfiles==NULL)searchfiles=(files_t*)malloc(0);
while((dirp=readdir(dir))!=NULL){
char name[256];
sprintf(name, “%s/%s”, dirn, dirp->d_name);
if((strcmp(dirp->d_name, “.”)==0)||(strcmp(dirp->d_name, “..”)==0))continue;
stat(name, &st);
strlwr(dirp->d_name);
if(SearchWord(dirp->d_name, word)!=-1){
searchfiles=(files_t*)realloc(searchfiles, (searchcount+1)*sizeof(files_t));
searchfiles[searchcount].fullpath=(char*)malloc(strlen(name)+1);
sprintf(searchfiles[searchcount].fullpath, “%s”, name);
searchcount++;
}
if((st.st_mode&S_IFDIR)){
Search(name, word);
}
}
return searchcount;
}

void ResetSearch(){
if(searchfiles!=NULL){
for(int i=0;i<searchcount;i++){
free(searchfiles[i].fullpath);
}
free(searchfiles);
searchfiles=NULL;
}
searchcount=0;
}

int main()
{
ResetSearch();
int count=Search(“C:/”,”filetosearch”);
for(int i=0;i<count;i++)printf(“%s\n”, searchfiles[i].fullpath);
printf(“\n%d files found\n”, count);
return 0;
}


Follow

Get every new post delivered to your Inbox.