コード例 #1
0
ファイル: Paint.cpp プロジェクト: soloveyhappy/tiny
// The message handlers for the VScroll and HScroll messages
void CTinyCadView::OnVScroll(UINT wParam, UINT pos, CScrollBar*)
{
	CRect rect;
	int moveFast, moveSlow;
	int x = static_cast<int> (GetTransform().GetOrigin().x);
	int y = static_cast<int> (GetTransform().GetOrigin().y);

	GetClientRect(rect);
	int Width = static_cast<int> (GetTransform().doubleDeScale(rect.bottom));
	moveFast = (Width << 4) / 20;
	moveSlow = (Width * 20) / 100;

	switch (wParam)
	{
		case SB_LINEUP:
			SetScroll(x, y - moveSlow);
			break;
		case SB_PAGEUP:
			SetScroll(x, y - moveFast);
			break;
		case SB_LINEDOWN:
			SetScroll(x, y + moveSlow);
			break;
		case SB_PAGEDOWN:
			SetScroll(x, y + moveFast);
			break;
		case SB_THUMBTRACK:
		case SB_THUMBPOSITION:
		{
			CDPoint xlap = GetCurrentDocument()->GetDetails().GetOverlap();
			SetScroll(x, static_cast<int> (pos) - static_cast<int> (xlap.y));
		}
			break;
	}
}
コード例 #2
0
ファイル: Scrollbar.cpp プロジェクト: quinsmpang/Tools
void CMyScrollBar::OnInitialUpdate()
{
	// Called automatically via AttachDlgItem

	// Set the Scroll bar position
	SetScroll(0);
}
コード例 #3
0
ファイル: main.c プロジェクト: ncxx-sl-lab/nes
uint8_t main(void)
{

	const char palettes[] = {
		0x0f, 0x00, 0x10, 0x20,
		0x0f, 0x06, 0x16, 0x26,
		0x0f, 0x08, 0x18, 0x28,
		0x09, 0x0a, 0x0b, 0x0c
	};
	const char string[] = "hello world!";
	char i;

	ShowScreen(0);

//	// パレットを書き込み
//	*(char*)0x2006 = 0x3f;
//	*(char*)0x2006 = 0x00;
//	for (i = 0; i < 0x10; i ++)
//		*(char*)0x2007 = palettes[i];
//
//	*(char*)0x2006 = 0x21;
//	*(char*)0x2006 = 0x20;
//	// ネームテーブルへ書き込み
//	for (i = 0; i < sizeof(string); i ++) {
//		*(char*)0x2007 = string[i];
//	}

	SetScroll(0, 0);
	ShowScreen(1);

	while (1);

	return 0;
}
コード例 #4
0
ファイル: Paint.cpp プロジェクト: soloveyhappy/tiny
void CTinyCadView::SetScrollCentre(CDPoint c)
{
	CRect rect;
	CDPoint p;

	GetClientRect(rect);
	p = GetTransform().DeScale(GetCurrentDocument()->m_snap, CPoint(rect.right / 2, rect.bottom / 2));
	SetScroll(GetTransform().GetOrigin().x + c.x - p.x, GetTransform().GetOrigin().y + c.y - p.y);
}
コード例 #5
0
ファイル: Paint.cpp プロジェクト: soloveyhappy/tiny
void CTinyCadView::SetScrollPoint(CDPoint c, CPoint p)
{
	CRect rect;
	CDPoint p2;

	GetClientRect(rect);
	//p2=GetTransform().DeScale(GetCurrentDocument()->m_snap,p - GetTransform().GetPixelOffset());
	p2 = GetTransform().DeScale(p - GetTransform().GetPixelOffset());
	SetScroll(GetTransform().GetOrigin().x + c.x - p2.x, GetTransform().GetOrigin().y + c.y - p2.y);
}
コード例 #6
0
ファイル: ScrView.cpp プロジェクト: KB3NZQ/hexedit4
BOOL CScrView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) 
{
	CPointAp pp = GetScroll();
	if (abs(zDelta) > line_.cy)
		pp.y -= (zDelta/line_.cy) * line_.cy;   // Restrict movement to multiple of text height
	else
		pp.y -= zDelta;
	if (pp.y < 0) pp.y = 0;                     // Scroll to start (else SetScroll ignores -ve position)
	SetScroll(pp);
	return TRUE;
//	return CView::OnMouseWheel(nFlags, zDelta, pt);
}
コード例 #7
0
ファイル: biglow.c プロジェクト: daemqn/Atari_ST_Sources
void main(void)
{   int Hdl;
    void *OldScreen;
    int dummy;
    long i;

/* d‚termine la base line A pour la position souris
*/
    linea_init();

/* charge l'image et la duplique en largeur
*/       
    Hdl=Fopen("MORETA.NEO",0); if (Hdl<0) { appl_exit(); Pterm0(); }
    Fseek(4L,Hdl,0);
    Fread(Hdl,32L,NewPalette);
    Fseek(128L,Hdl,0);
    for (i=0;i<200;i++) 
    {    LINE1 *p=(LINE1 *)&picbuf[0].line[i];
         Fread(Hdl,sizeof(LINE1),p);
         p[1]=p[0];
    }
    Fclose(Hdl);

/* Duplique l'image en hauteur 
*/  
    picbuf[1]=picbuf[0];
         
/* Installe la pallette et sauve l'ancienne
*/
    InsPalette(); 
    
/* Sauve l'adresse de l'‚cran courant
*/  
    OldScreen=GetScreenPtr();

/* Installe la routine de scrolling en VBL
*/
    InsVBL(Scrolling);
    
/* Boucle en attendant un Ctrl-C
*/
    while (1) if (Bconstat(2)<0 && (char)Bconin(2)==3) break;

/* Remet tout en ordre et sort de l…
*/  
    RmvVBL();
    SetScreenPtr(OldScreen);
    SetScroll(0);
    SetLineStride(0);
    RestPalette();
}
コード例 #8
0
ファイル: DebugCamera.cpp プロジェクト: TimLiszak/Midi
void CDebugCamera::Update( const FLOAT fFrameTime, BOOL bIsCurrent )
{
	CMouse* pMouse = GetGameEngine()->GetInput()->GetMouse();
	VECTOR vScroll = GetScroll();

	if ( pMouse->IsMouseDown( EMouseButton_Middle ) )
	{
		VECTOR vMove = pMouse->GetMousePosition() - m_vLastMousePos;
		vMove = vMove * GetGameEngine()->GetView()->GetZoom();
		vScroll = vScroll - vMove;
		SetScroll( vScroll );
	}
	m_vLastMousePos = pMouse->GetMousePosition();
}
コード例 #9
0
ファイル: ScrView.cpp プロジェクト: KB3NZQ/hexedit4
// Set the current scroll position in "text" units (see SetScroll)
void CScrView::SetTScroll(CPointAp newpos)
{
	TEXTMETRIC tm;
	{
		CClientDC dc(this);
		OnPrepareDC(&dc);
		dc.GetTextMetrics(&tm);
	}

	newpos.x *= tm.tmAveCharWidth;
	newpos.y *= tm.tmHeight + tm.tmExternalLeading;

	SetScroll(newpos);
}
コード例 #10
0
ファイル: xoptions.c プロジェクト: leedavid/WinBoard
void
HighlightWithScroll (Option *opt, int sel, int max)
{
    float top, bottom, f, g;
    HighlightListBoxItem(opt, sel);
    if(!ReadScroll(opt, &top, &bottom)) return; // no scroll bar
    bottom = bottom*max - 1.f;
    f = g = top;
    top *= max;
    if(sel > (top + 3*bottom)/4) f = (sel - 0.75f*(bottom-top))/max; else
    if(sel < (3*top + bottom)/4) f = (sel - 0.25f*(bottom-top))/max;
    if(f < 0.f) f = 0.; if(f + 1.f/max > 1.f) f = 1. - 1./max;
    if(f != g) SetScroll(opt, f);
}
コード例 #11
0
ファイル: genmain.cpp プロジェクト: HonzaMD/Krkal2
//nastavi plynuly scroling
void CGEnMain::Scroll(float startx, float starty, float destx, float desty, UI time)
{

	SetScroll(startx,starty);

	scrollStartTime = kernelTime;
	scrollTime = time;

	scrollStartX = startx; scrollStartY = starty;
	scrollX = destx; scrollY = desty;
	scrollXnow = startx; scrollYnow = starty;

	scrollDX = (destx-startx)/time; scrollDY = (desty-starty)/time;

	scroll = 1; //nastavi scroling

}
コード例 #12
0
ファイル: GUIList.cpp プロジェクト: Shikifuyin/Scarab-Engine
Void GUIListModel::OnScroll( const Point2 & /*ptLocalPos*/, Int iWheelDelta, GUIEventFlag iFlags )
{
    if ( m_iDisplayCount >= m_arrNodes.Count() ) {
        if ( m_iDisplayTop != 0 )
            SetScroll( 0 );
        return;
    }

    // Flags
    Bool bCtrl = ( (iFlags & GUIEVENT_FLAG_CTRL) != 0 );

    // Deal event
    if ( iWheelDelta > 0 )
        ScrollUp( bCtrl ? 3 : 1 );
    else if ( iWheelDelta < 0 )
        ScrollDown( bCtrl ? 3 : 1 );
}
コード例 #13
0
ファイル: Background2D.cpp プロジェクト: DeejStar/q-gears
//------------------------------------------------------------------------------
void
Background2D::ScriptScrollToPosition( const float x, const float y, const ScrollType type, const float seconds )
{
    LOG_TRIVIAL( "[SCRIPT] Background2d set scroll to position \"" + Ogre::StringConverter::toString( Ogre::Vector2( x, y ) ) + "\"." );

    Ogre::Vector2 position = Ogre::Vector2( x, y );

    m_ScrollEntity = NULL;

    if( type == Background2D::NONE )
    {
        SetScroll( position );
        return;
    }

    m_ScrollPositionStart = m_Position;
    m_ScrollPositionEnd = position;
    m_ScrollType = type;
    m_ScrollSeconds = seconds;
    m_ScrollCurrentSeconds = 0;
}
コード例 #14
0
ファイル: genmain.cpp プロジェクト: HonzaMD/Krkal2
int CGEnMain::AddToWindow( CBltWindow *wnd, int top )
{
	if(!GameWindow) return 0;

	SetScrollShift(0,0);

	if(GameWindow->GetParent())
	{
		GameWindow->GetParent()->RemoveChild(GameWindow);
	}
	if(wnd)
	{
		if(top) 
			wnd->AddChildToTop(GameWindow);
		else
			wnd->AddChildToBottom(GameWindow);
	}
	SetScroll(0,0);
	GameWindow->GetCache()->DeleteAllSurfaces();
	GameWindow->SetNeedRecalc();
	return 1;
}
コード例 #15
0
ファイル: Paint.cpp プロジェクト: soloveyhappy/tiny
// Track the size of the window
void CTinyCadView::OnSize(UINT a, int cx, int cy)
{
	CView::OnSize(a, cx, cy);

	if (IsWindowVisible())
	{
		CTinyCadRegistry::SetMDIMaximize(GetParentFrame()->IsZoomed() != 0);
	}

	if (m_pDocument == NULL) return;

	CRect nSize;
	GetClientRect(nSize);
	if (vRuler != NULL) vRuler->OnNewSize(nSize);
	if (hRuler != NULL) hRuler->OnNewSize(nSize);

	if (GetCurrentDocument())
	{
		SetScroll(GetTransform().GetOrigin().x, GetTransform().GetOrigin().y);
	}

}
コード例 #16
0
ファイル: main.c プロジェクト: ncxx-sl-lab/nes
uint8_t main(void)
{
	sprite_t* sprite = (sprite_t*)0x0200;
	const char palettes[] = {
		0x0f, 0x00, 0x10, 0x20,
		0x0f, 0x06, 0x16, 0x26,
		0x0f, 0x08, 0x18, 0x28,
		0x09, 0x0a, 0x0b, 0x0c
	};

	const char string[] = "hello sprite dma!";
	char i;
	ShowScreen(0);

	// パレットを書き込み

	*(char*)0x2006 = 0x3f;
	*(char*)0x2006 = 0x00;
	for (i = 0; i < 0x10; i ++)
		*(char*)0x2007 = palettes[i];

	*(char*)0x2006 = 0x21;
	*(char*)0x2006 = 0x20;
	// ネームテーブルへ書き込み
	for (i = 0; i < sizeof(string); i ++) {
		*(char*)0x2007 = string[i];
	}

	SetScroll(0, 0);
	ShowScreen(1);
	
	sprite[0].y = 20;
	sprite[0].idx = 0;
	sprite[0].attr = 0;
	sprite[0].x = 0;
	
	sprite[1].y = 25;
	sprite[1].idx = 1;
	sprite[1].attr = 0;
	sprite[1].x = 10;
	
	sprite[2].y = 20;
	sprite[2].idx = 2;
	sprite[2].attr = 0;
	sprite[2].x = 20;
	
	sprite[3].y = 25;
	sprite[3].idx = 3;
	sprite[3].attr = 0;
	sprite[3].x = 30;
	
	sprite[4].y = 20;
	sprite[4].idx = 4;
	sprite[4].attr = 0;
	sprite[4].x = 40;
	
	sprite[5].y = 25;
	sprite[5].idx = 5;
	sprite[5].attr = 0;
	sprite[5].x = 50;
	
	*APU_SPR_DMA = 0x02;

	while (1);

	return 0;
}
コード例 #17
0
ファイル: ScrView.cpp プロジェクト: KB3NZQ/hexedit4
// Responds to a cursor movement key to move the current caret position (if
// the caret is being displayed) or the current scroll position.
BOOL CScrView::MovePos(UINT nChar, UINT nRepCnt,
						 BOOL control_down, BOOL shift_down, BOOL caret_on)
{
	CPointAp newpos;

	// Get current position (if no caret then keys just do scrolling)
	if (!caret_on)
		newpos = scrollpos_;
	else if (shift_down && basepos_ == caretpos_)
		newpos = selpos_;
	else if (shift_down && basepos_ == selpos_)
		newpos = caretpos_;
	else if (nChar == VK_LEFT || nChar == VK_UP || nChar == VK_HOME || nChar == VK_PRIOR)
		newpos = caretpos_;
	else
		newpos = selpos_;

	// Calculate new position
	switch (nChar)
	{
	case VK_LEFT:
		if (!control_down)
			newpos.x -= line_.cx * nRepCnt;
		break;
	case VK_RIGHT:
		if (!control_down)
			newpos.x += line_.cx * nRepCnt;
		break;
	case VK_UP:
		if (!control_down)
			newpos.y -= line_.cy * nRepCnt;
		break;
	case VK_DOWN:
		if (!control_down)
			newpos.y += line_.cy * nRepCnt;
		break;
	case VK_HOME:
		if (!control_down)
			newpos.x = 0;
		else
		{
			newpos.x = 0;
			newpos.y = 0;
		}
		break;
	case VK_END:
		if (!control_down)
		{
			if (caret_on)
				newpos.x = total_.cx;
			else
				newpos.x = total_.cx - win_width_;
		}
		else
		{
			newpos.x = 0;
			if (caret_on)
				newpos.y = total_.cy;
			else
				newpos.y = total_.cy - win_height_;
		}
		break;
	case VK_PRIOR:
		if (!control_down)
			newpos.y -= page_.cy * nRepCnt;
		break;
	case VK_NEXT:
		if (!control_down)
			newpos.y += page_.cy * nRepCnt;
		break;
	}

	// Move to new position
	if (caret_on && shift_down)
	{
		// Using shifted cursor keys just extends the current selection
		OnSelUpdate(ConvertToDP(newpos));
	}
	else if (caret_on)
	{
		if (newpos == caretpos_ && caretpos_ == selpos_)
			return FALSE;           // Key not handled/had no effect

		SetCaret(newpos);
	}
	else
	{
		if (newpos == scrollpos_)
			return FALSE;           // Key not handled/had no effect

		SetScroll(newpos);
	}

	return TRUE;        // Indicate that keystroke used
}
コード例 #18
0
ファイル: gxScroller.cpp プロジェクト: Izhaki/gefriCPP
void gxScroller::OnScrollChanged( const gxScroll *aScroll )
{
    SetScroll( aScroll->mPosition );
}
コード例 #19
0
ファイル: ScrView.cpp プロジェクト: KB3NZQ/hexedit4
void CScrView::OnSelUpdate(CPoint point)
{
	// Keep the last drag position so we only invalidate what has changed.
	CPointAp last;
	ASSERT(basepos_ == caretpos_ || basepos_ == selpos_);
	if (caretpos_ == basepos_)
		last = selpos_;
	else
		last = caretpos_;

	CRect cli;                          // Display area (client coords)
	GetDisplayRect(&cli);
	CRectAp disp = ConvertFromDP(cli);  // Display area ("cli") in our coords
	CPointAp pp = ConvertFromDP(point); // Mouse point ("point") in our coords

	// Get display rect shrunk to only contain whole rows/columns
	CRectAp rr(disp);
	rr.top  = ((rr.top - 1)/line_.cy + 1)*line_.cy;
	rr.left = ((rr.left- 1)/line_.cx + 1)*line_.cx;
	rr.bottom = (rr.bottom/line_.cy)*line_.cy;
	rr.right  = (rr.right /line_.cx)*line_.cx;

	// Test if we are about to scroll or very close to edge
	if (!rr.PtInRect(pp))
	{
		// TODO: We probably should handle vertical and horizontal auto-scrolling
		// separately and not allow both at the same time, to avoid confusion.

		CPointAp newpos(-1, -1);  // New scroll position (our coords)
		static clock_t last_clock = 0;

		if (pp.x < rr.left)
		{
			newpos.x = scrollpos_.x - line_.cx;
		}
		else if (pp.x >= rr.right)
		{
			newpos.x = scrollpos_.x + line_.cx;
		}

		if (pp.y < rr.top)
		{
			// Use clock to ensure scrolling does not get faster with more mouse move events
			clock_t curr_clock = clock();
			clock_t diff_clock = curr_clock - last_clock;
			if (diff_clock > CLOCKS_PER_SEC/5) diff_clock = CLOCKS_PER_SEC/5;

			// Scroll speed depends on distance mouse is above window
//            int diff_pixel = ((disp.top - pp.y)*(disp.top - pp.y))/10;
			int diff_pixel = int(disp.top - pp.y);
			int autoscroll = (int)pow((double)diff_pixel, autoscroll_accel_/10.0);

			__int64 to_move = 0;                        // How much to scroll up

			// Always scroll so that top of text line is at top of window
			if (disp.top < rr.top) to_move = line_.cy - (rr.top - disp.top);

			// If enough time has passed or mouse is far enough above the window...
			if (disp.top > pp.y && diff_clock * autoscroll >= CLOCKS_PER_SEC/5)
			{
				// Scroll according to time and distance
				to_move += line_.cy*((diff_clock * autoscroll)/(CLOCKS_PER_SEC/5));
				last_clock = curr_clock;
			}
			newpos.y = scrollpos_.y - to_move;
			if (newpos.y < 0)
				newpos.y = 0;
		}
		else if (pp.y >= rr.bottom)
		{
			// See above comments (same but for bottom of window not top)
			clock_t curr_clock = clock();
			clock_t diff_clock = curr_clock - last_clock;
			if (diff_clock > CLOCKS_PER_SEC/5) diff_clock = CLOCKS_PER_SEC/5;
			int diff_pixel = int(pp.y - disp.bottom);
			int autoscroll = (int)pow((double)diff_pixel, autoscroll_accel_/10.0);

			__int64 to_move = 0;
			if (disp.bottom > rr.bottom) to_move = line_.cy - (disp.bottom - rr.bottom);
			if (disp.bottom < pp.y && diff_clock * autoscroll >= CLOCKS_PER_SEC/5)
			{
				to_move += line_.cy*((diff_clock * autoscroll)/(CLOCKS_PER_SEC/5));
				last_clock = curr_clock;
			}
			newpos.y = scrollpos_.y + to_move;
			if (newpos.y < 0)
				newpos.y = 0;
		}

		SetScroll(newpos, TRUE);
	}
	
	// Set end of selection based on this point
	CPoint ptmp = point;                         // Get pp based on new value of "point"

	// Don't allow selection to extend outside window
	if (ptmp.y < cli.top) ptmp.y = cli.top;
	else if (ptmp.y >= cli.bottom) ptmp.y = cli.bottom - 1;

	if (ptmp.x < cli.left) ptmp.x = cli.left;
	else if (ptmp.x >= cli.right) ptmp.x = cli.right - 1;

	// Work out new selection
	pp = ConvertFromDP(ptmp);
	ValidateCaret(pp, FALSE);

	if (pp.y < basepos_.y || (pp.y == basepos_.y && pp.x < basepos_.x))
	{
		caretpos_ = pp;
		selpos_ = basepos_;
	}
	else
	{
		caretpos_ = basepos_;
		selpos_ = pp;
	}

	// Allow derived class to invalidate the whole selection
	if (pp.y != last.y || pp.x != last.x)
		InvalidateRange(caretpos_, selpos_, true);

	// Invalidate everything that's changed
	if (pp.y < last.y || (pp.y == last.y && pp.x < last.x))
		InvalidateRange(pp, last);
	else if (pp.y != last.y || pp.x != last.x)
		InvalidateRange(last, pp);
}
コード例 #20
0
int StartSMS(char *Cartridge)
{
  static char *Countries[16] =
  {
    NULL,NULL,NULL,NULL,NULL,"Japan","Japan, USA, Europe","USA, Europe",
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
  };
  static char *Sizes[16] =
  {
    ">128kB",NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,"32kB","64kB","128kB",NULL
  };
  static byte VDPInit[16] =
  {
    0x00,0x60,0x0E,0x00,0x00,0x7F,0x00,0x00,
    0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00
  };

  FILE *F;
  int I,J,*T;
  char *P;
  reg R;

  /*** STARTUP CODE starts here: ***/
  T=(int *)"\01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
#ifdef LSB_FIRST
  if(*T!=1)
  {
    puts("********** This machine is high-endian. **********");
    puts("Take #define LSB_FIRST out and compile MasterGear again.");
    return(0);
  }
#else
  if(*T==1)
  {
    puts("********* This machine is low-endian. **********");
    puts("Insert #define LSB_FIRST and compile MasterGear again.");
    return(0);
  }
#endif

  RAM=VRAM=NULL;
  ROMPages=0;ROMMask=0;
  for(J=0;J<256;J++) ROMMap[J]=NULL;
  SaveName=NULL;Battery=0;

  if(Verbose) printf("Allocating 64kB for CPU address space...");
  if(!(RAM=(byte*)malloc(0x10000))) { if(Verbose) puts("FAILED");return(0); }
  memset(RAM,NORAM,0x10000);
  if(Verbose) printf("OK\nAllocating 16kB for Video address space...");
  if(!(VRAM=(byte*)malloc(0x4040))) { if(Verbose) puts("FAILED");return(0); }
  memset(VRAM,NORAM,0x4040);
  PRAM=VRAM+0x4000;

  if(Verbose) printf("OK\nOpening %s...",Cartridge);
  P=NULL;

#ifdef ZLIB
#define fopen          gzopen
#define fclose         gzclose
#define fread(B,N,L,F) gzread(F,B,(L)*(N))
#endif

  if(F=fopen(Cartridge,"rb"))
  {
    for(ROMPages=0;ROMPages<256;ROMPages++)
      if(!(ROMMap[ROMPages]=(byte*)malloc(0x4000)))
      { P="MALLOC FAILED";break; }
      else
      {
        J=fread(ROMMap[ROMPages],1,0x4000,F);
        if(!J)        { P=NULL;break; }
        if(J==512) // cartridge w/header
        {
           fclose(F);
           for(J=0;J<ROMPages;J++) free(ROMMap[J]);
           if(F=fopen(Cartridge,"rb"))
           {
              for(ROMPages=0;ROMPages<256;ROMPages++)
              if(!(ROMMap[ROMPages]=(byte*)malloc(0x4000)))
                 { P="MALLOC FAILED";break; }
              else
              {
                 if (ROMPages == 0) J=fread(ROMMap[ROMPages],1,512,F); // skip header
                 J=fread(ROMMap[ROMPages],1,0x4000,F);
                 if(!J)        { P=NULL;break; }
                 if(J!=0x4000) { P="SHORT FILE";break; }
              }
           }
           fclose(F);
           break;
        }
        if(J!=0x4000) { P="SHORT FILE";break; }
      }
    fclose(F);
  }
  else P="NOT FOUND";

#ifdef ZLIB
#undef fopen
#undef fclose
#undef fread
#endif

  /* Exit if there was a problem */
  if(P) { if(Verbose) puts(P);return(0); }

  /* I = Country Code, J = ROM Size */
  J=ROMMap[1][0x3FFF];I=J>>4;J&=0x0F;
  /* Enforce Japanese/English nationalization if needed */
  if(!Country) if(I==5) Country=2; else if(I==7) Country=1;

  /* Print out cartridge data if needed */
  if(Verbose)
  {
    printf("%d pages loaded\n",ROMPages);
    if(GameGear&&ROMMap[1])
    {
      if(Countries[I]) printf("  Country: %s\n",Countries[I]);
      else             printf("  Country: Unknown (%d)\n",I);
      if(Sizes[J])     printf("  Size:    %s\n",Sizes[J]);
      else             printf("  Size:    Unknown (%d)\n",J);
    }
  }

  /* Generate the .SAV file name and try to load it. */
  /* If found the .SAV file, assume battery backup.  */
    if(SaveName=(char*)malloc(strlen(Cartridge)+10))
  {
    strcpy(SaveName,Cartridge);
    if(P=strrchr(SaveName,'.')) strcpy(P,".sav");
    else strcat(SaveName,".sav");
    if(F=fopen(SaveName,"rb"))
    {
      if(Verbose) printf("Found %s...reading...",SaveName);
      J=(fread(RAM+0x8000,1,0x4000,F)==0x4000);
      if(Verbose) puts(J? "OK":"FAILED");
      fclose(F);
    }
  }

//  if(SndName)
//  {
//    if(Verbose) printf("Logging soundtrack to %s...",SndName);
//    SndStream=fopen(SndName,"wb");
//    if(Verbose) puts(SndStream? "OK":"FAILED");
//    if(SndStream)
//      fwrite
//      ("SND\032\001\004\062\0\0\0\0\0\0\0\0\0\376\003\002",1,19,SndStream);
//  }

  /* Calculate IPeriod from VPeriod */
  IPeriod=VPeriod/280;
  if(IPeriod<10) IPeriod=10;
  VPeriod=IPeriod*280;

  if(Verbose)
  {
    printf("Initializing CPU and System Hardware:\n");
    printf("  VBlank = %d opcodes\n  HBlank = %d opcodes\n",VPeriod,IPeriod);
  }

  for(J=1;J<ROMPages;J<<=1);
  ROMMask=J-1;
  EnWrite=0;
  RAM[0xC000]=RAM[0xDFFC]=0x00;
  Page[0]=ROMMap[RAM[0xDFFD]=0&ROMMask];
  Page[1]=Page[0]+0x2000;
  Page[2]=ROMMap[RAM[0xDFFE]=1&ROMMask];
  Page[3]=Page[2]+0x2000;
  Page[4]=ROMMap[RAM[0xDFFF]=2&ROMMask];
  Page[5]=Page[4]+0x2000;
  Page[6]=Page[7]=RAM+0xC000;

  memcpy(VDP,VDPInit,16);                /* VDP registers              */
  VKey=DKey=RKey=1;                      /* Accessing VRAM...          */
  VAddr=0x0000;PAddr=0;                  /* ...from address 0000h      */
  BGColor=0;                             /* Background color           */
  CURLINE=0;                             /* Current scanline           */
  VDPStatus=0x00;                        /* VDP status register        */
  ChrTab=VRAM+0x3800;                    /* Screen buffer at 3800h     */
  SprTab=VRAM+0x3F00;                    /* Sprite attributes at 3F00h */
  SprGen=VRAM;                           /* Sprite patterns at 0000h   */
  ChrPal=PRAM;                           /* Screen palette             */
  SprPal=PRAM+(GameGear? 0x20:0x10);     /* Sprite palette             */
  MinLine=GameGear? (192-144)/2:0;       /* First scanline to refresh  */
  MaxLine=MinLine+(GameGear? 143:191);   /* Last scanline to refresh   */
  LinesLeft=255;                         /* Lines left to line inte-pt */
  SetScroll();                           /* ScrollX,ScrollY            */
  JoyState=0xFFFF;                       /* Joypad state               */
  NoiseMode=0x00;                        /* Noise channel modes        */
  Freq[0]=Freq[1]=Freq[2]=Freq[3]=0;     /* Sound channel frequencies  */
  Volume[0]=Volume[1]=0;                 /* Sound channel volumes      */
  Volume[2]=Volume[3]=0;
  ResetZ80(&R);                          /* Reset Z80 registers        */

  if(Verbose) printf("RUNNING ROM CODE...\n");
  J=Z80(R);

  if(Verbose) printf("EXITED at PC = %04Xh.\n",J);
  return(1);
}
コード例 #21
0
ファイル: Background2D.cpp プロジェクト: DeejStar/q-gears
//------------------------------------------------------------------------------
void
Background2D::SetScreenScroll( const Ogre::Vector2& position )
{
    SetScroll( position / m_screen_scale );
}
コード例 #22
0
void aScrollBar::update()
{
	long mouseX = userInput->getMouseX();
	long mouseY = userInput->getMouseY();

		if ( userInput->isLeftDrag() && lastY ) // dragging the little tab
		{
			int tmpLastY = mouseY; 
			tmpLastY -= userInput->getMouseDragY();
			tmpLastY += lastY;

			float finalPos = (float)tmpLastY;
			// figure out what this translates to
			float physicalRange = height() - topButton.height() - bottomButton.height() - scrollTab.height() -  2.f;
			float RealRange = scrollMax;
			if ( !physicalRange )
				physicalRange = RealRange;

			//Check for what if both of the above are zero.  Probably nothing to scroll to, eh?
			if ((fabs(physicalRange) > Stuff::SMALL) && (fabs(RealRange) > Stuff::SMALL))
			{
				float newScrollPos = .5 + (finalPos)*RealRange/physicalRange;
				if ( newScrollPos < 0 )
					newScrollPos = 0;
				if ( newScrollPos > scrollMax )
					newScrollPos = scrollMax;
				SetScroll( newScrollPos );
				scrollTab.press( true );
			}
		}
		else if ( pointInside( mouseX, mouseY ) )
		{
	
		
				
			if ( userInput->isLeftClick() || gos_GetKeyStatus(KEY_LMOUSE) == KEY_HELD
				|| userInput->leftMouseReleased() )
			{
				lastY = 0;
				if ( scrollTab.pointInside( mouseX, mouseY ) && !userInput->leftMouseReleased()  )
					lastY = scrollTab.top() - topButton.bottom();
				else if ( getParent() )
				{
					if ( !topButton.pointInside( mouseX, mouseY )
						&& !bottomButton.pointInside( mouseX, mouseY )
						&& !topButton.pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
						&& !bottomButton.pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
						&& mouseY > topButton.globalBottom() 
						&& mouseY < bottomButton.globalY()
						&& pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
						&& !scrollTab.pointInside( mouseX, mouseY )
						&& ( userInput->leftMouseReleased() || userInput->getMouseLeftHeld() > .5 ) )
					{
					//	float physicalRange = height() - topButton.height() - bottomButton.height() - scrollTab.height();
					//	float RealRange = scrollMax;
					//	float delta = (float)mouseY - (topButton.globalY() + topButton.height());
				
						float newScrollPos = scrollPos;
						// if above the thumb, page up, otherwise page down
						if ( mouseY < scrollTab.globalY() )
						{
								newScrollPos = scrollPos - pageInc;
						}
						else if ( mouseY > scrollTab.globalBottom() )
						{
								newScrollPos = scrollPos + pageInc;
						}

						if( newScrollPos < 0 )
								newScrollPos = 0;

						if( newScrollPos > scrollMax )
							newScrollPos = scrollMax;

						
					
						getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos );
						SetScrollPos( newScrollPos );

					}

					scrollTab.press( 0 );
					
				}
			}
		}

		if ( userInput->leftMouseReleased() )
			lastY = 0;
		
	
	aObject::update();
}
コード例 #23
0
ファイル: Paint.cpp プロジェクト: soloveyhappy/tiny
void CTinyCadView::SetZoomFactor(double NewZoom)
{
	ChangeZoomFactor(NewZoom);
	SetScroll(GetTransform().GetOrigin().x, GetTransform().GetOrigin().y);
	Invalidate();
}
コード例 #24
0
ファイル: genmain.cpp プロジェクト: HonzaMD/Krkal2
int CGEnMain::Update(UI curtime)
{
	if(curtime==lastupdatetime) return 0;

	int chng=0;
	float x,y,z;
	UI dt;

	lastupdatetime=curtime;

	CPGEnMoveElemIter melit(MovingElems); //budu prochazet vsechny pohybujici (animujici) elementy

	CGEnMoveElem *el;
	if( !melit.End() ) chng=1;

	while( !melit.End() )
	{
		el=melit;

		if(el->type & 1) //rovnomerny primocary pohyb
		{

			dt = curtime - el->starttime;

			if(dt>=melit->time) //element uz mel dojet do konce
			{
				el->el->GEnSetPos(el->endx,el->endy,el->endz,0); //nastavim konecnou polohu

				if(el->ack&1){
					if(KerMain)
						KerMain->AutosMain->GEnProcessEnded(el->el->ObjPtr, 1); //informuju kernel
					el->ack ^= 1; //shodim 1
				}

				el->type ^= 1; //shodim 1 - zrusi pohyb

			}else
			{
				//hejbnu elementem (rovnomerny prim. pohyb)
				x=floorf(el->startx + dt * el->dx + 0.5f);
				y=floorf(el->starty + dt * el->dy + 0.5f);
				z=floorf(el->startz + dt * el->dz + 0.5f);

				el->el->GEnSetPos(x,y,z,0); //nastavim pozici
			}
		}

		if(el->type & 2) //animace
		{
			if(curtime>=el->nextframetime) //uz je cas na dalsi frame?
			{//ano!
				dt = curtime - el->nextframetime;
				
				int frm = el->nextframeindex; //index dalsiho framu
				int numfr = el->anim->GetNumFrames(); 

				if( dt>=el->anim->GetFrameTime(frm) ) //stihnul jsem to?
				{
					//ne - musim preskocit nekolik obrazku
					do{
						dt-=el->anim->GetFrameTime(frm);
						el->nextframetime += el->anim->GetFrameTime(frm);
						frm++;
						if(frm>=numfr){ //dostal jsem se na konec animacni sekvence
							if(el->anim->repeatflag) //mam opakovat?
							{
								frm=0; //ano
								UI temptm = el->anim->GetTotalTime();
								UI tt2;
								if(dt >= temptm)
								{
									tt2 = dt % temptm;
									el->nextframetime += dt-tt2;
									dt = tt2;
								}
							}
							else
							{
								frm=numfr-1; //ne - zobrazim posledni frame a skoncim
								break;
							}
						}
					}while(dt>=el->anim->GetFrameTime(frm));
				}

				SetLightTex(el->el, el->anim->GetFrameTex(frm)); //nastavi frame

				el->nextframetime+=el->anim->GetFrameTime(frm); //spocte cas dalsiho framu
				
				frm++; //posune na dalsi frame

				if(frm >= numfr) { //dostal jsem se na konec animacni sekvence
					if(el->anim->repeatflag) //mam opakovat?
					{
						frm=0; //ano
					}else{

						if(el->ack&2){
							if(KerMain)
								KerMain->AutosMain->GEnProcessEnded(el->el->ObjPtr, 2); //informuju kernel
							el->ack ^= 2; //shodim 2
						}

						el->type ^= 2; //ne - shodim 2 - konec animace
					}
				}
				
				el->nextframeindex = frm; //nastavim dalsi frame

			}
		}

		if(el->type) //pohyb nebo animace jeste neskoncil
			melit++; //vezmu dalsi
		else
		{   //pohyb i animace skoncil - zrusim MovingElement:
			el->el->mel=NULL; //zrusim MovingElement u elementu
			delete el; //smazu MovingElement
			melit.Remove(); //vyhodim ze seznamu
		}		
	}

	if(scroll) //plynuly scroling
	{
		dt = curtime - scrollStartTime;
		
		if(dt>=scrollTime) //uz jsem mel doscrolovat?
		{//ano
			SetScroll(scrollX,scrollY); //nastavim konecnou pozici (vypne scroling - nastavi scroll na 0)
		}else
		{
			//jeste scroluju...
			CMatrix2D m;

			scrollXnow = x = floorf(scrollStartX + dt * scrollDX + 0.5f);
			scrollYnow = y = floorf(scrollStartY + dt * scrollDY + 0.5f);

			m.Translate(-x+scrollshiftX,-y+scrollshiftY);

			GameWindow->SetInsideTrans(m);
            			
		}
		chng=1;
	}


	return chng;
}