mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-29 02:31:45 +00:00
Preliminary BBC Micro support
This commit is contained in:
parent
146e598636
commit
76a30acf9a
2
.gitignore
vendored
2
.gitignore
vendored
@ -27,5 +27,7 @@ src/test/scala/experiments/
|
||||
*.a78
|
||||
*.a2
|
||||
*.dsk
|
||||
*.inf
|
||||
HELLO
|
||||
|
||||
|
||||
|
@ -35,6 +35,8 @@ Read [the NES programming guide](./famicom-programming-guide.md) for more info.
|
||||
|
||||
* `a8` – Atari 8-bit computers
|
||||
|
||||
* `bbcmicro` – BBC Micro model B (32k RAM)
|
||||
|
||||
* `apple2` – Apple II+/IIe/Enhanced IIe
|
||||
|
||||
The primary and most tested platform is Commodore 64.
|
||||
@ -59,6 +61,20 @@ The file has to be loaded from $0C00. An example how to put such file onto a dis
|
||||
|
||||
Creating a bootable disk is beyond the scope of this document.
|
||||
|
||||
### A note about BBC Micro
|
||||
|
||||
The default configuration file puts the start address for the program at $0E00.
|
||||
|
||||
The compiler outputs two files: a raw machine code file without an extension and a `.inf` file with file metadata.
|
||||
To use the file, you need to put it on a disk or a disk image.
|
||||
You can for example use tools like BBC Disk Explorer.
|
||||
|
||||
After putting it on a disk, the file can be run with:
|
||||
|
||||
*RUN "FILENAME"
|
||||
|
||||
Currently, multipart BBC Micro programs are not supported.
|
||||
|
||||
## Adding a custom platform
|
||||
|
||||
Every platform is defined in an `.ini` file with an appropriate name.
|
||||
|
1
include/bbc_hardware.mfk
Normal file
1
include/bbc_hardware.mfk
Normal file
@ -0,0 +1 @@
|
||||
|
4
include/bbc_kernal.mfk
Normal file
4
include/bbc_kernal.mfk
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
// OSASCI. Write a character (to screen) from A plus LF if (A)=&0D
|
||||
// Input: A = Byte to write.
|
||||
asm void putchar(byte a) @$FFE3 extern
|
21
include/bbcmicro.ini
Normal file
21
include/bbcmicro.ini
Normal file
@ -0,0 +1,21 @@
|
||||
[compilation]
|
||||
; "strict" guarantees compatibility with Rockwell CPU's in some later Model B's
|
||||
arch=strict
|
||||
modules=bbc_kernal,bbc_hardware,default_panic
|
||||
|
||||
|
||||
[allocation]
|
||||
; TODO
|
||||
zp_pointers=$70, $72, $74, $76, $78, $7A, $7C, $7E, $80, $82, $84, $86, $88, $8A, $8C, $8E
|
||||
; $0E00 increases chances it will work on Electrons
|
||||
segment_default_start=$0E00
|
||||
; The following is for Model B; for Model A, consider changing it to $31FF
|
||||
segment_default_end=$71FF
|
||||
|
||||
[output]
|
||||
style=single
|
||||
format=allocated
|
||||
extension=
|
||||
bbc_inf=true
|
||||
|
||||
|
@ -166,6 +166,12 @@ object Main {
|
||||
c.runFileName.foreach(program =>
|
||||
new ProcessBuilder(program, Paths.get(defaultPrgOutput).toAbsolutePath.toString).start()
|
||||
)
|
||||
if (platform.generateBbcMicroInfFile) {
|
||||
val start = platform.codeAllocators("default").startAt
|
||||
val codeLength = result.code("default").length
|
||||
Files.write(Paths.get(defaultPrgOutput+".inf"),
|
||||
s"$defaultPrgOutput ${start.toHexString} ${start.toHexString} ${codeLength.toHexString}".getBytes(StandardCharsets.UTF_8))
|
||||
}
|
||||
}
|
||||
|
||||
private def parser = new CliParser[Context] {
|
||||
|
@ -24,6 +24,7 @@ class Platform(
|
||||
val codeAllocators: Map[String, UpwardByteAllocator],
|
||||
val variableAllocators: Map[String, VariableAllocator],
|
||||
val fileExtension: String,
|
||||
val generateBbcMicroInfFile: Boolean,
|
||||
val bankNumbers: Map[String, Int],
|
||||
val defaultCodeBank: String,
|
||||
val outputStyle: OutputStyle.Value
|
||||
@ -157,6 +158,7 @@ object Platform {
|
||||
}
|
||||
}.toList)
|
||||
val fileExtension = os.get(classOf[String], "extension", ".bin")
|
||||
val generateBbcMicroInfFile = os.get(classOf[Boolean], "bbc_inf", false)
|
||||
val outputStyle = os.get(classOf[String], "style", "single") match {
|
||||
case "" | "single" => OutputStyle.Single
|
||||
case "per_bank" | "per_segment" => OutputStyle.PerBank
|
||||
@ -166,7 +168,8 @@ object Platform {
|
||||
new Platform(cpu, flagOverrides, startingModules, outputPackager,
|
||||
codeAllocators.toMap,
|
||||
variableAllocators.toMap,
|
||||
if (fileExtension.startsWith(".")) fileExtension else "." + fileExtension,
|
||||
if (fileExtension == "" || fileExtension.startsWith(".")) fileExtension else "." + fileExtension,
|
||||
generateBbcMicroInfFile,
|
||||
bankNumbers,
|
||||
defaultCodeBank,
|
||||
outputStyle)
|
||||
|
@ -15,6 +15,7 @@ object EmuPlatform {
|
||||
Map("default" -> new UpwardByteAllocator(0x200, 0xb000)),
|
||||
Map("default" -> new VariableAllocator((0 until 256 by 2).toList, new AfterCodeByteAllocator(0xff00))),
|
||||
".bin",
|
||||
false,
|
||||
Map("default" -> 0),
|
||||
"default",
|
||||
OutputStyle.Single
|
||||
|
Loading…
Reference in New Issue
Block a user