예제 #1
0
int main(void)
{
    char key;

    timerInitTOD();
    screenInit();
    progressInit();

    g_strFileName[0] = '\0';
    g_nDrive = *(uint8_t*)0xba;
    if (g_nDrive < 8)
        g_nDrive = 8;

    internalCartType = INTERNAL_CART_TYPE_NONE;

    g_bFastLoaderEnabled = 1;
    updateFastLoaderText();

    refreshMainScreen();
    showAbout();
    refreshMainScreen();
    screenBing();

    // this also makes visible 16kByte of flash memory
    checkFlashType();

    checkRAM();

    for (;;)
    {
        setStatus("Ready. Press <m> for Menu.");

        key = cgetc();
        switch (key)
        {
        case 'm':
            execMenu(&menuMain);
            break;

        case 'o':
            execMenu(&menuOptions);
            break;

        case 'e':
            execMenu(&menuExpert);
            break;

        case 'h':
            execMenu(&menuHelp);
            break;
        }
    }
    return 0;
}
예제 #2
0
bool BoardSupportPackage::init() {
	bool result = false;
	SysTick_Config(SystemCoreClock/BSP_TICKS_PER_SECOND);
	initRCC();
	initGPIO_Power();
	initGPIO_Fan();
	init_DHT11();
	init_SPI();
	init_TIM();
	init_PWM();
 	screenInit();

	result = true;
	return result;
}
예제 #3
0
bool AppRunning()
{
   if(!OSIsMainCore())
   {
      ProcUISubProcessMessages(true);
   }
   else
   {
      ProcUIStatus status = ProcUIProcessMessages(true);
    
      if(status == PROCUI_STATUS_EXITING)
      {
          // Being closed, deinit things and prepare to exit
          isAppRunning = false;
          
          if(initialized)
          {
              initialized = false;
              screenDeinit();
              memoryRelease();
          }
          
          ProcUIShutdown();
      }
      else if(status == PROCUI_STATUS_RELEASE_FOREGROUND)
      {
          // Free up MEM1 to next foreground app, etc.
          initialized = false;
          
          screenDeinit();
          memoryRelease();
          ProcUIDrawDoneRelease();
      }
      else if(status == PROCUI_STATUS_IN_FOREGROUND)
      {
         // Reallocate MEM1, reinit screen, etc.
         if(!initialized)
         {
            initialized = true;
            
            memoryInitialize();
            screenInit();
         }
      }
   }

   return isAppRunning;
}
예제 #4
0
int main()
{
	//gateway
	*(volatile uint32_t*)0x80FFFC0 = 0x18300000;    // framebuffer 1 top left
	*(volatile uint32_t*)0x80FFFC4 = 0x18300000;    // framebuffer 2 top left
	*(volatile uint32_t*)0x80FFFC8 = 0x18300000;    // framebuffer 1 top right
	*(volatile uint32_t*)0x80FFFCC = 0x18300000;    // framebuffer 2 top right
	*(volatile uint32_t*)0x80FFFD0 = 0x18346500;    // framebuffer 1 bottom
	*(volatile uint32_t*)0x80FFFD4 = 0x18346500;    // framebuffer 2 bottom
	*(volatile uint32_t*)0x80FFFD8 = 1;    // framebuffer select top
	*(volatile uint32_t*)0x80FFFDC = 1;    // framebuffer select bottom

	//cakehax
	*(u32*)0x23FFFE00 = 0x18300000;
	*(u32*)0x23FFFE04 = 0x18300000;
	*(u32*)0x23FFFE08 = 0x18346500;

	FATFS fs;
	FIL payload;
	u32 br;

	if(f_mount(&fs, "0:", 0) == FR_OK)
	{
        char* payloadloc;

        if(HID_PAD & 1)
        {
            // Load Decrypt9
            payloadloc = "decrypt9.bin";
        }
        else
        {
            // Load regular payload
		    payloadloc = "arm9loaderhax.bin";
        }

        if(f_open(&payload, payloadloc, FA_READ | FA_OPEN_EXISTING) == FR_OK)
        {
            f_read(&payload, PAYLOAD_ADDRESS, PAYLOAD_SIZE, &br);
            ownArm11();
            screenInit();
            ((void (*)())PAYLOAD_ADDRESS)();
        }
	}

	i2cWriteRegister(I2C_DEV_MCU, 0x20, (u8)(1<<0));
    return 0;
}
예제 #5
0
파일: main.c 프로젝트: an0nym0u5/PSL1GHT
s32 main(s32 argc, const char* argv[])
{
  gcmContextData *context;
  void *host_addr = NULL;
  rsxBuffer buffers[MAX_BUFFERS];
  int currentBuffer = 0;
  padInfo padinfo ;
  padData paddata ;
  u16 width;
  u16 height;
  int i;
  long frame = 0; /* to keep track of how many frames we have rendered */

  atexit(unload_modules);
  if(sysModuleLoad(SYSMODULE_FS) != 0)
    return 0;
  else
    module_flag |= 1;

  if(sysModuleLoad(SYSMODULE_PNGDEC) != 0)
    return 0;
  else
    module_flag |= 2;

  /* Allocate a 1Mb buffer, alligned to a 1Mb boundary
   * to be our shared IO memory with the RSX. */
  host_addr = memalign ( 1024*1024, HOST_SIZE ) ;
  context = screenInit ( host_addr, HOST_SIZE ) ;
  getResolution( &width, &height ) ;
  for (i = 0; i < MAX_BUFFERS; i++)
    makeBuffer( &buffers[i], width, height, i ) ;
  flip( context, MAX_BUFFERS - 1 ) ;
  setRenderTarget(context, &buffers[currentBuffer]) ;

  sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandler, NULL);

  ioPadInit(7) ;

  /* png bitmap buffer */
  pngData png1;

#if USE_PNG_FROM_FILE == true
  const char *filename = PNG_FILE;
  /* load png from file */
  pngLoadFromFile(filename, &png1);
#endif
#if USE_PNG_FROM_FILE == false
  /* load png from memory */
  pngLoadFromBuffer((void *)psl1ght_png, psl1ght_png_size, &png1);
#endif

  /* Ok, everything is setup. Now for the main loop. */
  exitapp = 1;
  while(exitapp)
  {
    /* Check the pads. */
    ioPadGetInfo(&padinfo);
    for(i=0; i<MAX_PADS; i++){
      if(padinfo.status[i]){
        ioPadGetData(i, &paddata);

        if(paddata.BTN_CROSS){
          exitapp = 0;
          goto end;
        }
      }
    }

    waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer
    drawFrame(&buffers[currentBuffer], frame++); // Draw into the unused buffer

    if(png1.bmp_out)
    {
      static int x=0, y=0, dx=2, dy=2;
  
      u32 *scr = (u32 *)buffers[currentBuffer].ptr;
      u32 *png= (void *)png1.bmp_out;
      int n, m;
  
      /* update x, y coordinates */
      x+=dx;
      y+=dy;
  
      /* */
      if(x < 0)
      {
        x=0;
        dx=1;
      }

      /* screen width to png width */
      if(x > (buffers[currentBuffer].width - png1.width))
      {
        x=(buffers[currentBuffer].width - png1.width);
        dx=-2;
      }
  
      /* */
      if(y < 0)
      {
        y=0;
        dy=1;
      }

      /* screen height to png height */
      if(y > (buffers[currentBuffer].height - png1.height))
      {
        y = (buffers[currentBuffer].height - png1.height);
        dy=-2;
      }

      /* update screen buffer from coordinates */
      scr += y * buffers[currentBuffer].width + x;                     
  
      // draw PNG
      for(n=0;n<png1.height;n++)
      {
        if((y+n)>=buffers[currentBuffer].height) break;
        for(m=0;m<png1.width;m++)
        {
          if((x+m)>=buffers[currentBuffer].width) break;
          scr[m]=png[m];
        }
        png+=png1.pitch>>2;
        scr+=buffers[currentBuffer].width;
      }
    }

    flip(context, buffers[currentBuffer].id); /* Flip buffer onto screen */

    currentBuffer = !currentBuffer;
    setRenderTarget(context, &buffers[currentBuffer]) ; /* change buffer */

    sysUtilCheckCallback(); /* check user attention span */
  }

 end:

  gcmSetWaitFlip(context);
  for (i=0; i < MAX_BUFFERS; i++)
    rsxFree (buffers[i].ptr);
  rsxFinish (context, 1);
  free (host_addr);
  ioPadEnd();

  return 0;
}
예제 #6
0
int main(int argc, char **argv) { 

  int windX=10;
  int windY=30;
  int windWidth=320;
  int windHeight=200;
  int c;
  opterr = 0;

  openSound(configUseCD); 
  catchSignals();


  while ((c = getopt(argc, argv, "b:h:w:")) != -1){
    switch (c)
      {

      case '?':
	fprintf(stderr, "%s: unknown option \"%s\"\n", 
		argv[0], argv[optind-1]);
	usage(argv[0]);
	exit(1);	
      case 'b':
	bright = (double) atoi(optarg);
	bright = bright/10;
	break;
      case 'w':
	windWidth = atoi(optarg);
	break;
      case 'h':
	windHeight = atoi(optarg);
	break;
      }
  }

 
  if (bright > 1.0)
    bright = 1.0;
  else if (bright < 0.0)
    bright = 0.0;


  if (windWidth < 1)
    windWidth = 320;
  if (windHeight < 1)
    windHeight = 200;

  setBrightness(bright);

  screenInit(windX,windY,windWidth,windHeight);
  output = new unsigned char[outWidth*outHeight*2];

  coreInit();

  time_t timer = time(NULL);
  
  int frames = 0;
  do {
    screenShow();
    coreGo();
    frames++;
  } while(!processUserInput());

  timer = time(NULL) - timer;
  delete output;
  closeSound();

  if (timer > 10)
    fprintf(stderr,"Frames per second: %f\n", double(frames)/timer);
  
  return 0;
}
예제 #7
0
파일: tetris.mgl.c 프로젝트: 1tgr/mobius
/*****************************************************************************
    name:    main
*****************************************************************************/
int main(void)
{
    char Fell, NewShape, NewX, NewY;
    unsigned Shape, X, Y;
    wint_t Key;
    mglrc_t *rc;


/* re-seed the random number generator */
    srand(SysUpTime());

    rc = mglCreateRc(NULL);
    if (rc == NULL)
        return EXIT_FAILURE;

NEW:
        screenInit();
        write_status(L"TETRIS by Alexei\n"
            L" Pazhitnov\n"
            L"Software by\n"
            L" Chris Giese\n"
            L"\x2018" L"1" L"\x2019" L" and " L"\x2018" L"2" L"\x2019" L" rotate\n"
            L"Arrow keys move\n"
            L"Esc or Q quits");
        goto FOO;

    while(1)
    {
        Fell = 0;
        NewShape = Shape;
        NewX = X;
        NewY = Y;
        Key = getKey();
        if (Key == 0)
        {
            NewY++;
            Fell = 1;
        }
        else
        {
            if(Key == 'q' || Key == 'Q' || Key == 27)
                break;
                //goto FIN;
            if (Key == '1' || Key == KEY_UP)
                NewShape = Shapes[Shape].Plus90;
            else if (Key == '2')
                NewShape = Shapes[Shape].Minus90;
            else if (Key == KEY_LEFT)
            {
                if (X > 0)
                    NewX = X - 1;
            }
            else if (Key == KEY_RIGHT)
            {
                if (X < SCN_WID - 1)
                    NewX = X + 1;
            }
            else if (Key == KEY_DOWN)
            {
                if (Y < SCN_HT - 1)
                    NewY = Y + 1;
            }

            Fell = 0;
        }
        /* if nothing has changed, skip the bottom half of this loop */
        if(NewX == X && NewY == Y && NewShape == Shape)
            continue;
        /* otherwise, erase old shape from the old pos'n */
        shapeErase(X, Y, Shape);

        /* hit anything? */
        if(shapeHit(NewX, NewY, NewShape) == 0)
        {
            /* no, update pos'n */
            X = NewX;
            Y = NewY;
            Shape=NewShape; 
        }
        /* yes -- did the piece hit something while falling on its own? */
        else if(Fell)
        {
            /* yes, draw it at the old pos'n... */
            shapeDraw(X, Y, Shape);

            /* ... and spawn new shape */
FOO:        Y = 3;
            X = SCN_WID / 2;
            Shape = rand() % _countof(Shapes);
            collapse();

            /* if newly spawned shape hits something, game over */
            if (shapeHit(X, Y, Shape))
            {
                write_status(L"GAME OVER");
                ConReadKey();
                goto NEW; 
            }
        }

        /* hit something because of user movement/rotate OR no hit: just redraw it */
        shapeDraw(X, Y, Shape);
        refresh();
    }
    
    mglDeleteRc(rc);
    return 0;
}
예제 #8
0
int main()
{
	screenInit();

	screenPutString("BIOS Terminal v1.0 build " BUILD "\r\n(C) Copyright 2004 Wojtek Kaniewski <*****@*****.**>\r\nPress F12 to configure serial port\r\n\r\n");

	serialSetup();

	for (;;) {

#ifdef DEBUG_SERIAL
		byte x, y, a;

		x = screenX; y = screenY; a = screenAttr;
		screenX = 30; screenY = 24; screenAttr = 7*16;
		screenCursorNoUpdate = 1;
		screenPutString(" s:");
		screenPutHex((char)((char) serialRxHead - (char) serialRxTail));
		screenPutString(" i:");
		screenPutHex(portRead(0x21));
		screenPutString(" t:");
		screenPutHex(serialRxTail >> 8);
		screenPutHex(serialRxTail &255);
		screenPutString("/h:");
		screenPutHex(serialRxHead >> 8);
		screenPutHex(serialRxHead &255);
		screenPutString(",");
		screenPutHex(portRead(serialPort+1));
		screenPutString(",");
		screenPutHex(serialInterruptLast); // +2
		screenPutString(",");
		screenPutHex(portRead(serialPort+3));
		screenPutString(",");
		screenPutHex(portRead(serialPort+4));
		screenPutString(",");
		screenPutHex(portRead(serialPort+5));
		screenPutString(",");
		screenPutHex(portRead(serialPort+6));
		screenPutString(" k:");
		screenCursorNoUpdate = 0;
		screenX = x; screenY = y; screenAttr = a;

		screenCursorUpdate();
#endif // DEBUG_SERIAL

		if (keyboardPressed()) {
			char *seq = vtGetChar();

			while (*seq) {
				serialPutChar(*seq);
				seq++;
			}
		}

		while (serialDataReady()) {
			char ch = serialGetChar();

			vtPutChar(ch);
		}
	}
}
예제 #9
0
int 
main(int argc, char **argv) 
{
  int windX=10;
  int windY=30;
  int windWidth=uiWidth;
  int windHeight=uiHeight;
  int c;
  int xx, xy;
  opterr = 0;

  /*
  KAboutData aboutData( "kscdmagic", I18N_NOOP("kscdmagic"),
			KSCDMAGICVERSION, I18N_NOOP("sound visualisation"), 
			KAboutData::License_GPL,
			"(c) 2000, Dirk Försterling");
  aboutData.addAuthor("Paul Harrison",0, "*****@*****.**");
  aboutData.addAuthor("Dirk Försterling",0, "*****@*****.**");

  KCmdLineArgs::init( argc, argv, &aboutData );

  KApplication magicApp;
  */


  openSound(SourceCD, 44100, "/dev/dsp", NULL);

  catchSignals();

  while ((c = getopt(argc, argv, "b:h:w:")) != -1){
    switch (c)
      {
      case '?':
	fprintf(stderr, "%s: unknown option \"%s\"\n", 
		argv[0], argv[optind-1]);
	usage(argv[0]);
	exit(1);	
      case 'b':
	bright = (double) atoi(optarg);
	bright = bright/10;
	break;
      case 'w':
	windWidth = atoi(optarg);
	break;
      case 'h':
	windHeight = atoi(optarg);
	break;
      }
  }
  
  if (bright > 1.0)
    bright = 1.0;
  else if (bright < 0.0)
    bright = 0.0;
  
  if (windWidth < 1)
    windWidth = uiWidth;
  if (windHeight < 1)
    windHeight = uiHeight;

  screenInit(windX,windY,windWidth,windHeight);

  allocOutput(outWidth,outHeight);

  coreInit();
  

  setStarSize(starSize);
  setBrightness(bright);

  time_t timer = time(NULL);
  
  int frames = 0;

  for(;;) {
    fade();
    if (-1 == coreGo())
      break;

    polygonEngine.clear();

    for( xy = 0; xy < 48; xy++)
      {
	for( xx = 0; xx < 48; xx++)
	  {
	    if ( logo[xy][xx] != 0)
	      {
		polygonEngine.add(32769, xx+10, xy+3);
	      }
	  }
      }
    polygonEngine.apply(outputBmp.data);
    screenShow(); 



    frames++;
    if(processUserInput() == -1)
      break;
  } 

  
  timer = time(NULL) - timer;
  delete ucoutput;
  closeSound();
  
  if (timer > 10)
    fprintf(stderr,"Frames per second: %f\n", double(frames)/timer);
  
  return 0;
} // main() /* linux */