Example #1
0
File: jump.c Project: Bediko/r0ket
void ram(void) {

	splash_scene();

	long frame_count = 0;
	init_game();

	while(1) {
		frame_count++;

		lcdFill(0);
		update_platforms(frame_count);
		move_player(frame_count);
		draw_platforms();
		draw_player();
		draw_hud();
		blink_led();
		lcdDisplay();

		if(!game.running) {
			if(!gameover_scene()){
                delayms_queue_plus(10,1);
				return;
            }
			init_game();
		}
        delayms_queue_plus(24,0);
	}
}
Example #2
0
void ram(void){
	while(1) {
    if (!screen_intro())
     return;
    init_game();
    while(game.ships > 0){
      game.ticks++;
      lcdFill(0);
      conrtols();
      draw_game();
      lcdDisplay();
      delayms_queue_plus(12,0);
      if(game.shot_delay > 0){
        game.shot_delay--;
      }
    }
    draw_splash();
	}
}
Example #3
0
void ram(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())/2;

	lcdClear();
	DoString(dx,dy,GLOBAL(nickname));
	lcdRefresh();

    while(getInputRaw()==BTN_NONE){
        delayms_queue_plus(10,0);
    };
    return;
}
void ram(void)
{
	short centerx = RESX >> 1;
	short centery = RESY >> 1;
	short i;
	uint8_t key = 0;

	for (i = 0; i < NUM_STARS; i++) {
		init_star(stars + i, i + 1);
	}

	static uint8_t count = 0;
	while(1) {
		count++;
		count%=256;
		key = getInputRaw();
		if (key == BTN_ENTER) {
			break;
		} else if ( count%4 == 0 ) {
			if (key == BTN_UP && ship.speed < SPEED_MAX) {
				ship.speed++;
			} else if (key == BTN_DOWN && ship.speed > SPEED_STOP) {
				ship.speed--;
			} else if (key == BTN_NONE && count % 12 == 0) {
				/* converge towards default speed */
				if (ship.speed < SPEED_DEFAULT)
					ship.speed++;
				else if (ship.speed > SPEED_DEFAULT)
					ship.speed--;	
			}
		}

		if (ship.speed > SPEED_WARP) {
			set_warp_lights(1);
		} else {
			set_warp_lights(0);
		}

        if (count % 3 == 0) OFF(LED4);
		if (ship.speed == 0 && count%6==0) 
            drift_ship();
 

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

		lcdFill(0x00);
		DoString(dx,dy,GLOBAL(nickname));

		for (i = 0; i < NUM_STARS; i++) {
			stars[i].z -= ship.speed;

			if (ship.speed > 0 && stars[i].z <= 0)
				init_star(stars + i, i + 1);

			short tempx = ((stars[i].x * 30) / stars[i].z) + centerx;
			short tempy = ((stars[i].y * 30) / stars[i].z) + centery;

			if (tempx < 0 || tempx > RESX - 1 || tempy < 0 || tempy > RESY - 1) {
				if (ship.speed > 0) { /* if we are flying, generate new stars in front */
					init_star(stars + i, i + 1);
				} else { /* if we are drifting, simply move those stars to the other end */
					stars[i].x = (((tempx%RESX)-centerx)*stars[i].z)/30;
					stars[i].y = (((tempy%RESY)-centery)*stars[i].z)/30;
				}
				continue;
			}

			lcdSetPixel(tempx, tempy, 0xFF);
			if (stars[i].z < 50) {
				lcdSetPixel(tempx + 1, tempy, 0xFF);
			}
			if (stars[i].z < 20) {
				lcdSetPixel(tempx, tempy + 1, 0xFF);
				lcdSetPixel(tempx + 1, tempy + 1, 0xFF);
			}
		}

		lcdDisplay();

		delayms_queue_plus(50,0);
	}
	set_warp_lights(0);
}
Example #5
0
void ram(void) {
    getInputWaitRelease();
    reset_area();
    random_area(life,1,1,RESX,RESY,40);

    static int nickx=2,nicky=10;
    signed char movy=1;
    static int nickwidth,nickheight;
    static int nickoff=10;
    static char delaytime=10;
    static char speedmode=0;
    static char LCDSHIFTX_EVERY_N=2;
    static char LCDSHIFTY_EVERY_N=2;
    static char ITER_EVERY_N=1;

    lcdClear();
    setExtFont(GLOBAL(nickfont));
    
    nickwidth=DoString(nickx,nicky,GLOBAL(nickname));
    if(nickwidth<50)nickoff=30;
    nickheight=getFontHeight();

    char stepmode=0;
    while (1) {
        draw_area(); // xor life pattern over display content
        lcdDisplay();
        lcdClear();
        // draw_area(); // xor life pattern again to restore original display content
        // Old shift code. Can't handle longer Nicks...
        // if(iter%LCDSHIFT_EVERY_N==0) lcdShift(1,-2,1);
        // if(iter%LCDSHIFT_EVERY_N==0) { nickx=(nickx+1)%100-nickwidth; nicky=(nicky+1)%50;}
        if(iter%LCDSHIFTX_EVERY_N==0) { nickx--; 
        if(nickx<(-1*nickwidth-nickoff))nickx=0; }
        if(iter%LCDSHIFTY_EVERY_N==0) { nicky+=movy;
        if(nicky<1 || nicky>RESY-nickheight) movy*=-1; }
        DoString(nickx,nicky,GLOBAL(nickname));
        DoString(nickx+nickwidth+nickoff,nicky,GLOBAL(nickname));
        if(nickwidth<RESX) DoString(nickx+2*(nickwidth+nickoff),nicky,GLOBAL(nickname));
	char key=stepmode?getInputWait():getInputRaw();
	stepmode=0;
	switch(key) {
	case BTN_ENTER:
	  return;
	case BTN_RIGHT:
	  getInputWaitRelease();
          speedmode=(speedmode+1)%7;
          delaytime=15;
          switch(speedmode) {
            case 0:
              ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 1:
              ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=2; LCDSHIFTY_EVERY_N=2; break;
            case 2:
              ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=4; LCDSHIFTY_EVERY_N=4; break;
            case 3:
              ITER_EVERY_N=2; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 4:
              ITER_EVERY_N=4; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 5:
              ITER_EVERY_N=8; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 6:
              delaytime=5; ITER_EVERY_N=8; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
          }
	  break; 
	case BTN_DOWN:
	  stepmode=1;
	  getInputWaitRelease();
	  break;
	case BTN_LEFT:
	  pattern=(pattern+1)%PATTERNCOUNT;
	case BTN_UP:
	  stepmode=1;
	  reset_area();
	  getInputWaitRelease();
	  break;
	}
        delayms_queue_plus(delaytime,0);
#ifdef SIMULATOR
  fprintf(stderr,"Iteration %d - x %d, y %d \n",iter,nickx,nicky);
#endif
        if(iter%ITER_EVERY_N==0) calc_area(); else ++iter;
    }
    return;
}
Example #6
0
File: anim.c Project: 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;
}
Example #7
0
static uint8_t mainloop() {
	uint32_t volatile oldCount = BusIntCtr;
	uint32_t loopCount=BusIntCtr;
	perMin = 0; // counts in last 60 s
	uint32_t minuteTime = _timectr;
	startTime = minuteTime;
	uint8_t button;
	//usbHIDInit();
	while (1) {
		LED_OFF;
		if (loopCount != BusIntCtr) {
			loopCount=BusIntCtr;
			LED_ON;
			IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_GPIO;
			gpioSetDir(RB_LED3,gpioDirection_Output ) ;
			gpioSetValue(RB_LED3, 1);
			if (!GLOBAL(positionleds) ) {
				gpioSetValue(RB_LED2,1);
				gpioSetValue(RB_LED0,1);
			}
		} else {
			if (gpioGetValue(RB_PWR_CHRG) || !GLOBALchargeled) {
				gpioSetDir(RB_LED3,gpioDirection_Input ); // only when not charging..
				}
				if (!GLOBAL(positionleds) ) {
					gpioSetValue(RB_LED0,0);
					gpioSetValue(RB_LED2,0);
				}
			}

		lcdClear();
		//lcdPrintln("   Geiger");
		//lcdPrintln("   Counter");


		memcpy(&lcdBuffer[RESX*RESY_B-sizeof(Header_Invers)],Header_Invers,sizeof(Header_Invers));
		lcdPrintln("");
		lcdPrintln("");
		// ####
		for (int i = 0; i < (14 * (_timectr - minuteTime)) / (60 * 100); i++) {
			lcdPrint("#");
		}
		lcdPrintln("");
		lcdPrint(" ");
		lcdPrintInt(BusIntCtr);
		lcdPrint(" in ");
		lcdPrintInt((_timectr - startTime) / 100);
		lcdPrintln("s");
		lcdPrint(" ");
		lcdPrintInt(perMin);
		lcdPrintln(" cpm");
		{
			uint32_t equivalent = nanoSievertPerH(perMin)+5; // letzte stelle runden
			lcdPrint(" ");
			lcdPrintInt(equivalent / 1000);
			lcdPrint(".");
			lcdPrintInt((equivalent % 1000) / 100);
			lcdPrintInt((equivalent % 100) / 10);
			//lcdPrintInt((equivalent % 10));
			lcdPrintln(" uSv/h");

		}
		//getGeigerMeshVal();
		lcdPrintln("");
		if (gpioGetValue(RB_PWR_CHRG)){
			uint32_t voltage=GetVoltage();
			if (voltage >= GOOD_VOLTAGE) {
				lcdPrintln("Bat: [++++] ");
			} else if (voltage >= HALF_VOLTAGE) {
				lcdPrintln("Bat: [ooo ] ");
			} else if (voltage >= MIN_SAFE_VOLTAGE) {
				lcdPrintln("Bat: [==  ]  ");
			} else if (voltage >= CRIT_VOLTAGE) {
				lcdPrintln("Bat: [-   ] L");
			} else {
				lcdPrintln("Battery: CRIT!");
			}
		} else {
			    lcdPrintln("Bat: Charging");
		}
		// remember: We have a 10ms Timer counter
		if ((minuteTime + 60 * 100) <= _timectr) {
			// dumb algo: Just use last 60 seconds count
			perMin = BusIntCtr - oldCount;
			minuteTime = _timectr;
			oldCount = BusIntCtr;
			//transmitGeigerMeshVal(perMin,minuteTime / (100));
		}
		lcdRefresh();
		delayms_queue_plus(42, 0);
		button = getInputRaw();
		if (button != BTN_NONE) {
			break;
		}

	}
	//usbHidDisconnect();
	return button;
}