示例#1
0
void frame_free(int frame)
{
	KASSERT(frame >= 0 && frame < num_frames);

	lock_acquire(coremap_lock);
		int pid = coremap_ptr[frame].pid;
		int id = coremap_ptr[frame].id;

		if (pid != 0) {
			KASSERT(curproc->pid == pid);
			set_frame(frame, UNALLOCATED, 0,0);
			ZERO_OUT_FRAME(frame);
			goto FRAME_FREE_DONE;
		}
		for (int i = 0; i < num_frames; i++){
			if (coremap_ptr[i].pid != 0 || coremap_ptr[i].id != id) continue;
			set_frame(i, UNALLOCATED, 0,0);
			ZERO_OUT_FRAME(i);
			if (id_not_used != NULL){ // recycle id's for kernel memory
				q_addtail(id_not_used, (void*)id);
			}
			goto FRAME_FREE_DONE;
		}

		panic("Invalid freeing of the frame for the unique pair (pid,id)=(%d,%d)\n", pid, id);
FRAME_FREE_DONE:
	lock_release(coremap_lock);
}
示例#2
0
void gun::Sprite::Update(double dt)
{
	if(animations_.size() > 0)
	{
		Animation animation = current_anim();

		if (is_playing_)
		{
			if (frame_ >= animation.num_frames())
			{
				if (is_looping_)
				{
					set_frame(0);
				}
				else
				{
					set_frame(animation.num_frames() - 1);
					is_playing_ = false;
				}
			}

			set_frame(frame_ + dt * anim_speed_);
		}
	}
}
示例#3
0
int
uframe_alloc1(int *frame, pid_t pid, int id)
{

	int ret = 1;
	lock_acquire(coremap_lock);
	if(coremap_has_space() == 0)
	{
		ret = core_kickvictim(frame);
		if(ret) goto UFRAME_ALLOC1_FINISH;
		set_frame(*frame, USER, pid, id);
		ZERO_OUT_FRAME(*frame);
		goto UFRAME_ALLOC1_FINISH;
	}
	
	// start search from the MIDDLE of the coremap
	int idx = num_frames >> 1;
	for(int i = 0; i < num_frames; i++) {
		if(coremap_ptr[idx].status == UNALLOCATED) {
			set_frame(idx, USER, pid, id);
			*frame = idx;
			ret = 0;
			ZERO_OUT_FRAME(*frame);
			break;
		}
		idx = (idx + 1) % num_frames;
	}
UFRAME_ALLOC1_FINISH:
	lock_release(coremap_lock);
	DEBUG(DB_VM,"Finished uframe_alloc1 retval:%d\n", ret);
	return ret;
}
示例#4
0
g1_movie_flow_class::advance_status g1_movie_flow_class::advance_movie_with_time()
{
	poll_scores();

	advance_status stat=PLAYING;

	if (t_cut_scenes)
	{
		i4_time_class now;
		sw32 md;

		do
		{
			md=now.milli_diff(frame_time);
			if (md>(1000/G1_MOVIE_HZ))
			{
				frame_time.add_milli((1000/G1_MOVIE_HZ));

				if (frame+1<current()->total_frames())
				{
					set_frame(frame+1);
				}
				else if (scene+1<t_cut_scenes)
				{
					do
					{
						set_scene(scene+1);
						start();
						set_frame(0);
						stat=NEXT_SCENE;

						if (scene+1==t_cut_scenes && current()->total_frames()==0)
						{
							stop();
							return DONE;
						}

					}
					while (current()->total_frames()==0);
				}
				else
				{
					stop();
					return DONE;
				}
			}
		}
		while (md>(1000/G1_MOVIE_HZ));
	}
	return stat;
}
示例#5
0
static void do_action(struct Player *pp, Action ac)
{
    Action pre_action;
    pre_action = previous_action(pp);
    int pre_frame = pre_action.frame;
    int nframe;

    if (equal_action(pre_action, ac))
    {
        nframe = next_frame(pp, ac, pre_frame);
        set_frame(pp, nframe);
        complete_action(pp);
    }
    else if (pre_frame != 0)    // previous action unfinished
    {
        if (action_interruptable(pre_action))
        {
            set_action(pp, ac);
            complete_action(pp); //pp->spd = spd;
        }
        else
            do_action(pp, pre_action);
    }
    else          // previous action finished, set new action
    {
        set_action(pp, ac);
       complete_action(pp);
    }
}
示例#6
0
gun::Sprite::Sprite(const sf::Texture& texture, 
	const std::map<int, Animation>& animations, int anim_index, double anim_speed)
	: sprite_(sf::Sprite(texture)), draw_order_(0), is_visible_(true), is_playing_(false),
	is_looping_(false), animations_(animations), anim_speed_(anim_speed), anim_index_(anim_index)
{
	set_frame(0);
}
示例#7
0
文件: scheduler.c 项目: UIKit0/pmk
/**
 * Creates a new thread structure. If @process is not NULL, the thread is added
 * to the linked list of threads for the given process.
 */
scheduler_tcb_t *scheduler_new_tcb(scheduler_pcb_t *process) {
	unsigned int frame = find_free_frame();
	set_frame(frame);

	frame *= 0x1000;
	frame += TCB_START;

	// allocate the memory for this structure
	uintptr_t phys = vm_allocate_phys();
	platform_pm_map(platform_pm_get_kernel_table(), frame, phys, VM_FLAGS_KERNEL);

	// allocate a thread struct
	scheduler_tcb_t *tcb = (scheduler_tcb_t *) frame;
	tcb->thread_id = scheduler_new_tid();

	// add it to the linked list of threads
	if(process) {
		scheduler_tcb_t *thread = process->thread;

		while(thread) {
			// next thread NULL?
			if(!thread->next) {
				thread->next = tcb;
				break;
			}

			// check the next thread
			thread = thread->next;
		}
	}

	return tcb;
}
示例#8
0
文件: scheduler.c 项目: UIKit0/pmk
/**
 * Creates a new process structure. This will have one thread created for it,
 * but with no information populated.
 */
scheduler_pcb_t *scheduler_new_process(void) {
	unsigned int frame = find_free_frame();
	set_frame(frame);

	frame *= 0x1000;
	frame += TCB_START;

	// allocate the memory for this structure
	uintptr_t phys = vm_allocate_phys();
	platform_pm_map(platform_pm_get_kernel_table(), frame, phys, VM_FLAGS_KERNEL);

	// allocate the process struct here
	scheduler_pcb_t *pcb = (scheduler_pcb_t *) frame;
	pcb->process_id = scheduler_new_pid();

	// allocate a TCB
	scheduler_tcb_t *tcb = scheduler_new_tcb(pcb);

	// initialise process struct
	pcb->thread = tcb;

	// initialise thread struct

	return pcb;
}
示例#9
0
void SubApplication::update(float dt)
{
    if (done)
        return;
    starting = false;
    Frame * old_frame = global_manager->frame;
    global_manager->frame = &subapp_frame;

    if (subapp_frame.next_frame != -1) {
        int next_frame = subapp_frame.next_frame;
        if (subapp_frame.index != -1)
            subapp_frame.on_end();
        global_manager->frame = old_frame;
        set_frame(next_frame);
        return;
    }

    bool ret = subapp_frame.update(dt);

    if (!ret)
        subapp_frame.on_end();

    global_manager->frame = old_frame;

    if (ret)
        return;
    done = true;
    set_visible(false);
}
示例#10
0
void AnimatedSprite::_res_changed() {

	set_frame(frame);
	_change_notify("frame");
	_change_notify("animation");
	update();
}
示例#11
0
文件: page.c 项目: Ted-Chang/matrix
void page_alloc(struct page *p, int flags)
{
	uint32_t idx;
	
	ASSERT(p != NULL);

	if (p->frame != 0) {
		DEBUG(DL_WRN, ("page(%p), frame(%x), flags(%d)\n",
			       p, p->frame, flags));
		PANIC("alloc page in use");
	} else {
		spinlock_acquire(&_pages_lock);
		/* Get the first free frame from our global frame set */
		idx = first_frame();
		if (idx == (uint32_t)(-1)) {
			PANIC("No free frames!\n");
		}
		/* Mark the frame address as being used */
		set_frame(idx * PAGE_SIZE);
		spinlock_release(&_pages_lock);

		p->present = 1;
		p->frame = idx;
	}

#ifdef _DEBUG_MM
	DEBUG(DL_DBG, ("page(%p), frame(%x).\n", p, p->frame));
#endif	/* _DEBUG_MM */
}
示例#12
0
文件: paging.c 项目: 0xb0fh/inix
static address_t pdir_set(size_t pfno)
{
	pde_t *pdir_boot;
	uint16_t pdir_idx;

	/* map the page number and set as allocated  */
	/* for SUPERVISOR  */
	set_frame(pfno, PAGE_SUPERV);
	pdir_boot = (pde_t *) (pfno << PAGE_SHIFT);

	/* pdir_boot = pdir; */
	pdir = pdir_boot;

	/* 1st 4MiB identically mapped */
	/* needs to be invalidated later */
	/* ptable_boot with no shift because is already aligned to a page boundary */
	*(pdir_boot++) = (address_t) ptable_boot | PDE_P | PDE_RW;

	for (pdir_idx = 1; pdir_idx < __phys_to_pfn(_start); pdir_idx++)
		*(pdir_boot++) = ~PDE_P;

	/* pdir[768] mapped to the first 4MiB of phys RAM */
	*(pdir_boot++) = (address_t) ptable_boot | PDE_P | PDE_RW;

	for (; pdir_idx < 1023; pdir_idx++)
		*(pdir_boot++) = ~PDE_P;

	*(pdir_boot++) = (address_t) pdir | PDE_P | PDE_RW;

	return (address_t) pdir_boot;
}
示例#13
0
void Screen::init_control (Control* par) {
    set_background (C_SCREEN_BACKGROUND);
    set_foreground (C_FOREGROUND);
    set_font_color (C_FOREGROUND);
    set_frame (0);
    reinitialize ();
}
示例#14
0
void initialize_paging(uint32_t memsize)
{
	nframes = memsize / 4;
	frames = (uint32_t *)kmalloc(INDEX_FROM_BIT(nframes));
	uintptr_t pg;

	assert(frames != NULL);

	memset(frames, 0, INDEX_FROM_BIT(nframes));

	uintptr_t physical;
	kernel_directory = (page_directory_t *)kmalloc_ap(sizeof(page_directory_t), &physical);
	memset(kernel_directory, 0, sizeof(page_directory_t));
	current_directory = kernel_directory;

#if 1
	get_page(0,1,kernel_directory)->present = 0;
	set_frame(0);

	for(uintptr_t i = 0x1000; i < placement_address+0x3000; i += 0x1000)
#else
	for(uintptr_t i = 0x0; i < placement_address+0x3000; i += 0x1000)
#endif
	{
		direct_frame( get_page(i, 1, kernel_directory), 1, 0, i);
	}
	
	kernel_directory->physical_addr = (uintptr_t)kernel_directory->tables_physical;

	uintptr_t heap_start = KERNEL_HEAP_START;

	if(heap_start <= placement_address + 0x3000)
	{
		heap_start = placement_address + 0x100000;
	}
	
	for (uintptr_t i = placement_address + 0x3000; i < heap_start; i += 0x1000)
	{
		alloc_frame(get_page(i, 1, kernel_directory), 1, 0);
	}

	for(uintptr_t i = heap_start; i < heap_start + KERNEL_HEAP_INIT; i += 0x1000)
	{
		get_page(i, 1, kernel_directory);
	}

	for(uintptr_t i = heap_start; i < heap_start + KERNEL_HEAP_INIT; i += 0x1000)
	{
		alloc_frame(get_page(i, 1, kernel_directory), 0, 0);
	}
	
	register_isr_handler(13, general_protection_fault);
	register_isr_handler(14, page_fault);	

	switch_page_directory(kernel_directory);

	kernel_heap = create_heap(heap_start, heap_start + KERNEL_HEAP_INIT, KERNEL_HEAP_END, 0, 0);
	//kernel_heap = create_heap(heap_start, KERNEL_HEAP_END, KERNEL_HEAP_END, 0, 0);
}
示例#15
0
/**
 * \brief Creates a single-frame tile pattern.
 * \param frame Coordinates of the single frame to make.
 */
TilePatternData::TilePatternData(const Rectangle& frame) :
    ground(Ground::TRAVERSABLE),
    default_layer(0),
    scrolling(TileScrolling::NONE),
    frames() {

  set_frame(frame);
}
示例#16
0
文件: Sprite.cpp 项目: Tkachov/Square
Sprite::Sprite(Controller* c, Frame f): Entity(c) {
 curframe=0;
 _counter=1;
 animspeed=1;
 _left=_top=_right=_bottom=0;

 set_frame(f);
}
示例#17
0
gun::Sprite::Sprite(const sf::Texture& texture, 
	const Animation& animation, double anim_speed)
	: sprite_(sf::Sprite(texture)), draw_order_(0), is_visible_(true), is_playing_(false), 
	is_looping_(false), anim_speed_(anim_speed), anim_index_(0)
{
	animations_.insert(std::pair<int, Animation>(anim_index_, animation));
	set_frame(0);
}
示例#18
0
void direct_frame(page_entry_t * page, int32_t is_kernel, int32_t is_writeable, uintptr_t addr)
{
	page->present = 1;
	page->rw = (is_writeable) ? 1 : 0;
	page->user = (is_kernel) ? 0 : 1;
	page->frame = addr / 0x1000;

	set_frame(addr);
}
示例#19
0
文件: pmm.c 项目: Nov11/jamesos
u32int alloc_frame()
{
	u32int idx = first_frame();
	if(idx == 0xffffffff){
		//full先这么着,换页的事儿后面再写
		PANIC("full");
	}
	u32int ret = idx * 0x1000;
	set_frame(ret);
	return ret;
}
示例#20
0
void AnimatedSprite::set_animation(const StringName &p_animation) {

	if (animation == p_animation)
		return;

	animation = p_animation;
	_reset_timeout();
	set_frame(0);
	_change_notify();
	update();
}
示例#21
0
void PicPreConfig::mousePressEvent( QMouseEvent *event ) {
    if ( event->button() == Qt::LeftButton ) {
        qDebug()<<"global"<<m_pt_press_global<<m_pt_press_global.x()<<m_pt_press_global.y()<<"event"<<event->x()<<event->y();
        if( event->x()>this->x() && event->x()<= this->x()+this->width() && event->y()>this->y() && event->y()<=this->y()+this->height() ) {
            set_frame( event );
        }
    }

    qDebug()<<"PicPreConfig::mousePressEvent( QMouseEvent *event )"<<"点击";


}
示例#22
0
int core_sweep(pid_t pid){
	KASSERT(pid != 0); // NEVER sweep kernel internal memory

	int count = 0;
	for (int i = 0; i < num_frames; i++){
		if (coremap_ptr[i].pid != pid) continue;
		set_frame(i, UNALLOCATED, 0,0);
		ZERO_OUT_FRAME(i);
		count++;
	}
	return count;
}
示例#23
0
ENV_type Environment_Extend_C(NIL_type)
  { ENV_type extended_environment;
    FRM_type frame;
    UNS_type scope,
             size;
    VEC_type extended_environment_vector;
    size = size_environment(Current_environment);
    size += 1;
    extended_environment_vector = Cache_Make_Vector_C(size);
    extended_environment = (ENV_type)extended_environment_vector;
    for (scope = 1;
         scope < size;
         scope += 1)
      { frame = get_frame(Current_environment,
                          scope);
        set_frame(extended_environment,
                  scope,
                  frame); }
    apply_MRK(Current_frame);
    set_frame(extended_environment,
              size,
              Current_frame);
    return extended_environment; }
示例#24
0
void xform_node_t::do_calc_hash_str( const render::context_t& context)
{
    motion_blur_info_t::loop_data_t d( motion_blur_loop_data( context.frame, context.motion_blur_extra_samples,
                                                              context.motion_blur_shutter_factor));

	hash_generator() << ( int) get_filter_type();

	if( d.num_samples == 1)
		param_set().add_to_hash( hash_generator());
	else
	{
		float t = d.start_time;
	
		for( int i = 0; i < d.num_samples; ++i)
		{
			set_frame( t);
			param_set().add_to_hash( hash_generator());
			t += d.time_step;
		}
	
		set_frame( context.frame);
	}
}
示例#25
0
rstbx::detector_model::sensor::sensor(
            const scitbx::vec3<double>& _origin,
            const scitbx::vec3<double>& _dir1,
            const scitbx::vec3<double>& _dir2,
            const scitbx::vec2<double>& _lim1,
            const scitbx::vec2<double>& _lim2):
    lim1(_lim1),
    lim2(_lim2),
    normal(),
    d(),
    D(),
    d_is_invertible(false)
{
    set_frame(_origin, _dir1, _dir2);
}
示例#26
0
void alloc_frame(struct page *page, int kernel, int writable)
{
	uint32_t idx;
	if (page->frame) return;
	else
	{
		idx = first_frame();
		if (idx == (uint32_t)-1)
			PANIC("No free frames!");
		set_frame(idx*PAGE_SIZ);
		page->present = 1;
		page->rw = writable;
		page->user = kernel;
		page->frame = idx;
	}
}
示例#27
0
void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {

	if (frames.is_valid())
		frames->disconnect("changed",this,"_res_changed");
	frames=p_frames;
	if (frames.is_valid())
		frames->connect("changed",this,"_res_changed");

	if (!frames.is_valid()) {
		frame=0;

	} else {
		set_frame(frame);
	}
	update();

}
示例#28
0
    GameManager() : scene(NULL)
    {
#ifdef DEBUG
        glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif
        glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 0);
        glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
        glfwOpenWindow(WINDOW_WIDTH, WINDOW_HEIGHT, 0, 0, 0, 0, 0, 0,
                       GLFW_WINDOW);
        glfwSetWindowTitle(NAME);
        glfwSwapInterval(0);

        // OpenGL settings
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        set_frame(0);
    }
示例#29
0
void gun::Sprite::PlayAnimation(int anim_index, bool is_looping)
{
	int old_anim_index = anim_index_;

	// If not playing an animation or playing a different animation...
	if (!is_playing_ || anim_index != anim_index_)
	{
		// Set playing to true, set if it should loop, and set the animation.
		is_playing_ = true;
		is_looping_ = is_looping;
		anim_index_ = anim_index;
	}

	if (anim_index != old_anim_index)
	{
		set_frame(0);
	}
}
示例#30
0
文件: pmm.c 项目: Nov11/jamesos
void init_pmm(u32int start, u32int end)
{	
	//32MB最多(25) 那就是8k个页(13 + 12) 256个u32int(8 + 5 + 12)
	//一个页面足够存了
	pmm_location = align(start);
	frames = (u32int*)pmm_location;
	memset(frames, 0, 0x1000);
	pmm_location += 0x1000;
	u32int iter;
	for(iter = 0; iter < pmm_location; iter += 0x100){
		set_frame(iter);
		nframes++;
	}
	for(iter = pmm_location; iter < end; iter += 0x100){
		free_frame(iter);
		nframes++;
	}
}