1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-29 02:31:45 +00:00

Allow defining custom segment fill

This commit is contained in:
Karol Stasiak 2019-08-16 17:53:03 +02:00
parent d91b35468e
commit 2159fc345f
4 changed files with 19 additions and 3 deletions

View File

@ -34,6 +34,7 @@ class Platform(
val generateBbcMicroInfFile: Boolean,
val generateGameBoyChecksums: Boolean,
val bankNumbers: Map[String, Int],
val bankFill: Map[String, Int],
val defaultCodeBank: String,
val ramInitialValuesBank: Option[String],
val outputLabelsFormat: DebugOutputFormat,
@ -169,6 +170,10 @@ object Platform {
case "" => 0
case x => parseNumber(x)
})).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
banks.foreach(b => {
@ -274,6 +279,7 @@ object Platform {
generateBbcMicroInfFile,
generateGameBoyChecksums,
bankNumbers,
bankFills,
defaultCodeBank,
ramInitialValuesBank,
debugOutputFormat,

View File

@ -33,7 +33,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
var initializedVariablesSize: Int = 0
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()
private val bytesToWriteLater = mutable.ListBuffer[(String, Int, Constant)]()
private val wordsToWriteLater = mutable.ListBuffer[(String, Int, Constant)]()

View File

@ -5,12 +5,21 @@ import scala.collection.mutable
/**
* @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"
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) {
def fill(value: Int): Unit = {
output.indices.foreach(i => output(i) = value.toByte)
}
def readByte(addr: Int): Int = output(addr) & 0xff
def readWord(addr: Int): Int =

View File

@ -36,6 +36,7 @@ object EmuPlatform {
false,
false,
Map("default" -> 0, "second" -> 2, "third" -> 3),
Map("default" -> 0, "second" -> 0, "third" -> 0),
"default",
None,
ViceDebugOutputFormat,