예제 #1
0
파일: Game.c 프로젝트: yoyz/genesis
void GameLoop()
{
    VDP_resetSprites();
    playerObject->updateFunction(playerObject);
    playerObject->lifetime++;
    LevelManager_UpdateSection();
                
    ObjectManager_UpdateObjects();
	LevelManager_UpdateCoinPickup();
	LevelManager_UpdateBreakableRocks();
    ObjectManager_DrawObjects();
    LevelManager_UpdateTilePlanes();     

    // wait for vsync and then draw
	if (debugSettings.waitforvsync != FALSE)
	{
		MyVDP_waitVSync();                
	}
	VDP_updateSprites();
	LevelManager_DrawTilePlanes();     

    if (joyButtonPressedState.start)
    {
        OpenInGameMenu();
    }
}
예제 #2
0
파일: Game.c 프로젝트: yoyz/genesis
void OpenInGameMenu()
{
    currentLoopFunction = InGameMenuLoop;

    JOY_setEventHandler(joyEventCallback);

    menuItem = 0;

    MyVDP_waitVSync();
    VDP_setEnable(0);
    VDP_setReg(0x0b, 0x00); // set scroll mode to plane/plane
    VDP_resetSprites();

    VDP_setVerticalScroll(PLAN_A, 0);
    VDP_setVerticalScroll(PLAN_B, 0);
    VDP_setHorizontalScroll(PLAN_A, 0);
    VDP_setHorizontalScroll(PLAN_B, 0);

    VDP_updateSprites();

    VDP_fillTileMapRect(APLAN, 0, 0, 0, 64, 64);
    VDP_fillTileMapRect(BPLAN, 0, 0, 0, 64, 64);

    VDP_setTextPalette(0);

	DrawText();

    VDP_setEnable(1);
}
예제 #3
0
파일: Game.c 프로젝트: yoyz/genesis
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;

        }
    }
}
예제 #4
0
//Character selection menu
//@Fix glitchy BG screen and display of Arrow
void ChrselMenu()
{
    Sprite sprites[1];  //Sprite struct

    DrawBG(0);          //Cls
    DrawBG(8);          //Draw "How many players" BG
    InitMenu(1,0,0,3,_FALSE);   //Init a 2 item Menu

    //Setup the arrow sprite
    SYS_disableInts();
    SPR_init(16);   //Sprite tile cache of 16 tiles
    SYS_enableInts();

    // !@ Screws up
    SPR_initSprite(&sprites[0], &SPR_Arrow, 271, 266, TILE_ATTR(MISCPAL,TRUE,FALSE,FALSE));      //Init the Arrow Sprite
    VDP_setPalette(MISCPAL, SPR_Arrow.palette->data);                                              //Init pal OBJPAL to Arrow pal

    echo_play_sfx(SFX_13);              //"How many players are going to play today?"
    JOY_setEventHandler( &BtnHMenu );   //Setup joy handler to HMenu type
    //While no items are selected
    while (SItem==0)
    {
        //If 1 player hilighted
        if ((HItem==1) && (Trig==_FALSE))
        {
            SPR_setPosition(&sprites[0],271,266);   //Set new arrow position
            SPR_update(sprites, 1);                 //Update it
        }
        else
        {
            SPR_setPosition(&sprites[0],311, 266);
            SPR_update(sprites, 1);
        }
        VDP_waitVSync();
    }

    VDP_resetSprites();

    //@Toggle amt of players as appropriately
    if (SItem==1)
    {
        Opts[0]=_FALSE;
    }
    else
    {
        Opts[0]=PTRUE;
    }

    SPR_setPosition(&sprites[0],-128, -128);    //@Kill sprite
    SPR_update(sprites, 1);                     //Update it
    SPR_end;                                    //Kill sprite engine

    echo_wait_sfx(SFX_10);                      //"Let us play some hockey!"
    VDP_fadeOutAll(100,_FALSE);
}
예제 #5
0
파일: Game.c 프로젝트: yoyz/genesis
void CloseInGameMenu()
{
    MyVDP_waitVSync();
    VDP_setEnable(0);
    VDP_resetSprites();
    VDP_updateSprites();
    currentLoopFunction = GameLoop;
	LevelManager_SetupBackgroundPlanes();
    LevelManager_SetScrollMode();
    LevelManager_DrawTilePlanes();
    LevelManager_UpdateTilePlanes();
    VDP_setEnable(1);
}
예제 #6
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);
}
예제 #7
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();
}