mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-12 19:29:51 +00:00
Generate checksums for Game Boy
This commit is contained in:
parent
8211b3cf49
commit
6979cbfe39
docs/api
src
@ -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
|
||||
|
@ -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}"
|
||||
|
@ -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)
|
||||
|
@ -26,6 +26,7 @@ object EmuPlatform {
|
||||
pointers,
|
||||
".bin",
|
||||
false,
|
||||
false,
|
||||
Map("default" -> 0),
|
||||
"default",
|
||||
OutputStyle.Single
|
||||
|
Loading…
x
Reference in New Issue
Block a user