mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-16 16:31:04 +00:00
Allow defining custom segment fill
This commit is contained in:
parent
d91b35468e
commit
2159fc345f
@ -34,6 +34,7 @@ class Platform(
|
|||||||
val generateBbcMicroInfFile: Boolean,
|
val generateBbcMicroInfFile: Boolean,
|
||||||
val generateGameBoyChecksums: Boolean,
|
val generateGameBoyChecksums: Boolean,
|
||||||
val bankNumbers: Map[String, Int],
|
val bankNumbers: Map[String, Int],
|
||||||
|
val bankFill: Map[String, Int],
|
||||||
val defaultCodeBank: String,
|
val defaultCodeBank: String,
|
||||||
val ramInitialValuesBank: Option[String],
|
val ramInitialValuesBank: Option[String],
|
||||||
val outputLabelsFormat: DebugOutputFormat,
|
val outputLabelsFormat: DebugOutputFormat,
|
||||||
@ -169,6 +170,10 @@ object Platform {
|
|||||||
case "" => 0
|
case "" => 0
|
||||||
case x => parseNumber(x)
|
case x => parseNumber(x)
|
||||||
})).toMap
|
})).toMap
|
||||||
|
val bankFills = banks.map(b => b -> (as.get(classOf[String], s"segment_${b}_fill", "00") match {
|
||||||
|
case "" => 0
|
||||||
|
case x => parseNumber(x)
|
||||||
|
})).toMap
|
||||||
|
|
||||||
// TODO: validate stuff
|
// TODO: validate stuff
|
||||||
banks.foreach(b => {
|
banks.foreach(b => {
|
||||||
@ -274,6 +279,7 @@ object Platform {
|
|||||||
generateBbcMicroInfFile,
|
generateBbcMicroInfFile,
|
||||||
generateGameBoyChecksums,
|
generateGameBoyChecksums,
|
||||||
bankNumbers,
|
bankNumbers,
|
||||||
|
bankFills,
|
||||||
defaultCodeBank,
|
defaultCodeBank,
|
||||||
ramInitialValuesBank,
|
ramInitialValuesBank,
|
||||||
debugOutputFormat,
|
debugOutputFormat,
|
||||||
|
@ -33,7 +33,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
|
|||||||
var initializedVariablesSize: Int = 0
|
var initializedVariablesSize: Int = 0
|
||||||
protected val log: Logger = rootEnv.log
|
protected val log: Logger = rootEnv.log
|
||||||
|
|
||||||
val mem = new CompiledMemory(platform.bankNumbers.toList, platform.isBigEndian)
|
val mem = new CompiledMemory(platform.bankNumbers.toList, platform.bankFill, platform.isBigEndian)
|
||||||
val labelMap: mutable.Map[String, (Int, Int)] = mutable.Map()
|
val labelMap: mutable.Map[String, (Int, Int)] = mutable.Map()
|
||||||
private val bytesToWriteLater = mutable.ListBuffer[(String, Int, Constant)]()
|
private val bytesToWriteLater = mutable.ListBuffer[(String, Int, Constant)]()
|
||||||
private val wordsToWriteLater = mutable.ListBuffer[(String, Int, Constant)]()
|
private val wordsToWriteLater = mutable.ListBuffer[(String, Int, Constant)]()
|
||||||
|
@ -5,12 +5,21 @@ import scala.collection.mutable
|
|||||||
/**
|
/**
|
||||||
* @author Karol Stasiak
|
* @author Karol Stasiak
|
||||||
*/
|
*/
|
||||||
class CompiledMemory(bankNames: List[(String, Int)], bigEndian: Boolean) {
|
class CompiledMemory(bankNames: List[(String, Int)], bankFills: Map[String, Int], bigEndian: Boolean) {
|
||||||
var programName = "MILLFORK"
|
var programName = "MILLFORK"
|
||||||
val banks: mutable.Map[String, MemoryBank] = mutable.Map(bankNames.map(p => p._1 -> new MemoryBank(p._2, bigEndian)): _*)
|
val banks: mutable.Map[String, MemoryBank] = mutable.Map(bankNames.map{p =>
|
||||||
|
val bank = new MemoryBank(p._2, bigEndian)
|
||||||
|
bank.fill(bankFills.getOrElse(p._1, 0))
|
||||||
|
p._1 -> bank
|
||||||
|
}: _*)
|
||||||
}
|
}
|
||||||
|
|
||||||
class MemoryBank(val index: Int, val isBigEndian: Boolean) {
|
class MemoryBank(val index: Int, val isBigEndian: Boolean) {
|
||||||
|
|
||||||
|
def fill(value: Int): Unit = {
|
||||||
|
output.indices.foreach(i => output(i) = value.toByte)
|
||||||
|
}
|
||||||
|
|
||||||
def readByte(addr: Int): Int = output(addr) & 0xff
|
def readByte(addr: Int): Int = output(addr) & 0xff
|
||||||
|
|
||||||
def readWord(addr: Int): Int =
|
def readWord(addr: Int): Int =
|
||||||
|
@ -36,6 +36,7 @@ object EmuPlatform {
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Map("default" -> 0, "second" -> 2, "third" -> 3),
|
Map("default" -> 0, "second" -> 2, "third" -> 3),
|
||||||
|
Map("default" -> 0, "second" -> 0, "third" -> 0),
|
||||||
"default",
|
"default",
|
||||||
None,
|
None,
|
||||||
ViceDebugOutputFormat,
|
ViceDebugOutputFormat,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user