void gmiscMatrixFixed2DApplyShear(MatrixFixed2D *dst, const MatrixFixed2D *src, fixed sx, fixed sy) { if (src) { dst->a00 = src->a00 + FIXEDMUL(sy,src->a01); dst->a01 = FIXEDMUL(sx,src->a00) + src->a01; dst->a02 = src->a02; dst->a10 = src->a10 + FIXEDMUL(sy,src->a11); dst->a11 = FIXEDMUL(sx,src->a10) + src->a11; dst->a12 = src->a12; dst->a20 = src->a20 + FIXEDMUL(sy,src->a21); dst->a21 = FIXEDMUL(sx,src->a20) + src->a21; dst->a22 = src->a22; } else { dst->a00 = FIXED(1); dst->a01 = sx; dst->a02 = 0; dst->a10 = sy; dst->a11 = FIXED(1); dst->a12 = 0; dst->a20 = 0; dst->a21 = 0; dst->a22 = FIXED(1); } }
void gmiscMatrixFixed2DApplyTranslation(MatrixFixed2D *dst, const MatrixFixed2D *src, fixed tx, fixed ty) { if (src) { dst->a00 = src->a00; dst->a01 = src->a01; dst->a02 = src->a02+tx; dst->a10 = src->a10; dst->a11 = src->a11; dst->a12 = src->a12+ty; dst->a20 = src->a20; dst->a21 = src->a21; dst->a22 = src->a22; } else { dst->a00 = FIXED(1); dst->a01 = 0; dst->a02 = tx; dst->a10 = 0; dst->a11 = FIXED(1); dst->a12 = ty; dst->a20 = 0; dst->a21 = 0; dst->a22 = FIXED(1); } }
VOID SetupAspectRatio(VOID) { f_xdim = FIXED(xdim, 0); f_ydim = FIXED(ydim, 0); x_pix_size = (f_320 / xdim); y_pix_size = (f_200 / ydim); x_aspect_mul = (f_xdim / 320); y_aspect_mul = (f_ydim / 200); }
static GLOBJECT * createGroundPlane() { const int scale = 4; const int yBegin = -15, yEnd = 15; // ends are non-inclusive const int xBegin = -15, xEnd = 15; const long triangleCount = (yEnd - yBegin) * (xEnd - xBegin) * 2; const long vertices = triangleCount * 3; GLOBJECT *result; int x, y; long currentVertex, currentQuad; result = newGLObject(vertices, 2, 0); if (result == NULL) return NULL; currentQuad = 0; currentVertex = 0; for (y = yBegin; y < yEnd; ++y) { for (x = xBegin; x < xEnd; ++x) { GLubyte color; int i, a; color = (GLubyte)((randomUInt() & 0x5f) + 81); // 101 1111 for (i = currentVertex * 4; i < (currentVertex + 6) * 4; i += 4) { result->colorArray[i] = color; result->colorArray[i + 1] = color; result->colorArray[i + 2] = color; result->colorArray[i + 3] = 0; } // Axis bits for quad triangles: // x: 011100 (0x1c), y: 110001 (0x31) (clockwise) // x: 001110 (0x0e), y: 100011 (0x23) (counter-clockwise) for (a = 0; a < 6; ++a) { const int xm = x + ((0x1c >> a) & 1); const int ym = y + ((0x31 >> a) & 1); const float m = (float)(cos(xm * 2) * sin(ym * 4) * 0.75f); result->vertexArray[currentVertex * 2] = FIXED(xm * scale + m); result->vertexArray[currentVertex * 2 + 1] = FIXED(ym * scale + m); ++currentVertex; } ++currentQuad; } } return result; }
void WidgetPassword::show() { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; ImageFile &images = *ui._interfaceImages; // Set the up window to be centered on the screen _bounds = Common::Rect(_surface.widestChar() * 20 + 6, (_surface.fontHeight() + 7) * 2 + 3); _bounds.moveTo(SHERLOCK_SCREEN_WIDTH / 2 - _bounds.width() / 2, SHERLOCK_SCREEN_HEIGHT / 2 - _bounds.height() / 2); // Create the surface _surface.create(_bounds.width(), _bounds.height()); _surface.fill(TRANSPARENCY); makeInfoArea(); // Draw the header area _surface.writeString(FIXED(EnterPassword), Common::Point((_bounds.width() - _surface.stringWidth(FIXED(EnterPassword))) / 2, 5), INFO_TOP); _surface.hLine(3, _surface.fontHeight() + 7, _bounds.width() - 4, INFO_TOP); _surface.hLine(3, _surface.fontHeight() + 8, _bounds.width() - 4, INFO_MIDDLE); _surface.hLine(3, _surface.fontHeight() + 9, _bounds.width() - 4, INFO_BOTTOM); _surface.transBlitFrom(images[4], Common::Point(0, _surface.fontHeight() + 7 - 1)); _surface.transBlitFrom(images[5], Common::Point(_bounds.width() - images[5]._width, _surface.fontHeight() + 7 - 1)); // Set the password entry data _cursorPos = Common::Point(_surface.widestChar(), _surface.fontHeight() + 12); _password = ""; _index = 0; _cursorColor = 192; _insert = true; // Show the dialog ui._menuMode = PASSWORD_MODE; summonWindow(); }
void gwinCheckboxDraw_Button(GWidgetObject *gw, void *param) { const GColorSet * pcol; fixed alpha; fixed dalpha; coord_t i; color_t tcol, bcol; (void) param; if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return; pcol = getCheckboxColors(gw); #if GWIN_NEED_FLASHING // Flash the on and off state. pcol = _gwinGetFlashedColor(gw, pcol, TRUE); #endif /* Fill the box blended from variants of the fill color */ tcol = gdispBlendColor(White, pcol->fill, CHK_TOP_FADE); bcol = gdispBlendColor(Black, pcol->fill, CHK_BOTTOM_FADE); dalpha = FIXED(255)/gw->g.height; for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha) gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha))); gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter); gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge); gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge); }
void gwinRadioDraw_Tab(GWidgetObject *gw, void *param) { const GColorSet * pcol; fixed alpha; fixed dalpha; coord_t i; color_t tcol, bcol; (void) param; if (gw->g.vmt != (gwinVMT *)&radioVMT) return; pcol = getDrawColors(gw); if ((gw->g.flags & GRADIO_FLG_PRESSED)) { tcol = gdispBlendColor(pcol->edge, gw->pstyle->background, GRADIO_OUTLINE_FADE); gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, pcol->text, gw->g.bgcolor, justifyCenter); gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y, gw->g.x+gw->g.width-(GRADIO_TAB_CNR+1), gw->g.y, tcol); gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-(GRADIO_TAB_CNR+1), gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+GRADIO_TAB_CNR, tcol); gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y+GRADIO_TAB_CNR, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, tcol); } else { /* Fill the box blended from variants of the fill color */ tcol = gdispBlendColor(White, pcol->fill, GRADIO_TOP_FADE); bcol = gdispBlendColor(Black, pcol->fill, GRADIO_BOTTOM_FADE); dalpha = FIXED(255)/gw->g.height; for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha) gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha))); gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge); gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter); } }
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) { const GColorSet * pcol; fixed alpha; fixed dalpha; coord_t i; color_t tcol, bcol; (void) param; if (gw->g.vmt != (gwinVMT *)&buttonVMT) return; pcol = getButtonColors(gw); /* Fill the box blended from variants of the fill color */ tcol = gdispBlendColor(White, pcol->fill, BTN_TOP_FADE); bcol = gdispBlendColor(Black, pcol->fill, BTN_BOTTOM_FADE); dalpha = FIXED(255)/gw->g.height; for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha) gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha))); gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter); gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge); gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge); // Render highlighted border if focused _gwidgetDrawFocusRect(gw, 0, 0, gw->g.width-1, gw->g.height-1); }
void OptimizationAlgorithmLevenberg::printVerbose(std::ostream& os) const { os << "\t schur= " << _solver->schur() << "\t lambda= " << FIXED(_currentLambda) << "\t levenbergIter= " << _levenbergIterations; }
void Darts::showStatus(int playerNum) { Screen &screen = *_vm->_screen; const char *const CRICKET_SCORE_NAME[7] = { "20", "19", "18", "17", "16", "15", FIXED(Bull) }; screen._backBuffer2.blitFrom(screen._backBuffer1, Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 10), Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + 10, STATUS_INFO_X + STATUS_INFO_WIDTH, STATUS_INFO_Y + STATUS_INFO_HEIGHT - 10)); screen.print(Common::Point(STATUS_INFO_X + 30, STATUS_INFO_Y + _spacing + 4), 0, "%d", _score1); screen.print(Common::Point(STATUS2_INFO_X + 30, STATUS_INFO_Y + _spacing + 4), 0, "%d", _score2); int temp = (_gameType == GAME_CRICKET) ? STATUS_INFO_Y + 10 * _spacing + 5 : STATUS_INFO_Y + 55; screen.print(Common::Point(STATUS_INFO_X, temp), 0, "%s: %d", FIXED(Round), _roundNum); if (_gameType == GAME_301) { screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 75), 0, "%s: %d", FIXED(TurnTotal), _roundScore); } else { // Show cricket scores for (int x = 0; x < 7; ++x) { screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 40 + x * _spacing), 0, "%s:", CRICKET_SCORE_NAME[x]); for (int y = 0; y < 2; ++y) { switch (CRICKET_SCORE_NAME[y][x]) { case 1: screen.print(Common::Point(STATUS_INFO_X + 38 + y*STATUS2_X_ADD, STATUS_INFO_Y + 40 + x * _spacing), 0, "/"); break; case 2: screen.print(Common::Point(STATUS_INFO_X + 38 + y*STATUS2_X_ADD, STATUS_INFO_Y + 40 + x * _spacing), 0, "X"); break; case 3: screen.print(Common::Point(STATUS_INFO_X + 38 + y * STATUS2_X_ADD - 1, STATUS_INFO_Y + 40 + x * _spacing), 0, "X"); screen.print(Common::Point(STATUS_INFO_X + 37 + y * STATUS2_X_ADD, STATUS_INFO_Y + 40 + x * _spacing), 0, "O"); break; default: break; } } } } screen.blitFrom(screen._backBuffer1, Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 10), Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + 10, STATUS_INFO_X + STATUS_INFO_WIDTH, STATUS_INFO_Y + STATUS_INFO_HEIGHT - 10)); }
void WidgetPassword::close() { Talk &talk = *_vm->_talk; banishWindow(); if (talk._talkToAbort) return; // See if they entered the correct password Common::String correct1 = FIXED(CorrectPassword); Common::String correct2 = Common::String::format("%s?", FIXED(CorrectPassword)); Common::String correct3 = Common::String::format("%s ?", FIXED(CorrectPassword)); if (!_password.compareToIgnoreCase(correct1) || !_password.compareToIgnoreCase(correct2) || !_password.compareToIgnoreCase(correct3)) // They got it correct _vm->setFlags(149); talk.talkTo("LASC52P"); }
void test_copy(uint32_t w, uint32_t h, uint32_t format) { PixmapPtr src, dest; C2D_OBJECT blit = {}; C2D_RECT rect; c2d_ts_handle curTimestamp; DEBUG_MSG("----------------------------------------------------------------"); DEBUG_MSG("copy: %04dx%04d-%08x", w, h, format); RD_START("copy", "%dx%d format:%08x", w, h, format); dest = create_pixmap(w, h, format); src = create_pixmap(13, 17, format); rect.x = 1; rect.y = 2; rect.width = w - 2; rect.height = h - 3; CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); rect.x = 0; rect.y = 0; rect.width = 13; rect.height = 17; CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFlush(src->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); blit.surface_id = src->id; blit.config_mask = DEFAULT_BLIT_MASK; blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(13-1); blit.source_rect.height = FIXED(17-2); blit.target_rect.x = FIXED((w - 13) / 2); blit.target_rect.y = FIXED((h - 17) / 2); blit.target_rect.width = FIXED(13); blit.target_rect.height = FIXED(17); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); RD_END(); dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
void WidgetQuit::show() { Events &events = *_vm->_events; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; ImageFile &images = *ui._interfaceImages; Common::Point mousePos = events.mousePos(); const char *YES = FIXED(Yes); const char *NO = FIXED(No); // Set up the display area _bounds = Common::Rect(_surface.stringWidth(FIXED(AreYouSureYou)) + _surface.widestChar() * 2, (_surface.fontHeight() + 7) * 4); _bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2); // Create the surface _surface.create(_bounds.width(), _bounds.height()); _surface.clear(TRANSPARENCY); makeInfoArea(); // Draw the message text _surface.writeString(FIXED(AreYouSureYou), Common::Point((_surface.width() - _surface.stringWidth(FIXED(AreYouSureYou))) / 2, 5), INFO_TOP); _surface.writeString(FIXED(WishToQuit), Common::Point((_surface.width() - _surface.stringWidth(FIXED(WishToQuit))) / 2, _surface.fontHeight() + 9), INFO_TOP); // Draw the horizontal bars seperating the commands and the message int yp = (_surface.fontHeight() + 4) * 2 + 3; for (int idx = 0; idx < 2; ++idx) { _surface.SHtransBlitFrom(images[4], Common::Point(0, yp - 1)); _surface.SHtransBlitFrom(images[5], Common::Point(_surface.width() - images[5]._width, yp - 1)); _surface.hLine(3, yp, _surface.width() - 4, INFO_TOP); _surface.hLine(3, yp + 1, _surface.width() - 4, INFO_MIDDLE); _surface.hLine(3, yp + 2, _surface.width() - 4, INFO_BOTTOM); const char *btn = (idx == 0) ? YES : NO; _surface.writeString(btn, Common::Point((_bounds.width() - _surface.stringWidth(btn)) / 2, yp + 5), INFO_TOP); yp += _surface.fontHeight() + 7; } ui._menuMode = QUIT_MODE; summonWindow(); }
/* * cordic_calc_iq() - calculates the i/q coordinate for given angle * * theta: angle in degrees for which i/q coordinate is to be calculated * coord: function output parameter holding the i/q coordinate */ struct cordic_iq cordic_calc_iq(s32 theta) { struct cordic_iq coord; s32 angle, valtmp; unsigned iter; int signx = 1; int signtheta; coord.i = CORDIC_ANGLE_GEN; coord.q = 0; angle = 0; theta = FIXED(theta); signtheta = (theta < 0) ? -1 : 1; theta = ((theta + FIXED(180) * signtheta) % FIXED(360)) - FIXED(180) * signtheta; if (FLOAT(theta) > 90) { theta -= FIXED(180); signx = -1; } else if (FLOAT(theta) < -90) { theta += FIXED(180); signx = -1; } for (iter = 0; iter < CORDIC_NUM_ITER; iter++) { if (theta > angle) { valtmp = coord.i - (coord.q >> iter); coord.q += (coord.i >> iter); angle += arctan_table[iter]; } else {
ScalpelInventory::ScalpelInventory(SherlockEngine *vm) : Inventory(vm) { _invShapes.resize(6); _fixedTextExit = FIXED(Inventory_Exit); _fixedTextLook = FIXED(Inventory_Look); _fixedTextUse = FIXED(Inventory_Use); _fixedTextGive = FIXED(Inventory_Give); _hotkeyExit = toupper(_fixedTextExit[0]); _hotkeyLook = toupper(_fixedTextLook[0]); _hotkeyUse = toupper(_fixedTextUse[0]); _hotkeyGive = toupper(_fixedTextGive[0]); _hotkeysIndexed[0] = _hotkeyExit; _hotkeysIndexed[1] = _hotkeyLook; _hotkeysIndexed[2] = _hotkeyUse; _hotkeysIndexed[3] = _hotkeyGive; _hotkeysIndexed[4] = '-'; _hotkeysIndexed[5] = '+'; _hotkeysIndexed[6] = ','; _hotkeysIndexed[7] = '.'; }
static void bgarea(GWidgetObject *gw, const char *text, coord_t y, coord_t x, coord_t w) { const GColorSet * pcol; fixed alpha; coord_t i; color_t tcol, bcol; pcol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled; /* Fill the box blended from variants of the fill color */ tcol = gdispBlendColor(White, pcol->fill, GTABSET_TOP_FADE); bcol = gdispBlendColor(Black, pcol->fill, GTABSET_BOTTOM_FADE); for(alpha = 0, i = 0; i < GWIN_TABSET_TABHEIGHT; i++, alpha += FIXED(255)/GWIN_TABSET_TABHEIGHT) gdispGDrawLine(gw->g.display, gw->g.x+x, gw->g.y+y+i, gw->g.x+x+w-2, gw->g.y+y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha))); gdispGDrawLine(gw->g.display, gw->g.x+x+w-1, gw->g.y+y, gw->g.x+x+w-1, gw->g.y+y+GWIN_TABSET_TABHEIGHT-1, pcol->edge); gdispGDrawStringBox(gw->g.display, gw->g.x+x+1, gw->g.y+y+1, w-2, GWIN_TABSET_TABHEIGHT-2, text, gw->g.font, pcol->text, justifyCenter); }
void gmiscMatrixFixed2DApplyRotation(MatrixFixed2D *dst, const MatrixFixed2D *src, int angle) { fixed s, c; s = ffsin(angle); c = ffcos(angle); if (src) { dst->a00 = FIXEDMUL(c,src->a00) - FIXEDMUL(s,src->a01); dst->a01 = FIXEDMUL(s,src->a00) + FIXEDMUL(c,src->a01); dst->a02 = src->a02; dst->a10 = FIXEDMUL(c,src->a10) - FIXEDMUL(s,src->a11); dst->a11 = FIXEDMUL(s,src->a10) + FIXEDMUL(c,src->a11); dst->a12 = src->a12; dst->a20 = FIXEDMUL(c,src->a20) - FIXEDMUL(s,src->a21); dst->a21 = FIXEDMUL(s,src->a20) + FIXEDMUL(c,src->a21); dst->a22 = src->a22; } else { dst->a00 = c; dst->a01 = s; dst->a02 = 0; dst->a10 = -s; dst->a11 = c; dst->a12 = 0; dst->a20 = 0; dst->a21 = 0; dst->a22 = FIXED(1); } }
void Darts::showNames(int playerNum) { Screen &screen = *_vm->_screen; byte color; color = playerNum == 0 ? PLAYER_COLOR : DART_COLOR_FORE; screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y), 0, "%s", FIXED(Holmes)); screen._backBuffer1.fillRect(Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + _spacing + 1, STATUS_INFO_X + 50, STATUS_INFO_Y + _spacing + 3), color); screen.fillRect(Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + _spacing + 1, STATUS_INFO_X + 50, STATUS_INFO_Y + _spacing + 3), color); color = playerNum == 1 ? PLAYER_COLOR : DART_COLOR_FORE; screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y), 0, "%s", _opponent.c_str()); screen._backBuffer1.fillRect(Common::Rect(STATUS2_INFO_X, STATUS_INFO_Y + _spacing + 1, STATUS2_INFO_X + 50, STATUS_INFO_Y + _spacing + 3), color); screen.fillRect(Common::Rect(STATUS2_INFO_X, STATUS_INFO_Y + _spacing + 1, STATUS2_INFO_X + 50, STATUS_INFO_Y + _spacing + 3), color); screen._backBuffer2.blitFrom(screen._backBuffer1); }
static void copy(PixmapPtr dest, PixmapPtr src, int srcX, int srcY, int dstX, int dstY, int width, int height) { C2D_OBJECT blit = {}; blit.surface_id = src->id; blit.config_mask = C2D_SOURCE_RECT_BIT | C2D_TARGET_RECT_BIT | C2D_NO_PIXEL_ALPHA_BIT | C2D_NO_BILINEAR_BIT | C2D_NO_ANTIALIASING_BIT | C2D_ALPHA_BLEND_NONE; blit.next = NULL; blit.source_rect.x = FIXED(srcX); blit.source_rect.y = FIXED(srcY); blit.source_rect.width = FIXED(width); blit.source_rect.height = FIXED(height); blit.target_rect.x = FIXED(dstX); blit.target_rect.y = FIXED(dstY); blit.target_rect.width = FIXED(width); blit.target_rect.height = FIXED(height); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); }
void gmiscMatrixFixed2DSetIdentity(MatrixFixed2D *m) { m->a00 = m->a11 = m->a22 = FIXED(1); m->a01 = m->a02 = m->a10 = m->a12 = m->a20 = m->a21 = 0; }
int SparseOptimizerIncremental::optimize(int iterations, bool online) { (void) iterations; // we only do one iteration anyhow OptimizationAlgorithm* solver = _algorithm; solver->init(online); int cjIterations=0; bool ok=true; if (! online || batchStep) { //cerr << "performing batch step" << endl; if (! online) { ok = _underlyingSolver->buildStructure(); if (! ok) { cerr << __PRETTY_FUNCTION__ << ": Failure while building CCS structure" << endl; return 0; } } // copy over the updated estimate as new linearization point if (slamDimension == 3) { for (size_t i = 0; i < indexMapping().size(); ++i) { OnlineVertexSE2* v = static_cast<OnlineVertexSE2*>(indexMapping()[i]); v->setEstimate(v->updatedEstimate); } } else if (slamDimension == 6) { for (size_t i = 0; i < indexMapping().size(); ++i) { OnlineVertexSE3* v= static_cast<OnlineVertexSE3*>(indexMapping()[i]); v->setEstimate(v->updatedEstimate); } } SparseOptimizer::computeActiveErrors(); SparseOptimizer::linearizeSystem(); _underlyingSolver->buildSystem(); int numBlocksRequired = _ivMap.size(); if (_cmember.size() < numBlocksRequired) { _cmember.resize(2 * numBlocksRequired); } memset(_cmember.data(), 0, numBlocksRequired * sizeof(int)); if (_ivMap.size() > 100) { for (size_t i = _ivMap.size() - 20; i < _ivMap.size(); ++i) { const HyperGraph::EdgeSet& eset = _ivMap[i]->edges(); for (HyperGraph::EdgeSet::const_iterator it = eset.begin(); it != eset.end(); ++it) { OptimizableGraph::Edge* e = static_cast<OptimizableGraph::Edge*>(*it); OptimizableGraph::Vertex* v1 = static_cast<OptimizableGraph::Vertex*>(e->vertices()[0]); OptimizableGraph::Vertex* v2 = static_cast<OptimizableGraph::Vertex*>(e->vertices()[1]); if (v1->hessianIndex() >= 0) _cmember(v1->hessianIndex()) = 1; if (v2->hessianIndex() >= 0) _cmember(v2->hessianIndex()) = 1; } } } ok = _underlyingSolver->solve(); // get the current cholesky factor along with the permutation _L = _solverInterface->L(); if (_perm.size() < (int)_L->n) _perm.resize(2*_L->n); int* p = (int*)_L->Perm; for (size_t i = 0; i < _L->n; ++i) _perm[p[i]] = i; } else { // update the b vector for (HyperGraph::VertexSet::iterator it = _touchedVertices.begin(); it != _touchedVertices.end(); ++it) { OptimizableGraph::Vertex* v = static_cast<OptimizableGraph::Vertex*>(*it); int iBase = v->colInHessian(); v->copyB(_underlyingSolver->b() + iBase); } _solverInterface->solve(_underlyingSolver->x(), _underlyingSolver->b()); } update(_underlyingSolver->x()); ++cjIterations; if (verbose()){ computeActiveErrors(); cerr << "nodes = " << vertices().size() << "\t edges= " << _activeEdges.size() << "\t chi2= " << FIXED(activeChi2()) << endl; } if (vizWithGnuplot) gnuplotVisualization(); if (! ok) return 0; return 1; }
// Creates and returns a supershape object. // Based on Paul Bourke's POV-Ray implementation. // http://astronomy.swin.edu.au/~pbourke/povray/supershape/ static GLOBJECT * createSuperShape(const float *params) { const int resol1 = (int)params[SUPERSHAPE_PARAMS - 3]; const int resol2 = (int)params[SUPERSHAPE_PARAMS - 2]; // latitude 0 to pi/2 for no mirrored bottom // (latitudeBegin==0 for -pi/2 to pi/2 originally) const int latitudeBegin = resol2 / 4; const int latitudeEnd = resol2 / 2; // non-inclusive const int longitudeCount = resol1; const int latitudeCount = latitudeEnd - latitudeBegin; const long triangleCount = longitudeCount * latitudeCount * 2; const long vertices = triangleCount * 3; GLOBJECT *result; float baseColor[3]; int a, longitude, latitude; long currentVertex, currentQuad; result = newGLObject(vertices, 3, 1); if (result == NULL) return NULL; for (a = 0; a < 3; ++a) baseColor[a] = ((randomUInt() % 155) + 100) / 255.f; currentQuad = 0; currentVertex = 0; // longitude -pi to pi for (longitude = 0; longitude < longitudeCount; ++longitude) { // latitude 0 to pi/2 for (latitude = latitudeBegin; latitude < latitudeEnd; ++latitude) { float t1 = -PI + longitude * 2 * PI / resol1; float t2 = -PI + (longitude + 1) * 2 * PI / resol1; float p1 = -PI / 2 + latitude * 2 * PI / resol2; float p2 = -PI / 2 + (latitude + 1) * 2 * PI / resol2; float r0, r1, r2, r3; r0 = ssFunc(t1, params); r1 = ssFunc(p1, ¶ms[6]); r2 = ssFunc(t2, params); r3 = ssFunc(p2, ¶ms[6]); if (r0 != 0 && r1 != 0 && r2 != 0 && r3 != 0) { VECTOR3 pa, pb, pc, pd; VECTOR3 v1, v2, n; float ca; int i; //float lenSq, invLenSq; superShapeMap(&pa, r0, r1, t1, p1); superShapeMap(&pb, r2, r1, t2, p1); superShapeMap(&pc, r2, r3, t2, p2); superShapeMap(&pd, r0, r3, t1, p2); // kludge to set lower edge of the object to fixed level if (latitude == latitudeBegin + 1) pa.z = pb.z = 0; vector3Sub(&v1, &pb, &pa); vector3Sub(&v2, &pd, &pa); // Calculate normal with cross product. /* i j k i j * v1.x v1.y v1.z | v1.x v1.y * v2.x v2.y v2.z | v2.x v2.y */ n.x = v1.y * v2.z - v1.z * v2.y; n.y = v1.z * v2.x - v1.x * v2.z; n.z = v1.x * v2.y - v1.y * v2.x; /* Pre-normalization of the normals is disabled here because * they will be normalized anyway later due to automatic * normalization (GL_NORMALIZE). It is enabled because the * objects are scaled with glScale. */ /* lenSq = n.x * n.x + n.y * n.y + n.z * n.z; invLenSq = (float)(1 / sqrt(lenSq)); n.x *= invLenSq; n.y *= invLenSq; n.z *= invLenSq; */ ca = pa.z + 0.5f; for (i = currentVertex * 3; i < (currentVertex + 6) * 3; i += 3) { result->normalArray[i] = FIXED(n.x); result->normalArray[i + 1] = FIXED(n.y); result->normalArray[i + 2] = FIXED(n.z); } for (i = currentVertex * 4; i < (currentVertex + 6) * 4; i += 4) { int a, color[3]; for (a = 0; a < 3; ++a) { color[a] = (int)(ca * baseColor[a] * 255); if (color[a] > 255) color[a] = 255; } result->colorArray[i] = (GLubyte)color[0]; result->colorArray[i + 1] = (GLubyte)color[1]; result->colorArray[i + 2] = (GLubyte)color[2]; result->colorArray[i + 3] = 0; } result->vertexArray[currentVertex * 3] = FIXED(pa.x); result->vertexArray[currentVertex * 3 + 1] = FIXED(pa.y); result->vertexArray[currentVertex * 3 + 2] = FIXED(pa.z); ++currentVertex; result->vertexArray[currentVertex * 3] = FIXED(pb.x); result->vertexArray[currentVertex * 3 + 1] = FIXED(pb.y); result->vertexArray[currentVertex * 3 + 2] = FIXED(pb.z); ++currentVertex; result->vertexArray[currentVertex * 3] = FIXED(pd.x); result->vertexArray[currentVertex * 3 + 1] = FIXED(pd.y); result->vertexArray[currentVertex * 3 + 2] = FIXED(pd.z); ++currentVertex; result->vertexArray[currentVertex * 3] = FIXED(pb.x); result->vertexArray[currentVertex * 3 + 1] = FIXED(pb.y); result->vertexArray[currentVertex * 3 + 2] = FIXED(pb.z); ++currentVertex; result->vertexArray[currentVertex * 3] = FIXED(pc.x); result->vertexArray[currentVertex * 3 + 1] = FIXED(pc.y); result->vertexArray[currentVertex * 3 + 2] = FIXED(pc.z); ++currentVertex; result->vertexArray[currentVertex * 3] = FIXED(pd.x); result->vertexArray[currentVertex * 3 + 1] = FIXED(pd.y); result->vertexArray[currentVertex * 3 + 2] = FIXED(pd.z); ++currentVertex; } // r0 && r1 && r2 && r3 ++currentQuad; } // latitude } // longitude // Set number of vertices in object to the actual amount created. result->count = currentVertex; return result; }
TR(2, 31, TR_RES_DISEN , RES_DISEN , "Res Disen" , 1, 1, 15, BINARY , 0, false, false) TR(3, 0, TR_SH_FIRE , SH_FIRE , "Aura Fire" , 2, 0, 0, BINARY , 0, false, false) TR(3, 1, TR_SH_ELEC , SH_ELEC , "Aura Elec" , 2, 0, 1, BINARY , 0, false, false) TR(3, 2, TR_AUTO_CURSE , AUTO_CURSE , "Auto Curse", 2, 0, 2, BINARY , 0, false, false) TR(3, 3, TR_DECAY , DECAY , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 4, TR_NO_TELE , NO_TELE , "NoTeleport", 2, 0, 4, BINARY , 0, false, false) TR(3, 5, TR_NO_MAGIC , NO_MAGIC , "AntiMagic" , 2, 0, 5, BINARY , 0, false, false) TR(3, 6, TR_WRAITH , WRAITH , "WraithForm", 2, 0, 6, BINARY , 0, false, false) TR(3, 7, TR_TY_CURSE , TY_CURSE , "EvilCurse" , 2, 0, 7, BINARY , 0, false, false) TR(3, 8, TR_EASY_KNOW , EASY_KNOW , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 9, TR_HIDE_TYPE , HIDE_TYPE , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 10, TR_SHOW_MODS , SHOW_MODS , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 11, TR_INSTA_ART , INSTA_ART , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 12, TR_FEATHER , FEATHER , "Levitate" , 2, 0, 12, BINARY , 0, false, false) TR(3, 13, TR_LITE1 , LITE1 , "Lite" , 2, 0, 13, FIXED(1) , 0, false, false) TR(3, 14, TR_SEE_INVIS , SEE_INVIS , "See Invis" , 2, 0, 14, BINARY , 0, false, false) TR(3, 15, TR_NORM_ART , NORM_ART , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 16, TR_SLOW_DIGEST , SLOW_DIGEST , "Digestion" , 2, 1, 0, BINARY , 0, false, false) TR(3, 17, TR_REGEN , REGEN , "Regen" , 2, 1, 1, BINARY , 0, false, false) TR(3, 18, TR_XTRA_MIGHT , XTRA_MIGHT , "Xtra Might", 2, 1, 2, BINARY , 0, false, false) TR(3, 19, TR_XTRA_SHOTS , XTRA_SHOTS , "Xtra Shots", 2, 1, 3, BINARY , 0, false, false) TR(3, 20, TR_IGNORE_ACID , IGNORE_ACID , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 21, TR_IGNORE_ELEC , IGNORE_ELEC , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 22, TR_IGNORE_FIRE , IGNORE_FIRE , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 23, TR_IGNORE_COLD , IGNORE_COLD , nullptr , -1, -1, -1, BINARY , 0, false, false) TR(3, 24, TR_ACTIVATE , ACTIVATE , "Activate" , 2, 1, 8, BINARY , 0, false, false) TR(3, 25, TR_DRAIN_EXP , DRAIN_EXP , "Drain Exp" , 2, 1, 9, BINARY , 0, false, false) TR(3, 26, TR_TELEPORT , TELEPORT , "Teleport" , 2, 1, 10, BINARY , 0, false, false) TR(3, 27, TR_AGGRAVATE , AGGRAVATE , "Aggravate" , 2, 1, 11, BINARY , 0, false, false) TR(3, 28, TR_BLESSED , BLESSED , "Blessed" , 2, 1, 12, BINARY , 0, false, false)
void test_composite(const char *name, const struct blend_mode *blend, const struct format_mode *dst_format, uint32_t bw, uint32_t bh, const struct format_mode *src_format, uint32_t src_repeat, uint32_t sw, uint32_t sh, const struct format_mode *mask_format, uint32_t mask_repeat, uint32_t mw, uint32_t mh) { PixmapPtr src, dest, mask = NULL; C2D_OBJECT blit = {}; c2d_ts_handle curTimestamp; DEBUG_MSG("%s: op:%s src:%s (repeat:%d) mask=%s (repeat:%d) dst:%s", name, blend->name, src_format->name, src_repeat, mask_format ? mask_format->name : "none", mask_repeat, dst_format->name); RD_START(name, "op:%s src:%s (repeat:%d) mask=%s (repeat:%d) dst:%s", blend->name, src_format->name, src_repeat, mask_format ? mask_format->name : "none", mask_repeat, dst_format->name); blit.config_mask = DEFAULT_BLEND_MASK | blend->mode; dest = create_pixmap(1033, 1077, dst_format->format); if (src_repeat) { src = create_pixmap(1, 1, src_format->format); blit.config_mask |= C2D_SOURCE_TILE_BIT; } else { src = create_pixmap(sw, sh, src_format->format); } blit.config_mask |= C2D_SOURCE_RECT_BIT; blit.surface_id = src->id; if (mask_format) { /* TODO not clear if mask repeat is really supported.. msm-exa-c2d2.c * seems to reject it but C2D_MASK_TILE_BIT?? * * Also, for src format, msm-exa-c2d2.c seems to encode fgcolor (like * a solid fill) for repeats.. not really clear if TILE_BIT does what * we expect or not?? * * Seems like libC2D2 doesn't actually give any way to specify the * maskX/maskY!!! The previous c2d API does, so I'd have to assume * this is actually supported by the hardware and this is just C2D2 * retardation */ if (mask_repeat) { mask = create_pixmap(1, 1, mask_format->format); blit.config_mask |= C2D_MASK_TILE_BIT; } else { mask = create_pixmap(mw, mh, mask_format->format); } blit.config_mask |= C2D_MASK_SURFACE_BIT; blit.mask_surface_id = mask->id; } else { // TODO make redump not confused when one column has extra rows mask = create_pixmap(1, 1, ARGB); } blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(bw - blit.source_rect.x - 1); blit.source_rect.height = FIXED(bh - blit.source_rect.y - 2); blit.target_rect.x = FIXED((dest->width - sw) / 2); blit.target_rect.y = FIXED((dest->height - sh) / 2); blit.target_rect.width = blit.source_rect.width; blit.target_rect.height = blit.source_rect.height; CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); free_pixmap(src); free_pixmap(dest); if (mask) free_pixmap(mask); RD_END(); // dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
void WidgetVerbs::load(bool objectsOn) { Events &events = *_vm->_events; Talk &talk = *_vm->_talk; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; TattooPeople &people = *(TattooPeople *)_vm->_people; Common::Point mousePos = events.mousePos(); bool isWatson = false; if (talk._talkToAbort) return; _outsideMenu = false; _verbCommands.clear(); // Check if we need to show options for the highlighted object if (objectsOn) { // Set the verb list accordingly, depending on the target being a // person or an object if (ui._personFound) { TattooPerson &person = people[ui._activeObj - 1000]; TattooPerson &npc = people[ui._activeObj - 1001]; if (!scumm_strnicmp(npc._npcName.c_str(), "WATS", 4)) isWatson = true; if (scumm_strnicmp(person._examine.c_str(), "_EXIT", 5)) _verbCommands.push_back(FIXED(Look)); _verbCommands.push_back(FIXED(Talk)); // Add any extra active verbs from the NPC's verb list for (int idx = 0; idx < 2; ++idx) { if (!person._use[idx]._verb.empty() && !person._use[idx]._verb.hasPrefix(" ") && (person._use[idx]._target.empty() || person._use[idx]._target.hasPrefix(" "))) { _verbCommands.push_back(person._use[idx]._verb); } } } else { if (!scumm_strnicmp(ui._bgShape->_name.c_str(), "WATS", 4)) // Looking at Watson isWatson = true; if (scumm_strnicmp(ui._bgShape->_examine.c_str(), "_EXIT", 5)) // It's not an exit, so include Look as an option _verbCommands.push_back(FIXED(Look)); if (ui._bgShape->_aType == PERSON) _verbCommands.push_back(FIXED(Talk)); // Add any extra active verbs from the object's verb list for (int idx = 0; idx < 6; ++idx) { if (!ui._bgShape->_use[idx]._verb.empty() && !ui._bgShape->_use[idx]._verb.hasPrefix(" ") && (ui._bgShape->_use[idx]._target.empty() || ui._bgShape->_use[idx]._target.hasPrefix(" "))) { _verbCommands.push_back(ui._bgShape->_use[idx]._verb); } } } } // If clicked on Watson, have Journal as an option if (isWatson) _verbCommands.push_back(FIXED(Journal)); // Add the system commands _verbCommands.push_back(FIXED(Inventory)); _verbCommands.push_back(FIXED(Options)); // Figure out the needed width to show the commands int width = 0; for (uint idx = 0; idx < _verbCommands.size(); ++idx) width = MAX(width, _surface.stringWidth(_verbCommands[idx])); width += _surface.widestChar() * 2 + 6; int height = (_surface.fontHeight() + 7) * _verbCommands.size() + 3; // Set the bounds _bounds = Common::Rect(width, height); _bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2); // Render the window on the internal surface render(); }
void WidgetFiles::render(FilesRenderMode mode) { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; ImageFile &images = *ui._interfaceImages; byte color; if (mode == RENDER_ALL) { _surface.clear(TRANSPARENCY); makeInfoArea(); switch (_fileMode) { case SAVEMODE_LOAD: _surface.writeString(FIXED(LoadGame), Common::Point((_surface.width() - _surface.stringWidth(FIXED(LoadGame))) / 2, 5), INFO_TOP); break; case SAVEMODE_SAVE: _surface.writeString(FIXED(SaveGame), Common::Point((_surface.width() - _surface.stringWidth(FIXED(SaveGame))) / 2, 5), INFO_TOP); break; default: break; } _surface.hLine(3, _surface.fontHeight() + 7, _surface.width() - 4, INFO_TOP); _surface.hLine(3, _surface.fontHeight() + 8, _surface.width() - 4, INFO_MIDDLE); _surface.hLine(3, _surface.fontHeight() + 9, _surface.width() - 4, INFO_BOTTOM); _surface.SHtransBlitFrom(images[4], Common::Point(0, _surface.fontHeight() + 6)); _surface.SHtransBlitFrom(images[5], Common::Point(_surface.width() - images[5]._width, _surface.fontHeight() + 6)); int xp = _surface.width() - BUTTON_SIZE - 6; _surface.vLine(xp, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_TOP); _surface.vLine(xp + 1, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_MIDDLE); _surface.vLine(xp + 2, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_BOTTOM); _surface.SHtransBlitFrom(images[6], Common::Point(xp - 1, _surface.fontHeight() + 8)); _surface.SHtransBlitFrom(images[7], Common::Point(xp - 1, _bounds.height() - 4)); } int xp = _surface.stringWidth("00.") + _surface.widestChar() + 5; int yp = _surface.fontHeight() + 14; for (int idx = _savegameIndex; idx < (_savegameIndex + FILES_LINES_COUNT); ++idx) { if (idx == _selector && mode != RENDER_ALL) color = COMMAND_HIGHLIGHTED; else color = INFO_TOP; if (mode == RENDER_NAMES_AND_SCROLLBAR) _surface.fillRect(Common::Rect(4, yp, _surface.width() - BUTTON_SIZE - 9, yp + _surface.fontHeight()), TRANSPARENCY); Common::String numStr = Common::String::format("%d.", idx + 1); _surface.writeString(numStr, Common::Point(_surface.widestChar(), yp), color); _surface.writeString(_savegames[idx], Common::Point(xp, yp), color); yp += _surface.fontHeight() + 1; } // Draw the Scrollbar if neccessary if (mode != RENDER_NAMES) drawScrollBar(_savegameIndex, FILES_LINES_COUNT, _savegames.size()); }
OptimizationAlgorithm::SolverResult OptimizationAlgorithmVP::solve(int iteration, bool online) { assert(_optimizer && "_optimizer not set"); assert(_solver->optimizer() == _optimizer && "underlying linear solver operates on different graph"); bool ok = true; //here so that correct component for max-mixtures can be computed before the build structure double t=get_monotonic_time(); _optimizer->computeActiveErrors(); G2OBatchStatistics* globalStats = G2OBatchStatistics::globalStats(); if (globalStats) { globalStats->timeResiduals = get_monotonic_time()-t; } double preProjCost = 0; if (_projectNextIter) preProjCost = _optimizer->activeRobustChi2(); if (iteration == 0 && !online) { // built up the CCS structure, here due to easy time measure if (_projectNextIter) { ok = _solver->buildStructureLinear(); assert(ok); } ok = _solver->buildStructure(); if (! ok) { cerr << __PRETTY_FUNCTION__ << ": Failure while building CCS structure" << endl; return OptimizationAlgorithm::Fail; } } // is the position-position block of omega spherical? bool isSpherical = SPHERICAL; if (iteration == 0) cerr << "[VP]: isSpherical = " << isSpherical << " - Gamma_t = " << _gammaThreshold << "\n"; if (_projectNextIter) { if (iteration > 0 && isSpherical == true) { _solver->buildSystemSpherical(); _solver->project(isSpherical); _optimizer->updateLinear(_solver->xLinear()); _optimizer->computeActiveErrors(); } else { // not spherical or iteration = 0 _solver->buildSystemLinear(); _solver->project(); _optimizer->updateLinear(_solver->xLinear()); _optimizer->computeActiveErrors(); assert(preProjCost); double postProjCost = _optimizer->activeRobustChi2(); cerr << "[VP]: Cost Before Proj = " << preProjCost << " -> Cost After Proj = " << postProjCost << "\n"; /* gamma the gain */ double gamma = postProjCost/preProjCost; cerr << "[VP]: Gamma = " << FIXED(gamma) << endl; if (gamma > _gammaThreshold && isSpherical == false) { // no more projection step _projectNextIter = false; cerr << "[VP]: _projNextIter : true -> false" << endl; } } } t=get_monotonic_time(); _solver->buildSystem(); if (globalStats) { globalStats->timeQuadraticForm = get_monotonic_time()-t; t=get_monotonic_time(); } ok = _solver->solve(); if (globalStats) { globalStats->timeLinearSolution = get_monotonic_time()-t; t=get_monotonic_time(); } _optimizer->update(_solver->x()); if (globalStats) { globalStats->timeUpdate = get_monotonic_time()-t; } if (ok) return OK; else return Fail; }
int Darts::throwDart(int dartNum, int computer) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; int height; int horiz; Common::Point targetPos; Common::String temp; /* clear keyboard buffer */ events.clearEvents(); erasePowerBars(); screen.print(Common::Point(_dartInfo.left, _dartInfo.top), 0, "%s # %d", FIXED(Dart), dartNum); drawDartsLeft(dartNum, computer); if (!computer) { screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, "%s", FIXED(HitAKey)); screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 2), 0, "%s", FIXED(ToStart)); } if (!computer) { // Wait for a hit while (!dartHit()) ; } else { events.wait(1); } drawDartsLeft(dartNum + 1, computer); screen._backBuffer2.blitFrom(screen._backBuffer1, Common::Point(_dartInfo.left, _dartInfo.top - 1), Common::Rect(_dartInfo.left, _dartInfo.top - 1, _dartInfo.right, _dartInfo.bottom - 1)); screen.blitFrom(screen._backBuffer1, Common::Point(_dartInfo.left, _dartInfo.top - 1), Common::Rect(_dartInfo.left, _dartInfo.top - 1, _dartInfo.right, _dartInfo.bottom - 1)); if (computer) { getComputerNumber(computer - 1, targetPos); } else { // Keyboard control targetPos = Common::Point(0, 0); } horiz = drawHand(targetPos.x, computer); height = doPowerBar(Common::Point(DART_BAR_VX, DART_HEIGHT_Y), DART_COLOR_FORE, targetPos.y, 1); // Invert height height = 101 - height; // Copy power bars to the secondary back buffer screen._backBuffer2.blitFrom(screen._backBuffer1, Common::Point(DART_BAR_VX - 1, DART_HEIGHT_Y - 1), Common::Rect(DART_BAR_VX - 1, DART_HEIGHT_Y - 1, DART_BAR_VX - 1 + 10, DART_HEIGHT_Y - 1 + DART_BAR_SIZE + 2)); Common::Point dartPos(DARTBOARD_TOTALLEFT + horiz*DARTBOARD_TOTALX / 100, DARTBOARD_TOTALTOP + height * DARTBOARD_TOTALY / 100); dartPos.x += 2 - _vm->getRandomNumber(4); dartPos.y += 2 - _vm->getRandomNumber(4); drawDartThrow(dartPos, computer); return dartScore(dartPos); }
void WidgetQuit::handleEvents() { Events &events = *_vm->_events; Talk &talk = *_vm->_talk; Common::Point mousePos = events.mousePos(); Common::Rect yesRect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3, _bounds.right, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 7); Common::Rect noRect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + _surface.fontHeight() + 10, _bounds.right, _bounds.top + (_surface.fontHeight() + 4) * 2 + 10 + _surface.fontHeight() * 2 + 7); if (talk._talkToAbort) return; // Determine the highlighted item _select = -1; if (yesRect.contains(mousePos)) _select = 1; else if (noRect.contains(mousePos)) _select = 0; if (events.kbHit()) { Common::KeyState keyState = events.getKey(); switch (keyState.keycode) { case Common::KEYCODE_TAB: // If the mouse is not over any of the options, move the mouse so that it points to the first option if (_select == -1) events.warpMouse(Common::Point(_bounds.right - 10, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 1)); else if (_select == 1) events.warpMouse(Common::Point(mousePos.x, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() * 2 + 11)); else events.warpMouse(Common::Point(mousePos.x, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 1)); break; case Common::KEYCODE_ESCAPE: case Common::KEYCODE_n: close(); return; case Common::KEYCODE_y: close(); _vm->quitGame(); break; default: break; } } // Check for change of the highlighted item if (_select != _oldSelect) { byte color = (_select == 1) ? COMMAND_HIGHLIGHTED : INFO_TOP; int yp = (_surface.fontHeight() + 4) * 2 + 8; _surface.writeString(FIXED(Yes), Common::Point((_surface.width() - _surface.stringWidth(FIXED(Yes))) / 2, yp), color); color = (_select == 0) ? COMMAND_HIGHLIGHTED : INFO_TOP; yp += (_surface.fontHeight() + 7); _surface.writeString(FIXED(No), Common::Point((_surface.width() - _surface.stringWidth(FIXED(No))) / 2, yp), color); } _oldSelect = _select; // Flag is they started pressing outside of the menu if (events._firstPress && !_bounds.contains(mousePos)) _outsideMenu = true; if (events._released || events._rightReleased) { events.clearEvents(); close(); if (_select == 1) // Yes selected _vm->quitGame(); } }
void test_composite(uint32_t blend_mode, uint32_t dst_format, uint32_t dst_width, uint32_t dst_height, uint32_t src_format, uint32_t src_width, uint32_t src_height, uint32_t mask_format, uint32_t mask_width, uint32_t mask_height, uint32_t src_x, uint32_t src_y, uint32_t mask_x, uint32_t mask_y, uint32_t dst_x, uint32_t dst_y, uint32_t w, uint32_t h) { PixmapPtr src, dest, mask = NULL; C2D_OBJECT blit = {}; c2d_ts_handle curTimestamp; DEBUG_MSG("composite2: blend_mode:%08x, dst_format:%08x, dst_width:%x, dst_height=%x, " "src_format:%08x, src_width:%x, src_height:%x, " "mask_format:%08x, mask_width:%x, mask_height:%x, " "src_x:%x, src_y:%x, mask_x:%x, mask_y:%x, dst_x:%x, dst_y:%x, w:%x, h:%x", blend_mode, dst_format, dst_width, dst_height, src_format, src_width, src_height, mask_format, mask_width, mask_height, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); RD_START("composite2","blend_mode:%08x, dst_format:%08x, dst_width:%x, dst_height=%x, " "src_format:%08x, src_width:%x, src_height:%x, " "mask_format:%08x, mask_width:%x, mask_height:%x, " "src_x:%x, src_y:%x, mask_x:%x, mask_y:%x, dst_x:%x, dst_y:%x, w:%x, h:%x", blend_mode, dst_format, dst_width, dst_height, src_format, src_width, src_height, mask_format, mask_width, mask_height, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); blit.config_mask = DEFAULT_BLEND_MASK | blend_mode; dest = create_pixmap(dst_width, dst_height, dst_format); src = create_pixmap(src_width, src_height, src_format); blit.config_mask |= C2D_SOURCE_RECT_BIT; blit.surface_id = src->id; if (mask_format) { /* TODO not clear if mask repeat is really supported.. msm-exa-c2d2.c * seems to reject it but C2D_MASK_TILE_BIT?? * * Also, for src format, msm-exa-c2d2.c seems to encode fgcolor (like * a solid fill) for repeats.. not really clear if TILE_BIT does what * we expect or not?? * * Seems like libC2D2 doesn't actually give any way to specify the * maskX/maskY!!! The previous c2d API does, so I'd have to assume * this is actually supported by the hardware and this is just C2D2 * retardation */ mask = create_pixmap(mask_width, mask_height, mask_format); blit.config_mask |= C2D_MASK_SURFACE_BIT; blit.mask_surface_id = mask->id; } blit.next = NULL; blit.source_rect.x = FIXED(src_x); blit.source_rect.y = FIXED(src_y); blit.source_rect.width = FIXED(w); blit.source_rect.height = FIXED(h); blit.target_rect.x = FIXED(dst_x); blit.target_rect.y = FIXED(dst_y); blit.target_rect.width = FIXED(w); blit.target_rect.height = FIXED(h); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); free_pixmap(src); free_pixmap(dest); if (mask) free_pixmap(mask); RD_END(); // dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }