コード例 #1
0
ファイル: main.c プロジェクト: edwinchoate/off-season
void lose() {

	REG_DISPCTL = MODE4 | BG2_ENABLE;

	loadPalette(gameover_screenPal);

	drawBackgroundImage4(gameover_screenBitmap);

	while (1) {

		oldButtons = buttons;
		buttons = BUTTONS;

		if (BUTTON_PRESSED(BUTTON_A)) {

			init();
			setupLevel();

			state = GAME;
			return;
		}

		if (BUTTON_PRESSED(BUTTON_SELECT)) {

			playSoundB(menuSound, MENUSOUNDLEN, MENUSOUNDFREQ, 0);

			playSoundA(titleSong, TITLESONGLEN, TITLESONGFREQ, 1);

			state = SPLASH;
			return;
		}

	}

}
コード例 #2
0
ファイル: main.c プロジェクト: edwinchoate/off-season
void pause() {



	while (1) {

		oldButtons = buttons;
		buttons = BUTTONS;

		if (BUTTON_PRESSED(BUTTON_START)) {

			REG_DISPCTL ^= BG0_ENABLE;
			unpauseSound();
			state = GAME;
			return;
		}

		if (BUTTON_PRESSED(BUTTON_SELECT)) {

			REG_DISPCTL ^= BG0_ENABLE;

			unpauseSound();

			playSoundA(titleSong, TITLESONGLEN, TITLESONGFREQ, 1);

			state = SPLASH;
			return;
		}

	}

}
コード例 #3
0
ファイル: sound.c プロジェクト: johncaseysmith/KungFuLeahy
void interruptHandler()
{
	REG_IME = 0;

	if(REG_IF & INT_VBLANK)
	{

		// MODIFY THIS FUNCTION !!!
		// Add code to stop/repeat sounds here
                vbCountA++;
                if (vbCountA >= soundA.duration) {
                    REG_TM0CNT = 0;
                    dma[1].cnt = 0;
                    if (soundA.loops)
                        playSoundA(soundA.data, soundA.length, soundA.frequency, soundA.loops);
                }
                
                vbCountB++;
                if (vbCountB >= soundB.duration) {
                    REG_TM1CNT = 0;
                    dma[2].cnt = 0;
                    if (soundB.loops)
                        playSoundB(soundB.data, soundB.length, soundB.frequency, soundB.loops);
                }

		REG_IF = INT_VBLANK; 
	}

	REG_IME = 1;
}
コード例 #4
0
ファイル: main.c プロジェクト: edwinchoate/off-season
void winLevel() {

	REG_DISPCTL = MODE4 | BG2_ENABLE;

	loadPalette(win_level_screenPal);

	drawBackgroundImage4(win_level_screenBitmap);

	while (1) {

		oldButtons = buttons;
		buttons = BUTTONS;

		if (BUTTON_PRESSED(BUTTON_A)) {

			if (currentLevel + 1 <= NUMLEVELS) {

				currentLevel++;
				init();
				setupLevel();

				state = GAME;
			}
			else {
				state = GAMEEND;
			}
			
			return;
		}

		if (BUTTON_PRESSED(BUTTON_SELECT)) {

			playSoundB(menuSound, MENUSOUNDLEN, MENUSOUNDFREQ, 0);

			playSoundA(titleSong, TITLESONGLEN, TITLESONGFREQ, 1);

			state = SPLASH;
			return;
		}

	}

}
コード例 #5
0
ファイル: main.c プロジェクト: edwinchoate/off-season
void interruptHandler() {
    REG_IME = 0;
    if(REG_IF & INT_VBLANK)
    {

                if (soundA.isPlaying && vbCountA < soundA.duration) { // Continue vbCount until duration is reached
                    vbCountA++;
                }
                // loop soundA
                else if (!soundA.isPlaying && soundA.loops) {
                    playSoundA(soundA.data, soundA.length, soundA.frequency, soundA.loops);
                }
                else { // stop soundA
                    soundA.isPlaying = 0;
                    vbCountA = 0;
                    REG_TM0CNT = 0;
                    dma[1].cnt = 0;
                }

                if (soundB.isPlaying && vbCountB < soundB.duration) {
                    vbCountB++;
                }
                // loop soundB
                else if (!soundB.isPlaying && soundB.loops) {
                    playSoundB(soundB.data, soundB.length, soundB.frequency, soundB.loops);
                }
                else { // stop soundB
                    soundB.isPlaying = 0;
                    vbCountB = 0;
                    REG_TM1CNT = 0;
                    dma[2].cnt = 0;
                }

                

        REG_IF = INT_VBLANK; 
    }

    REG_IME = 1;
}
コード例 #6
0
ファイル: sound.c プロジェクト: DuqueKarl/Thief-of-Bagdad
void interruptHandler()
{
	REG_IME = 0;

	if(REG_IF & INT_VBLANK) {
		// MODIFY THIS FUNCTION !!!
		// Add code to stop/repeat sounds here
                vbCountA++; 
                if(vbCountA>=soundA.duration){
                    REG_TM0CNT = 0; 
                    dma[1].cnt = 0; 
                    
                    if(soundA.loops) {
                        playSoundA(soundA.data, soundA.length, soundA.frequency, soundA.loops);
                    } else {
                        soundA.isPlaying = false;
                    }
                }
                
                vbCountB++; 
                if(vbCountB>=soundB.duration){
                    REG_TM1CNT = 0; 
                    dma[2].cnt = 0; 
                    
                    if(soundB.loops && soundB.isPlaying) {
                        playSoundB(soundB.data, soundB.length, soundB.frequency, soundB.loops);
                    } else {
                        soundB.isPlaying = false;
                    }
                }
                
		REG_IF = INT_VBLANK; 
	}
        // (╯°□°)╯︵ ┻━┻ 
        // ┬──┬ ノ( ゜-゜ノ)
	REG_IME = 1;
}
コード例 #7
0
ファイル: main.c プロジェクト: edwinchoate/off-season
void splash() {

	REG_DISPCTL = MODE4 | BG2_ENABLE;

	loadPalette(splash_screenPal);

	drawBackgroundImage4(splash_screenBitmap);

	while (1) {

		oldButtons = buttons;
		buttons = BUTTONS;

		if (BUTTON_PRESSED(BUTTON_START)) {

			init();
			setupGame();

			playSoundA(gameSong, GAMESONGLEN, GAMESONGFREQ, 1);
			playSoundB(menuSound, MENUSOUNDLEN, MENUSOUNDFREQ, 0);

			state = GAME;
			return;
		}

		if (BUTTON_PRESSED(BUTTON_SELECT)) {

			playSoundB(menuSound, MENUSOUNDLEN, MENUSOUNDFREQ, 0);

			state = INSTRUCTIONS;
			return;
		}

	}

}
コード例 #8
0
ファイル: main.c プロジェクト: edwinchoate/off-season
int main() {

	setupInterrupts();
    setupSounds();

    playSoundA(titleSong, TITLESONGLEN, TITLESONGFREQ, 1);

	// Start game with splash screen
	splash();


	// Main Game Loop
	while (1) {

		oldButtons = buttons;
		buttons = BUTTONS;

		// Update player row and column
		player.bigRow = player.row + vOff;
		player.bigCol = player.col + hOff;


		switch(state) {

			case SPLASH:

				// Displays splash screen
				splash();

			break;

			case INSTRUCTIONS:

				instructions();

			break;

			case GAME:

				// Game Function holds all game logic
				game();

			break;

			case SEASONCHANGE:
				
				// Warp-like animation as player changes between seasons
				warpAnimation();

				// Change game to correct season, based on prevSeason and return to gameplay
				if (vBlankCount < 1) {
					seasonChange();
					state = GAME;
				}

			break;

			case PAUSE:

				pause();

			break;

			case LOSE:

				lose();

			break;

			case WINLEVEL:

				winLevel();

			break;

			case GAMEEND:

				gameEnd();

			break;

		}

		
		// Shadow OAM Handling
		// Player Sprite
		shadowOAM[0].attr0 = (ROWMASK & player.row) | ATTR0_SQUARE;
		shadowOAM[0].attr1 = (COLMASK & player.col) | ATTR1_SIZE16 | (ATTR1_HFLIP & (player.facing << 12));
		shadowOAM[0].attr2 = (SPRITEOFFSET16(season * 2, player.currentFrame * 2)) | ATTR2_PRIORITY2;	

		// Season Icon Sprite
		shadowOAM[1].attr0 = (ROWMASK & icon.row) | ATTR0_SQUARE;
		shadowOAM[1].attr1 = (COLMASK & icon.col) | ATTR1_SIZE16;
		shadowOAM[1].attr2 = (SPRITEOFFSET16(season * 2, 6)) | (1 << 10); // Priority 1

		REG_BG2HOFS = hOff;
        REG_BG2VOFS = vOff;

       	// Set BG1 offsets - used for snow and falling leaves
		REG_BG1HOFS = bg1HOff;
		REG_BG1VOFS = bg1VOff;
        
        //Copy the shadowOAM into the OAM
        DMANow(3, &shadowOAM, OAM, 512);

		waitForVblank();

	}

	return 0;
}