'$embed' directive now looks for binary in same directory as source

folder. #11.
This commit is contained in:
Rob Greene 2018-05-20 20:02:34 -05:00
parent e1bf0e719c
commit 56b3af7a44
3 changed files with 13 additions and 6 deletions

View File

@ -1,11 +1,10 @@
package com.webcodepro.applecommander.util.applesoft;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -14,6 +13,7 @@ import java.util.TreeMap;
import com.webcodepro.applecommander.util.applesoft.Token.Type;
import io.github.applecommander.bastokenizer.Main;
import io.github.applecommander.bastokenizer.Main.IntegerTypeConverter;
public abstract class Directive {
@ -112,9 +112,9 @@ public abstract class Directive {
}
String filename = requiresString();
int targetAddress = requiresInteger();
Path path = Paths.get(filename);
byte[] bin = Files.readAllBytes(path);
File file = new File(Main.configuration.sourceFile.getParentFile(), filename);
byte[] bin = Files.readAllBytes(file.toPath());
Optional<Line> nextLine = line.nextLine();
byte[] basicCode = nextLine.isPresent()

View File

@ -34,6 +34,8 @@ import picocli.CommandLine.Parameters;
name = "bt", mixinStandardHelpOptions = true,
versionProvider = Main.VersionProvider.class)
public class Main implements Callable<Void> {
public static Configuration configuration = new Configuration();
@Option(names = { "-o", "--output" }, description = "Write binary output to file.")
File outputFile;
@ -99,6 +101,7 @@ public class Main implements Callable<Void> {
public Void call() throws FileNotFoundException, IOException {
if (checkParameters()) {
if (debugFlag) debug = System.out;
configuration.sourceFile = this.sourceFile;
process();
}
@ -250,4 +253,8 @@ public class Main implements Callable<Void> {
}
}
}
/** Expose configuration details for other components to see. */
public static class Configuration {
public File sourceFile;
}
}

View File

@ -2,7 +2,7 @@
1 REM to allow for timing and verify that the "optimizations" improve runtime
2 REM to some degree...
5 $embed "src/test/resources/read.time.bin", "0x0260"
5 $embed "read.time.bin", "0x0260"
10 call 608: rem initialize clock routine
15 call 768,t1$:goto 100