Ejemplo n.º 1
0
bool Movement::test_direction(int dir, int displacement)
{
    float add_x, add_y;
    get_dir(dir, add_x, add_y);
    add_x *= displacement;
    add_y *= displacement;
    return test_offset(add_x, add_y);
}
Ejemplo n.º 2
0
/*
 *  polygon tests
 */
void setup(void)
{
    test_passed_waypoint();
    test_offset();
    test_accuracy();
    test_wrap_cd();
    test_wgs_conversion_functions();
    hal.console->printf("ALL TESTS DONE\n");
}
Ejemplo n.º 3
0
/*
 *  polygon tests
 */
void setup(void)
{
    test_passed_waypoint();
    test_offset();
    test_accuracy();
    test_wrap_cd();
#if HAL_CPU_CLASS >= HAL_CPU_CLASS_75
    test_wgs_conversion_functions();
#endif
    hal.console->printf("ALL TESTS DONE\n");
}
Ejemplo n.º 4
0
void PinballMovement::bounce(bool collision)
{
    add_x = add_y = 0.0;

    if (!collision) {
        x_speed = -x_speed;
        y_speed = -y_speed;
        return;
    }

    push_out();

    float angle = get_pinball_angle(x_speed, y_speed);
    float dist = get_length(x_speed, y_speed);

    float found_a = -1.0f;
    for (float a = 0.0f; a < (2.0f*CHOW_PI); a += (2.0f*CHOW_PI) / 32.0f) {
        float x_move = 10.0f * cos(angle + a);
        float y_move = -10.0f * sin(angle + a);

        if (!test_offset(x_move, y_move)) {
            found_a = a;
            break;
        }
    }

    if (found_a == -1.0f) {
        x_speed = -x_speed;
        y_speed = -y_speed;
        return;
    }

    angle += found_a * 2.0f;
    if (angle > 2.0 * CHOW_PI)
        angle -= 2.0 * CHOW_PI;

    // add some randomness
    angle += randrange(-0.3f, 0.3f);
    dist += randrange(0.0f, 15.0f);

    x_speed = dist * cos(angle);
    y_speed = -dist * sin(angle);
}
Ejemplo n.º 5
0
int main(int argc , char ** argv) {
  int year_offset;
  test_date(1,1,0 , &year_offset);
  test_offset(1,1,1000 , year_offset);
  exit(0);
}
Ejemplo n.º 6
0
// TODO(swwwolf): get human disassembler, not this piece of shit with strings
bool WDbgArk::FindDbgkLkmdCallbackArray() {
    #define MAX_INSN_LENGTH 15

    unsigned __int64 offset = 0;
    bool             result = false;

    if ( m_minor_build < W7RTM_VER ) {
        out << __FUNCTION__ << ": unsupported Windows version" << endlout;
        return false;
    }

    if ( GetSymbolOffset("nt!DbgkLkmdCallbackArray", true, &offset) )
        return true;

    if ( !GetSymbolOffset("nt!DbgkLkmdUnregisterCallback", true, &offset) ) {
        err << __FUNCTION__ << ": can't find nt!DbgkLkmdUnregisterCallback" << endlerr;
        return false;
    }

    try {
        ExtRemoteData test_offset(offset, m_PtrSize);
    }
    catch( const ExtRemoteException &Ex ) {
        err << __FUNCTION__ << ": " << Ex.GetMessage() << endlerr;
        return false;
    }

    unsigned __int64 cur_pointer = offset;
    unsigned __int64 end         = cur_pointer + MAX_INSN_LENGTH * 20;

    std::unique_ptr<char[]> disasm_buf(new char[0x100]);

    unsigned __int32 asm_options;

    if ( !SUCCEEDED(m_Control3->GetAssemblyOptions(reinterpret_cast<PULONG>(&asm_options))) )
        warn << __FUNCTION__ << ": failed to get assembly options" << endlwarn;

    if ( !SUCCEEDED(m_Control3->SetAssemblyOptions(DEBUG_ASMOPT_NO_CODE_BYTES)) )
        warn << __FUNCTION__ << ": failed to set assembly options" << endlwarn;

    HRESULT disasm_result;

    while ( cur_pointer < end ) {
        disasm_result = m_Control->Disassemble(cur_pointer,
                                               0,
                                               disasm_buf.get(),
                                               0x100,
                                               nullptr,
                                               &cur_pointer);

        if ( !SUCCEEDED(disasm_result) ) {
            err << __FUNCTION__ " : disassembly failed at " << std::hex << std::showbase << cur_pointer << endlerr;
            break;
        }

        std::string disasm   = disasm_buf.get();
        size_t      posstart = 0;
        size_t      posend   = 0;
        size_t      pos      = 0;

        // TODO(swwwolf): regexp?
        if ( m_is_cur_machine64 ) {
            pos = disasm.find("lea", 0);

            if ( pos == std::string::npos )
                continue;

            pos = disasm.find(",[", pos);

            if ( pos == std::string::npos )
                continue;

            posstart = disasm.find("(", pos);

            if ( posstart == std::string::npos )
                continue;

            posend = disasm.find(")", posstart);

            if ( posstart == std::string::npos )
                continue;
        } else {
            pos = disasm.find("mov", 0);

            if ( pos == std::string::npos )
                continue;

            pos = disasm.find(",offset", pos);

            if ( pos == std::string::npos )
                continue;

            posstart = disasm.find("(", pos);

            if ( posstart == std::string::npos )
                continue;

            posend = disasm.find(")", posstart);

            if ( posstart == std::string::npos )
                continue;
        }

        std::string string_value(disasm.substr(posstart + 1, posend - posstart - 1));

        try {
            unsigned __int64 ret_address = g_Ext->EvalExprU64(string_value.c_str());

            // do not reload nt module after that
            HRESULT hresult = g_Ext->m_Symbols3->AddSyntheticSymbol(ret_address,
                                                                    m_PtrSize,
                                                                    "DbgkLkmdCallbackArray",
                                                                    DEBUG_ADDSYNTHSYM_DEFAULT,
                                                                    NULL);

            if ( !SUCCEEDED(hresult) )
                err << __FUNCTION__ << ": failed to add synthetic symbol DbgkLkmdCallbackArray" << endlerr;
            else
                result = true;
        }
        catch ( const ExtStatusException &Ex ) {
            err << __FUNCTION__ << ": " << Ex.GetMessage() << endlerr;
        }

        break;
    }

    if ( !SUCCEEDED(m_Control3->SetAssemblyOptions(asm_options)) )
        warn << __FUNCTION__ << ": failed to set assembly options" << endlwarn;

    return result;
}