void GM_Title()
{
	PlaySound_Special(BGM_Stop);
	ClearPLC();
	PaletteFadeOut();
	DISABLE_INTERRUPTS();
	SoundDriverLoad();
	VDP_RegWrite(0x00, 4);             // 8-colour mode
	VDP_RegWrite(0x02, vram_fg >> 10); // set foreground nametable address
	VDP_RegWrite(0x04, vram_bg >> 13); // set background nametable address
	VDP_RegWrite(0x10, 1);             // 64-cell hscroll size
	VDP_RegWrite(0x12, 0);             // window vertical position
	VDP_RegWrite(0x0B, 3);
	VDP_RegWrite(0x07, 0x20);          // set background colour (palette line 2, entry 0)

	f_wtr_state = 0;
	ClearScreen();
	Clear_Objects();

	NemDec(Nem_JapNames, 0);
	NemDec(Nem_CreditText, 0x14C0);
	EniDec(Eni_JapNames, 0xFF0000, 0);
	CopyTilemap(0xFF0000, 0xC000, 0x27, 0x1B);
	Clear_Palette(v_pal_dry_dup);
	PalLoad1(Palette_Sonic);

	v_objspace[2].id = ID_CreditsText;
	ExecuteObjects();
	BuildSprites();
	PaletteFadeIn();

	DISABLE_INTERRUPTS();
	NemDec(Nem_TitleFg, 0x4000);
	NemDec(Nem_TitleSonic, 0x6000);
	NemDec(Nem_TitleTM, 0xA200);

	CopyToVRAM(Art_Text, 0xD000, 0x290 * sizeof(ushort));

	v_lastlamp = 0;
	v_debuguse = 0;
	f_demo = 0;
	v_w_FFEA = 0;
	v_zone = 0;
	v_pcyc_time = 0;

	LevelSizeLoad();
	DeformLayers();

	EniDec(Blk16_GHZ, v_16x16, 0);
	KosDec(Blk256_GHZ, v_256x256);
	LevelLayoutLoad();
	PaletteFadeOut();
	DISABLE_INTERRUPTS();
	ClearScreen();
	DrawChunks(0x6000, &v_bg1posx, v_lvllayout + 0x40);
	EniDec(Eni_Title, 0xFF0000, 0);
	CopyTilemap(0xFF0000, 0xC206, 0x21, 0x15);
	NemDec(Nem_GHZ_1st, 0);
	PalLoad1(Palette_Title);
	PlaySound_Special(BGM_Title);

	f_debugmode = 0;
	v_demolength = 0x178;

	memset(&v_objspace[2], 0, 32);
	v_objspace[1].id = ID_TitleSonic;
	v_objspace[2].id = ID_PSBTM; // "PRESS START BUTTON"

	if(v_megadrive & 0x80)
	{
		// Outside Japan, load the TM object
		v_objspace[3].id = ID_PSBTM;
		v_objspace[3].frame = 3;
	}

	v_objspace[4].id = ID_PSBTM;
	v_objspace[4].frame = 2; // sprite line limiter..?

	ExecuteObjects();
	DeformLayers();
	BuildSprites();
	NewPLC(PLC_Main);
	v_title_dcount = 0;
	v_title_ccount = 0;
	VDP_Control(v_vdp_buffer1 | 0x40);
	PaletteFadeIn();

	do
	{
		WaitForVBlank(VBlank_Title);
		ExecuteObjects()
		DeformLayers();
		BuildSprites();
		PCycle_Title();
		RunPLC();

		v_objspace[0].x += 2;

		if(v_objspace[0].x >= 7168)
		{
			v_gamemode = GameMode_Sega;
			return;
		}

		auto levSelCode = (v_megadrive & 0x80) ? LevSelCode_US : LevSelCode_J;
		auto buttons = v_jpadpress1 & Buttons_Dir;

		if(buttons == levSelCode[v_title_dcount])
		{
			v_title_dcount++;

			if(buttons == 0)
			{
				auto count = (v_title_ccount >> 1) & 3;

				if(count == 0)
					f_levselcheat = true;
				else if(v_megadrive & 0x80)
				{
					// International version
					f_debugcheat = true;
					f_slomocheat = true;
				}
				else
				{
					/// Japanese version
					if(count == 1)
						f_slomocheat = true;
					else if(count == 2)
						f_debugcheat = true;
					else
						f_creditscheat = true;
				}

				PlaySound_Special(SFX_Ring);
			}
		}
Пример #2
0
void UpdateObjects()
{
	CopyToVRAM(REG_OBJ_BASE, (uint16_t *) ObjBuffer, sizeof(ObjBuffer) / sizeof(uint16_t));
}