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;
	}
}
Exemple #2
0
void SetupForegroundLayer()
{
    s16 tilepositionx = PIXEL_TO_TILE(-scrollData.scrollx_vdp) - 1; // divide by 8
    s16 tilepositiony = PIXEL_TO_TILE(scrollData.scrolly_vdp) - 1; // 

    // compute start and end tiles
    s16 starttilex = tilepositionx;
    s16 endtilex = (tilepositionx + TILE_UPDATE_AREA_WIDTH);
    s16 starttiley = tilepositiony;
    s16 endtiley = (tilepositiony + TILE_UPDATE_AREA_HEIGHT);

    s16 loop = 0;
    s16 innerLoop = 0;
    u16 tileNumber = 0;
    u16 arrayStart = 0;

	const u16 tileBaseValue = TILE_ATTR_FULL(PAL3, 0, 0, 0, 0) + foregroundLoadedTileInfo.startIndex;

    for (loop = starttiley; loop <= endtiley; loop++)
    {
        arrayStart = loop * levelData.foreground->width;
        for (innerLoop = starttilex; innerLoop <= endtilex; innerLoop++)
        {
            tileNumber = ARRAY_ITEM_VALUE(levelData.foreground->tilemap, arrayStart + innerLoop);
			tileNumber = GetTile(tileNumber, tileBaseValue);
            VDP_setTileMapXY(APLAN, tileNumber, innerLoop & 63, loop & 63);
        }
    }
}
Exemple #3
0
void InGameMenuLoop()
{
    VDP_resetSprites();

    u16 tileAttr = TILE_ATTR_FULL(PAL0,0,0,0,goplanesLoadedTileInfo.startIndex);

    VDP_setSprite(0, TILE_TO_PIXEL(12), TILE_TO_PIXEL(9) + TILE_TO_PIXEL(menuItem), SPRITE_SIZE(3,3), tileAttr, 0);

    MyVDP_waitVSync();
	VDP_updateSprites();   

	if (joyButtonPressedState.b)
	{
		CloseInGameMenu(); 
		return;
	}

    if (joyButtonPressedState.start || joyButtonPressedState.a)
    {
        switch (menuItem)
        {
        case MENU_ITEM_RETURN:
			{
				CloseInGameMenu(); 
				return;
			}
			break;
        case MENU_ITEM_ENABLE_DEBUG:
            {
                if (playerObject->aiState != AI_STATE_DEBUG)
                {
                    Player_StartDebugMovement();
                }
                else
                {
                    Player_EndDebugMovement();
                }
				DrawText();
            }
            break;
		case MENU_ITEM_INVINCIBILITY:
			debugSettings.invincibility = !debugSettings.invincibility;
			DrawText();
			break;
		case MENU_ITEM_VSYNC:
			debugSettings.waitforvsync = !debugSettings.waitforvsync;
			DrawText();
			break;
		case MENU_ITEM_FPSCOUNTER:
			debugSettings.showFPSCounter = !debugSettings.showFPSCounter;
			DrawText();
			break;

        }
    }
}
Exemple #4
0
int main(void) {
	titleScreen();
	initBoard();
	drawBoard();
	VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL3, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 20), 32, 0, 5, 3);
	while(1) {
		VDP_waitVSync();
	}
	return 0;
}
Exemple #5
0
void _show_scr( const Image *img, u32 ms )
{
   SYS_disableInts();
   VDP_setEnable(FALSE);
      VDP_drawImageEx( BPLAN, img, TILE_ATTR_FULL( PAL0, FALSE, FALSE, FALSE, TILE_USERINDEX ), 0, 0, TRUE, FALSE );
   VDP_setEnable(TRUE);
   SYS_enableInts();

   waitMs(ms);
}
Exemple #6
0
void showBmp ( u16 pal, struct genresTiles *grt, u16 tile, VDPPlan plan, u16 x, u16 y, u8 pal_steps )
{
	SYS_disableInts();
	VDP_loadTileData ( grt->tiles, tile, grt->width * grt->height, 0 );
	SYS_enableInts();

	SYS_disableInts();
	VDP_fillTileMapRectInc ( plan, TILE_ATTR_FULL ( pal, 1, 0, 0, tile ), x, y, grt->width, grt->height );
	SYS_enableInts();
}
Exemple #7
0
void drawBoard() {
	int x, y;
	char score_string[11];
	for (y = 0; y != BOARD_Y; y++) {
		for (x = 0; x != BOARD_X; x++) {
			if (board[y][x].id) {
				if (board[y][x].selected)
					VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL2, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT);
				else
					VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL1, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT);
			} else {
				VDP_clearTileMapRect(VDP_PLAN_A, CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT);
			}
		}
	}
	VDP_drawText("Level 1", 31, 3);
	//VDP_drawText("Goals:", 32, 5);
	//VDP_drawText("0 / 0", 32, 6);
	VDP_drawText("Score:", 30, 26);
	intToStr((s32)score, score_string, 1);
	VDP_clearTileMapRect(VDP_PLAN_A, 30, 27, 10, 1);
	VDP_drawText(score_string, 30, 27);
	VDP_updateSprites();
}
Exemple #8
0
static void createPauseMenu(u8 player){

	u8 x = leftEdge(player), y = Y_PAUSE;
	u8 i;

	VDP_drawText("      OPTIONS", x, y);
	//draw underline
	for (i=x+6; i<x+13; i++){
		VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+4), i, y+1);
	}

	VDP_drawText("Coming soon...", x, y+2);
	VDP_drawText("Double-tap START", x, y+5);
	VDP_drawText("to resume", x, y+6);
}
void transition_fx(u8 frames, u16 vramindex_start)
{
	s16 i, j, k, l;
	u16 sw, sh;

	current_plan = VDP_PLAN_A;
	current_pal = PAL0;

	SYS_disableInts();

	vramIndex = vramindex_start;
	// u16  VDP_getPlanWidth();
	// u16  VDP_getPlanHeight();

	VDP_drawImageEx(APLAN, &transition_pattern_0, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 0, FALSE, FALSE);
    // vramIndex += transition_pattern_0.tileset->numTile;

    SYS_enableInts();

    sw = VDP_getPlanWidth();
    sh = VDP_getPlanHeight();

    for(i = 0; i < sw + WIPE_TILE_WIDTH; i++)
    {
		VDP_waitVSync();

    	for(j = 0; j < sh; j++)
    		for(k = 0; k < WIPE_TILE_WIDTH; k++)
	    	{
	    		l = i - k;
	    		if (l < 0)
	    			l = 0;
	    		else
	    		if (l > sw)
	    			l = sw - 1;

	    		l -= j;
	    		if (l < 0)
	    			break;
	    		else
	    		if (l > sw)
	    			break;

	    		VDP_setTileMapXY(current_plan, vramIndex + k, l, j); //TILE_ATTR_FULL(current_pal, FALSE, FALSE, FALSE, j));
	    	}
	}
}
Exemple #10
0
void text_draw ( u8 *str, u8 x, u8 y, u16 ms )
{
	#define POSITION	_base + _positions[chr] * _tiles + inc


	u8 chr;

	u16 k;
	u16 j;
	u16 i   = 0;
	u16 inc = 0;

   u8 *aux = str;

	while ( (chr = *aux++) )
	{
		inc = 0;
		chr -= ' ';
		if ( chr >= 96 ) chr = 0;

		if ( ! _positions[chr] )
		{
			_positions[chr] = _counter++;
			VDP_loadTileData ( _genres->sprites[chr], POSITION, _tiles, TRUE );
			VDP_waitDMACompletion();
		}
   }

	while ( (chr = *str++) )
	{
		inc = 0;
		chr -= ' ';
		if ( chr >= 96 ) chr = 0;

		for ( j = 0; j < _height; j++ )
		{
			for ( k = 0; k < _width; k++ )
			{
				VDP_setTileMapXY ( BPLAN, TILE_ATTR_FULL ( _palette, TRUE, 0, 0, POSITION ), i*_width + x + j, y + k );
				++inc;
			}
		}

		waitMs ( ms );
		++i;
	}
}
Exemple #11
0
void initBoard() {
	int x,y,c;
	for (y = 0; y != BOARD_Y; y++) {
		for (x = 0; x != BOARD_X; x++) {
			c = (custrand() % 4) + 1;
			board[y][x].id = c;
			board[y][x].selected = 0;
		}
	}
	VDP_resetSprites();
	cursor.posx = 0;
	cursor.posy = 0;
	cursor.size = SPRITE_SIZE(2, 2);
	cursor.tile_attr = TILE_ATTR_FULL(PAL1, PRIORITY_HIGH, FALSE, FALSE, TILE_USERINDEX);
	cursor.link = 0;
	VDP_setSpriteP(0, &cursor);
	VDP_updateSprites();
	
	SND_startPlay_VGM(muz_gameplay1);
}
Exemple #12
0
void FMP_draw ( FMP *fmp, s8 x_pos, s8 y_pos, s8 x_inner, s8 y_inner, u8 width, u8 height )
{
   SYS_disableInts();

	u16 x, y;
	const u16 *map = fmp->map->map ;

	for ( y = 0; y < height; y++ )
	{
		u16 aux = ( y + y_inner ) * fmp->map->width + x_inner;

		for ( x = 0; x < width; x++ )
		{
         u16 tile = TILE_ATTR_FULL ( fmp->pal, fmp->prio, 0, 0, map [ aux + x ] + fmp->vram );
			VDP_setTileMapXY ( fmp->plan, tile, x + x_pos, y + y_pos );
		}
	}

	SYS_enableInts();
}
u16 RSE_writerSetup(void)
{
	u16 j;
	current_plan = VDP_PLAN_A;
	current_pal = PAL0;

	SYS_disableInts();
	VDP_drawImageEx(APLAN, &oddball_fonts, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vramIndex), 0, 0, FALSE, FALSE);
	for(j = 0; j  < 4; j++)
		RSE_clearTileRowA(j);
	SYS_enableInts();

	vramIndex += oddball_fonts.tileset->numTile;

	writer_switch = FALSE;
	writer_is_done = FALSE;
	x_offset = 0;
	writer_display_duration = RSE_FRAMES(50);

	return vramIndex;
}
Exemple #14
0
u16 EnemyBulletCreate(s16 x, s16 y, s16 speedx, s16 speedy)
{
    ObjectStruct* enemyBulletObject = CreateObject(TYPE_ENEMY_PROJECTILE,
                                                   EnemyBulletUpdate, 
                                                   EnemyBulletDestroy, 
                                                   EnemyBulletDraw,
                                                   EnemyBulletCollide);

    if (!enemyBulletObject)
    {
#ifdef DEBUG_OBJECTS
        KDebug_Alert("EnemyBullet could not be created!");
#endif
        return 0;
    }

    enemyBulletObject->x                 = x;
    enemyBulletObject->y                 = y;
    enemyBulletObject->speedx            = speedx;
    enemyBulletObject->speedy            = speedy;
    enemyBulletObject->sprite.size       = SPRITE_SIZE(1,1);
    enemyBulletObject->spriteIndex       = 0;
    enemyBulletObject->sprite.tile_attr  = TILE_ATTR_FULL(PAL0,1,0,0,bulletLoadedTileInfo.startIndex);
    enemyBulletObject->rectLeft          = PIXEL_TO_VIRTUAL(-4);
    enemyBulletObject->rectRight         = PIXEL_TO_VIRTUAL(4);
    enemyBulletObject->rectTop           = PIXEL_TO_VIRTUAL(-4);
    enemyBulletObject->rectBottom        = PIXEL_TO_VIRTUAL(4);
    enemyBulletObject->damage            = 1;
    enemyBulletObject->healthPoints      = 1;
    enemyBulletObject->visible           = 1;

#ifdef DEBUG_OBJECTS
    KDebug_Alert("EnemyBulletCreate");
#endif

    return 1;
}
Exemple #15
0
static void _disclaimer_simple ( )
{
	displayInit();
	displayOff(0);

	SYS_disableInts();

	resetPalettes();
	resetScroll();
	resetSprites();
	resetScreen();

	VDP_drawImageEx ( PLAN_A, &ob_cs_disclaimer, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, 16),  0, 0, 0, 0 );

	preparePal ( PAL1, ob_cs_disclaimer.palette->data );

	SYS_enableInts();

	displayOn(0);

	waitJoySc(3);

	displayOff(10);
}
Exemple #16
0
static void displayFullScreenPicture(){
	s16 i,j,k;
	u16 tmp_tile_index;

	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 background */	
	// VDP_drawImageEx(BPLAN, &pic00, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 0, TRUE, TRUE);
	// vramIndex += pic00.tileset->numTile;
	VDP_setScrollingMode(HSCROLL_PLANE, VSCROLL_PLANE);
	VDP_setVerticalScroll(PLAN_B, 0);
	VDP_setVerticalScroll(PLAN_A, 0);
	VDP_setHorizontalScroll(PLAN_B, 0);
	VDP_setHorizontalScroll(PLAN_A, 0);	

	SYS_enableInts();

	// vramIndex = 0;
	VDP_waitDMACompletion();

	while (1){
		/* Pic 0 */
		// tmp_tile_index = curTileInd;
		SYS_disableInts();
		VDP_drawImageEx(APLAN, &pic00, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 0, TRUE, TRUE);
		SYS_enableInts();
		RSE_pause(RSE_FRAMES(1*60));

		RSE_pause(RSE_FRAMES(2*60));

		VDP_fadeOut(1, 63, 16, FALSE);
		RSE_turn_screen_to_black();		
		VDP_waitDMACompletion();
		for(i = 0; i  < 224 >> 3; i++)
		{
			VDP_waitVSync();
			RSE_clearTileRowB(i);
			RSE_clearTileRowA(i);
		}		

		/* Pic 1 */

		// curTileInd = tmp_tile_index;
		SYS_disableInts();
		VDP_drawImageEx(APLAN, &pic01a, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 12 >> 3, TRUE, TRUE);
		VDP_waitDMACompletion();
		VDP_drawImageEx(BPLAN, &pic01b, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, vramIndex + pic01a.tileset->numTile), 0, 12 >> 3, TRUE, TRUE);
		SYS_enableInts();

		RSE_pause(RSE_FRAMES(3*60));
		VDP_fadeOut(1, 63, 16, FALSE);
		RSE_turn_screen_to_black();		
		VDP_waitDMACompletion();
		for(i = 0; i  < 224 >> 3; i++)
		{
			VDP_waitVSync();
			RSE_clearTileRowB(i);
			RSE_clearTileRowA(i);
		}		

		/* Pic 2 */

		// curTileInd = tmp_tile_index;
		SYS_disableInts();
		VDP_drawImageEx(APLAN, &pic02a, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), (320 - 256) >> 4, 0, TRUE, TRUE);
		VDP_waitDMACompletion();
		VDP_drawImageEx(BPLAN, &pic02b, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, vramIndex + pic02a.tileset->numTile), (320 - 256) >> 4, 0, TRUE, TRUE);
		SYS_enableInts();

		RSE_pause(RSE_FRAMES(3*60));
		VDP_fadeOut(1, 63, 16, FALSE);
		RSE_turn_screen_to_black();		
		VDP_waitDMACompletion();
		for(i = 0; i  < 224 >> 3; i++)
		{
			VDP_waitVSync();
			RSE_clearTileRowB(i);
			RSE_clearTileRowA(i);
		}		

		/* Pic 9 */

		// curTileInd = tmp_tile_index;
		SYS_disableInts();
		VDP_drawImageEx(APLAN, &pic09, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 0, TRUE, TRUE);
		SYS_enableInts();

		RSE_pause(RSE_FRAMES(3*60));
		VDP_fadeOut(1, 63, 16, FALSE);
		RSE_turn_screen_to_black();		
		VDP_waitDMACompletion();
		for(i = 0; i  < 224 >> 3; i++)
		{
			VDP_waitVSync();
			RSE_clearTileRowB(i);
			RSE_clearTileRowA(i);
		}		
	}
}
u16 RSE_writerDrawString(char *str)
{
	char c;
	u16 i, fade, faded_idx;
	for (fade = 0; fade < 4; fade++)
	{
		faded_idx = current_char_idx + fade;
		c = str[faded_idx];

		if (fade == 0 && c == 0)
			return FALSE;

		if (c != ' ')
		{
			i = charToTileIndex(c);
			if (faded_idx < current_string_len && i != 0xFF)
				VDP_setTileMapXY(current_plan, TILE_USERINDEX + i + (FONT_LINE_OFFSET * fade), current_char_x + fade + x_offset, TILE_ATTR_FULL(current_pal, FALSE, FALSE, FALSE, current_char_y));
		}
	}

	current_char_x++;
	current_char_idx++;

	return TRUE;
}
Exemple #18
0
void SetupBackgroundLayer()
{
    // setup background
    MyVDP_setTileMapRect(BPLAN, levelData.background->tilemap, TILE_ATTR_FULL(PAL2, 0, 0, 0, backgroundLoadedTileInfo.startIndex), 0, 0, levelData.background->width, levelData.background->height);
}
Exemple #19
0
#include "EnemyBullet.h"
#include "Explosion.h"
#include "LargeExplosion.h"
#include "LevelManager.h"
#include "MathUtils.h"
#include "Objects.h"
#include "Physics.h"
#include "Player.h"
#include "SpritesAndMaps.h"

#define ENEMYPLANE_AI_STATE_FLYING 0
#define ENEMYPLANE_AI_STATE_DEAD   1

const u16 enemyPlaneAnimationFrames[32] =
{
    TILE_ATTR_FULL(PAL1,0,0,0,0),
    TILE_ATTR_FULL(PAL1,0,0,0,(1 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(2 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(3 * 9)),

    TILE_ATTR_FULL(PAL1,0,0,0,(4 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(5 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(6 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(7 * 9)),

    TILE_ATTR_FULL(PAL1,0,0,0,(8 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(9 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(10 * 9)),
    TILE_ATTR_FULL(PAL1,0,0,0,(11 * 9)),

    TILE_ATTR_FULL(PAL1,0,0,0,(12 * 9)),
			}

			tile_index++;
		}
	}

	SYS_disableInts();

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

	VDP_clearPlan(APLAN, 0);
	VDP_clearPlan(BPLAN, 0);

	/* Load the fond tiles */
	VDP_drawImageEx(APLAN, &pat_round, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vramIndex), 0, 0, FALSE, FALSE);
	vramIndex += pat_round.tileset->numTile;

	VDP_drawImageEx(BPLAN, &rse_logo, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, vramIndex), (320 - 200) / 16, (240 - 50) / 16, FALSE, FALSE);
	vramIndex += rse_logo.tileset->numTile;	

	VDP_setPalette(PAL0, pat_round.palette->data);
	VDP_setPalette(PAL1, rse_logo.palette->data);

	SPR_init(257);
    SPR_initSprite(&sprites[0], &rse_logo_shadow, 0, 0, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, 0));
    // SPR_initSprite(&sprites[1], &rse_logo_shadow_alt, 0, 0, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, 0));
	SPR_setPosition(&sprites[0], (320 - 160) >> 1, ((240 - 50) >> 1) + 8);
    SPR_update(sprites, 1);	

    VDP_setHilightShadow(0);
Exemple #21
0
static void fastStarFieldFX()
{
	u16 vramIndex = TILE_USERINDEX;
	s16 i, ns, s;
	Sprite sprites[256];

	SYS_disableInts();

	VDP_clearPlan(APLAN, 0);
	VDP_clearPlan(BPLAN, 0);
	VDP_setPlanSize(32, 32);

	/* Draw the foreground */
	VDP_drawImageEx(BPLAN, &starfield, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 0, TRUE, FALSE);
	vramIndex += starfield.tileset->numTile; 	

	/*	Set the proper scrolling mode (line by line) */
	VDP_setScrollingMode(HSCROLL_LINE, VSCROLL_PLANE);

	/*	Create the scrolling offset table */
	s = 1;
	for(i = 0; i < TABLE_LEN; i++)
	{
		scroll_PLAN_B[i] = 0;
		do
		{
			ns = -((random() % 3) + 1);
		}
		while (ns == s);
		scroll_speed[i] = ns;
		s = ns;
	}

	/* Setup the sprites */
	SPR_init(256);
	for(i = 0; i < MAX_DONUT; i++)
	    SPR_initSprite(&sprites[i], &donut, 0, 0, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, 0));

	SPR_update(sprites, MAX_DONUT);

	VDP_setPalette(PAL2, donut.palette->data);	    	

	SYS_enableInts();

	/*	Start !!!! */
	s = 0;
	while (TRUE)
	{
		VDP_waitVSync();
		BMP_showFPS(1);

		/* 	Scroll the starfield */
		VDP_setHorizontalScrollLine(PLAN_B, 2, scroll_PLAN_B, TABLE_LEN, TRUE);
		for(i = 0; i < TABLE_LEN; i++)
			scroll_PLAN_B[i] = (scroll_PLAN_B[i] + scroll_speed[i]) & 0xFF;

		/*	Animate the donuts */
		for(i = 0; i < MAX_DONUT; i++)
		{
	        // SPR_setPosition(&sprites[i], (cosFix16(s + (i << 5)) << 1) + 160 - 16, sinFix16(s + (i << 5)) + 112 - 16);
	        sprites[i].x = (cosFix16(s + (i << 5)) << 1) + 160 - 16 + 0x80;
	        sprites[i].y = sinFix16(s + (i << 5)) + 112 - 16 + 0x80;
			SPR_setFrame(&sprites[i], ((s >> 4) + i) & 0x7);
		}

		s += 4;	
		SPR_update(sprites, MAX_DONUT);
	}
}
Exemple #22
0
void titleScreen() {
	snowflake snowflakes[TITLE_SCREEN_SNOWFLAKES];
	SpriteDef sfdefs[TITLE_SCREEN_SNOWFLAKES];
	
	VDP_resetScreen();
	VDP_resetSprites();

	// Load Swirls
	VDP_loadTileData(swirls, TILE_USERINDEX, 20, TRUE);
	VDP_loadTileData(title_screen, TILE_USERINDEX + 20, 15, TRUE);
	VDP_loadTileData(swirl_spr, TILE_USERINDEX + 35, 20, TRUE);
	VDP_setPalette(PAL1, swirl_pal);
	VDP_setPalette(PAL2, sel_pal);
	VDP_setPalette(PAL3, ts_pal);
	
	JOY_init();
	JOY_setEventHandler(titleHandler);
	
	ImageAsset* title = getImage(titlbg);
	VDP_setPalette(PAL0, title->palette);
	VDP_loadTileData(title->tiles, TILE_USERINDEX + 55, (title->xTiles * title->yTiles), TRUE);
	VDP_fillTileMapRectInc(VDP_PLAN_B, TILE_ATTR_FULL(PAL0, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 55), 0, 0, title->xTiles, title->yTiles);
	MEM_free( title );
	
	VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL3, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 20), 18, 3, 5, 3);
	VDP_drawText("Mega Swirl",  1, 7);
	VDP_drawText("Testing Demo", 1, 8);
	VDP_drawText(VERSION_STRING, 1, 9);
	
	VDP_drawText("Music from Deflemask by", 1, 11);
	VDP_drawText("Delek", 1, 12);
	
	VDP_drawText("Featuring artwork by", 1, 14);
	VDP_drawText("Radioactivemantaray", 1, 15);
	
	VDP_drawText("- Press Start to Play -", 1, 21);
	VDP_drawText(BUILD_DATE, 1, 24);

	u8 selected_swirl;
	for(int i = 0; i != TITLE_SCREEN_SNOWFLAKES; i++) {
		snowflakes[i].startedAt = 
		snowflakes[i].startDelay =
		snowflakes[i].fallRate =
		snowflakes[i].swirltype =
		0;
		
		sfdefs[i].posx =
		sfdefs[i].posy =
		sfdefs[i].tile_attr =
		sfdefs[i].size =
		sfdefs[i].link =
		0;
		
		selected_swirl = (custrand() % 4);
		snowflakes[i].swirltype = selected_swirl; // Select one of four swirl types
		snowflakes[i].startDelay = ((custrand() % 3000) + 1) / 300; // Select between a 1-10 second delay (300 ticks per second)
		snowflakes[i].startedAt = getTick(); // Time when this snowflake was created 
		snowflakes[i].fallRate = (custrand() % 2) + 1; // Select how fast this snowflake should fall to the bottom of the screen
		sfdefs[i].posx = (custrand() % 320); // Select X position for this swirl
		sfdefs[i].posy = -16; // Start it off screen
		
		sfdefs[i].size = SPRITE_SIZE(2, 2);
		sfdefs[i].tile_attr = TILE_ATTR_FULL(PAL1, PRIORITY_HIGH, FALSE, FALSE, TILE_USERINDEX + 35 + (4 * selected_swirl)); // This will need to be changed as we need tiles arranged for sprites
		if(i != 0) {
			sfdefs[i - 1].link = i;
		}
	}
	VDP_setSpritesDirect(0, sfdefs, TITLE_SCREEN_SNOWFLAKES);

	Z80_loadDriver(Z80_DRIVER_VGM, 1);
	Z80_requestBus(1);
	YM2612_enableDAC();
	Z80_releaseBus();
	SND_startPlay_VGM(muz_title);

	while (waitflag == FALSE) {
		
		for(int i = 0; i != TITLE_SCREEN_SNOWFLAKES; i++) {
			
			if(getTick() - snowflakes[i].startedAt >= snowflakes[i].startDelay) {
				
				if(sfdefs[i].posy != 240) {
					sfdefs[i].posy = sfdefs[i].posy + snowflakes[i].fallRate;
				} else {
					selected_swirl = (custrand() % 4);
					snowflakes[i].startDelay = ((custrand() % 3000) + 1) / 300;
					snowflakes[i].startedAt = getTick();
					snowflakes[i].fallRate = (custrand() % 2) + 1;
					sfdefs[i].posx = (custrand() % 320);
					sfdefs[i].posy = -16;
				}
				
			}
			
			VDP_setSpritesDirect(0, sfdefs, TITLE_SCREEN_SNOWFLAKES);
		}
		
	}

	waitflag = FALSE;

	srand(GET_HVCOUNTER);
	VDP_clearPlan(APLAN, FALSE);
	JOY_setEventHandler(joyHandler);

	ImageAsset* test = getImage(swlspace);
	VDP_setPalette(PAL0, test->palette);
	VDP_loadTileData(test->tiles, TILE_USERINDEX + 55, (test->xTiles * test->yTiles), TRUE);
	VDP_fillTileMapRectInc(VDP_PLAN_B, TILE_ATTR_FULL(PAL0, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 55), 0, 0, test->xTiles, test->yTiles);
	MEM_free( test );
	
	SND_stopPlay_VGM();
}
Exemple #23
0
void HUD_updateStatusView(u8 joy, u8 bA, u8 bB, u8 bC, u8 bStart, u8 statusCode){
	u8 i,j;
	u8 channel;
	char status[20];

	//for each line
	for (j=0;j<9;j++){
		if (statusCode & statusCodes[j]){
			drawStatusMsg(joy,j);
		}
	}

	// u16 x = X0 + (joy * (WIDTH_TILES/2));
	// if (joy) x--;
	// u16 x = (joy * ((WIDTH_TILES-(HORIZONTAL_MARGIN*2)) / 2)) + (HORIZONTAL_MARGIN);
	u16 x = leftEdge(joy);
	u16 y = Y_STATUS;

	if (bStart && statusCode){
		bA = bB = bC = 0;
	}
	else{
		if (bA > 0) bA = 1;
		if (bB > 0) bB = 1;
		if (bC > 0) bC = 1;
	}

	//draw either grey or white circles to represent the fingering buttons
	VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bA), x+X_BUTTONS, y+Y_BUTTONS);
	VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bB), x+X_BUTTONS+2, y+Y_BUTTONS);
	VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bC), x+X_BUTTONS+4, y+Y_BUTTONS);

	char solfege[3];
	u8 mode = modeList[joy][keyIndex[joy]];
	u8 scalePitch = Instrument_buttonsToScalePitch(bA, bB, bC) % 7;
	u8 truePitch = SCALES[mode][scalePitch];
	switch (scalePitch){
		case 0:
			strcpy(solfege, "Do");
			break;
		case 1:
			strcpy(solfege, (truePitch == 1) ? "Ra" : "Re");
			break;
		case 2:
			strcpy(solfege, (truePitch == 3) ? "Me" : "Mi");
			break;
		case 3:
			strcpy(solfege, (truePitch == 6) ? "Fi" : "Fa");
			break;
		case 4:
			strcpy(solfege, (truePitch == 8) ? "Si" : (truePitch == 6) ? "Se" : "Sol");
			break;
		case 5:
			strcpy(solfege, (truePitch == 10) ? "Li" : (truePitch == 8) ? "Le" : "La");
			break;
		case 6:
			strcpy(solfege, (truePitch == 10) ? "Te" : "Ti");
			break;
		default:
			strcpy(solfege, "");
			break;
	}
	drawText(solfege, x+X_BUTTONS+6, y+Y_BUTTONS, 0, 3);

	// VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+2), x+X_NOTE, 25, 1, 2);

	//draw musical note
	if (playing[joy]){
		VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+2), x+X_NOTE, Y_NOTE, 1, 2);
	}
	else {
		VDP_clearTileMapRect(APLAN, x+X_NOTE, Y_NOTE, 1, 2);
	}

}
Exemple #24
0
    }
    
	fastMemsetU16(backgroundLineScrollValues, scrollData.scrollx_vdp >> 3, 162);
	fastMemsetU16(backgroundLineScrollValues + 162, scrollData.scrollx_vdp >> 2, 328);
}


void ClearCoin(u16 tileindex, u16 tilex, u16 tiley)
{
	tilex -= tileindex >> 1;
	tiley -= tileindex & 1;

	tilex &= 63;
	tiley &= 63;

	u16 tileattr = TILE_ATTR_FULL(PAL3, 0, 0, 0, 0) + foregroundLoadedTileInfo.startIndex;

	VDP_setTileMapXY(APLAN, tileattr, tilex, tiley);
	VDP_setTileMapXY(APLAN, tileattr, (tilex + 1)& 63, tiley);
	VDP_setTileMapXY(APLAN, tileattr, tilex, (tiley + 1) & 63);
	VDP_setTileMapXY(APLAN, tileattr, (tilex + 1) & 63, (tiley + 1) & 63);
}

void ClearBreakableRock(u16 tileindex, u16 tilex, u16 tiley)
{
	tilex -= tileindex >> 2;
	tiley -= tileindex & 3;

	u16 starttilex = tilex & 63;
	u16 starttiley = tiley & 63;
	u16 endtilex = (tilex + 4) & 63;