Esempio n. 1
0
File: Game.c Progetto: 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);
}
Esempio n. 2
0
void term_print(const char *s, u16 frames)
{
	col_puts(0,term_pos++ % 32, s);
	if (term_pos >= 28)
	{
		VDP_setVerticalScroll(PLAN_A, (term_pos - 28) << 3);
		VDP_setVerticalScroll(PLAN_B, (term_pos - 28) << 3);
		col_puts(0, term_pos % 32, "                                                                                ");
	}

	while (frames--)
	{	
		while (vbl_wait)
		{	
			__asm__("nop");
		}
		vbl_wait = 1;
	}
}
Esempio n. 3
0
_voidCallback *h_int_scroll(void)
{
	if (scroll_off > 200)
	{
		VDP_setPaletteColor(14, 0);
	}
	scroll_off += dscroll;
	VDP_setVerticalScroll(PLAN_A, scroll_off);
	return NULL;
}
Esempio n. 4
0
int main(void)
{
	music_init();
	music_play(3);
	u16 delay_mod = 4;
	u16 col_inc_cnt = 0;
	setup();
reset_demo:

		hint_val = 3;
	col = 0;
	col_off = 0;
	phrase_num = 0;
	scroll_off = 0;
	dscroll = 0;
	term_pos = 0;
	term_scrolling = 0;

	sprites_dma_simple();
	term_pos = 0;
	VDP_setHInterrupt(0);

	VDP_clearPlan(VDP_PLAN_A, 0);
	VDP_clearPlan(VDP_PLAN_B, 0);
	// Greyscale palette for text
	VDP_setPaletteColor(0,0x000);
	VDP_setPaletteColor(1,0x444);
	VDP_setPaletteColor(2,0x888);
	VDP_setPaletteColor(3,0xEEE);

	VDP_setScreenWidth256();
	bios_boot_demo();
	VDP_setScreenWidth320();
	VDP_clearPlan(VDP_PLAN_A, 0);
	VDP_clearPlan(VDP_PLAN_B, 0);


	awful_put_logo(8, 2);
	startup_stretch();

	VDP_setVerticalScroll(PLAN_A, 252);
	VDP_setVerticalScroll(PLAN_B, 252);

	VDP_setHIntCounter(hint_val);
	SYS_setHIntCallback((_voidCallback *)h_int);
	volatile u8 p1 = pad_read(0);
	sprites_init();

	col_puts40(8,0,"Computer Science House");

	// Initialize background stars
	star stars[NUM_STARS];
	u16 i = 0;
	for (i = 0; i < NUM_STARS; i++)
	{
		stars[i].x = i * 5;
		stars[i].y = 128 + i * 8;
		stars[i].speed = (i % 7) + 1;
		stars[i].offset = (3 * i) % 4;
		stars[i].size = (i % 4 == 0) ? ('.' + COL_FONT_VRAM_OFFSET) : (128 + '.' + COL_FONT_VRAM_OFFSET);
	}

	print_phrase(8);
	u16 delay = 0;
	u8 dir = 0;
	VDP_setHInterrupt(1);
	for (;;)
	{
		delay++;
		if (col_inc_cnt == 0)
		{
			col_inc_cnt = hint_val;
			col_off += 0x002;
		}
		else
		{
			col_inc_cnt--;
		}
		if (delay == 512)
		{
			if (phrase_num == 8)
			{
				phrase_num = 0;

				VDP_setHInterrupt(0);
				sprite_set(0, 0, 0, 0, 0, 0);
				sprites_dma_simple();
				while (vbl_wait)
		{	
			__asm__("nop");
		}

		vbl_wait = 1;
				goto reset_demo;
			}
			hint_val++;
			if (hint_val == 10)
			{
				hint_val = 3;
			}
			delay_mod = delay_mod >> 1;
			if (delay_mod == 0)
			{
				delay_mod = delay_mod = 4;
			}
			VDP_setHIntCounter(hint_val);
			VDP_setHInterrupt(0);
			print_phrase(phrase_num);
			VDP_setHInterrupt(1);
			phrase_num++;

			delay = 0;
		}	
		process_stars(&stars);
		while (vbl_wait)
		{	
			__asm__("nop");
		}
		VDP_setHInterrupt(0);
		VDP_setPaletteColor(14,palette[col]);
		col = col_off;
		vbl_wait = 1;
		sprites_dma_simple();
		VDP_setHInterrupt(1);
	}
	return 0;	
}
Esempio n. 5
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);
		}		
	}
}