Exemple #1
0
void Mbc1::StoreRom(u16 addr, u8 val)
{
    if (addr < 0x2000)
    {
        _ramEnabled = (val & 0x0A) == 0x0A;
    }
    else if (addr < 0x4000)
    {
        _reg2000 = val & 0x1F;
        CalculateOffsets();
    }
    else if (addr < 0x6000)
    {
        _reg4000 = val & 0x03;
        CalculateOffsets();
    }
    else if (addr < 0x8000)
    {
        _reg6000 = ((val & 1) != 0);
        CalculateOffsets();
    }
    else
    {
        __debugbreak();
    }
}
Exemple #2
0
LevelSelectCell::LevelSelectCell(const String& name, const UI::RenderableRect& Rect, UI::Screen* parent)
    : UI::Cell(name,parent)
      //PreviewImageOffset(Vector2(-0.005,-0.005)),
      //PreviewBorderOffset(Vector2(-0.01,-0.01)),
      //LevelTitleOffset(Vector2(0.115,0.01)),
      //EarnedScoreOffset(Vector2(0.18,0.05))
{
    const Vector2& WinDim = ParentScreen->GetViewportDimensions();
    UI::RenderableRect PIRect, PBRect, LTRect, ESRect;
    if(Rect.Relative)
    {
        RelPosition = Rect.Position;
        RelSize = Rect.Size;

        CalculateOffsets(Rect.Size * WinDim);

        PIRect.Position = Rect.Position+(PreviewImageOffset / WinDim);
        PIRect.Size = Vector2(Rect.Size.Y * 1.30,Rect.Size.Y * 1.05);
        PIRect.Relative = Rect.Relative;
        PBRect.Position = Rect.Position+(PreviewBorderOffset / WinDim);
        PBRect.Size = Vector2(Rect.Size.Y * 1.40,Rect.Size.Y * 1.15);
        PBRect.Relative = Rect.Relative;
        LTRect.Position = Rect.Position+(LevelTitleOffset / WinDim);
        LTRect.Size = Vector2(Rect.Size.X * 0.6,Rect.Size.Y * 0.36);
        LTRect.Relative = Rect.Relative;
        ESRect.Position = Rect.Position+(EarnedScoreOffset / WinDim);
        ESRect.Size = Vector2(Rect.Size.X * 0.4,Rect.Size.Y * 0.36);
        ESRect.Relative = Rect.Relative;
    }else{
        RelPosition = Rect.Position / WinDim;
        RelSize = Rect.Size / WinDim;

        CalculateOffsets(Rect.Size);

        PIRect.Position = Rect.Position+PreviewImageOffset;
        PIRect.Size = Vector2(Rect.Size.Y * 1.30,Rect.Size.Y * 1.05);
        PIRect.Relative = Rect.Relative;
        PBRect.Position = Rect.Position+PreviewBorderOffset;
        PBRect.Size = Vector2(Rect.Size.Y * 1.40,Rect.Size.Y * 1.15);
        PBRect.Relative = Rect.Relative;
        LTRect.Position = Rect.Position+LevelTitleOffset;
        LTRect.Size = Vector2(Rect.Size.X * 0.6,Rect.Size.Y * 0.36);
        LTRect.Relative = Rect.Relative;
        ESRect.Position = Rect.Position+EarnedScoreOffset;
        ESRect.Size = Vector2(Rect.Size.X * 0.4,Rect.Size.Y * 0.36);
        ESRect.Relative = Rect.Relative;
    }

    CellBack = ParentScreen->CreateRectangle(Rect);
    PreviewImage = ParentScreen->CreateRectangle(PIRect);
    PreviewBorder = ParentScreen->CreateRectangle(PBRect);
    LevelTitle = ParentScreen->CreateCaption(Name+"LT",LTRect,Real(Rect.Size.Y * 0.36),Name);
    EarnedScore = ParentScreen->CreateCaption(Name+"ES",ESRect,Real(Rect.Size.Y * 0.36),"0/0");
    AddSubRenderable(0,CellBack);
    AddSubRenderable(1,PreviewImage);
    AddSubRenderable(2,PreviewBorder);
    AddSubRenderable(3,LevelTitle);
    AddSubRenderable(4,EarnedScore);
}
clTabInfo::clTabInfo(clTabCtrl* tabCtrl, size_t style, wxWindow* page, const wxString& text, const wxBitmap& bmp)
    : m_tabCtrl(tabCtrl)
    , m_label(text)
    , m_bitmap(bmp)
    , m_window(page)
    , m_active(false)
{
    CalculateOffsets(style);
}
Exemple #4
0
void LevelSelectCell::UpdateDimensions()
{
    UI::WidgetResult Result = UI::ViewportUpdateTool::UpdateWidget(this);
    RelPosition = Result.first / UI::ViewportUpdateTool::GetNewSize();
    RelSize = Result.second / UI::ViewportUpdateTool::GetNewSize();
    CellBack->UpdateDimensions();
    PreviewImage->UpdateDimensions();
    PreviewBorder->UpdateDimensions();
    LevelTitle->UpdateDimensions();
    EarnedScore->UpdateDimensions();
    CalculateOffsets(Result.second);
    SetPosition(RelPosition);
}
clTabInfo::clTabInfo(clTabCtrl* tabCtrl)
    : m_tabCtrl(tabCtrl)
    , m_window(NULL)
    , m_active(false)
    , m_textX(wxNOT_FOUND)
    , m_textY(wxNOT_FOUND)
    , m_bmpX(wxNOT_FOUND)
    , m_bmpY(wxNOT_FOUND)
    , m_bmpCloseX(wxNOT_FOUND)
    , m_bmpCloseY(wxNOT_FOUND)
{

    CalculateOffsets(0);
}
ECode CYuvImage::CompressToJpeg(
    /* [in] */ IRect* rectangle,
    /* [in] */ Int32 quality,
    /* [in] */ IOutputStream* stream,
    /* [out] */ Boolean* result)
{
    VALIDATE_NOT_NULL(result);

    AutoPtr<IRect> wholeImage;
    CRect::New(0, 0, mWidth, mHeight, (IRect**)&wholeImage);

    Boolean res;
    if (wholeImage->Contains(rectangle, &res), !res) {
        // throw new IllegalArgumentException(
        //             "rectangle is not inside the image");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }

    if (quality < 0 || quality > 100) {
        // throw new IllegalArgumentException("quality must be 0..100");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }

    if (stream == NULL) {
        // throw new IllegalArgumentException("stream cannot be null");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }

    AdjustRectangle(rectangle);
    AutoPtr< ArrayOf<Int32> > offsets = CalculateOffsets(
        ((CRect*)rectangle)->mLeft,
        ((CRect*)rectangle)->mTop);

    Int32 width;
    Int32 height;
    rectangle->GetWidth(&width);
    rectangle->GetHeight(&height);
    AutoPtr< ArrayOf<Byte> > tempStorage = ArrayOf<Byte>::Alloc(WORKING_COMPRESS_STORAGE);
    *result = NativeCompressToJpeg(
                mData,
                mFormat,
                width,
                height,
                offsets,
                mStrides,
                quality,
                stream,
                tempStorage);
    return NOERROR;
}
void clTabInfo::SetActive(bool active, size_t style)
{
    this->m_active = active;
    CalculateOffsets(style);
}
void clTabInfo::SetLabel(const wxString& label, size_t style)
{
    this->m_label = label;
    CalculateOffsets(style);
}
void clTabInfo::SetBitmap(const wxBitmap& bitmap, size_t style)
{
    this->m_bitmap = bitmap;
    CalculateOffsets(style);
}
  //
  // Check
  //
  // Check if allowed to build at the given location
  //
  Placement::Result Placement::Check(const Matrix &location, U32 flags)
  {
    ASSERT(IsSetup());

    S32 xZip, zZip, xFoot, zFoot;
    S32 xMax, zMax;
    S32 x, z;

    // Reset the array
    Reset();

    // Set default result
    result = PR_OK;

    // Get direction
    dir = WorldCtrl::GetCompassDirection(location.front);

    // Get cell in bottom left corner of footprint
    FindOrigin(location, dir, min);

    // Setup extents using current direction
    SetupMaximums(xMax, zMax, size.x, size.z, dir);

    // Save max point
    max.Set(min.x + xMax - 3, min.z + zMax - 3);

    // Step over footprint in terrain space
    // This loop must occur before the thump simulation, as cell.map has to be set up
    for (z = 0; z < zMax; z++)
    {
      for (x = 0; x < xMax; x++)
      {
        // Convert the terrain offset to footprint offsets
        CalculateOffsets(dir, size.x, size.z, x, z, xZip, zZip, xFoot, zFoot);

        // Get the placement cell at this position
        Cell &cell = GetCell(xFoot, zFoot);

        // Is this a zipping location (not on a lower fringe)
        if (x > 0 && z > 0)
        {
          // Save zipping value, adjusting for fringe
          cell.zip.Set(xZip - 1, zZip - 1);

          ASSERT(cell.zip.x >= 0);
          ASSERT(cell.zip.z >= 0);
        }

        // Get actual terrain cell position
        cell.map.Set(min.x + x - 1, min.z + z - 1);
      }
    }

    // If we are doing a thumping simulation, then thumped.valid is TRUE and the
    // real TerrainData::Cell will be substituted for the thumped version when
    // performing the placement check.
    // Otherwise, the real terrain cell will be used
    if (flags & CHECK_NOTHUMPTEST)
    {
      // Thumped is no longer valid
      thumped.Invalidate();
    }
    else
    {
      // Copy terrain into thumped buffer
      if (thumped.CopyTerrain())
      {
        // Calculate the best height to build at
        thumpHeight = thumped.CalcBestHeight();

        // Thump terrain into the thumped buffer
        ThumpTerrain(thumpHeight, 0.0F, THUMP_TOBUFFER);

        // Update slopes
        thumped.UpdateCells();
      }
    }

    // UnitObjType is used inside the loop
    UnitObjType *unitObjType = Promote::Type<UnitObjType>(&type->GetMapType());

    // Step over footprint in terrain space
    for (z = 0; z < zMax; z++)
    {
      for (x = 0; x < xMax; x++)
      {
        // Default cell result to ok
        Result r = PR_OK;

        // Convert the terrain offset to footprint offsets
        CalculateOffsets(dir, size.x, size.z, x, z, xZip, zZip, xFoot, zFoot);

        // Get the placement cell at this position
        Cell &cell = GetCell(xFoot, zFoot);

        // Is this position on the map
        if (WorldCtrl::CellOnMapNoEdge(cell.map.x, cell.map.z))
        {
          // Get the map cell at this location
          TerrainData::Cell &origCell = TerrainData::GetCell(cell.map.x, cell.map.z);

          // Get the thumped cell at this location
          TerrainData::Cell *thumpCell = thumped.IsValid() ? thumped.GetCell(x, z) : NULL;

          // Is there another footprint at this location
          if (!AvailableInstanceIndex(origCell.footIndex))
          {           
            r = (cell.onFoot) ? PR_FOOTON : PR_FOOTOFF;
          }
          else

          if (!TestThumpArea(cell.map, cell.map))
          {
            r = PR_THUMPING;
          }
          else

          // Is this position on the footprint
          if (cell.onFoot)
          {
            Point<S32> g;
          
            // Convert cell to grain
            WorldCtrl::CellToFirstGrain(cell.map.x, cell.map.z, g.x, g.z);

            // Get the type cell
            Type::Cell &typeCell = GetType().GetCell(cell.type.x, cell.type.z);

            // Probe lower grains
            if (typeCell.GetFlag(Type::CLAIMLO) && ClaimBlock(g, Claim::LAYER_LOWER, flags))
            {
              r = PR_CLAIM;
            }
            else

            // Probe upper grains
            if (typeCell.GetFlag(Type::CLAIMHI) && ClaimBlock(g, Claim::LAYER_UPPER, flags))
            {
              r = PR_CLAIM;
            }
            else

            // Can this object build on this location
            if (!PathSearch::CanMoveToCell(type->GetMapType().GetTractionIndex(type->GetMapType().GetDefaultLayer()), origCell))
            {
              r = PR_CANMOVETO;
            }
            else

            if (thumpCell && !PathSearch::CanMoveToCell(type->GetMapType().GetTractionIndex(type->GetMapType().GetDefaultLayer()), *thumpCell))
            {
              r = PR_CANMOVETO;
            }
            else

            // Is this cell shrouded
            if (!(flags & CHECK_IGNORESHROUD) && team && !Sight::Seen(cell.map.x, cell.map.z, team))
            {
              r = PR_SHROUDED;
            }
          }
          else
          {
            if (unitObjType)
            {
              if (unitObjType->CanBoard())
              {
                // The pathability check is extended to the fringe cells for objects that can have a board manager
                if (!PathSearch::CanMoveToCell(type->GetMapType().GetTractionIndex(type->GetMapType().GetDefaultLayer()), origCell))
                {
                  r = PR_CANMOVETO;
                }
                else

                if (thumpCell && !PathSearch::CanMoveToCell(type->GetMapType().GetTractionIndex(type->GetMapType().GetDefaultLayer()), *thumpCell))
                {
                  r = PR_CANMOVETO;
                }
              }
              else
              {
                // Not allowed to change the pathability state from passabable to impassable
                if (PathSearch::CanMoveToCell(type->GetMapType().GetTractionIndex(type->GetMapType().GetDefaultLayer()), origCell))
                {
                  if (thumpCell && !PathSearch::CanMoveToCell(type->GetMapType().GetTractionIndex(type->GetMapType().GetDefaultLayer()), *thumpCell))
                  {
                    r = PR_CANMOVETO;
                  }
                }
              }
            }
          }
        }
        else
        {
          r = PR_OFFMAP;
        }

        // Save result in cell
        cell.result = r;

        // Save significant results
        if (!Acceptable(r) || result == PR_OK)
        {
          result = r;
        }
      }
    }

    return (result);
  }