1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-25 06:29:17 +00:00

Use target file name as disk label

This commit is contained in:
Karol Stasiak 2018-07-03 22:36:15 +02:00
parent 3390fe552e
commit 00be0b552e
5 changed files with 13 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import millfork.error.ErrorReporting
/**
* @author Karol Stasiak
*/
case class CompilationOptions(platform: Platform, commandLineFlags: Map[CompilationFlag.Value, Boolean]) {
case class CompilationOptions(platform: Platform, commandLineFlags: Map[CompilationFlag.Value, Boolean], outputFileName: Option[String]) {
import CompilationFlag._
import Cpu._

View File

@ -73,7 +73,7 @@ object Main {
ErrorReporting.info("No platform selected, defaulting to `c64`")
"c64"
})
val options = CompilationOptions(platform, c.flags)
val options = CompilationOptions(platform, c.flags, c.outputFileName)
ErrorReporting.debug("Effective flags: ")
options.flags.toSeq.sortBy(_._1).foreach{
case (f, b) => ErrorReporting.debug(f" $f%-30s : $b%s")

View File

@ -177,6 +177,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
storeDecimalValueInNormalRespresentation(f(parseNormalToDecimalValue(a), parseNormalToDecimalValue(b)))
def assemble(callGraph: CallGraph, optimizations: Seq[AssemblyOptimization[T]], options: CompilationOptions): AssemblerOutput = {
mem.programName = options.outputFileName.getOrElse("MILLFORK")
val platform = options.platform
val variableAllocators = platform.variableAllocators
val zpOccupied = mem.banks("default").occupied

View File

@ -1,13 +1,12 @@
package millfork.output
import millfork.error.ErrorReporting
import scala.collection.mutable
/**
* @author Karol Stasiak
*/
class CompiledMemory(bankNames: List[String]) {
var programName = "MILLFORK"
val banks = mutable.Map(bankNames.map(_ -> new MemoryBank): _*)
}

View File

@ -1,5 +1,7 @@
package millfork.output
import java.nio.charset.StandardCharsets
import scala.collection.mutable
/**
@ -24,7 +26,7 @@ object D88Output extends OutputPackager {
override def packageOutput(mem: CompiledMemory, bank: String): Array[Byte] = {
val b = mem.banks(bank)
val start = b.start
val header = new D88Header
val header = new D88Header(mem.programName.take(16))
val trackList = new D88TrackList
val sectors = mutable.ListBuffer[D88Sector]()
var trackOffset = 688
@ -67,13 +69,15 @@ sealed trait D88Part {
def toArray: Array[Byte]
}
class D88Header extends D88Part {
class D88Header(programName: String) extends D88Part {
var totalSize: Long = 0
def isAlphanum(c: Char): Boolean = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')
def toArray: Array[Byte] = {
Array(
'M', 'I', 'L', 'L', 'F', 'O', 'R', 'K',
0, 0, 0, 0, 0, 0, 0, 0,
programName.map(c =>
if (c == 0 || isAlphanum(c)) c.toByte else '_'.toByte
).padTo(16, 0.toByte).toArray ++ Array(
0, // NUL
0, 0, 0, 0, 0, 0, 0, 0, 0, // reserved
0, // not write protected