mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-25 21:29:25 +00:00
Use target file name as disk label
This commit is contained in:
parent
3390fe552e
commit
00be0b552e
@ -5,7 +5,7 @@ import millfork.error.ErrorReporting
|
|||||||
/**
|
/**
|
||||||
* @author Karol Stasiak
|
* @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 CompilationFlag._
|
||||||
import Cpu._
|
import Cpu._
|
||||||
|
@ -73,7 +73,7 @@ object Main {
|
|||||||
ErrorReporting.info("No platform selected, defaulting to `c64`")
|
ErrorReporting.info("No platform selected, defaulting to `c64`")
|
||||||
"c64"
|
"c64"
|
||||||
})
|
})
|
||||||
val options = CompilationOptions(platform, c.flags)
|
val options = CompilationOptions(platform, c.flags, c.outputFileName)
|
||||||
ErrorReporting.debug("Effective flags: ")
|
ErrorReporting.debug("Effective flags: ")
|
||||||
options.flags.toSeq.sortBy(_._1).foreach{
|
options.flags.toSeq.sortBy(_._1).foreach{
|
||||||
case (f, b) => ErrorReporting.debug(f" $f%-30s : $b%s")
|
case (f, b) => ErrorReporting.debug(f" $f%-30s : $b%s")
|
||||||
|
@ -177,6 +177,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
|
|||||||
storeDecimalValueInNormalRespresentation(f(parseNormalToDecimalValue(a), parseNormalToDecimalValue(b)))
|
storeDecimalValueInNormalRespresentation(f(parseNormalToDecimalValue(a), parseNormalToDecimalValue(b)))
|
||||||
|
|
||||||
def assemble(callGraph: CallGraph, optimizations: Seq[AssemblyOptimization[T]], options: CompilationOptions): AssemblerOutput = {
|
def assemble(callGraph: CallGraph, optimizations: Seq[AssemblyOptimization[T]], options: CompilationOptions): AssemblerOutput = {
|
||||||
|
mem.programName = options.outputFileName.getOrElse("MILLFORK")
|
||||||
val platform = options.platform
|
val platform = options.platform
|
||||||
val variableAllocators = platform.variableAllocators
|
val variableAllocators = platform.variableAllocators
|
||||||
val zpOccupied = mem.banks("default").occupied
|
val zpOccupied = mem.banks("default").occupied
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package millfork.output
|
package millfork.output
|
||||||
|
|
||||||
import millfork.error.ErrorReporting
|
|
||||||
|
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karol Stasiak
|
* @author Karol Stasiak
|
||||||
*/
|
*/
|
||||||
class CompiledMemory(bankNames: List[String]) {
|
class CompiledMemory(bankNames: List[String]) {
|
||||||
|
var programName = "MILLFORK"
|
||||||
val banks = mutable.Map(bankNames.map(_ -> new MemoryBank): _*)
|
val banks = mutable.Map(bankNames.map(_ -> new MemoryBank): _*)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package millfork.output
|
package millfork.output
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +26,7 @@ object D88Output extends OutputPackager {
|
|||||||
override def packageOutput(mem: CompiledMemory, bank: String): Array[Byte] = {
|
override def packageOutput(mem: CompiledMemory, bank: String): Array[Byte] = {
|
||||||
val b = mem.banks(bank)
|
val b = mem.banks(bank)
|
||||||
val start = b.start
|
val start = b.start
|
||||||
val header = new D88Header
|
val header = new D88Header(mem.programName.take(16))
|
||||||
val trackList = new D88TrackList
|
val trackList = new D88TrackList
|
||||||
val sectors = mutable.ListBuffer[D88Sector]()
|
val sectors = mutable.ListBuffer[D88Sector]()
|
||||||
var trackOffset = 688
|
var trackOffset = 688
|
||||||
@ -67,13 +69,15 @@ sealed trait D88Part {
|
|||||||
def toArray: Array[Byte]
|
def toArray: Array[Byte]
|
||||||
}
|
}
|
||||||
|
|
||||||
class D88Header extends D88Part {
|
class D88Header(programName: String) extends D88Part {
|
||||||
var totalSize: Long = 0
|
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] = {
|
def toArray: Array[Byte] = {
|
||||||
Array(
|
programName.map(c =>
|
||||||
'M', 'I', 'L', 'L', 'F', 'O', 'R', 'K',
|
if (c == 0 || isAlphanum(c)) c.toByte else '_'.toByte
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
).padTo(16, 0.toByte).toArray ++ Array(
|
||||||
0, // NUL
|
0, // NUL
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, // reserved
|
0, 0, 0, 0, 0, 0, 0, 0, 0, // reserved
|
||||||
0, // not write protected
|
0, // not write protected
|
||||||
|
Loading…
Reference in New Issue
Block a user