static void debug_whats_used()

in cores/snes/debug.cpp [1980:2337]


static void debug_whats_used (void)
{
	printf("V-line: %ld, H-Pos: %ld, \n", (long) CPU.V_Counter, (long) CPU.Cycles);

	printf("Screen mode: %d, ", PPU.BGMode);

	if (PPU.BGMode <= 1 && (Memory.FillRAM[0x2105] & 8))
		printf("(BG#2 Priority), ");

	printf("Brightness: %d, ", PPU.Brightness);

	if (Memory.FillRAM[0x2100] & 0x80)
		printf("(screen blanked), ");

	printf("\n");

	if (Memory.FillRAM[0x2133] & 1)
		printf("Interlace, ");

	if (Memory.FillRAM[0x2133] & 4)
		printf("240 line visible, ");

	if (Memory.FillRAM[0x2133] & 8)
		printf("Pseudo 512 pixels horizontal resolution, ");

	if (Memory.FillRAM[0x2133] & 0x40)
		printf("Mode 7 priority per pixel, ");

	printf("\n");

	if (PPU.BGMode == 7 && (Memory.FillRAM[0x211a] & 3))
		printf("Mode 7 flipping, ");

	if (PPU.BGMode == 7)
		printf("Mode 7 screen repeat: %d, ", (Memory.FillRAM[0x211a] & 0xc0) >> 6);

	if (Memory.FillRAM[0x2130] & 1)
		printf("32K colour mode, ");

	printf("\n");

	if (PPU.BGMode == 7)
	{
		// Sign extend 13 bit values to 16 bit values...
		if (PPU.CentreX & (1 << 12))
			PPU.CentreX |= 0xe000;

		if (PPU.CentreY & (1 << 12))
			PPU.CentreY |= 0xe000;

		printf("Matrix A: %.3f, B: %.3f, C: %.3f, D: %.3f, Centre X: %d Y:%d, \n",
		       (double) PPU.MatrixA / 256, (double) PPU.MatrixB / 256,
		       (double) PPU.MatrixC / 256, (double) PPU.MatrixD / 256,
		       PPU.CentreX, PPU.CentreY);
	}

	if ((Memory.FillRAM[0x2106] & 0xf0) && (Memory.FillRAM[0x2106] & 0x0f))
	{
		printf("Mosaic effect(%d) on, ", PPU.Mosaic);

		for (int i = 0; i < 4; i++)
			if (Memory.FillRAM[0x2106] & (1 << i))
				printf("BG%d, ", i);
	}

	printf("\n");

	if (PPU.HVBeamCounterLatched)
		printf("V and H beam pos latched, \n");

	if (Memory.FillRAM[0x4200] & 0x20)
		printf("V-IRQ enabled at %d, \n", PPU.IRQVBeamPos);

	if (Memory.FillRAM[0x4200] & 0x10)
		printf("H-IRQ enabled at %d, \n", PPU.IRQHBeamPos);

	if (Memory.FillRAM[0x4200] & 0x80)
		printf("V-blank NMI enabled, \n");

	for (int i = 0; i < 8; i++)
	{
		if (missing.hdma_this_frame & (1 << i))
		{
			printf("H-DMA %d [%d] 0x%02X%04X->0x21%02X %s %s 0x%02X%04X %s addressing, \n",
			       i, DMA[i].TransferMode, DMA[i].ABank, DMA[i].AAddress, DMA[i].BAddress,
			       DMA[i].AAddressDecrement ? "dec" : "inc",
			       DMA[i].Repeat ? "repeat" : "continue",
			       DMA[i].IndirectBank, DMA[i].IndirectAddress,
			       DMA[i].HDMAIndirectAddressing ? "indirect" : "absolute");
		}
	}

	for (int i = 0; i < 8; i++)
	{
		if (missing.dma_this_frame & (1 << i))
		{
			printf("DMA %d [%d] 0x%02X%04X->0x21%02X Num: %d %s, \n",
			       i, DMA[i].TransferMode, DMA[i].ABank, DMA[i].AAddress, DMA[i].BAddress, DMA[i].TransferBytes,
			       DMA[i].AAddressFixed ? "fixed" : (DMA[i].AAddressDecrement ? "dec" : "inc"));
		}
	}

	printf("VRAM write address: 0x%04x(%s), Full Graphic: %d, Address inc: %d, \n",
	       PPU.VMA.Address,
	       PPU.VMA.High  ? "Byte" : "Word",
	       PPU.VMA.FullGraphicCount, PPU.VMA.Increment);

	for (int i = 0; i < 4; i++)
	{
		printf("BG%d: VOffset:%d, HOffset:%d, W:%d, H:%d, TS:%d, BA:0x%04x, TA:0x%04X, \n",
		       i, PPU.BG[i].VOffset, PPU.BG[i].HOffset,
		       (PPU.BG[i].SCSize & 1) * 32 + 32,
		       (PPU.BG[i].SCSize & 2) * 16 + 32,
		       PPU.BG[i].BGSize * 8 + 8,
		       PPU.BG[i].SCBase,
		       PPU.BG[i].NameBase);
	}

	const char	*s = "";

	switch ((Memory.FillRAM[0x2130] & 0xc0) >> 6)
	{
		case 0:
			s = "always on";
			break;

		case 1:
			s = "inside";
			break;

		case 2:
			s = "outside";
			break;

		case 3:
			s = "always off";
			break;
	}

	printf("Main screen (%s): ", s);

	for (int i = 0; i < 5; i++)
	{
		if (Memory.FillRAM[0x212c] & (1 << i))
		{
			switch (i)
			{
				case 0:
					printf("BG0, ");
					break;

				case 1:
					printf("BG1, ");
					break;

				case 2:
					printf("BG2, ");
					break;

				case 3:
					printf("BG3, ");
					break;

				case 4:
					printf("OBJ, ");
					break;
			}
		}
	}

	printf("\n");

	switch ((Memory.FillRAM[0x2130] & 0x30) >> 4)
	{
		case 0:
			s = "always on";
			break;

		case 1:
			s = "inside";
			break;

		case 2:
			s = "outside";
			break;

		case 3:
			s = "always off";
			break;
	}

	printf("Subscreen (%s): ", s);

	for (int i = 0; i < 5; i++)
	{
		if (Memory.FillRAM[0x212d] & (1 << i))
		{
			switch (i)
			{
				case 0:
					printf("BG0, ");
					break;

				case 1:
					printf("BG1, ");
					break;

				case 2:
					printf("BG2, ");
					break;

				case 3:
					printf("BG3, ");
					break;

				case 4:
					printf("OBJ, ");
					break;
			}
		}
	}

	printf("\n");

	if ((Memory.FillRAM[0x2131] & 0x3f))
	{
		if (Memory.FillRAM[0x2131] & 0x80)
		{
			if (Memory.FillRAM[0x2130] & 0x02)
				printf("Subscreen subtract");
			else
				printf("Fixed colour subtract");
		}
		else
		{
			if (Memory.FillRAM[0x2130] & 0x02)
				printf("Subscreen addition");
			else
				printf("Fixed colour addition");
		}

		if (Memory.FillRAM[0x2131] & 0x40)
			printf("(half): ");
		else
			printf(": ");

		for (int i = 0; i < 6; i++)
		{
			if (Memory.FillRAM[0x2131] & (1 << i))
			{
				switch (i)
				{
					case 0:
						printf("BG0, ");
						break;

					case 1:
						printf("BG1, ");
						break;

					case 2:
						printf("BG2, ");
						break;

					case 3:
						printf("BG3, ");
						break;

					case 4:
						printf("OBJ, ");
						break;

					case 5:
						printf("BACK, ");
						break;
				}
			}
		}

		printf("\n");
	}

	printf("Window 1 (%d, %d, %02x, %02x): ", PPU.Window1Left, PPU.Window1Right, Memory.FillRAM[0x212e], Memory.FillRAM[0x212f]);

	for (int i = 0; i < 6; i++)
	{
		if (PPU.ClipWindow1Enable[i])
		{
			switch (i)
			{
				case 0:
					printf("BG0(%s-%s), ", PPU.ClipWindow1Inside[0] ? "I" : "O", debug_clip_fn(PPU.ClipWindowOverlapLogic[0]));
					break;

				case 1:
					printf("BG1(%s-%s), ", PPU.ClipWindow1Inside[1] ? "I" : "O", debug_clip_fn(PPU.ClipWindowOverlapLogic[1]));
					break;

				case 2:
					printf("BG2(%s-%s), ", PPU.ClipWindow1Inside[2] ? "I" : "O", debug_clip_fn(PPU.ClipWindowOverlapLogic[2]));
					break;

				case 3:
					printf("BG3(%s-%s), ", PPU.ClipWindow1Inside[3] ? "I" : "O", debug_clip_fn(PPU.ClipWindowOverlapLogic[3]));
					break;

				case 4:
					printf("OBJ(%s-%s), ", PPU.ClipWindow1Inside[4] ? "I" : "O", debug_clip_fn(PPU.ClipWindowOverlapLogic[4]));
					break;

				case 5:
					printf("COL(%s-%s), ", PPU.ClipWindow1Inside[5] ? "I" : "O", debug_clip_fn(PPU.ClipWindowOverlapLogic[5]));
					break;
			}
		}
	}

	printf("\n");

	printf("Window 2 (%d, %d): ", PPU.Window2Left, PPU.Window2Right);

	for (int i = 0; i < 6; i++)
	{
		if (PPU.ClipWindow2Enable[i])
		{
			switch (i)
			{
				case 0:
					printf("BG0(%s), ", PPU.ClipWindow2Inside[0] ? "I" : "O");
					break;

				case 1:
					printf("BG1(%s), ", PPU.ClipWindow2Inside[1] ? "I" : "O");
					break;

				case 2:
					printf("BG2(%s), ", PPU.ClipWindow2Inside[2] ? "I" : "O");
					break;

				case 3:
					printf("BG3(%s), ", PPU.ClipWindow2Inside[3] ? "I" : "O");
					break;

				case 4:
					printf("OBJ(%s), ", PPU.ClipWindow2Inside[4] ? "I" : "O");
					break;

				case 5:
					printf("COL(%s), " , PPU.ClipWindow2Inside[5] ? "I" : "O");
					break;
			}
		}
	}

	printf("\n");

	printf("Fixed colour: %02x%02x%02x, \n", PPU.FixedColourRed, PPU.FixedColourGreen, PPU.FixedColourBlue);
}