mirror of
https://github.com/KarolS/millfork.git
synced 2026-04-26 10:20:51 +00:00
Add TRS-80 Model 1 and 3 support
This commit is contained in:
@@ -284,10 +284,15 @@ object Platform {
|
||||
case "length_be" => AllocatedDataLengthBe(0)
|
||||
case "d88" => D88Output
|
||||
case "tap" => TapOutput
|
||||
case "trscmd" => TrsCmdOutput
|
||||
case n => n.split(":").filter(_.nonEmpty) match {
|
||||
case Array(b, s, e) => BankFragmentOutput(b, parseNumber(s), parseNumber(e))
|
||||
case Array(s, e) => CurrentBankFragmentOutput(parseNumber(s), parseNumber(e))
|
||||
case Array(b) => ConstOutput(parseNumber(b).toByte)
|
||||
case Array(b) => try {
|
||||
ConstOutput(parseNumber(b).toByte)
|
||||
} catch {
|
||||
case _:NumberFormatException => log.fatal(s"Invalid output format: `$b`")
|
||||
}
|
||||
case x => log.fatal(s"Invalid output format: `$x`")
|
||||
}
|
||||
}.toList)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package millfork.output
|
||||
|
||||
/**
|
||||
* @author Karol Stasiak
|
||||
*/
|
||||
object TrsCmdOutput extends OutputPackager {
|
||||
override def packageOutput(mem: CompiledMemory, bank: String): Array[Byte] = {
|
||||
val b = mem.banks(bank)
|
||||
val start = b.start
|
||||
b.output.slice(start, b.end + 1).grouped(256).zipWithIndex.flatMap{ case (chunk, index) =>
|
||||
// chunk type 1: data
|
||||
// chunk length: 1 byte, includes the load address, goes 3-258
|
||||
// load address: 2 bytes, little-endian
|
||||
Array[Byte](1, (chunk.length + 2).toByte, start.toByte, start.>>(8).+(index).toByte) ++ chunk
|
||||
}.toArray ++ Array[Byte](
|
||||
// chunk type 2: relocation address
|
||||
// chunk length: for type 2, it's always 2 bytes
|
||||
// relocation address: 2 bytes, little-endian
|
||||
2, 2, b.start.toByte, b.start.>>(8).toByte
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user