Exemple #1
0
bool CG_NetSocket::_NetStartUp(int VersionHigh,int VersionLow)
{
#ifdef WIN32
	WORD wVersionRequested;
	WSADATA wsaData;
	int err;
 
	wVersionRequested = MAKEWORD(VersionHigh,VersionLow);
    err=WSAStartup(wVersionRequested, &wsaData);
	
	/* startup failed */
	if (err!=0)									
	{
		CORE(LOG_NAME,"WSAStartup error");
		WSACleanup();
		return false;
	}

	/* version error */
	if (LOBYTE(wsaData.wVersion)!= VersionLow ||
        HIBYTE(wsaData.wVersion)!= VersionHigh ) 
	{
		CORE(LOG_NAME,"WSAStartup version error");
		WSACleanup();
		return false;
	}
	CORE(LOG_NAME,"WSAStartup ok");
#endif
	return true;
}
Exemple #2
0
void CGameWorld::processUser()
{
	short cmdId;
	CG_TCPSession *session;
	map<long,CUser*>::iterator it;
	CUser *user;
	vector<long> vDeadUser;
	for(it=m_oUsers.begin();it!=m_oUsers.end();)
	{
		user    = it->second;
		GIVER() = user;//user->m_dummy;//(CS_RegionCreature*)
		session = user->m_session;
		if(session)
		{
			session->DefProc();
			//check dead
			if(session->IsDead()/* || GIVER()->m_bClose*/) 
			{
				//user->m_session = NULL;
				user->m_netDeadTime = m_iTime;

				if(session->GetState() == NET_STATE_DEAD)
					CORE("User Disconnect:", "userid=%d",user->getUserId());

				//deleteUser(user->getUserId());
				vDeadUser.push_back(user->getUserId());
				//_DELETE(session);
				//continue;
			}
			else
			{
				bool bQuit = false;
				while(session->GetPacket(m_activeCmd)) 
				{	
					if(!m_activeCmd->ReadShort(&cmdId))
						break;
					m_channelLogin.RecvCmd(cmdId);
				}
				if(session->GetState() == NET_STATE_ERROR)
					CORE("Unknown package format", "%d",user->getUserId());
			}
		}
		it++;
	}

	//ÊͷŵôÏßµÄ
	for (int i=0;i<(int)vDeadUser.size();i++)
	{
		long userid = vDeadUser[i];
		if (userid>0)
		{
			deleteUser(userid);
			CORE("delete user:"******"userid=%d",userid);
		}
	}
}
Exemple #3
0
bool CGameWorld::init()
{
	m_iTime = Sys_GetTime();


	const char* pFilePath = "setup.xml";

	TiXmlDocument xmlDoc(pFilePath);
	if (!xmlDoc.LoadFile())
	{
		CORE("init:","load setup.xml error");
		return false;
	}
	TiXmlElement *root = xmlDoc.RootElement();  
	if (root==NULL)
	{
		CORE("init:","init error RootElement");
		return false;
	}
	


	if (!initConfig(root->FirstChildElement("config")))
	{
		CORE("init:","initConfig error");
		return false;
	}

	if (!initNet(root->FirstChildElement("net")))
	{
		CORE("init:","initNet error");
		return false;
	}

	if (!initDB(root->FirstChildElement("db")))
	{
		CORE("init:","initDB error");
		return false;
	}

	if (!initData())
	{
		return false;
	}


	return true;

}
Exemple #4
0
static void body(uint32_t ABCD[4], uint32_t X[16]){

    int t;
    int i av_unused;
    unsigned int a= ABCD[3];
    unsigned int b= ABCD[2];
    unsigned int c= ABCD[1];
    unsigned int d= ABCD[0];

#ifdef WORDS_BIGENDIAN
    for(i=0; i<16; i++)
        X[i]= bswap_32(X[i]);
#endif

#ifdef CONFIG_SMALL
    for( i = 0; i < 64; i++ ){
        CORE(i,a,b,c,d)
        t=d; d=c; c=b; b=a; a=t;
    }
#else
#define CORE2(i) CORE(i,a,b,c,d) CORE((i+1),d,a,b,c) CORE((i+2),c,d,a,b) CORE((i+3),b,c,d,a)
#define CORE4(i) CORE2(i) CORE2((i+4)) CORE2((i+8)) CORE2((i+12))
CORE4(0) CORE4(16) CORE4(32) CORE4(48)
#endif

    ABCD[0] += d;
    ABCD[1] += c;
    ABCD[2] += b;
    ABCD[3] += a;
}
Exemple #5
0
void close_rom()
{
	if(load_null_rom()) {
		CORE().runmode->set_pause();
		mark_pending_load("SOME NONBLANK NAME", LOAD_STATE_ROMRELOAD);
	}
}
Exemple #6
0
void switch_projects(const std::string& newproj)
{
	pending_new_project = newproj;
	CORE().runmode->start_load();
	platform::cancel_wait();
	platform::set_paused(false);
}
Exemple #7
0
bool CGameWorld::initNet(TiXmlElement* pRoot)
{
	CORE("init:","initNet..");
	g_cfg.client_listen_ip = "localhost";
	g_cfg.client_listen_port = 0;//8888;
	g_cfg.unlogin_timeout = 60;
	g_cfg.local_login = true;
	g_cfg.c2r_interval = 500;
	g_cfg.r2c_interval = 250;
	g_cfg.cl_pre_buffer = 3;
	g_cfg.cl_max_buffer = 1;

	//read config
	CORE("init:","initNet read config..");
	if(!pRoot)
		return false;
	m_strListenIp="0.0.0.0";
	TiXmlElement* pEleCon = pRoot->FirstChildElement("ip");
	if (pEleCon)
	{
		m_strListenIp = pEleCon->GetText();
	}
	string strport="7200";
	TiXmlElement* pEleConPort = pRoot->FirstChildElement("port");
	if (pEleConPort)
	{
		strport = pEleConPort->GetText();
	}
	m_iListenPort = atol(strport.c_str());

	g_cfg.client_listen_ip = m_strListenIp;
	g_cfg.client_listen_port = m_iListenPort;
	//start listen
	CORE("init:","start listen(%s,%d)..",m_strListenIp.c_str(),m_iListenPort);
	if(!m_ClientListener.StartListen(m_strListenIp.c_str(),
		m_iListenPort,true))
	{
		CORE("¼àÌý¶Ë¿Úʧ°Ü: ","start listen ip=%s,port = %d",m_strListenIp.c_str(),m_iListenPort);
		return false;
	}
	else
	{
		CORE("¿ªÊ¼¼àÌý¶Ë¿Ú: ","start listen  ip=%s,port = %d",m_strListenIp.c_str(),m_iListenPort);
	}
	InitChannel();
	return true;
}
Exemple #8
0
bool CG_NetSocket::_NetCleanUp()
{
#ifdef WIN32	
	WSACleanup();
	CORE(LOG_NAME,"WSACleanup ok");
#endif
	return true;
}
Exemple #9
0
void mainloop_signal_need_rewind(void* ptr)
{
	auto& core = CORE();
	if(ptr)
		core.runmode->start_load();
	do_unsafe_rewind = true;
	unsafe_rewind_obj = ptr;
}
Exemple #10
0
	int16_t get_input(unsigned port, unsigned index, unsigned control)
	{
		auto& core = CORE();
		int16_t x;
		x = core.mlogic->input_poll(port, index, control);
		core.lua2->callback_snoop_input(port, index, control, x);
		return x;
	}
Exemple #11
0
void convert_break_to_pause()
{
	auto& core = CORE();
	if(core.runmode->is_paused_break()) {
		core.runmode->set_pause();
		core.supdater->update();
	}
}
Exemple #12
0
void set_stop_at_frame(uint64_t frame)
{
	auto& core = CORE();
	stop_at_frame = frame;
	stop_at_frame_active = (frame != 0);
	if(!core.runmode->is_special())
		core.runmode->set_freerunning();
	platform::set_paused(false);
}
Exemple #13
0
	int16_t set_input(unsigned port, unsigned index, unsigned control, int16_t value)
	{
		auto& core = CORE();
		if(!core.mlogic->get_movie().readonly_mode()) {
			portctrl::frame f = core.mlogic->get_movie().get_controls();
			f.axis3(port, index, control, value);
			core.mlogic->get_movie().set_controls(f);
		}
		return core.mlogic->get_movie().next_input(port, index, control);
	}
Exemple #14
0
void do_break_pause()
{
	auto& core = CORE();
	core.runmode->set_break();
	core.supdater->update();
	core.fbuf->redraw_framebuffer();
	while(core.runmode->is_paused_break()) {
		platform::set_paused(true);
		platform::flush_command_queue();
	}
}
Exemple #15
0
void emulator_runmode::revalidate()
{
	if(!mode || mode & (mode - 1) || (mode == QUIT && magic != QUIT_MAGIC) || mode > CORRUPT) {
		//Uh, oh.
		auto& core = CORE();
		if(core.mlogic)
			emerg_save_movie(core.mlogic->get_mfile(), core.mlogic->get_rrdata());
		messages << "WARNING: Emulator runmode undefined, invoked movie dump." << std::endl;
		mode = PAUSE;
	}
}
Exemple #16
0
	void output_frame(framebuffer::raw& screen, uint32_t fps_n, uint32_t fps_d)
	{
		auto& core = CORE();
		core.lua2->callback_do_frame_emulated();
		core.runmode->set_point(emulator_runmode::P_VIDEO);
		core.fbuf->redraw_framebuffer(screen, false, true);
		auto rate = core.rom->get_audio_rate();
		uint32_t gv = gcd(fps_n, fps_d);
		uint32_t ga = gcd(rate.first, rate.second);
		core.mdumper->on_rate_change(rate.first / ga, rate.second / ga);
		core.mdumper->on_frame(screen, fps_n / gv, fps_d / gv);
	}
Exemple #17
0
	void timer_tick(uint32_t increment, uint32_t per_second)
	{
		auto& core = CORE();
		if(!*core.mlogic)
			return;
		auto& m = core.mlogic->get_mfile();
		m.dyn.rtc_subsecond += increment;
		while(m.dyn.rtc_subsecond >= per_second) {
			m.dyn.rtc_second++;
			m.dyn.rtc_subsecond -= per_second;
		}
	}
Exemple #18
0
bool CG_NetSocket::Listen()
{
//#ifdef GAME_SERVER
	if(listen(m_socket,SOMAXCONN)==SOCKET_ERROR)
	{
		CORE(LOG_NAME,"NetSocket listen error");
		return false;
	}
//#endif
	
	return true;
}
static void initialize(XmLabelHackWidget, XmLabelHackWidget _new, 
		       String *, Cardinal *)
{
    XmLabelHackWidgetClass lhwc;

    lhwc = (XmLabelHackWidgetClass)xmLabelHackWidgetClass;

    XtInitializeWidgetClass(xmLabelGadgetClass);

    if (HACK_CLASS(lhwc).on == -1)
    {
	enable3d(_new);
	HACK_CLASS(lhwc).on = HACK(_new).insensitive3D;
    }

    if ((CORE(_new).width == 0) || (CORE(_new).height == 0))
    {
	CORE(_new).width = 1;
	CORE(_new).height = 1;
    }
}
Exemple #20
0
		void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
		{
			frames_dumped++;
			if(frames_dumped % 100 == 0) {
				std::cout << "Dumping frame " << frames_dumped << "/" << total << " ("
					<< (100 * frames_dumped / total) << "%)" << std::endl;
			}
			if(frames_dumped >= total) {
				//Rough way to end it.
				CORE().command->invoke("quit-emulator");
			}
		}
static void enable3d(XmLabelHackWidget _new)
{
    if (HACK(_new).insensitive3D && CORE(_new).depth > 4)
    {
	if (oldLabelWidgetExposeProc == 0)
	    _replaceLabelExpose();

	if (oldLabelGadgetExposeProc == 0)
	    _replaceLabelGadgetExpose();

	// Keep around so there is one in the cache
	HACK(_new).topGC    = _topShadowGC((XmLabelWidget)_new);
	HACK(_new).bottomGC = _bottomShadowGC((XmLabelWidget)_new);
    }
}
Exemple #22
0
bool CG_NetSocket::SetNonBlocking()
{
	/* set to nonblocking mode */
	u_long arg;
	arg = 1;
	int ret;
	ret = IOCTLSOCKET(m_socket,FIONBIO,&arg);
	if (ret == SOCKET_ERROR)
	{
		CORE(LOG_NAME,"SetNonBlocking Failed,IOCTLSOCKET = %d",ret);
		return false;
	}
	else
	{
		return true;
	}
}
Exemple #23
0
static void body(uint32_t ABCD[4], uint32_t *src, int nblocks)
{
    int i av_unused;
    int n;
    uint32_t a, b, c, d, t, *X;

    for (n = 0; n < nblocks; n++) {
        a = ABCD[3];
        b = ABCD[2];
        c = ABCD[1];
        d = ABCD[0];

        X = src + n * 16;

#if HAVE_BIGENDIAN
        for (i = 0; i < 16; i++)
            X[i] = av_bswap32(X[i]);
#endif

#if CONFIG_SMALL
        for (i = 0; i < 64; i++) {
            CORE(i, a, b, c, d);
            t = d;
            d = c;
            c = b;
            b = a;
            a = t;
        }
#else
#define CORE2(i)                                                        \
        CORE(i, a, b, c, d); CORE((i + 1), d, a, b, c);                 \
        CORE((i + 2), c, d, a, b); CORE((i + 3), b, c, d, a)
#define CORE4(i) CORE2(i); CORE2((i + 4)); CORE2((i + 8)); CORE2((i + 12))
        CORE4(0);
        CORE4(16);
        CORE4(32);
        CORE4(48);
#endif

        ABCD[0] += d;
        ABCD[1] += c;
        ABCD[2] += b;
        ABCD[3] += a;
    }
}
Exemple #24
0
bool CG_NetSocket::BindAddr(const char *ip,int port)
{
	SOCKADDR_IN addrLocal;
	addrLocal.sin_family=AF_INET;
	addrLocal.sin_port=htons(port);
	if(ip && strcmp(ip,"localhost")!=0)
	{
		addrLocal.sin_addr.s_addr=inet_addr(ip);
	}
	else
	{
		addrLocal.sin_addr.s_addr=htonl(INADDR_ANY);
	}
	if(bind(m_socket,(SOCKADDR *)&addrLocal,sizeof(addrLocal))==SOCKET_ERROR)
	{
		CORE(LOG_NAME,"Bind socket error");
		return false;
	}
	return true;
}
Exemple #25
0
static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks)
{
    int i av_unused;
    int n;
    const uint32_t *X;
    uint32_t a, b, c, d, t;

    for (n = 0; n < nblocks; n++) {
        a = ABCD[3];
        b = ABCD[2];
        c = ABCD[1];
        d = ABCD[0];

        X = (const uint32_t *)src + n * 16;

#if CONFIG_SMALL
        for (i = 0; i < 64; i++) {
            CORE(i, a, b, c, d);
            t = d;
            d = c;
            c = b;
            b = a;
            a = t;
        }
#else
#define CORE2(i)                                                        \
        CORE(i, a, b, c, d); CORE((i + 1), d, a, b, c);                 \
        CORE((i + 2), c, d, a, b); CORE((i + 3), b, c, d, a)
#define CORE4(i) CORE2(i); CORE2((i + 4)); CORE2((i + 8)); CORE2((i + 12))
        CORE4(0);
        CORE4(16);
        CORE4(32);
        CORE4(48);
#endif

        ABCD[0] += d;
        ABCD[1] += c;
        ABCD[2] += b;
        ABCD[3] += a;
    }
}
Exemple #26
0
bool CG_NetSocket::Connect(const char *szAddr, int port, unsigned long ip)
{
	SOCKADDR_IN addrRemote;
	hostent *host=NULL;

	memset(&addrRemote,0,sizeof(addrRemote));
	addrRemote.sin_family=AF_INET;
	addrRemote.sin_port=htons(port);
	
	if(szAddr)
		addrRemote.sin_addr.s_addr = inet_addr(szAddr);
	else
		addrRemote.sin_addr.s_addr = ip;
	
	if(addrRemote.sin_addr.s_addr==INADDR_NONE)
	{
		if(!szAddr) return false;
		host=gethostbyname(szAddr);
		if(!host) return false;
		memcpy(&addrRemote.sin_addr,host->h_addr_list[0],host->h_length);
	}
	
	if(connect(m_socket,(SOCKADDR *)&addrRemote,sizeof(addrRemote))
		==SOCKET_ERROR)
	{
		int err = GETERROR;
		if (err != CONN_INPRROGRESS)
		{
			CORE(LOG_NAME,"Socket connect error = %d",err); 
			return false;
		}
// 		else if (!CanWrite())
// 		{
// 			CORE(LOG_NAME,"Socket connect error ,CanWrite=false"); 
// 			return false;
// 		}
		//return false;
	}
	return true;
}
Exemple #27
0
void handle_registerX(lua::state& L, uint64_t addr, int lfn)
{
    //Put the context in userdata so it can be gc'd when Lua context is terminated.
    lua_debug_callback2* D = (lua_debug_callback2*)L.newuserdata(sizeof(lua_debug_callback2));
    new(D) lua_debug_callback2;
    L.newtable();
    L.pushstring("__gc");
    L.push_trampoline(&lua_debug_callback2::on_lua_gc, 0);
    L.rawset(-3);
    L.setmetatable(-2);
    L.pushlightuserdata(D);
    L.pushvalue(-2);
    L.rawset(LUA_REGISTRYINDEX);
    L.pop(1); //Pop the copy of object.

    D->L = &L.get_master();
    D->addr = addr;
    D->type = type;
    D->dead = false;
    D->set_lua_fn(lfn);
    D->link_to_list();

    CORE().dbg->add_callback(addr, type, *D);
}
Exemple #28
0
static void body(uint32_t ABCD[4], uint32_t X[16])
{
    int i av_unused;
    uint32_t t;
    uint32_t a = ABCD[3];
    uint32_t b = ABCD[2];
    uint32_t c = ABCD[1];
    uint32_t d = ABCD[0];

#if HAVE_BIGENDIAN
    for (i = 0; i < 16; i++)
        X[i] = av_bswap32(X[i]);
#endif

#if CONFIG_SMALL
    for (i = 0; i < 64; i++) {
        CORE(i, a, b, c, d);
        t = d;
        d = c;
        c = b;
        b = a;
        a = t;
    }
#else
#define CORE2(i)                                                        \
    CORE( i,   a,b,c,d); CORE((i+1),d,a,b,c);                           \
    CORE((i+2),c,d,a,b); CORE((i+3),b,c,d,a)
#define CORE4(i) CORE2(i); CORE2((i+4)); CORE2((i+8)); CORE2((i+12))
    CORE4(0); CORE4(16); CORE4(32); CORE4(48);
#endif

    ABCD[0] += d;
    ABCD[1] += c;
    ABCD[2] += b;
    ABCD[3] += a;
}
Exemple #29
0
void
setup_routing_tables(uint my_x, uint my_y, uint cores_per_chip)
{
	uint entry;
	
	uint xyz[3] = {
		XY_TO_MIN_X(my_x,my_y),
		XY_TO_MIN_Y(my_x,my_y),
		XY_TO_MIN_Z(my_x,my_y)
	};
	
	// Add entries to multicast out nearest-neighbour messages from this chip
	ADD_RTR_ENTRY( NEAREST_NEIGHBOUR_KEY(XY_TO_COLOUR(my_x,my_y), 0)
	             , NEAREST_NEIGHBOUR_KEY(0xFF, 0)
	             , EAST|NORTH|NORTH_EAST|WEST|SOUTH_WEST|SOUTH
	             );
	// Add entry to catch all incoming nearest neighbour messages (i.e. those with
	// a different colour
	for (int p = 1; p <= cores_per_chip; p++)
		ADD_RTR_ENTRY( NEAREST_NEIGHBOUR_KEY(0, p-1)
		             , NEAREST_NEIGHBOUR_KEY(0, 0xF)
		             , CORE(p)
		             );
	
	// Add entries to accept master<->slave packets destined for this core
	for (int p = 1; p <= cores_per_chip; p++)
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0],xyz[1],xyz[2], p-1,0)
		             , XYZPD_TO_KEY(  0xFF,  0xFF,  0xFF,0x0F,0)
		             , CORE(p)
		             );
	
	// Add entries to accept master<->slave packets destined for this core
	for (int p = 1; p <= cores_per_chip; p++)
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0],xyz[1],xyz[2], p-1,0)
		             , XYZPD_TO_KEY(  0xFF,  0xFF,  0xFF,0x0F,0)
		             , CORE(p)
		             );
	
	// Add entry to pick up return packets for the master
	if (my_x == 0 && my_y == 0)
		ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,0))
		             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0))
		             , CORE(1)
		             );
	
	// Add routes which allow dimension-order routing with any dimension order
	for (int dim_order = 0; dim_order < NUM_DIM_ORDERS; dim_order++) {
		if (my_x == 0 && my_y == 0) {
			// Start packets off on the right dimension from the master
			// If the first/second dimensions are zero, route in the third dimension
			ADD_RTR_ENTRY( XYZPD_TO_KEY(   0,   0,   0,   0, dim_order)
			             , XYZPD_TO_KEY(DX1F,DY1F,DZ1F,0x00, 0x07)
			             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][2]]
			             );
			// If the first dimension is zero, route in the second dimension
			ADD_RTR_ENTRY( XYZPD_TO_KEY(   0,   0,   0,   0, dim_order)
			             , XYZPD_TO_KEY(DX0F,DY0F,DZ0F,0x00, 0x07)
			             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][1]]
			             );
			// If no dimension is zero, route in the first dimension
			ADD_RTR_ENTRY( XYZPD_TO_KEY(   0,   0,   0,   0, dim_order)
			             , XYZPD_TO_KEY(0x00,0x00,0x00,0x00, 0x07)
			             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][0]]
			             );
		} else {
			// Send packets in the opposite dimension order when returning to the
			// master.
			// If the third dimension is not zero, route along it first
			if (xyz[DIM_ORDERS[dim_order][2]])
				ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,dim_order))
				             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0x7))
				             , OPPOSITE(DIM_DIRECTIONS[DIM_ORDERS[dim_order][2]])
				             );
			else if (xyz[DIM_ORDERS[dim_order][1]])
				ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,dim_order))
				             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0x7))
				             , OPPOSITE(DIM_DIRECTIONS[DIM_ORDERS[dim_order][1]])
				             );
			else if (xyz[DIM_ORDERS[dim_order][0]])
				ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,dim_order))
				             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0x7))
				             , OPPOSITE(DIM_DIRECTIONS[DIM_ORDERS[dim_order][0]])
				             );
		}
		
		// Dimension order route packets (x, then y, then z)
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0]&DX1F, xyz[1]&DY1F,xyz[2]&DZ1F,   0,dim_order)
		             , XYZPD_TO_KEY(       DX1F,        DY1F,       DZ1F,0x00,0x07)
		             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][2]]
		             );
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0]&DX0F, xyz[1]&DY0F,xyz[2]&DZ0F,   0,dim_order)
		             , XYZPD_TO_KEY(       DX0F,        DY0F,       DZ0F,0x00,0x07)
		             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][1]]
		             );
	}
}
void c_main (void)
{
    int chipIDs[] = {0, 1, 256, 257};

    chipID = spin1_get_chip_id();
    coreID = spin1_get_core_id();
    spikeNumber = 0;
    //io_printf(IO_STD, "Simulation starting on (chip: %d, core: %d)...\n", chipID, coreID);

    // Set the number of chips in the simulation
    //spin1_set_core_map(64, (uint *)(0x74220000));

    // set the core map for the simulation
    //spin1_application_core_map(2, 2, core_map);
    //spin1_set_core_map(4, (uint *)(core_map));

    // initialise routing entries
    // set a MC routing table entry to send my packets back to me


    if (chipID == 0 && coreID == 1)
    {
  /* ------------------------------------------------------------------- */
  /* initialise routing entries                                          */
  /* ------------------------------------------------------------------- */
  /* set a MC routing table entry to send my packets back to me */

  io_printf(IO_STD, "Setting routing table on (chip: %d, core: %d)...\n", chipID, coreID);

   uint e = rtr_alloc (1);
   if (e == 0)
      rt_error (RTE_ABORT);

    rtr_mc_set (e,			// entry
	      0x11100001, 			// key
	      0xFFFF0001,		// mask
	      SOUTH_WEST
	      );
   e = rtr_alloc (1);
   if (e == 0)
      rt_error (RTE_ABORT);
    rtr_mc_set (e,			// entry
	      0x11100000, 			// key
	      0xFFFF0001,		// mask
	      SOUTH_WEST
	      );

   e = rtr_alloc (1);
   if (e == 0)
      rt_error (RTE_ABORT);

    rtr_mc_set (e,
        0x80000000 | 9 << 7 | 0 << 2,
        0x80000000 | 15 << 7 | 31 << 2,
        CORE(2) // core 2 handles bump sensor
        );

   e = rtr_alloc (1);
   if (e == 0)
      rt_error (RTE_ABORT);

    rtr_mc_set (e,
        0x80000000 | 9  << 7 | 4 << 2 | 2,
        0x80000000 | 15 << 7 | 31 << 2 | 3,
        CORE(3) // core 3 handles compass sensor
        );

   e = rtr_alloc (1);
   if (e == 0)
      rt_error (RTE_ABORT);

    rtr_mc_set (e,
        0x80000000 , //| 9  << 7 | 0 << 2,
        0x80000000 , //| 15 << 7 | 0 << 2,
        CORE(4) // core 4 logs data 
        );

    }

    // Call hardware and simulation configuration functions
    spin1_set_timer_tick(TIME_STEP_MICROSEC);

    if (chipID == 0 && coreID == 1) //core1 handles time-based stuff
    {
    spin1_callback_on(TIMER_TICK, timer_callback, TIMER_PRIORITY);
    }

    if (chipID == 0 && coreID == 2)
    {    
    spin1_callback_on(MCPL_PACKET_RECEIVED, bump_received, MC_PACKET_EVENT_PRIORITY);
    }
    
    if (chipID == 0 && coreID == 3)
    {
    spin1_callback_on(MC_PACKET_RECEIVED, enable_packet_received, MC_PACKET_EVENT_PRIORITY);

    }
    
    if (chipID == 0 && coreID == 4)
    {
    // Register callbacks
    spin1_callback_on(MC_PACKET_RECEIVED, multiCastPacketReceived_callback, MC_PACKET_EVENT_PRIORITY);
    spin1_callback_on(MCPL_PACKET_RECEIVED, multiCastPacketReceived_with_payload_callback, MC_PACKET_EVENT_PRIORITY);
    }

    // transfer control to the run-time kernel
    //if (chipID == 0 && coreID == 1)
    {
       spin1_start(0);


    }

}