mirror of
https://github.com/KarolS/millfork.git
synced 2025-08-08 18:25:03 +00:00
Z80 doesn't have a zeropage
This commit is contained in:
@@ -30,6 +30,8 @@ class Platform(
|
|||||||
val defaultCodeBank: String,
|
val defaultCodeBank: String,
|
||||||
val outputStyle: OutputStyle.Value
|
val outputStyle: OutputStyle.Value
|
||||||
) {
|
) {
|
||||||
|
def hasZeroPage: Boolean = cpuFamily == CpuFamily.M6502
|
||||||
|
|
||||||
def cpuFamily: CpuFamily.Value = CpuFamily.forType(this.cpu)
|
def cpuFamily: CpuFamily.Value = CpuFamily.forType(this.cpu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -118,28 +118,36 @@ 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 = {
|
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) {
|
||||||
case AllocationLocation.Zeropage =>
|
location match {
|
||||||
val a = zeropage.findFreeBytes(mem, count, options)
|
case AllocationLocation.Zeropage =>
|
||||||
if (a < 0) {
|
val a = zeropage.findFreeBytes(mem, count, options)
|
||||||
ErrorReporting.fatal("Out of zeropage memory")
|
if (a < 0) {
|
||||||
}
|
ErrorReporting.fatal("Out of zeropage memory")
|
||||||
a
|
}
|
||||||
case AllocationLocation.High =>
|
a
|
||||||
val a = bytes.findFreeBytes(mem, count, options)
|
case AllocationLocation.High =>
|
||||||
if (a < 0) {
|
val a = bytes.findFreeBytes(mem, count, options)
|
||||||
ErrorReporting.fatal("Out of high memory")
|
|
||||||
}
|
|
||||||
a
|
|
||||||
case AllocationLocation.Either =>
|
|
||||||
var a = zeropage.findFreeBytes(mem, count, options)
|
|
||||||
if (a < 0) {
|
|
||||||
a = bytes.findFreeBytes(mem, count, options)
|
|
||||||
if (a < 0) {
|
if (a < 0) {
|
||||||
ErrorReporting.fatal("Out of high memory")
|
ErrorReporting.fatal("Out of high memory")
|
||||||
}
|
}
|
||||||
}
|
a
|
||||||
a
|
case AllocationLocation.Either =>
|
||||||
|
var a = zeropage.findFreeBytes(mem, count, options)
|
||||||
|
if (a < 0) {
|
||||||
|
a = bytes.findFreeBytes(mem, count, options)
|
||||||
|
if (a < 0) {
|
||||||
|
ErrorReporting.fatal("Out of high memory")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
markBytes(mem, addr, count, initialized, writeable)
|
||||||
addr
|
addr
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package millfork.test.emu
|
package millfork.test.emu
|
||||||
|
|
||||||
import millfork.output.{AfterCodeByteAllocator, CurrentBankFragmentOutput, UpwardByteAllocator, VariableAllocator}
|
import millfork.output.{AfterCodeByteAllocator, CurrentBankFragmentOutput, UpwardByteAllocator, VariableAllocator}
|
||||||
import millfork.{Cpu, OutputStyle, Platform}
|
import millfork.{Cpu, CpuFamily, OutputStyle, Platform}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karol Stasiak
|
* @author Karol Stasiak
|
||||||
@@ -15,7 +15,9 @@ object EmuPlatform {
|
|||||||
Nil,
|
Nil,
|
||||||
CurrentBankFragmentOutput(0, 0xffff),
|
CurrentBankFragmentOutput(0, 0xffff),
|
||||||
Map("default" -> new UpwardByteAllocator(0x200, 0xb000)),
|
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,
|
pointers,
|
||||||
".bin",
|
".bin",
|
||||||
false,
|
false,
|
||||||
|
Reference in New Issue
Block a user