int main(void)
{
#ifdef chat
    InitScreen();
    InitSystem();
    ClientConnectChat(1);
    MessageType();
    ClientConnectChat(0);

    DeleteScreen();
    EndClient();

#endif
#ifdef server

    ProcInit();
    printf("server end \n");

#endif
#ifdef test

    InitSystem();

#endif
    return 0;
}
Esempio n. 2
0
File: olc.c Progetto: picpen/balrog
void set_editor( DESCRIPTOR_DATA *d, int editor, void * param )
{
	d->editor = editor;
	d->pEdit = param;
	if (d->pagina < 1)
		d->pagina = 1;
	InitScreen(d);
}
Esempio n. 3
0
int main( int   argc,
         char *argv[] )
{
	gtk_init (&argc, &argv);
	InitScreen();
	gtk_main ();

	return 0;
}
Esempio n. 4
0
int main(void)
{
	DDRA = 0xFF;
	InitScreen();
    while(1)
    {
        //TODO:: Please write your application code
    }
}
Esempio n. 5
0
File: main.cpp Progetto: pmer/xombie
void InitEverything()
{
	new ImgBase();
	randInit();
	fontInit();

	screen = InitScreen();

	SDL_WM_SetCaption("Xombie", "Xombie");
}
Esempio n. 6
0
File: flight.c Progetto: tachyo/SNP
/**
 * Initialize and shutdown ncurses and threads, mutexes, buffer ..
 * @param argc
 * @param argv
 * @return
 */
int main(int argc, char* argv[])
{
  unsigned rows, cols;
  int err = 0;
  FILE* track;

  // set terminal to a mode we can use for drawing using ncurses.
  initscr();
  raw();
  noecho();
  getmaxyx(stdscr, rows, cols);		// macro to get window size

  if (cols < SCREEN_WIDTH)
  {
    endwin();
    printf("Window is %d x %d\n", cols, rows);
    printf("It must be at least 49 chars wide!\n");
    return 2;
  }

  track = fopen(argc == 2 ? argv[1] : "track1.txt", "r");
  if (track == NULL)
  {
    endwin();
    printf("Error opening track file!\n");
    return 4;
  }

  screen = (char*) malloc(SCREEN_HEIGHT * SCREEN_WIDTH);

  if (screen == NULL)
  {
    endwin();
    printf("OOM!\n");
    return 3;
  }

  // TODO: Start InputThread as a thread, don't forget cleanup
  pthread_mutex_init(&input.lock, NULL);
  
  pthread_t controle;
  pthread_create(&controle, NULL, InputThread, NULL);

  err = InitScreen(track);
  if (!err)
    err = Gameplay(track);

  fclose(track);
  endwin();
  free(screen);
  pthread_mutex_destroy(&input.lock);
  if(pthread_join(controle, NULL)){ /*No err handling cuz i'm lazy*/}
  return err;
}
Esempio n. 7
0
void ToggleFullscreen()
{
	#if defined(_GP2X) || defined(_IPHONE)
		fullscreen=true;
		return;
	#else
	fullscreen = !fullscreen;
	InitScreen();
	StateMakerBase::current->ScreenModeChanged();
	#endif
}
Esempio n. 8
0
void
main()
{
  int i, j;
  int nsubpixels = 1 << (HIBITS+LOBITS);
  fixpoint zero, maxpix;

  zero = 0;
  maxpix = ((NPIXELS-1) << LOBITS) | LOMASK;

  InitScreen();

  if (verbose) {
	 printf("zero "); fp_print(zero); printf(", max "); fp_print(maxpix);
	 printf("\n");
  }

  for (i=0; i != maxpix + 1; i++) {
	 for (j=0; j != maxpix + 1; j++) {

		if (verbose) {
		  printf("\n\n************** New Iteration ************\n\n");
		  printf("%3d, %3d --> ", i, j);
		  fp_print(i); printf(", "); fp_print(j); printf("\n");
		}

		clear_buffer();
		clear_view_surface(fildes); 

		fill_color(fildes, 0.5, 0.5, 0.5);
		subpixel_triangle(zero, zero,  zero,  maxpix, i, j);

		fill_color(fildes, 0.0, 1.0, 0.0);
		subpixel_triangle(zero, zero,  maxpix,  zero, i, j);

		fill_color(fildes, 0.0, 0.0, 1.0);
		subpixel_triangle(zero,  maxpix,  maxpix,   maxpix, i, j);

		fill_color(fildes, 1.0, 0.0, 0.0);
		subpixel_triangle( maxpix, zero,  maxpix,   maxpix, i, j);

		buffer_check();
		make_picture_current(fildes);

		if (verbose) {
		  printf("  hit <return> for next iteration\n");
		  getchar();
		}

	 }
  }
}
Esempio n. 9
0
Boolean CGameForm::OnOpen(EventPtr pEvent, Boolean& bHandled) {

	FrmDrawForm(FrmGetActiveForm());
	InitScreen();
	DrawLead();

	EventType event;
	event.eType = nilEvent;
	EvtAddEventToQueue (&event);

	bHandled = false;
	return true;
}
Esempio n. 10
0
void Init () 
{
    shader = ShaderClass::GetShader(0);
    shader->shader_program = InitShader("Res\\Shader\\vPhone.glsl", "Res\\Shader\\fPhone.glsl");
    GLuint program = shader->shader_program; 
    glUseProgram(program);
    shader->vPosition = glGetAttribLocation(program, "vPosition");
    shader->vNormal = glGetAttribLocation(program, "vNormal");
    shader->AmbientProduct = glGetUniformLocation(program, "AmbientProduct");
    shader->DiffuseProduct = glGetUniformLocation(program, "DiffuseProduct");
    shader->SpecularProduct = glGetUniformLocation(program, "SpecularProduct");
    shader->ModelView = glGetUniformLocation(program, "ModelView");
    shader->Projection = glGetUniformLocation(program, "Projection");
    shader->LightPosition = glGetUniformLocation(program, "LightPosition");
    shader->Shininess = glGetUniformLocation(program, "Shininess");
    shader->Emission = glGetUniformLocation(program, "Emission");
    shader->SpotDirection = glGetUniformLocation(program, "SpotDirection");
    shader->SpotCutOff = glGetUniformLocation(program, "SpotCutOff");
    shader->SpotExponent = glGetUniformLocation(program, "SpotExponent");
    shader->LightOn = glGetUniformLocation(program, "LightOn");
    shader->vTexCoord = glGetAttribLocation(program, "vTexCoord");
    shader->tex = glGetUniformLocation(program, "tex");
    shader->OnlyTex = glGetUniformLocation(program,"OnlyTex");          
    shader->pColor = glGetAttribLocation(program,"color");			    // 颜色索引
    shader->OnlyColor = glGetUniformLocation(program,"onlyColor");		// 由顶点颜色决定平面颜色

    glAlphaFunc(GL_GREATER, 0.1f);
    glEnable(GL_ALPHA_TEST);

    glGenTextures(1, &tex_screen);
    glBindTexture(GL_TEXTURE_2D, tex_screen);
    LoadTexture("Res\\Tex\\longgong.png");
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    InitScreen();

    level_state = LEVEL_STATE_INDUCING;

    glClearColor(0.6, 0.4, 0.7, 1.0);

    // 开启深度检测
    glEnable(GL_DEPTH_TEST);
    //开启混合
    glEnable(GL_BLEND);
    //设置混合模式
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    //质量最佳
    glPolygonMode(GL_FRONT, GL_NICEST);
}
Esempio n. 11
0
void Engine::SetFullscreen(bool b)
{
    if(b == IsFullscreen())
        return; // no change required

    uint32 flags = _screen->flags | _screenFlags;

    // toggle between fullscreen, preserving other flags
    if(b)
        flags |= SDL_FULLSCREEN; // add fullscreen flag
    else
        flags &= ~SDL_FULLSCREEN; // remove fullscreen flag

    InitScreen(GetResX(), GetResY(), GetBPP(), flags);
}
Esempio n. 12
0
void Engine::SetResizable(bool b)
{
    if(b == IsResizable())
        return; // no change required

    uint32 flags = _screen->flags | _screenFlags;

    // toggle between fullscreen, preserving other flags
    if(b)
        flags |= SDL_RESIZABLE; // add resizable flag
    else
        flags &= ~SDL_RESIZABLE; // remove resizable flag

    InitScreen(GetResX(), GetResY(), GetBPP(), flags);
}
Esempio n. 13
0
bool VNCStartServer(HVNC hVNC,HVNC_CONNECTION_INFO *lpConnInfo)
{
    bool bRet=false;
    if (bHVNCInit)
    {
        HVNC_HANDLE *lpHandle=VNCGetHandleInformation(hVNC);
        if ((lpHandle) && (!lpHandle->lpServer->bActive))
        {
            memcpy(&lpHandle->ConnInfo,lpConnInfo,sizeof(lpHandle->ConnInfo));
            PHVNC lpServer=lpHandle->lpServer;
            lpServer->bStopped=false;
            if (!(lpServer->DeskInfo.dwFlags & HVNC_SCREEN_SIZE_DETERMINED))
                GetScreenInfo(lpServer);

            if (!(lpServer->DeskInfo.dwFlags & HVNC_NO_INJECTS))
            {
                lpServer->hSharedMemMapping=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,lpServer->DIBInfo.dwScreenBufferSize,lpServer->Names.szSharedMemMappingName);
                lpServer->lpSharedMemMapping=(byte *)MapViewOfFile(lpServer->hSharedMemMapping,FILE_MAP_ALL_ACCESS,0,0,0);
            }
            InitScreen(lpServer,&lpServer->DIBInfo.lpOldBkgBits);
            ResetEvent(lpServer->EventsInfo.hVNCKillEvent);
            ResetEvent(lpServer->EventsInfo.hSendThreadMessageEvent);
            g_leave(hInputMutex);
            g_leave(hSharedMemMutex);
            g_leave(hPaintMutex);
            g_leave(hSendThreadMessageMutex);
            lpServer->bActive=true;
            lpHandle->hEvent=CreateEvent(NULL,true,false,NULL);
            SysCreateThread(lpServer,(LPTHREAD_START_ROUTINE)VNCServerThread,(LPDWORD)hVNC,true);
            WaitForSingleObject(lpHandle->hEvent,INFINITE);
            SysCloseHandle(lpHandle->hEvent);
            if (lpServer->bActive)
            {
                SysCreateThread(lpServer,(LPTHREAD_START_ROUTINE)ThreadsWatchThread,(LPDWORD)lpServer,true);
                bRet=true;
                if ((!lpServer->DeskInfo.bInputDesktop) && (!lpServer->DeskInfo.bWebCam))
                    SysCreateThread(lpServer,(LPTHREAD_START_ROUTINE)WndStealerThread,lpServer,true);
            }
            lpHandle->hEvent=NULL;
        }
    }
    return bRet;
}
Esempio n. 14
0
int main( void )
/*============*/
{
    int     i;

    if( !InitScreen() ) {
        puts( "No graphics adapter present" );
        return( 1 );
    }
    Do_Demo1();
    Press_any_key();

    for( i = 0; modes[i]; ++i ) {
        Do_Demo2( modes[i] );
    }
    _setvideomode( _DEFAULTMODE );      /* reset the screen */

    return( 0 );
}
Esempio n. 15
0
ExtFunc void InitBoard(int scr)
{
	int s,w,h;

	for(s = 0 ; s < MAX_SCREENS ; s++)
		for(h = 0 ; h < MAX_BOARD_HEIGHT ; h++)
			for(w = 0 ; w < MAX_BOARD_WIDTH ; w++) {
				board[s][h][w] = 0;
				oldBoard[s][h][w] = 0;
				changed[s][h] = 0;
				falling[s][w] = 0;
				oldFalling[s][w] = 0;
			}

	boardHeight[scr] = MAX_BOARD_HEIGHT;
	boardVisible[scr] = 20;
	boardWidth[scr] = 10;
	InitScreen(scr);
}
Esempio n. 16
0
void DUIInit( void )
{
    InitScreen();
    CmdHistory = WndInitHistory();
    SrchHistory = WndInitHistory();
    InitToolBar();
    InitMemWindow();
    InitAboutMessage();
    InitIOWindow();
    InitMenus();
    WndInit( LIT_DUI( The_WATCOM_Debugger ) );
    _SwitchOff( SW_ERROR_STARTUP );
#if defined(__GUI__)
    TellWinHandle();
#endif
    if( WndMain != NULL ) WndSetIcon( WndMain, &MainIcon );
    StartTimer();
    InitHelp();
    InitGadget();
    InitPaint();
    InitBrowse();
    InitFont();
}
Esempio n. 17
0
void Simulator (Vehicle *vehicle, char *type, int distance)
{
    srand (time (NULL));

    int clock = 0, obstacle = 0, at_destination = 0;

    InitScreen (distance, type);

    attrset (A_BOLD);

    while (! at_destination && distance > 0)
    {
        mvaddstr (17, 19, "Driving...                              ");
        Moving (vehicle, clock++, obstacle, distance, 0, "[]O>");
        at_destination = vehicle->Drive ();

        if ((rand () % 10) == 0 && ! at_destination)
        {
            Crashing (vehicle, clock++, obstacle++, distance, 1);
            mvaddstr (17, 19, "Backing up...                           ");
            vehicle->Reverse ();
            Moving (vehicle, clock++, obstacle, distance,  0, "<O[]");
            Moving (vehicle, clock++, obstacle, distance, -1, "<O[]");
            mvaddstr (17, 19, "Passing...                              ");
            Moving (vehicle, clock++, obstacle, distance, -1, "[]O>");
            vehicle->Reverse ();
            at_destination = vehicle->Pass ();
        }
    }

    mvaddstr (17, 19, "Turning off...                          ");
    Moving (vehicle, clock++, obstacle, distance, 0, "[]O>");

    attrset (A_NORMAL);
    refresh ();
}
Esempio n. 18
0
void init_screen()
{
    hScreen = GetStdHandle(STD_OUTPUT_HANDLE);
	InitScreen(hScreen);
}
Esempio n. 19
0
int main(int argc, char * argv[])
{
	atexit(Terminate);
#ifdef _IPHONE
	sprintf( base_path, "%s", argv[0] );
#else
	strcpy( base_path, argv[0] );
	base_path[strlen(base_path)-9] = '\0';
#endif
//	printf("SDL_Init\n");
	

/*	// Experimental - create a splash screen window whilst loading
	SDL_Init(SDL_INIT_VIDEO);
	screen = SDL_SetVideoMode( 200,200,0,SDL_NOFRAME );
	SDL_Rect r = {0,0,200,200};
	SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 0, 50));
	SDL_Flip(screen);
*/

	SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE);
#ifdef _IPHONE
	SDL_ShowCursor(0);
#endif
	
#ifdef _GP2X
	joystick=SDL_JoystickOpen(0);
#endif
	SDL_Surface* icon = SDL_LoadBMP("graphics/icon.bmp");
	if (icon)
	{
		static unsigned int mask[32] = {
			0x00001fc0,
			0x00003fe0,
			0x00007ff0,
			0x0f007df8,
			0x0000f0f8,
			0x0000f07c,
			0x0005f87c,
			0x0fbfff3c,

			0x1ffffffe,
			0x3ffffffe,
			0x3ffffffe,
			0x7ffffffe,
			0x7ffffffe,
			0x7ffffffe,
			0x7ffffffe,
			0xefffffff,

			0x1fffffff,
			0x3fffffff,
			0x3fffffff,
			0x3fffffff,
			0x3fffffff,
			0x3fffffff,
			0x3fffffff,
			0x3ffffffe,

			0x3ffffff8,
			0x3ffffff0,
			0x3ffffff0,
			0x3ffffff0,
			0x3fffffe0,
			0x3fffffe0,
			0x1ffffff0,
			0x1ffffff1,
		};
		for (int i=0; i<32; i++)
			mask[i] = mask[i]>>24 | (mask[i]>>8)&0xff00 | (mask[i]<<8)&0xff0000 | (mask[i]<<24)&0xff000000;
		SDL_WM_SetIcon(icon, (unsigned char*) mask);
		SDL_FreeSurface(icon);
	}

	InitScreen();

	SDL_WarpMouse(SCREEN_W/2, SCREEN_H/2);

#ifdef WIN32
	HWND hwnd = 0;
#endif
#ifdef USE_BBTABLET
	bbTabletDevice &td = bbTabletDevice::getInstance( );
	SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
#endif

//	printf("Main loop...\n");
	
	StateMakerBase::GetNew();
	int time = SDL_GetTicks();

	while(!quitting)
	{
		SDL_Event e;
#ifdef _IPHONE
		SDL_PumpEvents();
#endif
		while(!SDL_PollEvent(&e) && !quitting)
		{
			int x = SDL_GetTicks() - time;
			time += x;
			if (x<0) x = 0, time = SDL_GetTicks();
			if (x>500) x = 500;

			// experimental...
			if (!noMouse)
				StateMakerBase::current->Mouse(mousex, mousey, 0, 0, 0, 0, mouse_buttons);

			StateMakerBase::current->Update(x / 1000.0);
			StateMakerBase::current->Render();

			#ifdef USE_OPENGL
				SDL_GL_SwapBuffers();
			#else
				if (screen && realScreen!=screen)
				{
					SDL_Rect r = {0,0,SCREEN_W,SCREEN_H};
					SDL_BlitSurface(screen, &r, realScreen, &r);
				}
				SDL_Flip(realScreen);
			#endif

//#ifdef WIN32
//				Sleep(1);
//#endif
			SDL_Delay(10);

#ifdef USE_BBTABLET
			// Tablet ////////////////////////
			bbTabletEvent evt;
			while(hwnd!=NULL && td.getNextEvent(evt))
			{
				stylusok = 1;
				RECT r;
				if (tablet_system)
				{
					GetWindowRect(hwnd, &r);
					stylusx = evt.x * GetSystemMetrics(SM_CXSCREEN);
					stylusy = (1.0 - evt.y) * GetSystemMetrics(SM_CYSCREEN);
					stylusx -= (r.left + GetSystemMetrics(SM_CXFIXEDFRAME));
					stylusy -= (r.top + GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION));;
				}
				else
				{
					GetClientRect(hwnd, &r);
					stylusx = evt.x * r.right;
					stylusy = (1.0 - evt.y) * r.bottom;
				}
				styluspressure = (evt.buttons & 1) ? evt.pressure : 0;
 
				/*
				printf("id=%d csrtype=%d b=%x (%0.3f, %0.3f, %0.3f) p=%0.3f tp=%0.3f\n", 
					   evt.id,
					   evt.type,
					   evt.buttons,
					   evt.x,
					   evt.y,
					   evt.z,
					   evt.pressure,
					   evt.tpressure
					   );
				*/
			}

#endif
		}

		#if defined(_GP2X) || defined(_IPHONE) 
		int nkey=0;
		int mod=0;
		#endif
		
		switch (e.type)
		{
/*			case SDL_VIDEOEXPOSE:
				w.Render();
				SDL_GL_SwapBuffers();
				break;*/
#ifdef WIN32
			case SDL_SYSWMEVENT:
			{
				SDL_SysWMmsg* m = e.syswm.msg;
				hwnd = m->hwnd;
				static bool init=false;
				if (!init)
				{
					init = true;
					DragAcceptFiles(hwnd, TRUE);
					#ifdef USE_BBTABLET
						td.initTablet(hwnd, tablet_system ? bbTabletDevice::SYSTEM_POINTER : bbTabletDevice::SEPARATE_POINTER );
						if (!td.isValid())
							 printf("No tablet/driver found\n");
					#endif
  				}
				if (m->msg == WM_DROPFILES)
				{
					HDROP h = (HDROP)m->wParam;
					
					char name[512];
					if (DragQueryFile(h, 0xffffffff, 0, 0) == 1)
					{
						DragQueryFile(h, 0, name, sizeof(name)/sizeof(name[0]));

						StateMakerBase::current->FileDrop(name);
					}

					DragFinish(h);
				}

				break;
			}
#endif

			case SDL_ACTIVEEVENT:
			{
				static int focus = 0;
				int gain = e.active.gain ? e.active.state : 0;
				int loss = e.active.gain ? 0 : e.active.state;
				focus = (focus | gain) & ~loss;
				if (gain & SDL_APPACTIVE)
					StateMakerBase::current->ScreenModeChanged();
				if (loss & SDL_APPMOUSEFOCUS)
					noMouse = 1;
				else if (gain & SDL_APPMOUSEFOCUS)
					noMouse = 0;
				break;
			}

			case SDL_MOUSEMOTION:
				noMouse = false;
				StateMakerBase::current->Mouse(e.motion.x, e.motion.y, e.motion.x-mousex, e.motion.y-mousey, 0, 0, mouse_buttons);
				mousex = e.motion.x; mousey = e.motion.y;
				break;
			case SDL_MOUSEBUTTONUP:
				noMouse = false;
				mouse_buttons &= ~(1<<(e.button.button-1));
				StateMakerBase::current->Mouse(e.button.x, e.button.y, e.button.x-mousex, e.button.y-mousey, 
										0, 1<<(e.button.button-1), mouse_buttons);
				mousex = e.button.x; mousey = e.button.y ;
				break;
			case SDL_MOUSEBUTTONDOWN:
				noMouse = false;
				mouse_buttons |= 1<<(e.button.button-1);
				StateMakerBase::current->Mouse(e.button.x, e.button.y, e.button.x-mousex, e.button.y-mousey, 
										1<<(e.button.button-1), 0, mouse_buttons);
				mousex = e.button.x; mousey = e.button.y ;
				break;
#ifdef _IPHONE
			case SDL_KEYDOWN:
				if(e.key.keysym.sym == SDLK_KP4)		nkey = SDLK_z;
				else if(e.key.keysym.sym == SDLK_KP6)	nkey = SDLK_ESCAPE;
				StateMakerBase::current->KeyPressed(nkey, mod);
				break;				

			case SDL_KEYUP:
				if(e.key.keysym.sym == SDLK_KP4)		nkey = SDLK_z;
				else if(e.key.keysym.sym == SDLK_KP6)	nkey = SDLK_ESCAPE;
				StateMakerBase::current->KeyReleased(nkey);
				break;				
#else
			case SDL_KEYUP:
				StateMakerBase::current->KeyReleased(e.key.keysym.sym);
				break;
#endif
			#ifdef _GP2X
			case SDL_JOYBUTTONUP:
				if(e.jbutton.button==VK_UP) nkey=SDLK_UP;
				if(e.jbutton.button==VK_DOWN) nkey=SDLK_DOWN;
				if(e.jbutton.button==VK_LEFT) nkey=SDLK_LEFT;
				if(e.jbutton.button==VK_RIGHT) nkey=SDLK_RIGHT;
				if(e.jbutton.button==VK_START) nkey=SDLK_ESCAPE;
				if(e.jbutton.button==VK_FX) nkey=SDLK_RETURN;
				if(e.jbutton.button==VK_UP_LEFT) nkey=SDLK_q;
				if(e.jbutton.button==VK_UP_RIGHT) nkey=SDLK_e;
				if(e.jbutton.button==VK_DOWN_LEFT) nkey=SDLK_a;
				if(e.jbutton.button==VK_DOWN_RIGHT) nkey=SDLK_d;
				if(e.jbutton.button==VK_FY) nkey=SDLK_z;
				StateMakerBase::current->KeyReleased(nkey);
				break;
			case SDL_JOYBUTTONDOWN:
				if(e.jbutton.button==VK_UP) nkey=SDLK_UP;
				if(e.jbutton.button==VK_DOWN) nkey=SDLK_DOWN;
				if(e.jbutton.button==VK_LEFT) nkey=SDLK_LEFT;
				if(e.jbutton.button==VK_RIGHT) nkey=SDLK_RIGHT;
				if(e.jbutton.button==VK_START) nkey=SDLK_ESCAPE;
				if(e.jbutton.button==VK_FX) nkey=SDLK_RETURN;
				if(e.jbutton.button==VK_UP_LEFT) nkey=SDLK_q;
				if(e.jbutton.button==VK_UP_RIGHT) nkey=SDLK_e;
				if(e.jbutton.button==VK_DOWN_LEFT) nkey=SDLK_a;
				if(e.jbutton.button==VK_DOWN_RIGHT) nkey=SDLK_d;
				if(e.jbutton.button==VK_FY) nkey=SDLK_z;
				StateMakerBase::current->KeyPressed(nkey,mod);
				break;
			#endif
#ifndef _IPHONE
			case SDL_KEYDOWN:
			{
				SDL_KeyboardEvent & k = e.key;

				if (k.keysym.sym==SDLK_F4 && (k.keysym.mod & KMOD_ALT))
				{
					quitting = 1;
				}
				else if (k.keysym.sym==SDLK_F12)	
				{
					// Toggle system pointer controlled by tablet or not
					#ifdef USE_BBTABLET
						if (td.isValid())
						{
							tablet_system = !tablet_system;
							td.setPointerMode(tablet_system ? bbTabletDevice::SYSTEM_POINTER : bbTabletDevice::SEPARATE_POINTER);
						}
					#endif
				}
				else if (k.keysym.sym==SDLK_RETURN && (k.keysym.mod & KMOD_ALT) && !(k.keysym.mod & KMOD_CTRL))
				{
					ToggleFullscreen();
				}
				else if (StateMakerBase::current->KeyPressed(k.keysym.sym, k.keysym.mod))
				{
				}
				else if ((k.keysym.mod & (KMOD_ALT | KMOD_CTRL))==0)
				{
					StateMakerBase::GetNew(k.keysym.sym);
				}
			}
			break;
#endif
			case SDL_QUIT:
				quitting = 1;
				break;
		}
		
#ifdef _IPHONE
		if(SDL_GetExitStatus())
		{
			quitting = 1;
		}
#endif
	}

	SDL_Quit();
	return 0;
}
Esempio n. 20
0
int five_pk(int fd,int first)
{
    int cx, ch, cy,datac,fdone,x /* ,y */;
    char genbuf[100],data[90],xy_po[5],genbuf1[20] /* ,x1[1],y1[1],done[1] */;
    /*    struct user_info *opponent; */
    /*     char fname[50]; */
    int i,j /* ,k */,fway,banf,idone;


    /*
     *      Ôö¼ÓÁÄÌ칦ÄÜ. Added by satan. 99.04.02
     */

#define START    17
#define END      21
#define PROMPT   23
#undef MAX
#define MAX      (END - START)
#define BSIZE    60


    char chatbuf[80], *cbuf;
    int ptr = 0, chating = 0 /*, over = 0 */;

    setutmpmode(FIVE);       /*Óû§×´Ì¬ÉèÖÃ*/
    clear ();
    InitScreen();
    five_chat (NULL, 1);

    cbuf = chatbuf + 19;
    chatbuf[0] = '\0';
    chatbuf[79] = '\0';
    cbuf[0] = '\0';
    sprintf (chatbuf + 1, "%-16s: ", cuser.username);

    add_io(fd, 0);

begin:
    for(i=0; i<=14; i++)
        for(j=0; j<=14; j++)
            playboard[i][j]=0;


    hand=1;
    winner=0;
    quitf=0;
    px=14;
    py=7;
    fway = 1;
    banf = 1;
    idone = 0;


    sprintf(genbuf, "%s (%s)", cuser.userid, cuser.username);

    if(first)
    {
        move(1,33);
        prints("ºÚ¡ñÏÈÊÖ %s  ",genbuf);
        move(2,33);
        prints("°×¡ðºóÊÖ %s  ",save_page_requestor);
    }
    else
    {
        move(1,33);
        prints("°×¡ðºóÊÖ %s  ",genbuf);
        move(2,33);
        prints("ºÚ¡ñÏÈÊÖ %s  ",save_page_requestor);
    }


    move(15,35);
    if(first)
        outs("¡ïµÈ´ý¶Ô·½ÏÂ×Ó¡ï");
    else
        outs("¡ôÏÖÔÚ¸Ã×Ô¼ºÏ¡ô");
    move(7,14);
    outs("¡ñ");
    player=white;
    playboard[7][7]=black;
    chess[1][0]=14; /*¼Í¼ËùÏÂλַ*/
    chess[1][1]=7;
    move(4,35);
    outs("µÚ 1ÊÖ ¡ñH 8");

    if(!first)
    {   /*³¬¹Ö!*/
        move (7, 14);
        fdone=1;
    }
    else
        fdone=0;    /*¶ÔÊÖÍê³É*/

    while (1)
    {
        ch=igetkey();

        if (ch == I_OTHERDATA)
        {
            datac = recv(fd, data, sizeof(data), 0);
            if (datac <= 0)
            {
                move(17,30);
                outs(" ¶Ô·½Í¶½µÁË...@_@ ");
                break;
            }
            if (data[0] == '\0')
            {
                five_chat (data + 1, 0);
                if (chating)
                    move (PROMPT, ptr + 6);
                else
                    move (py, px);
                continue;
            }
            else if (data[0] == '\1')
            {
                bell ();
                RMSG = YEA;
                saveline (PROMPT, 0);
                sprintf (genbuf, "%s ˵: ÖØÀ´Ò»Å̺ÃÂð? (Y/N)[Y]:", save_page_requestor);
                getdata (PROMPT, 0, genbuf, genbuf1, 2, LCECHO, YEA);
                RMSG = NA;
                if (genbuf1[0] == 'n' || genbuf1[0] == 'N')
                {
                    saveline (PROMPT, 1);
                    send (fd, "\3", 1, 0);
                    continue;
                }
                else
                {
                    saveline (PROMPT, 1);
                    InitScreen ();
                    first = 0;
                    send (fd, "\2", 1, 0);
                    goto begin;
                }
            }
            else if (data[0] == '\2')
            {
                bell ();
                saveline (PROMPT, 0);
                move (PROMPT, 0);
                clrtoeol ();
                prints ("%s ½ÓÊÜÁËÄãµÄÇëÇó :-)", save_page_requestor);
                refresh ();
                sleep (1);
                saveline (PROMPT, 1);
                InitScreen ();
                first = 1;
                goto begin;
            }
            else if (data[0] == '\3')
            {
                bell ();
                saveline (PROMPT, 0);
                move (PROMPT, 0);
                clrtoeol ();
                prints ("%s ¾Ü¾øÁËÄãµÄÇëÇó :-(", save_page_requestor);
                refresh ();
                sleep (1);
                saveline (PROMPT, 1);
                if (chating)
                    move (PROMPT, ptr + 6);
                else
                    move (py, px);
                continue;
            }
            else if (data[0] == '\xff')
            {
                move (PROMPT, 0);
                quit ();
                break;
            }
            i=atoi(data);
            cx=i/1000;   /*½âÒëdata³ÉÆåÅÌ×ÊÁÏ*/
            cy=(i%1000)/10;
            fdone=i%10;
            hand+=1;

            if(hand%2==0)
                move(((hand-1)%20)/2+4,48);
            else
                move(((hand-1)%19)/2+4,35);

            prints("µÚ%2dÊÖ %s%c%2d",hand,
                   (player==black)?"¡ñ":"¡ð",abcd[cx/2],15-cy);


            move(cy,cx);
            x=cx/2;
            playboard[x][cy]=player;
            if(player==black)
            {
                outs("¡ñ");
                player=white;
            }
            else
            {
                outs("¡ð");
                player=black;
            }
            move (cy, cx);
            refresh ();
            bell ();
            move(15,35);
            outs("¡ôÏÖÔÚ¸Ã×Ô¼ºÏ¡ô");
            haha (5);

            tdeadf=tlivef=livethree=threefour=0;
            for(j=0; j<=10; j++)
                calvalue(cx/2,j,cx/2,j+1,cx/2,j+2,cx/2,j+3,cx/2,j+4);
            for(i=0; i<=10; i++) /*ºáÏò*/
                calvalue(i,cy,i+1,cy,i+2,cy,i+3,cy,i+4,cy);
            for(i=-4; i<=0; i++) /*бÓÒÏÂ*/
                calvalue(cx/2+i,cy+i,cx/2+i+1,cy+i+1,cx/2+i+2,cy+i+2,
                         cx/2+i+3,cy+i+3,cx/2+i+4,cy+i+4);
            for(i=-4; i<=0; i++) /*б×óÏÂ*/
                calvalue(cx/2-i,cy+i,cx/2-i-1,cy+i+1,cx/2-i-2,cy+i+2,cx/2-i-3,
                         cy+i+3,cx/2-i-4,cy+i+4);

            for(j=0; j<=9; j++)
                callfour(cx/2,j,cx/2,j+1,cx/2,j+2,cx/2,j+3,cx/2,j+4,cx/2,j+5);
            for(i=0; i<=9; i++) /*ËĺáÏò*/
                callfour(i,cy,i+1,cy,i+2,cy,i+3,cy,i+4,cy,i+5,cy);
            for(i=-5; i<=0; i++)
            {   /*ËÄбÓÒÏÂ*/
                callfour(cx/2+i,cy+i,cx/2+i+1,cy+i+1,cx/2+i+2,cy+i+2,
                         cx/2+i+3,cy+i+3,cx/2+i+4,cy+i+4,cx/2+i+5,cy+i+5);
                /*ËÄб×óÏÂ*/
                callfour(cx/2-i,cy+i,cx/2-i-1,cy+i+1,cx/2-i-2,cy+i+2,cx/2-i-3,
                         cy+i+3,cx/2-i-4,cy+i+4,cx/2-i-5,cy+i+5);
            }

            py = cy;
            px = cx;
            if(tlivef>=2 && winner==0)
                bandhand(4);
            if(livethree>=2 && tlivef ==0)
                bandhand(3);
            if(threefour==black)
                haha(1);
            else if(threefour==white)
                haha(1);
            if (chating)
            {
                sleep (1);
                move (PROMPT, ptr + 6);
            }
            else
                move (py, px);
            if (winner)
            {
                InitScreen ();
                goto begin;
            }
        }
        else
        {
            if (ch == Ctrl('X'))
            {
                quitf = 1;
            }
            else if (ch==Ctrl('C') || ((ch=='Q' || ch=='q') && !chating))
            {
                RMSG = YEA;
                saveline (PROMPT, 0);
                getdata(PROMPT, 0, "ÄúÈ·¶¨ÒªÀ뿪Âð? (Y/N)?[N] ", genbuf1, 2, LCECHO, YEA);
                if (genbuf1[0] == 'Y' || genbuf1[0] == 'y')
                    quitf = 1;
                else
                    quitf = 0;
                saveline (PROMPT, 1);
                RMSG = NA;
            }
            else if (ch==Ctrl('N') || ((ch=='N' || ch=='n') && !chating))
            {
                saveline (PROMPT, 0);
                RMSG = YEA;
                getdata(PROMPT,0,"ÄúÈ·¶¨ÒªÖØпªÊ¼Âð? (Y/N)?[N] ",genbuf1,2,LCECHO, YEA);
                if (genbuf1[0] == 'Y' || genbuf1[0] == 'y')
                {
                    send (fd, "\1", 1, 0);
                    move (PROMPT, 0);
                    bell ();
                    clrtoeol ();
                    move (PROMPT, 0);
                    outs ("ÒѾ­ÒѾ­ÌæÄú·¢³öÇëÇóÁË");
                    refresh ();
                    sleep (1);
                }
                RMSG = NA;
                saveline (PROMPT, 1);
                if (chating)
                    move (PROMPT, ptr + 6);
                else
                    move (py, px);
                continue;
            }
            else if (ch == '\t')
            {
                if (chating)
                {
                    chating = 0;
                    move (py, px);
                }
                else
                {
                    chating = 1;
                    move (PROMPT, 6 + ptr);
                }
                continue;
            }
            else if (ch == '\0')
                continue;
            else if (chating)
            {
                if (ch == '\n' || ch == '\r')
                {
                    if (!cbuf[0])
                        continue;
                    ptr = 0;
                    five_chat (chatbuf + 1, 0);
                    send (fd, chatbuf, strlen (chatbuf + 1) + 2, 0);
                    cbuf[0] = '\0';
                    move (PROMPT, 6);
                    clrtoeol ();
                }
                else if (ch == KEY_LEFT)
                {
                    if (ptr)
                        ptr --;
                }
                else if (ch == KEY_RIGHT)
                {
                    if (cbuf[ptr])
                        ptr ++;
                }
                else if (ch == Ctrl ('H') || ch == '\177')
                {
                    if (ptr)
                    {
                        ptr --;
                        memcpy (&cbuf[ptr], &cbuf[ptr+1], BSIZE-ptr);
                        move (PROMPT, ptr+6);
                        clrtoeol ();
                        prints ("%s",&cbuf[ptr]);
                    }
                }
                else if (ch == KEY_DEL)
                {
                    if (cbuf[ptr])
                    {
                        memcpy (&cbuf[ptr], &cbuf[ptr+1], BSIZE-ptr);
                        clrtoeol ();
                        prints ("%s",&cbuf[ptr]);
                    }
                }
                else if (ch == Ctrl ('A'))
                {
                    ptr = 0;
                }
                else if (ch == Ctrl ('E'))
                {
                    while (cbuf[++ptr])
                        ;
                }
                else if (ch == Ctrl ('K'))
                {
                    ptr = 0;
                    cbuf[ptr] = '\0';
                    move (PROMPT, ptr+6);
                    clrtoeol ();
                }
                else if (ch == Ctrl ('U'))
                {
                    memmove (cbuf, &cbuf[ptr], BSIZE - ptr + 1);
                    ptr = 0;
                    move (PROMPT, ptr+6);
                    clrtoeol ();
                    prints ("%s",cbuf);
                }
                else if (ch == Ctrl ('W'))
                {
                    if (ptr)
                    {
                        int optr;

                        optr = ptr;
                        ptr --;
                        do
                        {
                            if (cbuf[ptr] != ' ')
                                break;
                        }
                        while (-- ptr);
                        do
                        {
                            if (cbuf[ptr] == ' ')
                            {
                                if (cbuf[ptr+1] != ' ')
                                    ptr ++;
                                break;
                            }
                        }
                        while (-- ptr);
                        memcpy (&cbuf[ptr], &cbuf[optr], BSIZE-optr+1);
                        move (PROMPT, ptr+6);
                        clrtoeol ();
                        prints ("%s",&cbuf[ptr]);
                    }
                }
                else if (isprint2 (ch))
                {
                    if (ptr == BSIZE)
                        continue;
                    if (!cbuf[ptr])
                    {
                        cbuf[ptr] = ch;
                        move (PROMPT, 6 + ptr);
                        outc (ch);
                        cbuf[++ptr] = 0;
                    }
                    else
                    {
                        memmove (&cbuf[ptr+1], &cbuf[ptr], BSIZE-ptr+1);
                        cbuf[ptr] = ch;
                        move (PROMPT, 6 + ptr);
                        prints ("%s",&cbuf[ptr]);
                        ptr ++;
                    }
                }
                move (PROMPT, 6 + ptr);
                continue;
            }
        }

        if(fdone==1 && !chating && ch != I_OTHERDATA)/*»»ÎÒ*/
        {

            move(py,px);
            switch (ch)
            {

            case KEY_DOWN:
            case 'j':
            case 'J':
                py=py+1;
                if(py>14)
                    py=0;
                break;

            case KEY_UP:
            case 'k':
            case 'K':
                py=py-1;
                if(py<0)
                    py=14;
                break;

            case KEY_LEFT:
            case 'h':
            case 'H':
                px=px-1;
                if(px<0)
                    px=28;
                break;

            case KEY_RIGHT:
            case 'l':
            case 'L':
                px=px+1;
                if(px>28)
                {
                    px=0;
                    px=px-1;
                }                      /*»áÌø¸ñßÖ*/
                break;
            case ' ':
                if(banf==1)
                    break;

                if((px%2)==1)
                    px=px-1; /*½â¾önetterm²»ºÏÎÊÌâ*/
                move(py,px);
                hand+=1;
                playboard[x][py]=player;
                if(player==black)
                {
                    outs("¡ñ");
                    player=white;
                }
                else
                {
                    outs("¡ð");
                    player=black;
                }
                chess[hand][0]=px;
                chess[hand][1]=py;
                if(hand%2==0)
                    move(((hand-1)%20)/2+4,48);
                else
                    move(((hand-1)%19)/2+4,35);

                prints("µÚ%2dÊÖ %s%c%2d",hand,
                       (hand%2==1)?"¡ñ":"¡ð",abcd[px/2],15-py);
                idone=1;
                move (py, px);
                refresh ();
                break;
            default:
                break;
            }
            move(py,px);
            x=px/2;
            if(playboard[x][py]!=0)
                banf=1;
            else
                banf=0;

            if(idone==1)
            {
                xy_po[0] = px/10 + '0';
                xy_po[1] = px%10 + '0';
                xy_po[2] = py/10 + '0';
                xy_po[3] = py%10 + '0';
                fdone=0;
                xy_po[4]='1';
                if(send(fd,xy_po,sizeof(xy_po),0)==-1)
                    break;

                move(15,35);
                outs("¡ïµÈ´ý¶Ô·½ÏÂ×Ó¡ï");
                haha (5);

                tdeadf=tlivef=livethree=threefour=0;
                for(j=0; j<=10; j++)
                    calvalue(px/2,j,px/2,j+1,px/2,j+2,px/2,j+3,px/2,j+4);
                for(i=0; i<=10; i++) /*ºáÏò*/
                    calvalue(i,py,i+1,py,i+2,py,i+3,py,i+4,py);
                for(i=-4; i<=0; i++) /*бÓÒÏÂ*/
                    calvalue(px/2+i,py+i,px/2+i+1,py+i+1,px/2+i+2,py+i+2,
                             px/2+i+3,py+i+3,px/2+i+4,py+i+4);
                for(i=-4; i<=0; i++) /*б×óÏÂ*/
                    calvalue(px/2-i,py+i,px/2-i-1,py+i+1,px/2-i-2,py+i+2,px/2-i-3,
                             py+i+3,px/2-i-4,py+i+4);

                for(j=0; j<=9; j++)
                    callfour(px/2,j,px/2,j+1,px/2,j+2,px/2,j+3,px/2,j+4,px/2,j+5);
                for(i=0; i<=9; i++) /*ËĺáÏò*/
                    callfour(i,py,i+1,py,i+2,py,i+3,py,i+4,py,i+5,py);
                for(i=-5; i<=0; i++)
                {   /*ËÄбÓÒÏÂ*/
                    callfour(px/2+i,py+i,px/2+i+1,py+i+1,px/2+i+2,py+i+2,
                             px/2+i+3,py+i+3,px/2+i+4,py+i+4,px/2+i+5,py+i+5);
                    /*ËÄб×óÏÂ*/
                    callfour(px/2-i,py+i,px/2-i-1,py+i+1,px/2-i-2,py+i+2,px/2-i-3,
                             py+i+3,px/2-i-4,py+i+4,px/2-i-5,py+i+5);
                }

                if(tlivef>=2 && winner==0)
                    bandhand(4);
                if(livethree>=2 && tlivef ==0)
                    bandhand(3);
                if(threefour==black)
                    haha(1);
                else if(threefour==white)
                    haha(1);

            }
            idone=0;
        }
        if (quitf)
        {
            genbuf1[0] = '\xff';
            send (fd, genbuf1, 1, 0);
            press ();
            break;
        }
        if (winner)
        {
            InitScreen ();
            goto begin;
        }
    }

    add_io(0, 0);
    close(fd);
    return;
}