1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-08-09 10:24:57 +00:00

Z80 doesn't have a zeropage

This commit is contained in:
Karol Stasiak
2018-07-02 22:34:29 +02:00
parent 02a408e1be
commit da023daadc
3 changed files with 33 additions and 21 deletions

View File

@@ -30,6 +30,8 @@ class Platform(
val defaultCodeBank: String,
val outputStyle: OutputStyle.Value
) {
def hasZeroPage: Boolean = cpuFamily == CpuFamily.M6502
def cpuFamily: CpuFamily.Value = CpuFamily.forType(this.cpu)
}

View File

@@ -118,7 +118,8 @@ class VariableAllocator(pointers: List[Int], private val bytes: ByteAllocator) {
}
def allocateBytes(mem: MemoryBank, options: CompilationOptions, count: Int, initialized: Boolean, writeable: Boolean, location: AllocationLocation.Value): Int = {
val addr = location match {
val addr = if (options.platform.hasZeroPage) {
location match {
case AllocationLocation.Zeropage =>
val a = zeropage.findFreeBytes(mem, count, options)
if (a < 0) {
@@ -141,6 +142,13 @@ class VariableAllocator(pointers: List[Int], private val bytes: ByteAllocator) {
}
a
}
} else {
val a = bytes.findFreeBytes(mem, count, options)
if (a < 0) {
ErrorReporting.fatal("Out of high memory")
}
a
}
markBytes(mem, addr, count, initialized, writeable)
addr
}

View File

@@ -1,7 +1,7 @@
package millfork.test.emu
import millfork.output.{AfterCodeByteAllocator, CurrentBankFragmentOutput, UpwardByteAllocator, VariableAllocator}
import millfork.{Cpu, OutputStyle, Platform}
import millfork.{Cpu, CpuFamily, OutputStyle, Platform}
/**
* @author Karol Stasiak
@@ -15,7 +15,9 @@ object EmuPlatform {
Nil,
CurrentBankFragmentOutput(0, 0xffff),
Map("default" -> new UpwardByteAllocator(0x200, 0xb000)),
Map("default" -> new VariableAllocator(pointers, new AfterCodeByteAllocator(0xff00))),
Map("default" -> new VariableAllocator(
if (CpuFamily.forType(cpu) == CpuFamily.M6502) pointers else Nil,
new AfterCodeByteAllocator(0xff00))),
pointers,
".bin",
false,