diff --git a/docs/source/todo.rst b/docs/source/todo.rst index a3ccbf173..8e0499d74 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,9 +3,6 @@ TODO For next minor release ^^^^^^^^^^^^^^^^^^^^^^ -- fix IR/VM: animals.p8 example is borked, it jumps straight to a suggestion and then somehow doesn't print the animal name correctly in the first question, and exits after 1 animal instead of looping - this has happened after v8.7: caused by c21913a6 ir: keep order of children in block 22-11-2022 - ... diff --git a/examples/cx16/keyboardhandler.p8 b/examples/cx16/keyboardhandler.p8 index 2a4d266f8..06a3dff18 100644 --- a/examples/cx16/keyboardhandler.p8 +++ b/examples/cx16/keyboardhandler.p8 @@ -2,6 +2,9 @@ %zeropage basicsafe %option no_sysinit +; The documentation for custom PS2 key handlers can be found here: +; https://github.com/X16Community/x16-docs/blob/master/X16%20Reference%20-%2002%20-%20Editor.md#custom-keyboard-scancode-handler + main { sub start() { @@ -69,6 +72,9 @@ main { ; Unfortunately this also means you cannot decide from that prog8 code ; if the keyboard press should be consumed/ignored or put into the keyboard queue ; (this is controlled by returning 0 or 1 in register A here) + ; + ; see: + ; https://github.com/X16Community/x16-docs/tree/X16%20Reference%20-%2002%20-%20Editor.md#custom-keyboard-scancode-handler %asm {{ php diff --git a/virtualmachine/src/prog8/vm/VmProgramLoader.kt b/virtualmachine/src/prog8/vm/VmProgramLoader.kt index 6a67c946c..ab3235b54 100644 --- a/virtualmachine/src/prog8/vm/VmProgramLoader.kt +++ b/virtualmachine/src/prog8/vm/VmProgramLoader.kt @@ -23,9 +23,11 @@ class VmProgramLoader { // make sure that if there is a "main.start" entrypoint, we jump to it irProgram.blocks.firstOrNull()?.let { if(it.children.any { sub -> sub is IRSubroutine && sub.label=="main.start" }) { - val chunk = IRCodeChunk(null, null) + val previous = programChunks.lastOrNull() + val chunk = IRCodeChunk(null, previous) placeholders[Pair(chunk, 0)] = "main.start" chunk += IRInstruction(Opcode.JUMP, labelSymbol = "main.start") + previous?.let { p -> p.next = chunk } programChunks += chunk } }