int SFInitScreen(lua_State* l) { int w = lua_tonumber(Scripts.vm, 1); /* получаем 1-ый */ /* переданный параметр */ int h = lua_tonumber(Scripts.vm, 2); const char *title = lua_tostring(Scripts.vm, 3); bool fullscreen = lua_toboolean(Scripts.vm, 4); ScreenInit(w, h, title, fullscreen); return 0; }
void main() { int Key; ScreenInit(); Init(); while (1) { if (_kbhit()) { Key = _getch(); if (Key == 'q' || Key=='Q') break; if (Key == SPACE) { //게임 시작 / 일시정지 switch (GameStatus) { case START: GameStatus = INIT; break; case RUNNING: GameStatus = STOP; break; case GO: GameStatus = RUNNING; break; case STOP: GameStatus = RUNNING; break; } } if (GameStatus != GO && GameStatus != STOP) KeyControl(Key); } Update(); Render(); } Release(); ScreenRelease(); }
SQInteger SFInitScreen(HSQUIRRELVM v) { int w; int h; const char *title; bool fullscreen; sq_getinteger(Scripts.vm, 2, &w); /* получаем 1-ый */ /* переданный параметр */ sq_getinteger(Scripts.vm, 3, &h); sq_getstring(Scripts.vm, 4, &title); sq_getbool(Scripts.vm, 5, &fullscreen); ScreenInit(w, h, title, fullscreen); return 0; }
void EqualCard() { int key; clock_t CurTime; Init(); ScreenInit(); while (1) { if (_kbhit()) // key 입력이 있으면 { key = _getch(); if ((key == 'q') || (key == 'Q')) { Stage.Level = 0; break; } // key 조작 KeyControl(key); } Update(); Render(); while (1) { CurTime = clock(); if (CurTime - G_OldTime > DelayT) { G_OldTime = CurTime; break; } } } }
void main() { int key; Init(); ScreenInit(); while (1) { if (_kbhit()) { key = _getch(); if (key == 'q' || key == 'Q') break; KeyControl(key); } Update(); Render(); } }
/** * Resize the bitmap and the related parameters * * @param x the new size of the graphic * @param y the new size of the graphic (view) */ void TViewBoard::Resize( int x, int y ) { TLowGraphic::Resize( x, y ); ScreenInit(); }
Print::Print() { ScreenInit(); }
/* * doInitializeEditor - do just that */ static void doInitializeEditor( int argc, char *argv[] ) { int i, arg, cnt, ocnt, startcnt = 0; srcline sline; int k, j; char tmp[FILENAME_MAX], c[1]; char buff[MAX_STR], file[MAX_STR], **list; char cmd[MAX_STR * 2]; char *parm; char *startup[MAX_STARTUP]; char *startup_parms[MAX_STARTUP]; vi_rc rc; vi_rc rc1; /* * Make sure WATCOM is setup and if it is not, make a best guess. */ watcom_setup_env(); /* * If EDPATH is not set, use system default %WATCOM%\EDDAT. */ if( getenv( "EDPATH" ) == NULL ) { char *watcom; watcom = getenv( "WATCOM" ); if( watcom != NULL ) { char edpath[FILENAME_MAX]; sprintf( edpath, "%s%c%s", watcom, FILE_SEP, "eddat" ); if( setenv( "EDPATH", edpath, 0 ) != 0 ) { /* * Bail out silently on error, as we will get error message later on. */ } } } /* * misc. set up */ MaxMemFree = MemSize(); StaticStart(); FTSInit(); BoundDataInit(); EditFlags.Starting = true; InitCommandLine(); ChkExtendedKbd(); SSInitBeforeConfig(); GetCWD1( &HomeDirectory ); GetCWD1( &CurrentDirectory ); SetCWD( HomeDirectory ); if( cfgFN == NULL ){ cfgFN = DupString( CFG_NAME ); } checkFlags( &argc, argv, startup, startup_parms, &startcnt ); ScreenInit(); SetWindowSizes(); EditFlags.ClockActive = false; SetInterrupts(); #ifdef __WIN__ InitClrPick(); InitFtPick(); SubclassGenericInit(); CursorOp( COP_INIT ); #else InitColors(); #endif InitSavebufs(); InitKeyMaps(); /* * initial configuration */ EditVars.Majick = MemStrDup( "()~@" ); EditVars.FileEndString = MemStrDup( "[END_OF_FILE]" ); MatchInit(); SetGadgetString( NULL ); WorkLine = MemAlloc( sizeof( line ) + EditVars.MaxLine + 2 ); WorkLine->len = -1; sline = 0; if( cfgFN[0] != 0 ) { c[0] = 0; rc = Source( cfgFN, c, &sline ); if( rc == ERR_FILE_NOT_FOUND ) { #ifdef __WIN__ CloseStartupDialog(); MessageBox( (HWND)NULLHANDLE, "Could not locate configuration information; please make sure your EDPATH environment variable is set correctly", EditorName, MB_OK ); ExitEditor( -1 ); #else rc = ERR_NO_ERR; #endif } } else { rc = ERR_NO_ERR; } if( wantNoReadEntireFile ) { EditFlags.ReadEntireFile = false; } VerifyTmpDir(); while( LostFileCheck() ); HookScriptCheck(); if( EditFlags.Quiet ) { EditFlags.Spinning = false; EditFlags.Clock = false; } ExtendedMemoryInit(); /* * more misc. setup */ if( EditVars.WordDefn == NULL ) { EditVars.WordDefn = DupString( &WordDefnDefault[6] ); InitWordSearch( EditVars.WordDefn ); } if( EditVars.WordAltDefn == NULL ) { EditVars.WordAltDefn = DupString( WordDefnDefault ); } if( EditVars.TagFileName == NULL ) { EditVars.TagFileName = DupString( "tags" ); } DotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); AltDotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); DotCmd = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); SwapBlockInit( EditVars.MaxSwapBlocks ); ReadBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); WriteBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); FindHistInit( EditVars.FindHist.max ); FilterHistInit( EditVars.FilterHist.max ); CLHistInit( EditVars.CLHist.max ); LastFilesHistInit( EditVars.LastFilesHist.max ); GetClockStart(); GetSpinStart(); SelRgnInit(); SSInitAfterConfig(); #if defined( VI_RCS ) ViRCSInit(); #endif /* * create windows */ StartWindows(); InitMouse(); rc1 = NewMessageWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } DoVersion(); rc1 = InitMenu(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.SpinningOurWheels = true; EditFlags.ClockActive = true; EditFlags.DisplayHold = true; rc1 = NewStatusWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.DisplayHold = false; MaxMemFreeAfterInit = MemSize(); /* * look for a tag: if there is one, set it up as the file to start */ EditFlags.WatchForBreak = true; if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif rc1 = LocateTag( cTag, file, buff ); cFN = file; if( rc1 != ERR_NO_ERR ) { if( rc1 == ERR_TAG_NOT_FOUND ) { Error( GetErrorMsg( rc1 ), cTag ); ExitEditor( 0 ); } FatalError( rc1 ); } } /* * start specified file(s) */ cmd[0] = 'e'; cmd[1] = 0; arg = argc - 1; k = 1; while( !EditFlags.NoInitialFileLoad ) { if( cFN == nullFN && !EditFlags.UseNoName ) { break; } #ifdef __NT__ { int k2; int arg2; char path[_MAX_PATH]; int found; int fd; size_t len; size_t len1; char *p; /* * check for the existence of a file name containing spaces, and open it if * there is one */ len = _MAX_PATH - 1; found = 0; p = path; arg2 = arg; for( k2 = k; argv[k2] != NULL; ) { len1 = strlen( argv[k2] ); if( len1 > len ) break; memcpy( p, argv[k2], len1 ); p += len1; *p = '\0'; len -= len1; --arg2; ++k2; fd = open( path, O_RDONLY ); if( fd != -1 ) { close( fd ); k = k2; arg = arg2; found = 1; break; } *p++ = ' '; } if( found ) { #ifndef __UNIX__ len1 = strlen( path ); if( path[len1 - 1] == '.' ) path[len1 - 1] = '\0'; #endif rc1 = NewFile( path, false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } cFN = argv[k]; if( arg < 1 ) { break; } continue; } } #endif strcat( cmd, SingleBlank ); strcat( cmd, cFN ); ocnt = cnt = ExpandFileNames( cFN, &list ); if( cnt == 0 ) { cnt = 1; } else { cFN = list[0]; } for( j = 0; j < cnt; j++ ) { rc1 = NewFile( cFN, false ); if( rc1 != ERR_NO_ERR && rc1 != NEW_FILE ) { FatalError( rc1 ); } if( EditFlags.BreakPressed ) { break; } if( cnt > 0 && j < cnt - 1 ) { cFN = list[j + 1]; } } if( ocnt > 0 ) { MemFreeList( ocnt, list ); } if( EditFlags.BreakPressed ) { ClearBreak(); break; } k++; arg--; if( cTag != NULL || arg < 1 ) { break; } cFN = argv[k]; } if( EditFlags.StdIOMode ) { rc1 = NewFile( "stdio", false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } } EditFlags.WatchForBreak = false; EditFlags.Starting = false; /* * if there was a tag, do the appropriate search */ if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { if( buff[0] != '/' ) { i = atoi( buff ); rc1 = GoToLineNoRelCurs( i ); } else { rc1 = FindTag( buff ); } if( rc1 > 0 ) { Error( GetErrorMsg( rc1 ) ); } } /* * try to run startup file */ if( EditFlags.RecoverLostFiles ) { startcnt = 0; } for( i = 0; i < startcnt; i++ ) { GetFromEnv( startup[i], tmp ); ReplaceString( &cfgFN, tmp ); if( cfgFN[0] != 0 ) { if( startup_parms[i] != NULL ) { parm = startup_parms[i]; } else { c[0] = 0; parm = c; } #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif sline = 0; rc = Source( cfgFN, parm, &sline ); } } if( rc > ERR_NO_ERR ) { Error( "%s on line %u of \"%s\"", GetErrorMsg( rc ), sline, cfgFN ); } if( argc == 1 ) { LoadHistory( NULL ); } else { LoadHistory( cmd ); } if( EditVars.GrepDefault == NULL ) { EditVars.GrepDefault = DupString( "*.(c|h)" ); } if( goCmd[0] != 0 ) { KeyAddString( goCmd ); } if( keysToPush != NULL ) { KeyAddString( keysToPush ); } #ifdef __WIN__ if( lineToGoTo != 0 ) { SetCurrentLine( lineToGoTo ); NewCursor( CurrentWindow, EditVars.NormalCursorType ); } #endif AutoSaveInit(); HalfPageLines = WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES ) / 2 - 1; #if defined( _M_X64 ) VarAddGlobalStr( "OSX64", "1" ); #elif defined( _M_IX86 ) && !defined( _M_I86 ) VarAddGlobalStr( "OS386", "1" ); #endif if( EditVars.StatusString == NULL ) { EditVars.StatusString = DupString( "L:$6L$nC:$6C" ); } UpdateStatusWindow(); #ifdef __WIN__ if( CurrentInfo == NULL ) { // no file loaded - screen is disconcertenly empty - reassure DisplayFileStatus(); } #endif NewCursor( CurrentWindow, EditVars.NormalCursorType ); #if defined( __NT__ ) && !defined( __WIN__ ) { SetConsoleActiveScreenBuffer( OutputHandle ); } #endif } /* doInitializeEditor */
/* * This function sets up all of our connections to X */ void SetupX(const char *dstr) { int err; char buf[128]; unsigned int mask; if (!dstr) dstr = getenv("DISPLAY"); if (!dstr) dstr = ":0.0"; /* Open a connection to the diplay nominated by the DISPLAY variable */ err = EDisplayOpen(dstr, Dpy.screen); if (err) { Alert(_("Enlightenment cannot connect to the display nominated by\n" "your shell's DISPLAY environment variable. You may set this\n" "variable to indicate which display name Enlightenment is to\n" "connect to. It may be that you do not have an Xserver already\n" "running to serve that Display connection, or that you do not\n" "have permission to connect to that display. Please make sure\n" "all is correct before trying again. Run an Xserver by running\n" "xdm or startx first, or contact your local system\n" "administrator, or Xserver vendor, or read the X, xdm and\n" "startx manual pages before proceeding.\n")); EExit(1); } if (getenv("ESYNCHRONIZE")) XSynchronize(disp, True); Dpy.screens = ScreenCount(disp); Dpy.screen = DefaultScreen(disp); if (Mode.wm.master || Mode.wm.master_screen < 0 || Mode.wm.master_screen >= Dpy.screens) Mode.wm.master_screen = Dpy.screen; /* Start up on multiple heads, if appropriate */ if (Dpy.screens > 1 && !Mode.wm.single && !Mode.wm.restart) { int i; for (i = 0; i < Dpy.screens; i++) { pid_t pid; if (i == Dpy.screen) continue; pid = fork(); if (pid) { /* We are the master */ Mode.wm.child_count++; Mode.wm.children = EREALLOC(pid_t, Mode.wm.children, Mode.wm.child_count); Mode.wm.children[Mode.wm.child_count - 1] = pid; } else { /* We are a slave */ EDisplayDisconnect(); Mode.wm.master = 0; Mode.wm.pid = getpid(); Dpy.screen = i; ExtInitWinSet(NoXID); #ifdef SIGSTOP kill(getpid(), SIGSTOP); #endif EDisplayOpen(dstr, i); /* Terminate the loop as I am the child process... */ break; } } } Dpy.name = Estrdup(DisplayString(disp)); Esetenv("DISPLAY", Dpy.name); Dpy.pixel_black = BlackPixel(disp, Dpy.screen); Dpy.pixel_white = WhitePixel(disp, Dpy.screen); EDisplaySetErrorHandlers(EventShowError, HandleXIOError); /* Root defaults */ RROOT = ERegisterWindow(DefaultRootWindow(disp), NULL); if (Mode.wm.window) { VROOT = ECreateWindow(RROOT, 0, 0, Mode.wm.win_w, Mode.wm.win_h, 0); /* Enable eesh and edox to pick up the virtual root */ Esnprintf(buf, sizeof(buf), "%#x", WinGetXwin(VROOT)); Esetenv("ENL_WM_ROOT", buf); } else { /* Running E normally on the root window */ VROOT = RROOT; } Dpy.root_gc = EXCreateGC(WinGetXwin(VROOT), 0, NULL); /* Initialise event handling */ EventsInit(); /* select all the root window events to start managing */ Dpy.last_error_code = 0; mask = StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask; ESelectInput(VROOT, mask); ESync(0); if (Dpy.last_error_code) { AlertX(_("Another Window Manager is already running"), _("OK"), NULL, NULL, _("Another Window Manager is already running.\n" "\n" "You will have to quit your current Window Manager first before\n" "you can successfully run Enlightenment.\n")); EExit(1); } mask |= ButtonPressMask | ButtonReleaseMask; ESelectInput(VROOT, mask); ESync(0); if (Dpy.last_error_code) { AlertX(_("Cannot select root window button press events"), _("OK"), NULL, NULL, _("Root window button actions will not work.\n")); } /* warn, if necessary about X version problems */ if (ProtocolVersion(disp) != 11) { AlertX(_("X server version error"), _("Ignore this error"), "", _("Quit Enlightenment"), _("WARNING:\n" "This is not an X11 Xserver. It in fact talks the X%i protocol.\n" "This may mean Enlightenment will either not function, or\n" "function incorrectly. If it is later than X11, then your\n" "server is one the author of Enlightenment neither have\n" "access to, nor have heard of.\n"), ProtocolVersion(disp)); } /* damn that bloody numlock stuff - ok I'd rather XFree got fixed to not */ /* have it as a modifier and everyone have to write specific code to mask */ /* it out - but well.... */ /* ok under Xfree Numlock and Scollock are lock modifiers and we need */ /* to hunt them down to mask them out - EVIL EVIL EVIL hack but needed */ { XModifierKeymap *mod; EX_KeyCode nl, sl; unsigned int numlock, scrollock; int i; int masks[8] = { ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; numlock = scrollock = 0; mod = XGetModifierMapping(disp); nl = EKeysymToKeycode(XK_Num_Lock); sl = EKeysymToKeycode(XK_Scroll_Lock); if ((mod) && (mod->max_keypermod > 0)) { for (i = 0; i < (8 * mod->max_keypermod); i++) { if ((nl) && (mod->modifiermap[i] == nl)) numlock = masks[i / mod->max_keypermod]; else if ((sl) && (mod->modifiermap[i] == sl)) scrollock = masks[i / mod->max_keypermod]; } } Mode.masks.mod_combos[0] = 0; Mode.masks.mod_combos[1] = LockMask; if (numlock) { Mode.masks.mod_combos[2] = numlock; Mode.masks.mod_combos[5] = LockMask | numlock; } if (scrollock) { Mode.masks.mod_combos[3] = scrollock; Mode.masks.mod_combos[6] = LockMask | scrollock; } if (numlock && scrollock) { Mode.masks.mod_combos[4] = numlock | scrollock; Mode.masks.mod_combos[7] = LockMask | numlock | scrollock; } Mode.masks.mod_key_mask = (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) & (~(numlock | scrollock | LockMask)); if (mod) XFreeModifiermap(mod); } ScreenInit(); }
/* * ---------------------------------------------------------------------------- * * DevGraphicsInit -- * * Initialize the mouse and the screen. * * Results: * None. * * Side effects: * The world is initialized. * * ---------------------------------------------------------------------------- */ void DevGraphicsInit() { Time time; int i; int slot; Mach_SlotInfo slotInfo; ReturnStatus status; char *slotAddr; DisplayInfo *displayInfoPtr = (DisplayInfo *) NIL; Sync_SemInitDynamic(&graphicsMutex, "graphicsMutex"); for (i = 0; i < numConfigDisplays; i++) { displayInfoPtr = &configDisplays[i]; for (slot = 0; slot < 3; slot++) { slotAddr = (char *) MACH_IO_SLOT_ADDR(slot); status = Mach_GetSlotInfo(slotAddr + displayInfoPtr->romOffset, &slotInfo); if (status == SUCCESS) { if ((!strcmp(slotInfo.vendor, displayInfoPtr->vendor)) && (!strcmp(slotInfo.module, displayInfoPtr->module))) { displayType = displayInfoPtr->type; break; } } } if (displayType != UNKNOWN) { break; } } switch (displayType) { case UNKNOWN : Mach_MonPrintf( "Assuming you have one of those fancy graphics displays.\n"); displayType = PMAGDA; break; case PMAGBA: Mach_MonPrintf("Color frame buffer in slot %d, (%s %s %s %s)\n", slot, slotInfo.module, slotInfo.vendor, slotInfo.revision, slotInfo.type); break; } if (displayType == PMAGBA) { ramdac.addrLowPtr = (unsigned char *) (slotAddr + PMAGBA_RAMDAC_OFFSET); ramdac.addrHighPtr = (unsigned char *) (slotAddr + PMAGBA_RAMDAC_OFFSET + 0x4); ramdac.regPtr = (unsigned char *) (slotAddr + PMAGBA_RAMDAC_OFFSET + 0x8); ramdac.colorMap = (unsigned char *) (slotAddr + PMAGBA_RAMDAC_OFFSET + 0xc); /* * Initialize screen info. */ scrInfoPtr = (DevScreenInfo *) MACH_UNCACHED_ADDR(&scrInfoCached); events = (DevEvent *) MACH_UNCACHED_ADDR(eventsCached); tcs = (DevTimeCoord *) MACH_UNCACHED_ADDR(tcsCached); InitScreenDefaults(scrInfoPtr); scrInfoPtr->eventQueue.events = events; scrInfoPtr->eventQueue.tcs = tcs; frameBuffer = (char *) (slotAddr + PMAGBA_BUFFER_OFFSET); scrInfoPtr->bitmap = (char *) frameBuffer; scrInfoPtr->cursorBits = (short *)(cursorBits); Timer_GetRealTimeOfDay(&time, (int *) NIL, (Boolean *) NIL); scrInfoPtr->eventQueue.timestampMS = TO_MS(time); scrInfoPtr->eventQueue.eSize = DEV_MAXEVQ; scrInfoPtr->eventQueue.eHead = scrInfoPtr->eventQueue.eTail = 0; scrInfoPtr->eventQueue.tcSize = MOTION_BUFFER_SIZE; scrInfoPtr->eventQueue.tcNext = 0; /* * Initialize the color map, and the screen, and the mouse. */ InitColorMap(); ScreenInit(); } MouseInit(); Scroll(); /* * Init the "latest mouse report" structure */ lastRep.state = 0; lastRep.dx = 0; lastRep.dy = 0; lastRep.byteCount = 0; /* * Reset the keyboard. */ if(!inKBDReset) { KBDReset(); } if (displayType == PMAGBA) { /* * Clear any pending video interrupts. */ * ((int *) (slotAddr + PMAGBA_IREQ_OFFSET)) = 1; } initialized = TRUE; bzero((char *) debugArray, sizeof(debugArray)); }
void Shoot() { int Key, Remain; ScreenInit(); Init(); // 초기화 while (1) //무한반복 { if (_kbhit()) // 키 입력? { Key = _getch(); if (p_GameState == RESULT) // RESULT 키입력 -> 종료 break; // RESULT 상태가 아닐 시 if (Key == 'q' || Key == 'Q') { p_Stage = -1; break; } // START 상태에서의 키 조작 if (p_GameState == START) { if (Key == SPACE) p_GameState = INIT; } // SUCCESS 상태에서의 키 조작 if (p_GameState == SUCCESS) { p_OldTime = clock(); switch (Key) { case 'Y': case 'y': if (p_Stage < 2) { ++p_Stage; p_GameState = INIT; } else // 모든 게임 클리어 { p_GameState = RESULT; } break; case 'N': case 'n': p_GameState = RESULT; break; } } // FAILED 상태에서의 키 조작 if (p_GameState == FAILED) { p_GameState = RESULT; p_OldTime = clock(); p_Stage--; getchar(); } /* if (p_GameState == FAILED || p_GameState==SUCCESS) { switch (Key) { case 'Y': case 'y': if (p_GameState == SUCCESS) { ++p_Stage; // 미션성공 + 게임진행 원할 시, 스테이지 레벨 증가 p_GameState = INIT; } if (p_GameState==FAILED) p_GameState = RESULT; p_OldTime = clock(); break; case 'N': case 'n': if (p_GameState == FAILED) { p_Stage--; // 게임결과창을 위한 -- } p_GameState = RESULT; p_OldTime = clock(); break; } } */ switch (Key) { // S F Y case 'S': case 's': p_Goal = 1; break; case 'F': case 'f': p_Goal = 0; break; // 플레이어 캐릭터 조작 case LEFT: if (Player.MoveX > 0) { Player.MoveX--; Remain = Length - (Player.CenterX + 1); // 남은길이 = 전체 길이 - (중심좌표 + 1) if (Player.MoveX + Remain > 79 || Player.MoveX - Player.CenterX < 0) Player.MoveX--; Player.X = Player.MoveX - Player.CenterX; } break; case RIGHT: if (Player.MoveX + 1 < 79) { Player.MoveX++; Remain = Length - (Player.CenterX + 1); if (Player.MoveX + Remain > 79 || Player.MoveX - Player.CenterX < 0) Player.MoveX++; Player.X = Player.MoveX - Player.CenterX; } break; case SPACE: if (Ball.ReadyB) { Ball.bMoveX = Player.MoveX; Ball.bMoveY = Player.MoveY - 1; Ball.OldTime = clock(); Ball.ReadyB = 0; } break; case 'r': if (BallCount != 0) { BallCount = 0; Ball.ReadyB = 1; Ball.bMoveX = Player.MoveX; Ball.bMoveY = Player.MoveY - 1; p_GameState = INIT; } break; } } Update();//데이터 갱신 Render(); //화면 출력 } }
/** * Constructor * * @param x size of the view * @param y size of the view */ TViewBoard::TViewBoard( int x, int y ) : TView( x, y ) { m_iShowCarsBehind = 3; ScreenInit(); }
//***************************************************************************** // // The main routine // //***************************************************************************** int main(void) { int TypeID; tTRF79x0TRFMode eCurrentTRF79x0Mode = P2P_PASSIVE_TARGET_MODE; uint32_t x; uint16_t ui16MaxSizeRemaining=0; bool bCheck=STATUS_FAIL; uint8_t pui8Instructions[]="Instructions:\n " "You will need a NFC capable device and a NFC boosterpack for " "this demo\n " "To use this demo put the phone or tablet within 2 inches of " "the NFC boosterpack\n " "Messages sent to the microcontroller will be displayed on " "the terminal and screen\n " "Messages can be sent back to the NFC device via the " "'Echo Tag' button on the pull down menu\n"; // // Run from the PLL at 120 MHz. // g_ui32SysClk = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Select NFC Boosterpack Type // g_eRFDaughterType = RF_DAUGHTER_TRF7970ATB; // // Configure the device pins. // PinoutSet(); // // Initialize the UART for console I/O. // UARTStdioConfig(0, 115200, g_ui32SysClk); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(g_ui32SysClk); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Initialize the Touch Screen Frames and related Animations. // ScreenInit(); // // Draw the application frame. // FrameDraw(&g_sContext, "nfc-p2p-demo"); // // Initialize USER LED to Blue. (May Overlap TriColor LED) // ENABLE_LED_PERIPHERAL; SET_LED_DIRECTION; // // Initialize TriColer LED if it exists. // if(BOARD_HAS_TRICOLOR_LED) { ENABLE_LED_TRICOLOR_RED_PERIPH; SET_LED_TRICOLOR_RED_DIRECTION; ENABLE_LED_TRICOLOR_BLUE_PERIPH; SET_LED_TRICOLOR_BLUE_DIRECTION; ENABLE_LED_TRICOLOR_GREEN_PERIPH; SET_LED_TRICOLOR_GREEN_DIRECTION; } // // Initialize the TRF79x0 and SSI. // TRF79x0Init(); // // Initialize Timer0A. // Timer0AInit(); // // Enable First Mode. // NFCP2P_init(eCurrentTRF79x0Mode,FREQ_212_KBPS); // // Enable Interrupts. // IntMasterEnable(); // // Print a prompt to the console. // UARTprintf("\n****************************\n"); UARTprintf("* NFC P2P Demo *\n"); UARTprintf("****************************\n"); // // Print instructions to the console / screen. // UARTprintf((char *)pui8Instructions); ScreenPayloadWrite(pui8Instructions,sizeof(pui8Instructions),1); while(1) { // // Update Screen. // ScreenPeriodic(); // // NFC-P2P-Initiator-Statemachine. // if(NFCP2P_proccessStateMachine() == NFC_P2P_PROTOCOL_ACTIVATION) { if(eCurrentTRF79x0Mode == P2P_INITATIOR_MODE) { eCurrentTRF79x0Mode = P2P_PASSIVE_TARGET_MODE; //Toggle LED's if(BOARD_HAS_TRICOLOR_LED) { TURN_OFF_LED_TRICOLOR_GREEN TURN_OFF_LED_TRICOLOR_RED; TURN_ON_LED_TRICOLOR_BLUE } } else if(eCurrentTRF79x0Mode == P2P_PASSIVE_TARGET_MODE) { eCurrentTRF79x0Mode = P2P_INITATIOR_MODE; // // Toggle LED's. // if(BOARD_HAS_TRICOLOR_LED) { TURN_OFF_LED_TRICOLOR_BLUE TURN_ON_LED_TRICOLOR_RED TURN_ON_LED_TRICOLOR_GREEN } }
int ModeHandler(int mode, char *textIn, int argc, char **argv) { LcdSpi *lcd; Spi *spiBus0; ScreenData *screenBg; int result = 0; Fonts font; iconv_t ic; size_t res; char text[MAX_ISO8859_LEN] = ""; memset(&font, 0, sizeof(Fonts)); spiBus0 = SpiCreate(0); if (spiBus0 == NULL) { printf("SPI-Error\n"); exit(EXITCODE_ERROR); } lcd = LcdOpen(spiBus0); if (!lcd) { printf("LCD-Error\n"); exit(EXITCODE_ERROR); } if (gConfig.mIsInit == 1) { LcdInit(lcd); } else if (gConfig.mIsInit == 2) { LcdUninit(lcd); exit(EXITCODE_OK); } if (gConfig.mIsBgLight) { LcdSetBgLight(lcd, gConfig.mBgLight & 1, gConfig.mBgLight & 2, gConfig.mBgLight & 4); } screenBg = ScreenInit(LCD_X, LCD_Y); if (!screenBg) { printf("Screen-Error\n"); exit(EXITCODE_ERROR); } ScreenClear(screenBg); if (gConfig.mBgFilename) { if (ScreenLoadImage(screenBg, gConfig.mBgFilename, gConfig.mBgOffX, gConfig.mBgOffY) != 0) { ScreenClear(screenBg); } } if (textIn) { int testInLen = strlen(textIn); char **inPtr = &textIn; char *outPtr = &text[0]; ic = iconv_open("ISO-8859-1", "UTF-8"); if (ic != (iconv_t)(-1)) { size_t inBytesLeft = testInLen; size_t outBytesLeft = sizeof(text) - 1; res = iconv(ic, inPtr, &inBytesLeft, &outPtr, &outBytesLeft); if ((int)res != -1 && outBytesLeft) { outPtr[0] = 0; } else { strncpy(text, textIn, sizeof(text) - 1); text[sizeof(text) - 1] = 0; } iconv_close(ic); } } //printf("Mode: %i\n", mode); switch (mode) { case OPT_YESNO: LoadFonts(&font); result = YesNo(lcd, &font, text, screenBg); break; case OPT_OK: LoadFonts(&font); result = Ok(lcd, &font, text, screenBg); break; case OPT_MENU: LoadFonts(&font); result = Menu(lcd, &font, screenBg, optind, argc, argv); break; case OPT_IPV4: LoadFonts(&font); result = Ipv4(lcd, &font, text, screenBg, optind, argc, argv); break; case OPT_SUBNETMASK: LoadFonts(&font); result = Subnetmask(lcd, &font, text, screenBg, optind, argc, argv); break; case OPT_INFO: LoadFonts(&font); result = Info(lcd, &font, text, screenBg); break; case OPT_BUTTONWAIT: result = ButtonWait(); break; case OPT_INTINPUT: LoadFonts(&font); result = IntInput(lcd, &font, text, screenBg, optind, argc, argv); break; case OPT_PROGRESS: LoadFonts(&font); result = Progress(lcd, &font, text, screenBg, optind, argc, argv); break; case OPT_PERCENT: LoadFonts(&font); result = Percent(lcd, &font, text, screenBg, optind, argc, argv); break; default: break; } if (font.mSystem) { //FontDestroy(font.mSystem); } if (font.mInternal) { //FontDestroy(font.mInternal); } if (gConfig.mIsClear) { LcdCls(lcd); } ScreenDestroy(screenBg); LcdCleanup(lcd); SpiDestroy(spiBus0); return result; }
int ButtonGetCursor(LcdSpi *lcd, ScreenData *screen, CursorData cur) { int ret; int fd1; int fd2; int fd3; uint8_t val1; uint8_t val2; uint8_t val3; uint8_t val1_old = 0; uint8_t val2_old = 0; uint8_t val3_old = 0; int result = 0; int counter = COUNTER_MAX; ScreenData *screenOut; long int start; long int end; ret = 0; ret += GpioFdOpen(PIN_KEY_1, &fd1); ret += GpioFdOpen(PIN_KEY_2, &fd2); ret += GpioFdOpen(PIN_KEY_3, &fd3); if (ret != 3) { return -1; } if (!screen) { return 0; } screenOut = ScreenInit(screen->mX, screen->mY); ScreenCopy(screenOut, screen); start = GetTime(); while (!gEnde) { if (gConfig.mTimeout) { end = GetTime(); if (end - start >= gConfig.mTimeout) { result = ASCII_CAN; break; } } counter++; if (counter > COUNTER_MAX) { ScreenBlink(screenOut, cur); LcdWriteImageScreen(lcd, screenOut); counter = 0; } GpioGetValue(PIN_KEY_1, &val1); GpioGetValue(PIN_KEY_2, &val2); GpioGetValue(PIN_KEY_3, &val3); if (val1 != val1_old && val1 == 0) { usleep(DEBOUNCE * 1000); result = '1'; break; } if (val2 != val2_old && val2 == 0) { usleep(DEBOUNCE * 1000); result = '2'; break; } if (val3 != val3_old && val3 == 0) { usleep(DEBOUNCE * 1000); result = '3'; break; } val1_old = val1; val2_old = val2; val3_old = val3; usleep(50 * 1000); } ScreenDestroy(screenOut); return result; }
/************************************************* Function: logic_init Description: 逻辑初始化 Input: 无 Output: 无 Return: 无 *************************************************/ void logic_init(void) { PFULL_DEVICE_NO pDevNo = NULL; PNET_PARAM pNetParam = NULL; init_auTimer(); // 初始化定时器 init_timer(); storage_init(); // 初始化存储模块 init_list_address(); // 初始化监视列表 ScreenInit(); NetworkInit(); #ifdef _JD_MODE_ jd_logic_init(); // 如有家电模块可以不启动看门狗,家电轮巡命令可以喂狗 //#else hw_start_com_dog(); // 启动串口看门狗 #endif #ifdef _DOOR_PHONE_ init_ioctrl_callback(analog_callin_io); hw_switch_digit(); // 切换到数字通路 #endif init_keypad_probe(); // 按键侦测 alarm_logic_init(); media_init(); sys_init_hint_state(); alarm_init_gui_callback((ALARMGUI_CALLBACK)af_callback_gui, (SHOW_SYSEVENHIT)show_sys_event_hint); inter_call_ini(callrequest_state_callbak, callout_state_callbak, callin_state_callbak); monitor_ini(monitor_list_state_callbak, monitor_state_callbak); rtsp_ini(rtsp_list_state_callbak, rtsp_state_callbak); other_func_callbak_ini(); net_set_recivedata_func(SSC_INFO, msg_distribute, msg_responsion); net_set_recivedata_func(SSC_ALARM, alarm_distribute, alarm_responsion); net_set_recivedata_func(SSC_INTERPHONE, inter_distribute, inter_responsion); net_set_recivedata_func(SSC_PUBLIC, public_distribute, public_responsion); net_set_recivedata_func(SSC_VIDEOMONITORING, rtsp_distribute, rtsp_responsion); net_set_recivedata_func(SSC_IPDOORPHONE, netdoor_distribute, netdoor_responsion); #ifdef _JD_MODE_ net_set_recivedata_func(SSC_EHOME, jd_net_distribute, jd_net_responsion); #endif pDevNo = storage_get_devparam(); pNetParam = storage_get_netparam(); net_start_comm(pDevNo, pNetParam); net_send_cmd_packet(NULL, 0, INADDR_BROADCAST, NETCMD_UDP_PORT); init_reboot_timer(); // 定时重启设置 #ifdef _USE_NEW_CENTER_ logic_reg_center_ini(); // 新上位机注册保持 #endif #ifdef _NEW_SELF_IPC_ init_ipc_state(); // add by chenbh 2016-03-09 初始化家居监视列表在线状态值 #endif #ifdef _IP_MODULE_ init_ipmodule(); // IP模块绑定 保持 #endif #ifdef _RTSP_REG_KEEP_ init_rtsp_timer(); // 室内主机需要向流媒体服务器保持 #endif #ifdef _YUYUE_MODE_ init_yuyue_timer(); // 预约模块定时器 #endif // 请求时间同步 uint32 center = storage_get_center_ip(); set_nethead(G_CENTER_DEVNO, PRIRY_DEFAULT); net_direct_send(CMD_REQ_SYN_TIME, NULL, 0, center, NETCMD_UDP_PORT); // 测试校验数据是否正确 check_sysconfig_ifcorrect(); dprintf("devno: %s \n", pDevNo->DeviceNoStr); }
int main (void){ int Key, Remain; clock_t CurTime, OldTime; ScreenInit(); Init(); // 초기화 while( 1 ) //무한반복 { if(_kbhit()) { Key = _getch(); if(Key == 'q') break; switch(Key) { case LEFT : if(Player.MoveX > 0){ Player.MoveX--; Remain = Length - (Player.CenterX); // 남은길이 = 전체 길이 - (중심좌표 + 1) if(Player.MoveX + Remain > 79 || Player.MoveX - Player.CenterX - 1 < 0) Player.MoveX--; Player.X = Player.MoveX - Player.CenterX; } break; case RIGHT : if(Player.MoveX + 1< 79){ Player.MoveX++; Remain = Length - (Player.CenterX); if(Player.MoveX + Remain >79 || Player.MoveX - Player.CenterX < 0) Player.MoveX++; Player.X = Player.MoveX - Player.CenterX; } break; case SPACE : if(Ball.ReadyB) { Ball.bMoveX = Player.MoveX; Ball.bMoveY = Player.MoveY - 1; Ball.OldTime = clock(); Ball.ReadyB = 0; } break; } } Update();//데이터 갱신 Render(); //화면 출력 OldTime = clock(); while (1) { CurTime = clock(); if (CurTime - OldTime > 20) { OldTime = CurTime; break; } }//대기시간 } Release(); ScreenRelease(); return 0; }