mirror of
https://github.com/KarolS/millfork.git
synced 2025-04-10 01:36:59 +00:00
Z80 doesn't have a zeropage
This commit is contained in:
parent
02a408e1be
commit
da023daadc
src
main/scala/millfork
test/scala/millfork/test/emu
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 = {
|
||||
val addr = location match {
|
||||
case AllocationLocation.Zeropage =>
|
||||
val a = zeropage.findFreeBytes(mem, count, options)
|
||||
if (a < 0) {
|
||||
ErrorReporting.fatal("Out of zeropage memory")
|
||||
}
|
||||
a
|
||||
case AllocationLocation.High =>
|
||||
val a = bytes.findFreeBytes(mem, count, options)
|
||||
if (a < 0) {
|
||||
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)
|
||||
val addr = if (options.platform.hasZeroPage) {
|
||||
location match {
|
||||
case AllocationLocation.Zeropage =>
|
||||
val a = zeropage.findFreeBytes(mem, count, options)
|
||||
if (a < 0) {
|
||||
ErrorReporting.fatal("Out of zeropage memory")
|
||||
}
|
||||
a
|
||||
case AllocationLocation.High =>
|
||||
val a = bytes.findFreeBytes(mem, count, options)
|
||||
if (a < 0) {
|
||||
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)
|
||||
addr
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user