void LoadConfig() { cfg_Init("verge.cfg"); cfg_SetDefaultKeyValue("startmap", ""); if (cfg_KeyPresent("xres")) v3_xres = cfg_GetIntKeyValue("xres"); if (cfg_KeyPresent("yres")) v3_yres = cfg_GetIntKeyValue("yres"); // Overkill (2010-04-29): Scaling policies. if (cfg_KeyPresent("scalewin")) { int value = cfg_GetIntKeyValue("scalewin"); if(value >= 0 && value < SCALE_FORMAT_COUNT) { v3_scale_win = (ScaleFormat) value; } } if (cfg_KeyPresent("scalefull")) { int value = cfg_GetIntKeyValue("scalefull"); if(value >= 0 && value < SCALE_FORMAT_COUNT) { v3_scale_full = (ScaleFormat) value; } } if (cfg_KeyPresent("window_x_res")) v3_window_xres = cfg_GetIntKeyValue("window_x_res"); if (cfg_KeyPresent("window_y_res")) v3_window_yres = cfg_GetIntKeyValue("window_y_res"); if (cfg_KeyPresent("windowmode")) windowmode = cfg_GetIntKeyValue("windowmode") ? true : false; if (cfg_KeyPresent("nosound")) sound = cfg_GetIntKeyValue("nosound") ? false : true; if (cfg_KeyPresent("soundengine")) soundengine = cfg_GetIntKeyValue("soundengine"); if (cfg_KeyPresent("automax")) automax = cfg_GetIntKeyValue("automax") ? true : false; if (cfg_KeyPresent("startmap")) strcpy(mapname, cfg_GetKeyValue("startmap")); if (cfg_KeyPresent("appname")) setWindowTitle(cfg_GetKeyValue("appname")); if (cfg_KeyPresent("gamerate")) gamerate = cfg_GetIntKeyValue("gamerate"); if (cfg_KeyPresent("v3isuberlikethetens")) cheats = true; if (cfg_KeyPresent("editcode")) editcode = cfg_GetIntKeyValue("editcode") ? true : false; if (cfg_KeyPresent("logconsole")) { logconsole = true; initConsole(); } else if (cfg_KeyPresent("logconsole-normalstdout")) { logconsole = true; } void platform_ProcessConfig(); platform_ProcessConfig(); }
int IdeDrvExecDLL // EXECUTE THE DLL ONE TIME (LOAD IF REQ'D) ( IDEDRV *inf // - driver control information , char const *cmd_line ) // - command line #ifdef STATIC_LINKAGE // Execute DLL // // One mode (with static linkage): // // (1) WATCOM IDE interface is used. // { int runcode; int retcode; retcode = ensureLoaded( inf, &runcode ); if( retcode == IDEDRV_SUCCESS ) { IDEBool fatal = FALSE; initConsole(); runcode = IDERunYourSelf( inf->ide_handle, cmd_line, &fatal ); finiConsole(); retcode = retcodeFromFatal( fatal, runcode, retcode ); } stashCodes( inf, runcode, retcode ); return( retcode ); }
/****************************************************************************** * Function: void InitializeSystem(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: This routine takes care of all of the system * initialization that is required. * * Note: * *****************************************************************************/ void InitializeSystem(void) { initDelayms(); // Delayms() must be initialized first initAllIndicators(); // Init all Explorer 16 LEDs initAllSwitches(SWITCH_DEBOUNCE_MS); // Init all Explorer 16 switches initLCD(); // Init LCD //Initialize Debug Console UART interface initConsole(PB_CLOCK_FREQ); clrscrConsole(); homeConsole(); putsConsole("wifly_pass_thru_demo_exp16_p24...\r\n"); sprintf(OutString,"version: %s\r\n", Version); putsConsole(OutString); sprintf(OutString,"build date: %s\r\n", CompileDate); putsConsole(OutString); sprintf(OutString,"build time: %s\r\n\r\n", CompileTime); putsConsole(OutString); sprintf(OutString,"use a terminal emulator to communicate directly with the module...\r\n\r\n"); putsConsole(OutString); sprintf(OutString,"(optional) press S4 on Explorer16 to reset WiFly to factory defaults...\r\n\r\n"); putsConsole(OutString); initWiFly(PB_CLOCK_FREQ); }
/****************************************************************************** * Function: void InitializeSystem(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: This routine takes care of all of the system * initialization that is required. * * Note: * *****************************************************************************/ void InitializeSystem(void) { initDelayms(); // Delayms() must be initialized first initAllIndicators(); // Init all Explorer 16 LEDs initAllSwitches(SWITCH_DEBOUNCE_MS); // Init all Explorer 16 switches /* Enable ADC to the Potentiometer channel and configure it as 10 bit interrupt driven mode */ ADC_ChannelEnable ( ADC_CHANNEL_POTENTIOMETER ) ; ADC_SetConfiguration ( ADC_CONFIGURATION_EXP16_DEMO ) ; initLCD(); // Init LCD //Initialize Debug Console UART interface initConsole(PB_CLOCK_FREQ); clrscrConsole(); homeConsole(); putsConsole("wifly_pass_thru_demo_exp16_p24...\r\n"); sprintf(OutString,"version: %s\r\n", Version); putsConsole(OutString); sprintf(OutString,"build date: %s\r\n", CompileDate); putsConsole(OutString); sprintf(OutString,"build time: %s\r\n\r\n", CompileTime); putsConsole(OutString); sprintf(OutString,"use a terminal emulator to communicate directly with the module...\r\n\r\n"); putsConsole(OutString); sprintf(OutString,"(optional) press S4 on Explorer16 to reset WiFly to factory defaults...\r\n\r\n"); putsConsole(OutString); initWiFly(PB_CLOCK_FREQ); }
int main(void) { unsigned int i; int sum = 0; int current = 0; int hgt_percent = 0; int degrees = 0; STATE = IDLE; initClock(); initADC(); initYaw(); initMotorPin(); initDisplay(); intButton(); initConsole(); initPWMchan(); initCircBuf (&g_inBuffer, BUF_SIZE); // Enable interrupts to the processor. IntMasterEnable(); while (1) { //double dt = SysCtlClockGet() / SYSTICK_RATE_HZ; degrees = yawToDeg(); // Background task: calculate the (approximate) mean of the values in the // circular buffer and display it. sum = 0; for (i = 0; i < BUF_SIZE; i++) { current = readCircBuf (&g_inBuffer); sum = sum + current; } int newHght = ADC_TO_MILLIS(sum/BUF_SIZE); if(initialRead != 0) { hgt_percent = calcHeight(initialRead, newHght); } if (STATE == FLYING || STATE == LANDING){ PIDControl(hgt_percent, SysCtlClockGet() / SYSTICK_RATE_HZ); PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty / 100); PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty / 100); } displayInfo((int)initialRead, hgt_percent, degrees); } }
int Setup() { initConsole(); puts("�כ�ה�כ�ם¶�"); int width; scanf("%d", &width); initWindow("test", 600, 600, width, width); beginPaint(); line(20, 20, width-20, width-20); endPaint(); return 0; }
void init() { // Set precision for floating point output elapsedTime = 0.0; initConsole(ConsoleSize, "SP1 Framework"); ArrowLocate.X = 31; ArrowLocate.Y = 11; ArrowLocate2.X = 44; ArrowLocate2.Y = 11; }
void Console::openConsole(float posX, float posY, int charW, int charH) { if(!consoleOpened) { initConsole(); CellDbgFontConsoleConfig ccfg; ccfg.posLeft = posX; // Left coordinate of the console ccfg.posTop = posY; // Upper coordinate of the console ccfg.cnsWidth = charW; // Console width (number of characters) ccfg.cnsHeight = charH; // Console height (number of characters) ccfg.scale = 0.50f; // Font size ccfg.color = 0xffffff00; // Font color consoleId = cellDbgFontConsoleOpen(&ccfg); consoleOpened = true; } }
int Setup() { initWindow ("Test", DEFAULT, DEFAULT, 800, 600); initConsole(); printf("Hello\n"); beginPaint (); line(10, 10, 100, 100); endPaint(); return 0; }
int main(int argc, char* argv[]) { REG_POWERCNT = POWER_ALL & ~(POWER_MATRIX | POWER_3D_CORE); // don't need 3D consoleDebugInit(DebugDevice_CONSOLE); defaultExceptionHandler(); time(&rawTime); lastRawTime = rawTime; timerStart(0, ClockDivider_1024, TIMER_FREQ_1024(1), clockUpdater); /* Reset the EZ3in1 if present */ if (!__dsimode) { sysSetCartOwner(BUS_OWNER_ARM9); GBA_BUS[0x0000] = 0xF0; GBA_BUS[0x1000] = 0xF0; } fifoSetValue32Handler(FIFO_USER_02, fifoValue32Handler, NULL); sharedData = (SharedData*)memUncached(malloc(sizeof(SharedData))); sharedData->scalingOn = false; // It might make more sense to use "fifoSendAddress" here. // However there may have been something wrong with it in dsi mode. fifoSendValue32(FIFO_USER_03, ((u32)sharedData)&0x00ffffff); consoleOn = true; initConsole(); initInput(); readConfigFile(); if (argc >= 2) { char* filename = argv[1]; loadProgram(filename); initializeGameboyFirstTime(); } else { selectRom(); } consoleOn = false; updateScreens(); runEmul(); return 0; }
// プログラムは WinMain から始まります int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // 初期化処理 initConsole(); if (!initDxLib()) { exit(1); } SceneManager smgr; BattleScene* start = new BattleScene(); //DrawableFactoryTest* start = new DrawableFactoryTest(); smgr.reserveNewScene(start); smgr.run(); // 終了処理 FreeConsole(); DxLib_End(); return 0; // ソフトの終了 }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { initConsole(); //accès au nombre de processeur SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); int proc = sysinfo.dwNumberOfProcessors; consoleEcho("test"); consoleEcho("%i",proc); consoleEcho("test1"); consoleEcho("test2"); consoleEcho("test3"); consoleEcho("test4"); return 0; }
int main(void) { int iChoice = 0; // size console window to 100x40 if(!initConsole()) { // show error box showError("Error", "Console Window could not be initialized.\nExiting program."); return EXIT_FAILURE; } // LogIn / Register Menu showStartScreen(); do { // choose between LogIn and Register getUserInput("%i", &iChoice, "\tChoose: ", "\n\tYour input is invalid. Please choose again.\n"); } while(iChoice != 1 && iChoice != 2); // LogIn / Register if(iChoice == 1) { // loop until valid login while(!showLogin()); } else { // loop until valid registration while(!showRegister()); } // loop until user quits manually while(startApplication()); return EXIT_SUCCESS; }
void init() { // Set precision for floating point output elapsedTime = 0.0; initConsole(ConsoleSize, "SP1 Framework"); shipLocation.X = 0; shipLocation.Y = ConsoleSize.Y / 2; bullets = new bool*[ConsoleSize.Y]; for (int count = 0; count < ConsoleSize.Y; count++) { bullets[count] = new bool[ConsoleSize.X]; for (int count2 = 0; count2 < ConsoleSize.X; count2++) bullets[count][count2] = false; } bulletBuffer = 0; levelInfo.level = 11; spawnBufferCount = 0; enemiesSpawned = 0; }
/* * RTEMS Startup task */ rtems_task Init (rtems_task_argument ignored) { int i; char *argv[3] = { NULL, NULL, NULL }; char *cp; rtems_task_priority newpri; rtems_status_code sc; rtems_time_of_day now; /* * Explain why we're here */ logReset(); /* * Architecture-specific hooks */ if (epicsRtemsInitPreSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) delayedPanic("epicsRtemsInitPreSetBootConfigFromNVRAM"); if (rtems_bsdnet_config.bootp == NULL) { extern void setBootConfigFromNVRAM(void); setBootConfigFromNVRAM(); } if (epicsRtemsInitPostSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) delayedPanic("epicsRtemsInitPostSetBootConfigFromNVRAM"); /* * Override RTEMS configuration */ rtems_task_set_priority ( RTEMS_SELF, epicsThreadGetOssPriorityValue(epicsThreadPriorityIocsh), &newpri); /* * Create a reasonable environment */ initConsole (); putenv ("TERM=xterm"); putenv ("IOCSH_HISTSIZE=20"); /* * Display some OS information */ printf("\n***** RTEMS Version: %s *****\n", rtems_get_version_string()); /* * Start network */ if ((cp = getenv("EPICS_TS_NTP_INET")) != NULL) rtems_bsdnet_config.ntp_server[0] = cp; if (rtems_bsdnet_config.network_task_priority == 0) { unsigned int p; if (epicsThreadHighestPriorityLevelBelow(epicsThreadPriorityScanLow, &p) == epicsThreadBooleanStatusSuccess) { rtems_bsdnet_config.network_task_priority = epicsThreadGetOssPriorityValue(p); } } printf("\n***** Initializing network *****\n"); rtems_bsdnet_initialize_network(); initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); /* * More environment: iocsh prompt and hostname */ { char hostname[1024]; gethostname(hostname, 1023); char *cp = mustMalloc(strlen(hostname)+3, "iocsh prompt"); sprintf(cp, "%s> ", hostname); epicsEnvSet ("IOCSH_PS1", cp); epicsEnvSet("IOC_NAME", hostname); } /* * Use BSP-supplied time of day if available otherwise supply default time. * It is very likely that other time synchronization facilities in EPICS * will soon override this value. */ if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&now) != RTEMS_SUCCESSFUL) { now.year = 2001; now.month = 1; now.day = 1; now.hour = 0; now.minute = 0; now.second = 0; now.ticks = 0; if ((sc = rtems_clock_set (&now)) != RTEMS_SUCCESSFUL) printf ("***** Can't set time: %s\n", rtems_status_text (sc)); } if (getenv("TZ") == NULL) { const char *tzp = envGetConfigParamPtr(&EPICS_TIMEZONE); if (tzp == NULL) { printf("Warning -- no timezone information available -- times will be displayed as GMT.\n"); } else { char tz[10]; int minWest, toDst = 0, fromDst = 0; if(sscanf(tzp, "%9[^:]::%d:%d:%d", tz, &minWest, &toDst, &fromDst) < 2) { printf("Warning: EPICS_TIMEZONE (%s) unrecognizable -- times will be displayed as GMT.\n", tzp); } else { char posixTzBuf[40]; char *p = posixTzBuf; p += sprintf(p, "%cST%d:%.2d", tz[0], minWest/60, minWest%60); if (toDst != fromDst) p += sprintf(p, "%cDT", tz[0]); epicsEnvSet("TZ", posixTzBuf); } } } tzset(); osdTimeRegister(); /* * Run the EPICS startup script */ printf ("***** Starting EPICS application *****\n"); iocshRegisterRTEMS (); set_directory (argv[1]); epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]); atexit(exitHandler); i = main ((sizeof argv / sizeof argv[0]) - 1, argv); printf ("***** IOC application terminating *****\n"); epicsThreadSleep(1.0); epicsExit(0); }
// Main function void main(void) { reset_peripheral(); initClock(); initTimer(); initDisplay(); initPin(); initGPIO(); initADC(); initConsole(); int i = 0; //init_password(); send_data(); initCircBuf (&speed_buffer, BUF_SIZE); init_set_speed_data(&speed_set_data); int screen = 0; int screen_prev = 0; float speed = 0; float buffed_speed = 0; int fake_speed = 0; float acc = 0; float max_acc = 0; //float fuel_eco = 0; float distance = 0; bool fix = 0; uint8_t satillite = 0; float quality = 0; clock time; int aim_pos = 0; unsigned long adc = 0; //int error_stepper = 0; IntMasterEnable(); while(1){ //reading data read_data = split_data(UART_char_data_old, read_data); // decode data speed = read_speed(); //read data into variables adc = run_adc()/7; //calculations aim_pos = speed_feedback(buffed_speed, encoder_1/40, speed_set_data.speed); if (speed_set_data.enable == 1){ step_motor_control(encoder_1/40, aim_pos); } //sending fake data fake_speed = (int)adc;//= random_at_most(100/1.852); send_info(fake_speed);//knots //storing data store_speed(speed); buffed_speed = analysis_speed(); acc = read_acceleration(buffed_speed); max_acc = max_acc_func(acc, max_acc); time = read_time(); satillite = read_satillite(); fix = read_fix(); quality = read_quality(); debounce_button(); // debounce buttons screen = read_button_screen(screen, fix); distance = read_distance(); select_read(); //need a mosfet for turning power off // select adds a an on and off switch yo if (screen == 1){ if(screen_prev != 1 && screen == 1){ speed_set_data.speed = buffed_speed; } speed_set_data.speed = set_speed(speed_set_data.speed); // set the speed to cruise at } if (screen == 2){ //0 to 100 acceleration_test(speed); } // refresh chainging if (fix == 1 && speed_set_data.old == speed_set_data.speed && refresh_rate < 4){ UARTSend((unsigned char *)PMTK_SET_NMEA_UPDATE_5HZ, 18, 0); refresh_rate += 1; } if (i >= 50){ display(screen, buffed_speed, acc, max_acc, speed_set_data.speed, satillite, encoder_1/40, time, distance, quality, UART_char_data_old, aim_pos, adc, acc_times); i = 0; } screen_prev = screen; i++; } }
ConsoleGraphics::ConsoleGraphics() { this->lastStatusChar = 0; initConsole(); initArray(); }
void kmain(MultibootInfo *info) { ASM("cli"); kernelStatus = KERNEL_RUNNING; initConsole(); kprintf("Successfully booted into 64-bit mode\n"); if (info->modsCount != 1) { panic("the initrd was not loaded"); }; kprintf_debug(" *** TO TRAP THE KERNEL *** \n"); kprintf_debug(" set r15=rip\n"); kprintf_debug(" set rip=%a\n", &trapKernel); kprintf_debug(" *** END OF INFO *** \n"); kprintf("Initializing the IDT... "); initIDT(); kprintf("%$\x02" "Done%#\n"); kprintf("Checking amount of memory... "); int memSize = info->memLower + info->memUpper; if (info->flags & 1) { kprintf("%$\x01%dMB%#\n", (memSize/1024)); } else { kprintf("%$\x04" "Failed%#\n"); panic("could not determine memory size"); }; if ((info->flags & (1 << 6)) == 0) { panic("no memory map from bootloader"); }; uint64_t mmapAddr = (uint64_t) info->mmapAddr + 0xFFFF800000000000; uint64_t mmapEnd = mmapAddr + info->mmapLen; kprintf("Memory map address: %a memory map size = %d\n", mmapAddr, info->mmapLen); MultibootMemoryMap *mmap = (MultibootMemoryMap*) mmapAddr; kprintf("Size\tBase\tLen\tType\n"); while ((uint64_t)mmap < mmapEnd) { kprintf("%d\t%a\t%d\t%d\n", mmap->size, mmap->baseAddr, mmap->len, mmap->type); mmap = (MultibootMemoryMap*) ((uint64_t) mmap + mmap->size + 4); }; MultibootModule *mod = (MultibootModule*) ((uint64_t) info->modsAddr + 0xFFFF800000000000); uint64_t end = (uint64_t) mod->modEnd + 0xFFFF800000000000; kprintf("Initializing memory allocation phase 1 (base=%a)... ", end); initMemoryPhase1(end); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the physical memory manager (%d pages)... ", (memSize/4)); initPhysMem(memSize/4, (MultibootMemoryMap*) mmapAddr, mmapEnd); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the ISP... "); ispInit(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing memory allocation phase 2... "); initMemoryPhase2(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the frame stack... "); initPhysMem2(); kprintf("%$\x02" "Done%#\n"); initModuleInterface(); kprintf("Getting ACPI info... "); acpiInit(); msrWrite(0x1B, 0xFEE00000 | (1 << 11) /*| (1 << 8)*/ ); apic->sivr = 0x1FF; kprintf("Initializing the FPU... "); fpuInit(); DONE(); kprintf("Initializing the VFS... "); vfsInit(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the initrdfs... "); initInitrdfs(info); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the procfs... "); initProcfs(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the devfs... "); initDevfs(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing PCI... "); pciInit(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the FS driver interface... "); initFSDrivers(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the PIT... "); uint16_t divisor = 1193180 / 1000; // 1000 Hz outb(0x43, 0x36); uint8_t l = (uint8_t)(divisor & 0xFF); uint8_t h = (uint8_t)( (divisor>>8) & 0xFF ); outb(0x40, l); outb(0x40, h); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the APIC timer..."); ASM("sti"); apic->timerDivide = 3; apic->timerInitCount = 0xFFFFFFFF; sleep(35); apic->lvtTimer = 0; quantumTicks = 0xFFFFFFFF - apic->timerCurrentCount; apic->timerInitCount = 0; // put the timer in single-shot mode at the appropriate interrupt vector. apic->lvtTimer = I_APIC_TIMER; DONE(); kprintf("Initializing the scheduler and syscalls... "); //msrWrite(0xC0000080, msrRead(0xC0000080) | 1); //msrWrite(0xC0000081, ((uint64_t)8 << 32)); //msrWrite(0xC0000082, (uint64_t)(&_syscall_entry)); //msrWrite(0xC0000084, (1 << 9)); initSched(); // "Done" will be displayed by initSched(), and then kmain2() will be called. };
s32 main(s32 argc, const char* argv[]) { int count = 0; int n; padInfo padinfo; padData paddata; char *cur_device = "/ntfs0:"; char path[1024]; // map file functions to libc open, fopen, ... NTFS_init_system_io(); tiny3d_Init(1024*1024); tiny3d_Project2D(); u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) u32 * texture_pointer; // use to asign texture space without changes texture_mem if(!texture_mem) return 0; // fail! texture_pointer = texture_mem; ResetFont(); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); initConsole(); ioPadInit(7); DbgHeader("NTFS EXT2/3/4 Example"); /* // Mount all NTFS volumes on all inserted block devices mountCount = ntfsMountAll(&mounts, NTFS_DEFAULT | NTFS_RECOVER); // mountCount = ntfsMountDevice (&__io_ntfs_usb000, &mounts, NTFS_DEFAULT | NTFS_RECOVER); if (mountCount == -1) DPrintf("Error whilst mounting devices (%i).\n", errno); else if (mountCount == 0) DPrintf("No NTFS volumes were found and/or mounted.\n"); else DPrintf("%i NTFS volumes(s) mounted!\n\n", mountCount); */ int i; count = 1; while(1) { if(count > 0) { count--; if(count == 0) { int k; initConsole(); for(k = 0; k < 8; k++) { for (i = 0; i < mountCount[k]; i++) DPrintf("%i - %s:/ (%s) (from usb00%i)\n", i + 1, (mounts[k]+i)->name, ntfsGetVolumeName((mounts[k] + i)->name), ((mounts[k] + i)->interface->ioType & 0xff) - '0'); } int r; cur_device = NULL; r = NTFS_Test_Device("ext0"); DPrintf("\nTest ext0 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext0:"; r = NTFS_Test_Device("ext1"); DPrintf("Test ext1 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext1:"; r = NTFS_Test_Device("ext2"); DPrintf("Test ext2 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext2:"; r = NTFS_Test_Device("ext3"); DPrintf("Test ext3 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext3:"; r = NTFS_Test_Device("ntfs0"); DPrintf("Test ntfs0 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs0:"; r = NTFS_Test_Device("ntfs1"); DPrintf("Test ntfs1 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs1:"; r = NTFS_Test_Device("ntfs2"); DPrintf("Test ntfs2 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs2:"; r = NTFS_Test_Device("ntfs3"); DPrintf("Test ntfs3 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs3:"; if(!cur_device) cur_device = "/ntfs0:"; // by default } } DbgHeader("NTFS EXT2/3/4 Example"); DbgMess("Press X to list device, O to test file and /\\ to exit"); for(i = 0; i < 8 ; i++) { int r = NTFS_Event_Mount(i); if(r == 1) { // mount device NTFS_UnMount(i); mounts[i] = NULL; mountCount[i] = 0; mountCount[i] = ntfsMountDevice (disc_ntfs[i], &mounts[i], NTFS_DEFAULT | NTFS_RECOVER); if(mountCount[i]>0) {count = 1;} // update counter } else if(r == -1) { // unmount device NTFS_UnMount(i); count = 1; } } // DbgMess(); DbgDraw(); tiny3d_Flip(); ioPadGetInfo(&padinfo); for(n = 0; n < MAX_PADS; n++) { static u32 btn_flags = 0; if(padinfo.status[n]) { ioPadGetData(n, &paddata); if(paddata.BTN_CROSS) { if((btn_flags & 1)==0){ btn_flags|=1; max_list = 0; initConsole(); count = 300; DPrintf("Listing 10 entries from %s (5 seconds)\n", cur_device); sprintf(path, "%s", cur_device); list(path, 0); } } else btn_flags&=~1; if(paddata.BTN_CIRCLE) { if((btn_flags & 2)==0){ btn_flags|=2; DPrintf("\n\nWriting / Reading a file from %s\n", cur_device); sprintf(path, "%s/0text", cur_device); mkdir(path, 0777); sprintf(path, "%s/0text/test.txt", cur_device); FILE *fp; fp =fopen(path, "wb"); if(fp) { int i; i = fwrite(message, 1, strlen(message), fp); if(i != strlen(message)) DPrintf("Error writing the file!\n"); fclose(fp); } else DPrintf("Error creating the file!\n"); memset(buffer, 0, 1024); sprintf(path, "%s/0text/test.txt", cur_device); fp = fopen(path, "rb"); if(fp) { int i; // NOTE: for files > 2GB you can use 64 bit method #ifdef USE_64BIT_SEEK struct _reent reent1; DPrintf ("Using _lseek64_r for large files\n"); s64 size = _lseek64_r(&reent1, fp->_file, 0, SEEK_END); _lseek64_r(&reent1, fp->_file, 0, SEEK_SET); DPrintf ("Size of file %i bytes\n", (int) size); #else fseek(fp, 0, SEEK_END); int size = ftell(fp); DPrintf ("Size of file %i bytes\n", size); fseek(fp, 0, SEEK_SET); #endif i = fread(buffer, 1, size, fp); if(i != size) DPrintf("Error reading the file %i!\n", i); fclose(fp); } else DPrintf("Error Reading the file!\n"); DPrintf("Readed From file: %s\n\n", buffer); } } else btn_flags&=~2; if(paddata.BTN_TRIANGLE){ goto out; } } } } out:; DPrintf("Umounting\n"); DbgDraw(); tiny3d_Flip(); NTFS_UnMountAll(); return 0; }
int main() { touchPosition touch; PrintConsole mainScreen; mySprite sprites[128]; lcdMainOnBottom(); initVideo(); initBackgrounds(); initConsole(&mainScreen); initSprites(sprites); //leftButtonOff oamSet(&oamMain, sprites[0].id, sprites[0].x, sprites[0].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[0].gfx, -1, false, false, false, false, false); //rightButtonOff oamSet(&oamMain, sprites[2].id, sprites[2].x, sprites[2].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[2].gfx, -1, false, false, false, false, false); int keys = keysDown(); int currentSprite = 4; int moveLeft = 0; int moveRight = 0; int MOVE_SPEED = 21; while (true) { //consoleClear(); scanKeys(); touchRead(&touch); keys = keysHeld(); if (keys) { if (keys & KEY_TOUCH) { touchRead(&touch); if (within(&touch, sprites[0])) { // leftButton clicked // leftButtonOn oamClearSprite(&oamMain, 0); oamSet(&oamMain, sprites[1].id, sprites[1].x, sprites[1].y, 0, 1, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[1].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); moveLeft = 1; } else if (within(&touch, sprites[2])) { // rightButton clicked // rightButtonOn oamClearSprite(&oamMain, 2); oamSet(&oamMain, sprites[3].id, sprites[3].x, sprites[3].y, 0, 1, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[3].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); moveRight = 1; } else if(within(&touch, sprites[currentSprite])) { mmEffectEx(&sprites[currentSprite].sfx); } } } else { //leftButtonOff oamClearSprite(&oamMain, 1); oamSet(&oamMain, sprites[0].id, sprites[0].x, sprites[0].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[0].gfx, -1, false, false, false, false, false); //rightButtonOff oamClearSprite(&oamMain, 3); oamSet(&oamMain, sprites[2].id, sprites[2].x, sprites[2].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[2].gfx, -1, false, false, false, false, false); if (moveLeft) { if ((currentSprite - 1) >= 4) { // move current sprite to the right and new one in from left int x1 = sprites[currentSprite].x; int x2 = -64; while (x1 < 280 || x2 < 96) { oamSet(&oamMain, sprites[currentSprite].id, x1, sprites[currentSprite].y, 0, sprites[currentSprite].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite].gfx, -1, false, false, false, false, false); oamSet(&oamMain, sprites[currentSprite-1].id, x2, sprites[currentSprite-1].y, 0, sprites[currentSprite-1].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite-1].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); x1 += MOVE_SPEED; x2 += MOVE_SPEED; } currentSprite--; } moveLeft = 0; } else if (moveRight) { if ((currentSprite + 1) - SPRITECOUNT < 0) { // move current sprite to the left and new one from right int x1 = sprites[currentSprite].x; int x2 = 256; while (x1 > -80 || x2 > 96) { oamSet(&oamMain, sprites[currentSprite].id, x1, sprites[currentSprite].y, 0, sprites[currentSprite].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite].gfx, -1, false, false, false, false, false); oamSet(&oamMain, sprites[currentSprite+1].id, x2, sprites[currentSprite+1].y, 0, sprites[currentSprite+1].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite+1].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); x1 -= MOVE_SPEED; x2 -= MOVE_SPEED; } currentSprite++; } moveRight = 0; } } //oamSet(oam, id, x, y, priority, palette_alpha, size, colorformat, gfxOffset, affineIndex, //sizedouble, hide, hflip, vflip, mosaic); // //gong consoleClear(); printf("\x1b[3;3H%s", sprites[currentSprite].desc); oamSet(&oamMain, sprites[currentSprite].id, sprites[currentSprite].x, sprites[currentSprite].y, 0, sprites[currentSprite].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); } }
//============================================================================= // Console object code follows //============================================================================= Console::Console(COORD consoleSize, LPCSTR lpConsoleTitle) : screenDataBufferSize(consoleSize.X * consoleSize.Y) { initConsole(consoleSize, lpConsoleTitle); }
int main(void) { int prevPwm = 0; int prevDegC = 0; int degC; int pwm; WDTCTL = WDTPW + WDTSSEL + WDTCNTCL; // ACLK / 32768: 3,2s // config clk BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; BCSCTL3 = LFXT1S_2; // Use VLO // Unused pins as inputs with pull-down. P1DIR = 0; P1REN = ~(MOSFET_GATE_PIN | BIT1 | BIT2 | ZERO_DETECT_PIN); P2DIR = 0; P2REN = 0xff; initConsole(); printf("Start\r\n"); ADC10AE0 |= (1 << 4); // PA.1 ADC option select // Configure MOSFET gate pin P1OUT &= ~MOSFET_GATE_PIN; P1DIR |= MOSFET_GATE_PIN; // P1.6 output // Configure voltage zero level detect pin P1IE |= ZERO_DETECT_PIN; P1IES |= ZERO_DETECT_PIN; // Timer A0 for PWM TA0CCR0 = (ACLK_HZ / PWM_HZ) - 1; TA0CCR1 = 0; TA0CCTL1 = OUTMOD_7 | CCIE; // Positive PWM TA0CCTL0 = CCIE; TA0CTL = TASSEL_1 + MC_1 + TACLR + TAIE; // ACLK, upmode __eint(); while (1) { WDTCTL = WDTPW + WDTSSEL + WDTCNTCL; // ACLK / 32768: 3,2s __bis_status_register(CPUOFF); degC = adcTemp - *tempCal30; degC = 30 + ((float)degC) / 1024 * 1500 / 3.55; // Filter temperature changes, // during cooling react only if change // is more than 2 degrees. if (degC > prevDegC) prevDegC = degC; else if (prevDegC - degC >= 2) prevDegC = degC; printf ("adc %d degc %d filtdegc %d ", adcPot, degC, prevDegC); if (adcPot < 20) adcPot = 0; else if (adcPot > 1000) adcPot = 1000; pwm = adcPot / 10; // PWM % if (pwm > 10 && prevDegC > 40) { // check overheat pwm = 10; printf ("overheat "); } printf("pwm %d %%\r\n", pwm); if (abs(prevPwm - pwm) > 2) { prevPwm = pwm; TA0CCR1 = ((float)pwm) / 100.0 * (ACLK_HZ / PWM_HZ); } } }
Console::Console(unsigned short consoleWidth, unsigned short consoleHeight, LPCSTR lpConsoleTitle) : screenDataBufferSize(consoleWidth * consoleHeight) { COORD consoleSize = { consoleWidth, consoleHeight }; initConsole(consoleSize, lpConsoleTitle); }