Пример #1
0
/*** AG Link finder, to work with TAB key ***/
void FindNextLink( struct scrpos *inf, char dir )
{
	AGNode src = (AGNode) inf->node;

	/* If there was a previous active link, reset styles */
	if( src->ActiveLink )
		src->ActiveLink->bgpen = DEF_BGPEN,
		src->ActiveLink->style = DEF_LINKSTYLE;

	/* If there is no previous selected link, or it is now outside **
	** the visible area, choose a new one, starting from topline.  */
	if( src->ActiveLink == NULL || src->ActiveLine < src->line ||
	    src->ActiveLine >= src->line+inf->height-1 )
	{
		short nb;
		src->ActiveLink = WordsPara( src->StartLine = src->Shown );
		src->ActiveLine = src->line;
		/* Start at bottom of screen, if backward scan */
		if( dir == -1 )
		{
			for(nb=inf->height-2; nb && NEXT(src->StartLine);
			    nb--,src->StartLine=NEXT(src->StartLine),src->ActiveLine++);
			src->ActiveLink = EndOfLine( src->StartLine );
		}
			
	} else {
		/* Unhilight previous visible link */
		tabs = src->StartLine->ts;
		set_cursor_pos(src->ActiveLine - src->line + 1, 0);
		RenderLine(src->StartLine, src->column, inf->width, OVERWRITE);
		NextLink( src, dir );
	}

	/* Search for the next available link following current position */
	while( src->StartLine )
	{
		AGWord wrd = src->ActiveLink;
		if(wrd && wrd->data != NULL && wrd->link) break;
		NextLink( src, dir );
		/* If `cursor' go outside visible area, resets it */
		if( src->ActiveLine >= src->line + inf->height - 1 ||
		    src->ActiveLine <  src->line )
		{
			src->ActiveLink = NULL;
			break;
		}
	}
	/* Hilite the new one */
	if( src->ActiveLink )
	{
		src->ActiveLink->bgpen = DEF_ACTIVELINK;
		src->ActiveLink->style = DEF_LINKSTYLE | FSF_INVERSID;

		tabs = src->StartLine->ts;
		set_cursor_pos(src->ActiveLine - src->line + 1, 0);
		RenderLine(src->StartLine, src->column, inf->width, OVERWRITE);
	}
	set_cursor_pos(inf->height,6);
	fflush(stdout);
}
Пример #2
0
      /// <summary>Draw multiple lines of rich text</summary>
      /// <param name="dc">dc.</param>
      /// <param name="rect">drawing rectangle</param>
      /// <param name="str">string.</param>
      /// <param name="flags">drawing flags.</param>
      /// <exception cref="Logic::Win32Exception">Drawing error</exception>
      /// <returns>Width of widest line</returns>
      int  RichTextRenderer::DrawLines(CDC* dc, CRect& rect, const RichString& str, RenderFlags flags)
      {
         LOGFONT  fontData;
         CFont*   oldFont;
         LineRect line(rect, dc->GetTextExtent(L"ABC").cy);
         long     rightMargin = rect.left;

         // Get original font properties
         oldFont = dc->GetCurrentFont();
         if (!oldFont->GetLogFont(&fontData))
            throw Win32Exception(HERE, L"Unable to get logical font");
         
         // Draw paragraphs
         for (auto para = str.Paragraphs.begin(); para != str.Paragraphs.end(); )
         {
            auto words(GetWords(*para));

            // Draw words
            for (auto w = words.begin(); w != words.end(); )
            {
               CRect remaining(line);

               // Measure words on line
               auto first = w;
               int line_remaining = MeasureLine(dc, w, words.end(), line, flags);

               // Alignment: Offset all word rectangles
               for (auto word = first; word != w; ++word)
               {
                  switch (para->Align)
                  {
                  case Alignment::Right:   word->Offset(line_remaining, 0);    break;
                  case Alignment::Centre:
                  case Alignment::Justify: word->Offset(line_remaining/2, 0);  break;
                  }

                  // Set rightmost margin
                  rightMargin = max(rightMargin, word->Rect.right);
               }

               // Render words
               if (flags != RenderFlags::Calculate)
                  RenderLine(dc, first, w, flags);

               // NewLine
               if (w != words.end())
                  line.Advance();
            }

            // Start each paragraph on a separate line
            if (++para != str.Paragraphs.end())
               line.Advance();
         }

         // Set drawing extent
         rect.bottom = (!str.FirstParagraph.empty() ? line.bottom : line.top);

         // Return width of widest line of text
         return rightMargin - rect.left;
      }
Пример #3
0
      void RenderPolygons()
      {
         for (fdword i = 0; i < polyPrimitiveCount; i++)
         {
            switch(polyPrimitives[i].m_type)
            {
            case PolyPrimitive::POLY_LINE:
               RenderLine(polyPrimitives[i]);
               break;

            case PolyPrimitive::POLY_VECTOR:
               RenderVector(polyPrimitives[i]);
               break;

            case PolyPrimitive::POLY_RECTANGLE:
               RenderRectangle(polyPrimitives[i]);
               break;

            case PolyPrimitive::POLY_CIRCLE:
               RenderCircle(polyPrimitives[i]);
               break;

            case PolyPrimitive::POLY_FILLED_RECTANGLE:
               RenderFilledRectangle(polyPrimitives[i]);
               break;

            case PolyPrimitive::POLY_FILLED_CIRCLE:
               RenderFilledCircle(polyPrimitives[i]);
               break;

            }
         }

         polyPrimitiveCount = 0;
      }
Пример #4
0
static void RenderNextLineIfNeeded() {
  Area2D rect = {0, 0, WIDTH, SIZE};
  WORD s = frameCount / 16;

  if (s > last_line) {
    APTR ptr = scroll->planes[0];
    WORD line_num = (s % (LINES + 2)) * SIZE;
    char *line_end;
    WORD size;

    line_end = line_start;
    NextLine(&line_end);
    size = (line_end - line_start) - 1;

    ptr += line_num * scroll->bytesPerRow;

    rect.y = line_num;
    BitmapClearArea(scroll, &rect);
    WaitBlitter();
    RenderLine(ptr, line_start, min(size, COLUMNS));

    last_line = s;
    NextLine(&line_start);
  }
}
Пример #5
0
      /// <summary>Draw rich text in a single line</summary>
      /// <param name="dc">dc.</param>
      /// <param name="line">line rect</param>
      /// <param name="str">string.</param>
      /// <param name="flags">How to modify colours for light/dark backgrounds.</param>
      /// <exception cref="Logic::Win32Exception">Drawing error</exception>
      void  RichTextRenderer::DrawLine(CDC* dc, CRect line, const RichString& str, RenderFlags flags)
      {
         // Separate into phrases
         auto words = GetPhrases(str);

         // Measure phrases
         auto first = words.begin(), last = first;
         int line_remaining = MeasureLine(dc, last, words.end(), line, flags);

         // Vertical Centre
         auto textHeight = dc->GetTextExtent(L"ABC").cy;
         auto vCentre = (line.Height() > textHeight ? (line.Height() - textHeight) / 2 : 0);

         // ListView: Always render left-aligned
         if (flags == RenderFlags::Inverted || flags == RenderFlags::Selected)
            line_remaining = 0;

         // Alignment: Offset all word rectangles
         for (auto w = first; w != last; ++w)
         {
            switch (str.FirstParagraph.Align)
            {
            case Alignment::Left:    w->Offset(0, vCentre);                 break;
            case Alignment::Right:   w->Offset(line_remaining, vCentre);    break;
            case Alignment::Centre:
            case Alignment::Justify: w->Offset(line_remaining/2, vCentre);  break;
            }
         }

         // Render words
         RenderLine(dc, first, last, flags);
      }
Пример #6
0
void FormatText::PushTextWrapped(
        FTTextureFont* font,
        float x,
        float y,
        const char* text,
        const Vector& colour,
        AlignX::Enum alignX,
        AlignY::Enum alignY,
        float maxwidth)
{
    float ignore = -1;
    float yOffset = 0;
    if(alignY == AlignY::Bottom)
    {
        float lines = (float) CountLines(font, text, maxwidth, &ignore)  - 1;
        yOffset = ((float)lines) * FormatText::GetFaceMaxHeight(font);
    }
    else if(alignY == AlignY::Center)
    {
        float lines = (float) CountLines(font, text, maxwidth, &ignore)  - 1;
        lines *= 0.5;
        float lineHeight = FormatText::GetFaceMaxHeight(font);
        yOffset = (lines *  lineHeight) - lineHeight*0.25;
    }
    else
    {
        yOffset = -GetFaceMaxHeight(font) * 0.75;
    }

    int lineEnd = 0;
    do
    {
        int outStart = 0;
        float outPixelWidth = 0;
        //dsprintf("\tNextline cursor[%d] char[%c]\n", lineEnd, text[lineEnd]);
        NextLine(font, text, lineEnd, maxwidth,
                    &outStart,
                    &lineEnd,
                    &outPixelWidth);
        //dsprintf("Output: outStart[%d] outFinish[%d], outPixelWidth[%f]\n",
        //     outStart, lineEnd, outPixelWidth);
        float xPos = x;
        if(alignX == AlignX::Right)
        {
            xPos -= outPixelWidth;
        }
        else if(alignX == AlignX::Center)
        {
            xPos -= outPixelWidth / 2;
        }

        RenderLine(font, xPos, y + yOffset, text, outStart, lineEnd);
        y = y - GetFaceMaxHeight(font);
    } while (text[lineEnd] != '\0');

    return;
}
Пример #7
0
void RenderPolyScene::RenderSubsector(PolyRenderThread *thread, subsector_t *sub, uint32_t subsectorDepth)
{
	sector_t *frontsector = sub->sector;
	auto Level = frontsector->Level;
	frontsector->MoreFlags |= SECMF_DRAWN;

	if (sub->polys)
	{
		if (sub->BSP == nullptr || sub->BSP->bDirty)
		{
			sub->BuildPolyBSP();

			// This is done by the GL renderer, but not the sw renderer. No idea what the purpose is..
			for (unsigned i = 0; i < sub->BSP->Segs.Size(); i++)
			{
				sub->BSP->Segs[i].Subsector = sub;
				sub->BSP->Segs[i].PartnerSeg = nullptr;
			}
		}

		if (sub->BSP->Nodes.Size() == 0)
		{
			RenderPolySubsector(thread, &sub->BSP->Subsectors[0], subsectorDepth, frontsector);
		}
		else
		{
			RenderPolyNode(thread, &sub->BSP->Nodes.Last(), subsectorDepth, frontsector);
		}
	}

	PolyTransferHeights fakeflat(sub);

	Render3DFloorPlane::RenderPlanes(thread, sub, CurrentViewpoint->StencilValue, subsectorDepth, thread->TranslucentObjects);
	RenderPolyPlane::RenderPlanes(thread, fakeflat, CurrentViewpoint->StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, thread->SectorPortals, CurrentViewpoint->SectorPortalsStart);

	for (uint32_t i = 0; i < sub->numlines; i++)
	{
		if (Cull.IsLineSegVisible(subsectorDepth, i))
		{
			seg_t *line = &sub->firstline[i];
			RenderLine(thread, sub, line, fakeflat.FrontSector, subsectorDepth);
		}
	}

	int subsectorIndex = sub->Index();
	for (int i = Level->ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Level->Particles[i].snext)
	{
		FParticle *particle = &Level->Particles[i];
		thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentParticle>(particle, sub, subsectorDepth, CurrentViewpoint->StencilValue));
	}
}
Пример #8
0
    STARTDECL(gl_line) (Value &start, Value &end, Value &thickness)
    {
        TestGL();

        auto v1 = ValueDecTo<float3>(start);
        auto v2 = ValueDecTo<float3>(end);

        float angle = atan2f(v2.y() - v1.y(), v2.x() - v1.x());
        float3 v = float3(sinf(angle), -cosf(angle), 0) * thickness.fval / 2;

        RenderLine(currentshader, polymode, v1, v2, v);

        return Value();
    }
Пример #9
0
void RenderCircle(float x, float y, float r, D3DCOLOR col)
{
	#define step 0.2f

	D3DXVECTOR2 p1, p2;
	for (float i = 0; i < 2*PI; i += step)
	{
		p1.x = x + (float)sin(i) * r;
		p1.y = y + (float)cos(i) * r;

		p2.x = x + (float)sin(i + step) * r;
		p2.y = y + (float)cos(i + step) * r;

		RenderLine(p1, p2, col);
	}
}
Пример #10
0
void
avtOpenGLCurveRenderer::RenderCurves()
{
    //
    // Make the OpenGL calls to get it into the desired state.
    //
    SetupGraphicsLibrary();

    //
    // Set up the OpenGL state
    //

    // Turn off lighting if it's on.
    GLboolean enableLighting;
    glGetBooleanv(GL_LIGHTING, &enableLighting);
    if(enableLighting)
        glDisable(GL_LIGHTING);

    // Disable depth testing
    GLboolean enableDepthTest;
    glGetBooleanv(GL_DEPTH_TEST, &enableDepthTest);
    if(enableDepthTest)
        glDisable(GL_DEPTH_TEST);

    if (atts.GetShowLines())
        DrawCurveAsLines();

    if (atts.GetShowPoints())
        DrawCurveAsSymbols();

    if (atts.GetDoLineTimeCue())
    {
        RenderLine();
    }
    if (atts.GetDoBallTimeCue())
    {
        RenderBall();
    }

    // Enable depth testing if it was on.
    if(enableDepthTest)
        glEnable(GL_DEPTH_TEST);

    // Enable lighting again if it was on.
    if(enableLighting)
        glEnable(GL_LIGHTING);
}
Пример #11
0
	void	cCurve::RenderCurve(Vector4 e_vColor,cMatrix44 e_mat)
	{
		if( m_FinallyPointList.size() < 2 )
		{
			if( m_FinallyPointList.size() == 1 )
				RenderPoints(&m_OriginalPointList[0],(int)m_OriginalPointList.size(),10,e_vColor,e_mat);
			return;
		}
		//draw line
		std::vector<Vector3>	l_CurvePointVector;
		int	l_iNumPoint = ((int)m_FinallyPointList.size()-1)*2;
		l_CurvePointVector.resize(l_iNumPoint);
		for( int i=0;i<l_iNumPoint/2;++i )
		{
			l_CurvePointVector[i*2] = m_FinallyPointList[i];
			l_CurvePointVector[i*2+1] = m_FinallyPointList[i+1];
		}
		RenderLine((float*)&l_CurvePointVector[0],l_iNumPoint,e_vColor,3,e_mat);
		RenderPoints(&m_OriginalPointList[0],(int)m_OriginalPointList.size(),10,e_vColor,e_mat);
	}
Пример #12
0
void OpenGLRenderer::RenderPrimitive(PrimitiveType primitive)
{
	switch (primitive)
	{
	case AbstractRenderer::Point:
		RenderPoint();
		break;
	case AbstractRenderer::Line:
		RenderLine();
		break;
	case AbstractRenderer::Triangle:
		RenderTriangle();
		break;
	case AbstractRenderer::Quad:
		RenderQuad();
		break;
	default:
		break;
	}
}
Пример #13
0
void S9xDoHBlankProcessing ()
{
#ifdef CPU_SHUTDOWN
    CPU.WaitCounter++;
#endif
    switch (CPU.WhichEvent)
    {
    case HBLANK_START_EVENT:
		if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
			IPPU.HDMA = S9xDoHDMA (IPPU.HDMA);
	break;

    case HBLANK_END_EVENT:
	S9xSuperFXExec ();

#ifndef STORM
	if (Settings.SoundSync)
	    S9xGenerateSound ();
#endif

	CPU.Cycles -= Settings.H_Max;
	if (IAPU.APUExecuting)
	    APU.Cycles -= Settings.H_Max;
	else
	    APU.Cycles = 0;

	CPU.NextEvent = -1;
	ICPU.Scanline++;

	if (++CPU.V_Counter > (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER))
	{
	    PPU.OAMAddr = PPU.SavedOAMAddr;
	    PPU.OAMFlip = 0;
	    CPU.V_Counter = 0;
	    CPU.NMIActive = FALSE;
	    ICPU.Frame++;
	    PPU.HVBeamCounterLatched = 0;
	    CPU.Flags |= SCAN_KEYS_FLAG;
	    S9xStartHDMA ();
	}

	if (PPU.VTimerEnabled && !PPU.HTimerEnabled &&
	    CPU.V_Counter == PPU.IRQVBeamPos)
	{
	    S9xSetIRQ (PPU_V_BEAM_IRQ_SOURCE);
	}

	if (CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE)
	{
	    // Start of V-blank
	    S9xEndScreenRefresh ();
	    PPU.FirstSprite = 0;
	    IPPU.HDMA = 0;
	    // Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
	    missing.dma_this_frame = 0;
	    IPPU.MaxBrightness = PPU.Brightness;
	    PPU.ForcedBlanking = (Memory.FillRAM [0x2100] >> 7) & 1;

	    Memory.FillRAM[0x4210] = 0x80;
	    if (Memory.FillRAM[0x4200] & 0x80)
	    {
			CPU.NMIActive = TRUE;
			CPU.Flags |= NMI_FLAG;
			CPU.NMICycleCount = CPU.NMITriggerPoint;
	    }

#ifdef OLD_SNAPSHOT_CODE
	    if (CPU.Flags & SAVE_SNAPSHOT_FLAG)
	    {
			CPU.Flags &= ~SAVE_SNAPSHOT_FLAG;
			Registers.PC = CPU.PC - CPU.PCBase;
			S9xPackStatus ();
			S9xAPUPackStatus ();
			Snapshot (NULL);
	    }
#endif
        }

	if (CPU.V_Counter == PPU.ScreenHeight + 3)
	    S9xUpdateJoypads ();

	if (CPU.V_Counter == FIRST_VISIBLE_LINE)
	{
	    Memory.FillRAM[0x4210] = 0;
	    CPU.Flags &= ~NMI_FLAG;
	    S9xStartScreenRefresh ();
	}
	if (CPU.V_Counter >= FIRST_VISIBLE_LINE &&
	    CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE)
	{
	    RenderLine (CPU.V_Counter - FIRST_VISIBLE_LINE);
	}
	// Use TimerErrorCounter to skip update of SPC700 timers once
	// every 128 updates. Needed because this section of code is called
	// once every emulated 63.5 microseconds, which coresponds to
	// 15.750KHz, but the SPC700 timers need to be updated at multiples
	// of 8KHz, hence the error correction.
//	IAPU.TimerErrorCounter++;
//	if (IAPU.TimerErrorCounter >= )
//	    IAPU.TimerErrorCounter = 0;
//	else
	{
	    if (APU.TimerEnabled [2])
	    {
			APU.Timer [2] += 4;
			while (APU.Timer [2] >= APU.TimerTarget [2])
			{
				IAPU.RAM [0xff] = (IAPU.RAM [0xff] + 1) & 0xf;
				APU.Timer [2] -= APU.TimerTarget [2];
#ifdef SPC700_SHUTDOWN		
				IAPU.WaitCounter++;
				IAPU.APUExecuting = TRUE;
#endif		
			}
	    }
	    if (CPU.V_Counter & 1)
	    {
			if (APU.TimerEnabled [0])
			{
				APU.Timer [0]++;
				if (APU.Timer [0] >= APU.TimerTarget [0])
				{
					IAPU.RAM [0xfd] = (IAPU.RAM [0xfd] + 1) & 0xf;
					APU.Timer [0] = 0;
#ifdef SPC700_SHUTDOWN		
					IAPU.WaitCounter++;
					IAPU.APUExecuting = TRUE;
#endif		    
			    }
			}
			if (APU.TimerEnabled [1])
			{
				APU.Timer [1]++;
				if (APU.Timer [1] >= APU.TimerTarget [1])
				{
					IAPU.RAM [0xfe] = (IAPU.RAM [0xfe] + 1) & 0xf;
					APU.Timer [1] = 0;
#ifdef SPC700_SHUTDOWN		
					IAPU.WaitCounter++;
					IAPU.APUExecuting = TRUE;
#endif		    
			    }
			}
	    }
	}
	break; //HBLANK_END_EVENT

    case HTIMER_BEFORE_EVENT:
    case HTIMER_AFTER_EVENT:
	if (PPU.HTimerEnabled &&
	    (!PPU.VTimerEnabled || CPU.V_Counter == PPU.IRQVBeamPos))
	{
	    S9xSetIRQ (PPU_H_BEAM_IRQ_SOURCE);
	}
	break;
    }
Пример #14
0
	void D3DRenderContext::RenderWorldAxises() const {
		RenderLine(vec2(0.0f, 0.0f), vec2(AXIS_LENGTH, 0.0f), ivec3(0xFF, 0, 0));
		RenderLine(vec2(0.0f, 0.0f), vec2(0.0f, AXIS_LENGTH), ivec3(0, 0, 0xFF));
	}
Пример #15
0
void RenderLine3D(Shader *sh, const float3 &v1, const float3 &v2, const float3 &campos, float thickness)
{
    auto side = normalize(cross(v2 - v1, campos - (v1 + v2) / 2)) * thickness;
    RenderLine(sh, PRIM_FAN, v1, v2, side);
}
Пример #16
0
void
S9xDoHBlankProcessing ()
{
	START_PROFILE_FUNC (S9xDoHBlankProcessing);
	
#ifdef CPU_SHUTDOWN
  CPU.WaitCounter++;
#endif
  switch (CPU.WhichEvent)
    {
    case HBLANK_START_EVENT:
      if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
	IPPU.HDMA = S9xDoHDMA (IPPU.HDMA);

      break;

    case HBLANK_END_EVENT:
      S9xSuperFXExec ();


      CPU.Cycles -= Settings.H_Max;
      (IAPUuncached->NextAPUTimerPos) -= (Settings.H_Max * 10000L);
      if ( (IAPUuncached->APUExecuting))
	(APUuncached->Cycles) -= Settings.H_Max;
      else
	(APUuncached->Cycles) = 0;

      CPU.NextEvent = -1;
      ICPU.Scanline++;

      if (++CPU.V_Counter >
	  (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER))
	{
	  PPU.OAMAddr = PPU.SavedOAMAddr;
	  PPU.OAMFlip = 0;
	  CPU.V_Counter = 0;
	  CPU.NMIActive = FALSE;
	  ICPU.Frame++;
	  PPU.HVBeamCounterLatched = 0;
	  CPU.Flags |= SCAN_KEYS_FLAG;
	  S9xStartHDMA ();
	}

      if (PPU.VTimerEnabled && !PPU.HTimerEnabled &&
	  CPU.V_Counter == PPU.IRQVBeamPos)
	{
	  S9xSetIRQ (PPU_V_BEAM_IRQ_SOURCE);
	}

      if (CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE)
	{
	  // Start of V-blank
	  S9xEndScreenRefresh ();
	  PPU.FirstSprite = 0;
	  IPPU.HDMA = 0;
	  // Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
	  missing.dma_this_frame = 0;
	  IPPU.MaxBrightness = PPU.Brightness;
	  PPU.ForcedBlanking = (FillRAM[0x2100] >> 7) & 1;

	  FillRAM[0x4210] = 0x80;
	  if (FillRAM[0x4200] & 0x80)
	    {
	      CPU.NMIActive = TRUE;
	      CPU.Flags |= NMI_FLAG;
	      CPU.NMICycleCount = CPU.NMITriggerPoint;
	    }


	}

      if (CPU.V_Counter == PPU.ScreenHeight + 3)
	S9xUpdateJoypads ();

      if (CPU.V_Counter == FIRST_VISIBLE_LINE)
	{
	  FillRAM[0x4210] = 0;
	  CPU.Flags &= ~NMI_FLAG;
	  S9xStartScreenRefresh ();
	}
      if (CPU.V_Counter >= FIRST_VISIBLE_LINE &&
	  CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE)
	{
	  RenderLine (CPU.V_Counter - FIRST_VISIBLE_LINE);
	}

      break;
    case HTIMER_BEFORE_EVENT:
    case HTIMER_AFTER_EVENT:
      if (PPU.HTimerEnabled &&
	  (!PPU.VTimerEnabled || CPU.V_Counter == PPU.IRQVBeamPos))
	{
	  S9xSetIRQ (PPU_H_BEAM_IRQ_SOURCE);
	}
      break;
    }
Пример #17
0
/*
 *	Send a caret position message.
 */
void SendCaretMessage( LPCLASSDATA lpcd )
{
	NMCARETPOSITION		nmcp;
	HWND			hParent;

	/*
	 *	Do we have a parent?
	 */
	if (( hParent = GetParent( lpcd->hWnd )) != NULL )
	{
		/*
		 *	Fill in the structure.
		 */
		nmcp.hdr.code		= NMBC_CARETPOSITION;
		nmcp.hdr.hwndFrom	= lpcd->hWnd;
		nmcp.hdr.idFrom		= GetWindowLong( lpcd->hWnd, GWL_ID );
		nmcp.ptCaretPos		= lpcd->ptCaretPos;

		/*
		 *	Convert to screen coordinates.
		 */
		nmcp.ptCaretPos.x = GetCaretOffset( lpcd, nmcp.ptCaretPos.x );
		nmcp.ptCaretPos.x++;
		nmcp.ptCaretPos.y++;

		/*
		 *	Send the notification if the
		 *	position really changed.
		 */
		if ( nmcp.ptCaretPos.x != lpcd->ptLastPositionSent.x ||
		     nmcp.ptCaretPos.y != lpcd->ptLastPositionSent.y )
		{
			SendMessage( hParent, WM_NOTIFY, nmcp.hdr.idFrom, ( LPARAM )&nmcp );
			lpcd->ptLastPositionSent = nmcp.ptCaretPos;
		}
	}


	/*
	 *	Re-render the line if current line
	 *	highlighting is on.
	 */
	if ( Parser->bHighlightCurrentLine )
	{
		if ( lpcd->ptCaretPos.y != Parser->nHighlighted ) RenderLine( lpcd, Parser->nHighlighted );
		RenderLine( lpcd, lpcd->ptCaretPos.y );
		Parser->nHighlighted = lpcd->ptCaretPos.y;
	}

	/*
	 *	Higlight brackets?
	 */
	if ( Parser->bColorBracketMatches )
	{
		/*
		 *	Render previous match ( if any )
		 */
		if ( lpcd->ptBracket1.y >= 0 ) RenderLine( lpcd, lpcd->ptBracket1.y );
		if ( lpcd->ptBracket2.y != lpcd->ptBracket1.y && lpcd->ptBracket2.y >= 0 ) RenderLine( lpcd, lpcd->ptBracket2.y );

		/*
		 *	Find match.
		 */
		if ( FindMatches( lpcd, &lpcd->ptBracket1, &lpcd->ptBracket2, TRUE ) < 0 )
		{
			/*
			 *	No match found. 
			 */
			lpcd->ptBracket1.x = lpcd->ptBracket1.y = -1;
			lpcd->ptBracket2.x = lpcd->ptBracket2.y = -1;
		}

		/*
		 *	Render the lines on which the
		 *	matches are found.
		 */
		if ( lpcd->ptBracket1.y >= 0 ) RenderLine( lpcd, lpcd->ptBracket1.y );
		if ( lpcd->ptBracket2.y != lpcd->ptBracket1.y && lpcd->ptBracket2.y >= 0 ) RenderLine( lpcd, lpcd->ptBracket2.y );
	}
}
Пример #18
0
void S9xDoHBlankProcessing (struct SCPUState *cpu, struct SAPU *apu, struct SIAPU *iapu)
{
	struct SPPU *ppu = &PPU;
	struct InternalPPU *ippu = &IPPU;

#ifdef CPU_SHUTDOWN
    cpu->WaitCounter++;
#endif
    switch (cpu->WhichEvent)
    {
    case HBLANK_START_EVENT:
		if (ippu->HDMA && cpu->V_Counter <= ppu->ScreenHeight)
			ippu->HDMA = S9xDoHDMA (ippu, ppu, cpu);
	break;

    case HBLANK_END_EVENT:
#ifndef _ZAURUS
	S9xSuperFXExec ();
#endif
#ifndef STORM
#endif

	cpu->Cycles -= Settings.H_Max;
	if (iapu->APUExecuting)
	    apu->Cycles -= Settings.H_Max;
	else
	    apu->Cycles = 0;

	cpu->NextEvent = -1;
	ICPU.Scanline++;

	if (++cpu->V_Counter > (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER))
	{
	    ppu->OAMAddr = ppu->SavedOAMAddr;
	    ppu->OAMFlip = 0;
	    cpu->V_Counter = 0;
	    cpu->NMIActive = FALSE;
	    ICPU.Frame++;
	    ppu->HVBeamCounterLatched = 0;
	    cpu->Flags |= SCAN_KEYS_FLAG;
	    S9xStartHDMA ();
	}

	if (ppu->VTimerEnabled && !ppu->HTimerEnabled &&
	    cpu->V_Counter == ppu->IRQVBeamPos)
	{
	    S9xSetIRQ (PPU_V_BEAM_IRQ_SOURCE, cpu);
	}

	if (cpu->V_Counter == ppu->ScreenHeight + FIRST_VISIBLE_LINE)
	{
	    // Start of V-blank
	    S9xEndScreenRefresh (ppu);
	    ppu->FirstSprite = 0;
	    ippu->HDMA = 0;
	    // Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
	    missing.dma_this_frame = 0;
	    ippu->MaxBrightness = ppu->Brightness;
	    ppu->ForcedBlanking = (Memory.FillRAM [0x2100] >> 7) & 1;

	    Memory.FillRAM[0x4210] = 0x80;
	    if (Memory.FillRAM[0x4200] & 0x80)
	    {
			cpu->NMIActive = TRUE;
			cpu->Flags |= NMI_FLAG;
			cpu->NMICycleCount = cpu->NMITriggerPoint;
	    }

#ifdef OLD_SNAPSHOT_CODE
	    if (cpu->Flags & SAVE_SNAPSHOT_FLAG)
	    {
			cpu->Flags &= ~SAVE_SNAPSHOT_FLAG;
			Registers.PC = cpu->PC - cpu->PCBase;
			S9xPackStatus ();
			S9xAPUPackStatus ();
			Snapshot (NULL);
	    }
#endif
        }

	if (cpu->V_Counter == ppu->ScreenHeight + 3)
	    S9xUpdateJoypads (&IPPU);

	if (cpu->V_Counter == FIRST_VISIBLE_LINE)
	{
	    Memory.FillRAM[0x4210] = 0;
	    cpu->Flags &= ~NMI_FLAG;
	    S9xStartScreenRefresh ();
	}
	if (cpu->V_Counter >= FIRST_VISIBLE_LINE &&
	    cpu->V_Counter < ppu->ScreenHeight + FIRST_VISIBLE_LINE)
	{
	    RenderLine (cpu->V_Counter - FIRST_VISIBLE_LINE, ppu);
	}
	// Use TimerErrorCounter to skip update of SPC700 timers once
	// every 128 updates. Needed because this section of code is called
	// once every emulated 63.5 microseconds, which coresponds to
	// 15.750KHz, but the SPC700 timers need to be updated at multiples
	// of 8KHz, hence the error correction.
//	IAPU.TimerErrorCounter++;
//	if (IAPU.TimerErrorCounter >= )
//	    IAPU.TimerErrorCounter = 0;
//	else
	{
	    if (apu->TimerEnabled [2])
	    {
			apu->Timer [2] += 4;
			while (apu->Timer [2] >= apu->TimerTarget [2])
			{
				iapu->RAM [0xff] = (iapu->RAM [0xff] + 1) & 0xf;
				apu->Timer [2] -= apu->TimerTarget [2];
#ifdef SPC700_SHUTDOWN		
				iapu->WaitCounter++;
				iapu->APUExecuting = TRUE;
#endif		
			}
	    }
	    if (cpu->V_Counter & 1)
	    {
			if (apu->TimerEnabled [0])
			{
				apu->Timer [0]++;
				if (apu->Timer [0] >= apu->TimerTarget [0])
				{
					iapu->RAM [0xfd] = (iapu->RAM [0xfd] + 1) & 0xf;
					apu->Timer [0] = 0;
#ifdef SPC700_SHUTDOWN		
					iapu->WaitCounter++;
					iapu->APUExecuting = TRUE;
#endif		    
			    }
			}
			if (apu->TimerEnabled [1])
			{
				apu->Timer [1]++;
				if (apu->Timer [1] >= apu->TimerTarget [1])
				{
					iapu->RAM [0xfe] = (iapu->RAM [0xfe] + 1) & 0xf;
					apu->Timer [1] = 0;
#ifdef SPC700_SHUTDOWN		
					iapu->WaitCounter++;
					iapu->APUExecuting = TRUE;
#endif		    
			    }
			}
	    }
	}
	break; //HBLANK_END_EVENT

    case HTIMER_BEFORE_EVENT:
    case HTIMER_AFTER_EVENT:
	if (ppu->HTimerEnabled &&
	    (!ppu->VTimerEnabled || cpu->V_Counter == ppu->IRQVBeamPos))
	{
	    S9xSetIRQ (PPU_H_BEAM_IRQ_SOURCE, cpu);
	}
	break;
    }
Пример #19
0
	void	cUVAnimationImage::DebugRender()
	{
		std::vector<Vector3>l_vPoint;
		switch(m_eOrientation)
		{
			case eUVD_LEFT_TO_RIGHT:
			case eUVD_RIGHT_TO_LEFT:
				//horizontal
				//0      2		4
				//
				//1      3		5
				l_vPoint.push_back(m_vRenderVerticesPos[0]);
				l_vPoint.push_back(m_vRenderVerticesPos[1]);
				l_vPoint.push_back(m_vRenderVerticesPos[0]);
				l_vPoint.push_back(m_vRenderVerticesPos[2]);
				l_vPoint.push_back(m_vRenderVerticesPos[1]);
				l_vPoint.push_back(m_vRenderVerticesPos[3]);
				l_vPoint.push_back(m_vRenderVerticesPos[2]);
				l_vPoint.push_back(m_vRenderVerticesPos[3]);
				l_vPoint.push_back(m_vRenderVerticesPos[2]);
				l_vPoint.push_back(m_vRenderVerticesPos[4]);
				l_vPoint.push_back(m_vRenderVerticesPos[4]);
				l_vPoint.push_back(m_vRenderVerticesPos[5]);
				l_vPoint.push_back(m_vRenderVerticesPos[5]);
				l_vPoint.push_back(m_vRenderVerticesPos[3]);
				break;
			case eUVD_UP_TO_DOWN:
			case eUVD_DOWN_TO_UP:
				//vertical
				//for UV
				//0      1
				//
				//2      3
				//
				//4      5		
				l_vPoint.push_back(m_vRenderVerticesPos[0]);
				l_vPoint.push_back(m_vRenderVerticesPos[2]);
				l_vPoint.push_back(m_vRenderVerticesPos[4]);
				RenderLine(&l_vPoint,Vector4::Green,cMatrix44::Identity,true);
				l_vPoint.clear();
				l_vPoint.push_back(m_vRenderVerticesPos[5]);
				l_vPoint.push_back(m_vRenderVerticesPos[3]);
				l_vPoint.push_back(m_vRenderVerticesPos[1]);
				RenderLine(&l_vPoint,Vector4::Green,cMatrix44::Identity,true);
				l_vPoint.clear();
				l_vPoint.push_back(m_vRenderVerticesPos[0]);
				l_vPoint.push_back(m_vRenderVerticesPos[1]);
				RenderLine(&l_vPoint,Vector4::Red,cMatrix44::Identity,true);
				l_vPoint.clear();
				l_vPoint.push_back(m_vRenderVerticesPos[2]);
				l_vPoint.push_back(m_vRenderVerticesPos[3]);
				RenderLine(&l_vPoint,Vector4::Red,cMatrix44::Identity,true);
				l_vPoint.clear();
				l_vPoint.push_back(m_vRenderVerticesPos[4]);
				l_vPoint.push_back(m_vRenderVerticesPos[5]);
				RenderLine(&l_vPoint,Vector4::Red,cMatrix44::Identity,true);
				//l_vPoint.push_back(m_vRenderVerticesPos[0]);
				//l_vPoint.push_back(m_vRenderVerticesPos[1]);
				//l_vPoint.push_back(m_vRenderVerticesPos[0]);
				//l_vPoint.push_back(m_vRenderVerticesPos[2]);
				//l_vPoint.push_back(m_vRenderVerticesPos[1]);
				//l_vPoint.push_back(m_vRenderVerticesPos[3]);
				//l_vPoint.push_back(m_vRenderVerticesPos[2]);
				//l_vPoint.push_back(m_vRenderVerticesPos[3]);
				//l_vPoint.push_back(m_vRenderVerticesPos[2]);
				//l_vPoint.push_back(m_vRenderVerticesPos[4]);
				//l_vPoint.push_back(m_vRenderVerticesPos[4]);
				//l_vPoint.push_back(m_vRenderVerticesPos[5]);
				//l_vPoint.push_back(m_vRenderVerticesPos[5]);
				//l_vPoint.push_back(m_vRenderVerticesPos[3]);
		}
	}
Пример #20
0
void
S9xDoHBlankProcessing_HBLANK_END_EVENT () {
	//START_PROFILE_FUNC (S9xDoHBlankProcessing);			
#ifdef CPU_SHUTDOWN
  CPUPack.CPU.WaitCounter++;
#endif
  if (Settings.SuperFX) S9xSuperFXExec ();
  	  

	cpu_glob_cycles += CPUPack.CPU.Cycles-old_cpu_cycles;		
	CPUPack.CPU.Cycles -= Settings.H_Max;	
	old_cpu_cycles=CPUPack.CPU.Cycles;
	
#ifdef FAST_IAPU_APUEXECUTING_CHECK
	if (IAPU_APUExecuting_Main==false || APUExecuting_Main_Counter==0)
		IAPU_APUExecuting_Main = IAPU_APUExecuting;
	if (IAPU_APUExecuting_Main){
		apu_glob_cycles_Main=cpu_glob_cycles;
		if (cpu_glob_cycles>=0x00700000) {
			APU_EXECUTE2();
		}
	}
	else {
  		apu_glob_cycles=apu_glob_cycles_Main=0;
  		Uncache_APU_Cycles = 0;
	}
	if (APUExecuting_Main_Counter==0){
		FLUSH_APU();
	}
#else
  //(IAPUuncached.NextAPUTimerPos) -= (Settings.H_Max * 10000L);      
  if (  (IAPU_APUExecuting_Main)) {
  	//(APUPack.APU.Cycles) -= Settings.H_Max;
		apu_glob_cycles=cpu_glob_cycles;
#ifdef ME_SOUND		
		if (cpu_glob_cycles>=0x00700000) {		
			APU_EXECUTE2 ();
		}
#else
//		if (cpu_glob_cycles>=0x00000000) {		
//			APU_EXECUTE2 ();
//		}
#endif		
  }
  else {
  	//(APUPack.APU.Cycles) = 0;
  	apu_glob_cycles=0;
  	Uncache_APU_Cycles = 0;
  }
#endif
  
       
  CPUPack.CPU.NextEvent = -1;
// not use
//  CPUPack.ICPU.Scanline++;

  if (++CPUPack.CPU.V_Counter > (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER)) {
  	//PPU.OAMAddr = PPU.SavedOAMAddr;
    //PPU.OAMFlip = 0;            
    CPUPack.CPU.V_Counter = 0;
    ROM_GLOBAL[0x213F]^=0x80;
    CPUPack.CPU.NMIActive = FALSE;
    //CPUPack.ICPU.Frame++;
    PPU.HVBeamCounterLatched = 0;
    CPUPack.CPU.Flags |= SCAN_KEYS_FLAG;
    S9xStartHDMA ();
  }

  if (PPU.VTimerEnabled && !PPU.HTimerEnabled && CPUPack.CPU.V_Counter == PPU.IRQVBeamPos) S9xSetIRQ (PPU_V_BEAM_IRQ_SOURCE);
#if (1)
//  pEvent->apu_event1[pEvent->apu_event1_cpt2 & 0xFFFF]=(os9x_apu_ratio != 256) ? cpu_glob_cycles * os9x_apu_ratio / 256: cpu_glob_cycles;
//  pEvent->apu_event1_cpt2++;
  uint32 EventVal = (os9x_apu_ratio != 256) ? cpu_glob_cycles * os9x_apu_ratio / 256: cpu_glob_cycles;
  if (CPUPack.CPU.V_Counter & 1) {
    EventVal |= 0x80000000;
  }
#ifdef ME_SOUND
  int pos=apu_event1_cpt2_main++;
  apu_event1[pos & APU_EVENT_MASK] = EventVal;
  apu_event1_cpt2=apu_event1_cpt2_main;
#else
  int pos=apu_event1_cpt2;
  apu_event1[pos & APU_EVENT_MASK] = EventVal;
  apu_event1_cpt2=pos+1;
#endif

  //APU_EXECUTE2 ();
    
  /*if ((APUPack.APU.TimerEnabled) [2]) {
		(APUPack.APU.Timer) [2] += 4;
		while ((APUPack.APU.Timer) [2] >= (APUPack.APU.TimerTarget) [2]) {
		  (IAPUuncached.RAM) [0xff] = ((IAPUuncached.RAM) [0xff] + 1) & 0xf;
		  (APUPack.APU.Timer) [2] -= (APUPack.APU.TimerTarget) [2];
#ifdef SPC700_SHUTDOWN
		  (IAPUuncached.WaitCounter)++;
		  (IAPU_APUExecuting)= TRUE;
#endif		
		}
	}*/
#else
	if (CPUPack.CPU.V_Counter & 1) {		
		apu_event2[(apu_event2_cpt2)&0xFFFF]=cpu_glob_cycles * os9x_apu_ratio / 256;  
  	(apu_event2_cpt2)++;
		/*if ((APUPack.APU.TimerEnabled) [0]) {
		  (APUPack.APU.Timer) [0]++;
		  if ((APUPack.APU.Timer) [0] >= (APUPack.APU.TimerTarget) [0]) {
				(IAPUuncached.RAM) [0xfd] = ((IAPUuncached.RAM) [0xfd] + 1) & 0xf;
				(APUPack.APU.Timer) [0] = 0;
#ifdef SPC700_SHUTDOWN		
				(IAPUuncached.WaitCounter)++;
				(IAPU_APUExecuting)= TRUE;
#endif		    
		  }
		}
		if ((APUPack.APU.TimerEnabled) [1]) {
		  (APUPack.APU.Timer) [1]++;
		  if ((APUPack.APU.Timer) [1] >= (APUPack.APU.TimerTarget) [1]) {
				(IAPUuncached.RAM) [0xfe] = ((IAPUuncached.RAM) [0xfe] + 1) & 0xf;
				(APUPack.APU.Timer) [1] = 0;
#ifdef SPC700_SHUTDOWN		
				(IAPUuncached.WaitCounter)++;
				(IAPU_APUExecuting) = TRUE;
#endif		    
		  }
		}*/		
	}	  
#endif
  if (CPUPack.CPU.V_Counter == FIRST_VISIBLE_LINE)
    {
      ROM_GLOBAL[0x4210] = 0;
      CPUPack.CPU.Flags &= ~NMI_FLAG;
      S9xStartScreenRefresh ();
    }
  if (CPUPack.CPU.V_Counter >= FIRST_VISIBLE_LINE &&
      CPUPack.CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE)
    {
      RenderLine (CPUPack.CPU.V_Counter - FIRST_VISIBLE_LINE);
      S9xReschedule ();                  
  		//FINISH_PROFILE_FUNC (S9xDoHBlankProcessing); 
  		return;
    }

  if (CPUPack.CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE)
    {
      // Start of V-blank
      S9xEndScreenRefresh ();
      //PPU.FirstSprite = 0;
      IPPU.HDMA = 0;
      // Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
#ifdef DEBUGGER
	  missing.dma_this_frame = 0;
#endif
	  IPPU.MaxBrightness = PPU.Brightness;
      PPU.ForcedBlanking = (ROM_GLOBAL[0x2100] >> 7) & 1;
      
      if(!PPU.ForcedBlanking){
				PPU.OAMAddr = PPU.SavedOAMAddr;			
				uint8 tmp = 0;
				if(PPU.OAMPriorityRotation)
					tmp = (PPU.OAMAddr&0xFE)>>1;
				if((PPU.OAMFlip&1) || PPU.FirstSprite!=tmp){
					PPU.FirstSprite=tmp;
					IPPU.OBJChanged=TRUE;
				}			
				PPU.OAMFlip = 0;
			}
Пример #21
0
	void D3DRenderContext::RenderSolidRectangle(const Rect& geometry, const ivec3& color) const {
		RenderLine(geometry.LeftBottomCorner(), geometry.RightBottomCorner(), color);
		RenderLine(geometry.RightBottomCorner(), geometry.RightTopCorner(), color);
		RenderLine(geometry.RightTopCorner(), geometry.LeftTopCorner(), color);
		RenderLine(geometry.LeftTopCorner(), geometry.LeftBottomCorner(), color);
	}