示例#1
0
void playLevelMusic()
{
    int m=tmpscr->screen_midi;
    
    switch(m)
    {
    case -2:
        music_stop();
        break;
        
    case -1:
        play_DmapMusic();
        break;
        
    case 1:
        jukebox(ZC_MIDI_OVERWORLD);
        break;
        
    case 2:
        jukebox(ZC_MIDI_DUNGEON);
        break;
        
    case 3:
        jukebox(ZC_MIDI_LEVEL9);
        break;
        
    default:
        if(m>=4 && m<4+MAXCUSTOMMIDIS)
            jukebox(m-4+ZC_MIDI_COUNT);
        else
            music_stop();
    }
}
示例#2
0
void GetTriforce::activate()
{
    //get rid off all sprites but Link
    guys.clear();
    items.clear();
    Ewpns.clear();
    Lwpns.clear();
    Sitems.clear();
    chainlinks.clear();
    
    //decorations.clear();
    if(!COOLSCROLL)
        show_subscreen_items=false;
    
    sfx(itemsbuf[triforceID].playsound);
    music_stop();
    
    if(itemsbuf[triforceID].misc1)
        jukebox(itemsbuf[triforceID].misc1+ZC_MIDI_COUNT-1);
    else
        try_zcmusic((char*)"zelda.nsf",5, ZC_MIDI_TRIFORCE);
        
    if(itemsbuf[triforceID].flags & ITEM_GAMEDATA)
        game->lvlitems[dlevel]|=liTRIFORCE;
}
示例#3
0
void jukebox(int index)
{
    if(index<0)         index=MAXMIDIS-1;
    
    if(index>=MAXMIDIS) index=0;
    
    // do nothing if it's already playing
    if(index==currmidi && midi_pos>=0)
    {
        midi_paused=false;
        return;
    }
    
    jukebox(index,tunes[index].loop);
}
示例#4
0
// Run an NSF, or a MIDI if the NSF is missing somehow.
bool try_zcmusic(char *filename, int track, int midi)
{
    ZCMUSIC *newzcmusic = NULL;
    
    // Try the ZC directory first
    {
        char exepath[2048];
        char musicpath[2048];
        get_executable_name(exepath, 2048);
        replace_filename(musicpath, exepath, filename, 2048);
        newzcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath);
    }
    
    // Not in ZC directory, try the quest directory
    if(newzcmusic==NULL)
    {
        char musicpath[2048];
        replace_filename(musicpath, qstpath, filename, 2048);
        newzcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath);
    }
    
    // Found it
    if(newzcmusic!=NULL)
    {
        zcmusic_stop(zcmusic);
        zcmusic_unload_file(zcmusic);
        stop_midi();
        
        zcmusic=newzcmusic;
        zcmusic_play(zcmusic, emusic_volume);
        
        if(track>0)
            zcmusic_change_track(zcmusic,track);
            
        return true;
    }
    
    // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
    else if(midi>-1000)
        jukebox(midi);
        
    return false;
}
示例#5
0
void opentyrian_menu( void )
{
	static const char *menu_items[] =
	{
		"About OpenTyrian",
		"Toggle Fullscreen",
		"Scaler: None",
		// "Play Destruct",
		"Jukebox",
		"Return to Main Menu",
	};
	bool menu_items_disabled[] =
	{
		false,
		!can_init_any_scaler(false) || !can_init_any_scaler(true),
		false,
		// false,
		false,
		false,
	};
	
	fade_black(10);
	JE_loadPic(VGAScreen, 13, false);

	draw_font_hv(VGAScreen, VGAScreen->w / 2, 5, opentyrian_str, large_font, centered, 15, -3);

	memcpy(VGAScreen2->pixels, VGAScreen->pixels, VGAScreen2->pitch * VGAScreen2->h);

	JE_showVGA();

	play_song(36); // A Field for Mag

	int sel = 0;
	const int maxSel = COUNTOF(menu_items) - 1;

	uint32_t temp_scaler = scaler;

	bool fade_in = true, quit = false;
	do
	{
		memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);

		for (int i = 0; i <= maxSel; i++)
		{
			const char *text = menu_items[i];
			char buffer[100];

			if (i == 2) /* Scaler */
			{
				snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
				text = buffer;
			}

			int y = i != maxSel ? i * 16 + 32 : 118;
			draw_font_hv(VGAScreen, VGAScreen->w / 2, y, text, normal_font, centered, 15, menu_items_disabled[i] ? -8 : i != sel ? -4 : -2);
		}

		JE_showVGA();

		if (fade_in)
		{
			fade_in = false;
			fade_palette(colors, 20, 0, 255);
			wait_noinput(true, false, false);
		}

		tempW = 0;
		JE_textMenuWait(&tempW, false);

		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				do
				{
					if (--sel < 0)
						sel = maxSel;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
			case SDLK_DOWN:
				do
				{
					if (++sel > maxSel)
						sel = 0;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
				
			case SDLK_LEFT:
				if (sel == 2)
				{
					do
					{
						if (temp_scaler == 0)
							temp_scaler = scalers_count;
						temp_scaler--;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
			case SDLK_RIGHT:
				if (sel == 2)
				{
					do
					{
						temp_scaler++;
						if (temp_scaler == scalers_count)
							temp_scaler = 0;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
				
			case SDLK_RETURN:
				switch (sel)
				{
				case 0: /* About */
					JE_playSampleNum(S_SELECT);

					scroller_sine(about_text);

					memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case 1: /* Fullscreen */
					JE_playSampleNum(S_SELECT);

					if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
						!init_any_scaler(!fullscreen_enabled) &&     // try any scaler in new fullscreen state
						!init_scaler(scaler, fullscreen_enabled))    // revert on fail
					{
						exit(EXIT_FAILURE);
					}
					set_palette(colors, 0, 255); // for switching between 8 bpp scalers
					break;
					
				case 2: /* Scaler */
					JE_playSampleNum(S_SELECT);

					if (scaler != temp_scaler)
					{
						if (!init_scaler(temp_scaler, fullscreen_enabled) &&   // try new scaler
							!init_scaler(temp_scaler, !fullscreen_enabled) &&  // try other fullscreen state
							!init_scaler(scaler, fullscreen_enabled))          // revert on fail
						{
							exit(EXIT_FAILURE);
						}
						set_palette(colors, 0, 255); // for switching between 8 bpp scalers
					}
					break;
					
				case 3: /* Jukebox */
					JE_playSampleNum(S_SELECT);

					fade_black(10);
					jukebox();

					memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case 4: /* Return to main menu */
					quit = true;
					JE_playSampleNum(S_SPRING);
					break;
				}
				break;
				
			case SDLK_ESCAPE:
				quit = true;
				JE_playSampleNum(S_SPRING);
				break;
				
			default:
				break;
			}
		}
	} while (!quit);
}
示例#6
0
void GanonIntro::update()
{
    /*
    ************************
    * GANON INTRO SEQUENCE *
    ************************
    -25 DOT updates
    -24 LINK in
    0 TRIFORCE overhead - code begins at this point (counter == 0)
    47 GANON in
    58 LIGHT step
    68 LIGHT step
    78 LIGHT step
    255 TRIFORCE out
    256 TRIFORCE in
    270 TRIFORCE out
    271 GANON out, LINK face up
    */
    
    if(counter==47)
    {
        music_stop();
        stop_sfx(WAV_ROAR);
        sfx(WAV_GASP);
        sfx(WAV_GANON);
        int Id=0;
        
        for(int i=0; i<eMAXGUYS; i++)
        {
            if(guysbuf[i].flags2&eneflag_ganon)
            {
                Id=i;
                break;
            }
        }
        
        if(current_item(itype_ring))
            addenemy(160,96,Id,0);
        else
            addenemy(80,32,Id,0);
    }
    
    else if(counter==48)
    {
        lighting(true,true); // Hmm. -L
        counter += 30;
    }
    
    //NES Z1, the triforce vanishes for one frame in two cases
    //while still showing Link's two-handed overhead sprite.
    else if(counter==255 || counter==270)
        link.setHeldItem(-1);
    
    else if(counter==256)
        link.setHeldItem(getItemID(itemsbuf,itype_triforcepiece,1));
    
    counter++;
    if(counter<271)
        return;
    
    link.setAction(none);
    link.dir=up;
    
    if(!getmapflag() && (tunes[MAXMIDIS-1].data))
        jukebox(MAXMIDIS-1);
    else
        playLevelMusic();
        
    currcset=DMaps[currdmap].color;
    showCurrentDMapIntro();
    cont_sfx(WAV_ROAR);
    finish();
}
示例#7
0
void opentyrian_menu( void )
{
	typedef enum
	{
		MENU_ABOUT = 0,
		MENU_FULLSCREEN,
		MENU_SCALER,
		// MENU_DESTRUCT,
		MENU_JUKEBOX,
		MENU_RETURN,
		MenuOptions_MAX
	} MenuOptions;

	static const char *menu_items[] =
	{
		"About OpenTyrian",
		"Toggle Fullscreen",
		"Scaler: None",
		// "Play Destruct",
		"Jukebox",
		"Return to Main Menu",
	};
	bool menu_items_disabled[] =
	{
		false,
		!can_init_any_scaler(false) || !can_init_any_scaler(true),
		false,
		// false,
		false,
		false,
	};
	
	assert(COUNTOF(menu_items) == MenuOptions_MAX);
	assert(COUNTOF(menu_items_disabled) == MenuOptions_MAX);

	fade_black(10);
	JE_loadPic(VGAScreen, 13, false);

	draw_font_hv(VGAScreen, VGAScreen->surf->w / 2, 5, opentyrian_str, large_font, centered, 15, -3);

	memcpy(VGAScreen2->surf->pixels, VGAScreen->surf->pixels, VGAScreen2->surf->pitch * VGAScreen2->surf->h);

	JE_showVGA();

	play_song(36); // A Field for Mag

	MenuOptions sel = 0;

	uint temp_scaler = scaler;

	bool fade_in = true, quit = false;
	do
	{
		memcpy(VGAScreen->surf->pixels, VGAScreen2->surf->pixels, VGAScreen->surf->pitch * VGAScreen->surf->h);

		for (MenuOptions i = 0; i < MenuOptions_MAX; i++)
		{
			const char *text = menu_items[i];
			char buffer[100];

			if (i == MENU_SCALER)
			{
				snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
				text = buffer;
			}

			int y = i != MENU_RETURN ? i * 16 + 32 : 118;
			draw_font_hv(VGAScreen, VGAScreen->surf->w / 2, y, text, normal_font, centered, 15, menu_items_disabled[i] ? -8 : i != sel ? -4 : -2);
		}

		JE_showVGA();

		if (fade_in)
		{
			fade_in = false;
			fade_palette(colors, 20, 0, 255);
			wait_noinput(true, false, false);
		}

		tempW = 0;
		JE_textMenuWait(&tempW, false);

		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				do
				{
					if (sel-- == 0)
						sel = MenuOptions_MAX - 1;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
			case SDLK_DOWN:
				do
				{
					if (++sel >= MenuOptions_MAX)
						sel = 0;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
				
			case SDLK_LEFT:
				if (sel == MENU_SCALER)
				{
					do
					{
						if (temp_scaler == 0)
							temp_scaler = scalers_count;
						temp_scaler--;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
			case SDLK_RIGHT:
				if (sel == MENU_SCALER)
				{
					do
					{
						temp_scaler++;
						if (temp_scaler == scalers_count)
							temp_scaler = 0;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
				
			case SDLK_RETURN:
				switch (sel)
				{
				case MENU_ABOUT:
					JE_playSampleNum(S_SELECT);

					scroller_sine(about_text);

					memcpy(VGAScreen->surf->pixels, VGAScreen2->surf->pixels, VGAScreen->surf->pitch * VGAScreen->surf->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case MENU_FULLSCREEN:
					JE_playSampleNum(S_SELECT);

					if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
						!init_any_scaler(!fullscreen_enabled) &&     // try any scaler in new fullscreen state
						!init_scaler(scaler, fullscreen_enabled))    // revert on fail
					{
						exit(EXIT_FAILURE);
					}
					break;
					
				case MENU_SCALER:
					JE_playSampleNum(S_SELECT);

					if (scaler != temp_scaler)
					{
						if (!init_scaler(temp_scaler, fullscreen_enabled) &&   // try new scaler
							!init_scaler(temp_scaler, !fullscreen_enabled) &&  // try other fullscreen state
							!init_scaler(scaler, fullscreen_enabled))          // revert on fail
						{
							exit(EXIT_FAILURE);
						}
					}
					break;
					
				case MENU_JUKEBOX:
					JE_playSampleNum(S_SELECT);

					fade_black(10);
					jukebox();

					memcpy(VGAScreen->surf->pixels, VGAScreen2->surf->pixels, VGAScreen->surf->pitch * VGAScreen->surf->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case MENU_RETURN:
					quit = true;
					JE_playSampleNum(S_SPRING);
					break;
					
				case MenuOptions_MAX:
					assert(false);
					break;
				}
				break;
				
			case SDLK_ESCAPE:
				quit = true;
				JE_playSampleNum(S_SPRING);
				break;
				
			default:
				break;
			}
		}
	} while (!quit);
}
示例#8
0
void play_DmapMusic()
{
    static char tfile[2048];
    static int ttrack=0;
    bool domidi=false;
    
    // Seems like this ought to call try_zcmusic()...
    
    if(DMaps[currdmap].tmusic[0]!=0)
    {
        if(zcmusic==NULL ||
           strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
           (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
        {
            if(zcmusic != NULL)
            {
                zcmusic_stop(zcmusic);
                zcmusic_unload_file(zcmusic);
                zcmusic = NULL;
            }
            
            // Try the ZC directory first
            {
                char exepath[2048];
                char musicpath[2048];
                get_executable_name(exepath, 2048);
                replace_filename(musicpath, exepath, DMaps[currdmap].tmusic, 2048);
                zcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath);
            }
            
            // Not in ZC directory, try the quest directory
            if(zcmusic==NULL)
            {
                char musicpath[2048];
                replace_filename(musicpath, qstpath, DMaps[currdmap].tmusic, 2048);
                zcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath);
            }
            
            if(zcmusic!=NULL)
            {
                stop_midi();
                strcpy(tfile,DMaps[currdmap].tmusic);
                zcmusic_play(zcmusic, emusic_volume);
                int temptracks=0;
                temptracks=zcmusic_get_tracks(zcmusic);
                temptracks=(temptracks<2)?1:temptracks;
                ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
                zcmusic_change_track(zcmusic,ttrack);
            }
            else
            {
                tfile[0] = 0;
                domidi=true;
            }
        }
    }
    else
    {
        domidi=true;
    }
    
    if(domidi)
    {
        int m=DMaps[currdmap].midi;
        
        switch(m)
        {
        case 1:
            jukebox(ZC_MIDI_OVERWORLD);
            break;
            
        case 2:
            jukebox(ZC_MIDI_DUNGEON);
            break;
            
        case 3:
            jukebox(ZC_MIDI_LEVEL9);
            break;
            
        default:
            if(m>=4 && m<4+MAXCUSTOMMIDIS)
                jukebox(m-4+ZC_MIDI_COUNT);
            else
                music_stop();
        }
    }
}
示例#9
0
void Message::executeControlCode(char code)
{
    int arg1, arg2, arg3;
    int numArgs=getNumControlCodeArgs(code);
    
    if(numArgs>=1)
        arg1=stream.getControlCodeArgument();
    if(numArgs>=2)
        arg2=stream.getControlCodeArgument();
    if(numArgs==3)
        arg3=stream.getControlCodeArgument();
    
    switch(code)
    {
        // Message property change codes
    case MSGC_SPEED:
        textSpeed=arg1;
        break;
        
    case MSGC_COLOUR:
        renderer.setColor(CSET(arg1)+arg2);
        break;
        
        // Message switch codes
    case MSGC_GOTOIFRAND:
        if(arg1<=1 || rand()%arg1==0)
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFGLOBAL: // Screen->D[], not global. Should be renamed.
        {
            arg1=vbound(arg1, 0, 7);
            int scr=(get_currdmap()<<7)+get_currscr();
            if(DMaps[get_currdmap()].type!=dmOVERW)
                scr-=DMaps[get_currdmap()].xoff;
            
            if(game->screen_d[scr][arg1]>=arg2)
                manager.switchTo(arg3);
            break;
        }
        
    case MSGC_GOTOIF: // If item. Rename this one, too.
        if(arg1>=0 && arg1<MAXITEMS && game->item[arg1])
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFCTR:
        if(game->get_counter(arg1)>=arg2)
            manager.switchTo(arg3);
        break;
        
    case MSGC_GOTOIFCTRPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            if(game->get_counter(arg1)>=amount)
                manager.switchTo(arg3);
            break;
        }
        
    case MSGC_GOTOIFTRICOUNT:
        if(TriforceCount()>=arg1)
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFTRI:
        if(arg1>=0 && arg1<MAXLEVELS && (game->lvlitems[arg1]&liTRIFORCE)!=0)
            manager.switchTo(arg2);
        break;
        
        // Item and counter codes
    case MSGC_CTRUP:
        game->change_counter(arg2, arg1);
        break;
    
    case MSGC_CTRDN:
        game->change_counter(-arg2, arg1);
        break;
    
    case MSGC_CTRSET:
        game->set_counter(vbound(arg2, 0, game->get_maxcounter(arg1)), arg1);
        break;
    
    case MSGC_CTRUPPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            game->change_counter(arg2, amount);
            break;
        }
        
    case MSGC_CTRDNPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            game->change_counter(-arg2, amount);
            break;
        }
        
    case MSGC_CTRSETPC:
        {
            int amount=vbound((arg2*game->get_maxcounter(arg1))/100,
              0, game->get_maxcounter(arg1));
            game->set_counter(amount, arg1);
            break;
        }
        
    case MSGC_GIVEITEM:
        getitem(arg1);
        break;
        
    case MSGC_TAKEITEM:
        takeitem(arg1);
        break;
        
        // Other codes
    case MSGC_MIDI:
        if(arg1==0)
            music_stop();
        else
            jukebox(arg1+(ZC_MIDI_COUNT-1));
        break;
        
    case MSGC_SFX:
        sfx(arg1);
        break;
    }
}