Пример #1
0
VOID Do_WM_PAINT(HWND hwnd)
{
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);

    RECT rcClient;
    if (!GetClientRect(hwnd, &rcClient)) { };
    
    RECT rcempty; 
    if (!SetRect(&rcempty, 0, 0, 0, 0)) { };
    

    //background is red for no file, green with a file
    FillRect(hdc, &rcClient, CreateSolidBrush((fileopen ? RGB(0, 255, 0) : RGB(255, 0, 0))));
    
    //status area
    RECT rcstatus;
    if (!CopyRect(&rcstatus, &rcempty)) { }
    if (statusarea) {
        if (!CopyRect(&rcstatus, &rcClient)) {}
        rcstatus.bottom = rcstatus.top + STATUSAREAHEIGHT;
        DrawStatusArea(hwnd, hdc, rcstatus);
    }
    

    EndPaint(hwnd, &ps);
}
Пример #2
0
//===========================================================================
void DrawFrameWindow () {
  VideoRealizePalette(/*dc*/);
//  printf("In DrawFrameWindow. g_nAppMode == %d\n", g_nAppMode);

  // DRAW THE STATUS AREA
  DrawStatusArea(DRAW_BACKGROUND | DRAW_LEDS);

  // DRAW THE CONTENTS OF THE EMULATED SCREEN
  if (g_nAppMode == MODE_LOGO)
    VideoDisplayLogo(); // logo
  else if (g_nAppMode == MODE_DEBUG)
    DebugDisplay(1);  //debugger
  else
    VideoRedrawScreen(); // normal state - running emulator?
//  printf("Out of DrawFrameWindow!\n");
}
Пример #3
0
//===========================================================================
void ProcessButtonClick (int button, int mod) {
// button - number of button pressed (starting with 0, which means F1
// mod - what modifiers been set (like CTRL, ALT etc.)
	SDL_Event qe;	// for Quitting and Reset

	SoundCore_SetFade(FADE_OUT); // sound/music off?

  switch (button) {

    case BTN_HELP:	// will get some help on the screen?
	    FrameShowHelpScreen(screen->w, screen->h);

//         TCHAR filename[MAX_PATH];
//         _tcscpy(filename,g_sProgramDir);
//         _tcscat(filename,TEXT("APPLEWIN.CHM"));
//         HtmlHelp(g_hFrameWindow,filename,HH_DISPLAY_TOC,0);
//         helpquit = 1;
      break;

    case BTN_RUN:	// F2 - Run that thing! Or Shift+2 ReloadConfig and run it anyway!
	if(mod & KMOD_SHIFT) {
		  restart = 1;	// keep up flag of restarting
		  qe.type = SDL_QUIT;
		  SDL_PushEvent(&qe);// push quit event
	}
	else {
      if (g_nAppMode == MODE_LOGO)
        DiskBoot();
      else if (g_nAppMode == MODE_RUNNING)
        ResetMachineState();
      if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING))
        DebugEnd();
      g_nAppMode = MODE_RUNNING;
      DrawStatusArea(/*(HDC)0,*/DRAW_TITLE);
      VideoRedrawScreen();
      g_bResetTiming = true;
	}
      break;

    case BTN_DRIVE1:
    case BTN_DRIVE2:
	    if (mod & KMOD_SHIFT) {
		if(mod & KMOD_ALT)
			HD_FTP_Select(button - BTN_DRIVE1);// select HDV image through FTP
		else HD_Select(button - BTN_DRIVE1);	// select HDV image from local disk
	    }
      	    else {
		if(mod & KMOD_ALT) Disk_FTP_SelectImage(button - BTN_DRIVE1);//select through FTP
		else DiskSelect(button - BTN_DRIVE1); // select image file for appropriate disk drive(#1 or #2)
	    }
/*      if (!fullscreen)
        DrawButton((HDC)0,button);*/
      break;

    case BTN_DRIVESWAP:	// F5 - swap disk drives
      DiskDriveSwap();
      break;

    case BTN_FULLSCR:	// F6 - Fullscreen on/off
      if (fullscreen) { fullscreen = 0;
        SetNormalMode(); }
      else { fullscreen = 1;
        SetFullScreenMode();}
      break;

    case BTN_DEBUG:	// F7 - debug mode - not implemented yet? Please, see README about it. --bb
/*		if (g_nAppMode == MODE_LOGO)
		{
			ResetMachineState();
		}

		if (g_nAppMode == MODE_STEPPING)
		{
			DebuggerInputConsoleChar( DEBUG_EXIT_KEY );
		}
		else
		if (g_nAppMode == MODE_DEBUG)
		{
			g_bDebugDelayBreakCheck = true;
			ProcessButtonClick(BTN_RUN);
		}
		else
		{
			DebugBegin();
		}*/
      break;

    case BTN_SETUP:	// setup is in conf file - linapple.conf.
	    		// may be it should be implemented using SDL??? 0_0 --bb
	// Now Shift-F8 save settings changed run-tme in linapple.conf
	// F8 - save current screen as a .bmp file
	    // Currently these setting are just next:
	if(mod & KMOD_SHIFT) {
		RegSaveValue(TEXT("Configuration"),TEXT("Video Emulation"),1,videotype);
		RegSaveValue(TEXT("Configuration"),TEXT("Emulation Speed"),1,g_dwSpeed);
		RegSaveValue(TEXT("Configuration"),TEXT("Fullscreen"),1,fullscreen);
	}
	else {
		FrameSaveBMP();
	}

//      {
//		  PSP_Init();
      //}
      break;


////////////////////////// my buttons handlers F9..F12 ////////////////////////////
    case BTN_CYCLE: // F9 - CYCLE through allowed video modes
//	  printf("F9 has been pressed!\n");
	  videotype++;	// Cycle through available video modes
	  if (videotype >= VT_NUM_MODES)
		  videotype = 0;
	  VideoReinitialize();
	  if ((g_nAppMode != MODE_LOGO) || ((g_nAppMode == MODE_DEBUG) && (g_bDebuggerViewingAppleOutput))) // +PATCH
	  {
		  VideoRedrawScreen();
		  g_bDebuggerViewingAppleOutput = true;  // +PATCH
	  }

  	  break;
    case BTN_QUIT:	// F10 - exit from emulator?

		qe.type = SDL_QUIT;
		SDL_PushEvent(&qe);// push quit event
		break;	//

    case BTN_SAVEST:	// Save state (F11)
	    if(mod & KMOD_ALT) { // quick save
		    Snapshot_SaveState();
	    }
	  else
	  if(PSP_SaveStateSelectImage(true))
	  {
		  Snapshot_SaveState();
	  }
  	break;
    case BTN_LOADST:	// Load state (F12) or Hot Reset (Ctrl+F12)
	    if(mod & KMOD_CTRL) {
			// Ctrl+Reset
			if (!IS_APPLE2)
				MemResetPaging();

			DiskReset();
			KeybReset();
			if (!IS_APPLE2)
				VideoResetState();	// Switch Alternate char set off
			MB_Reset();
			CpuReset();
		}
	else if(mod & KMOD_ALT)	// quick load state
	{
		Snapshot_LoadState();
	}
    	else if(PSP_SaveStateSelectImage(false))
    	  {
	   	Snapshot_LoadState();
    	  }
	  break;
}//switch (button)
//////////////////////////////////////////// end of my buttons handlers //////////////////

  if((g_nAppMode != MODE_DEBUG) && (g_nAppMode != MODE_PAUSED))
  {
	  SoundCore_SetFade(FADE_IN);
  }
}
Пример #4
0
/*LRESULT CALLBACK FrameWndProc (
	HWND   window,
	UINT   message,
	WPARAM wparam,
	LPARAM lparam)*/
void	FrameDispatchMessage(SDL_Event * e) // process given SDL event
{
	int mysym = e->key.keysym.sym; // keycode
	int mymod = e->key.keysym.mod; // some special keys flags
	int x,y;	// used for mouse cursor position

   switch (e->type) //type of SDL event
   {
     case SDL_ACTIVEEVENT:
	g_bAppActive = e->active.gain; // if gain==1, app is active
        break;

    case SDL_KEYDOWN:
//	    printf("keyb %d is down!\n", mysym);
	    if(mysym >= SDLK_0 && mysym <= SDLK_9 && mymod & KMOD_CTRL) {
		    FrameQuickState(mysym - SDLK_0, mymod);
		    break;
	    }

	    if(mysym < 128 && mysym != SDLK_PAUSE) { // it should be ASCII code?
		if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_LOGO) ||
			((g_nAppMode == MODE_STEPPING) && (mysym != SDLK_ESCAPE)))
			{
				KeybQueueKeypress(mysym,ASCII);
			}
			else
			if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING))
			{
				DebuggerInputConsoleChar(mysym);
			}
			break;
	}
	else {// this is function key?
//		KeybUpdateCtrlShiftStatus(); // if ctrl or shift or alt was pressed?------?
		if ((mysym >= SDLK_F1) && (mysym <= SDLK_F12) && (buttondown == -1))
		{
//			SetUsingCursor(0);	-- for what purpose???
			buttondown = mysym - SDLK_F1;	// special function keys processing

/*			if (fullscreen && (buttonover != -1)) {
				if (buttonover != buttondown)
				EraseButton(buttonover);
				buttonover = -1;
			}
			DrawButton((HDC)0,buttondown);*/
		}
		else if (mysym == SDLK_KP_PLUS) // Gray + - speed up the emulator!
		{
			g_dwSpeed = g_dwSpeed + 2;
			if(g_dwSpeed > SPEED_MAX) g_dwSpeed = SPEED_MAX; // no Maximum tresspassing!
			printf("Now speed=%d\n", (int)g_dwSpeed);
			SetCurrentCLK6502();
		}
		else if (mysym == SDLK_KP_MINUS) // Gray + - speed up the emulator!
		{
			if(g_dwSpeed > SPEED_MIN) g_dwSpeed = g_dwSpeed - 1;// dw is unsigned value!
			//if(g_dwSpeed <= SPEED_MIN) g_dwSpeed = SPEED_MIN; // no Minimum tresspassing!
			printf("Now speed=%d\n", (int)g_dwSpeed);
			SetCurrentCLK6502();
		}
		else if (mysym == SDLK_KP_MULTIPLY) // Gray * - normal speed!
		{
			g_dwSpeed = 10;// dw is unsigned value!
			printf("Now speed=%d\n", (int)g_dwSpeed);
			SetCurrentCLK6502();
		}


		else if (mysym == SDLK_CAPSLOCK) // CapsLock
		{
				KeybToggleCapsLock();
		}
		else if (mysym == SDLK_PAUSE)	// Pause - let us pause all things for the best
		{
			SetUsingCursor(0); // release cursor?
			switch (g_nAppMode)
			{
			case MODE_RUNNING: // go in pause
				g_nAppMode = MODE_PAUSED;
				SoundCore_SetFade(FADE_OUT); // fade out sound?**************
				break;
			case MODE_PAUSED: // go to the normal mode?
				g_nAppMode = MODE_RUNNING;
				SoundCore_SetFade(FADE_IN);  // fade in sound?***************
				break;
			case MODE_STEPPING:
				DebuggerInputConsoleChar( DEBUG_EXIT_KEY );
				break;
			}
			DrawStatusArea(/*(HDC)0,*/DRAW_TITLE);
			if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
				VideoRedrawScreen();
			g_bResetTiming = true;
		}
		else if (mysym == SDLK_SCROLLOCK)	// SCROLL LOCK pressed
		{
			g_bScrollLock_FullSpeed = !g_bScrollLock_FullSpeed; // turn on/off full speed?
		}
		else if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_LOGO) || (g_nAppMode == MODE_STEPPING))
		{
			// Note about Alt Gr (Right-Alt):
			// . WM_KEYDOWN[Left-Control], then:
			// . WM_KEYDOWN[Right-Alt]
			BOOL autorep  = 0; //previous key was pressed? 30bit of lparam
			BOOL extended = (mysym >= 273); // 24bit of lparam - is an extended key, what is it???
			if ((!JoyProcessKey(mysym ,extended, 1, autorep)) && (g_nAppMode != MODE_LOGO))
				KeybQueueKeypress(mysym, NOT_ASCII);
		}
		else if (g_nAppMode == MODE_DEBUG)
			DebuggerProcessKey(mysym);	// someone should realize debugger for Linapple!?--bb
/*
		if (wparam == VK_F10)
		{
			SetUsingCursor(0);
			return 0;
		}
		break;*/
    }//else
    break;

    case SDL_KEYUP:
//	int mysym = e->key.keysym.sym; // keycode
	if ((mysym >= SDLK_F1) && (mysym <= SDLK_F12) && (buttondown == mysym-SDLK_F1))
	{
		buttondown = -1;
// 			if (fullscreen)
// 				EraseButton(wparam-VK_F1);
// 			else
// 				DrawButton((HDC)0,wparam-VK_F1);
		ProcessButtonClick(mysym-SDLK_F1, mymod); // process function keys - special events
	}
	else
	{	// mysym >= 300 (or 273????)- check for extended key, what is it EXACTLY???
		JoyProcessKey(mysym,(mysym >= 273), 0, 0);
	}
	break;

    case SDL_MOUSEBUTTONDOWN:
	if(e->button.button == SDL_BUTTON_LEFT) {// left mouse button was pressed

	    if (buttondown == -1)
	  {
        x = e->button.x; // mouse cursor coordinates
        y = e->button.y;
        if (usingcursor) // we use mouse cursor for our special needs?
	{
	   KeybUpdateCtrlShiftStatus(); // if either of ALT, SHIFT or CTRL is pressed
	   if (g_bShiftKey | g_bCtrlKey)
	   {
           	 SetUsingCursor(0); // release mouse cursor for user
	   }
          else
	  {
		if (sg_Mouse.Active())
			sg_Mouse.SetButton(BUTTON0, BUTTON_DOWN);
		else
		        JoySetButton(BUTTON0, BUTTON_DOWN);
	  }
	}// we do not use mouse
        else if ( (/*(x < buttonx) &&*/ JoyUsingMouse() && ((g_nAppMode == MODE_RUNNING) ||
		   (g_nAppMode == MODE_STEPPING))) || (sg_Mouse.Active()) )
		{
          		SetUsingCursor(1); // capture cursor
		}
		DebuggerMouseClick( x, y );
      }
//RelayEvent(WM_LBUTTONDOWN,wparam,lparam);
     }//if left mouse button down
     else if(e->button.button == SDL_BUTTON_RIGHT) {
	if (usingcursor)
        {
	     if (sg_Mouse.Active())
		     sg_Mouse.SetButton(BUTTON1, BUTTON_DOWN);
	     else
		     JoySetButton(BUTTON1, BUTTON_DOWN);
        }
     }

      break; // end of MOSEBUTTONDOWN event

    case SDL_MOUSEBUTTONUP:
     if (e->button.button == SDL_BUTTON_LEFT) {// left mouse button was released
     if (usingcursor)
      {
		if (sg_Mouse.Active())
			sg_Mouse.SetButton(BUTTON0, BUTTON_UP);
		else
		    JoySetButton(BUTTON0, BUTTON_UP);
      }
//      RelayEvent(WM_LBUTTONUP,wparam,lparam);
     }
     else if(e->button.button == SDL_BUTTON_RIGHT) {
	     if (usingcursor)
	     {
		     if (sg_Mouse.Active())
			     sg_Mouse.SetButton(BUTTON1, BUTTON_UP);
		     else
			     JoySetButton(BUTTON1, BUTTON_UP);
	     }
     }
     break; // MOUSEBUTTONUP event

    case SDL_MOUSEMOTION:
      x = e->motion.x;// get relative coordinates of mouse cursor
      y = e->motion.y;
      if (usingcursor)
      {
//        DrawCrosshairs(x,y); I do not like those crosshairs, but... --bb
		if (sg_Mouse.Active())
	            sg_Mouse.SetPosition(x, VIEWPORTCX-4, y, VIEWPORTCY-4);
		else
		    JoySetPosition(x, VIEWPORTCX-4, y, VIEWPORTCY-4);
      }
//      RelayEvent(WM_MOUSEMOVE,wparam,lparam);
      break;

    case SDL_USEREVENT:
	if (e->user.code == 1) // should do restart?
		ProcessButtonClick(BTN_RUN, 0);
	break;

   }//switch

//  return DefWindowProc(window,message,wparam,lparam);
}
Пример #5
0
//===========================================================================
void FrameRefreshStatus (int drawflags) {
  DrawStatusArea(/*(HDC)0,*/drawflags);
}