Support l0dable nickname display.

This commit is contained in:
Stefan `Sec` Zehl 2011-08-04 16:57:18 +02:00
parent 1091daeb9d
commit 16da194336
7 changed files with 46 additions and 12 deletions

View File

@ -16,7 +16,20 @@
/**************************************************************************/
void simpleNickname(void);
void fancyNickname(void) {
if(GLOBAL(l0nick)){
if(execute_file(GLOBAL(nickl0),0,0))
GLOBAL(l0nick)=0;
}
if(!GLOBAL(l0nick))
simpleNickname();
return;
}
void simpleNickname(void) {
int dx=0;
int dy=0;
static uint32_t ctr=0;
@ -44,6 +57,7 @@ void fancyNickname(void) {
void init_nick(void){
readFile("nick.cfg",GLOBAL(nickname),MAXNICK);
readFile("font.cfg",GLOBAL(nickfont),FILENAMELEN);
readFile("l0nick.cfg",GLOBAL(nickl0),FILENAMELEN);
};
//# MENU nick editNick
@ -71,3 +85,16 @@ void doFont(void){
setIntFont(&Font_7x8);
while(!getInputRaw())delayms(10);
};
//# MENU nick chooseAnim
void doAnim(void){
getInputWaitRelease();
if( selectFile(GLOBAL(nickl0),"NIK") != 0){
lcdPrintln("No file selected.");
GLOBAL(l0nick)=0;
return;
};
writeFile("l0nick.cfg",GLOBAL(nickl0),strlen(GLOBAL(nickl0)));
GLOBAL(l0nick)=1;
getInputWaitRelease();
};

View File

@ -7,7 +7,7 @@
#include "basic/random.h"
#include "basic/config.h"
#define CFGVER 2
#define CFGVER 3
struct CDESC the_config[]= {
{"version", CFGVER, CFGVER, CFGVER, 0, 0},
@ -27,11 +27,13 @@ struct CDESC the_config[]= {
{"flamespeed", 1, 1, 100, 1, CFG_TYPE_FLAME},
{"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME},
{"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME},
{"l0nick", 0, 0, 1 , 0, 0},
{ NULL, 0, 0, 0 , 0, 0},
};
char nickname[MAXNICK]="anonymous";
char nickfont[FILENAMELEN];
char nickl0[FILENAMELEN];
#define CONFFILE "r0ket.cfg"
#define CONF_ITER for(int i=0;the_config[i].name!=NULL;i++)

View File

@ -21,8 +21,9 @@ struct CDESC {
#define MAXNICK 20
extern struct CDESC the_config[];
extern char nickname[MAXNICK];
extern char nickname[];
extern char nickfont[];
extern char nickl0[];
#define GLOBALversion (the_config[ 0].value)
#define GLOBALprivacy (the_config[ 1].value)
@ -40,8 +41,10 @@ extern char nickfont[];
#define GLOBALflamespeed (the_config[13].value)
#define GLOBALflamemaxw (the_config[14].value)
#define GLOBALflameminw (the_config[15].value)
#define GLOBALl0nick (the_config[16].value)
#define GLOBALnickname (nickname)
#define GLOBALnickfont (nickfont)
#define GLOBALnickl0 (nickl0)
#define GLOBAL(x) GLOBAL ## x

View File

@ -20,7 +20,7 @@ extern void * sram_top;
/**************************************************************************/
void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
FRESULT res;
FIL file;
UINT readbytes;
@ -38,7 +38,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
//lcdPrintln(f_get_rc_string(res));
//lcdRefresh();
if(res){
return;
return -1;
};
res = f_read(&file, (char *)dst, RAMCODE, &readbytes);
@ -46,7 +46,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
//lcdPrintln(f_get_rc_string(res));
//lcdRefresh();
if(res){
return;
return -1;
};
if( decode || checksignature )
//only accept files with fixed length
@ -55,7 +55,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
lcdPrint("readbytes&3");
lcdRefresh();
while(1);
return;
return -1;
}
if( checksignature ){
uint32_t mac[4];
@ -72,7 +72,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
lcdPrintIntHex(mac[3]); lcdNl();
lcdRefresh();
while(1);
return;
return -1;
}
//lcdPrint("macok");
//lcdRefresh();
@ -90,6 +90,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode!
dst();
return 0;
};

View File

@ -1,7 +1,7 @@
#ifndef _EXECUTE_H_
#define _EXECUTE_H_
void execute_file (const char * fname, uint8_t checksignature, uint8_t decode);
uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode);
void executeSelect(char *ext);
#endif

View File

@ -72,3 +72,8 @@ nrf_check_reset
sspSend
sspReceive
sspSendReceive
getInputWait
lcdGetPixel
nickfont
setExtFont
getFontHeight

View File

@ -44,10 +44,6 @@ $(LDFILE):
clean:
rm -f *.o *.elf *.bin usetable.h
IDIR=/cygdrive/f
install:
for a in $(BINS) ; do f=$${a#*/};cp $$a $(IDIR)/$${f%.bin}.c0d ; done
$(OBJS): usetable.h
usetable.h: