Example #1
0
static GameLoopResult DogfightScoresUpdate(GameLoopData *data, LoopRunner *l)
{
	PlayerList *pl = data->Data;

	const GameLoopResult result = MenuUpdate(&pl->ms);
	if (result == UPDATE_RESULT_OK)
	{
		// Calculate PVP rounds won
		int maxScore = 0;
		CA_FOREACH(PlayerData, p, gPlayerDatas)
			if (IsPlayerAlive(p))
			{
				p->Totals.Score++;
				maxScore = MAX(maxScore, p->Totals.Score);
			}
		CA_FOREACH_END()
		gCampaign.IsComplete =
			maxScore == ModeMaxRoundsWon(gCampaign.Entry.Mode);
		CASSERT(maxScore <= ModeMaxRoundsWon(gCampaign.Entry.Mode),
			"score exceeds max rounds won");
		if (gCampaign.IsComplete)
		{
			LoopRunnerChange(l, ScreenDogfightFinalScores());
		}
		else
		{
			LoopRunnerChange(
				l, HighScoresScreen(&gCampaign, &gGraphicsDevice));
		}
	}
void DualTriggerControlAdjust(void* data)
{
   uint8_t* input = data;
   SoftTimer2[SC_AutoMenuUpdate].timeCompare = FAST_AUTO_MENU_UPDATE;
   SoftTimerStart(SoftTimer2[SC_AutoMenuUpdate]);

   switch( *input )
   {
      case KP_UP:
         SetTrigger(SelectedChannel, GetTrigger(SelectedChannel)+1);
      break;

      case KP_DOWN:
         SetTrigger(SelectedChannel, GetTrigger(SelectedChannel)-1);
      break;

      case KP_BACK:
         UF_MenuUpOneLevel(ActiveMenu);
      return;
   }

   MenuUpdate(ActiveMenu, RESET_MENU | NO_EXECUTE);
   UF_MenuSetInput(KP_INVALID);
   PrintDualTriggerInformation(3);
}
Example #3
0
static GameLoopResult PlayerListUpdate(GameLoopData *data, LoopRunner *l)
{
	PlayerList *pl = data->Data;

	const GameLoopResult result = MenuUpdate(&pl->ms);
	if (result == UPDATE_RESULT_OK)
	{
		LoopRunnerChange(
			l, HighScoresScreen(&gCampaign, &gGraphicsDevice));
	}
	return result;
}
Example #4
0
void __stdcall ExOptions::m_LBUTTONDOWN(StormMsg * Msg)
{
	WORD mX = LOWORD(Msg->lParam);
	WORD mY = HIWORD(Msg->lParam);
	int nMenu = D2ASMFuncs::D2CLIENT_GetSelectedMenu(mY);
	if (nMenu != -1)
		*D2Vars.D2CLIENT_SelectedMenu = nMenu;
	MenuUpdate(mX, mY);
	isMenuClicked = 1;
	Msg->_2 = 1;
	Msg->_3 = 0;
	D2Funcs.STORM_ResetMsgQuene(Msg);
}
Example #5
0
static int ModeUpdate()
{
  if (Inp.held[14] && Inp.held[15] && Inp.held[12]==1) LoopQuit=1; // L+R+black to quit:
  if (Inp.button[4]>30 && Inp.button[5]>30) LoopQuit=1; // Start and back to quit

  if (LoopMode==8) { DoGame(); return 0; }

  if (DSoundNext) memset(DSoundNext,0,PsndLen<<2);

  if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; }
  if (LoopMode==3) { MenuUpdate(); return 0; }
  if (LoopMode==4) { LightCalUpdate(); return 0; }

  LoopMode=2; // Unknown mode, go to rom menu
  return 0;
}
Example #6
0
/* Set (or re-set) the language for the application. */
void
set_language(int id)
{
    LCID lcidNew = MAKELCID(id, dwSubLangID);

    if (lang_id != lcidNew) {
	/* Set our new language ID. */
	lang_id = lcidNew;

	SetThreadLocale(lang_id);

	/* Load the strings table for this ID. */
	LoadCommonStrings();

#if 0
	/* Update the menus for this ID. */
	MenuUpdate();
#endif
    }
}
Example #7
0
// Main Function
void _main(void)
{
  HANDLE menu_handle = MenuNew (2, 240, 18);
  MenuAddText (menu_handle, 0, "First", 1, DMF_TOP_SUB);
  MenuAddText (menu_handle, 1, "Subitem 1.1", 5, DMF_CHILD_SUB);
  MenuAddText (menu_handle, 5, "Subitem 1.1.1", 8, DMF_CHILD_SUB);
  MenuAddText (menu_handle, 5, "Subitem 1.1.2", 9, DMF_CHILD);
  MenuAddText (menu_handle, 8, "Subitem 1.1.1.1", 10, DMF_CHILD);
  MenuAddText (menu_handle, 1, "Subitem 1.2", 6, DMF_CHILD);
  MenuAddText (menu_handle, 0, "Second", 2, DMF_TOP_SUB);
  MenuAddText (menu_handle, 2, "Subitem 2.1", 7, DMF_CHILD);
  MenuAddText (menu_handle, -1, "Third", 3, DMF_TOP);
  MenuAddText (menu_handle, -1, "Fourth", 4, DMF_TOP);
  HANDLE exec_handle = MenuBegin (NULL, 0, 0, MBF_HMENU, menu_handle);
  short result;
  do {
    result = MenuKey (exec_handle, ngetchx ());
  } while (result == M_NOTMENUKEY);
  MenuEnd (exec_handle);
  MenuUpdate ();
  push_shortint (result);
}
void DualTriggerNoteAdjust(void* data)
{
   uint8_t* input = data;
   uint8_t keyType = GetState(ActiveMenu) - ST_SET_OPEN_NOTE;

   SoftTimer2[SC_AutoMenuUpdate].timeCompare = FAST_AUTO_MENU_UPDATE;
   SoftTimerStart(SoftTimer2[SC_AutoMenuUpdate]);

   NoteEditor(data, keyType);

   switch( *input )
   {
      case KP_BACK:
         UF_MenuUpOneLevel(ActiveMenu);
      return;
   }

   MenuUpdate(ActiveMenu, RESET_MENU | NO_EXECUTE);
   UF_MenuSetInput(KP_INVALID);

   /* print the open or closed key */
   PrintDualTriggerInformation(keyType + 1);
}
Example #9
0
interrupt (TIMERB1_VECTOR) timerb1_int(void)
{
   dint();   
   
   uint8_t intVec = TBIV;
					
   if( intVec & TBIV_CCR2 )
   {
		TBCCR2 += SAMPLE_1MS;
		
	
		if(SoftTimerInterrupt(SoftTimer2[SC_AutoMenuUpdate]))
		{
         /* Update the Threshold and Retrigger bar */
         MenuSetInput(ActiveMenu, KP_UPDATE);
         MenuUpdate(ActiveMenu, RESET_MENU);
         //ThresholdBar();
         SoftTimerReset(SoftTimer2[SC_AutoMenuUpdate]);     
      }
         
		if(SoftTimerInterrupt(SoftTimer2[SC_VUDecay]))
		{
			SoftTimerReset(SoftTimer2[SC_VUDecay]); 
			/* Decay the VU Meters here */
			if( ActiveProcess == PLAY_MODE )
			{
   	   	VULevelDecay(ALL_METERS);
			}
		}
		
		if( SoftTimerInterrupt(SoftTimer2[SC_LCD_BL_Period]) )
		{
			SoftTimerReset( SoftTimer2[SC_LCD_BL_Period] );
			SoftTimerStop( SoftTimer2[SC_LCD_BL_Period] );
			UI_LCD_BL_Off();
			
			/* If no SoftTimer2's are enabled, then turn off the Timer2 module */
			if( !SoftTimer_IsTimer2Active() )
			{
            /* Stop the Auxuliary Timer */
            TBCCTL2 &= ~(CCIE);
         }
			
		}
         
		if(SoftTimerInterrupt(SoftTimer2[SC_VUMeterUpdate]))
		{
			SoftTimerReset(SoftTimer2[SC_VUMeterUpdate]); 
		
         /* Do the VU Meter*/
         uint16_t i;
         uint8_t  VURows = GetVURows();
			   			           
         for( i = 0 ; i < ANALOGUE_INPUTS; i++ )
         {
				if( GetChannelStatus(i) )
				{
					if( VUValues[i] > GetChannelThresh(i) )
					{
						uint16_t conditionedSignal = (VUValues[i] - GetChannelThresh(i));
						
						conditionedSignal = GainFunction(i, conditionedSignal);
						
		            /* Normalise with x rows */
		            VUSetLevel(i, VUNormaliseMIDI(conditionedSignal, VURows), VURows);            
					}
	         }
			}
         VUMeterPrint(SEQUENTIAL_METERS | 0x0F, VURows);
         ResetVUValues();
      }         
      
      /* Digital & Metronome VU Meter  */
		if(SoftTimerInterrupt(SoftTimer2[SC_DigitalVUUpdate]))
		{
			SoftTimerReset(SoftTimer2[SC_DigitalVUUpdate]); 
		
         /* Do the VU Meter*/
         uint16_t i;
         uint8_t  VURows = GetVURows();
			   			           
         for( i = 0 ; i < DIGITAL_INPUTS+METRONOME_INPUTS; i++ )
         {
            uint8_t ActualChannel = i + ANALOGUE_INPUTS;
            
				if( GetChannelStatus(ActualChannel) )
				{	
					if( VUValues[i] )
					{
						VUSetLevel(i, VUNormaliseMIDI(GetDigitalVelocity(i), VURows), VURows); 
					}
				}
			}
         VUMeterPrint(SEQUENTIAL_METERS | 0x0F, VURows);
         ResetVUValues();
      }          
      
		/* About Strings Update routine */   
      if( SoftTimerInterrupt(SoftTimer2[SC_AboutUpdate]) )
		{
			uint8_t nameIndex = 0;
			nameIndex = ThanksIndex(GET);
			if( ++nameIndex == SIZEOFTHANKS )
			{
				nameIndex = ThanksIndex(MAIN_SCREEN);	
			}
			ThanksIndex(nameIndex);
			aboutScroll(nameIndex);
			SoftTimerReset(SoftTimer2[SC_AboutUpdate]);
		}   
	}
	
	eint();
}
Example #10
0
void ExOptions::DrawMenuRecon()
{
	ASSERT(*D2Vars.D2CLIENT_D2Menu);
	ASSERT(*D2Vars.D2CLIENT_D2MenuEntries);

	D2Menu * Menu = *D2Vars.D2CLIENT_D2Menu;
	D2MenuEntry * Entries = *D2Vars.D2CLIENT_D2MenuEntries;

	static CellContext Pent = { 0 };
	Pent.pCellFile = *D2Vars.D2CLIENT_MenuPent;
	Pent.nCellNo = 0;

	static DWORD LastTick = 0;
	static DWORD PentFrame = 0;
	D2Funcs.D2WIN_SetTextSize(6);
	ExScreen::DrawTextEx(2, 10, 5, 0, 5, "D2Ex2/Build %s%d.%s.%s.%s,",
#if !defined D2EX_CLOSED_BNET && !defined D2EX_SCRAP_HACK && !defined D2EX_MULTIRES && !defined D2EX_ARGOLD && \
	!defined D2EX_PVPGN_EXT && !defined D2EX_EXAIM_ENABLED && !defined D2EX_PVM_BUILD
		"GENERIC|"
#endif 
#ifdef D2EX_CLOSED_BNET
		D2EX_CLOSED_BNET
#endif
#ifdef D2EX_SCRAP_HACKS
		D2EX_SCRAP_HACKS
#endif
#ifdef D2EX_MULTIRES
		D2EX_MULTIRES
#endif
#ifdef D2EX_ARGOLD
		D2EX_ARGOLD
#endif
#ifdef D2EX_PVPGN_EXT
		D2EX_PVPGN_EXT
#endif
#ifdef D2EX_EXAIM_ENABLED
		D2EX_EXAIM_ENABLED
#endif
#ifdef D2EX_PVM_BUILD
		D2EX_PVM_BUILD
#endif
		, __BUILDNO__, __DATE__, __TIME__,
#ifdef _DEBUG
		"Nightly"
#else
		"Release"
#endif
		);

	int MenuStartY = (*D2Vars.D2CLIENT_ScreenHeight - 80) / 2 - (Menu->dwEntriesNo * Menu->dwInterline) / 2;

	if (*D2Vars.D2CLIENT_PrevMouseY != *D2Vars.D2CLIENT_MouseY || *D2Vars.D2CLIENT_PrevMouseX != *D2Vars.D2CLIENT_MouseX)
	{
		*D2Vars.D2CLIENT_PrevMouseY = *D2Vars.D2CLIENT_MouseY;
		*D2Vars.D2CLIENT_PrevMouseX = *D2Vars.D2CLIENT_MouseX;
		if (isMenuClicked)
			MenuUpdate(*D2Vars.D2CLIENT_MouseX, *D2Vars.D2CLIENT_MouseY);
		//	D2Funcs.D2CLIENT_D2MenuChange(*D2Vars.D2CLIENT_MouseY,0,*D2Vars.D2CLIENT_MouseX);
		else
		{
			int SelMenu = D2ASMFuncs::D2CLIENT_GetSelectedMenu(*D2Vars.D2CLIENT_MouseY);
			if (SelMenu != -1) *D2Vars.D2CLIENT_SelectedMenu = SelMenu;
		}
	}

	for (int eNo = 0; (int)Menu->dwEntriesNo > eNo; eNo++)
	{
		Entries[eNo].dwYOffset = 0;
		int dwTrans = 0;
		if (!Entries[eNo].dwExpansion || D2Funcs.FOG_isExpansion())
		{
			if (!Entries[eNo].EnableCheck || (dwTrans = Entries[eNo].EnableCheck(&Entries[eNo], eNo)) != 0) dwTrans = 1;
			dwTrans = (4 * dwTrans) + 1;
			if (Entries[eNo].ValidateCheck) Entries[eNo].ValidateCheck(&Entries[eNo]);
			int MenuPosY = MenuStartY + eNo * Menu->dwInterline;
			int MenuTextY = MenuPosY + Menu->dwTextHeight;
			Entries[eNo].dwYOffset = MenuPosY;
			switch (Entries[eNo].dwMenuType)
			{
			case D2MENU_STATIC: // Static entry
			case D2MENU_NORMAL: // Normal entry
				if (Entries[eNo].ptCellFile)
					D2Funcs.D2WIN_DrawCellFile(Entries[eNo].ptCellFile, *D2Vars.D2CLIENT_ScreenWidth / 2, MenuTextY, 1, dwTrans, -1);
				else if (Entries[eNo].wItemName[0])
				{
					D2Funcs.D2WIN_SetTextSize(Entries[eNo].dwFontType ? Entries[eNo].dwFontType : 3);
					int Tw = D2Funcs.D2WIN_GetTextWidth(Entries[eNo].wItemName);
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wItemName, (*D2Vars.D2CLIENT_ScreenWidth - Tw) / 2, MenuTextY, Entries[eNo].dwColor, 0, dwTrans);
				}
				break;
			case D2MENU_SWITCH: // Switch Entry
				if (Entries[eNo].ptCellFile)
					D2Funcs.D2WIN_DrawCellFile(Entries[eNo].ptCellFile, *D2Vars.D2CLIENT_ScreenWidth / 2 - 230, MenuTextY, 0, dwTrans, -1);
				else if (Entries[eNo].wItemName[0])
				{
					D2Funcs.D2WIN_SetTextSize(2);
					int Tw = D2Funcs.D2WIN_GetTextWidth(Entries[eNo].wItemName);
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wItemName, (*D2Vars.D2CLIENT_ScreenWidth) / 2 - 250, MenuTextY, 0, 0, dwTrans);
				}
				if (Entries[eNo].ptSwitchCellFile[Entries[eNo].dwCurrentValue])
					D2Funcs.D2WIN_DrawCellFile(Entries[eNo].ptSwitchCellFile[Entries[eNo].dwCurrentValue], *D2Vars.D2CLIENT_ScreenWidth / 2 + 230, MenuTextY, 2, dwTrans, -1);
				else if (Entries[eNo].wItemName[0])
				{
					D2Funcs.D2WIN_SetTextSize(Entries[eNo].dwFontType ? Entries[eNo].dwFontType : 2);
					int Tw = D2Funcs.D2WIN_GetTextWidth(Entries[eNo].wSwitchItemName[Entries[eNo].dwCurrentValue]);
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wSwitchItemName[Entries[eNo].dwCurrentValue], (*D2Vars.D2CLIENT_ScreenWidth - Tw) / 2 + 230, MenuTextY, 0, 0, dwTrans);
				}
				break;
			case D2MENU_BAR: // Bar Entry
				if (Entries[eNo].ptCellFile)
				{
					D2Funcs.D2WIN_DrawCellFile(Entries[eNo].ptCellFile, *D2Vars.D2CLIENT_ScreenWidth / 2 - 230, MenuTextY, 0, dwTrans, -1);
					D2Funcs.D2CLIENT_D2DrawBar(MenuPosY, 0, &Entries[eNo], dwTrans, Entries[eNo].ptCellFile == 0);
				}
				else if (Entries[eNo].wItemName[0])
				{
					D2Funcs.D2WIN_SetTextSize(Entries[eNo].dwFontType ? Entries[eNo].dwFontType : 7);
					int Tw = D2Funcs.D2WIN_GetTextWidth(Entries[eNo].wItemName);
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wItemName, (*D2Vars.D2CLIENT_ScreenWidth - Tw) / 2 - 230, MenuTextY, 7, 0, dwTrans);
					D2Funcs.D2CLIENT_D2DrawBar(MenuPosY + 7, 0, &Entries[eNo], dwTrans, 0);
				}
				break;
			case D2MENU_KEY: // Key Config
				if (Entries[eNo].wItemName[0])
				{
					D2Funcs.D2WIN_SetTextSize(Entries[eNo].dwFontType ? Entries[eNo].dwFontType : 8);
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wItemName, 130, MenuTextY, COL_ORANGE, 0, dwTrans);
					if (Entries[eNo].Bind) {
						wchar_t* szKey = ExInput::GetNameOfKey((WORD)*Entries[eNo].Bind);
						int Tw2 = D2Funcs.D2WIN_GetTextWidth(szKey);
						D2Funcs.D2WIN_DrawTextEx(szKey, (*D2Vars.D2CLIENT_ScreenWidth - Tw2) / 2 + 230, MenuTextY, MenuKeyClicked == eNo ? COL_RED : COL_WHITE, 0, dwTrans);
					}
				}
				break;
			case D2MENU_SWITCHEX: // Switch++ Entry
				D2Funcs.D2WIN_SetTextSize(Entries[eNo].dwFontType ? Entries[eNo].dwFontType : 2);
				if (Entries[eNo].wItemName[0])
				{
					int Tw = D2Funcs.D2WIN_GetTextWidth(Entries[eNo].wItemName);
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wItemName, (*D2Vars.D2CLIENT_ScreenWidth) / 2 - 250, MenuTextY, 0, 0, dwTrans);

					Tw = D2Funcs.D2WIN_GetTextWidth(Entries[eNo].wSwitches[Entries[eNo].dwCurrentValue]->c_str());
					D2Funcs.D2WIN_DrawTextEx(Entries[eNo].wSwitches[Entries[eNo].dwCurrentValue]->c_str(), (*D2Vars.D2CLIENT_ScreenWidth - Tw) / 2 + 230, MenuTextY, 0, 0, dwTrans);
				}
				break;
			}
		}
	}
	if (PentFrame == 0) Pent.nCellNo = 0; //*D2Vars.D2CLIENT_WidestMenu
	else Pent.nCellNo = 8 - PentFrame;
	int PentY = Menu->dwMenuOffset + Entries[*D2Vars.D2CLIENT_SelectedMenu].dwYOffset;
	D2Funcs.D2GFX_DrawCellContext(&Pent, (int)(*D2Vars.D2CLIENT_ScreenWidth * 0.9), PentY, -1, 5, 0);
	Pent.nCellNo = PentFrame;
	D2Funcs.D2GFX_DrawCellContext(&Pent, (int)(*D2Vars.D2CLIENT_ScreenWidth * 0.02), PentY, -1, 5, 0);

	int Tick = GetTickCount();
	if (Tick - LastTick > 50)
	{
		LastTick = Tick;
		PentFrame = (PentFrame + 1) % 8;
	}

}
Example #11
0
// The main message loop
int RunMessageLoop()
{
	int bRestartVideo=0;

RunAgain:

	if (nVidFullscreen)
	{
		while (ShowCursor(0)>=0)
			;    // hide cursor in fullscreen
	}

	// Size the window for current game
	ScrnSize();

	RunInit();

	bRestartVideo = 0;

	for (;;)
	{
		MSG Msg;
		int nRet=0;
		nRet=PeekMessage(&Msg,NULL,0,0,PM_REMOVE);
		if (nRet!=0)
		{
			// A message is waiting to be processed
			if (Msg.message == WM_QUIT)
			{
				break;    // Quit program
			}
			if (Msg.message == WM_APP + 0)
			{
				bRestartVideo = 1;
				break;
			}

			if (Msg.message == WM_KEYDOWN)
			{

				// Escape key
				if (Msg.wParam == VK_ESCAPE)
				{
					if (bCmdOptUsed)
					{
						PostQuitMessage(0);
					}
					else
					{
						if (nVidFullscreen)
						{
							nVidFullscreen = 0;
							PostMessage(NULL, WM_APP + 0, 0, 0);
						}

					}
				}

				// Hotkeys for savestates
				if (Msg.wParam >= VK_F1 && Msg.wParam <= VK_F9)
				{
					if (GetAsyncKeyState(VK_CONTROL) & 0x80000000)
					{
						int nSlot = Msg.wParam + 1 - VK_F1;
						if (GetAsyncKeyState(VK_SHIFT) & 0x80000000)
							// Save state
						{
							StatedSave(nSlot);
						}
						else
							// Load state
						{
							StatedLoad(nSlot);
						}
					}
				}

			}


#ifdef _DEBUG
			// For the "counter"variable
			if ((Msg.message==WM_SYSKEYDOWN || Msg.message==WM_KEYDOWN))
			{
				switch (Msg.wParam)
				{
				case 'N':
					counter--;
					break;
				case 'M':
					counter++;
					break;
				}
			}
#endif

			if ((Msg.message==WM_SYSKEYDOWN || Msg.message==WM_KEYDOWN)&&(Msg.lParam&0x20000000))
			{
				// An Alt/AltGr-key was pressed
				switch (Msg.wParam)
				{
				case 'I':
					bAppFastForward=!bAppFastForward;
					break;
				case 'O':
					bAppStep=1;
					break;
				case 'P':
					bRunPause=!bRunPause;
					bAltPause=!bAltPause;
					MenuUpdate();
					break;
				case 13 :
				{
					nVidFullscreen=!nVidFullscreen;
					PostMessage(NULL,WM_APP+0,0,0);
					break;
				}
				case 0xBB:
				{
					if(nDSoundVol < 0L)
					{
						nDSoundVol+=100L;
					}

					break;
				}
				case 0xBD:
				{
					if(nDSoundVol > -4000L)
					{
						nDSoundVol-=100L;
					}

					break;
				}
				}
			}

			// Check for messages for dialogs etc.
			nRet=AppMessage(&Msg);
			if (nRet!=0)
			{
				if(TranslateAccelerator(hScrnWnd, hAccel, &Msg)==0)
				{
					DispatchMessage(&Msg);
				}
			}
		}
		else
		{
			HWND hActive=GetActiveWindow();

			bAppDoFast=bAppFastForward;

			if (APP_TAKE_INPUT(hActive))
			{
				if (KEY_DOWN(VK_F7))
				{
					bAppDoFast=1;
				}
			}
			// No messages are waiting
			RunIdle();
		}
	}

	if (nVidFullscreen==0)
	{
		while (ShowCursor(1)< 0);    // show cursor in windowed
	}

	RunExit();

	if (bRestartVideo)
	{
		int nRet=0;
		VidExit();
		MediaExit();

		MediaInit();

		// Reinit the video plugin
		nRet=VidInit();
		if (nRet!=0)
		{
			AppError("VidInit Failed",0);
		}
		if (bDrvOkay && bRunPause)
		{
			VidRedraw();
		}
		goto RunAgain;
	}

	return 0;
}