示例#1
0
  void khLuaScript::_match( Status* S, Sprite* Src, Sprite* Tgt )
  {
    // precluding judgment
    if(!Keyhole::contact(Src,Tgt))return;
    
    checkAndInitOfxLua();
    resetLuaOutput();
    
    // input Lua state    
    inputStatusProp(S,L.get());
    inputSpriteProp(Src,L.get(),"S_");
    inputSpriteProp(Tgt,L.get(),"T_");

    // call Lua function
    L->scriptFcn(matchFcn);

    // read Lua state        
    readSpriteProp(Src,L.get(),"S_");
    readSpriteProp(Tgt,L.get(),"T_"); 
    readStatusProp(S,L.get());

    // audio-visual feedback
    dispInfo();
    playSound();
  }
示例#2
0
文件: main.c 项目: M4Duke/cpcxfer
int main(int argc, char *argv[])
{	int opt = 0;
	
#ifdef __WIN32__
	WSADATA WsaDat;
#endif

	if ( argc < 2 )
	{	
		dispInfo(argv[0]);
		exit(0);
	}

#ifdef __WIN32__
	WSAStartup(MAKEWORD(2,2),&WsaDat);		
#endif	
	if ( !strnicmp(argv[1], "-p", 2) )	// reset cpc
	{
		startCard(argv[2]);
	}
	else
	if ( !strnicmp(argv[1], "-r", 2) )	// reboot M4
	{
		reset(argv[2]);
	}
	else	if ( !strnicmp(argv[1], "-s", 2) )	// reset cpc
	{
		resetCPC(argv[2]);
	}
	else	if ( !strnicmp(argv[1], "-x", 2) && (argc>=3) )	// execute
	{
		run(argv[2], argv[3]);
	}
	else if ( !strnicmp(argv[1], "-f", 2) && (argc>=4) )	// upload (flash) rom
	{	
		uploadRom(argv[3], argv[2], atoi(argv[4]), argv[5] );
	}
	else if ( !strnicmp(argv[1], "-u", 2) && (argc>=4) )	// upload 
	{	unsigned short start = 0;
		unsigned short exec = 0;
		if ( argc < 5 )
		{
			dispInfo(argv[0]);
			exit(0);
		}
		
		if ( argc>5 )
		{	opt = atoi(argv[5]);
			
			if ( opt == 2 )	// add binary header ?
			{
				// we need more parameters then
				
				if ( argc < 8 )
				{
					printf("Please add start address and exec. address for binary header\r\n");
					exit(0);	
				}
				
				start = atoh(argv[6]);
				exec = atoh(argv[7]);
				
			}
		
		}
		upload(argv[3], argv[4], argv[2], opt, start, exec);
	}
	else if ( !strnicmp(argv[1], "-c", 2) && (argc>=4) )	// upload cartridge
	{
		uploadctr(argv[3], argv[2]);
	}
	else if ( !strnicmp(argv[1], "-y", 2) && (argc>=3) )
	{
        // Prepare the file manipulation variables
        char fullpath[256];
		char path[] = "/tmp"; // TODO Find a way to use /tmp or something like that
		char * filename = argv[3];
		char * ip = argv[2];
		int p = pathPos(filename, strlen(filename));	// strip any PC path from filename
		sprintf(fullpath, "%s/%s", path, &filename[p]);
                
		upload(filename, path, ip, 0, 0, 0 );  // Upload the file on CPC
		run(ip, fullpath);              // Execute the file on CPC

	}
	else if ( !strnicmp(argv[1], "-d", 2) && (argc>=4) )	// download
	{	
		if ( argc>5 )
			opt = atoi(argv[5]);

		download(argv[3], argv[4], argv[2], opt);
	}
	else
	{	
		dispInfo(argv[0]);
		exit(0);
	}
	

#ifdef __WIN32__	
	WSACleanup();
#endif
	
	return 0;
}