void LoadTilesFromStart()
{
	DrawChunks(0x4000, &v_screenposx, v_lvllayout);

	switch(v_zone)
	{
		case Zone_GHZ:
		case Zone_EndZ: Draw_GHz_Bg(); break;
		case Zone_MZ:   Draw_Mz_Bg (); break;
		case Zone_SBZ:  Draw_SBz_Bg(); break;
		default:        DrawChunks(0x6000, &v_bg1posx, v_lvllayout + 0x40); break;
	}
}
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);
			}
		}
示例#3
0
void KillBlobs( int player )
{
	int x,y;
	const int   position[] = {  0, 15, 27, 39, 51, 63, 72, 81, 90, 99,105,
	                          111,117,123,126,129,131,132,133,134,135,135,
	                          136,136,137,137,138,138,138,139,139,139,139,
	                          140,140,140 },
	            shading [] = {20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
	                          31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
	                          31, 30, 29, 28, 26, 24, 21, 18, 15, 12, 9,
	                           6,  3,  0 },
	            blobGraphic[kZapFrames] = { kDying,   kDying,   kDying,   kDying,   kSquish1,
	                                        kSquish1, kSquish1, kSquish1, kSquish2, kSquish2,
	                                        kSquish2, kSquish2, kSquish3, kSquish3, kSquish3,
	                                        kSquish3, kSquish4, kSquish4, kSquish4, kSquish4 },
	            grayGraphic[kZapFrames] = { kGrayBlink1, kGrayBlink1, kGrayBlink1,
	                                        kGrayBlink1, kGrayBlink1, kGrayBlink1,
	                                        kGrayBlink2, kGrayBlink2, kGrayBlink2,
	                                        kGrayBlink2, kGrayBlink2, kGrayBlink2,
	                                        kGrayBlink3, kGrayBlink3, kGrayBlink3,
	                                        kGrayBlink3, kGrayBlink3, kGrayBlink3,
	                                        kGrayBlink3, kGrayBlink3 };
	SDL_Rect myRect;
	bool busy = false;
	SDLU_Point dPoint, oPoint;
	char *scan;

	if( blobTime[player] > GameTickCount( ) )
		return;

	blobTime[player]++;

	SDLU_AcquireSurface( playerSurface[player] );

	// clear grenade sprite
	if( grenadeFrame[player] <= kBlastFrames )
	{
		CleanSpriteArea( player, &grenadeRect[player] );
		if( grenadeFrame[player] == kBlastFrames ) grenadeFrame[player]++;
	}

	for( x=0; x<kGridAcross; x++ )
	{
		for( y=0; y<kGridDown; y++ )
		{
			if( grid[player][x][y] >= kFirstBlob &&  // if a blob is dying
				grid[player][x][y] <= kLastBlob &&
				suction[player][x][y] == kInDeath )
			{
				death[player][x][y]++;
				busy = true;

				CalcBlobRect( x, y, &myRect );

				if( death[player][x][y] >= 0 && death[player][x][y] <= kZapFrames ) // draw its death
				{
					if( death[player][x][y] == kZapFrames )
					{
						grid[player][x][y] = kEmpty;
						suction[player][x][y] = kNoSuction;
						charred[player][x][y] = kNoCharring;
						SurfaceDrawBlob( player, &myRect, kEmpty, kNoSuction, kNoCharring );
						CleanSpriteArea( player, &myRect );
					}
					else
					{
						SurfaceDrawBlob( player, &myRect,
						                 grid[player][x][y],
						                 blobGraphic[ death[player][x][y] ],
						                 kNoCharring );
						CleanSpriteArea( player, &myRect );
					}

					CleanChunks( player, x, y, death[player][x][y], character[player].zapStyle );
				}
				else
				{
					SurfaceDrawBlob( player, &myRect, grid[player][x][y],
								(blobTime[player] & 2)? kFlashDarkBlob: kNoSuction, kNoCharring );
					CleanSpriteArea( player, &myRect );
				}
			}
			else
			{
				if( grid[player][x][y] == kGray &&					// gray dying
					suction[player][x][y] == kGrayBlink1 )
				{
					CalcBlobRect( x, y, &myRect );

					if( death[player][x][y] >= 0 && death[player][x][y] <= kZapFrames )
					{
						if( death[player][x][y] == kZapFrames )
						{
							grid[player][x][y] = kEmpty;
							suction[player][x][y] = kNoSuction;
							SurfaceDrawBlob( player, &myRect, kEmpty, kNoSuction, kNoCharring );
						}
						else
						{
							SurfaceDrawBoard( player, &myRect );
							SurfaceDrawAlpha( &myRect, kGray, kLight, grayGraphic[ death[player][x][y] ] );
							busy = true;
						}
						CleanSpriteArea( player, &myRect );
					}

					death[player][x][y]++;
				}
			}
		}
	}

	// draw score info above blobs but below chunks and explosions

	if( zapScoreFrame[player] < arrsize(position) )
	{
		myRect.y = zapScorePt[player].y - (position[zapScoreFrame[player]    ]);
		myRect.x = zapScorePt[player].x;
		myRect.h = 15 - (position[zapScoreFrame[player] - 1]);
		myRect.w = zapScoreWidth[player];
		CleanSpriteArea( player, &myRect );

		if( zapScoreFrame[player] < arrsize(position)-1 )
		{
			SDLU_AcquireSurface( playerSpriteSurface[player] );

			dPoint.y = oPoint.y = myRect.y;
			dPoint.x = oPoint.x = myRect.x;
			scan = zapScore[player];
			while( *scan )
			{
				SurfaceBlitWeightedCharacter( zapFont,    *scan, &dPoint, zapScoreR[player], zapScoreG[player], zapScoreB[player], shading[zapScoreFrame[player]] );
				SurfaceBlitWeightedCharacter( zapOutline, *scan, &oPoint, 0,                 0,                 0,                 shading[zapScoreFrame[player]] );
				scan++;
			}

			SDLU_ReleaseSurface( playerSpriteSurface[player] );

			zapScoreFrame[player]++;
			busy = true;
		}
	}

	///////////////////////////////////////////////////////////////

	for( x=0; x<kGridAcross; x++ )
	{
		for( y=0; y<kGridDown; y++ )
		{
			if( grid[player][x][y] >= kFirstBlob &&  // if a blob is dying
				grid[player][x][y] <= kLastBlob &&
				suction[player][x][y] == kInDeath &&
				death[player][x][y] >= 0 && death[player][x][y] < kZapFrames ) // draw chunks (after all that stuff)
			{
				DrawChunks( player, x, y, death[player][x][y], character[player].zapStyle );
			}
		}
	}

	SDLU_ReleaseSurface( playerSurface[player] );

	if( grenadeFrame[player] < kBlastFrames )
	{
		busy = true;

		SDLU_AcquireSurface( playerSpriteSurface[player] );

		myRect.y = grenadeFrame[player] * kBlastHeight;
		myRect.x = 0;
		myRect.h = kBlastHeight;
		myRect.w = kBlastWidth;

		SurfaceBlitAlpha(  playerSpriteSurface[player],  blastSurface,  blastMaskSurface,  playerSpriteSurface[player],
		                  &grenadeRect[player],         &myRect,       &myRect,           &grenadeRect[player]          );

		grenadeFrame[player]++;

		SDLU_ReleaseSurface( playerSpriteSurface[player] );
	}

	if( !busy && role[player] == kKillBlobs )
	{
		blobTime[player] = GameTickCount( );
		halfway[player] = false;
		role[player] = kDropBlobs;
	}
}