From 6c60ea9cacce4a7f3b2b2219031ef24ed26b6594 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 9 Mar 2021 21:47:36 +0100 Subject: [PATCH] allocate even more c64 zeropage locations for floats --- compiler/res/prog8lib/c64/graphics.p8 | 4 ++-- .../prog8/compiler/target/c64/C64MachineDefinition.kt | 1 + examples/test.p8 | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/res/prog8lib/c64/graphics.p8 b/compiler/res/prog8lib/c64/graphics.p8 index e2eaec21b..97ef7c704 100644 --- a/compiler/res/prog8lib/c64/graphics.p8 +++ b/compiler/res/prog8lib/c64/graphics.p8 @@ -39,8 +39,8 @@ graphics { swap(x1, x2) swap(y1, y2) } - word @zp dx = x2-x1 as word - word @zp dy = y2-y1 + word @zp dx = (x2-x1) as word + word @zp dy = (y2-y1) as word if dx==0 { vertical_line(x1, y1, abs(dy)+1 as ubyte) diff --git a/compiler/src/prog8/compiler/target/c64/C64MachineDefinition.kt b/compiler/src/prog8/compiler/target/c64/C64MachineDefinition.kt index ccb0530e7..af5aa99da 100644 --- a/compiler/src/prog8/compiler/target/c64/C64MachineDefinition.kt +++ b/compiler/src/prog8/compiler/target/c64/C64MachineDefinition.kt @@ -109,6 +109,7 @@ internal object C64MachineDefinition: IMachineDefinition { if (options.zeropage == ZeropageType.FLOATSAFE) { // remove the zero page locations used for floating point operations from the free list free.removeAll(listOf( + 0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x12, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, diff --git a/examples/test.p8 b/examples/test.p8 index bbe15a292..6f2d42d7d 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,6 +1,8 @@ -%import graphics +%target c64 %import floats - +%import graphics +%import test_stack +%zeropage floatsafe main { sub start() { @@ -10,7 +12,9 @@ main { uword xx ubyte yy - graphics.line(150,50,150,50) + graphics.line(160,100,160,80) + graphics.line(160,80,180,81) + graphics.line(180,81,177,103) for yy in 0 to 199-60 step 16 {