static void beastScrollingFX(){
	u32 hscrollInc = 0;
	u16 vblCount = 0;
	u16 vramIndex = TILE_USERINDEX;
	short i;
	Sprite sprites[BALL_COUNT];

	SYS_disableInts();

	VDP_clearPlan(APLAN, 0);
	VDP_clearPlan(BPLAN, 0);
	/* Set a larger tileplan to be able to scroll */
	VDP_setPlanSize(64, 32);

	/* Draw the foreground */
	VDP_setPalette(PAL1, ground.palette->data);
	VDP_drawImageEx(BPLAN, &ground, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 4, FALSE, FALSE);
	VDP_drawImageEx(BPLAN, &ground, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 24, 4, FALSE, FALSE);
	vramIndex += ground.tileset->numTile;

	VDP_setPalette(PAL0, rse_logo.palette->data);
	VDP_drawImageEx(APLAN, &rse_logo, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vramIndex), 0, 6, FALSE, FALSE);
	vramIndex += rse_logo.tileset->numTile;	    	

	for(i = 0; i < BALL_COUNT; i++)
		SPR_initSprite(&sprites[i], &ball_metal, 0, 0, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, 0));

	VDP_setPalette(PAL2, ball_metal.palette->data);
	SPR_init(BALL_COUNT);

	SYS_enableInts();

	SND_startPlay_XGM(midnight);

	while (1){
		hscrollInc = 0;
		VDP_waitVSync();
		VDP_setHorizontalScroll(PLAN_B, -vblCount);
		VDP_setHorizontalScroll(PLAN_A, sinFix16(vblCount << 2));

		for(i = 0; i < BALL_COUNT; i++)
		{
			// SPR_setPosition(&sprites[i], 160 + sinFix16((vblCount << 2) + (i << 5)), 100 + cosFix16((vblCount << 3) + (i << 3)));
			sprites[i].x = (160 + 0x80) + sinFix16((vblCount << 2) + (i << 5));
			sprites[i].y = (100 + 0x80) + cosFix16((vblCount << 3) + (i << 3));
		}

		SPR_update(sprites, BALL_COUNT);
		vblCount += 1;
	}
}
Beispiel #2
0
Datei: main.c Projekt: clbr/SGDK
static void joyEvent(u16 joy, u16 changed, u16 state)
{
    // LEFT button state changed
    if (changed & state & BUTTON_LEFT)
    {
        if (cmd == NULL)
        {
            // driver change
            if (driver > &drivers[0]) driver--;
        }
        else
        {
            // param change
            const param_def *param = getCurrentParam();

            if (param > &cmd->params[0])
                setCurrentParam(param - 1);
        }
    }
    // RIGHT button state changed
    else if (changed & state & BUTTON_RIGHT)
    {
        if (cmd == NULL)
        {
            // driver change
            if (driver < &drivers[NUM_DRIVER - 1]) driver++;
        }
        else
        {
            // param change
            const param_def *param = getCurrentParam();

            if (param < &cmd->params[cmd->num_param - 1])
                setCurrentParam(param + 1);
        }
    }

    // UP button state changed
    if (changed & state & BUTTON_UP)
    {
        if (cmd != NULL)
        {
            if (cmd > &driver->cmds[0]) cmd--;
            else cmd = NULL;
        }
    }
    // DOWN button state changed
    else if (changed & state & BUTTON_DOWN)
    {
        if (cmd == NULL)
        {
            if (driver->num_cmd > 0)
                cmd = driver->cmds;
        }
        else if (cmd < &driver->cmds[driver->num_cmd - 1]) cmd++;
    }

    const u16 driver_ind = getCurrentDriverIndex();
    const u16 loop = params_value[driver_ind][0]->value;

    // driver commands
    switch(driver->id)
    {
    case Z80_DRIVER_PCM:
    {
        const u16 pan = params_value[driver_ind][1]->value;

        if (changed & state & BUTTON_A)
        {
            if (SND_isPlaying_PCM())
                SND_stopPlay_PCM();
            else
            {
                // RATE parameter value
                switch(params_value[driver_ind][2]->value)
                {
                case SOUND_RATE_8000:
                    SND_startPlay_PCM(india_8k, sizeof(india_8k), SOUND_RATE_8000, pan, loop);
                    break;

                case SOUND_RATE_11025:
                    SND_startPlay_PCM(india_11k, sizeof(india_11k), SOUND_RATE_11025, pan, loop);
                    break;

                case SOUND_RATE_13400:
                    SND_startPlay_PCM(india_13k, sizeof(india_13k), SOUND_RATE_13400, pan, loop);
                    break;

                case SOUND_RATE_16000:
                    SND_startPlay_PCM(india_16k, sizeof(india_16k), SOUND_RATE_16000, pan, loop);
                    break;

                case SOUND_RATE_22050:
                    SND_startPlay_PCM(india_22k, sizeof(india_22k), SOUND_RATE_22050, pan, loop);
                    break;

                case SOUND_RATE_32000:
                    SND_startPlay_PCM(india_32k, sizeof(india_32k), SOUND_RATE_32000, pan, loop);
                    break;
                }
            }
        }

        break;
    }

    case Z80_DRIVER_2ADPCM:
    {
        if (changed & state & BUTTON_A)
        {
            if (SND_isPlaying_2ADPCM(SOUND_PCM_CH1_MSK))
                SND_stopPlay_2ADPCM(SOUND_PCM_CH1);
            else
                SND_startPlay_2ADPCM(india_pcm_22k, sizeof(india_pcm_22k), SOUND_PCM_CH1, loop);
        }

        if (changed & state & BUTTON_B)
        {
            if (SND_isPlaying_2ADPCM(SOUND_PCM_CH2_MSK))
                SND_stopPlay_2ADPCM(SOUND_PCM_CH2);
            else
                SND_startPlay_2ADPCM(loop3_pcm_22k, sizeof(loop3_pcm_22k), SOUND_PCM_CH2, loop);
        }

        break;
    }

    case Z80_DRIVER_4PCM_ENV:
    {
        // set volume values for driver 4PCM_ENV
        SND_setVolume_4PCM_ENV(SOUND_PCM_CH1, params_value[driver_ind][1]->value);
        SND_setVolume_4PCM_ENV(SOUND_PCM_CH2, params_value[driver_ind][2]->value);
        SND_setVolume_4PCM_ENV(SOUND_PCM_CH3, params_value[driver_ind][3]->value);
        SND_setVolume_4PCM_ENV(SOUND_PCM_CH4, params_value[driver_ind][4]->value);

        if (changed & state & BUTTON_START)
        {
            if (SND_isPlaying_4PCM_ENV(SOUND_PCM_CH4_MSK))
                SND_stopPlay_4PCM_ENV(SOUND_PCM_CH4);
            else
                SND_startPlay_4PCM_ENV(loop2_16k, sizeof(loop2_16k), SOUND_PCM_CH4, loop);
        }

        if (changed & state & BUTTON_A)
        {
            if (SND_isPlaying_4PCM_ENV(SOUND_PCM_CH1_MSK))
                SND_stopPlay_4PCM_ENV(SOUND_PCM_CH1);
            else
                SND_startPlay_4PCM_ENV(hat2_16k, sizeof(hat2_16k), SOUND_PCM_CH1, loop);
        }

        if (changed & state & BUTTON_B)
        {
            if (SND_isPlaying_4PCM_ENV(SOUND_PCM_CH2_MSK))
                SND_stopPlay_4PCM_ENV(SOUND_PCM_CH2);
            else
                SND_startPlay_4PCM_ENV(snare2_16k, sizeof(snare2_16k), SOUND_PCM_CH2, loop);
        }

        if (changed & state & BUTTON_C)
        {
            if (SND_isPlaying_4PCM_ENV(SOUND_PCM_CH3_MSK))
                SND_stopPlay_4PCM_ENV(SOUND_PCM_CH3);
            else
                SND_startPlay_4PCM_ENV(hat1_16k, sizeof(hat1_16k), SOUND_PCM_CH3, loop);
        }

        break;
    }

    case Z80_DRIVER_MVS:
    {
        if (changed & state & BUTTON_A)
        {
            if (SND_isPlaying_MVS())
                SND_stopPlay_MVS();
            else
            {
                if (loop)
                    SND_startPlay_MVS(music_mvs, 1);
                else
                    SND_startPlay_MVS(music_mvs, 0);
            }
        }

        if (changed & state & BUTTON_B)
        {
            SND_startDAC_MVS(explode_u8k, sizeof(explode_u8k));
        }

        break;
    }

    case Z80_DRIVER_TFM:
    {
        if (changed & state & BUTTON_A)
        {
            SND_startPlay_TFM(music_tfd);
        }
        if (changed & state & BUTTON_START)
        {
            SND_stopPlay_TFM();
        }
        break;
    }

    case Z80_DRIVER_VGM:
    {
        if (changed & state & BUTTON_X)
        {
            SND_playSfx_VGM(explode_u8k, sizeof(explode_u8k));
        }
        if (changed & state & BUTTON_A)
        {
            SND_startPlay_VGM(sonic1);
        }
        if (changed & state & BUTTON_B)
        {
            SND_startPlay_VGM(roadrash);
        }
        if (changed & state & BUTTON_C)
        {
            SND_startPlay_VGM(bapcm_vgm);
        }
        if (changed & state & BUTTON_START)
        {
            if (SND_isPlaying_VGM())
                SND_stopPlay_VGM();
            else
                SND_resumePlay_VGM();
        }
        break;
    }

    case Z80_DRIVER_XGM:
    {
        if (changed & state & BUTTON_X)
        {
            SND_setPCM_XGM(64, snare1_14k, sizeof(snare1_14k));
            SND_startPlayPCM_XGM(64, 10, SOUND_PCM_CH2);
        }
        if (changed & state & BUTTON_Y)
        {
            //SND_setPCM_XGM(65, hat1_14k, sizeof(hat1_14k));
            SND_setPCM_XGM(65, f_voice1_14k, sizeof(f_voice1_14k));
            SND_startPlayPCM_XGM(65, 10, SOUND_PCM_CH3);
        }
        if (changed & state & BUTTON_Z)
        {
            SND_setPCM_XGM(66, loop1_14k, sizeof(loop1_14k));
            SND_startPlayPCM_XGM(66, 10, SOUND_PCM_CH4);
        }

        if (changed & state & BUTTON_A)
        {
            if (SND_isPlaying_XGM()) SND_stopPlay_XGM();
            else SND_startPlay_XGM(sor2_xgm);
        }
        if (changed & state & BUTTON_B)
        {
            if (SND_isPlaying_XGM()) SND_stopPlay_XGM();
            else SND_startPlay_XGM(bapcm_xgm);
        }
        if (changed & state & BUTTON_C)
        {
            if (SND_isPlaying_XGM()) SND_stopPlay_XGM();
            else
//                SND_startPlay_XGM(toystory);
                SND_startPlay_XGM(midnight);
        }

        if (changed & state & BUTTON_START)
        {
            if (SND_isPlaying_XGM())
                SND_pausePlay_XGM();
            else
                SND_resumePlay_XGM();
        }

        break;
    }
    }

    // MODE button state changed
    if (changed & state & BUTTON_MODE)
    {
        dmaMethod++;
        dmaMethod &= 3;
    }

    if (changed & state)
        refreshDriverInfos();
}