> 3) | ((($green + ($green <= 248 ? 4 : 0)) >> 3) << 5) | ((($blue + ($blue <= 248 ? 4 : 0)) >> 3) << 10)) & 0x7FFF; } function arrayToTable($arr, $chunkSize = 8) { $table = ''; $command = (strlen($arr[0]) === 2) ? 'db' : 'dw'; $chunks = array_chunk($arr, $chunkSize); foreach ($chunks as $chunk) { $table .= $command . ' $' . join(',$', $chunk) . "\n"; } return $table; } if (isset($_POST['submit'])) { if ($_FILES['pal']['error'] !== 0) { die('something went wrong.'); } if (pathinfo($_FILES['pal']['name'])['extension'] !== 'pal') { die('wrong file extension.'); } if ($_FILES['pal']['size'] !== 768) { die('wrong file size.'); } $palFile = fopen($_FILES['pal']['tmp_name'], 'rb'); $indexes = []; $highBytes = []; $lowBytes = []; for ($i = 0; $i < 256; $i++) { $red = hexdec(bin2hex(fread($palFile, 1))); $green = hexdec(bin2hex(fread($palFile, 1))); $blue = hexdec(bin2hex(fread($palFile, 1))); $color = dechex(PCRGBToSNESColor($red, $green, $blue)); $color = strtoupper($color); $color = str_pad($color, 4, '0', STR_PAD_LEFT); $indexes[] = str_pad(strtoupper(dechex($i)), 2, '0', STR_PAD_LEFT); $highBytes[] = substr($color, 0, 2); $lowBytes[] = substr($color, 2, 2); } fclose($palFile); echo '
';

		echo 'Colors:' . "\n" . arrayToTable($indexes, 16) . "\n";
		echo 'LowBytes:' . "\n" . arrayToTable($lowBytes) . "\n";
		echo 'HighBytes:' . "\n" . arrayToTable($highBytes);

		echo '
'; } else { ?>

.pal to table