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
void smeMAP_Load(smeMap* map)
{
    VDP_setPalette(0, map->PlaneA->Palette);
    VDP_loadTileSet(map->PlaneA->Tiles, TILE_USERINDEX, 0);
    map->PlaneA->Data = (Map*)MEM_alloc(sizeof(Map));
    map->PlaneA->Data->compression = 0;
    map->PlaneA->Data->w = map->Width;
    map->PlaneA->Data->h = map->Height;
    map->PlaneA->Data->tilemap = map->PlaneA->Graphics;

    VDP_setPalette(1, map->PlaneB->Palette);
    VDP_loadTileSet(map->PlaneB->Tiles, TILE_USERINDEX+map->PlaneA->Tiles->numTile, 0);
    map->PlaneB->Data = (Map*)MEM_alloc(sizeof(Map));
    map->PlaneB->Data->compression = 0;
    map->PlaneB->Data->w = map->Width;
    map->PlaneB->Data->h = map->Height;
    map->PlaneB->Data->tilemap = map->PlaneB->Graphics;
}
Beispiel #3
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);
}
Beispiel #4
0
static void _init( u16 hard )
{
   if ( hard == 0 ) // 0 is soft reset
   {
      VDP_drawText ( "BUG HUNT", 16, 9 );
      VDP_drawText ( "FOR SEGA MEGADRIVE", 11, 11 );
      VDP_drawText ( "BY THE AFROMONKEYS, 2015", 8, 13 );

      waitMs(3000);


      // That's weird.
      // Resetting in SGDK v1.11 invokes JOY_init() that
      // makes Justifier | Menacer not to be detected if
      // mouse is on PORT_1

      if ( JOY_getPortType(PORT_1) != PORT_TYPE_PAD )
      {
         VDP_drawText ( "PLEASE, REBOOT YOUR SYSTEM", 7, 19 );

         while ( 1 );
      }

      _start_entry(); // even more reset
   }


   sd_reset();
   SYS_assertReset(); // makes gensKmod crash, WTF?!



   VDP_init();
   //JOY_init();  // can cause mouse + justifer issues

   h_scroll = 0;
   VDP_setScrollingMode ( HSCROLL_PLANE, VSCROLL_PLANE );     /* The scroll mode never change during the game */
   VDP_setPlanSize(64,32);

   save_init( );

   SPR_init(0);                                             /* Sprite Engine INIT */
   VDP_setPalette(PAL3, sprpal.data);                       /* Sprite Palette (never change during the game) */

   /* PAD & Mouse (PORT_1) & Lightgun (PORT_2) Support */
   _JOYint ( TRUE );
   LightgunInit ( PORT_2 );

   VINT_SCROLL_FLAG  = FALSE;
   VINT_JOY_UPDATE   = FALSE;

   SYS_setVIntCallback((_voidCallback*) VIntCallback);

   FIRST_TIME_FLAG = TRUE;
}
Beispiel #5
0
Datei: main.c Projekt: clbr/SGDK
int main()
{
    u16 i, j;
    const driver_def *cur_driver;
    const cmd_def *cur_cmd;

    JOY_setEventHandler(joyEvent);

    VDP_setScreenWidth320();
    VDP_setHInterrupt(0);
    VDP_setHilightShadow(0);
    SYS_setVIntCallback(vintEvent);

    // point to first driver
    driver = &drivers[0];
    cmd = NULL;
    dmaMethod = 0;

    for(i = 0, cur_driver = drivers; i < NUM_DRIVER; i++, cur_driver++)
        for(j = 0, cur_cmd = cur_driver->cmds; j < MAX_CMD; j++, cur_cmd++)
            params_value[i][j] = cur_cmd->params;

    VDP_setPalette(PAL0, font_pal_lib.data);
    VDP_setPaletteColor((PAL1 * 16) + 15, 0x0888);
    VDP_setTextPalette(PAL0);
    VDP_drawText("Current Z80 driver", 10, 1);
    VDP_drawText("DMA Method:", 1, 26);

    refreshDriverInfos();


    while(1)
    {
        VDP_waitVSync();
    }
}
Beispiel #6
0
void _start_entry()
{
    // initiate random number generator
    randbase = 0xD94B ^ GET_HVCOUNTER;
    vtimer = 0;

    // default interrupt callback
    busErrorCB = _buserror_callback;
    addressErrorCB = _addresserror_callback;
    illegalInstCB = _illegalinst_callback;
    zeroDivideCB = _zerodivide_callback;
    chkInstCB = _chkinst_callback;
    trapvInstCB = _trapvinst_callback;
    privilegeViolationCB = _privilegeviolation_callback;
    traceCB = _trace_callback;
    line1x1xCB = _line1x1x_callback;
    errorExceptionCB = _errorexception_callback;
    intCB = _int_callback;
    internalVIntCB = _vint_callback;
    internalHIntCB = _hint_callback;
    internalExtIntCB = _extint_callback;

    internal_reset();

#if (ENABLE_LOGO != 0)
    {
        Bitmap *logo = unpackBitmap(&logo_lib, NULL);

        // correctly unpacked
        if (logo)
        {
            const Palette *logo_pal = logo->palette;

            // display logo (use BMP mode for that)
            BMP_init(TRUE, PAL0, FALSE);

    #if (ZOOMING_LOGO != 0)
            // init fade in to 30 step
            u16 step_fade = 30;

            if (VDP_initFading(logo_pal->index, logo_pal->index + (logo_pal->length - 1), palette_black, logo_pal->data, step_fade))
            {
                // prepare zoom
                u16 size = 256;

                // while zoom not completed
                while(size > 0)
                {
                    // sort of log decrease
                    if (size > 20) size = size - (size / 6);
                    else if (size > 5) size -= 5;
                    else size = 0;

                    // get new size
                    const u32 w = 256 - size;

                    // adjust palette for fade
                    if (step_fade-- > 0) VDP_doStepFading(FALSE);

                    // zoom logo
                    BMP_loadAndScaleBitmap(logo, 64 + ((256 - w) >> 2), (256 - w) >> 1, w >> 1, w >> 1, FALSE);
                    // flip to screen
                    BMP_flip(0);
                }

                // while fade not completed
                while(step_fade--) VDP_doStepFading(TRUE);
            }

            // wait 1 second
            waitTick(TICKPERSECOND * 1);
    #else
            // set palette 0 to black
            VDP_setPalette(PAL0, palette_black);

            // don't load the palette immediatly
            BMP_loadBitmap(logo, 64, 0, FALSE);
            // flip
            BMP_flip(0);

            // fade in logo
            VDP_fade((PAL0 << 4) + logo_pal->index, (PAL0 << 4) + (logo_pal->index + (logo_pal->length - 1)), palette_black, logo_pal->data, 30, FALSE);

            // wait 1.5 second
            waitTick(TICKPERSECOND * 1.5);
    #endif

            // fade out logo
            VDP_fadePalOut(PAL0, 20, 0);
            // wait 0.5 second
            waitTick(TICKPERSECOND * 0.5);

            // shut down bmp mode
            BMP_end();
            // release bitmap memory
            MEM_free(logo);
            // reinit vdp before program execution
            VDP_init();
        }
    }
Beispiel #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();
}
Beispiel #8
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);
	}
}
Beispiel #9
0
void FMP_set_palette ( FMP *fmp )
{
	VDP_setPalette ( fmp->pal, fmp->map->pal );
}