Esempio n. 1
0
File: dos_kb.c Progetto: fourks/16
void main(void)
{
	byte q;
	setkb(1);
	while(!keyp(1))
	{
		keyp(q);
	}
	setkb(0);
}
Esempio n. 2
0
static PyObject * pplay(PyObject *self, PyObject* args)
{
    const char *s;
    if(PyArg_ParseTuple(args, "s",&s))
    {
    keyp(10);
    char *ch="echo 1> /tmp/sftkoko; mplayer \"";
    while (*ch)
	keyp(*ch++);
    while (*s)
	if(*s==34)
    		{keyp(92);keyp(34);s++;}
    	else if((*s==13)||(*s==10))
		break;
	else
    		keyp(*s++);
    keyp(34);
    char *i=";rm /tmp/sftkoko";
    while (*i)
	keyp(*i++);

    keyp(10);
    return Py_BuildValue("i", 0);
    }
}
Esempio n. 3
0
File: s3dtv.c Progetto: koo5/lemon-2
void clip(int noes)
{
    char * r=rotoclipin();
    char *s=r;
    if (r)
    {
        while (*r)
        {
            if (!noes || ((*r)!=10 && (*r)!=13 )) keyp(t,*r);
            r++;
        }
        free(s);
    }
}
void ChannelServer::FindCtors (const string& type, const string& keypat, std::set<ChannelCtor*>& ctors)
{
	ctors.clear();

	CtorTable::iterator c1 = find_if(chCtors.begin(),chCtors.end(),FindType(type));

	if(c1==chCtors.end())
	{
		return;
	}

	CtorTable::iterator c2 = find_if(c1,chCtors.end(),FindType(type,true));

	// Now find those ctors that match the key pattern
	StringPattern keyp(keypat);
	for(CtorTable::iterator ci = c1; ci!=c2; ci++)
	{
		if(keyp((ci->second)->GetKey()))
		{
			ctors.insert(ci->second);
		}
	}
}
Esempio n. 5
0
int RunGLTest ()
{
	int bpp;
	int w = 500;
	int h = 500;
	int done = 0;
	int shrink=0;
	int grow=0;

	xy s	   	=		   parsemodes(w,h,"mode",1,0,0);
	if (s.x!=-1){w=s.x;h=s.y;};
	
	Uint32 video_flags=initsdl(w,h,&bpp);
    
	/* Set the window manager title bar */
	SDL_WM_SetCaption( "SDL GL test", "testgl" );
	SDL_EnableUNICODE(1);
	
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
	
	wm(w,h);
	glDepthFunc(GL_LESS);
	glEnable(GL_BLEND);
	glShadeModel(GL_SMOOTH);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);

	add_terminal();
	glLineWidth(1);
	glClearColor( 0.0, 0.0, 0.0, 1.0 );
	while( !done )
	{
		GLenum gl_error;
		char* sdl_error;
		SDL_Event event;
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				
		rote_vt_update(t);
		glPushMatrix();
		glRotatef(rot,1,0,0);
		glPushMatrix();
		    glTranslatef(-2.52,1.92,0);
		    glPushMatrix();
		    activetext=(active==2);
		    if (active==2)
			glScalef(0.003,-0.003,1);
		    else
			glScalef(0.002,-0.002,1);
		    draw_terminal(t);
		    glPopMatrix();
		    glPushMatrix();
		    activetext=(active==1);
		    if (active==1)
			glScalef(0.003,-0.003,1);
		    else
			glScalef(0.002,-0.002,1);
		    glTranslatef(0,plscroll*60,0);
		    PyRun_SimpleString("dr_aw()");
		    glPopMatrix();
		glPopMatrix();
		glPopMatrix();

		SDL_GL_SwapBuffers( );
    
		gl_error = glGetError( );

		if( gl_error != GL_NO_ERROR )
			fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );

		sdl_error = SDL_GetError( );

		if( sdl_error[0] != '\0' ) 
		{
		    fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
		    SDL_ClearError();
		}
		
		{
		}
		
		/* Check if there's a pending event. */
		while( SDL_PollEvent( &event ) )
		{
			switch( event.type )
			{
			case SDL_KEYDOWN:
				printf("%i\n",event.key.keysym.unicode);
				int key=event.key.keysym.sym;
				if ( key==SDLK_UP )
				{
					PyRun_SimpleString("pl_up()");
					active=1;
				}
				if ( key==(SDLK_DOWN) )
				{
					PyRun_SimpleString("pl_down()");
					active=1;
				}
				if ( key==(SDLK_PAGEUP) )
				{
					PyRun_SimpleString("pl_pgup()");
					active=1;
				}
				if ( key==(SDLK_PAGEDOWN) )
				{
					PyRun_SimpleString("pl_pgdown()");
					active=1;
				}
				else
				if ( (key == SDLK_SPACE) )
				    keyp(32);
				else
				if ( (key == SDLK_q) )
				    rot++;
				else
				if ( (key == SDLK_w) )
				    rot--;
				else
				if ( (key == SDLK_e) )
				    glLineWidth(3);
				else
				if ( (key == SDLK_r) )
				    glLineWidth(4);
				else
				if ( (key == SDLK_t) )
				    glLineWidth(5);
				else
				if ( (key == SDLK_y) )
				    glLineWidth(6);
				else
				if ( (key == SDLK_F1) )
					shrink=1;
				else
				if ( (key == SDLK_F2) )
					grow=1;
				else
				if ( (key == SDLK_END) )
				{
					PyRun_SimpleString("pl_end()");
					active=1;
				}
				else
				if ( (key == SDLK_HOME) )
				{
					PyRun_SimpleString("pl_home()");
					active=1;
				}
				else
				if ( (key == SDLK_q) )
				{
					PyRun_SimpleString("wanna_play()");
					wannaplay=1;
					active=2;
				}
				else
				if ( (key == SDLK_RETURN) )
				{
					keyp(10);					
					PyRun_SimpleString("wanna_play()");
					wannaplay=1;
					active=2;
				}
				else
				if ( (key == SDLK_c) )
					done=1;
				break;
	 		case SDL_QUIT:
				done = 1;
			break;
			}
		}
		if (wannaplay)
		{
		    FILE *f;
		    if (f=fopen("/tmp/sftkoko","r"))
			fclose(f);
		    else
		    {
			wannaplay=0;
			PyRun_SimpleString("pl_ay()");
		    }
		}
		if (shrink||grow)
		    resize(&w,&h,&bpp,&video_flags,&shrink,&grow);
	}
	SDL_Quit( );
	return(0);
}
Esempio n. 6
0
int RunGLTest (void)
{

#ifdef GL
	int mm=1;
#else
	int mm = 0;
#endif
	int mode=0;
	cam.x=0;
	cam.y=0;
	int bpp;
	int w = 200;
	int h = 200;
	int done = 0;
	int shrink=0;
	int grow=0;
	int gofullscreen=0;
	int mustresize = 1;
	int justresized = 0;
	xy  ss = parsemodes(w,h,"mode",1,0,0);
	printf("wtf\n");
	if (ss.x!=-1){w=ss.x;h=ss.y;};
	SDL_Surface* s;
#ifdef GL
	s=initsdl(w,h,&bpp,SDL_OPENGL

#else
	gltextsdlsurface=s=initsdl(w,h,&bpp,
#endif

	+0);printf("inito\n");
	SDL_InitSubSystem( SDL_INIT_TIMER);
	SDL_EnableUNICODE(1);
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY/2, SDL_DEFAULT_REPEAT_INTERVAL*2);
#ifdef GL
	newtermmsg=GetFileIntoCharPointer1("newtermmsg");
	printf("pretty far\n");
	wm(w,h);
	int down=0;
	glEnable(GL_BLEND);
	glShadeModel(GL_FLAT);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	glClearColor( 0.0, 0.0, 0.04, 0.0 );
	glLineWidth(lv);
#else
	gltextsdlsurface=s;
#endif
	roteface *face1;
	roteface *activeface;
	face1=add_face();
	activeface =face1 ;
	face1->next=add_face();
	printf("still?\n");
	add_terminal(face1);
	printf("2threaad\n");
	loadl2();
	struct state *nerv=0;
#ifdef nerve
	nerv=nerverot_init(w,h);
#endif

	int dirty=1;
	printf("mainloop descent commencing\n");
	while( !done )
	{	
	        lockterms(face1);


		if(dirty||faces_dirty(face1))
		{
			dirty=0;
			facesclean(face1);
#ifdef GL
			glClear(GL_COLOR_BUFFER_BIT);
#else
			SDL_FillRect	( s, NULL, 0 );

#endif

#ifndef GL

#else

				if(nerv)
				{
				    shownerv(nerv);
				    dirty=1;
				}
				glPushMatrix();
				glScalef(sx,sy,0.004);
				glTranslatef(cam.x,cam.y,0);
				

#endif
				Uint8 * k;
				int integer;

				k=SDL_GetKeyState(&integer);
				if(k[SDLK_RCTRL])
					focusline(activeface);
				int nf;
				switch(mode)
				{
				    case 0:
					showfaces(face1);
				    break;
#ifdef GL
				    case 1:
					krychlus(face1);
				    break;
#endif
				}
#ifdef GL
				glPopMatrix();
#endif


#ifndef GL
			SDL_UpdateRect(s,0,0,0,0);
#else
			SDL_GL_SwapBuffers( );
#endif
			facesclean(face1);
			
		}
#ifdef GL
		GLenum gl_error;
		gl_error = glGetError( );
		if( gl_error != GL_NO_ERROR )
		{
			if(gl_error==GL_STACK_OVERFLOW)
				printf("QUACK QUACK QUACK, OVERFLOVING STACK\n");
			else if(gl_error==GL_INVALID_OPERATION)
				printf("INVALID OPERATION, PATIENT EXPLODED\n");
			else	fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );
			
		}
#endif
		char* sdl_error;
		sdl_error = SDL_GetError( );
		if( sdl_error[0] != '\0' )
		{
		    fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
		    SDL_ClearError();
		}

		SDL_TimerID x=0;
		if(dirty)
		    x= SDL_AddTimer(55, NewTimerCallback, 0);
		                     
		unlockterms(face1);
//		printf("---------unlocked wating\n");
		SDL_Event event;
		if(SDL_WaitEvent( &event ))
		{
	    	    lockterms(face1);
//		    printf("---------locked goooin %i\n", event.type);
		    if(x)SDL_RemoveTimer(x);x=0;	    	    
		    do {
			int mod=event.key.keysym.mod;
			int key=event.key.keysym.sym;
    			Uint8 *keystate = SDL_GetKeyState(NULL);

			switch( event.type )
			{
			
#ifdef GL
				case SDL_MOUSEMOTION:
				if((SDL_BUTTON(1)|SDL_BUTTON(2))&SDL_GetMouseState(0,0))
				{
					activeface->x+=event.motion.xrel;
					activeface->y+=event.motion.yrel;
				}
				if((SDL_BUTTON(3)|SDL_BUTTON(2))&SDL_GetMouseState(0,0))
				{
					cam.x-=event.motion.xrel;
					cam.y-=event.motion.yrel;
				}
				
				break;
#endif
				case SDL_KEYUP:
				{
					if ( (key == SDLK_RCTRL) )
					{
						dirty=1;
					}
				}
				break;
				case SDL_KEYDOWN:
				

					if(mod&KMOD_RSHIFT&&(key==SDLK_PAGEUP||key==SDLK_PAGEDOWN))
					{
						if(key==SDLK_PAGEUP)
							tscroll+=9;
						if(key==SDLK_PAGEDOWN)
							tscroll-=9;
						if(tscroll<0)tscroll=0;
//						printf("scroll:%i,logl:%i, log&%i, t:%i ,b:%i\n", tscroll,activeface->t->logl, activeface->t->log,activeface->t->scrolltop,activeface->t->scrollbottom);
					}
					else
					if(key==SDLK_RCTRL||mod&KMOD_RCTRL)
					{
						dirty=1;
						switch (key)
						{
							case SDLK_TAB:
							    cycle(face1, &activeface);
							break;
							case SDLK_F2:
							    gofullscreen=1;
							break;
							case SDLK_F3:
							    rastio+=0.05;
							    mustresize=1;
							    dirty=1;
							break;
							case SDLK_F4:
							    rastio-=0.05;
							    mustresize=1;
							    dirty=1;
							break;
							case SDLK_F5:
							    sx-=0.001;
							    sy+=0.001;
							break;
							case SDLK_F6:
							    sx+=0.001;
							    sy-=0.001;
							break;

							case SDLK_F7:
							    savemode(w,h);
							break;
							case SDLK_F8:
							    loadl2();
							break;
							case SDLK_p:
							    saveScreenshot();
							break;
#ifdef GL
							case SDLK_F9:
							    lv-=1;	glLineWidth(lv);
							break;
							case SDLK_F10:
							    lv+=1;	glLineWidth(lv);
							break;
#endif
							case SDLK_F11:
							    shrink=1;
							break;
							case SDLK_F12:
							    grow=1;
							break;
							case SDLK_PAGEUP:
							     mode++;
							     if(mode>mm)mode= mm;
							break;
							case SDLK_INSERT:
							     mode--;
							     if(mode<0)mode= 0;
							break;
							case SDLK_END:
							    resizooo(activeface, 0,1,keystate);
							break;
							case SDLK_HOME:
							    resizooo(activeface, 0,-1,keystate);
							break;
							case SDLK_DELETE:
							    resizooo(activeface, -1,0,keystate);
							break;
							case SDLK_PAGEDOWN:
							    resizooo(activeface, 1,0,keystate);
							break;
#ifdef nerve
							case SDLK_F1:
								if(nerv)
								{
									nerverot_free(nerv);
							        	dirty=1;
									nerv=0;
								}
								else
								{
							        	nerv=nerverot_init(w,h);
									
									dirty=1;
								}
							break;
#endif
						}
					}
					else
					{
					    if(activeface->t==0)
					    {
						printf("debug messages r fun\n");
						add_terminal(activeface);
						activeface->next=add_face();
					    }
					    if ( (key >= SDLK_F1) && (key <= SDLK_F15) )
					    {
						char *k;
						if(asprintf(&k ,"kf%i", key-SDLK_F1+1)!=-1)
						{
						    rote_vt_terminfo(activeface->t, k);
						    free(k);
						}
					    }
					    else
					    if ( (key == SDLK_SPACE) )
						keyp(activeface,32);
					    else
					    #define magic(x) rote_vt_terminfo(activeface->t, x )
					    if ( (key == SDLK_BACKSPACE) )
						magic( "kbs");
					    else
					    if ( (key == SDLK_ESCAPE) )
						keyp(activeface,27);
					    else
					    if ( (key == SDLK_LEFT) )
						magic("kcub1");
					    else
					    if ( (key == SDLK_RIGHT) )
						magic( "kcuf1");
					    else
					    if ( (key == SDLK_UP) )
						magic( "kcuu1");
					    else
					    if ( (key == SDLK_DOWN) )
						magic( "kcud1");
					    else
					    if ( (key == SDLK_END) )
						magic( "kend");
					    else
					    if ( (key == SDLK_HOME) )
						magic("khome");
					    else
					    if ( (key == SDLK_DELETE) )
						magic( "kdch1");
					    else
					    if ( (key == SDLK_PAGEDOWN) )
						magic( "knp");
					    else
					    if ( (key == SDLK_INSERT) )
					    	magic( "kich1");
					    else
					    if ( (key == SDLK_PAGEUP) )
						magic ( "kpp" );
					    else
					    if ( (key == SDLK_RETURN) )
						keyp(activeface,10);
					    else
					    if( event.key.keysym.unicode && ( (event.key.keysym.unicode & 0xFF80) == 0 ) )
						keyp(activeface, event.key.keysym.unicode);
					}
				break;
	 			case SDL_QUIT:
					done = 1;
					break;
#ifndef GL
	 			case SDL_MOUSEBUTTONDOWN:
					rote_vt_mousedown(activeface->t,event.button.x/13, event.button.y/26);
					break;
	 			case SDL_MOUSEBUTTONUP:
					rote_vt_mouseup  (activeface->t,event.button.x/13, event.button.y/26);
					break;
	 			case SDL_MOUSEMOTION:
					rote_vt_mousemove(activeface->t,event.button.x/13, event.button.y/26);
					break;
#endif
				case SDL_VIDEORESIZE:
				    {
					w=event.resize.w;h=event.resize.h;
//					printf("videoresize %i %i\n", w,h);
					dirty=1;
					if (s=SDL_SetVideoMode( w,h, bpp, s->flags ) ) 
//						printf("hmm\n");
					wm(w,h);
				    if(!justresized)

					mustresize=1;
				        justresized=0;
				        
				    }

					break;
				case SDL_USEREVENT:
					if(event.user.code==1)
					    RemoveTerm(&activeface,&face1, event.user.data1);
					break;
			}
		    }
		    while (SDL_PollEvent(&event));
		    if (shrink||grow)
		    { 
		        resize(&w,&h,&bpp,&s->flags,&shrink,&grow);
		        wm(w,h);
		    }
		    if (mustresize)
		    {
			mustresize=0;
			justresized=1;
//			if(activeface->t->cols!=event.resize.w/13/rastio||
//			    activeface->t->rows!=event.resize.h/26/rastio)
				//rote_vt_resize(activeface->t,event.resize.h/26/rastio ,event.resize.w/13/rastio);
		    }
		    if(gofullscreen)
			if(s->flags & SDL_FULLSCREEN )
			{
    			    s=SDL_SetVideoMode( w,h, bpp, (s->flags & ~SDL_FULLSCREEN ));
			
			}
			else
    			    s=SDL_SetVideoMode( w,h, bpp, (s->flags | SDL_FULLSCREEN ));
		    gofullscreen=0;
		    unlockterms(face1);
		}

	}
	SDL_Quit( );
	return(0);
}
Esempio n. 7
0
//#define SWAP(a, b) tmp=a; a=b; b=tmp;
void main() {
	bitmap_t ptmp; // player sprite
	word q=1;
	const char *cpus;
	static int persist_aniframe = 0;    /* gonna be increased to 1 before being used, so 0 is ok for default */
	page_t screen, screen2, screen3;
	map_t map;
	map_view_t mv, mv2, mv3;
	map_view_t *bg, *spri, *mask;//, *tmp;
	byte *ptr;

	/* create the map */
	map = allocMap(MAPX,MAPY); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly
	initMap(&map);
	mv.map = &map;
	mv2.map = &map;
	mv3.map = &map;

	/* draw the tiles */
	ptr = map.data;
	/*data\\*/
	ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite
	setkb(1);
	modexEnter();
	modexPalUpdate(ptmp.palette);
	screen = modexDefaultPage();
	screen.width += (TILEWH*2);
	screen.height += (TILEWH*2)+QUADWH;
	mv.page = &screen;
	screen2 = modexNextPage(mv.page);
	mv2.page = &screen2;
	screen3 = screen2;
	mv3.page = &screen3;

	/* set up paging */
	bg = &mv;
	spri = &mv2;
	mask = &mv3;

//TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
	mapGoTo(bg, 0, 0);
	mapGoTo(spri, 0, 0);
	//mapGoTo(mask, 0, 0);

	//TODO: put player in starting position of spot
	//default player position on the viewable map
	player.tx = bg->tx + 10;
	player.ty = bg->ty + 8;
	player.x = player.tx*TILEWH;
	player.y = player.ty*TILEWH;
	player.triggerx = player.tx;
	player.triggery = player.ty+1;
	//TODO: erase player initial draw
	modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
	//temp draw trigger box
	modexClearRegion(spri->page, player.triggerx*16, player.triggery*16, 16, 16, 1);
	modexClearRegion(bg->page, player.triggerx*16, player.triggery*16, 16, 16, 1);
	modexShowPage(spri->page);
	while(!keyp(1))//!keyp(1))
	{
	//top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
	//to stop scrolling and have the player position data move to the edge of the screen with respect to the direction
	//when player.tx or player.ty == 0 or player.tx == 20 or player.ty == 15 then stop because that is edge of map and you do not want to walk of the map

	#define INC_PER_FRAME if(q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1;

	//temp testing
		/*if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10)
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				//INC_PER_FRAME;
				//animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				//animatePlayer(bg, spri, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				mapScrollRight(bg, SPEED);
				//mapScrollRight(spri, SPEED);
				//mapScrollRight(mask, SPEED);
				modexShowPage(bg->page);
			}
			player.tx++;
		}
		else if(player.tx < MAPX)
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				player.x+=SPEED;
				//animatePlayer(bg, spri, mask, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				modexShowPage(spri->page);
			}
			player.tx++;
		}
		else
		{
break;
		}*/
	if(keyp(77) && !keyp(75))
	{
		if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10 && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				//animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				mapScrollRight(bg, SPEED);
				mapScrollRight(spri, SPEED);
				//mapScrollRight(mask, SPEED);
				modexShowPage(spri->page);
			}
			player.tx++;
		}
		else if(player.tx < MAPX && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				player.x+=SPEED;
				//animatePlayer(bg, spri, mask, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				modexShowPage(spri->page);
			}
			player.tx++;
		}
		else
		{
			modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
			modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
			modexShowPage(spri->page);
		}
		player.triggerx = player.tx+1;
		player.triggery = player.ty;
	}

	if(keyp(75) && !keyp(77))
	{
		if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				//animatePlayer(bg, spri, mask, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				mapScrollLeft(bg, SPEED);
				mapScrollLeft(spri, SPEED);
				//mapScrollLeft(mask, SPEED);
				modexShowPage(spri->page);
			}
			player.tx--;
		}
		else if(player.tx > 1 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				player.x-=SPEED;
				//animatePlayer(bg, spri, mask, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				modexShowPage(spri->page);
			}
			player.tx--;
		}
		else
		{
			modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
			modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
			modexShowPage(spri->page);
		}
		player.triggerx = player.tx-1;
		player.triggery = player.ty;
	}

	if(keyp(80) && !keyp(72))
	{
		if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				//animatePlayer(bg, spri, mask, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				mapScrollDown(bg, SPEED);
				mapScrollDown(spri, SPEED);
				//mapScrollDown(mask, SPEED);
				modexShowPage(spri->page);
			}
			player.ty++;
		}
		else if(player.ty < MAPY && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				player.y+=SPEED;
				//animatePlayer(bg, spri, mask, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				modexShowPage(spri->page);
			}
			player.ty++;
		}
		else
		{
			modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
			modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
			modexShowPage(spri->page);
		}
		player.triggerx = player.tx;
		player.triggery = player.ty+1;
	}

	if(keyp(72) && !keyp(80))
	{
		if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				//animatePlayer(bg, spri, mask, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				animatePlayer(bg, spri, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp);
				mapScrollUp(bg, SPEED);
				mapScrollUp(spri, SPEED);
				//mapScrollUp(mask, SPEED);
				modexShowPage(spri->page);
			}
			player.ty--;
		}
		else if(player.ty > 1 && !(player.tx == TRIGGX &&  player.ty-1 == TRIGGY))
		{
			for(q=1; q<=(TILEWH/SPEED); q++)
			{
				INC_PER_FRAME;
				player.y-=SPEED;
				//animatePlayer(bg, spri, mask, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp);
				modexShowPage(spri->page);
				animatePlayer(bg, spri, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp);
			}
			player.ty--;
		}
		else
		{
			modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
			modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
			modexShowPage(spri->page);
		}
		player.triggerx = player.tx;
		player.triggery = player.ty-1;
	}
	//modexClearRegion(mask->page, 66, 66, 2, 40, 0);

	if((player.triggerx == TRIGGX && player.triggery == TRIGGY) && keyp(KEY_ENTER))
	{
		short i;
		for(i=600; i>=400; i--)
		{
			sound(i);
		}
		nosound();
	}
	}

	modexLeave();
	setkb(0);
	printf("Project 16 scroll.exe\n");
	printf("tx: %d\n", bg->tx);
	printf("ty: %d\n", bg->ty);
	printf("player.x: %d\n", player.x);
	printf("player.y: %d\n", player.y);
	printf("player.tx: %d\n", player.tx);
	printf("player.ty: %d\n", player.ty);
	printf("player.triggx: %d\n", player.triggerx);
	printf("player.triggy: %d\n", player.triggery);
	printf("dxThresh: %d\n", bg->dxThresh);
	printf("dyThresh: %d\n", bg->dyThresh);
	printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");
	printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");
	printf("\n");
	switch(detectcpu())
	{
		case 0: cpus = "8086/8088 or 186/88"; break;
		case 1: cpus = "286"; break;
		case 2: cpus = "386 or newer"; break;
		default: cpus = "internal error"; break;
	}
	printf("detected CPU type: %s\n", cpus);
}
Esempio n. 8
0
File: s3dtv.c Progetto: koo5/lemon-2
static int keypress(struct s3d_evt *event)
{
    struct s3d_key_event *keys = (struct s3d_key_event *)event->buf;
    int key=keys->keysym;
    int mod=keys->modifier;
    if (mod&S3D_KMOD_RSHIFT)
    {
        switch (key)
        {
        case S3DK_INSERT:
            clip(mod&S3D_KMOD_RCTRL);
        }
    }

    if (mod&S3D_KMOD_RCTRL)
    {
        switch (key)
        {
        case S3DK_F5:
            wdt-=0.1;
            dirty=1;
            break;
        case S3DK_F6:
            wdt+=0.1;
            dirty=1;
            break;
        case S3DK_F7:
            afterlife=!afterlife;
            break;
        case S3DK_F8:
            loadl2("l2");
            dirty=1;
            break;
        case S3DK_F12:
            dirty=1;
            showhex=!showhex;
            printf("showhex=!showhex;\n");
            break;
        case S3DK_F10:
            dirty=1;
            ok=!ok;
            printf("ok\n");
            break;
        case S3DK_END:
            resizooo(t, 0,1);
            break;
        case S3DK_HOME:
            resizooo(t, 0,-1);
            break;
        case S3DK_DELETE:
            resizooo(t, -1,0);
            break;
        case S3DK_PAGEDOWN:
            resizooo(t, 1,0);
            break;
        }
    }
    else if (mod&S3D_KMOD_RALT)
    {
        switch (key)
        {
        case S3DK_END:
            resizooo(t, 0,100);
            break;
        case S3DK_HOME:
            resizooo(t, 0,-100);
            break;
        case S3DK_DELETE:
            resizooo(t, -100,0);
            break;
        case S3DK_PAGEDOWN:
            resizooo(t, 100,0);
            break;
        }
    }
    else
    {
        if ( (key == S3DK_F1) )
            {    }
        else

            if ( (key >= S3DK_F1) && (key <= S3DK_F15) )
            {
                char *k;
                if (asprintf(&k ,"kf%i", key-S3DK_F1+1)!=-1)
                {
                    rote_vt_terminfo(t, k);
                    free(k);
                }
            }
            else if ( (key == S3DK_SPACE) )
                keyp(t,32);
            else if ( (key == S3DK_BACKSPACE) )
                rote_vt_terminfo(t, "kbs");
            else if ( (key == S3DK_ESCAPE) )
                keyp(t,27);
            else if ( (key == S3DK_LEFT) )
                rote_vt_terminfo(t, "kcub1");
            else if ( (key == S3DK_RIGHT) )
                rote_vt_terminfo(t, "kcuf1");
            else if ( (key == S3DK_UP) )
                rote_vt_terminfo(t, "kcuu1");
            else if ( (key == S3DK_DOWN) )
                rote_vt_terminfo(t, "kcud1");
            else if ( (key == S3DK_END) )
                rote_vt_terminfo(t, "kend");
            else if ( (key == S3DK_HOME) )
                rote_vt_terminfo(t, "khome");
            else if ( (key == S3DK_DELETE) )
                rote_vt_terminfo(t, "kdch1");
            else if ( (key == S3DK_PAGEDOWN) )
                rote_vt_terminfo(t, "knp");
            else if ( (key == S3DK_INSERT) )
                rote_vt_terminfo(t, "kich1");
            else if ( (key == S3DK_PAGEUP) )
                if (mod&S3D_KMOD_RSHIFT)
                    scrollup();
                else
                    rote_vt_terminfo(t, "kpp");
            else if ( (key == S3DK_RETURN) )
            {
                if (mod&(S3D_KMOD_RSHIFT|S3D_KMOD_LSHIFT))
                    keyp(t,10);
                else
                    keyp(t,13);
            }
            else if (mod&(S3D_KMOD_RALT|S3D_KMOD_LALT))
            {
                char x[2];

                x[0]=27;
                x[1]=keys->keysym;
                rote_vt_write(t, &x[0], 2);//thx twkm

            }
            else
            {
                if ( (key==S3DK_LSHIFT)||(key==S3DK_RSHIFT))
                {
                    globmousecopying=!keys->state;
                }
                else
                {
                    keyp(t, keys->unicode);
//					    	printf("%c, %i\n",  keys->keysym,  keys->unicode);
                }
            }
    }
}