1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-10-01 07:59:30 +00:00

6502: Correctly assign true view pointies; fixes #28

This commit is contained in:
Karol Stasiak 2019-12-30 14:25:46 +01:00
parent b2dd4eadd4
commit 709d3d0fcd
2 changed files with 27 additions and 1 deletions

View File

@ -66,7 +66,7 @@ sealed trait Constant {
}
def subbyte(index: Int): Constant = {
if (requiredSize <= index) Constant.Zero
if (requiredSize > 0 && requiredSize <= index) Constant.Zero
else index match {
case 0 => if (isProvablyDivisibleBy256) Constant.Zero else loByte
case 1 => hiByte

View File

@ -176,4 +176,30 @@ class StructSuite extends FunSuite with Matchers {
m.readWord(0xc002) should equal(code.count(_ == '↑') + 8)
}
}
test("Boolean fields") {
val code =
"""
|struct Sprite {
| byte size,
| byte size2,
| byte size3,
| byte size4,
| bool x1,
| bool x,
| bool y,
| bool z
|}
|
|array(Sprite) sprites [20] @ $c000
|
|void main() {
| sprites[0].x = true
|}
|""".stripMargin
EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)(code){ m =>
m.readByte(0xc005) should equal(1)
}
}
}