Пример #1
0
// NOTE: May have to overload with implementation dependant version
void ECPU8Bit::rts()
{
  ULONG ea=pullAddr()+1;
  jump(ea);
}
Пример #2
0
int game()
{
    scores = 0;
    int life = 3, obstacle_num = 1, life_bar = 800;
    //initwindow(1000, 600, "Man run cycle");
    cleardevice();
    outtextxy(50, 200, "Score:");
    //readimagefile("background//Road.jpg", 0, 553, 1000, 561);
    sndPlaySound("Files//Sound//Background.wav", SND_FILENAME | SND_ASYNC | SND_LOOP);
    readimagefile("Files//Images//background//aurora.jpg", 0, 0, 1000, 192);
    readimagefile("Files//Images//background//Life.jpg", 800, 200, 830, 225);
    readimagefile("Files//Images//background//Life.jpg", 860, 200, 890, 225);
    readimagefile("Files//Images//background//Life.jpg", 920, 200, 950, 225);
    for(i = 1; life; i++, r++)
    {
        sprintf(score, "%d", scores);
        outtextxy(100, 200, score);
        if((kbhit()))
        {
            a = getch();
            if(a == ' ')
            {
                random = jump(i, random);
                readimagefile("Files//Images//game character//black.jpg", 25, 270, 175, 442); // make jump image black
            }
        }

        else
        {
            if( random > -40 && random < 150)  // character er size
            {
                life--;
                readimagefile("Files//Images//obstacle//black.jpg", 175, 485, 305, 552);
                readimagefile("Files//Images//obstacle//black.jpg", 0, 485, 25, 552);
                readimagefile("Files//Images//game character//collided.jpg", 25, 380, 175, 552);
                readimagefile("Files//Images//background//Life end.jpg", life_bar, 200, life_bar + 30, 225);
                life_bar += 60;
                delay(700);
                random -= 300;
            }
            sprintf(img_obstacle, "Files//Images//obstacle//Obstacle %02d.jpg", obstacle);
            readimagefile(img_obstacle, random, 485, random + 130, 552);
            sprintf(img_game_chr, "Files//Images//game character//Untitled-%d.jpg", i);
            readimagefile(img_game_chr, 25, 380, 175, 552);
            sprintf(road, "Files//Images//road//sidebar%d.jpg", r);
            readimagefile(road, 0, 553, 1000, 561);
            i %= 14;
            r %= 6;
            random -= 20;
            if((random < - 600))
            {
                random = 1000;
                obstacle = rand() % 16;
                obstacle_num++;
                //printf("%d    %d\n", obstacle, dlay);
                if( !(obstacle_num % 3))
                {

                    if(obstacle_num == 6) // level up er jonno korsi.
                        break;
                    dlay -= 10;
                }
            }
            delay(dlay);
        }
    }
    // loop for walking the man from the screen
    if(life)
    {
        sndPlaySound("Files//Sound//Tada.wav", SND_FILENAME | SND_ASYNC);
        delay(1000);
        for(random = 25, i = 1; random < 1100; random += 10, i++)
        {
            sprintf(img_game_chr, "Files//Images//game character//Untitled-%d.jpg", i);
            readimagefile(img_game_chr, random, 380, random + 150, 552);
            readimagefile("Files//Images//game character//black.jpg",random - 151 , 380, random - 1, 552);
            i %= 14;
            delay(60);
        }
        return scores;
    }
    else
    {
        //scores = 0;
        sndPlaySound("Files//Sound//Game Over.wav", SND_FILENAME | SND_ASYNC);
        readimagefile("Files//Images//game character//collided.jpg", 25, 380, 175, 552);
        delay(1000);
        return 0;
    }
}
Пример #3
0
HyperDocPage *
parse_patch(PasteNode *paste)
{
    TextNode *new_paste;
    TextNode *end_node;
    TextNode *begin_node;
    TextNode *arg_node;
    TextNode *old;
    TextNode *next_node;
    InputItem *paste_item = paste->paste_item;
    int where = paste->where;
    GroupItem *g = paste->group;
    ItemStack *is = paste->item_stack;
    PatchStore *patch;
    char *patch_name;
    int ret_value = 1;

    /* prepare to throw away the current paste node */
    end_node = paste->end_node;
    next_node = end_node->next;
    begin_node = paste->begin_node;
    arg_node = paste->arg_node;
    old = begin_node->next;

    /* now read the new stuff and add it in between all this stuff */

    switch (where) {
      case openaxiom_FromFile_input:
        patch_name = print_to_string(arg_node);
        patch = (PatchStore *) hash_find(gWindow->fPatchHashTable, patch_name);
        if (!patch) {
            fprintf(stderr, "(HyperDoc) Unknown patch name %s\n", patch_name);
            BeepAtTheUser();
            return 0;
        }
        if (!patch->loaded)
            load_patch(patch);
        input_type = openaxiom_FromString_input;
        input_string = patch->string;
        break;
      case openaxiom_FromSpadSocket_input:
        input_type = openaxiom_FromSpadSocket_input;
        ret_value = issue_serverpaste(arg_node);
        if (ret_value < 0) {
            paste->where = where;
            paste->end_node = end_node;
            paste->arg_node = arg_node;
            paste->group = g;
            paste->item_stack = is;
            paste->haspaste = 1;
            return 0;
        }
        break;
      case openaxiom_FromUnixFD_input:
        input_type = openaxiom_FromUnixFD_input;
        issue_unixpaste(arg_node);
        break;
      default:
        fprintf(stderr, "(HyperDoc) \\parsebutton error: Unknown where\n");
        exit(-1);
        break;
    }

    paste->where = 0;
    paste->end_node = paste->arg_node = paste->begin_node = 0;
    paste->group = 0;
    paste->item_stack = 0;
    paste->haspaste = 0;
    paste->paste_item = 0;


    /* set the jump buffer in case it is needed */
    if (setjmp(jmpbuf)) {
        /*** OOOPS, an error occurred ****/
        fprintf(stderr, "(HyperDoc) Had an error parsing a patch: Goodbye!\n");
        exit(-1);
    }


    end_node->next = 0;
    free_node(old, 1);

    init_parse_patch(gWindow->page);
    init_paste_item(paste_item);
    get_token();
    if (token.type != openaxiom_Patch_token) {
        fprintf(stderr, "(HyperDoc) Pastebutton %s was expecting a patch\n",
                paste->name);
        jump();
    }
    if (input_type == openaxiom_FromString_input) {
        get_token();
        if (token.type != openaxiom_Lbrace_token) {
            token_name(token.type);
            fprintf(stderr, "(HyperDoc) Unexpected %s \n", ebuffer);
            print_page_and_filename();
            jump();
        }

        get_token();
        if (token.type != openaxiom_Word_token) {
            token_name(token.type);
            fprintf(stderr, "(HyperDoc) Unexpected %s \n", ebuffer);
            print_page_and_filename();
            jump();
        }

        get_token();
        if (token.type != openaxiom_Rbrace_token) {
            token_name(token.type);
            fprintf(stderr, "(HyperDoc) Unexpected %s \n", ebuffer);
            print_page_and_filename();
            jump();
        }
    }
    new_paste = alloc_node();
    curr_node = new_paste;
    parse_HyperDoc();

    /* Once I am back, I need only reallign all the text structures */
    curr_node->type = openaxiom_Noop_token;
    curr_node->next = next_node;
    begin_node->next = new_paste;
    begin_node->type = openaxiom_Noop_token;
    free(begin_node->data.text);
    begin_node->data.text = 0;

    gWindow->fDisplayedWindow = gWindow->fScrollWindow;

    repaste_item();

    paste_page(begin_node);

    /* so now I should just be able to disappear */
    return gWindow->page;
}
Пример #4
0
	/**
	 * Updates media playback state
     *
     * @param forceFrame If this is passed, the current frame for the video will be set accordingly
     * @param updateTexture If this is false (default), the player is updated but the new frame is not updated
     * in m_frameImg (nor in its texture) until the next call to getImage. With updateTexture set to true, the image and textures are updated if
     * there is a new frame regardless of teh getImage() call. The latter might be slower if you won't need or use the image or texture, but if for example
     * you are using the player just as a texture for an object that use it but don't need to draw the video on screen, you can pass updateTexture to true so that the
     * texture is always up to date.
	 */
	void MediaPlayerOCV::update( unsigned int forceFrame /*= -1*/, bool updateTexture /*= false*/ )
	{
		// Check if we have to loop
		if ( m_loopPending )
		{
			jump(0);
			m_loopPending = false;
		}
       	
		// Set the playhead and get new frame if we are in sigle thread mode
		if ( !m_multithreaded )
		{
            m_newBufferReady = false;
            
			double currentFrame = 0;
			if ( forceFrame != -1 )
			{
				currentFrame = forceFrame;
			}
			else
			{
				unsigned long millisPlayback = m_timer.getMilliseconds();
				currentFrame = ((double)millisPlayback/1000.0) * m_videoFps;
			}
        
        	//double currentActualFrame = m_capture.get(CV_CAP_PROP_POS_FRAMES);
        	//if ( currentFrame > currentActualFrame )
        	//{
           		m_capture.set(CV_CAP_PROP_POS_FRAMES, currentFrame);
        		//double currentActualFrame = m_capture.get(CV_CAP_PROP_POS_FRAMES);

            	// And grab new frame (it will be updated in the next call to getImage()
            	m_newBufferReady = m_capture.grab();
        	//}
        
        	// If we got a new frame
        	if ( m_newBufferReady )
        	{
            	m_currentFrame = currentFrame;
        
            	// Update image and texture if necessary
            	copyBufferIntoImage(updateTexture);
	        }
		}
        // We are in multithreaded mode
        else if ( m_newBufferReady )
        {
            // Update playhead
            unsigned long millisPlayback = m_timer.getMilliseconds();
			double currentFrame = ((double)millisPlayback/1000.0) * m_videoFps;
            
        	double currentActualFrame = m_capture.get(CV_CAP_PROP_POS_FRAMES);
            //LOG( "** Current = %f, current actual = %f", currentFrame, currentActualFrame);

        	if ( currentFrame > currentActualFrame )
        	{
                m_currentFrame = currentFrame;
                if (m_currentFrame >= m_videoNFrames)
                {
                    // Looping
                    if ( m_loop )
                    {
                        m_timer.reset();
                        m_currentFrame = 0;
                        m_capture.set( CV_CAP_PROP_POS_FRAMES, 0 );
                    }
                    // Not looping
                    else
                    {
                        m_playing = false;
                        m_currentFrame = 0;
                    }
                }
                
                if ( m_playing )
                    m_capture.set(CV_CAP_PROP_POS_FRAMES, m_currentFrame);
            }
            
            // Get new frames
            if ( m_playing )
            {
                copyFrameFromThread();
                if ( updateTexture )
                    m_frameImg.updateTexture();
            }
        }
        
		// Check loop
		if ( !m_multithreaded && (m_currentFrame >= m_videoNFrames) )
		{
			// Looping
			if ( m_loop )
			{
				m_timer.reset();
				m_currentFrame = 0;
                if ( m_multithreaded )
                {
                    //boost::mutex::scoped_lock lock(m_mutex);
                    m_capture.set( CV_CAP_PROP_POS_FRAMES, 0 );
                }
                else
                    m_capture.set( CV_CAP_PROP_POS_FRAMES, 0 );
			}
			// Not looping
			else 
			{
				m_playing = false;
				m_currentFrame = 0;
			}
			
		}
	}
Пример #5
0
void CharacterGame::keyEvent(Keyboard::KeyEvent evt, int key)
{
    if (evt == Keyboard::KEY_PRESS)
    {
        switch (key)
        {
        case Keyboard::KEY_ESCAPE:
            exit();
            break;
        case Keyboard::KEY_W:
        case Keyboard::KEY_CAPITAL_W:
            _keyFlags |= NORTH;
            _keyFlags &= ~SOUTH;
            break;
        case Keyboard::KEY_S:
        case Keyboard::KEY_CAPITAL_S:
            _keyFlags |= SOUTH;
            _keyFlags &= ~NORTH;
            break;
        case Keyboard::KEY_A:
        case Keyboard::KEY_CAPITAL_A:
            _keyFlags |= WEST;
            _keyFlags &= ~EAST;
            break;
        case Keyboard::KEY_D:
        case Keyboard::KEY_CAPITAL_D:
            _keyFlags |= EAST;
            _keyFlags &= ~WEST;
            break;
        case Keyboard::KEY_B:
            _drawDebug++;
            if (_drawDebug > 3)
                _drawDebug = 0;
            break;
        case Keyboard::KEY_SPACE:
            jump();
            break;
        case Keyboard::KEY_SHIFT:
            _keyFlags |= RUNNING;
            break;
        }
    }
    else if (evt == Keyboard::KEY_RELEASE)
    {
        switch (key)
        {
        case Keyboard::KEY_W:
        case Keyboard::KEY_CAPITAL_W:
            _keyFlags &= ~NORTH;
            break;
        case Keyboard::KEY_S:
        case Keyboard::KEY_CAPITAL_S:
            _keyFlags &= ~SOUTH;
            break;
        case Keyboard::KEY_A:
        case Keyboard::KEY_CAPITAL_A:
            _keyFlags &= ~WEST;
            break;
        case Keyboard::KEY_D:
        case Keyboard::KEY_CAPITAL_D:
            _keyFlags &= ~EAST;
            break;
        case Keyboard::KEY_SHIFT:
            _keyFlags &= ~RUNNING;
            break;
        }
    }
}
void JITCompiler::jumpFromSpeculativeToNonSpeculative(const SpeculationCheck& check, const EntryLocation& entry, SpeculationRecovery* recovery)
{
    ASSERT(check.m_nodeIndex == entry.m_nodeIndex);

    // Link the jump from the Speculative path to here.
    check.m_check.link(this);

    // Does this speculation check require any additional recovery to be performed,
    // to restore any state that has been overwritten before we enter back in to the
    // non-speculative path.
    if (recovery) {
        // The only additional recovery we currently support is for integer add operation
        ASSERT(recovery->type() == SpeculativeAdd);
        // Revert the add.
        sub32(gprToRegisterID(recovery->src()), gprToRegisterID(recovery->dest()));
    }

    // FIXME: - This is hideously inefficient!
    // Where a value is live in a register in the speculative path, and is required in a register
    // on the non-speculative path, we should not need to be spilling it and reloading (we may
    // need to spill anyway, if the value is marked as spilled on the non-speculative path).
    // This may also be spilling values that don't need spilling, e.g. are already spilled,
    // are constants, or are arguments.

    // Spill all GPRs in use by the speculative path.
    for (GPRReg gpr = gpr0; gpr < numberOfGPRs; next(gpr)) {
        NodeIndex nodeIndex = check.m_gprInfo[gpr].nodeIndex;
        if (nodeIndex == NoNode)
            continue;

        DataFormat dataFormat = check.m_gprInfo[gpr].format;
        VirtualRegister virtualRegister = graph()[nodeIndex].virtualRegister;

        ASSERT(dataFormat == DataFormatInteger || DataFormatCell || dataFormat & DataFormatJS);
        if (dataFormat == DataFormatInteger)
            orPtr(tagTypeNumberRegister, gprToRegisterID(gpr));
        storePtr(gprToRegisterID(gpr), addressFor(virtualRegister));
    }

    // Spill all FPRs in use by the speculative path.
    for (FPRReg fpr = fpr0; fpr < numberOfFPRs; next(fpr)) {
        NodeIndex nodeIndex = check.m_fprInfo[fpr];
        if (nodeIndex == NoNode)
            continue;

        VirtualRegister virtualRegister = graph()[nodeIndex].virtualRegister;

        moveDoubleToPtr(fprToRegisterID(fpr), regT0);
        subPtr(tagTypeNumberRegister, regT0);
        storePtr(regT0, addressFor(virtualRegister));
    }

    // Fill all FPRs in use by the non-speculative path.
    for (FPRReg fpr = fpr0; fpr < numberOfFPRs; next(fpr)) {
        NodeIndex nodeIndex = entry.m_fprInfo[fpr];
        if (nodeIndex == NoNode)
            continue;

        fillNumericToDouble(nodeIndex, fpr, gpr0);
    }

    // Fill all GPRs in use by the non-speculative path.
    for (GPRReg gpr = gpr0; gpr < numberOfGPRs; next(gpr)) {
        NodeIndex nodeIndex = entry.m_gprInfo[gpr].nodeIndex;
        if (nodeIndex == NoNode)
            continue;

        DataFormat dataFormat = entry.m_gprInfo[gpr].format;
        if (dataFormat == DataFormatInteger)
            fillInt32ToInteger(nodeIndex, gpr);
        else {
            ASSERT(dataFormat & DataFormatJS || dataFormat == DataFormatCell); // Treat cell as JSValue for now!
            fillToJS(nodeIndex, gpr);
            // FIXME: For subtypes of DataFormatJS, should jitAssert the subtype?
        }
    }

    // Jump into the non-speculative path.
    jump(entry.m_entry);
}
Пример #7
0
void JIT::compileLoadVarargs(Instruction* instruction)
{
    int thisValue = instruction[3].u.operand;
    int arguments = instruction[4].u.operand;
    int firstFreeRegister = instruction[5].u.operand;

    JumpList slowCase;
    JumpList end;
    bool canOptimize = m_codeBlock->usesArguments()
        && arguments == m_codeBlock->argumentsRegister()
        && !m_codeBlock->symbolTable()->slowArguments();

    if (canOptimize) {
        emitLoadTag(arguments, regT1);
        slowCase.append(branch32(NotEqual, regT1, TrustedImm32(JSValue::EmptyValueTag)));

        load32(payloadFor(JSStack::ArgumentCount), regT2);
        slowCase.append(branch32(Above, regT2, TrustedImm32(Arguments::MaxArguments + 1)));
        // regT2: argumentCountIncludingThis

        move(regT2, regT3);
        add32(TrustedImm32(firstFreeRegister + JSStack::CallFrameHeaderSize), regT3);
        lshift32(TrustedImm32(3), regT3);
        addPtr(callFrameRegister, regT3);
        // regT3: newCallFrame

        slowCase.append(branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT3));

        // Initialize ArgumentCount.
        store32(regT2, payloadFor(JSStack::ArgumentCount, regT3));

        // Initialize 'this'.
        emitLoad(thisValue, regT1, regT0);
        store32(regT0, Address(regT3, OBJECT_OFFSETOF(JSValue, u.asBits.payload) + (CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))));
        store32(regT1, Address(regT3, OBJECT_OFFSETOF(JSValue, u.asBits.tag) + (CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))));

        // Copy arguments.
        neg32(regT2);
        end.append(branchAdd32(Zero, TrustedImm32(1), regT2));
        // regT2: -argumentCount;

        Label copyLoop = label();
        load32(BaseIndex(callFrameRegister, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))), regT0);
        load32(BaseIndex(callFrameRegister, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))), regT1);
        store32(regT0, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))));
        store32(regT1, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))));
        branchAdd32(NonZero, TrustedImm32(1), regT2).linkTo(copyLoop, this);

        end.append(jump());
    }

    if (canOptimize)
        slowCase.link(this);

    JITStubCall stubCall(this, cti_op_load_varargs);
    stubCall.addArgument(thisValue);
    stubCall.addArgument(arguments);
    stubCall.addArgument(Imm32(firstFreeRegister));
    stubCall.call(regT3);

    if (canOptimize)
        end.link(this);
}
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
  const char *name;
  switch (type) {
    case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
    case T_BYTE:    name = "jni_fast_GetByteField";    break;
    case T_CHAR:    name = "jni_fast_GetCharField";    break;
    case T_SHORT:   name = "jni_fast_GetShortField";   break;
    case T_INT:     name = "jni_fast_GetIntField";     break;
    case T_LONG:    name = "jni_fast_GetLongField";    break;
    default:        ShouldNotReachHere();
  }
  ResourceMark rm;
  BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE);
  address fast_entry = b->instructions_begin();
  CodeBuffer cbuf(fast_entry, b->instructions_size());
  MacroAssembler* masm = new MacroAssembler(&cbuf);

  Label slow;

  ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
  __ mov32 (rcounter, counter);
  __ mov   (robj, c_rarg1);
  __ testb (rcounter, 1);
  __ jcc (Assembler::notZero, slow);
  if (os::is_MP()) {
    __ xorptr(robj, rcounter);
    __ xorptr(robj, rcounter);                   // obj, since
                                                // robj ^ rcounter ^ rcounter == robj
                                                // robj is data dependent on rcounter.
  }
  __ movptr(robj, Address(robj, 0));             // *obj
  __ mov   (roffset, c_rarg2);
  __ shrptr(roffset, 2);                         // offset

  assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
  speculative_load_pclist[count] = __ pc();
  switch (type) {
    case T_BOOLEAN: __ movzbl (rax, Address(robj, roffset, Address::times_1)); break;
    case T_BYTE:    __ movsbl (rax, Address(robj, roffset, Address::times_1)); break;
    case T_CHAR:    __ movzwl (rax, Address(robj, roffset, Address::times_1)); break;
    case T_SHORT:   __ movswl (rax, Address(robj, roffset, Address::times_1)); break;
    case T_INT:     __ movl   (rax, Address(robj, roffset, Address::times_1)); break;
    case T_LONG:    __ movq   (rax, Address(robj, roffset, Address::times_1)); break;
    default:        ShouldNotReachHere();
  }

  if (os::is_MP()) {
    __ lea(rcounter_addr, counter);
    // ca is data dependent on rax.
    __ xorptr(rcounter_addr, rax);
    __ xorptr(rcounter_addr, rax);
    __ cmpl (rcounter, Address(rcounter_addr, 0));
  } else {
    __ cmp32 (rcounter, counter);
  }
  __ jcc (Assembler::notEqual, slow);

  __ ret (0);

  slowcase_entry_pclist[count++] = __ pc();
  __ bind (slow);
  address slow_case_addr;
  switch (type) {
    case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
    case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
    case T_CHAR:    slow_case_addr = jni_GetCharField_addr();    break;
    case T_SHORT:   slow_case_addr = jni_GetShortField_addr();   break;
    case T_INT:     slow_case_addr = jni_GetIntField_addr();     break;
    case T_LONG:    slow_case_addr = jni_GetLongField_addr();
  }
  // tail call
  __ jump (ExternalAddress(slow_case_addr));

  __ flush ();

  return fast_entry;
}
Пример #9
0
int main() {
	REG_DISPCTL = MODE3 | BG2_ENABLE;


    while(1) {
        died = 0;
        drawImage3(0,0,TITLESCREEN_WIDTH,TITLESCREEN_HEIGHT,titleScreen);
        if (KEY_DOWN_NOW(BUTTON_START)) {    
            CHARACTER character = mario;
            mario.col = 50;
            QUESTIONBLOCK questionBlocks[] = {questionBlock1,questionBlock2};
            int numBlocks = 2;
            ENEMY enemies[] = {goomba1,goomba2,goomba3,goomba4};
            int numEnemies = 4;
            int jumpHeight = 0;
            levelColLeft = 0;
            levelColRight = 240;
            backgroundCol = 0;
            backgroundCount = 0;
            lives = 3;
            coins = 0;
            flag.col = 500;
            drawMenuIcons();
	        while(1) {
                character.atBoundary = 0;
                if (KEY_DOWN_NOW(BUTTON_SELECT)) { break; }
                if (KEY_DOWN_NOW(BUTTON_LEFT)) {
                    moveLeft(&character,questionBlocks,numBlocks,enemies,numEnemies);
                }
                if (KEY_DOWN_NOW(BUTTON_RIGHT)) {
                    moveRight(&character,questionBlocks,numBlocks,enemies,numEnemies);
                }
                if (KEY_DOWN_NOW(BUTTON_A) && !character.jumpingUp && !character.fallingDown) {
                    character.jumpingUp = 1;
                    character.fallingDown = 0;
                    int *rowPtr;
                    rowPtr = (int *) malloc(sizeof(int));
                    *rowPtr = character.row;
                    jumpHeight = *rowPtr - 2 * character.height[character.mode] + 7;
                }
                if (character.jumpingUp) {
                    jump(&character,jumpHeight,questionBlocks,numBlocks);
                } else if (character.fallingDown) {
                    fall(&character,enemies,numEnemies);
                }
		        WaitForVblank();
                if (character.atBoundary && character.direction == 0) {
                    scrollBackgroundRight();
                    int b;
                    for (b = 0; b < numBlocks; b++) {
                        questionBlocks[b].col -= 1;
                        int screenCol = questionBlocks[b].col - levelColLeft;
                        if (questionBlocks[b].col > levelColLeft && questionBlocks[b].col + questionBlocks[b].width < levelColRight) {
                            drawImage3(questionBlocks[b].row,screenCol,questionBlocks[b].width,
                                questionBlocks[b].height,questionBlocks[b].images[questionBlocks[b].mode]);
                        }
                    }
                    int e;
                    for (e = 0; e < numEnemies; e++) {
                        enemies[e].col -= 1;
                        int screenCol = enemies[e].col - levelColLeft;
                        if (enemies[e].isDead == 0 && enemies[e].col > levelColLeft && enemies[e].col + enemies[e].width < levelColRight) {
                            drawImage3(enemies[e].row,screenCol,enemies[e].width, enemies[e].height,
                                enemies[e].images[enemies[e].mode]);
                        }
                    }
                    flag.col -= 1;
                    int screenCol = flag.col - levelColLeft;
                    if (flag.col > levelColLeft && flag.col + flag.width < levelColRight) {
                        drawImage3(flag.row,screenCol,flag.width,flag.height,flagpole);
                    }
                } else if (character.atBoundary && character.direction == 1) {
                    scrollBackgroundLeft();
                    int b;
                    for (b = 0; b < numBlocks; b++) {
                        questionBlocks[b].col += 1;
                        int screenCol = questionBlocks[b].col - levelColLeft;
                        if (questionBlocks[b].col > levelColLeft && questionBlocks[b].col + questionBlocks[b].width < levelColRight) {
                            drawImage3(questionBlocks[b].row,screenCol,questionBlocks[b].width,
                                questionBlocks[b].height,questionBlocks[b].images[questionBlocks[b].mode]);
                        }
                    }
                    int e;
                    for (e = 0; e < numEnemies; e++) {
                        enemies[e].col += 1;
                        int screenCol = enemies[e].col - levelColLeft;
                        if (enemies[e].isDead == 0 && enemies[e].col > levelColLeft && enemies[e].col + enemies[e].width < levelColRight) {
                            drawImage3(enemies[e].row,screenCol,enemies[e].width, enemies[e].height,
                                enemies[e].images[enemies[e].mode]);
                        }
                    }
                    flag.col += 1;
                    int screenCol = flag.col - levelColLeft;
                    if (flag.col > levelColLeft && flag.col + flag.width < levelColRight) {
                        drawImage3(flag.row,screenCol,flag.width,flag.height,flagpole);
                    }
                } else {
                    drawBackground();
                    int b;
                    for (b = 0; b < numBlocks; b++) {
                        int screenCol = questionBlocks[b].col - levelColLeft;
                        if (questionBlocks[b].col > levelColLeft && questionBlocks[b].col + questionBlocks[b].width < levelColRight) {
                            drawImage3(questionBlocks[b].row,screenCol,questionBlocks[b].width,
                                questionBlocks[b].height,questionBlocks[b].images[questionBlocks[b].mode]);
                        }
                    }
                    int e;
                    for (e = 0; e < numEnemies; e++) {
                        int screenCol = enemies[e].col - levelColLeft;
                        if (enemies[e].isDead == 0 && enemies[e].col > levelColLeft && enemies[e].col + enemies[e].width < levelColRight) {
                            drawImage3(enemies[e].row,screenCol,enemies[e].width, enemies[e].height,
                                enemies[e].images[enemies[e].mode]);
                        }
                    }
                    int screenCol = flag.col - levelColLeft;
                    if (flag.col > levelColLeft && flag.col + flag.width < levelColRight) {
                        drawImage3(flag.row,screenCol,flag.width,flag.height,flagpole);
                    }
                }
                
                drawImage3(character.row,character.col,character.width[character.mode],
                    character.height[character.mode],character.images[character.mode]);
                if (lives < 0) { 
                    died = 1;                    
                    break; 
                }
                if (character.col > flag.col - levelColLeft) {
                    died = 0;
                    break;
                }
	            updateVars();
	        }
            if (died == 1) {
                while (1) {
                    drawImage3(0,0,GAMEOVER_WIDTH,GAMEOVER_HEIGHT,gameOver);
                    if (KEY_DOWN_NOW(BUTTON_START) || KEY_DOWN_NOW(BUTTON_SELECT)) {
                        break;
                    }
                }        
            } else if (died == 0) {
                drawRect(0,0,20,240,BLACK);
                char levelComplete[50] = "Level Complete!\0";
                drawString(5,78,levelComplete,RED);
                while (1) {
                    if (KEY_DOWN_NOW(BUTTON_START) || KEY_DOWN_NOW(BUTTON_SELECT)) {
                        break;
                    }
                }
            }
        }  
    }
}
Пример #10
0
Player::Player(QWidget *parent)
    : QWidget(parent)
    , videoWidget(0)
    , coverLabel(0)
    , slider(0)
    , colorDialog(0)
{
    player = new QMediaPlayer(this);
    playlist = new QMediaPlaylist(this);
    playlist->setMediaObject(player);

    connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
    connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
    connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
    connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));

    videoWidget = new VideoWidget;
    videoWidget->setMediaObject(player);

    playlistModel = new PlaylistModel(this);
    playlistModel->setPlaylist(playlist);

    playlistView = new QListView;
    playlistView->setModel(playlistModel);
    playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0));

    connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex)));

    playbackModeBox = new QComboBox;
    playbackModeBox->addItem(tr("Linear"),
                             QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Linear));
    playbackModeBox->addItem(tr("Loop"),
                             QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Loop));
    playbackModeBox->addItem(tr("Random"),
                             QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Random));
    playbackModeBox->addItem(tr("Current Item Once"),
                             QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::CurrentItemOnce));
    playbackModeBox->addItem(tr("Current Item In Loop"),
                             QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::CurrentItemInLoop));
    playbackModeBox->setCurrentIndex(0);

    connect(playbackModeBox, SIGNAL(activated(int)), SLOT(updatePlaybackMode()));
    updatePlaybackMode();

    slider = new QSlider(Qt::Horizontal);
    slider->setRange(0, player->duration() / 1000);

    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));

    QPushButton *openButton = new QPushButton(tr("Open"));

    connect(openButton, SIGNAL(clicked()), this, SLOT(open()));

    PlayerControls *controls = new PlayerControls;
    controls->setState(player->state());
    controls->setVolume(player->volume());
    controls->setMuted(controls->isMuted());

    connect(controls, SIGNAL(play()), player, SLOT(play()));
    connect(controls, SIGNAL(pause()), player, SLOT(pause()));
    connect(controls, SIGNAL(stop()), player, SLOT(stop()));
    connect(controls, SIGNAL(next()), playlist, SLOT(next()));
    connect(controls, SIGNAL(previous()), this, SLOT(previousClicked()));
    connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
    connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool)));
    connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));

    connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
            controls, SLOT(setState(QMediaPlayer::State)));
    connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int)));
    connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool)));

    QPushButton *fullScreenButton = new QPushButton(tr("FullScreen"));
    fullScreenButton->setCheckable(true);

    if (videoWidget != 0) {
        connect(fullScreenButton, SIGNAL(clicked(bool)), videoWidget, SLOT(setFullScreen(bool)));
        connect(videoWidget, SIGNAL(fullScreenChanged(bool)),
                fullScreenButton, SLOT(setChecked(bool)));
    } else {
        fullScreenButton->setEnabled(false);
    }

    QPushButton *colorButton = new QPushButton(tr("Color Options..."));
    if (videoWidget)
        connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
    else
        colorButton->setEnabled(false);

    QBoxLayout *playlistLayout = new QVBoxLayout;
    playlistLayout->addWidget(playlistView);
    playlistLayout->addWidget(playbackModeBox);

    QBoxLayout *displayLayout = new QHBoxLayout;
    if (videoWidget)
        displayLayout->addWidget(videoWidget, 2);
    else
        displayLayout->addWidget(coverLabel, 2);
    displayLayout->addLayout(playlistLayout);

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addStretch(1);
    controlLayout->addWidget(controls);
    controlLayout->addStretch(1);
    controlLayout->addWidget(fullScreenButton);
    controlLayout->addWidget(colorButton);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(displayLayout);
    layout->addWidget(slider);
    layout->addLayout(controlLayout);

    setLayout(layout);

    metaDataChanged();

    QStringList arguments = qApp->arguments();
    arguments.removeAt(0);
    foreach (QString const &argument, arguments) {
        QFileInfo fileInfo(argument);
        if (fileInfo.exists()) {
            QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
            if (fileInfo.suffix().toLower() == QLatin1String("m3u")) {
                playlist->load(url);
            } else
                playlist->addMedia(url);
        } else {
            QUrl url(argument);
            if (url.isValid()) {
                playlist->addMedia(url);
            }
        }
    }
Пример #11
0
void JITCompiler::compileFunction()
{
    setStartOfCode();
    compileEntry();

    // === Function header code generation ===
    // This is the main entry point, without performing an arity check.
    // If we needed to perform an arity check we will already have moved the return address,
    // so enter after this.
    Label fromArityCheck(this);
    // Plant a check that sufficient space is available in the JSStack.
    addPtr(TrustedImm32(virtualRegisterForLocal(m_graph.requiredRegisterCountForExecutionAndExit() - 1).offset() * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
    Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfStackLimit()), GPRInfo::regT1);

    // Move the stack pointer down to accommodate locals
    addPtr(TrustedImm32(m_graph.stackPointerOffset() * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister);
    checkStackPointerAlignment();

    compileSetupRegistersForEntry();
    compileEntryExecutionFlag();

    // === Function body code generation ===
    m_speculative = std::make_unique<SpeculativeJIT>(*this);
    compileBody();
    setEndOfMainPath();

    // === Function footer code generation ===
    //
    // Generate code to perform the stack overflow handling (if the stack check in
    // the function header fails), and generate the entry point with arity check.
    //
    // Generate the stack overflow handling; if the stack check in the function head fails,
    // we need to call out to a helper function to throw the StackOverflowError.
    stackOverflow.link(this);

    emitStoreCodeOrigin(CodeOrigin(0));

    if (maxFrameExtentForSlowPathCall)
        addPtr(TrustedImm32(-maxFrameExtentForSlowPathCall), stackPointerRegister);

    m_speculative->callOperationWithCallFrameRollbackOnException(operationThrowStackOverflowError, m_codeBlock);
    
    // The fast entry point into a function does not check the correct number of arguments
    // have been passed to the call (we only use the fast entry point where we can statically
    // determine the correct number of arguments have been passed, or have already checked).
    // In cases where an arity check is necessary, we enter here.
    // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions).
    m_arityCheck = label();
    compileEntry();

    load32(AssemblyHelpers::payloadFor((VirtualRegister)JSStack::ArgumentCount), GPRInfo::regT1);
    branch32(AboveOrEqual, GPRInfo::regT1, TrustedImm32(m_codeBlock->numParameters())).linkTo(fromArityCheck, this);
    emitStoreCodeOrigin(CodeOrigin(0));
    if (maxFrameExtentForSlowPathCall)
        addPtr(TrustedImm32(-maxFrameExtentForSlowPathCall), stackPointerRegister);
    m_speculative->callOperationWithCallFrameRollbackOnException(m_codeBlock->m_isConstructor ? operationConstructArityCheck : operationCallArityCheck, GPRInfo::regT0);
    if (maxFrameExtentForSlowPathCall)
        addPtr(TrustedImm32(maxFrameExtentForSlowPathCall), stackPointerRegister);
    branchTest32(Zero, GPRInfo::returnValueGPR).linkTo(fromArityCheck, this);
    emitStoreCodeOrigin(CodeOrigin(0));
    move(GPRInfo::returnValueGPR, GPRInfo::argumentGPR0);
    m_callArityFixup = call();
    jump(fromArityCheck);
    
    // Generate slow path code.
    m_speculative->runSlowPathGenerators(m_pcToCodeOriginMapBuilder);
    m_pcToCodeOriginMapBuilder.appendItem(label(), PCToCodeOriginMapBuilder::defaultCodeOrigin());
    
    compileExceptionHandlers();
    linkOSRExits();
    
    // Create OSR entry trampolines if necessary.
    m_speculative->createOSREntries();
    setEndOfCode();

    // === Link ===
    auto linkBuffer = std::make_unique<LinkBuffer>(*m_vm, *this, m_codeBlock, JITCompilationCanFail);
    if (linkBuffer->didFailToAllocate()) {
        m_graph.m_plan.finalizer = std::make_unique<FailedFinalizer>(m_graph.m_plan);
        return;
    }
    link(*linkBuffer);
    m_speculative->linkOSREntries(*linkBuffer);
    
    m_jitCode->shrinkToFit();
    codeBlock()->shrinkToFit(CodeBlock::LateShrink);
    
    linkBuffer->link(m_callArityFixup, FunctionPtr((m_vm->getCTIStub(arityFixupGenerator)).code().executableAddress()));
    
    disassemble(*linkBuffer);

    MacroAssemblerCodePtr withArityCheck = linkBuffer->locationOf(m_arityCheck);

    m_graph.m_plan.finalizer = std::make_unique<JITFinalizer>(
        m_graph.m_plan, m_jitCode.release(), WTFMove(linkBuffer), withArityCheck);
}
Пример #12
0
void
parse_radioboxes(void)
{
  TextNode *return_node = curr_node;
  RadioBoxes *newrb;
  char *fname;

  /* I really don't need this node, it just sets up some parsing stuff */
  return_node->type = openaxiom_Noop_token;

  newrb = alloc_rbs();

  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "\\radioboxes was expecting a name not %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }

  newrb->name = alloc_string(get_input_string());

  /* quick search for the name in the current list */
  if (already_there(newrb->name)) {
    free(newrb->name);
    free(newrb);
    fprintf(stderr, "Tried to redefine radioboxes %s\n", newrb->name);
    print_page_and_filename();
    jump();
  }
  /* now I have to get the selected and unslected bitmaps */
  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "\\radioboxes was expecting a name not %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }
  fname = get_input_string();
  if (!make_input_file)
    newrb->selected = insert_image_struct(fname);

  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "\\radioboxes was expecting a name not %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }
  fname = get_input_string();
  if (!make_input_file) {
    newrb->unselected = insert_image_struct(fname);
    newrb->height = max(newrb->selected->height, newrb->unselected->height);
    newrb->width = max(newrb->selected->width, newrb->unselected->width);
    /* now add the thing to the current list of radio boxes */
  }
  newrb->next = gPageBeingParsed->radio_boxes;
  gPageBeingParsed->radio_boxes = newrb;

  curr_node = return_node;
  return;
}
Пример #13
0
void
parse_radiobox(void)
{
  InputBox *box;
  char *name;
  char *group_name;
  short int picked = 0;
  TextNode *input_box = curr_node;

  gStringValueOk = 0;

  /* set the type and space fields  */
  input_box->type = openaxiom_Radiobox_token;
  input_box->space = token.id[-1];

  /* IS it selected? */
  get_token();
  if (token.type == openaxiom_Lsquarebrace_token) {
    get_expected_token(openaxiom_Word_token);
    if (!is_number(token.id)) {
      fprintf(stderr,
              "parse_simple_box: Expected a value not %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    else if (!strcmp(token.id, "1"))
      picked = 1;
    else if (!strcmp(token.id, "0"))
      picked = 0;
    else {
      fprintf(stderr, "parse_simple_box: Unexpected Value %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    get_expected_token(openaxiom_Rsquarebrace_token);
    get_token();
  }

  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "parse_inputbox was expecting a { not a %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }

  name = get_input_string();
  if (gPageBeingParsed->box_hash && hash_find(gPageBeingParsed->box_hash, name)) {
    fprintf(stderr, "Input box name %s is not unique \n", name);
    print_page_and_filename();
    jump();
  }

  box = alloc_inputbox();
  box->name = alloc_string(name);
  input_box->data.text = alloc_string(name);
  box->picked = picked;

  /* Now what I need to do is get the group name */
  get_token();
  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "parse_inputbox was expecting a { not a %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }
  group_name = get_input_string();

  /*
   * Now call a routine which searches the radio box list for the current
   * group name, and if found adds this box to it
   */
  add_box_to_rb_list(group_name, box);

  input_box->width = box->rbs->width;
  input_box->height = box->rbs->height;
  /* Make the window and stuff */
  input_box->link = make_box_window(box, openaxiom_Radiobox_token);
  if (!make_input_file)
    box->win = input_box->link->win;        /* TTT */


  /* Now add the box to the box_has table for this window */
  if (gPageBeingParsed->box_hash == NULL) {
    gPageBeingParsed->box_hash = (HashTable *) halloc(sizeof(HashTable),
                                                      "Box Hash");
    hash_init(
              gPageBeingParsed->box_hash, 
              BoxHashSize, 
              (EqualFunction) string_equal, 
              (HashcodeFunction) string_hash);
  }
  hash_insert(gPageBeingParsed->box_hash, (char *)box, box->name);

  /* reset the curr_node and then return */
  curr_node = input_box;
  gStringValueOk = 1;
  return;
}
Пример #14
0
void
parse_simplebox(void)
{
  InputBox *box;
  char *name;
  short int picked = 0;
  char *filename;
  TextNode *input_box = curr_node;

  gStringValueOk = 0;

  /* set the type and space fields  */
  input_box->type = openaxiom_SimpleBox_token;
  input_box->space = token.id[-1];

  /* IS it selected? */
  get_token();
  if (token.type == openaxiom_Lsquarebrace_token) {
    get_expected_token(openaxiom_Word_token);
    if (!is_number(token.id)) {
      fprintf(stderr,
              "parse_simple_box: Expected a value not %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    else if (!strcmp(token.id, "1"))
      picked = 1;
    else if (!strcmp(token.id, "0"))
      picked = 0;
    else {
      fprintf(stderr, "parse_simple_box: Unexpected Value %s\n", token.id);
      print_page_and_filename();
      jump();
    }
    get_expected_token(openaxiom_Rsquarebrace_token);
    get_token();
  }

  if (token.type != openaxiom_Lbrace_token) {
    token_name(token.type);
    fprintf(stderr, "parse_inputbox was expecting a { not a %s\n", ebuffer);
    print_page_and_filename();
    jump();
  }

  name = get_input_string();
  if (gPageBeingParsed->box_hash && hash_find(gPageBeingParsed->box_hash, name)) {
    fprintf(stderr, "Input box name %s is not unique \n", name);
    print_page_and_filename();
    jump();
  }

  box = alloc_inputbox();
  box->name = alloc_string(name);
  input_box->data.text = alloc_string(name);
  box->picked = picked;

  /* Get the filename for the selected and unselected bitmaps */
  get_expected_token(openaxiom_Lbrace_token);
  filename = get_input_string();
  if (!make_input_file)
    box->selected = insert_image_struct(filename);
  get_expected_token(openaxiom_Lbrace_token);
  filename = get_input_string();
  if (!make_input_file) {
    box->unselected = insert_image_struct(filename);
    /* set the width and height for the maximaum of the two */
    input_box->height = max(box->selected->height, box->unselected->height);
    input_box->width = max(box->selected->width, box->unselected->width);
    /* Make the window and stuff */
    input_box->link = make_box_window(box, openaxiom_SimpleBox_token);
    box->win = input_box->link->win;

    /* Now add the box to the box_has table for this window */
    if (gPageBeingParsed->box_hash == NULL) {
      gPageBeingParsed->box_hash = (HashTable *) halloc(sizeof(HashTable),
                                                        "Box Hash");
      hash_init(
                gPageBeingParsed->box_hash, 
                BoxHashSize, 
                (EqualFunction) string_equal, 
                (HashcodeFunction) string_hash);
    }
    hash_insert(gPageBeingParsed->box_hash, (char *)box, box->name);
  }

  /* reset the curr_node and then return */
  curr_node = input_box;
  gStringValueOk = 1;
  return;
}
bool JITCompiler::compileFunction(JITCode& entry, MacroAssemblerCodePtr& entryWithArityCheck)
{
    SamplingRegion samplingRegion("DFG Backend");
    
    setStartOfCode();
    compileEntry();

    // === Function header code generation ===
    // This is the main entry point, without performing an arity check.
    // If we needed to perform an arity check we will already have moved the return address,
    // so enter after this.
    Label fromArityCheck(this);
    // Plant a check that sufficient space is available in the JSStack.
    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291
    addPtr(TrustedImm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
    Jump stackCheck = branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), GPRInfo::regT1);
    // Return here after stack check.
    Label fromStackCheck = label();


    // === Function body code generation ===
    SpeculativeJIT speculative(*this);
    compileBody(speculative);
    setEndOfMainPath();

    // === Function footer code generation ===
    //
    // Generate code to perform the slow stack check (if the fast one in
    // the function header fails), and generate the entry point with arity check.
    //
    // Generate the stack check; if the fast check in the function head fails,
    // we need to call out to a helper function to check whether more space is available.
    // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions).
    stackCheck.link(this);
    move(stackPointerRegister, GPRInfo::argumentGPR0);
    poke(GPRInfo::callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));

    CallBeginToken token;
    beginCall(CodeOrigin(0), token);
    Call callStackCheck = call();
    notifyCall(callStackCheck, CodeOrigin(0), token);
    jump(fromStackCheck);
    
    // The fast entry point into a function does not check the correct number of arguments
    // have been passed to the call (we only use the fast entry point where we can statically
    // determine the correct number of arguments have been passed, or have already checked).
    // In cases where an arity check is necessary, we enter here.
    // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions).
    Label arityCheck = label();
    compileEntry();

    load32(AssemblyHelpers::payloadFor((VirtualRegister)JSStack::ArgumentCount), GPRInfo::regT1);
    branch32(AboveOrEqual, GPRInfo::regT1, TrustedImm32(m_codeBlock->numParameters())).linkTo(fromArityCheck, this);
    move(stackPointerRegister, GPRInfo::argumentGPR0);
    poke(GPRInfo::callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));
    beginCall(CodeOrigin(0), token);
    Call callArityCheck = call();
    notifyCall(callArityCheck, CodeOrigin(0), token);
    move(GPRInfo::regT0, GPRInfo::callFrameRegister);
    jump(fromArityCheck);
    
    // Generate slow path code.
    speculative.runSlowPathGenerators();
    
    compileExceptionHandlers();
    linkOSRExits();
    
    // Create OSR entry trampolines if necessary.
    speculative.createOSREntries();
    setEndOfCode();

    // === Link ===
    LinkBuffer linkBuffer(*m_vm, this, m_codeBlock, JITCompilationCanFail);
    if (linkBuffer.didFailToAllocate())
        return false;
    link(linkBuffer);
    speculative.linkOSREntries(linkBuffer);
    
    // FIXME: switch the stack check & arity check over to DFGOpertaion style calls, not JIT stubs.
    linkBuffer.link(callStackCheck, cti_stack_check);
    linkBuffer.link(callArityCheck, m_codeBlock->m_isConstructor ? cti_op_construct_arityCheck : cti_op_call_arityCheck);
    
    if (shouldShowDisassembly())
        m_disassembler->dump(linkBuffer);
    if (m_graph.m_compilation)
        m_disassembler->reportToProfiler(m_graph.m_compilation.get(), linkBuffer);

    entryWithArityCheck = linkBuffer.locationOf(arityCheck);
    entry = JITCode(
        linkBuffer.finalizeCodeWithoutDisassembly(),
        JITCode::DFGJIT);
    return true;
}
Пример #16
0
int
main (void)
{
  int value;

  value = setjmp (env);
  if (value != last_value + 1)
    {
      fputs("Shouldn't have ", stdout);
      lose = 1;
    }
  last_value = value;
  switch (value)
    {
    case 0:
      puts("Saved environment.");
      jump (0);
    default:
      printf ("Jumped to %d.\n", value);
      if (value < 10)
	jump (value + 1);
    }

  if (!lose && value == 10)
    {
      /* Do a second test, this time without `setjmp' being a macro.
         This is not required by ISO C but we have this for compatibility.  */
#undef setjmp
      extern int setjmp (jmp_buf);

      last_value = -1;
      lose = 0;

      value = setjmp (env);
      if (value != last_value + 1)
	{
	  fputs("Shouldn't have ", stdout);
	  lose = 1;
	}
      last_value = value;
      switch (value)
	{
	case 0:
	  puts("Saved environment.");
	  jump (0);
	default:
	  printf ("Jumped to %d.\n", value);
	  if (value < 10)
	    jump (value + 1);
	}
    }

  if (!lose && value == 10)
    {
      /* And again for the `_setjmp' function.  */
#ifndef _setjmp
      extern int _setjmp (jmp_buf);
#endif
      last_value = -1;
      lose = 0;

      value = _setjmp (env);
      if (value != last_value + 1)
	{
	  fputs("Shouldn't have ", stdout);
	  lose = 1;
	}
      last_value = value;
      switch (value)
	{
	case 0:
	  puts("Saved environment.");
	  jump (0);
	default:
	  printf ("Jumped to %d.\n", value);
	  if (value < 10)
	    jump (value + 1);
	}
    }

  if (lose || value != 10)
    puts ("Test FAILED!");
  else
    puts ("Test succeeded!");

  return lose ? EXIT_FAILURE : EXIT_SUCCESS;
}
Пример #17
0
void Player::update(float dt)
{
    move(dt);
    jump(dt);
}
Пример #18
0
void IngameState::handlePlayerInput(const SDL_Event& event)
{
	auto player = game->getPlayer();
	switch(event.type) {
	case SDL_KEYDOWN:
		switch(event.key.keysym.sym) {
		case SDLK_SPACE:
			if( player->getCharacter()->getCurrentVehicle() ) {
				player->getCharacter()->getCurrentVehicle()->setHandbraking(true);
			}
			else
			{
				player->jump();
			}
			break;
		case SDLK_f:
			if( player->getCharacter()->getCurrentVehicle()) {
				player->exitVehicle();
			}
			else
				if (player->isCurrentActivity(
							Activities::EnterVehicle::ActivityName))
			{
				// Give up entering a vehicle if we're alreadying doing so
				player->skipActivity();
			}
			else {
				player->enterNearestVehicle();
			}
			break;
		case SDLK_LSHIFT:
			player->setRunning(true);
			break;
		default:
			break;
		}
		break;

	case SDL_KEYUP:
		switch (event.key.keysym.sym) {
		case SDLK_LSHIFT:
			player->setRunning(false);
			break;
		default: break;
		}
		break;

	case SDL_MOUSEBUTTONDOWN:
		switch(event.button.button) {
		case SDL_BUTTON_LEFT:
			player->getCharacter()->useItem(true, true);
			break;
		default: break;
		}
		break;
	case SDL_MOUSEBUTTONUP:
		switch(event.button.button) {
		case SDL_BUTTON_LEFT:
			player->getCharacter()->useItem(false, true);
			break;
		default: break;
		}
		break;
	case SDL_MOUSEWHEEL:
		player->getCharacter()->cycleInventory(event.wheel.y > 0);
		break;
	case SDL_MOUSEMOTION:
		if (game->hasFocus())
		{
			glm::ivec2 screenSize = getWindow().getSize();
			glm::vec2 mouseMove(event.motion.xrel / static_cast<float>(screenSize.x),
			                    event.motion.yrel / static_cast<float>(screenSize.y));

			autolookTimer = kAutoLookTime;
			if (!m_invertedY) {
				mouseMove.y = -mouseMove.y;
			}
			m_cameraAngles += glm::vec2(mouseMove.x, mouseMove.y);
			m_cameraAngles.y = glm::clamp(m_cameraAngles.y, kCameraPitchLimit, glm::pi<float>() - kCameraPitchLimit);
		}
		break;
	default:
		break;
	}
}
void JITCompiler::compileFunction(JITCode& entry, MacroAssemblerCodePtr& entryWithArityCheck)
{
    // === Stage 1 - Function header code generation ===
    //
    // This code currently matches the old JIT. In the function header we need to
    // pop the return addres (since we do not allow any recursion on the machine
    // stack), and perform a fast register file check.

    // This is the main entry point, without performing an arity check.
    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56292
    // We'll need to convert the remaining cti_ style calls (specifically the register file
    // check) which will be dependant on stack layout. (We'd need to account for this in
    // both normal return code and when jumping to an exception handler).
    preserveReturnAddressAfterCall(regT2);
    emitPutToCallFrameHeader(regT2, RegisterFile::ReturnPC);
    // If we needed to perform an arity check we will already have moved the return address,
    // so enter after this.
    Label fromArityCheck(this);

    // Setup a pointer to the codeblock in the CallFrameHeader.
    emitPutImmediateToCallFrameHeader(m_codeBlock, RegisterFile::CodeBlock);

    // Plant a check that sufficient space is available in the RegisterFile.
    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291
    addPtr(Imm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), callFrameRegister, regT1);
    Jump registerFileCheck = branchPtr(Below, AbsoluteAddress(m_globalData->interpreter->registerFile().addressOfEnd()), regT1);
    // Return here after register file check.
    Label fromRegisterFileCheck = label();


    // === Stage 2 - Function body code generation ===
    //
    // We generate the speculative code path, followed by the non-speculative
    // code for the function. Next we need to link the two together, making
    // bail-outs from the speculative path jump to the corresponding point on
    // the non-speculative one (and generating any code necessary to juggle
    // register values around, rebox values, and ensure spilled, to match the
    // non-speculative path's requirements).

#if DFG_JIT_BREAK_ON_ENTRY
    // Handy debug tool!
    breakpoint();
#endif

    // First generate the speculative path.
    SpeculativeJIT speculative(*this);
    speculative.compile();

    // Next, generate the non-speculative path. We pass this a SpeculationCheckIndexIterator
    // to allow it to check which nodes in the graph may bail out, and may need to reenter the
    // non-speculative path.
    SpeculationCheckIndexIterator checkIterator(speculative);
    NonSpeculativeJIT nonSpeculative(*this);
    nonSpeculative.compile(checkIterator);

    // Link the bail-outs from the speculative path to the corresponding entry points into the non-speculative one.
    linkSpeculationChecks(speculative, nonSpeculative);


    // === Stage 3 - Function footer code generation ===
    //
    // Generate code to lookup and jump to exception handlers, to perform the slow
    // register file check (if the fast one in the function header fails), and
    // generate the entry point with arity check.

    // Iterate over the m_calls vector, checking for exception checks,
    // and linking them to here.
    unsigned exceptionCheckCount = 0;
    for (unsigned i = 0; i < m_calls.size(); ++i) {
        Jump& exceptionCheck = m_calls[i].m_exceptionCheck;
        if (exceptionCheck.isSet()) {
            exceptionCheck.link(this);
            ++exceptionCheckCount;
        }
    }
    // If any exception checks were linked, generate code to lookup a handler.
    if (exceptionCheckCount) {
        // lookupExceptionHandler is passed two arguments, exec (the CallFrame*), and
        // an identifier for the operation that threw the exception, which we can use
        // to look up handler information. The identifier we use is the return address
        // of the call out from JIT code that threw the exception; this is still
        // available on the stack, just below the stack pointer!
        move(callFrameRegister, argumentRegister0);
        peek(argumentRegister1, -1);
        m_calls.append(CallRecord(call(), lookupExceptionHandler));
        // lookupExceptionHandler leaves the handler CallFrame* in the returnValueRegister,
        // and the address of the handler in returnValueRegister2.
        jump(returnValueRegister2);
    }

    // Generate the register file check; if the fast check in the function head fails,
    // we need to call out to a helper function to check whether more space is available.
    // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions).
    registerFileCheck.link(this);
    move(stackPointerRegister, argumentRegister0);
    poke(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));
    Call callRegisterFileCheck = call();
    jump(fromRegisterFileCheck);

    // The fast entry point into a function does not check the correct number of arguments
    // have been passed to the call (we only use the fast entry point where we can statically
    // determine the correct number of arguments have been passed, or have already checked).
    // In cases where an arity check is necessary, we enter here.
    // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions).
    Label arityCheck = label();
    preserveReturnAddressAfterCall(regT2);
    emitPutToCallFrameHeader(regT2, RegisterFile::ReturnPC);
    branch32(Equal, regT1, Imm32(m_codeBlock->m_numParameters)).linkTo(fromArityCheck, this);
    move(stackPointerRegister, argumentRegister0);
    poke(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));
    Call callArityCheck = call();
    move(regT0, callFrameRegister);
    jump(fromArityCheck);


    // === Stage 4 - Link ===
    //
    // Link the code, populate data in CodeBlock data structures.

    LinkBuffer linkBuffer(this, m_globalData->executableAllocator.poolForSize(m_assembler.size()), 0);

    // Link all calls out from the JIT code to their respective functions.
    for (unsigned i = 0; i < m_calls.size(); ++i)
        linkBuffer.link(m_calls[i].m_call, m_calls[i].m_function);

    if (m_codeBlock->needsCallReturnIndices()) {
        m_codeBlock->callReturnIndexVector().reserveCapacity(exceptionCheckCount);
        for (unsigned i = 0; i < m_calls.size(); ++i) {
            if (m_calls[i].m_exceptionCheck.isSet()) {
                unsigned returnAddressOffset = linkBuffer.returnAddressOffset(m_calls[i].m_call);
                unsigned exceptionInfo = m_calls[i].m_exceptionInfo;
                m_codeBlock->callReturnIndexVector().append(CallReturnOffsetToBytecodeOffset(returnAddressOffset, exceptionInfo));
            }
        }
    }

    // FIXME: switch the register file check & arity check over to DFGOpertaion style calls, not JIT stubs.
    linkBuffer.link(callRegisterFileCheck, cti_register_file_check);
    linkBuffer.link(callArityCheck, m_codeBlock->m_isConstructor ? cti_op_construct_arityCheck : cti_op_call_arityCheck);

    entryWithArityCheck = linkBuffer.locationOf(arityCheck);
    entry = linkBuffer.finalizeCode();
}
VtableStub* VtableStubs::create_itable_stub(int itable_index) {
  // Note well: pd_code_size_limit is the absolute minimum we can get away with.  If you
  //            add code here, bump the code stub size returned by pd_code_size_limit!
  const int i486_code_length = VtableStub::pd_code_size_limit(false);
  VtableStub* s = new(i486_code_length) VtableStub(false, itable_index);
  ResourceMark rm;
  CodeBuffer cb(s->entry_point(), i486_code_length);
  MacroAssembler* masm = new MacroAssembler(&cb);

  // Entry arguments:
  //  rax,: Interface
  //  rcx: Receiver

#ifndef PRODUCT
  if (CountCompiledCalls) {
    __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
  }
#endif /* PRODUCT */
  // get receiver (need to skip return address on top of stack)

  assert(VtableStub::receiver_location() == rcx->as_VMReg(), "receiver expected in rcx");

  // get receiver klass (also an implicit null-check)
  address npe_addr = __ pc();
  __ movptr(rsi, Address(rcx, oopDesc::klass_offset_in_bytes()));

  // Most registers are in use; we'll use rax, rbx, rsi, rdi
  // (If we need to make rsi, rdi callee-save, do a push/pop here.)
  const Register method = rbx;
  Label throw_icce;

  // Get methodOop and entrypoint for compiler
  __ lookup_interface_method(// inputs: rec. class, interface, itable index
                             rsi, rax, itable_index,
                             // outputs: method, scan temp. reg
                             method, rdi,
                             throw_icce);

  // method (rbx): methodOop
  // rcx: receiver

#ifdef ASSERT
  if (DebugVtables) {
      Label L1;
      __ cmpptr(method, (int32_t)NULL_WORD);
      __ jcc(Assembler::equal, L1);
      __ cmpptr(Address(method, methodOopDesc::from_compiled_offset()), (int32_t)NULL_WORD);
      __ jcc(Assembler::notZero, L1);
      __ stop("methodOop is null");
      __ bind(L1);
    }
#endif // ASSERT

  address ame_addr = __ pc();
  __ jmp(Address(method, methodOopDesc::from_compiled_offset()));

  __ bind(throw_icce);
  __ jump(RuntimeAddress(StubRoutines::throw_IncompatibleClassChangeError_entry()));
  masm->flush();

  if (PrintMiscellaneous && (WizardMode || Verbose)) {
    tty->print_cr("itable #%d at "PTR_FORMAT"[%d] left over: %d",
                  itable_index, s->entry_point(),
                  (int)(s->code_end() - s->entry_point()),
                  (int)(s->code_end() - __ pc()));
  }
  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
  // shut the door on sizing bugs
  int slop = 3;  // 32-bit offset is this much larger than an 8-bit one
  assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");

  s->set_exception_points(npe_addr, ame_addr);
  return s;
}
Пример #21
0
  void SurfaceVectorGradient<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t pt=0; pt < numQPs; ++pt) {
        Intrepid::Vector<ScalarT> g_0(3, &currentBasis(cell, pt, 0, 0));
        Intrepid::Vector<ScalarT> g_1(3, &currentBasis(cell, pt, 1, 0));
        Intrepid::Vector<ScalarT> g_2(3, &currentBasis(cell, pt, 2, 0));
        Intrepid::Vector<ScalarT> G_2(3, &refNormal(cell, pt, 0));
        Intrepid::Vector<ScalarT> d(3, &jump(cell, pt, 0));
        Intrepid::Vector<ScalarT> G0(3, &refDualBasis(cell, pt, 0, 0));
        Intrepid::Vector<ScalarT> G1(3, &refDualBasis(cell, pt, 1, 0));
        Intrepid::Vector<ScalarT> G2(3, &refDualBasis(cell, pt, 2, 0));

        Intrepid::Tensor<ScalarT>
        Fpar(Intrepid::bun(g_0, G0) +
            Intrepid::bun(g_1, G1) +
            Intrepid::bun(g_2, G2));
        // for Jay: bun()
        Intrepid::Tensor<ScalarT> Fper((1 / thickness) * Intrepid::bun(d, G_2));

        Intrepid::Tensor<ScalarT> F = Fpar + Fper;

        defGrad(cell, pt, 0, 0) = F(0, 0);
        defGrad(cell, pt, 0, 1) = F(0, 1);
        defGrad(cell, pt, 0, 2) = F(0, 2);
        defGrad(cell, pt, 1, 0) = F(1, 0);
        defGrad(cell, pt, 1, 1) = F(1, 1);
        defGrad(cell, pt, 1, 2) = F(1, 2);
        defGrad(cell, pt, 2, 0) = F(2, 0);
        defGrad(cell, pt, 2, 1) = F(2, 1);
        defGrad(cell, pt, 2, 2) = F(2, 2);

        J(cell,pt) = Intrepid::det(F);
      }
    }

    if (weightedAverage)
    {
      ScalarT Jbar, wJbar, vol;
      for (std::size_t cell=0; cell < workset.numCells; ++cell)
      {
        Jbar = 0.0;
        vol = 0.0;
        for (std::size_t qp=0; qp < numQPs; ++qp)
        {
          Jbar += weights(cell,qp) * std::log( J(cell,qp) );
          vol  += weights(cell,qp);
        }
        Jbar /= vol;

        // Jbar = std::exp(Jbar);
        for (std::size_t qp=0; qp < numQPs; ++qp)
        {
          for (std::size_t i=0; i < numDims; ++i)
          {
            for (std::size_t j=0; j < numDims; ++j)
            {
              wJbar = std::exp( (1-alpha) * Jbar + alpha * std::log( J(cell,qp) ) );
              defGrad(cell,qp,i,j) *= std::pow( wJbar / J(cell,qp) ,1./3. );
            }
          }
          J(cell,qp) = wJbar;
        }
      }
    }

  }
Пример #22
0
void IngameState::handlePlayerInput(const sf::Event& event)
{
	auto player = game->getPlayer();
	switch(event.type) {
	case sf::Event::KeyPressed:
		switch(event.key.code) {
		case sf::Keyboard::Space:
			if( player->getCharacter()->getCurrentVehicle() ) {
				player->getCharacter()->getCurrentVehicle()->setHandbraking(true);
			}
			else
			{
				player->jump();
			}
			break;
		case sf::Keyboard::LShift:
			player->setRunning(true);
			break;
		case sf::Keyboard::F:
			if( player->getCharacter()->getCurrentVehicle()) {
				player->exitVehicle();
			}
			else {
				player->enterNearestVehicle();
			}
			break;
		default:
			break;
		}
	break;
	case sf::Event::KeyReleased:
		switch(event.key.code) {
		case sf::Keyboard::LShift:
			player->setRunning(false);
			break;
		default: break;
		}
	break;
	case sf::Event::MouseButtonPressed:
		switch(event.mouseButton.button) {
		case sf::Mouse::Left:
			player->getCharacter()->useItem(true, true);
			break;
		default: break;
		}
		break;
	case sf::Event::MouseButtonReleased:
		switch(event.mouseButton.button) {
		case sf::Mouse::Left:
			player->getCharacter()->useItem(false, true);
			break;
		default: break;
		}
		break;
	case sf::Event::MouseWheelMoved:
		player->getCharacter()->cycleInventory(event.mouseWheel.delta > 0);
		break;
	default:
		break;
	}
}
Пример #23
0
void CharacterGame::update(long elapsedTime)
{
    Vector2 direction;

    if (_gamepad->getButtonState(0) == Gamepad::BUTTON_PRESSED)
    {
        // Jump while the gamepad button is being pressed
        jump();
    }

	if (_gamepad->isJoystickActive(0))
    {
        // Get joystick direction
        direction = _gamepad->getJoystickState(0);
    }
    else
    {
        // Construct direction vector from keyboard input
        if (_keyFlags & NORTH)
            direction.y = 1;
        else if (_keyFlags & SOUTH)
            direction.y = -1;
        if (_keyFlags & EAST)
            direction.x = 1;
        else if (_keyFlags & WEST)
            direction.x = -1;

        direction.normalize();
        if ((_keyFlags & RUNNING) == 0)
            direction *= 0.5f;
    }

    // Update character animation and velocity
    if (direction.isZero())
    {
        play("idle", true);
        _character->setVelocity(Vector3::zero());
    }
    else
    {
        bool running = (direction.lengthSquared() > 0.75f);
        float speed = running ? RUN_SPEED : WALK_SPEED;

        play(running ? "running" : "walking", true, 1.0f);

        // Orient the character relative to the camera so he faces the direction we want to move.
        const Matrix& cameraMatrix = _scene->getActiveCamera()->getNode()->getWorldMatrix();
        Vector3 cameraRight, cameraForward;
        cameraMatrix.getRightVector(&cameraRight);
        cameraMatrix.getForwardVector(&cameraForward);

        // Get the current forward vector for the mesh node (negate it since the character was modelled facing +z)
        Vector3 currentHeading(-_characterMeshNode->getForwardVectorWorld());

        // Construct a new forward vector for the mesh node
        Vector3 newHeading(cameraForward * direction.y + cameraRight * direction.x);

        // Compute the rotation amount based on the difference between the current and new vectors
        float angle = atan2f(newHeading.x, newHeading.z) - atan2f(currentHeading.x, currentHeading.z);
        if (angle > MATH_PI)
            angle -= MATH_PIX2;
        else if (angle < -MATH_PI)
            angle += MATH_PIX2;
        angle *= (float)elapsedTime * 0.001f * MATH_PIX2;
        _characterMeshNode->rotate(Vector3::unitY(), angle);

        // Update the character's velocity
        Vector3 velocity = -_characterMeshNode->getForwardVectorWorld();
        velocity.normalize();
        velocity *= speed;
        _character->setVelocity(velocity);
    }

    // Adjust camera to avoid it from being obstructed by walls and objects in the scene.
    adjustCamera(elapsedTime);

    // Project the character's shadow node onto the surface directly below him.
    PhysicsController::HitResult hitResult;
    Vector3 v = _character->getNode()->getTranslationWorld();
    if (getPhysicsController()->rayTest(Ray(Vector3(v.x, v.y + 1.0f, v.z), Vector3(0, -1, 0)), 100.0f, &hitResult))
        _characterShadowNode->setTranslation(Vector3(hitResult.point.x, hitResult.point.y + 0.1f, hitResult.point.z));
}
Пример #24
0
int *astar_compute (const char *grid, 
		    int *solLength, 
		    int boundX, 
		    int boundY, 
		    int start, 
		    int end)
{
	astar_t astar;
	if (!init_astar_object (&astar, grid, solLength, boundX, boundY, start, end))
		return NULL;

	struct coord_t bounds = {boundX, boundY};
	struct coord_t endCoord = getCoord (bounds, end);

	while (astar.open->size) {
		int dir;
		int node = findMin (astar.open)->value; 
		struct coord_t nodeCoord = getCoord (bounds, node);
		if (nodeCoord.x == endCoord.x && nodeCoord.y == endCoord.y) {
			freeQueue (astar.open);
			free (astar.closed);
			free (astar.gScores);

			int *rv = recordSolution (&astar);

			free (astar.cameFrom);

			return rv;
		}

		deleteMin (astar.open);
		astar.closed[node] = 1;

		direction from = directionWeCameFrom (&astar, 
						      node,
						      astar.cameFrom[node]);

		directionset dirs = 
			forcedNeighbours (&astar, nodeCoord, from) 
		      | naturalNeighbours (from);

		for (dir = nextDirectionInSet (&dirs); dir != NO_DIRECTION; dir = nextDirectionInSet (&dirs))
		{
			int newNode = jump (&astar, dir, node);
			struct coord_t newCoord = getCoord (bounds, newNode);

			// this'll also bail out if jump() returned -1
			if (!contained (bounds, newCoord))
				continue;

			if (astar.closed[newNode])
				continue;
			
			addToOpenSet (&astar, newNode, node);

		}
	}
	freeQueue (astar.open);
	free (astar.closed);
	free (astar.gScores);
	free (astar.cameFrom);

	return NULL;
}
Пример #25
0
void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID)
{
    int dst = instruction[1].u.operand;
    int callee = instruction[2].u.operand;
    int argCount = instruction[3].u.operand;
    int registerOffset = instruction[4].u.operand;

    linkSlowCase(iter);

    // The arguments have been set up on the hot path for op_call_eval
    if (opcodeID == op_call)
        compileOpCallSetupArgs(instruction);
    else if (opcodeID == op_construct)
        compileOpConstructSetupArgs(instruction);

    // Fast check for JS function.
    Jump callLinkFailNotObject = emitJumpIfNotJSCell(X86::ecx);
    Jump callLinkFailNotJSFunction = jnePtr(Address(X86::ecx), ImmPtr(m_interpreter->m_jsFunctionVptr));

    // First, in the case of a construct, allocate the new object.
    if (opcodeID == op_construct) {
        emitCTICall(Interpreter::cti_op_construct_JSConstruct);
        emitPutVirtualRegister(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
        emitGetVirtualRegister(callee, X86::ecx);
    }

    move(Imm32(argCount), X86::edx);

    // Speculatively roll the callframe, assuming argCount will match the arity.
    storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));
    addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister);

    m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation =
        emitNakedCall(m_interpreter->m_ctiVirtualCallPreLink);

    Jump storeResultForFirstRun = jump();

// FIXME: this label can be removed, since it is a fixed offset from 'callReturnLocation'.
    // This is the address for the cold path *after* the first run (which tries to link the call).
    m_callStructureStubCompilationInfo[callLinkInfoIndex].coldPathOther = MacroAssembler::Label(this);

    // The arguments have been set up on the hot path for op_call_eval
    if (opcodeID == op_call)
        compileOpCallSetupArgs(instruction);
    else if (opcodeID == op_construct)
        compileOpConstructSetupArgs(instruction);

    // Check for JSFunctions.
    Jump isNotObject = emitJumpIfNotJSCell(X86::ecx);
    Jump isJSFunction = jePtr(Address(X86::ecx), ImmPtr(m_interpreter->m_jsFunctionVptr));

    // This handles host functions
    isNotObject.link(this);
    callLinkFailNotObject.link(this);
    callLinkFailNotJSFunction.link(this);
    emitCTICall(((opcodeID == op_construct) ? Interpreter::cti_op_construct_NotJSConstruct : Interpreter::cti_op_call_NotJSFunction));
    Jump wasNotJSFunction = jump();

    // Next, handle JSFunctions...
    isJSFunction.link(this);

    // First, in the case of a construct, allocate the new object.
    if (opcodeID == op_construct) {
        emitCTICall(Interpreter::cti_op_construct_JSConstruct);
        emitPutVirtualRegister(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
        emitGetVirtualRegister(callee, X86::ecx);
    }

    // Speculatively roll the callframe, assuming argCount will match the arity.
    storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));
    addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister);
    move(Imm32(argCount), X86::edx);

    emitNakedCall(m_interpreter->m_ctiVirtualCall);

    // Put the return value in dst. In the interpreter, op_ret does this.
    wasNotJSFunction.link(this);
    storeResultForFirstRun.link(this);
    emitPutVirtualRegister(dst);

#if ENABLE(CODEBLOCK_SAMPLING)
    storePtr(ImmPtr(m_codeBlock), m_interpreter->sampler()->codeBlockSlot());
#endif
}
Пример #26
0
T GhostGridField<T>::valueAtWorld(double w_x, double w_y,double w_z) const{
    
    int i,j,k;
    GridField<T>::worldToUpperLeftIndex(w_x, w_y, w_z, i, j, k);
    
    CellType thisType = LevelSet::getCellType(_levelset->grid->valueAtWorld(w_x, w_y, w_z));
    CellType c000 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i, j, k));
    CellType c100 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i+1, j, k));
    CellType c110 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i+1, j+1, k));
    CellType c010 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i, j+1, k));

    CellType c001 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i, j, k+1));
    CellType c101 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i+1, j, k+1));
    CellType c111 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i+1, j+1, k+1));
    CellType c011 = LevelSet::getCellType(_levelset->grid->valueAtIndex(i, j+1, k+1));
    
    double v000 = GridField<T>::valueAtIndex(i,j,k)+jump(thisType, c000, i, j, k);
    double v100 = GridField<T>::valueAtIndex(i+1,j,k)+jump(thisType, c100, i+1, j, k);
    double v110 = GridField<T>::valueAtIndex(i+1,j+1,k)+jump(thisType, c110, i+1, j+1, k);
    double v010 = GridField<T>::valueAtIndex(i,j+1,k)+jump(thisType, c010, i, j+1, k);

    double v001 = GridField<T>::valueAtIndex(i,j,k+1)+jump(thisType, c001, i, j, k+1);
    double v101 = GridField<T>::valueAtIndex(i+1,j,k+1)+jump(thisType, c101, i+1, j, k+1);
    double v111 = GridField<T>::valueAtIndex(i+1,j+1,k+1)+jump(thisType, c111, i+1, j+1, k+1);
    double v011 = GridField<T>::valueAtIndex(i,j+1,k+1)+jump(thisType, c011, i, j+1, k+1);

    double w_x0,w_y0,w_z0;
    double w_x1,w_y1,w_z1;
    double x,y,z;
    
    GridField<T>::indexToWorld(i, j, k, w_x0, w_y0, w_z0);
    GridField<T>::indexToWorld(i+1, j+1, k+1, w_x1, w_y1, w_z1);
    
    x = (w_x-w_x0)/(w_x1-w_x0);
    y = (w_y-w_y0)/(w_y1-w_y0);
    z = (w_z-w_z0)/(w_z1-w_z0);
    LinearInterpolation<T> interpolation;
 
    
    double t1 = interpolation(x,v000,v100);
    double t2 = interpolation(x,v010,v110);
    double t3 = interpolation(x,v001,v101);
    double t4 = interpolation(x,v011,v111);
    
    double t5 = interpolation(y,t1,t2);
    double t6 = interpolation(y,t3,t4);
    
    double t7 = interpolation(z,t5,t6);
    
    /*
     T t1 = (*this)(x,g.valueAtIndex(i,j,k),g.valueAtIndex(i+1,j,k));
     T t2 = (*this)(x,g.valueAtIndex(i,j+1,k),g.valueAtIndex(i+1,j+1,k));
     T t3 = (*this)(x,g.valueAtIndex(i,j,k+1),g.valueAtIndex(i+1,j,k+1));
     T t4 = (*this)(x,g.valueAtIndex(i,j+1,k+1),g.valueAtIndex(i+1,j+1,k+1));
     
     T t5 = (*this)(y,t1,t2);
     T t6 = (*this)(y,t3,t4);
     
     T t7 = (*this)(z,t5,t6);
     */

	if(t7 != 0.)
		return t7;
    
    return t7;
}
Пример #27
0
void main_loop(void)
{
	Doubly_linked_node *iterator;
	int direction, dx, dy, count;
	int x, y;

	uint32_t last_time;
	uint32_t current_time;
	uint32_t ellapsed_time;
	uint32_t start_time;

	Point *save_eye;
	float speed;

	last_time = SDL_GetTicks();
	while (!conf->key[SDLK_ESCAPE] && !conf->quit)
	{
		start_time = SDL_GetTicks(); 
		save_eye = point_new(conf->eye->x, conf->eye->y, conf->eye->z);
		speed  = (conf->free_fly) ? 5 : 0.5;

		update_event();

		if (!conf->viewMode && conf->key[SDLK_F1])
		{
			conf->key[SDLK_F1] = 0;
			conf->free_fly = !conf->free_fly;
			if (!conf->free_fly)
			{
				save_eye->x = CELL_SIZE / 2;
				save_eye->y = CELL_SIZE / 2;
				save_eye->z = CHARACTER_SIZE;
			}
			else {
				conf->jump_duration = 0;
			}
		}

		if (!conf->viewMode && (conf->key[SDLK_LSHIFT] || conf->key[SDLK_LALT]))
		{
			if ( conf->jump_duration == 0 ) { /* j'ai du mal a courir quand je saute */
				speed = (conf->free_fly) ? 7.51337 : 0.91337;
			}
		}

		if (!conf->viewMode &&  conf->key[SDLK_LCTRL])
		{
			speed = (conf->free_fly) ? 0.1 : 0.3;
		}

		if (conf->key[SDLK_F2])
		{
			conf->key[SDLK_F2] = 0;
			conf->time = !conf->time;
		}

		if (conf->key[SDLK_F3])
		{
			conf->key[SDLK_F3] = 0;
			conf->display = !conf->display;
		}

		if (!conf->viewMode &&  conf->key[SDLK_F4])
		{
			conf->key[SDLK_F4] = 0;
			conf->quadTreeView = !conf->quadTreeView;
		}

		if (conf->key[SDLK_F5])
		{
			conf->key[SDLK_F5] = 0;
			if (!strcmp(conf->music, "music/music2.mp3"))
			{
				conf->music = "music/music.mp3";
				music_new();
			} else if (!strcmp(conf->music, "music/music.mp3")) {
				conf->music = "music/music2.mp3";
				music_new();
			}
		}
		
		if (!conf->viewMode && (conf->key[SDLK_UP] || conf->key[SDLK_z]))
		{
			forward_move(save_eye, speed);
		}

		if (!conf->viewMode && (conf->key[SDLK_DOWN] || conf->key[SDLK_s]))
		{
			backward_move(save_eye, speed);
		}

		if (!conf->viewMode && (conf->key[SDLK_RIGHT] || conf->key[SDLK_d]))
		{
			right_move(save_eye, speed);
		}

		if (!conf->viewMode && (conf->key[SDLK_LEFT] || conf->key[SDLK_q]))
		{
			left_move(save_eye, speed);
		}

		if (!conf->viewMode && conf->key[SDLK_a])
		{
			conf->key[SDLK_a] = 0;
			conf->theta += 180;
		}

		if (!conf->viewMode && conf->key[SDLK_r])
		{
			conf->key[SDLK_r] = 0;
			conf->life = MAX_HEALTH;
			save_eye->x = CELL_SIZE / 2;
			save_eye->y = CELL_SIZE / 2;
			save_eye->z = CHARACTER_SIZE;
			
			portals->bleu->actif = 0;
			portals->orange->actif = 0;
			conf->timer = SDL_GetTicks();
		}

		if (conf->key[SDLK_KP2] || (conf->key[SDLK_n]))
		{
			if (conf->free_fly) {
				save_eye->z -= 3;
			} else if (conf->viewMode) {
				save_eye->z -= 10;
			}
		}

		if (conf->key[SDLK_KP8] || (conf->key[SDLK_SPACE]))
		{
			if (!conf->free_fly && !conf->viewMode)
			{
				conf->key[SDLK_KP8] = 0;
				conf->key[SDLK_SPACE] = 0;
				if ( !conf->viewMode && conf->jump_duration == 0 ) {
					conf->jump_duration = 120;
				}
			} 
			else if (conf->free_fly){
				save_eye->z += 3;
			} else {
				save_eye->z += 10;
			}
		}
		
		conf->eye->z += jump(save_eye);
		
		if ( conf->key[SDLK_p] ) {
			conf->key[SDLK_p] = 0;
			if(Mix_PausedMusic() == 1) {
				Mix_ResumeMusic();
			}
			else {
				Mix_PauseMusic();
			}
		}
		
		if ( conf->key[SDLK_PLUS] || conf->key[SDLK_m] || conf->key[SDLK_KP_PLUS] ) {
			change_volume(CHANG_VOL);
		}

		if ( conf->key[SDLK_MINUS] || conf->key[SDLK_l] || conf->key[SDLK_KP_MINUS] ) {
			change_volume(-CHANG_VOL);
		}
		
		if (!conf->mousebutton[SDL_BUTTON_LEFT] && !conf->mousebutton[SDL_BUTTON_RIGHT])
		{
			conf->shoot = 0;
		}

		if (!conf->viewMode && conf->mousebutton[SDL_BUTTON_LEFT])
		{
			conf->mousebutton[SDL_BUTTON_LEFT] = 0;
			conf->mousebutton[SDL_BUTTON_RIGHT] = 0;
			conf->shoot = 1;
		}

		if (!conf->viewMode && conf->mousebutton[SDL_BUTTON_RIGHT])
		{
			conf->mousebutton[SDL_BUTTON_LEFT] = 0;
			conf->mousebutton[SDL_BUTTON_RIGHT] = 0;
			conf->shoot = 2;
		}
		
		if (!conf->viewMode && portals->orange->actif && portals->bleu->actif ) {
			if ( abs(save_eye->x - portals->bleu->portail->x ) < TRIGGER_DISTANCE && abs(save_eye->y - portals->bleu->portail->y) < TRIGGER_DISTANCE) {
				save_eye->x = portals->orange->portail->x - (sin(portals->orange->rotation) * PUSH_DISTANCE);
				save_eye->y = portals->orange->portail->y + (cos(portals->orange->rotation) * PUSH_DISTANCE);
				conf->theta += 180 + ( portals->orange->rotation - portals->bleu->rotation);
			}
			else if ( abs(save_eye->x - portals->orange->portail->x ) < TRIGGER_DISTANCE && abs(save_eye->y - portals->orange->portail->y) < TRIGGER_DISTANCE) {
				save_eye->x = portals->bleu->portail->x - (sin(portals->bleu->rotation) * PUSH_DISTANCE);
				save_eye->y = portals->bleu->portail->y + (cos(portals->bleu->rotation) * PUSH_DISTANCE);
				conf->theta += 180 + ( portals->bleu->rotation - portals->orange->rotation);
			}
		}

		if (COORD((int)(save_eye->x / CELL_SIZE), (int)(save_eye->y / CELL_SIZE))
				!= COORD((int)((conf->eye)->x / CELL_SIZE), (int)((conf->eye)->y / CELL_SIZE)))
		{
			iterator = mwl->last;
			while (1)
			{
				if ((iterator->object)->type == MOVING_WALL)
				{
					x = (((int)((iterator->object)->anchor)->x ) / CELL_SIZE);
					y = (((int)((iterator->object)->anchor)->y ) / CELL_SIZE);

					count = 0;
					direction = rand() % 4;
					while (count < 4)
					{	
					 	dx = 0;
					 	dy = 0;
					 	switch (direction)
					 	{
					 		case 0:
					 			dx = 1;
					 		break;
					 		case 1:
					 			dy = 1;
					 		break;
					 		case 2:
					 			dx = -1;
					 		break;
					 		default:
					 			dy = -1;
					 		break;
					 	}
					 	if(COORD((x+dx),(y+dy)) == COORD(((int)save_eye->x / CELL_SIZE), ((int)save_eye->y / CELL_SIZE))
					 		|| !IS_PLAYABLE(COORD((x+dx),(y+dy)))
					 		|| (dx == 1 && END_RIGHT(COORD(x,y)))
					 		|| (dy == 1 && END_TOP(COORD(x,y)))
					 		|| (dx == -1 && END_LEFT(COORD(x,y)))
					 		|| (dy == -1 && END_BOTTOM(COORD(x,y)))
					 	) {
					 		direction = (direction + 1) % 4;
					 		++count;
					 	} else {
					 		if(laby->matrix[COORD(x,y)] == SPIKES_MW) {
					 			laby->matrix[COORD(x,y)] = SPIKES;
					 		} else if (laby->matrix[COORD(x,y)] == MOVING_WALL) {
					 			laby->matrix[COORD(x,y)] = PASS;
					 		}

							if(laby->matrix[COORD((x+dx),(y+dy))] == PASS)
							{
								laby->matrix[COORD((x+dx),(y+dy))] = MOVING_WALL;
							} else if (laby->matrix[COORD((x+dx),(y+dy))] == SPIKES) {
								laby->matrix[COORD((x+dx),(y+dy))] = SPIKES_MW;
							}

							((iterator->object)->anchor)->x += (dx * CELL_SIZE);
							((iterator->object)->anchor)->y += (dy * CELL_SIZE);
							count = 4;
						}
					}
				}

				if (iterator->next != NULL)
				{
					iterator = iterator->next;
				} else {
					break;
				}
			}
		}

		/*fprintf(stderr, "%d %d\n", conf->mousex - SCREEN_MID_WIDTH, conf->mousey - SCREEN_MID_HEIGHT);*/
		if (!conf->viewMode && (( save_eye->x > 2 && save_eye->y > 2 
			&& save_eye->x < (CELL_SIZE * WIDTH) - 2 
			&& save_eye->y < (CELL_SIZE * HEIGHT) - 2 
			/*&& save_eye->z <= CHARACTER_SIZE 
			&& save_eye->z > CHARACTER_SIZE - 3*/
			&& IS_PLAYABLE(COORD((int)(save_eye->x / CELL_SIZE),(int)(save_eye->y / CELL_SIZE))) 
			&& IS_PLAYABLE(COORD((int)((save_eye->x + 2) / CELL_SIZE),(int)((save_eye->y) / CELL_SIZE))) 
			&& IS_PLAYABLE(COORD((int)((save_eye->x) / CELL_SIZE),(int)((save_eye->y + 2) / CELL_SIZE))) 
			&& IS_PLAYABLE(COORD((int)((save_eye->x - 2) / CELL_SIZE),(int)((save_eye->y) / CELL_SIZE))) 
			&& IS_PLAYABLE(COORD((int)((save_eye->x) / CELL_SIZE),(int)((save_eye->y - 2) / CELL_SIZE))) 
			) || conf->free_fly == 1
		)) {
			conf->eye->x = save_eye->x;
			conf->eye->y = save_eye->y;
			conf->eye->z = save_eye->z;
		}

		/* Mouse motion */
		if(!conf->viewMode)
		{
			conf->theta -= (conf->mousex - SCREEN_MID_WIDTH) * SENSITIVITY;
			conf->phi -= (conf->mousey - SCREEN_MID_HEIGHT) * SENSITIVITY;
			SDL_WarpMouse(SCREEN_MID_WIDTH, SCREEN_MID_HEIGHT); 
			modify_direction();
			change_center();
		} else {
			conf->eye->x = conf->center->x + CELL_SIZE * WIDTH * cos(conf->theta * M_PI / 180);
			conf->eye->y = conf->center->y + CELL_SIZE * HEIGHT * sin(conf->theta * M_PI / 180);
			conf->theta += 0.5;
			if (conf->theta >= 360)
			{
				conf->theta = 0;
			}
		}

		if (conf->life <= 0)
		{
			fprintf(stderr,"                          .,---.\n");
			fprintf(stderr,"                        ,/XM#MMMX;,\n");
			fprintf(stderr,"                      -%%##########M%%,\n");
			fprintf(stderr,"                     -@######%%  $###@=\n");
			fprintf(stderr,"      .,--,         -H#######$   $###M:\n");
			fprintf(stderr,"   ,;$M###MMX;     .;##########$;HM###X=\n");
			fprintf(stderr," ,/@##########H=      ;################+\n");
			fprintf(stderr,"-+#############M/,      %%##############+\n");
			fprintf(stderr,"%%M###############=      /##############:\n");
			fprintf(stderr,"H################      .M#############;.\n");
			fprintf(stderr,"@###############M      ,@###########M:.\n");
			fprintf(stderr,"X################,      -$=X#######@:\n");
			fprintf(stderr,"/@##################%%-     +######$-\n");
			fprintf(stderr,".;##################X     .X#####+,\n");
			fprintf(stderr," .;H################/     -X####+.\n");
			fprintf(stderr,"   ,;X##############,       .MM/\n");
			fprintf(stderr,"      ,:+$H@M#######M#$-    .$$=\n");
			fprintf(stderr,"           .,-=;+$@###X:    ;/=.\n");
			fprintf(stderr,"                  .,/X$;   .::,\n");
			fprintf(stderr,"                      .,    ..\n");
			fprintf(stderr,"Haw Haw ! You lose !\n");
			conf->quit = 1;
		}

		if (IS_EXIT(COORD((int)(conf->eye->x / CELL_SIZE), (int)(conf->eye->y / CELL_SIZE))) && !conf->free_fly)
		{
			if (!conf->win)
			{
				fprintf(stderr, "\n                         #,\n");
				fprintf(stderr, "                        ###\n");
				fprintf(stderr, "                       ## ##\n");
				fprintf(stderr, "                      ##  ##\n");
				fprintf(stderr, "                       ####\n");
				fprintf(stderr, "                         |\n");
				fprintf(stderr, "                        #####\n");
				fprintf(stderr, "                       ######\n");
				fprintf(stderr, "                       ##  ##\n");
				fprintf(stderr, "                       ##  ##\n");
				fprintf(stderr, "                       ##  ##\n");
				fprintf(stderr, "                       ##  ##########\n");
				fprintf(stderr, "                       ##  #############\n");
				fprintf(stderr, "                  #######  ###############\n");
				fprintf(stderr, "              #############################\n");
				fprintf(stderr, "        .###################################\n");
				fprintf(stderr, "       #####################################;\n");
				fprintf(stderr, "       ##                                 ##.\n");
				fprintf(stderr, "       ##                                 ##\n");
				fprintf(stderr, "       #####################################\n");
				fprintf(stderr, "       ##                                 ##\n");
				fprintf(stderr, "       ##                                 ##\n");
				fprintf(stderr, "       ##                                 ###\n");
				fprintf(stderr, "    #####                                 #####\n");
				fprintf(stderr, "   ### ##################################### ###\n");
				fprintf(stderr, "  ###  ##                                 ##  ###\n");
				fprintf(stderr, "  ##   ## ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ##   ##\n");
				fprintf(stderr, "   ##  #####################################  ##\n");
				fprintf(stderr, "    ##                                       ##\n");
				fprintf(stderr, "     ####                                 ####\n");
				fprintf(stderr, "       ######                         ######\n");
				fprintf(stderr, "          ###############################\n");
				fprintf(stderr, "The cake was not a lie !\n");
			}
			if (strcmp(conf->music, "music/music3.mp3")) {
				conf->music = "music/music3.mp3";
				music_new();
			}
			conf->win = 1;
		}

		/* Display with FPS care */
		current_time = SDL_GetTicks();
		ellapsed_time = current_time - last_time;
		last_time = current_time;

		display();

		ellapsed_time = SDL_GetTicks() - start_time;
		if (ellapsed_time < 25)
		{
			SDL_Delay(25 - ellapsed_time);
		}

		point_free(save_eye);
	}
}
Пример #28
0
T GhostGridField<T>::operator()(int i,int j,int k, CellType cellType) const{
    CellType thisCell = _levelset->getCellType(i, j, k);
    return GridField<T>::operator()(i,j,k)*jump(thisCell,cellType,i,j,k);
}
Пример #29
0
void
parse_paste(void)
{
    TextNode *pn = curr_node;
    PasteNode *paste;
    int where;

    if (gParserRegion != Scrolling) {
        fprintf(stderr, "(HyperDoc) Paste areas are only allowed in the scrolling area:");
        print_page_and_filename();
        jump();
    }
    gInPaste++;

    /* now I need to get the name */
    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) A paste area needs a name:\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    pn->data.text = alloc_string(get_input_string());
    pn->type = openaxiom_Paste_token;

    /*
     * now see if there is already an entry in the hash_table for this thing,
     * if not create it and put it there.
     */
    paste = (PasteNode *) hash_find(gWindow->fPasteHashTable, pn->data.text);
    if (paste == 0) {
        paste = alloc_paste_node(pn->data.text);
        hash_insert(gWindow->fPasteHashTable, (char *)paste, paste->name);
    }
    else if (paste->haspaste) {
        fprintf(stderr, "(HyperDoc) Tried to redefine paste area %s\n", paste->name);
        print_page_and_filename();
        /* jump(); */
    }
    paste->haspaste = 1;
    paste->paste_item = current_item();
    get_token();
    if (token.type == openaxiom_Lsquarebrace_token) {
        /* user wishes to specify a where to send the command */
        where = get_where();
        if (where == -1) {
            paste->where = -1;
            fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting [lisp|unix|ht]\n");
            print_next_ten_tokens();
            print_page_and_filename();
            jump();
        }
        else
            paste->where = where;
        get_token();
    }
    else
        paste->where = openaxiom_FromFile_input;

    /* now try to get the command argument or page name */
    if (token.type != openaxiom_Lbrace_token) {
        paste->where = 0;
        fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting an argument\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    paste->arg_node = alloc_node();
    curr_node = paste->arg_node;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endarg_token;

    gWindow->fDisplayedWindow = gWindow->fScrollWindow;

    /* Now try to find the displaying text */
    pn->next = alloc_node();
    curr_node = pn->next;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endpaste_token;
    paste->end_node = curr_node;

    paste->begin_node = pn;
    gInPaste--;
}
Пример #30
0
// NOTE: May have to overload with implementation dependant version
void ECPU8Bit::jsr(ULONG location)
{
  pushAddr(pc+op_len);
  jump(location);
}