⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gameprelude.c

📁 凌阳32位单片机开发的小游戏
💻 C
字号:
/******************************************************************************
 *
 *     The information contained herein is the exclusive property of
 *   Sunplus Technology Co. And shall not be distributed, reproduced,
 *   or disclosed in whole in part without prior written permission.
 *
 *         (C) COPYRIGHT 2005   SUNPLUS TECHNOLOGY CO.
 *                        ALL RIGHTS RESERVED
 *
 * The entire notice above must be reproduced on all authorized copies.
 *
 *****************************************************************************/

/******************************************************************************
 *  Filename:   	GamePrelude.c
 *  Author:     	xydeng  (eMail: xydeng @sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2005-11-28 
 *  Description:	 
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2005-11-28           xydeng               Create
 *
 *****************************************************************************/
#include "Include/GamePrelude.h"
#include "Include/GamePlay.h"
#include "../GameData/MotionData.h"

extern U16 nHMovementCnt;
extern bool g_bHMovementFlag;

#define   PREINIT          0
#define   PRELOOP          1
#define   PREEND           2

GAMESTATE ePreludeTempState;
U8 nSelID;
U8 nPreState;
U16 aPosY[3] = {200, 264+20, 328};

MOTION *pPrelude_Motion_Start,*pPrelude_Motion_Sensor,*pPrelude_Motion_Acotor;

const LOAD_INFO LoadPreInfo[] =
{
 	{".\\Game\\CeShow\\Prelude_Index1.bin"		, TEXT1_PNT_ADDR	, O_RDONLY, 0x4000  },//O_CREAT
	{".\\Game\\CeShow\\Prelude_Index2.bin"		, TEXT2_PNT_ADDR	, O_RDONLY, 0x4000  },
	{".\\Game\\CeShow\\Prelude_Index3.bin"		, TEXT3_PNT_ADDR	, O_RDONLY, 0x0000  },
 	{".\\Game\\CeShow\\Prelude_Pixel1.bin"		, TEXT1_PGT_ADDR	, O_RDONLY, 0x100000},
	{".\\Game\\CeShow\\Prelude_Pixel2.bin"		, TEXT2_PGT_ADDR	, O_RDONLY, 0x100000},
	{".\\Game\\CeShow\\Prelude_Pixel3.bin"		, TEXT3_PGT_ADDR	, O_RDONLY, 0x000000},
	{".\\Game\\CeShow\\Prelude_Palette.bin"	 	, BG_PAL_ADDR   	, O_RDONLY, 0x4000  },
	{".\\Game\\CeShow\\Prelude_TextHeader.bin" 	, TEXT_HEADER_ADDR	, O_RDONLY, 0x8000  },
};
                    
/******************************************************************
 * Function:    GAMESTATE BW_Prelude(void)
 * Description: This function is the start of this Benthal world
                and when  turn down the START key it will turn to
                GamePlay,or if you wait some time,it will turn to
                MP4
 * Syntax:      GAMESTATE BW_Prelude(void)
 * parameters:   
 * returns:     ePreludeTempState
 * Notes:       
 ******************************************************************/
GAMESTATE BW_Prelude(void)
{
	nPreState = PREINIT;
   
	while(1)
	{ 
   		//Check State 
		switch(nPreState)
		{
		case PREINIT:
			Prelude_Init();
			break;
		case PRELOOP: 
			Prelude_Loop();
			break;
		case PREEND:
			Prelude_End(); 
			return ePreludeTempState;
			break;
		}  
   }
   return BW_GAMESTATE_MAXNUM; 
}

/******************************************************************
 * Function:    Prelude_Init()
 * Description:  
 * Syntax:      void Prelude_Init(void)
 * parameters:  none
 * returns:      
 * Notes:       none
 ******************************************************************/
void Prelude_Init(void)
{
	InitTV();
	
	Sys_Load_SDCard(&LoadPreInfo, ASZ(LoadPreInfo));
	
	InitSystem();
	*P_PPU_TX1_Control = 0x000a;
	*P_PPU_TX2_Control = 0x011a;
	*P_PPU_TX3_Control = 0x0002;
	*P_PPU_TX2_Blending = 40;
	*P_PPU_TX1_X = 0;
	*P_PPU_TX2_X = 0;
	*P_PPU_TX3_X = 0;
	*P_PPU_TX1_Y = 0;
	*P_PPU_TX2_Y = 0;
	*P_PPU_TX3_Y = 0;
	WaitBlanking();
	E_InitMotion();   
	pPrelude_Motion_Start=E_AllocMotion(&Start_Action[0], 0, 256, 304-64, SP_PRIO_7);
	pPrelude_Motion_Sensor=E_AllocMotion(&Sensor_Action[0], 0, 224+20, 304+32, SP_PRIO_7);
	pPrelude_Motion_Acotor=E_AllocMotion(&Actor_Action[0], 2, 96, 200, SP_PRIO_15);

	nSelID = 0;
	g_nKeyCnt = 0;
	nHMovementCnt = 0;//HMovement
	g_bHMovementFlag = true;
#ifdef MIDI_ENABLE
	//SetMidiChannelMask(0x00FF, 0xFFFF);//bit0 ~ bit15 used by midi
	//SetMidiVolume(127);
	StopMidi();
	//InitSPU();	// tested by Bruce
	PlayMidi(MIDI_START, SS_PLAYMIDI_INFINITY);
#endif
	PPU_ShowSprite(true);
	WaitBlanking();
	FadeIn();
	nPreState = PRELOOP;
}

extern U8		g_nScore;
/******************************************************************
 * Function:    Prelude_Loop()
 * Description:  
 * Syntax:      void Prelude_Loop( void)
 * parameters:  none
 * returns:      
 * Notes:       none
 ******************************************************************/
void Prelude_Loop(void)
{
	g_bHMovementFlag = true;

	g_stEvent.Ev_Key = VK_MAX_NUM;
	g_nKeyCnt ++;
	if ( g_nKeyCnt > 3)//IGNOREKEY
	{
		Play_ProcessInput();
		g_nKeyCnt = 0;
	}
	
	if ( g_stEvent.Ev_Key == VK_UP )
	{
		if ( nSelID > 0)
			nSelID --;
		else
			nSelID = 1;
#ifdef AUDIO_ENABLE
		//TM_StopPCM(AUDIO_NO0);
		TM_PlayPCM((U8 *)RES_WAVEBUTTON_DRM, 64, 127);
#endif
	}
	if ( g_stEvent.Ev_Key == VK_DOWN )
	{
		if ( nSelID < 1)
			nSelID ++;
		else
			nSelID = 0;
#ifdef AUDIO_ENABLE	
		//TM_StopPCM(AUDIO_NO0);
		TM_PlayPCM((U8 *)RES_WAVEBUTTON_DRM, 64, 127);
#endif
	}
	if ( g_stEvent.Ev_Key == VK_START )
	{
#ifdef AUDIO_ENABLE	
		//TM_StopPCM(AUDIO_NO0);
		TM_PlayPCM((U8 *)RES_WAVESFX_SELECT_DRM, 64, 127);
#endif
		switch( nSelID )
		{
		case 0:
			ePreludeTempState= BW_PLAY;
			g_nScore = 0;	// Score			
			g_nText3Mode = 1;//Text3
			break;
		case 1:
			ePreludeTempState= BW_PLAY;
			g_nScore = 0;	// Score			
			g_nText3Mode = 0;//Sensor
			break;
		case 2:
//			ePreludeTempState= BW_MP4;
//			nMP4Select = 1;
			break;
		}
		nPreState = PREEND;
	}
	//exit game
	if ( g_stEvent.Ev_Key == VK_A )
	{
		nPreState = PREEND;
		ePreludeTempState= BW_GAMESTATE_MAXNUM;
	}
	pPrelude_Motion_Acotor->pSprite->stPos.y = aPosY[nSelID];
	E_MotionProc();
	PPU_ShowSprite(true);
	WaitBlanking();
}

/******************************************************************
 * Function:    Prelude_End()
 * Description:    
 * Syntax:      void Prelude_End( void)
 * parameters:  none
 * returns:     none
 * Notes:       none
 ******************************************************************/

void Prelude_End( void)
{
	E_FreeMotion(pPrelude_Motion_Start);
	E_FreeMotion(pPrelude_Motion_Sensor);
	E_FreeMotion(pPrelude_Motion_Acotor);

	FadeOut();
#ifdef MIDI_ENABLE
	StopMidi();
	//SetMidiVolume(0);
	//TM_StopPCM(AUDIO_NO0);
	//InitSPU();
#endif
	WaitBlanking();
}





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -