| 
					
				 | 
			
			
				@@ -3,73 +3,145 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		<link href="css/jquery-linedtextarea.css" rel="stylesheet"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		<script src="js/jquery-linedtextarea.js"></script> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		<title>SPS Assembler</title> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		<style> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			.header { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				font-family: Verdana, "Lucida Grande", Lucida, Helvetica, Arial, sans-serif; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				font-size:30px; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				color: #F8F8F8; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				height: 2em; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				border: 1px solid #ccc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				background-color: #436976; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				margin-bottom: .2em; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				vertical-align: middle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		</style> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	</head> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	<body> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		<div class="header"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			<div style="text-align:left;float:left;"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			<b>SPS Assembler</b> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			<div style="text-align:right;float:right;"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<a href="https://wkla.no-ip.biz/ArduinoWiki/doku.php?id=arduino:arduinosps:tpsass">Arduino im Modellbau</a> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		<?php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		error_reporting(E_ALL & ~E_NOTICE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$path = realpath(dirname(".")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (isset($_FILES['srcfile']) && $_FILES['srcfile']['error'] === UPLOAD_ERR_OK) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$folder = $_FILES['srcfile']['tmp_name'] ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$file = $_FILES['srcfile']['name']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			echo "folder: $folder<br/>"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			echo "filename: $file<br/>"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (isset($file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$source = file_get_contents($folder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$source = str_replace("\r", "", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$source = str_replace("\n", "\\n", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				unlink ($file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$example = $_POST["examples"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (isset($example)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$files = glob($path."/examples/*.tps"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			foreach($files as $filename){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if(is_file($filename)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					$basename = basename($filename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if ($basename == $example) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						$source = file_get_contents($filename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						$source = str_replace("\r", "", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						$source = str_replace("\n", "\\n", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						$file = $basename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$submitValue = $_POST["submit"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if ($submitValue == "file") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (isset($_FILES['srcfile']) && $_FILES['srcfile']['error'] === UPLOAD_ERR_OK) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$folder = $_FILES['srcfile']['tmp_name'] ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$file = $_FILES['srcfile']['name']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (isset($file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$source = file_get_contents($folder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$source = str_replace("\r", "", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$source = str_replace("\n", "\\n", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					unlink ($file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		?> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		<form  method="post" enctype="multipart/form-data"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<input type="file" name="srcfile"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<button type="submit">load</button>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		</form> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		<form  method="post"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<label for="examples">Examples:</label> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<select id="examples" name="examples" size="1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				<?php  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$example = $_POST["examples"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (isset($example)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$files = glob($path."/examples/*.tps"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				foreach($files as $filename){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					if(is_file($filename)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						$basename = basename($filename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						echo "<option value=\"$basename\">$basename</option>\r\n";  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					}    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if ($basename == $example) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							$source = file_get_contents($filename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							$source = str_replace("\r", "", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							$source = str_replace("\n", "\\n", $source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							$file = $basename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				?> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<button type="submit">load</button>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		</form> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		?> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		<div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			<form  method="post" enctype="multipart/form-data"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<table> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							<label for="file"><b>File upload</b></label> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td>						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							<input id="file" type="file" name="srcfile"/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							<button name="submit" type="submit" value="file">load</button>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td colspan="3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							upload your own file from your local computer<br/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							<label for="examples"><b>select an example</b></label> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							<select id="examples" name="examples" size="1"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								<?php  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								$files = glob($path."/examples/*.tps"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								foreach($files as $filename){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									if(is_file($filename)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										$basename = basename($filename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										echo "<option value=\"$basename\">$basename</option>\r\n";  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									}    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								?> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							<button name="submit" type="submit" value="example">load</button>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td>						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<td colspan="3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							load an example from the web page<br/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</table> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			</form> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		<hr/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		<b>Editing</b> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		<form  method="post" action="ass.php" target="_blank"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<label for="name">Name:</label><input id="name" name="name"><br/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<label for="dest">Destination:</label><select id="dest" name="dest"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="HOLTEK">Holtek</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="ATMEGA8">ATMega 8</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="ARDUINOSPS">Arduino SPS</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="TINYSPS">ATtiny84 SPS</option>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<label for="output">Outputformat:</label><select id="output" name="output"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="INTELHEX">Intel HEX Code</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="TPSTXT">SPS Emulator Source</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<option value="HEXTXT">HEX Text</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			</select><br/> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<textarea class="lined" rows="20" cols="60" name="source"></textarea> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			<button type="submit">Assemble</button>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			<table> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td><label for="name">Name:</label></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td align="right"><input id="name" name="name"></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td><label for="dest">Destination:</label></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td align="right"><select id="dest" name="dest"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="HOLTEK">Holtek</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="ATMEGA8">ATMega 8</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="ARDUINOSPS">Arduino SPS</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="TINYSPS">ATtiny84 SPS</option>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td><label for="output">Outputformat:</label></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td align="right"><select id="output" name="output"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="INTELHEX">Intel HEX Code</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="TPSTXT">SPS Emulator Source</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<option value="HEXTXT">HEX Text</option> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td colspan="2"><textarea class="lined" rows="20" cols="60" name="source"></textarea></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<td align="right"><button type="submit">Assemble</button></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			</table> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		</form> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		<script> 
			 |