Merge branch 'master' of ssh://github.com/r0ket/r0ket
This commit is contained in:
commit
e1124fb952
|
@ -120,7 +120,19 @@ char *meshmsgs(void){
|
|||
return msgtypes;
|
||||
};
|
||||
|
||||
|
||||
static inline uint32_t popcount(uint32_t *buf, uint8_t n){
|
||||
int cnt=0;
|
||||
do {
|
||||
unsigned m = *buf++;
|
||||
m = (m & 0x55555555) + ((m & 0xaaaaaaaa) >> 1);
|
||||
m = (m & 0x33333333) + ((m & 0xcccccccc) >> 2);
|
||||
m = (m & 0x0f0f0f0f) + ((m & 0xf0f0f0f0) >> 4);
|
||||
m = (m & 0x00ff00ff) + ((m & 0xff00ff00) >> 8);
|
||||
m = (m & 0x0000ffff) + ((m & 0xffff0000) >> 16);
|
||||
cnt += m;
|
||||
} while(--n);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
extern MPKT meshbuffer[MESHBUFSIZE];
|
||||
//# MENU messages
|
||||
|
@ -152,6 +164,12 @@ void m_choose(){
|
|||
case('T'):
|
||||
strcpy(p,"Time");
|
||||
break;
|
||||
case('Z'):
|
||||
strcpy(p,"Schnitzel");
|
||||
break;
|
||||
case('z'):
|
||||
strcpy(p,"S-Score");
|
||||
break;
|
||||
case('i'):
|
||||
strcpy(p,"Invaders");
|
||||
break;
|
||||
|
@ -188,6 +206,12 @@ void m_choose(){
|
|||
case('T'):
|
||||
lcdPrintln("Time");
|
||||
break;
|
||||
case('Z'):
|
||||
strcpy(p,"Schnitzel");
|
||||
break;
|
||||
case('z'):
|
||||
strcpy(p,"S-Score");
|
||||
break;
|
||||
case('i'):
|
||||
lcdPrintln("Invaders");
|
||||
break;
|
||||
|
@ -203,7 +227,19 @@ void m_choose(){
|
|||
lcdPrint(IntToStr(tm->tm_sec,2,F_LONG|F_ZEROS));
|
||||
lcdNl();
|
||||
|
||||
if(tmm[i]=='T'){
|
||||
if(tmm[i]=='Z'){
|
||||
lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+ 6),8));
|
||||
lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+10),8));
|
||||
lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+14),8));
|
||||
lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+18),8));
|
||||
lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+22),8));
|
||||
lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+26),8));
|
||||
lcdPrint(IntToStr(popcount(meshbuffer[j].pkt+6,6),3,0));
|
||||
lcdPrintln(" pts.");
|
||||
lcdRefresh();
|
||||
getInputWaitRelease();
|
||||
continue;
|
||||
}else if(tmm[i]=='T'){
|
||||
lcdPrint(IntToStr(tm->tm_mday,2,F_LONG));
|
||||
lcdPrint(".");
|
||||
lcdPrint(IntToStr(tm->tm_mon+1,2,0));
|
||||
|
|
|
@ -28,7 +28,7 @@ struct CDESC the_config[]= {
|
|||
{"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME},
|
||||
{"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME},
|
||||
{"l0nick", 0, 0, 1 , 0, 0},
|
||||
{"chargeled", 1, 0, 1 , 0, 0},
|
||||
{"chargeled", 0, 0, 1 , 0, 0},
|
||||
{ NULL, 0, 0, 0 , 0, 0},
|
||||
};
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ MPKT * meshGetMessage(uint8_t type){
|
|||
void mesh_cleanup(void){
|
||||
time_t now=getSeconds();
|
||||
for(int i=1;i<MESHBUFSIZE;i++){
|
||||
if(meshbuffer[i].flags&MF_LOCK)
|
||||
continue;
|
||||
if(meshbuffer[i].flags&MF_USED){
|
||||
if (MO_GEN(meshbuffer[i].pkt)<meshgen)
|
||||
meshbuffer[i].flags=MF_FREE;
|
||||
|
@ -126,6 +128,20 @@ void mesh_recvqloop_setup(void){
|
|||
nrf_rcv_pkt_start();
|
||||
};
|
||||
|
||||
static inline uint32_t popcount(uint32_t *buf, uint8_t n){
|
||||
int cnt=0;
|
||||
do {
|
||||
unsigned m = *buf++;
|
||||
m = (m & 0x55555555) + ((m & 0xaaaaaaaa) >> 1);
|
||||
m = (m & 0x33333333) + ((m & 0xcccccccc) >> 2);
|
||||
m = (m & 0x0f0f0f0f) + ((m & 0xf0f0f0f0) >> 4);
|
||||
m = (m & 0x00ff00ff) + ((m & 0xff00ff00) >> 8);
|
||||
m = (m & 0x0000ffff) + ((m & 0xffff0000) >> 16);
|
||||
cnt += m;
|
||||
} while(--n);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
uint8_t mesh_recvqloop_work(void){
|
||||
__attribute__ ((aligned (4))) uint8_t buf[32];
|
||||
int len;
|
||||
|
@ -164,9 +180,26 @@ uint8_t mesh_recvqloop_work(void){
|
|||
// Store packet in a same/free slot
|
||||
MPKT* mpkt=meshGetMessage(MO_TYPE(buf));
|
||||
|
||||
// Skip locked packet
|
||||
if(mpkt->flags&MF_LOCK)
|
||||
return 2;
|
||||
// Schnitzel
|
||||
if(MO_TYPE(buf)=='Z'){
|
||||
mpkt->flags=MF_USED|MF_LOCK;
|
||||
MO_TIME_set(mpkt->pkt,getSeconds());
|
||||
MO_GEN_set(mpkt->pkt,0x70);
|
||||
for(int i=6;i<MESHPKTSIZE;i++)
|
||||
mpkt->pkt[i]|=buf[i];
|
||||
|
||||
int score=popcount(MO_BODY(mpkt->pkt),6);
|
||||
|
||||
MPKT* reply=meshGetMessage('z');
|
||||
|
||||
if(MO_TIME(reply->pkt)>=score)
|
||||
return 1;
|
||||
|
||||
MO_TIME_set(reply->pkt,score);
|
||||
strcpy((char*)MO_BODY(reply->pkt),GLOBAL(nickname));
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
// only accept newer/better packets
|
||||
if(mpkt->flags==MF_USED)
|
||||
|
@ -179,6 +212,7 @@ uint8_t mesh_recvqloop_work(void){
|
|||
|
||||
memcpy(mpkt->pkt,buf,MESHPKTSIZE);
|
||||
mpkt->flags=MF_USED;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue