diff --git a/compiler/src/prog8/ast/processing/VerifyFunctionArgTypes.kt b/compiler/src/prog8/ast/processing/VerifyFunctionArgTypes.kt index 100402e83..584ee6c87 100644 --- a/compiler/src/prog8/ast/processing/VerifyFunctionArgTypes.kt +++ b/compiler/src/prog8/ast/processing/VerifyFunctionArgTypes.kt @@ -57,7 +57,7 @@ class VerifyFunctionArgTypes(val program: Program) : IAstVisitor { // they MIGHT work in a regular assignment or just a function call statement. val parent = if(call is Statement) call.parent else if(call is Expression) call.parent else null if(call !is FunctionCallStatement && parent !is Assignment && parent !is VarDecl) { - return "can't use multiple return values here" + return "can't use subroutine call that returns multiple return values here (try moving it into a separate assignment)" } } } diff --git a/examples/diskdir-sys50000.p8 b/examples/diskdir-sys50000.p8 index 50e2d955f..7cadb2023 100644 --- a/examples/diskdir-sys50000.p8 +++ b/examples/diskdir-sys50000.p8 @@ -10,8 +10,7 @@ ; You load it with LOAD "diskdir-sys50000",8,1 ; and then call it with SYS 50000. -; TODO once diskdir.p8 is done, change this program as well. - +; The only difference with diskdir.p8 is the directives that make this load at 50000. main { sub start() { @@ -22,15 +21,20 @@ main { sub diskdir(ubyte drivenumber) { c64.SETNAM(1, "$") c64.SETLFS(1, drivenumber, 0) - c64.OPEN() ; open 1,8,0,"$" - c64.CHKIN(1) ; use #1 as input channel + void c64.OPEN() ; open 1,8,0,"$" + if_cs + goto io_error + void c64.CHKIN(1) ; use #1 as input channel + if_cs + goto io_error repeat 4 { void c64.CHRIN() ; skip the 4 prologue bytes } ; while not key pressed / EOF encountered, read data. - while not (@($c6) | c64.STATUS) { + ubyte status = c64.READST() + while not status { txt.print_uw(mkword(c64.CHRIN(), c64.CHRIN())) txt.chrout(' ') ubyte @zp char @@ -42,9 +46,22 @@ main { repeat 2 { void c64.CHRIN() ; skip 2 bytes } + status = c64.READST() + + c64.STOP() + if_nz + break } +io_error: + status = c64.READST() c64.CLOSE(1) c64.CLRCHN() ; restore default i/o devices + + if status and status != 64 { ; 64=end of file + txt.print("\ni/o error, status: ") + txt.print_ub(status) + txt.chrout('\n') + } } } diff --git a/examples/diskdir.p8 b/examples/diskdir.p8 index d4f13da75..5a42e87ed 100644 --- a/examples/diskdir.p8 +++ b/examples/diskdir.p8 @@ -4,7 +4,7 @@ %zeropage basicsafe ; This example shows the directory contents of disk drive 8. -; Note: this program is compatible with C64 and CX16. TODO not yet on cx16 +; Note: this program is compatible with C64 and CX16. TODO not yet on cx16, fix the crash main { sub start() { @@ -15,8 +15,12 @@ main { sub diskdir(ubyte drivenumber) { c64.SETNAM(1, "$") c64.SETLFS(1, drivenumber, 0) - void c64.OPEN() ; open 1,8,0,"$" ; TODO handle error condition in carry/A - void c64.CHKIN(1) ; use #1 as input channel ; TODO handle error condition in carry/A + void c64.OPEN() ; open 1,8,0,"$" + if_cs + goto io_error + void c64.CHKIN(1) ; use #1 as input channel + if_cs + goto io_error repeat 4 { void c64.CHRIN() ; skip the 4 prologue bytes @@ -24,7 +28,7 @@ main { ; while not key pressed / EOF encountered, read data. ubyte status = c64.READST() - while not (@($c6) | status) { ; TODO replace $c6 by kernal function c64.STOP() once the multi-return and status flags thingy work + while not status { txt.print_uw(mkword(c64.CHRIN(), c64.CHRIN())) txt.chrout(' ') ubyte @zp char @@ -37,8 +41,14 @@ main { void c64.CHRIN() ; skip 2 bytes } status = c64.READST() + + c64.STOP() + if_nz + break } +io_error: + status = c64.READST() c64.CLOSE(1) c64.CLRCHN() ; restore default i/o devices @@ -47,6 +57,5 @@ main { txt.print_ub(status) txt.chrout('\n') } - } } diff --git a/examples/mandelbrot-gfx.p8 b/examples/mandelbrot-gfx.p8 index b83f07f7b..85239ff54 100644 --- a/examples/mandelbrot-gfx.p8 +++ b/examples/mandelbrot-gfx.p8 @@ -8,6 +8,9 @@ ; Note: this program is compatible with C64 and CX16. +; TODO fix compiler crash + + main { const ubyte width = 255 const ubyte height = 200 diff --git a/examples/tehtriz.p8 b/examples/tehtriz.p8 index 1e16ffc01..1188e699c 100644 --- a/examples/tehtriz.p8 +++ b/examples/tehtriz.p8 @@ -249,8 +249,10 @@ waitkey: txt.print("────────────────────────") c64.CHROUT('K') - while c64.GETIN()!=133 { + ubyte key = 0 + while key!=133 { ; endless loop until user presses F1 to restart the game + key = c64.GETIN() } } diff --git a/examples/test.p8 b/examples/test.p8 index 14f7fcd97..4a78f09a2 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -8,6 +8,9 @@ main { str planet_name = "12345678" sub start() { + &str ms1 = $c000 ; TODO fix invalid error message . what about memory mapped array? memory mapped struct? + + c64.OPEN() ; works: function call droppign the value but preserving the statusregister if_cs return diff --git a/examples/testarrays.p8 b/examples/testarrays.p8 index e98f51f25..8f99a0d90 100644 --- a/examples/testarrays.p8 +++ b/examples/testarrays.p8 @@ -16,7 +16,7 @@ main { str s1 = "hello" str s2 = @"screencodes" - &str ms1 = $c000 + &str ms1 = $c000 ; TODO fix invalid error message byte[4] barray diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 654c40d6a..0fb270a48 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -2,6 +2,8 @@ %zeropage basicsafe %option no_sysinit +; TODO fix compiler crash + main { sub start() { txt.lowercase()