1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-07-07 06:28:54 +00:00

Generate checksums for Game Boy

This commit is contained in:
Karol Stasiak 2019-01-11 15:17:48 +01:00
parent 8211b3cf49
commit 6979cbfe39
4 changed files with 12 additions and 0 deletions

View File

@ -162,3 +162,5 @@ Default: `after_code`.
* `extension` target file extension, with or without the dot
* `bbc_inf` should the `.inf` file with file metadata for BBC Micro be created
* `gb_checksum` should the main output file be patched with Game Boy-compatible checksums

View File

@ -106,6 +106,12 @@ object Main {
result.code.foreach{
case (bankName, code) =>
val prgOutput = if (bankName == "default") {
if (platform.generateGameBoyChecksums) {
code(0x14d) = (0x0134 to 0x14c).map(code).map(_^0xff).sum.toByte
val globalChecksum = code.map(_&0xff).sum
code(0x14f) = globalChecksum.toByte
code(0x14e) = globalChecksum.>>(8).toByte
}
defaultPrgOutput
} else {
s"${output.stripSuffix(platform.fileExtension)}.$bankName${platform.fileExtension}"

View File

@ -31,6 +31,7 @@ class Platform(
val freeZpPointers: List[Int],
val fileExtension: String,
val generateBbcMicroInfFile: Boolean,
val generateGameBoyChecksums: Boolean,
val bankNumbers: Map[String, Int],
val defaultCodeBank: String,
val outputStyle: OutputStyle.Value
@ -193,6 +194,7 @@ object Platform {
}.toList)
val fileExtension = os.get(classOf[String], "extension", ".bin")
val generateBbcMicroInfFile = os.get(classOf[Boolean], "bbc_inf", false)
val generateGameBoyChecksums = os.get(classOf[Boolean], "gb_checksum", false)
val outputStyle = os.get(classOf[String], "style", "single") match {
case "" | "single" => OutputStyle.Single
case "per_bank" | "per_segment" => OutputStyle.PerBank
@ -227,6 +229,7 @@ object Platform {
freePointers,
if (fileExtension == "" || fileExtension.startsWith(".")) fileExtension else "." + fileExtension,
generateBbcMicroInfFile,
generateGameBoyChecksums,
bankNumbers,
defaultCodeBank,
outputStyle)

View File

@ -26,6 +26,7 @@ object EmuPlatform {
pointers,
".bin",
false,
false,
Map("default" -> 0),
"default",
OutputStyle.Single