示例#1
0
文件: invaders.c 项目: miloh/f1rmware
static bool screen_intro() {
	uint32_t highscore;
	char highnick[20];
	char key=0;
	bool step = false;
	//getInputWaitRelease();
	while(key==0) {
		getInputWaitRelease();
		lcdFill(0x00);
		setIntFont(&Font_Invaders);
    setTextColor(0x00,0b11100000);
    lcdSetCrsr(28+18,25+15);lcdPrint(step?"ABC":"abc");
		setIntFont(&Font_7x8);
    setTextColor(0x00,0b00011000);
		lcdSetCrsr(28+18,40+15);lcdPrint("SPACE");
    setTextColor(0x00,0b11111000);
		lcdSetCrsr(18+18,50+15);lcdPrint("INVADERS");

		highscore = highscore_get(highnick);
    setTextColor(0x00,0xff);
		lcdSetCrsr(0,0);lcdPrint(IntToStr(highscore,6,F_LONG));
//		lcdSetCrsr(0,9);lcdPrint(highnick);
		lcdDisplay();
		step = !step;
		key=getInputWaitTimeout(1000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}
示例#2
0
文件: jump.c 项目: Bediko/r0ket
static void splash_scene() {
	uint32_t highscore;
	char highnick[20];

	char key = 0;
	while(key == 0) {
		getInputWaitRelease();

		int dy = getFontHeight();
		int s1x = DoString(0, 0, "r0ket");
		s1x = (RESX-s1x)/2;
		int s2x = DoString(0, 0, "JUMP!");
		s2x = (RESX-s2x)/2;

		lcdFill(0);
		
		DoString(s1x, 3*dy, "r0ket");
		DoString(s2x, 4*dy, "JUMP!");
		DoString(0, 7*dy, "by webholics");

		highscore = highscore_get(highnick);

		int s3x = DoInt(0, 0, highscore);
		DoChar(s3x, 0, 'm');
		DoString (0, dy, highnick);

		lcdDisplay();

		key = getInputWaitTimeout(1000);
	}
}
示例#3
0
文件: jump.c 项目: Bediko/r0ket
static bool gameover_scene() {
	int dy = getFontHeight();
	int s1x = DoString(0, 0, "GAME OVER!");
	s1x = (RESX-s1x)/2;
	int s2x = DoString(0, 0, "HIGHTSCORE!");
	s2x = (RESX-s2x)/2;

	char key = 0;
	while(key != BTN_UP && key != BTN_DOWN) {
		lcdClear();

		if(highscore_set(game.scroll_pos / 15, GLOBAL(nickname)))
			DoString (s2x, dy, "HIGHSCORE!");
		else
			DoString(s1x, dy, "GAME OVER!");

		int x = DoInt(0, 3*dy, game.scroll_pos / 15);
		DoChar(x, 3*dy, 'm');

		DoString(0, 5*dy, "UP to play");
		DoString(0, 6*dy, "DOWN to quit");

		lcdDisplay();

		key = getInputWaitTimeout(5000);
	}

	return !(key==BTN_DOWN);
}
示例#4
0
static bool screen_intro() {
	uint32_t highscore;
	char highnick[20];
	char key=0;
	bool step = false;
	//getInputWaitRelease();
	while(key==0) {
		getInputWaitRelease();
		lcdFill(0);
		font = &Font_Invaders;
        DoString(28,25,step?"ABC":"abc");
		font = &Font_7x8;
		DoString (28,40,"SPACE");
		DoString (18,50,"INVADERS");
		
		highscore = highscore_get(highnick);
		DoInt(0, 0, highscore);
		DoString (0, 9, highnick);
		lcdDisplay();
		step = !step;
		key=getInputWaitTimeout(1000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}
示例#5
0
文件: high.c 项目: astro/lun1k
void ram() {
  char *nick = "Pentagon V1LLAG3";
  char nickbuf[32];  // 16?

  do {
    lcdFill(0);
    DoString(0, 0, "Getting");
    lcdDisplay();
    uint32_t score = highscore_get(nickbuf);

    gpioSetValue (RB_LED2, 1);
    lcdFill(0);
    DoString(0, 0, "Highscore:");
    DoString(0, 16, nickbuf);
    DoInt(0, 32, score);
    lcdDisplay();

    if (strcmp(nick, nickbuf) != 0) {
      lcdFill(0);
      DoString(0, 48, "Setting");
      lcdDisplay();
      delayms_queue(500);
      highscore_set(score+1, nick);
    }

  } while(getInputWaitTimeout(500) != BTN_UP);

}
示例#6
0
文件: anim.c 项目: hwhw/r0ket
void ram(void) {
	FRESULT ret;
	FATFS FatFs[1];          /* File system object for logical drive */

	//gpioSetValue (RB_LED1, CFG_LED_OFF); 
	//backlightInit();
	//
	lcdFill(0);

	ret=f_mount(0, &FatFs[0]);
	
	if(ret) {
		return;
	}

//	lcdLoadLZOImage("TESTLZO.ILZ");
//	lcdDisplay();
	ret = lcdShowLZOAnim("LZOANIM.VLZ", 80);
#ifdef SIMULAT0R
	fprintf(stderr, "ret=%d\n", ret);
#endif
	while(!getInputRaw()){
		/* nothing Yet */
            getInputWaitTimeout(1000);
	}
	return;
}
示例#7
0
文件: image.c 项目: cokesme/f1rmware
uint8_t lcdShowAnim(char *fname) {
    FIL file;            /* File object */
	int res;
    UINT readbytes;
	uint8_t state=0;
    uint16_t framems=0;

	res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);
	if(res != FR_OK)
		return 1;

	getInputWaitRelease();
	while(!getInputRaw()){
		res = f_read(&file, &framems, sizeof(framems), &readbytes);
        /*
        lcdPrint("ms=");lcdPrintln(IntToStr(framems,4,0));
        lcdPrint("off=");lcdPrintln(IntToStr(f_tell(&file),4,0));
        */
        if(res != FR_OK)
            return 1;
		if(readbytes<sizeof(framems)){
			f_lseek(&file,0);
            continue;
        };
        lcdShowImage(&file);
        getInputWaitTimeout(framems);
	}

    return 0;
}
示例#8
0
文件: mandel.c 项目: cokesme/f1rmware
void mandelMove() {
    //long delta_r = (mandel.rmax - mandel.rmin)/10;
    //long delta_i = (mandel.imax - mandel.imin)/10;

	long rs =(mandel.rmax-mandel.rmin)/RESY;
	long is =(mandel.imax-mandel.imin)/RESX;

	char key = getInputWaitTimeout(10);

	if (key == BTN_LEFT) {
		mandel.imax -=is;
		mandel.imin -=is;
		mandel.dleft = true;
	} else if (key == BTN_RIGHT) {
		mandel.imax += is;
		mandel.imin += is;
		mandel.dright = true;
	} else if (key == BTN_DOWN) {
		mandel.rmax += rs;
		mandel.rmin += rs;
		mandel.ddown = true;
	} else if (key == BTN_UP) {
		mandel.rmax -= rs;
		mandel.rmin -= rs;
		mandel.dup = true;
	} else if (key == BTN_ENTER) {
		if (mandel.presscount < mandel.presslimitzin) {
			mandel.presscount = mandel.presscount + 1;
		}
	} else if (key == BTN_NONE) {
		//delayms_queue(15);
		if(mandel.presscount > 0 ) {
			mandel.presscount = mandel.presscount - 1;
			mandel.clickmark = true;
		}
		if (mandel.presscount == 0 ) {
			mandel.clickmark = false;
		}
	}
	if (mandel.presscount > mandel.presslimitzout && mandel.clickmark && key == BTN_ENTER && mandel.zoomlevel >= mandel.maxzoomout) {
		mandel.imin = mandel.imin - (mandel.imax-mandel.imin)/8;
		mandel.imax = mandel.imax + (mandel.imax-mandel.imin)/8;
		mandel.rmin = mandel.rmin -(mandel.rmax-mandel.rmin)/8;
		mandel.rmax = mandel.rmax +(mandel.rmax-mandel.rmin)/8;
        mandel.dirty = true;
        delayms(10);
        mandel.zoomlevel = mandel.zoomlevel - 1 ;
	 }
       else if (mandel.presscount == mandel.presslimitzin && key == BTN_ENTER && mandel.zoomlevel <= mandel.maxzoomin ) {
        mandel.imin = mandel.imin + (mandel.imax-mandel.imin)/8;
        mandel.imax = mandel.imax - (mandel.imax-mandel.imin)/8;
        mandel.rmin = mandel.rmin +(mandel.rmax-mandel.rmin)/8;
        mandel.rmax = mandel.rmax -(mandel.rmax-mandel.rmin)/8;
        mandel.dirty = true;
        delayms(10);
        mandel.zoomlevel = mandel.zoomlevel + 1 ;
     }
}
示例#9
0
static bool screen_gameover() {
	char key =0;
	while(key==0) {
		lcdFill(0);
		font = &Font_7x8;
		DoString (14,32, "GAME OVER");
		DoInt (0,0, game.score);
		if (highscore_set(game.score, GLOBAL(nickname)))
			DoString (0,9,"HIGHSCORE!");
		lcdDisplay();
		key=getInputWaitTimeout(5000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}	
示例#10
0
文件: r0type.c 项目: andrmuel/r0ket
static void draw_splash(void){
  char key=0;
	while(key==0) {
    lcdFill(0);
    if (highscore_set(game.score, GLOBAL(nickname))){
			DoString (16,15,"HIGHSCORE!");
    } else {
      DoString (16,15, "GAME OVER");
    }
		DoString (24,40, "GAME BY");
		DoString (10,50, "@RANZWERTIG");
    lcdDisplay();
		key=getInputWaitTimeout(1000);
  }
  return;
}
示例#11
0
文件: invaders.c 项目: miloh/f1rmware
static bool screen_gameover() {
	char key =0;
	while(key==0) {
		lcdFill(0x00);
		setIntFont(&Font_7x8);
    setTextColor(0x00,0b11100000);
		lcdSetCrsr(14+15,32+15);lcdPrint("GAME OVER");
    setTextColor(0x00,0xff);
		lcdSetCrsr(0,0);lcdPrint(IntToStr(game.score,6,F_LONG));
		if (highscore_set(game.score, GLOBAL(nickname))){
      setTextColor(0x00,0b00011000);
      lcdSetCrsr(0,9);lcdPrint("HIGHSCORE!");
		};
		lcdDisplay();
		key=getInputWaitTimeout(5000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}
示例#12
0
void simpleNickname(void) {
    int dx=0;
	int dy=0;
    static uint32_t ctr=0;
	ctr++;

	setExtFont(GLOBAL(nickfont));
	dx=DoString(0,0,GLOBAL(nickname));
    dx=(RESX-dx)/2;
    if(dx<0)
        dx=0;
    dy=(RESY-getFontHeight())/3;

    lcdFill(GLOBAL(nickbg));
    setTextColor(GLOBAL(nickbg),GLOBAL(nickfg));
	DoString(dx,dy,GLOBAL(nickname));
    dataLove();
    batteryLevel();
	lcdDisplay();

    getInputWaitTimeout(300);
    return;
}
示例#13
0
文件: r0type.c 项目: andrmuel/r0ket
static bool screen_intro(void) {
	char key=0;
	while(key==0) {
		getInputWaitRelease();
		lcdFill(0);
		int ct = 0;
    for (int i = 0; i < SHIP_HEIGHT; i++){
      for(int d = 0; d < SHIP_WIDTH; d++){
        lcdSetPixel((40+d)%RESX,(10+i)%RESY,SHIP[ct]);
        ct++;
      }
    }
		DoString (13,25,"R0KET TYPE");
		uint32_t highscore;
	  char highnick[20];
	  highscore = highscore_get(highnick);
		DoInt(13, 40, highscore);
		DoString (13, 50, highnick);
		lcdDisplay();
		key=getInputWaitTimeout(1000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}
示例#14
0
文件: msn.c 项目: nupfel/r0ket
/*Message Receiver*/
void waitMsg()
{
    uint8_t key;
    unsigned char buf[32];
    char sender_nick[10];
    int n,i;
    int index=0;
    int rcv =0;
    int try=0;
    do
    {
        key = getInput();
        if(1)
        {
            nrf_config_set(&config);
            n = nrf_rcv_pkt_time(100,32,buf);
            getInputWaitTimeout(100);
            if(n == 32)
            {
                index=buf[0];
                for(i=0; i<10; i++)
                    sender_nick[i]=buf[i+1];
                lcdClear();
                lcdPrintln("");
                lcdPrintln("CCC MSN 0.1b");
                lcdPrintln("---------------");
                lcdPrintln(msgs[index]);
                lcdPrintln("");
                lcdPrintln("Received");
                lcdPrintln("");
                lcdPrintln("_______________");
                lcdPrintln(sender_nick);
                lcdRefresh();
                blink();
                rcv=1;
                try=0;
            } else if(rcv)
            {
                lcdClear();
                lcdPrintln("");
                lcdPrintln("CCC MSN 0.1b");
                lcdPrintln("-----------------");
                lcdPrintln("Waiting...");
                lcdPrint("Try ");
                lcdPrintln(IntToStr(try,5,0));
                lcdPrintln("");
                lcdPrintln(msgs[index]);
                lcdPrintln("_______________");
                lcdPrintln(sender_nick);
                lcdRefresh();
            }
            try++;
        }
        if(!rcv)
        {
            lcdClear();
            lcdPrintln("");
            lcdPrintln("CCC MSN 0.1b");
            lcdPrintln("-----------------");
            lcdPrintln("Waiting...");
            lcdPrintln("");
            lcdPrint("Try ");
            lcdPrintln(IntToStr(try,5,0));
            lcdPrintln("");
            lcdPrintln("_______________");
            lcdPrintln("W8 Users Auto");
            lcdRefresh();
        }
示例#15
0
文件: anim.c 项目: hwhw/r0ket
uint8_t lcdShowLZOAnim(char *fname, uint32_t framems) {
	unsigned char img[864];
	UINT readbytes;
	FRESULT ret;
	FIL file;
	uint16_t sz;
	lzo_uint len;
	uint8_t state=0;

	ret=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);
	if(ret)
		return 1;

	ret = lzo_init();
	if(ret)
		return 2;

	getInputWaitRelease();

	while(!getInputRaw()) {
		//lcdFill(0x55);

		ret = f_read(&file, &sz, 2, &readbytes);

		if(sz == 0) {
			// uncompressed
			ret = f_read(&file, (unsigned char *)lcdBuffer, 864, &readbytes);
			if(ret || readbytes != 864) {
				f_lseek(&file, 0);
				continue;
			}
		} else {
			ret = f_read(&file, img, sz, &readbytes);
			if(ret || readbytes != sz) {
				f_lseek(&file, 0);
				continue;
			}

			lzo1x_decompress(img, sz, (unsigned char *)lcdBuffer, &len, NULL);
		}

		lcdDisplay();
#ifndef SIMULAT0R
		if(framems<100){
#endif
			state=delayms_queue_plus(framems,0);
#ifdef SIMULAT0R
			usleep(framems*1000);
#endif
#ifndef SIMULAT0R
		}else{
			getInputWaitTimeout(framems);
		}
#endif
	}

	if(state)
		work_queue();

	f_close(&file);
	return 0;
}
示例#16
0
文件: menu.c 项目: falkorichter/r0ket
void handleMenu(const struct MENU *the_menu) {
    uint8_t back = 0;
    int8_t menuselection = 0;
    uint8_t numentries;
    uint8_t visible_lines = 0;
    uint8_t current_offset = 0;

    if (the_menu == NULL) return;

    setSystemFont();

    for (numentries = 0; the_menu->entries[numentries].text != NULL ; numentries++);

    if(the_menu->entries[numentries-1].text[0]=='|' && !GLOBAL(develmode))
        numentries--;

    visible_lines = lcdGetVisibleLines()-1; // subtract title line

    if(menuflags&MENU_BIG)
        visible_lines/=2;

#ifdef SAFETY
    if (visible_lines < 2) return;
#endif

    while (!back) {
        // Display current menu page
        lcdClear();
        lcdPrintln(the_menu->title);

        for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++) {
            if(menuflags&MENU_BIG)
                lcdNl();
            if (i == menuselection) {
                lcdPrint("*");
            }
            lcdSetCrsrX(14);
            lcdPrintln(the_menu->entries[i].text);
        }
        lcdRefresh();

        switch (getInputWaitTimeout((menuflags&MENU_TIMEOUT)?15000:0)) {
            case BTN_UP:
                menuselection--;
                if (menuselection < current_offset) {
                    if (menuselection < 0) {
                        menuselection = numentries-1;
                        current_offset = ((numentries-1)/visible_lines) * visible_lines;
                    } else {
                        current_offset -= visible_lines;
                    }
                }
                break;
            case BTN_DOWN:
                menuselection++;
                if (menuselection > (current_offset + visible_lines-1) || menuselection >= numentries) {
                    if (menuselection >= numentries) {
                        menuselection = 0;
                        current_offset = 0;
                    } else {
                        current_offset += visible_lines;
                    }
                }
                break;
            case BTN_LEFT:
                return;
            case BTN_RIGHT:
                if (the_menu->entries[menuselection].callback!=NULL)
                    the_menu->entries[menuselection].callback();
				
				if (menuflags&MENU_JUSTONCE)
					return;
				
                break;
            case BTN_ENTER:
                lcdClear();
//                lcdPrintln("Called...");
//                lcdRefresh();
                getInputWaitRelease();
                if (the_menu->entries[menuselection].callback!=NULL)
                    the_menu->entries[menuselection].callback();
                lcdRefresh();
				
				if (menuflags&MENU_JUSTONCE)
					return;

//                getInputWait();

                break;
            case BTN_NONE: /* timeout */
                return;
            default:
                /* NOTREACHED */
                break;
        }
        getInputWaitRelease();
    }
    return;
}