osd-contiki/tools/6502/download.php
oliverschmidt 3851548684 Added support for the Atari to the Contiki download page.
The Atari disk image tools don't allow to place contiki.cfg at a fixed location. Therefore the byte offset of the contiki.cfg content isn't constant :-( However using the tool adir with the option -r allows to learn the block number of the contiki.cfg content. So this block number is stored for each Atari disk image in the PHP code (in the array $blk) and translated into the correct byte offset.
2010-09-30 20:32:07 +00:00

60 lines
1.5 KiB
PHP

<?php
error_reporting(0);
$cfg = chr($_GET['addr-a']).chr($_GET['addr-b']).chr($_GET['addr-c']).chr($_GET['addr-d']);
$cfg .= chr($_GET['mask-a']).chr($_GET['mask-b']).chr($_GET['mask-c']).chr($_GET['mask-d']);
$cfg .= chr($_GET['dgw-a']). chr($_GET['dgw-b']). chr($_GET['dgw-c']). chr($_GET['dgw-d']);
$cfg .= chr($_GET['dns-a']). chr($_GET['dns-b']). chr($_GET['dns-c']). chr($_GET['dns-d']);
$dsk = $_GET['disk'];
switch ($_GET['machine']) {
case 'apple2':
$hex = $_GET['apple2-addr'];
$drv = $_GET['apple2-drv'];
$ext = '-' . $dsk . '.dsk';
$ofs = 0x05B00;
break;
case 'c64':
$hex = strtok($_GET['c64-addr-drv'], '-');
$drv = strtok('-');
$ext = '-' . $dsk . '.d64';
$ofs = 0x15002;
break;
case 'c128':
$hex = strtok($_GET['c128-addr-drv'], '-');
$drv = strtok('-');
$ext = '-' . $dsk . '.d71';
$ofs = 0x15002;
break;
case 'atari':
$hex = strtok($_GET['atari-addr-drv'], '-');
$drv = strtok('-');
$ext = '-' . $dsk . '.atr';
$blk = array(0, 5, 4, 0);
$ofs = 0x00010 + ($blk[$dsk] - 1) * 0x80;
break;
}
$addr = hexdec($hex);
$cfg .= chr($addr % 0x100).chr($addr / 0x100);
$cfg .= $drv;
if ($dsk) {
$img = file_get_contents('contiki'. $ext);
if ($img)
$out = substr_replace($img, $cfg, $ofs, strlen($cfg));
else
$out = '';
} else {
$ext = '.cfg';
$out = $cfg;
}
header('Content-Type: application/octetstream');
header('Content-Disposition: attachment; filename=contiki' . $ext);
print($out);
?>