示例#1
0
文件: main.c 项目: brett19/wut
int
main(int argc, char **argv)
{
   OSReport("Main thread running on core %d", OSGetCoreId());

   // Run thread on core 0
   OSThread *threadCore0 = OSGetDefaultThread(0);

   const char *core0Args[] = {
      "Core 0"
   };

   OSRunThread(threadCore0, CoreEntryPoint, 0, core0Args);

   // Run thread on core 2
   OSThread *threadCore2 = OSGetDefaultThread(2);

   const char *core2Args[] = {
      "Core 2"
   };

   OSRunThread(threadCore2, CoreEntryPoint, 2, core2Args);

   // Wait for threads to return
   int resultCore0 = -1, resultCore2 = -1;
   OSJoinThread(threadCore0, &resultCore0);
   OSJoinThread(threadCore2, &resultCore2);

   OSReport("Core 0 thread returned %d", resultCore0);
   OSReport("Core 2 thread returned %d", resultCore2);
   return 0;
}
示例#2
0
void dKPMusic::play(int id) {
	if (s_playing) {
		// Switch track
		OSReport("Trying to switch to song %d (Current one is %d)...\n", id, s_song);
		if ((s_song == id && s_nextSong == -1) || s_nextSong == id) {
			OSReport("This song is already playing or is scheduled. Not gonna do that.\n");
		//} else if (s_countdownToFadeIn >= 0) {
		//	OSReport("There's already a track being faded in (CountdownToFadeIn=%d)\n", s_countdownToFadeIn);
		} else if (s_countdownToSwitch >= 0) {
			OSReport("We were already going to switch tracks, but the rstm hasn't been changed yet, so the next song is being changed to this one\n");
			s_nextSong = id;
		} else {
			OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN);

			if (s_handle.Exists())
				s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f);
			s_nextSong = id;
			s_countdownToSwitch = FADE_OUT_LEN;
		}

	} else {
		// New track
		OSReport("Playing song %d from the start.\n", id);

		int realStreamID;
		char brstmName[8];
		sprintf(brstmName, "map%d", id);
		hijackMusicWithSongName(brstmName, -1, false, 4, 2, &realStreamID);

		PlaySoundWithFunctionB4(SoundRelatedClass, &s_handle, realStreamID, 1);

		s_playing = true;
		s_song = id;
	}
}
示例#3
0
void screenInit()
{
	//Grab the buffer size for each screen (TV and gamepad)
	int buf0_size = OSScreenGetBufferSizeEx(0);
	int buf1_size = OSScreenGetBufferSizeEx(1);
	__os_snprintf(log_buf, 0x400, "Screen sizes %x, %x\n", buf0_size, buf1_size);
	OSReport(log_buf);
	
	//Set the buffer area.
	screenBuffer = MEM1_alloc(buf0_size + buf1_size, 0x40);
	__os_snprintf(log_buf, 0x400, "Allocated screen buffers at %x\n", screenBuffer);
	OSReport(log_buf);

    OSScreenSetBufferEx(0, screenBuffer);
    OSScreenSetBufferEx(1, (screenBuffer + buf0_size));
    OSReport("Set screen buffers\n");

    OSScreenEnableEx(0, 1);
    OSScreenEnableEx(1, 1);
    
    //Clear both framebuffers.
	for (int ii = 0; ii < 2; ii++)
	{
		fillScreen(0,0,0,0);
		flipBuffers();
	}
}
示例#4
0
/*!
 ******************************************************************************
 * \brief
 *		Check for drive status
 *
 ******************************************************************************
 */
BOOL AUDSimpleCheckDVDError(void)
	{
	switch (DVDGetDriveStatus())
		{
		case DVD_STATE_FATAL_ERROR:
			{
			OSReport("DVDGetDriveStatus()=DVD_STATE_FATAL_ERROR\n");
			break;
			}
		case DVD_STATE_NO_DISK:
			{
			OSReport("DVDGetDriveStatus()=DVD_STATE_NO_DISK\n");
			break;
			}
		case DVD_STATE_COVER_OPEN:
			{
			OSReport("DVDGetDriveStatus()=DVD_STATE_COVER_OPEN\n");
			break;
			}
		case DVD_STATE_WRONG_DISK:
			{
			OSReport("DVDGetDriveStatus()=DVD_STATE_WRONG_DISK\n");
			break;
			}
		case DVD_STATE_RETRY:
			{
			OSReport("DVDGetDriveStatus()=DVD_STATE_RETRY\n");
			break;
			}
		default:
			return(TRUE);
		}
	
	return(FALSE);
	}
示例#5
0
void dWMShop_c::ShopModel_c::execute() {
	model._vf1C();

	if(this->animation.isAnimationDone()) {
		OSReport("Animaiton Complete");
		if (this->isLakitu) {
			OSReport("Setting animation to idle");
			playAnim("idle", 1.0f, 0);
			this->animation.setCurrentFrame(0.0);
			if (playingNotEnough) {
				OSReport("Detected Not Enough animation as being over\n");
				playingNotEnough = false;
			}
		}
	}	
}
示例#6
0
	void daTopman::executeState_KnockBack() { 

		bool ret = calculateTileCollisions();
		this->speed.x = this->speed.x / 1.1;

		bodyModel._vf1C();
		if(this->chrAnimation.isAnimationDone()) {
			if (this->isWaiting == 0) {
				OSReport("Done being knocked back, going back to Walk state\n");
				doStateChange(&StateID_Walk); }
			else {
				OSReport("Done being knocked back, going back to Wait state\n");
				doStateChange(&StateID_Wait); }
		}

	}
示例#7
0
extern "C" GEIFS *GrabExitInfoForFileSelect(GEIFS *out, SaveBlock *save) {
	out->starCoins = 0;
	out->exits = 0;

	for (int i = 0; i < dLevelInfo_c::s_info.sectionCount(); i++) {
		dLevelInfo_c::section_s *section = dLevelInfo_c::s_info.getSectionByIndex(i);

		for (int j = 0; j < section->levelCount; j++) {
			dLevelInfo_c::entry_s *l = &section->levels[j];
			if (l->flags & 2) {
				//OSReport("Checking %d-%d...\n", l->worldSlot+1, l->levelSlot+1);
				u32 cond = save->GetLevelCondition(l->worldSlot, l->levelSlot);
				if ((l->flags & 0x10) && (cond & COND_NORMAL))
					out->exits++;
				if ((l->flags & 0x20) && (cond & COND_SECRET))
					out->exits++;
				if (cond & COND_COIN1)
					out->starCoins++;
				if (cond & COND_COIN2)
					out->starCoins++;
				if (cond & COND_COIN3)
					out->starCoins++;
			}
		}
	}

	OSReport("Done, got %d coins and %d exits\n", out->starCoins, out->exits);

	return out;
}
示例#8
0
void dWMShop_c::executeState_Wait() {
	if (timer < 90) {
		scaleEase = -((cos(timer * 3.14 /20)-0.9)/timer*10)+1;
		timer++;
		return;
	}

	int nowPressed = Remocon_GetPressed(GetActiveRemocon());

	int newSelection = -1;

	if (nowPressed & WPAD_ONE) {
		// Hide the thing
		state.setState(&StateID_HideWait);

	} else if (nowPressed & WPAD_UP) {
		// Move up
		if (selected == 4)
			newSelection = lastTopRowChoice;
		else if (selected == 5)
			newSelection = 4;

	} else if (nowPressed & WPAD_DOWN) {
		// Move down
		if (selected <= 3)
			newSelection = 4;
		else if (selected == 4)
			newSelection = 5;

	} else if (nowPressed & WPAD_LEFT) {
		// Just use the previous choice
		if (selected > 0)
			newSelection = selected - 1;

	} else if (nowPressed & WPAD_RIGHT) {
		// Just use the next choice
		if (selected < 5)
			newSelection = selected + 1;

	} else if (nowPressed & WPAD_TWO) {
		if (!lakituModel->playingNotEnough)
			buyItem(selected);
		else
			OSReport("Not Enough is still playing!\n");
	}

	if (newSelection > -1) {
		MapSoundPlayer(SoundRelatedClass, SE_SYS_CURSOR, 1);

		layout.enableNonLoopAnim(DEACTIVATE_BUTTON+selected);
		layout.enableNonLoopAnim(ACTIVATE_BUTTON+newSelection);

		selected = newSelection;
		if (newSelection <= 3)
			lastTopRowChoice = newSelection;

		showSelectCursor();
	}
}
示例#9
0
void dWMShop_c::buyItem(int item) {
	static int itemDefs[6][3] = {
		// Cost, Start Index, Count
		{1, 0, 1}, {2, 1, 1}, {2, 2, 1}, {3, 3, 1},
		{5, 4, 3}, {8, 7, 5}
	};

	int cost = itemDefs[item][0], cash = getUnspentStarCoinCount();

	if (cost > cash) {
		OSReport("Started playing Not Enough\n");
		lakituModel->playingNotEnough = true;
		lakituModel->playAnim("notenough", 1.0f, 1);
		MapSoundPlayer(SoundRelatedClass, SE_SYS_INVALID, 1);
		return;
	}

	MapSoundPlayer(SoundRelatedClass, SE_SYS_DECIDE, 1);

	SaveFile *file = GetSaveFile();
	SaveBlock *block = file->GetBlock(file->header.current_file);

	coinsRemaining = cost;

	// Work out what we need to apply
	int appliedItems[ITEM_TYPE_COUNT];
	for (int i = 0; i < ITEM_TYPE_COUNT; i++)
		appliedItems[i] = 0;

	int invStartIndex = itemDefs[item][1], invCount = itemDefs[item][2];
	for (int i = 0; i < invCount; i++)
		appliedItems[(int)Inventory[shopKind][invStartIndex+i]]++;

	for (int i = 0; i < 8; i++) {
		block->powerups_available[i] += appliedItems[i];

		if (block->powerups_available[i] > 99)
			block->powerups_available[i] = 99;

		dScKoopatlas_c::instance->stockItem->newCounts[i] = block->powerups_available[i];
	}

	// Apply lives to everyone
	for (int i = 0; i < 4; i++) {
		if (Player_Active[i]) {
			int id = Player_ID[i];
			Player_Lives[id] += appliedItems[(int)ONE_UP];
			if (Player_Lives[id] > 99)
				Player_Lives[id] = 99;
		}
	}

	if (appliedItems[(int)ONE_UP] > 0)
		MapSoundPlayer(SoundRelatedClass, SE_SYS_100COIN_ONE_UP, 1);

	state.setState(&StateID_CoinCountdown);
	HideSelectCursor(SelectCursorPointer, 0);
}
示例#10
0
void FuckinBubbles() {
	dCourse_c *course = dCourseFull_c::instance->get(GetAreaNum());
	bool thing = false;

	int zone = GetZoneNum();
	for (int i = 0; i < course->zoneSpriteCount[zone]; i++) {
		dCourse_c::sprite_s *spr = &course->zoneFirstSprite[zone][i];
		if (spr->type == 246 && (spr->settings & 0xF) == 8)
			thing = true;
	}

	if (thing) {
		OSReport("DISABLING EXISTING BUBBLES.\n");
		for (int i = 0; i < 4; i++)
			Player_Flags[i] &= ~4;
	}
}
示例#11
0
static void AUDSimpleLoadStartDVDCallback( s32 result, DVDFileInfo* fileInfo )
{
	// Deal with errors.
	if( audio_player.error )
	{
		return;
	}
	
	audio_player.nextFrameOffset += audio_player.nextFrameSize;
	audio_player.readBuffer[audio_player.readIndex].size = audio_player.nextFrameSize;

	// Set read size for next 'FRAM' chunk.
	u32* nextFrame = (u32*)(audio_player.readBuffer[audio_player.readIndex].ptr + audio_player.nextFrameSize - 32);

	// Some sanity check if file structure is valid!
	ASSERT( nextFrame[0] == VID_FCC( 'F','R','A','M' ));

	audio_player.nextFrameSize = nextFrame[1];
	ASSERT( audio_player.nextFrameSize );

	audio_player.readBuffer[audio_player.readIndex].valid = TRUE;
	audio_player.readBuffer[audio_player.readIndex].frameNumber = audio_player.currentFrameCount;

	// Use next buffer.
	audio_player.readIndex = (audio_player.readIndex + 1) % AUD_NUM_READ_BUFFERS;
	audio_player.currentFrameCount++;
	
	if( --readNum > 0 )
	{
		if( DVDReadAsync( &audio_player.fileHandle, audio_player.readBuffer[audio_player.readIndex].ptr, (s32)audio_player.nextFrameSize, (s32)audio_player.nextFrameOffset, AUDSimpleLoadStartDVDCallback ) < 0 )
		{
#			ifdef _DEBUG
			OSReport("*** AUDSimpleLoadStart: Failed to read from file.\n");
#			endif
			audio_player.error = TRUE;
			return;
		}
	}
	else
	{
		// All done.
		audio_player.loopMode		= FALSE;
		audio_player.preFetchState	= TRUE;
	}
}
示例#12
0
void dKPMusic::stop() {
	if (!s_playing)
		return;

	OSReport("Stopping song\n");

	s_playing = false;
	s_song = -1;
	s_nextSong = -1;
	s_countdownToSwitch = -1;
	s_countdownToFadeIn = -1;

	if (s_handle.Exists())
		s_handle.Stop(30);

	if (s_starHandle.Exists())
		s_starHandle.Stop(15);
}
示例#13
0
//TODO better fix for possible bug with sign (ex. life=120; count=-9;)
bool daMegaGoomba_c::takeHit(char count) {
	OSReport("Taking a hit!\n");
	if(!this->already_hit) {
		int c = count;
		int l = this->life;
		if(l - c > 127) {
			c = 127 - l;
		}
		this->life -= c;
		// this->XSpeed += 0.10;

		// float rate = this->animationChr.getUpdateRate();
		// this->animationChr.setUpdateRate(rate+0.05);
		this->JumpHeight += 12.0;
		this->JumpDist += 12.0;
		this->JumpTime += 5.0;
		doStateChange(&StateID_Shrink);
		this->already_hit = true;
	}
	return (life <= 0) ? true : false;
}
示例#14
0
void MeteorPhysicsCallback(dMeteor *self, dEn_c *other) {
	if (other->name == 657) {
		OSReport("CANNON COLLISION");

		S16Vec nullRot = {0,0,0};
		Vec oneVec = {1.0f, 1.0f, 1.0f};
		SpawnEffect("Wm_en_explosion", 0, &other->pos, &nullRot, &oneVec);
		SpawnEffect("Wm_en_explosion_smk", 0, &other->pos, &nullRot, &oneVec);
		PlaySound(other, SE_OBJ_TARU_BREAK);
		other->Delete(1);

		switch ((self->settings >> 24) & 3) {
			case 1:
				dStageActor_c::create(EN_HATENA_BALLOON, 0x100, &self->pos, 0, self->currentLayerID);
				break;
			case 2:
				VEC3 coinPos = {self->pos.x - 16.0f, self->pos.y, self->pos.z};
				dStageActor_c::create(EN_COIN, 9, &coinPos, 0, self->currentLayerID);
				break;
		}

		self->kill();
	}
示例#15
0
文件: main.c 项目: brett19/wut
int
CoreEntryPoint(int argc, const char **argv)
{
   OSReport("Hello world from %s", argv[0]);
   return argc;
}
示例#16
0
/*!
 ******************************************************************************
 * \brief
 *		Preload the allocated buffers.
 *
 *		This functions fills all buffers with initial data
 *
 * \param loopMode
 *		TRUE if we want to operate in loop mode
 *
 * \return
 *		TRUE if preload was okay 		
 *
 ******************************************************************************
 */
BOOL AUDSimpleLoadStart(BOOL loopMode)
{
//	u32		i, readNum;
//	u32		i;
//	u32*	nextFrame;

	ASSERT( loopMode == FALSE );
	
	if( audio_player.open && audio_player.preFetchState == FALSE )
	{
		readNum = AUD_NUM_READ_BUFFERS;

		// In 'non-loop' mode we must take care if we have LESS frames than preloading buffers
        if( !loopMode && audio_player.audioInfo.vaudex.frameCount < AUD_NUM_READ_BUFFERS )
			readNum = audio_player.audioInfo.vaudex.frameCount;
				
//		for( i = 0; i < readNum; i++ )
		if( readNum > 0 )
		{
			// Read total 'FRAM' chunk and 32 bytes of NEXT chunk.
//			if( DVDRead( &audio_player.fileHandle, ptr, (s32)audio_player.nextFrameSize, (s32)audio_player.nextFrameOffset ) < 0 )
			if( DVDReadAsync( &audio_player.fileHandle, audio_player.readBuffer[audio_player.readIndex].ptr, (s32)audio_player.nextFrameSize, (s32)audio_player.nextFrameOffset, AUDSimpleLoadStartDVDCallback ) < 0 )
			{
#				ifdef _DEBUG
				OSReport("*** AUDSimpleLoadStart: Failed to read from file.\n");
#				endif
				audio_player.error = TRUE;
				return FALSE;
			}
			
//			audio_player.nextFrameOffset += audio_player.nextFrameSize;
//			audio_player.readBuffer[audio_player.readIndex].size = audio_player.nextFrameSize;

            // set read size for next 'FRAM' chunk
//			nextFrame = (u32*)(audio_player.readBuffer[audio_player.readIndex].ptr + audio_player.nextFrameSize - 32);
			
			// some sanity check if file structure is valid!
//			ASSERT(nextFrame[0] == VID_FCC('F','R','A','M'));
			
//			audio_player.nextFrameSize = nextFrame[1];
//			ASSERT( audio_player.nextFrameSize );

//			audio_player.readBuffer[audio_player.readIndex].valid = TRUE;
//			audio_player.readBuffer[audio_player.readIndex].frameNumber = audio_player.currentFrameCount;

			// Use next buffer
//			audio_player.readIndex = (audio_player.readIndex + 1) % AUD_NUM_READ_BUFFERS;

//			audio_player.currentFrameCount++;

//			if (audio_player.currentFrameCount >  audio_player.audioInfo.vaudex.frameCount - 1)
//			{
//				if (loopMode)
//				{
//					audio_player.currentFrameCount = 0;
//					audio_player.nextFrameOffset = audio_player.firstFrameOffset;
//					audio_player.nextFrameSize  = audio_player.firstFrameSize;
//				}
//			}
		}
//		audio_player.loopMode = loopMode;
//		audio_player.preFetchState = TRUE;
		return TRUE;
	}
	return FALSE;
}
示例#17
0
static void AUDSimpleOpenDVDCallback( s32 result, DVDFileInfo* fileInfo )
{
	static u32	fileOffset		= 0;
	static u32	headSize		= 0;
	static u32	audioInfoSize	= 0;
	
	// Deal with errors, possibly flagged as an indication to shut down immediately.
	if( audio_player.error )
	{
		// Set this back to zero so the player will be regarded as 'free' again.
		audio_player.asyncOpenCallbackStatus = 0;
		return;
	}
	
	switch( audio_player.asyncOpenCallbackStatus )
	{
		case 1:
		{
			// The read of the 'VID1' chunk has completed.
			fileOffset = 32;
	
			// Check file id.
			if( workChunk.id != VID_FCC('V','I','D','1' ))
			{
#				ifdef _DEBUG
				OSReport("*** No VID1 file: '%s'\n", fileName);
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}
	
			// Check for correct version of vid chunk.
			// If we find this version we assume a 'special' alignment and chunk ordering which may be invalid
			// in another version of the file format.
			if( workChunk.vid.versionMajor != 1 || workChunk.vid.versionMinor != 0 )
			{
#				ifdef _DEBUG
				OSReport("*** Unsupported file version: major: %d, minor: %d\n", workChunk.vid.versionMajor, workChunk.vid.versionMajor);
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}
	
#			ifdef _DEBUG
			// Sometimes, it's required to check for a special build of the VidConv converter.
			{
				u32 version = VID_VERSION(workChunk.vid.vidConvMajor, workChunk.vid.vidConvMinor, workChunk.vid.vidConvBuild);
				if( version < VID_VERSION( 1, 0, 1 ))
					OSReport("*** WARNING: Vid file created using an unsupported converter version: %d.%d.%d\n", (u32)workChunk.vid.vidConvMajor, (u32)workChunk.vid.vidConvMinor, (u32)workChunk.vid.vidConvBuild);
			}
#			endif

			// Set callback status to indicate 'VID1' chunk is read.
			audio_player.asyncOpenCallbackStatus = 2;
			
			// Check types of chunks we have in this file.
			// !!! Note that we assume start of 'HEAD' chunk at byte offset 32 from file start !!!
			if( DVDReadAsync( &audio_player.fileHandle, &workChunk, 32, (s32)fileOffset, AUDSimpleOpenDVDCallback ) < 0 )
			{
#				ifdef _DEBUG
				OSReport("*** Failed to read 'HEAD' chunk.\n");
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}
			break;
		}
	
		case 2:
		{
			// The read of the chunk type info has completed.
			if( workChunk.id != VID_FCC('H','E','A','D' ))
			{
#				ifdef _DEBUG
				OSReport("*** No HEAD chunk found at expected offset\n");
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}

			// Calculate the start of the first frame chunk (we know the header chunk starts at offset 32).
			audio_player.nextFrameOffset = workChunk.len + 32;

			// Skip 'HEAD' chunk id, len and version fields.
			fileOffset += VID_CHUNK_HEADER_SIZE;

			// The header chunk contains one or more header chunks for the different data types contained
			// in the stream. Parse them all...

			headSize = workChunk.len - VID_CHUNK_HEADER_SIZE;
			
			audio_player.asyncOpenCallbackStatus = 3;
			if( DVDReadAsync( &audio_player.fileHandle, &workChunk, 32, (s32)fileOffset, AUDSimpleOpenDVDCallback ) < 0 )
			{
#				ifdef _DEBUG
				OSReport("*** Error reading file at offset %d\n", fileOffset);
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}
			break;
		}
	
		case 3:
		{
			fileOffset	+= 32;
			headSize	-= 32;

			// We analyze the 1st 32 bytes of the chunk for a known header format.
			if( workChunk.id == VID_FCC( 'A','U','D','H' ))
			{
				// Allocate memory for audio header chunk.
				audio_player.audioHeaderChunk	= (u8*)((*audio_player.cbAlloc)(workChunk.len));
				audioInfoSize					= workChunk.len - VID_CHUNK_HEADER_SIZE;

				// Copy the already loaded part.
				memcpy( audio_player.audioHeaderChunk, &workChunk, 32 );
				workChunk.len -= 32;

				// Read additional audio header bytes if the audio header is greater that 32 bytes
				if( workChunk.len >= 32 )
				{
					ASSERT(( workChunk.len & 31 ) == 0 );
					audio_player.asyncOpenCallbackStatus = 4;
					if( DVDReadAsync( &audio_player.fileHandle, audio_player.audioHeaderChunk + 32, workChunk.len, (s32)fileOffset, AUDSimpleOpenDVDCallback ) < 0 )
					{
#						ifdef _DEBUG
						OSReport("*** Error reading file at offset %d\n", fileOffset);
#						endif
						DVDClose( &audio_player.fileHandle );
						audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
						return;
					}
				}
				else
				{
					ASSERT( 0 );
				}
			}
			else
			{
				ASSERT( 0 );
			}
			break;
		}
					
		case 4:
		{
			fileOffset	+= workChunk.len;
			headSize	-= workChunk.len;

			// Setup and calc the number of bytes which we are allowed to copy into the audioInfo struct
			memcpy( &audio_player.audioInfo, audio_player.audioHeaderChunk + VID_CHUNK_HEADER_SIZE, MIN( audioInfoSize, sizeof( audio_player.audioInfo )));
			
			// Check if we have the correct vaud file version (>0).
			if( audio_player.audioInfo.vaudex.version == 0 )
			{
#				ifdef _DEBUG
				OSReport("*** Invalid version in vaud file.");
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}

			// We can only play audio files which have the following fields set.
			// Note that in case of VIDEO files this fields are allowed to be 0.
			ASSERT( audio_player.audioInfo.vaudex.maxBufferSize > 0 );
			ASSERT( audio_player.audioInfo.vaudex.frameCount > 0 );
			ASSERT( audio_player.audioInfo.vaudex.frameTimeMs > 0 );

			// Read beginning of 1st frame chunk to get required size information.
			audio_player.asyncOpenCallbackStatus = 5;
			if( DVDReadAsync( &audio_player.fileHandle, &workChunk, 32 , (s32)audio_player.nextFrameOffset, AUDSimpleOpenDVDCallback ) < 0 )
			{
#				ifdef _DEBUG
				OSReport("*** Failed to read 'FRAM' chunk.\n");
#				endif
				DVDClose( &audio_player.fileHandle );
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				return;
			}
			break;
		}
			
		case 5:
		{
			if( workChunk.id != VID_FCC('F','R','A','M') )
			{
#				ifdef _DEBUG
				OSReport("*** No FRAM chunk found.");
#				endif
				audio_player.asyncOpenCallbackStatus = ASYNC_OPEN_FAIL;
				DVDClose( &audio_player.fileHandle );
				return;
			}

			// 32 bytes of this chunk are already consumed, but we want to 'preload' the NEXT chunk's FRAM header.
			audio_player.nextFrameSize				= workChunk.len; 		
			audio_player.nextFrameOffset			+= 32;

			audio_player.firstFrameOffset			= audio_player.nextFrameOffset;
			audio_player.firstFrameSize				= audio_player.nextFrameSize;

//			strncpy( audio_player.fileName, fileName, 64 );
//			audio_player.fileName[63]				= 0;

			audio_player.open 			 			= TRUE;

			audio_player.asyncOpenCallbackStatus	= ASYNC_OPEN_SUCCESS;
			audio_player.readIndex 					= 0;
			audio_player.decodeIndex 				= 0;
			audio_player.lastDecodedFrame			= 0;
			audio_player.error 			 			= FALSE;
			audio_player.preFetchState 	 			= FALSE;
			audio_player.loopMode		 			= FALSE;
			audio_player.asyncDvdRunning			= FALSE;
			audio_player.currentFrameCount 			= 0;
			audio_player.readBufferBaseMem			= 0;
			break;
		}
	
		default:
		{
			ASSERT( 0 );
			break;
		}
	}
}
示例#18
0
int main(int argc, char **argv)
{	
    OSScreenInit();
    OSReport("Screen initted\n");
    
    ProcUIInit(&SaveCallback);

	/****************************>             Globals             <****************************/
	struct pongGlobals myPongGlobals;
	//Flag for restarting the entire game.
	myPongGlobals.restart = 1;
	//scale of game
	myPongGlobals.scale=1;
	//Default locations for paddles and ball location and movement dx/dy
	myPongGlobals.p1X_default=40*myPongGlobals.scale;
	myPongGlobals.p2X_default=340*myPongGlobals.scale;
	myPongGlobals.ballX_default=200*myPongGlobals.scale;
	myPongGlobals.p1Y_default=150*myPongGlobals.scale;
	myPongGlobals.p2Y_default=150*myPongGlobals.scale;
	myPongGlobals.ballY_default=120*myPongGlobals.scale;
	//Sizes of objects
	myPongGlobals.p1X_size=20*myPongGlobals.scale;
	myPongGlobals.p1Y_size=60*myPongGlobals.scale;
	myPongGlobals.ballX_size=8*myPongGlobals.scale;
	myPongGlobals.ballY_size=8*myPongGlobals.scale;
	myPongGlobals.p2X_size=20*myPongGlobals.scale;
	myPongGlobals.p2Y_size=60*myPongGlobals.scale;
	//Boundry of play area (screen)
	myPongGlobals.xMinBoundry=0*myPongGlobals.scale;
	myPongGlobals.xMaxBoundry=400*myPongGlobals.scale;
	myPongGlobals.yMinBoundry=0*myPongGlobals.scale;
	myPongGlobals.yMaxBoundry=240*myPongGlobals.scale;
	
	myPongGlobals.winX=11*2*myPongGlobals.scale;
	myPongGlobals.winY=5*2*myPongGlobals.scale;
	myPongGlobals.score1X=13*2*myPongGlobals.scale;
	myPongGlobals.score2X=15*2*myPongGlobals.scale;
	myPongGlobals.score1Y=0*myPongGlobals.scale;
	myPongGlobals.score2Y=0*myPongGlobals.scale;
	//Game engine globals
	myPongGlobals.direction = 1;
	myPongGlobals.button = 0;
	myPongGlobals.paddleColorR=0xFF;
	myPongGlobals.paddleColorG=0x00;
	myPongGlobals.paddleColorB=0x00;
	myPongGlobals.ballColorR=0x00;
	myPongGlobals.ballColorG=0xFF;
	myPongGlobals.ballColorB=0x00;
	myPongGlobals.ballTrailColorR=0x00;
	myPongGlobals.ballTrailColorG=0x00;
	myPongGlobals.ballTrailColorB=0xFF;
	myPongGlobals.backgroundColorR=0x00;
	myPongGlobals.backgroundColorG=0x00;
	myPongGlobals.backgroundColorB=0x00;
	myPongGlobals.count = 0;
	//Keep track of score
	myPongGlobals.score1 = 0;
	myPongGlobals.score2 = 0;
	myPongGlobals.scoreWin = 9;
	//Game engine globals
	myPongGlobals.direction = 1;
	myPongGlobals.button = 0;
	myPongGlobals.paddleColorR=0xFF;
	myPongGlobals.paddleColorG=0x00;
	myPongGlobals.paddleColorB=0x00;
	myPongGlobals.ballColorR=0x00;
	myPongGlobals.ballColorG=0xFF;
	myPongGlobals.ballColorB=0x00;
	myPongGlobals.ballTrailColorR=0x00;
	myPongGlobals.ballTrailColorG=0x00;
	myPongGlobals.ballTrailColorB=0xFF;
	myPongGlobals.backgroundColorR=0x00;
	myPongGlobals.backgroundColorG=0x00;
	myPongGlobals.backgroundColorB=0x00;
	myPongGlobals.count = 0;
	//Keep track of score
	myPongGlobals.score1 = 0;
	myPongGlobals.scoreWin = 9;
	//Used for collision
	myPongGlobals.flag = 0;

	//Flag to determine if p1 should be rendered along with p1's movement direction
	myPongGlobals.renderP1Flag = 0;
	//Flags for render states
	myPongGlobals.renderResetFlag = 0;
	myPongGlobals.renderBallFlag = 0;
	myPongGlobals.renderWinFlag = 0;
	myPongGlobals.renderScoreFlag = 0;
	OSReport("Globals initialized\n");
	
	/****************************>            VPAD Loop            <****************************/
	int error;
	VPADStatus vpad_data;
	while (AppRunning())
	{
	    if(!initialized) continue;
	    
		VPADRead(0, &vpad_data, 1, &error);
		//Get the status of the gamepad
		myPongGlobals.button = vpad_data.hold;
		//If the game has been restarted, reset the game (we do this one time in the beginning to set everything up)
		if (myPongGlobals.restart == 1)
		{
		    OSReport("Game reset\n");
			reset(&myPongGlobals);
			myPongGlobals.restart = 0;
		}		
		//Set old positions.
		updatePosition(&myPongGlobals);

		//Update location of player1 and 2 paddles
		p1Move(&myPongGlobals);
		p2Move(&myPongGlobals);

		//Update location of the ball
		moveBall(&myPongGlobals);
		//Check if their are any collisions between the ball and the paddles.
		checkCollision(&myPongGlobals);
		//Render the scene
		myPongGlobals.renderBallFlag = 1;
		render(&myPongGlobals);

		//Increment the counter (used for physicals calcuations)
		myPongGlobals.count+=1;
	}
	
	return 0;
}
示例#19
0
/*!
 ******************************************************************************
 * \brief
 *		Open video file.
 *
 *		This functions opens a video file and parses some basic file
 *		information.
 *
 * \param fileName
 *		Name of file to open
 *
 * \return
 *		TRUE if file could be opened and is in valid format!
 *
 ******************************************************************************
 */
BOOL AUDSimpleOpen( char* fileName )
{
//	u32 fileOffset = 0;
//	u32 headSize;
//	u32 audioInfoSize;
	
	if( audio_player.open )
	{
#		ifdef _DEBUG
		OSReport( "*** Cannot open '%s' because audio_player already open.\n", fileName );
#		endif
		return FALSE;
	}

	// Initialise the callback status.
	audio_player.asyncOpenCallbackStatus = 0;
	
	s32 entry_num = DVDConvertPathToEntrynum( fileName );
	if( entry_num == -1 )
	{
#		ifdef _DEBUG
		OSReport( "*** Cannot find '%s'\n", filename );
#		endif
		return FALSE;
	}
	if( DVDFastOpen( entry_num, &audio_player.fileHandle ) == FALSE )
	{
#		ifdef _DEBUG
		OSReport( "*** Cannot open: '%s'\n", fileName );
#		endif
		return FALSE;
	}
		
	// Set callback status to indicate file is now open.
	audio_player.asyncOpenCallbackStatus = 1;
	
	// Read 'VID1' chunk from file and check for correct version.
//	if( DVDRead( &audio_player.fileHandle, &workChunk, 32, 0 ) < 0 )
	if( DVDReadAsync( &audio_player.fileHandle, &workChunk, 32, 0, AUDSimpleOpenDVDCallback ) < 0 )
	{
#		ifdef _DEBUG
		OSReport( "*** Failed to read the header for %s.\n", fileName );
#		endif
		DVDClose( &audio_player.fileHandle );
		return FALSE;
	}

	strncpy( audio_player.fileName, fileName, 64 );
	audio_player.fileName[63]				= 0;

	// Nothing more to do here.
	return TRUE;
		
//	fileOffset += 32;
	
	// Check file id	
//	if( workChunk.id != VID_FCC('V','I','D','1' ))
//	{
//#		ifdef _DEBUG
//		OSReport("*** No VID1 file: '%s'\n", fileName);
//#		endif
//		DVDClose( &audio_player.fileHandle );
//		return FALSE;
//	}
	
	// Check for correct version of vid chunk.
	// If we find this version we assume a 'special' alignment and chunk ordering which may be invalid
	// in another version of the file format.
//	if( workChunk.vid.versionMajor != 1 || workChunk.vid.versionMinor != 0 )
//	{
//#		ifdef _DEBUG
//		OSReport("*** Unsupported file version: major: %d, minor: %d\n", workChunk.vid.versionMajor, workChunk.vid.versionMajor);
//#		endif
//		DVDClose(&audio_player.fileHandle);
//		return FALSE;
//	}
	
//#	ifdef _DEBUG
	// Sometimes, it's required to check for a special build of the VidConv converter.
//	{
//		u32 version = VID_VERSION(workChunk.vid.vidConvMajor, workChunk.vid.vidConvMinor, workChunk.vid.vidConvBuild);
//		if(version < VID_VERSION(1,0,1))
//		OSReport("*** WARNING: Vid file created using an unsupported converter version: %d.%d.%d\n", (u32)workChunk.vid.vidConvMajor, (u32)workChunk.vid.vidConvMinor, (u32)workChunk.vid.vidConvBuild);
//	}
//#	endif

	// Check types of chunks we have in this file.
	// !!! Note that we assume start of 'HEAD' chunk at byte offset 32 from file start !!!
//	if( DVDRead( &audio_player.fileHandle, &workChunk, 32, (s32)fileOffset ) < 0 )
//	{
//#		ifdef _DEBUG
//		OSReport("*** Failed to read 'HEAD' chunk.\n");
//#		endif
//		DVDClose( &audio_player.fileHandle );
//		return FALSE;
//	}
	
//	if( workChunk.id != VID_FCC('H','E','A','D' ))
//	{
//#		ifdef _DEBUG
//		OSReport("*** No HEAD chunk found at expected offset\n");
//#		endif
//		DVDClose(&audio_player.fileHandle);
//		return FALSE;
//	}
	
	// Calculate the start of the first frame chunk
	// (we know the header chunk starts at offset 32)
//	audio_player.nextFrameOffset = workChunk.len + 32;

	// Skip 'HEAD' chunk id, len and version fields
//	fileOffset += VID_CHUNK_HEADER_SIZE;
	
	// The header chunk contains one or more header chunks for the different data types contained
	// in the stream. Parse them all...
//	headSize = workChunk.len - VID_CHUNK_HEADER_SIZE;
//	while( headSize >= 32 )
//	{
//		if( DVDRead( &audio_player.fileHandle, &workChunk, 32, (s32)fileOffset ) < 0 )
//		{
//#			ifdef _DEBUG
//			OSReport("*** Error reading file at offset %d\n", fileOffset);
//#			endif
//			DVDClose(&audio_player.fileHandle);
//			return FALSE;
//		}
		
//		fileOffset += 32;
//		headSize -= 32;

		// We analyze the 1st 32 bytes of the chunk for a known header format
//		if(workChunk.id == VID_FCC('A','U','D','H'))
//		{
			// Allocate memory for audio header chunk
//			audio_player.audioHeaderChunk = (u8*)((*audio_player.cbAlloc)(workChunk.len));
//			audioInfoSize = workChunk.len - VID_CHUNK_HEADER_SIZE;
			
			// Copy the already loaded part
//			memcpy(audio_player.audioHeaderChunk, &workChunk, 32);
//			workChunk.len -= 32;
			
			// Read additional audio header bytes if the audio header is greater that 32 bytes
//			if(workChunk.len >= 32)
//			{
//				ASSERT((workChunk.len&31)==0);
//				if( DVDRead( &audio_player.fileHandle, audio_player.audioHeaderChunk + 32, workChunk.len, (s32)fileOffset ) < 0 )
//				{
//#					ifdef _DEBUG
//					OSReport("*** Error reading file at offset %d\n", fileOffset);
//#					endif
//					DVDClose(&audio_player.fileHandle);
//					return FALSE;
//				}
//				fileOffset += workChunk.len;
//				headSize -= workChunk.len;
//			}

			// Setup and calc the number of bytes which we are allowed to copy into the audioInfo struct
//			memcpy(&audio_player.audioInfo, audio_player.audioHeaderChunk+VID_CHUNK_HEADER_SIZE, MIN(audioInfoSize, sizeof(audio_player.audioInfo)));
//		}
//		else
//		{
//			// Skip unknown chunks. We already read 32 bytes for the header which we must subtract here.
//			fileOffset += workChunk.len - 32;
///			headSize -= workChunk.len - 32;
//		}
//	}
	
	// check if we have the correct vaud file version (>0)
//	if(audio_player.audioInfo.vaudex.version == 0)
//	{
//#		ifdef _DEBUG
//		OSReport("*** Invalid version in vaud file.");
//#		endif
//		DVDClose(&audio_player.fileHandle);
//		return FALSE;
//	}

	// we can only play audio files which have the following fiels set.
	// Note that in case of VIDEO files this fields are allowed to be 0.
//	ASSERT(audio_player.audioInfo.vaudex.maxBufferSize > 0);
//	ASSERT(audio_player.audioInfo.vaudex.frameCount > 0);
//	ASSERT(audio_player.audioInfo.vaudex.frameTimeMs > 0);
	
	// read beginning of 1st frame chunk to get required size information
//	if( DVDRead( &audio_player.fileHandle, &workChunk, 32 , (s32)audio_player.nextFrameOffset ) < 0 )
//	{
//#		ifdef _DEBUG
//		OSReport("*** Failed to read 'FRAM' chunk.\n");
//#		endif
//		DVDClose(&audio_player.fileHandle);
//		return FALSE;
//	}

//	if( workChunk.id != VID_FCC('F','R','A','M') )
//	{
//#		ifdef _DEBUG
//		OSReport("*** No FRAM chunk found.");
//#		endif
//		DVDClose(&audio_player.fileHandle);
//		return FALSE;
//	}

//	audio_player.nextFrameSize = workChunk.len; 		// 32 bytes of this chunk are already consumed, but we want to 'preload' the NEXT chunk's FRAM header
//	audio_player.nextFrameOffset += 32;
	
//	audio_player.firstFrameOffset = audio_player.nextFrameOffset;
//	audio_player.firstFrameSize   = audio_player.nextFrameSize;

//	strncpy(audio_player.fileName, fileName, 64);
//	audio_player.fileName[63] = 0;
	
//	audio_player.open 			 	= TRUE;

//	audio_player.readIndex 			= 0;
//	audio_player.decodeIndex 			= 0;
//	audio_player.lastDecodedFrame		= 0;
//	audio_player.error 			 	= FALSE;
//	audio_player.preFetchState 	 	= FALSE;
//	audio_player.loopMode			 	= FALSE;
//	audio_player.asyncDvdRunning		= FALSE;
//	audio_player.currentFrameCount 	= 0;
//	audio_player.readBufferBaseMem	= 0;

//	return TRUE;
} 	
示例#20
0
void dKPMusic::execute() {
	if (!s_playing)
		return;

	if (s_handle.GetSound() == 0) {
		nw4r::db::Exception_Printf_("SOUND IS NOT PLAYING!\n");
		return;
	}

	if (s_countdownToSwitch >= 0) {
		s_countdownToSwitch--;
		if (s_countdownToSwitch == 0) {
			nw4r::db::Exception_Printf_("Switching brstm files to song %d.\n", s_nextSong);

			char brstmPath[48];
			sprintf(brstmPath, "/Sound/new/map%d.er", s_nextSong);

			u8 *sound = (u8*)(s_handle.GetSound());
			u8 *player = sound+0x110;
			u8 **fileStreamPointer = (u8**)(player+0x808);
			u8 *fileStream = *fileStreamPointer;
			DVDHandle *fileInfo = (DVDHandle*)(fileStream+0x28);

			if (fileInfo->unk4 == 1) {
				OSReport("Was reading chunk, will try again next frame...\n");
				s_countdownToSwitch++;
				return;
			}

			if (s_nextSong > 0)
				s_countdownToFadeIn = BUFFER_CLEAR_DELAY;

			DVDCancel(fileInfo);
			//OSReport("CANCEL successfully called!\n");
			bool result = DVDFastOpen(DVDConvertPathToEntrynum(brstmPath), fileInfo);

			nw4r::db::Exception_Printf_("StrmSound is at %p, StrmPlayer is at %p, FileStream pointer is at %p, FileStream is at %p, FileInfo is at %p\n", sound, player, fileStreamPointer, fileStream, fileInfo);
			nw4r::db::Exception_Printf_("Changed to name %s. FastOpen returned: %d\n", brstmPath, result);

			u8 *trackArray = player+0xB58;
			u8 *track = (trackArray + (0x38 * 1));
			u8 **voicePointer = (u8**)(track+4);
			u8 *voice = *voicePointer;
			nw4r::db::Exception_Printf_("Track Array: %p; Track: %p; Voice Pointer: %p; Voice: %p\n", trackArray, track, voicePointer, voice);

			for (int i = 0; i < 2; i++) {
				int sourceBlockID = (s_nextSong*2)+i;
				u8 *sourceData = ((u8*)(s_adpcmInfoLoader.buffer)) + (0x30*sourceBlockID);
				nw4r::db::Exception_Printf_("Using ADPCM data for channel %d from block %d, data at %p\n", i, sourceBlockID, sourceData);

				if (!voice)
					continue;

				Voice_SetADPCMLoop(voice, i, sourceData+0x28);

				// loop through all axVoices
				for (int j = 0; j < 4; j++) {
					int axVoiceID = (i*4) + j;
					u8 **axVoicePointer = (u8**)(voice + 0xC + (axVoiceID*4));
					u8 *axVoice = *axVoicePointer;
					nw4r::db::Exception_Printf_("Setting AxVoice ID %d, with pointer at %p, located at %p\n", axVoiceID, axVoicePointer, axVoice);

					if (axVoice)
						AxVoice_SetADPCM(axVoice, sourceData);
				}
			}

			OSReport("All done\n");

			s_song = s_nextSong;
			s_nextSong = -1;
		}

	} else if (s_countdownToFadeIn >= 0) {
		s_countdownToFadeIn--;
		if (s_countdownToFadeIn == 0) {
			OSReport("Going to fade in the second track now!\n");
			if (s_handle.Exists())
				s_handle.SetTrackVolume(1<<1, FADE_IN_LEN, 1.0f);
		}
	}
}
示例#21
0
/*!
 ******************************************************************************
 * \brief
 *		Decode all frame data
 *
 *		This function operates on the full frame input data. It forwards this
 *		data to the required decoder.
 *
 ******************************************************************************
 */
BOOL AUDSimpleDecode(void)
{
	BOOL enabled;
	u8* chunkStart;
	u32 chunkSize;
	u32 frameSize;

	if( audio_player.readBuffer[audio_player.decodeIndex].valid )
	{
		
		// ptr to our (pre-) loaded data INSIDE (!) 'FRAM' chunk
		// (in other words, the 'FRAM' chunk itself is not visible here)
		chunkStart = audio_player.readBuffer[audio_player.decodeIndex].ptr;

		// usually, we read additional 32 bytes for getting info about the NEXT chunk.
		// We only deal with the actual 'FRAM' chunk data here and adjust the size by 32 bytes.
        frameSize = audio_player.readBuffer[audio_player.decodeIndex].size - 32;
		
		// loop across ALL chunks inside 'FRAM'
		while(frameSize >= 32)
		{
			chunkSize = VID_CHUNK_LEN(chunkStart);
			
			if( VID_CHUNK_ID(chunkStart) == VID_FCC('A','U','D','D') )
			{
				// Get the data to the audio system...
				if(! AUDSimpleAudioDecode(chunkStart + VID_CHUNK_HEADER_SIZE, chunkSize - VID_CHUNK_HEADER_SIZE))
				{
#ifdef _DEBUG
					OSReport("*** AUDSimpleAudioDecode failed!\n");
#endif
				}
			}
#ifdef _DEBUG
			else
			{
				OSReport("*** AUDSimpleDecode: unknown chunk type!\n");
			}
#endif
			
			// goto next chunk
			chunkStart += chunkSize;
			frameSize -= chunkSize;
		}
			
		audio_player.lastDecodedFrame = audio_player.readBuffer[audio_player.decodeIndex].frameNumber;
		audio_player.readBuffer[audio_player.decodeIndex].valid = FALSE;
		audio_player.decodeIndex = (audio_player.decodeIndex + 1) % AUD_NUM_READ_BUFFERS;

		// check if loading is still running
		enabled = OSDisableInterrupts();
		if (!audio_player.readBuffer[audio_player.readIndex].valid && !audio_player.asyncDvdRunning)
			ReadFrameAsync();
		OSRestoreInterrupts(enabled);
		
        return TRUE;
	}

#ifdef _DEBUG
	OSReport("*** AUDSimpleDecode: No valid decode buffer found (?).\n");
#endif
	return FALSE;

}
示例#22
0
int dWMShop_c::onCreate() {
	if (!layoutLoaded) {
		bool gotFile = layout.loadArc("shop.arc", false);
		if (!gotFile)
			return false;

		selected = 0;
		lastTopRowChoice = 0;

		layout.build("shop.brlyt");

		if (IsWideScreen()) {
			layout.layout.rootPane->scale.x = 0.735f;
		} else {
			layout.clippingEnabled = true;
			layout.clipX = 0;
			layout.clipY = 52;
			layout.clipWidth = 640;
			layout.clipHeight = 352;
			layout.layout.rootPane->scale.x = 0.731f;
			layout.layout.rootPane->scale.y = 0.7711f;
		}

		static const char *brlanNames[] = {
			"shop_Show.brlan",
			"shop_Hide.brlan",
			"shop_ActivateButton.brlan",
			"shop_DeactivateButton.brlan",
			"shop_CountCoin.brlan"
		};
		static const char *groupNames[] = {
			"BaseGroup", "BaseGroup",
			"GBtn00", "GBtn01", "GBtn02", "GBtn03", "GBtn1", "GBtn2",
			"GBtn00", "GBtn01", "GBtn02", "GBtn03", "GBtn1", "GBtn2",
			"GCoinCount"
		};
		static const int brlanIDs[] = {
			0, 1,
			2, 2, 2, 2, 2, 2,
			3, 3, 3, 3, 3, 3,
			4,
		};

		layout.loadAnimations(brlanNames, 5);
		layout.loadGroups(groupNames, brlanIDs, 15);
		layout.disableAllAnimations();

		layout.drawOrder = 1;

		static const char *tbNames[] = {
			"Title", "TitleShadow",
			"CoinCount", "CoinCountShadow",
			"BackText", "BuyText",
		};
		layout.getTextBoxes(tbNames, &Title, 6);

		// Warning: weird code coming up
		const char *crap = "000102031\0" "2\0";
		char name[12];
		for (int i = 0; i < 6; i++) {
			strcpy(name, "BtnLeftXX");
			name[7] = crap[i*2];
			name[8] = crap[i*2+1];
			BtnLeft[i] = layout.findPictureByName(name);

			strcpy(name, "BtnMidXX");
			name[6] = crap[i*2];
			name[7] = crap[i*2+1];
			BtnMid[i] = layout.findPictureByName(name);

			strcpy(name, "BtnRightXX");
			name[8] = crap[i*2];
			name[9] = crap[i*2+1];
			BtnRight[i] = layout.findPictureByName(name);

			strcpy(name, "BtnXX");
			name[3] = crap[i*2];
			name[4] = crap[i*2+1];
			Buttons[i] = layout.findPaneByName(name);
		}

		Btn1Base = layout.findPaneByName("Btn1_Base");
		Btn2Base = layout.findPaneByName("Btn2_Base");
		OSReport("Found btn 1,2: %p, %p\n", Btn1Base, Btn2Base);

		leftCol.setTexMap(BtnLeft[0]->material->texMaps);
		midCol.setTexMap(BtnMid[0]->material->texMaps);
		rightCol.setTexMap(BtnRight[0]->material->texMaps);

		for (int i = 1; i < 6; i++) {
			leftCol.applyAlso(BtnLeft[i]->material->texMaps);
			midCol.applyAlso(BtnMid[i]->material->texMaps);
			rightCol.applyAlso(BtnRight[i]->material->texMaps);
		}

		layoutLoaded = true;
	}

	return true;
}
示例#23
0
/*!
 ******************************************************************************
 * \brief
 *		Main audio data decode function.
 *
 *		This function will be used as a callback from the VIDAudioDecode
 *		function or is called directely in case of PCM or ADPCM.
 *
 * \param numChannels
 *		Number of channels present in the sample array
 *
 * \param samples
 *		Array of s16 pointers to the sample data
 *
 * \param sampleNum
 *		Number of samples in the array. All arrays have the same amount
 *		of sample data
 *
 * \param userData
 *		Some user data
 *
 * \return
 *		FALSE if data could not be interpreted properly
 *
 ******************************************************************************
 */
static BOOL audioDecode(u32 numChannels, const s16 **samples, u32 sampleNum, void* _UNUSED(userData))
	{
	u32	 freeSamples;
	u32	 sampleSize;
	u32	 len1;
	BOOL old;
	
	// we can only play mono or stereo!
	ASSERT(numChannels <= 2);

	// Disable IRQs. We must make sure we don't get interrupted by the AI callback.
	old = OSDisableInterrupts();

	// Did the video decoder just jump back to the beginning of the stream?
	if (audio_player.readBuffer[audio_player.decodeIndex].frameNumber < audio_player.lastDecodedFrame)
		{
		// Yes! We have to reset the internal read buffer and disable any audio output
		// until we got new video data to display...
		//
		// Note: we have to reset our buffers because the stream contains more audio data than
		// neccessary to cover a single video frame within the first few frames to accumulate
		// some safety buffer. If the stream would just be allowed to loop we would get an
		// overflow (unless we used up the extra buffer due to read / decode delays) after a few
		// loops...
		//
		AUDSimpleAudioReset();
		}

	// Calculate the read buffer's sample size
	sampleSize = sizeof(s16) * audioReadBufferNumChannels;

	// How many samples could we put into the buffer?
	if (audioReadBufferWritePos >= audioReadBufferReadPos)
	{
		freeSamples = audioReadBufferNumSamples - (audioReadBufferWritePos - audioReadBufferReadPos);

		if( freeSamples < sampleNum )
		{
			OSRestoreInterrupts(old);
			#ifndef FINAL
			OSReport("*** audioDecode: overflow case 1\n");
			#endif
			return FALSE;				// overflow!
		}

		// We might have a two buffer update to do. Check for it...
		if ((len1 = (audioReadBufferNumSamples - audioReadBufferWritePos)) >= sampleNum)
		{
			// No. We got ourselfs a nice, simple single buffer update.
			writeChannelData((s16 *)((u32)audioReadBuffer + audioReadBufferWritePos * sampleSize),numChannels,samples,0,sampleNum);
		}
		else
		{
			// Dual buffer case
			writeChannelData((s16 *)((u32)audioReadBuffer + audioReadBufferWritePos * sampleSize),numChannels,samples,0,len1);
            writeChannelData((s16 *)audioReadBuffer,numChannels,samples,len1,sampleNum-len1);
		}
	}
	else
	{
		freeSamples = audioReadBufferReadPos - audioReadBufferWritePos;

		if (freeSamples < sampleNum)
		{
			OSRestoreInterrupts(old);
			#ifndef FINAL
			OSReport("*** audioDecode: overflow case 2\n");
			#endif
			return FALSE;				// overflow!
		}

		// We're save to assume to have a single buffer update in any case...
		writeChannelData((s16 *)((u32)audioReadBuffer + audioReadBufferWritePos * sampleSize),numChannels,samples,0,sampleNum);
	}

	// Advance write position...
	audioReadBufferWritePos += sampleNum;

	if (audioReadBufferWritePos >= audioReadBufferNumSamples)
		audioReadBufferWritePos -= audioReadBufferNumSamples;

	// We're done with all critical stuff. IRQs may be enabled again...
	OSRestoreInterrupts(old);

	return TRUE;
	}
示例#24
0
void CInputDeviceWii::Input_Poll()
{
	mConnectionStatus = CONN_STATUS_ACTIVE;

	MCheckPointContext( "CInputDeviceWii::Input_Poll" );

	InputState& inpstate = RefInputState();
	inpstate.BeginCycle();

	s32 status;
    u32 type;
    u32 index;


/*
	ork::FileProgressWatcher *fw =  ork::CFileEnv::GetRef().GetDefaultDevice()->GetWatcher();
	if(fw) {
		fw->SetEnable( true);
		fw->Reading( 0, 1 );
		fw->SetEnable( false);
	}
*/
	//

	/*
	PADRead( padsTmp ) ;
	if ( padsTmp[ 0 ].err == PAD_ERR_NONE ) {
	pads[ 0 ] = padsTmp[ 0 ] ;
	}
	padsTrig[ 0 ].button = (u16)( (padsTrig[ 0 ].button ^ pads[ 0 ].button) & pads[ 0 ].button ) ;
	 */
	for( orkmap<int,int>::const_iterator it= mInputMap.begin(); it!=mInputMap.end(); it++ )
	{
		std::pair<int,int> Value = *it;
		int ikey = Value.first;
		int iout = Value.second;
		inpstate.SetPressure( iout, 0 );
	}

	KPADDisableStickCrossClamp() ;
	KPADDisableDPD(m_channel);




	if (WPADProbe(m_channel, NULL) == WPAD_ERR_NO_CONTROLLER) {

		if(mdisconnectframe == 10)
			inpstate.SetPressure( ETRIG_RAW_DISCONNECT, 127);
		else
			mdisconnectframe++;

		inpstate.EndCycle();
		return;
	}

	mkpad_reads = KPADRead( m_channel, &mkpad[0], KPAD_MAX_READ_BUFS ) ;
//For some reason when you reconnect you have your state in there yuck!
    if(mdisconnectframe) {
		mdisconnectframe = 0;
		for (int i=0;i< KPAD_MAX_READ_BUFS;i++)
			mkpad[i].hold = 0;
		inpstate.EndCycle();
		return;
	}

	for( orkmap<int,int>::const_iterator it=mInputMap.begin(); it!=mInputMap.end(); it++ )
	{
		std::pair<int,int> Value = *it;
		int ikey = Value.first;
		int iout = Value.second;

		bool bkey = mkpad[0].hold & ikey ;

		if ( bkey)
		{
			if(mkpad[0].dev_type != WPAD_DEV_FREESTYLE)
			{
				U32 outrotated = iout;


				switch( iout )
				{
					case ETRIG_RAW_JOY0_LDIG_LEFT:
						outrotated = ETRIG_RAW_JOY0_LDIG_DOWN;
						break;
					case ETRIG_RAW_JOY0_LDIG_RIGHT:
						outrotated = ETRIG_RAW_JOY0_LDIG_UP;
						break;
					case ETRIG_RAW_JOY0_LDIG_DOWN:
						outrotated = ETRIG_RAW_JOY0_LDIG_RIGHT;
						break;
					case ETRIG_RAW_JOY0_LDIG_UP:
						outrotated = ETRIG_RAW_JOY0_LDIG_LEFT;
						break;
					//default:

				}
				inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_XAXIS, 0.0f);
				inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_YAXIS, 0.0f);

				inpstate.SetPressure( outrotated, 127);

				if(outrotated == 144)
					OSReport("IP: %x\n",(void *) &inpstate);

			}
			else
			{
				inpstate.SetPressure( iout, 127);
			}
		}

		if((mkpad[0].wpad_err == WPAD_ERR_NONE))
		{
			if(mkpad[0].dev_type == WPAD_DEV_FREESTYLE)
			{
				#define BOOL_TO_S8(v)		(S8)((v) ? 127 : 0)
				#define F32NORM_TO_S8(v)	(S8)((v) * 127.0f)

				S8 rdown = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_DOWN);
				S8 rup = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_UP);
				S8 rleft = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_LEFT);
				S8 rright = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_RIGHT);

				inpstate.SetPressure(ETRIG_RAW_JOY0_RDIG_DOWN, rdown);
				inpstate.SetPressure(ETRIG_RAW_JOY0_RDIG_UP, rup);
				inpstate.SetPressure(ETRIG_RAW_JOY0_RDIG_LEFT, rleft);
				inpstate.SetPressure(ETRIG_RAW_JOY0_RDIG_RIGHT, rright);

				S8 lthumbX = F32NORM_TO_S8(mkpad[0].ex_status.fs.stick.x);
				S8 lthumbY = F32NORM_TO_S8(mkpad[0].ex_status.fs.stick.y);

				inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_XAXIS, lthumbX);
				inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_YAXIS, lthumbY);

				S8 bA = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_A);
				S8 bB = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_B);
				S8 b1 = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_1);
				S8 b2 = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_2);

				inpstate.SetPressure(ETRIG_RAW_ALPHA_A, bA);
				inpstate.SetPressure(ETRIG_RAW_ALPHA_B, bB);
				inpstate.SetPressure(ETRIG_RAW_NUMBER_1, b1);
				inpstate.SetPressure(ETRIG_RAW_NUMBER_2, b2);

				S8 bPLUS = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_PLUS);
				S8 bMINUS = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_MINUS);

				inpstate.SetPressure(ETRIG_RAW_KEY_PLUS, bPLUS);
				inpstate.SetPressure(ETRIG_RAW_KEY_MINUS, bMINUS);

				S8 bC = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_C);
				S8 bZ = BOOL_TO_S8(mkpad[0].hold & KPAD_BUTTON_Z);
				
				inpstate.SetPressure(ETRIG_RAW_ALPHA_C, bC);
				inpstate.SetPressure(ETRIG_RAW_ALPHA_Z, bZ);

#if 0
				static int accum = 0;
				accum++;
				if(accum >= 128)
				{
					accum = 0;
					orkprintf("rleft<%d> rright<%d> rup<%d> rdown<%d>\n", int(rleft), int(rright), int(rup), int(rdown));
					orkprintf("lthumbX<%d> lthumbY<%d>\n", int(lthumbX), int(lthumbY));
					orkprintf("A<%d> B<%d> 1<%d> 2<%d>\n", int(bA), int(bB), int(b1), int(b2));
					orkprintf("+<%d> -<%d>\n", int(bPLUS), int(bMINUS));
					orkprintf("C<%d> Z<%d>\n", int(bC), int(bZ));
				}
#endif
			}
			else if (mkpad[0].dev_type == WPAD_DEV_CLASSIC)
			{
				F32 zaxis = 0.0f;
				/////////////////////////////////////////////////////
				// Make the 2 triggers behave like the crappy 360 PC controller
				if(mkpad[0].ex_status.cl.rtrigger >= 0.1f)
					zaxis += mkpad[0].ex_status.cl.rtrigger;
				if(mkpad[0].ex_status.cl.ltrigger >= 0.1f)
					zaxis -= mkpad[0].ex_status.cl.ltrigger;

				inpstate.SetPressure(ETRIG_RAW_JOY0_ANA_ZAXIS, zaxis * 127.0f);


				/////////////////////////////////////////////////////
				inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_XAXIS, mkpad[0].ex_status.cl.lstick.x * 127.0f);
				inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_YAXIS, -mkpad[0].ex_status.cl.lstick.y * 127.0f);

				inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_XAXIS, mkpad[0].ex_status.cl.rstick.x * 127.0f);
				inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_YAXIS, -mkpad[0].ex_status.cl.rstick.y * 127.0f);

				/////////////////////////////////////////////////////
				if(mkpad[0].ex_status.cl.lstick.y >= 0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_UP, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_UP, 0.0f);

				if(mkpad[0].ex_status.cl.lstick.y <= -0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_DOWN, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_DOWN, 0.0f);

				if(mkpad[0].ex_status.cl.lstick.x <= -0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_LEFT, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_LEFT, 0.0f);

				if(mkpad[0].ex_status.cl.lstick.y >= 0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_RIGHT, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_LANA_RIGHT, 0.0f);

				/////////////////////////////////////////////////////
/*
				if(mkpad[0].ex_status.cl.rstick.y >= 0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_UP, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_UP, 0.0f);

				if(mkpad[0].ex_status.cl.rstick.y <= -0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_DOWN, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_DOWN, 0.0f);

				if(mkpad[0].ex_status.cl.rstick.x <= -0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_LEFT, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_LEFT, 0.0f);

				if(mkpad[0].ex_status.cl.rstick.y >= 0.8f)
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_RIGHT, 127.0f);
				else
					inpstate.SetPressure(ETRIG_RAW_JOY0_RANA_RIGHT, 0.0f);

  */

			}





		}
	}

	inpstate.EndCycle();

	return;
}