examples issues

This commit is contained in:
Irmen de Jong 2020-10-07 01:21:41 +02:00
parent 3e181362dd
commit 2b48828179
8 changed files with 49 additions and 13 deletions

View File

@ -57,7 +57,7 @@ class VerifyFunctionArgTypes(val program: Program) : IAstVisitor {
// they MIGHT work in a regular assignment or just a function call statement. // 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 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) { 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)"
} }
} }
} }

View File

@ -10,8 +10,7 @@
; You load it with LOAD "diskdir-sys50000",8,1 ; You load it with LOAD "diskdir-sys50000",8,1
; and then call it with SYS 50000. ; 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 { main {
sub start() { sub start() {
@ -22,15 +21,20 @@ main {
sub diskdir(ubyte drivenumber) { sub diskdir(ubyte drivenumber) {
c64.SETNAM(1, "$") c64.SETNAM(1, "$")
c64.SETLFS(1, drivenumber, 0) c64.SETLFS(1, drivenumber, 0)
c64.OPEN() ; open 1,8,0,"$" void c64.OPEN() ; open 1,8,0,"$"
c64.CHKIN(1) ; use #1 as input channel if_cs
goto io_error
void c64.CHKIN(1) ; use #1 as input channel
if_cs
goto io_error
repeat 4 { repeat 4 {
void c64.CHRIN() ; skip the 4 prologue bytes void c64.CHRIN() ; skip the 4 prologue bytes
} }
; while not key pressed / EOF encountered, read data. ; 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.print_uw(mkword(c64.CHRIN(), c64.CHRIN()))
txt.chrout(' ') txt.chrout(' ')
ubyte @zp char ubyte @zp char
@ -42,9 +46,22 @@ main {
repeat 2 { repeat 2 {
void c64.CHRIN() ; skip 2 bytes void c64.CHRIN() ; skip 2 bytes
} }
status = c64.READST()
c64.STOP()
if_nz
break
} }
io_error:
status = c64.READST()
c64.CLOSE(1) c64.CLOSE(1)
c64.CLRCHN() ; restore default i/o devices 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')
}
} }
} }

View File

@ -4,7 +4,7 @@
%zeropage basicsafe %zeropage basicsafe
; This example shows the directory contents of disk drive 8. ; 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 { main {
sub start() { sub start() {
@ -15,8 +15,12 @@ main {
sub diskdir(ubyte drivenumber) { sub diskdir(ubyte drivenumber) {
c64.SETNAM(1, "$") c64.SETNAM(1, "$")
c64.SETLFS(1, drivenumber, 0) c64.SETLFS(1, drivenumber, 0)
void c64.OPEN() ; open 1,8,0,"$" ; TODO handle error condition in carry/A void c64.OPEN() ; open 1,8,0,"$"
void c64.CHKIN(1) ; use #1 as input channel ; TODO handle error condition in carry/A if_cs
goto io_error
void c64.CHKIN(1) ; use #1 as input channel
if_cs
goto io_error
repeat 4 { repeat 4 {
void c64.CHRIN() ; skip the 4 prologue bytes void c64.CHRIN() ; skip the 4 prologue bytes
@ -24,7 +28,7 @@ main {
; while not key pressed / EOF encountered, read data. ; while not key pressed / EOF encountered, read data.
ubyte status = c64.READST() 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.print_uw(mkword(c64.CHRIN(), c64.CHRIN()))
txt.chrout(' ') txt.chrout(' ')
ubyte @zp char ubyte @zp char
@ -37,8 +41,14 @@ main {
void c64.CHRIN() ; skip 2 bytes void c64.CHRIN() ; skip 2 bytes
} }
status = c64.READST() status = c64.READST()
c64.STOP()
if_nz
break
} }
io_error:
status = c64.READST()
c64.CLOSE(1) c64.CLOSE(1)
c64.CLRCHN() ; restore default i/o devices c64.CLRCHN() ; restore default i/o devices
@ -47,6 +57,5 @@ main {
txt.print_ub(status) txt.print_ub(status)
txt.chrout('\n') txt.chrout('\n')
} }
} }
} }

View File

@ -8,6 +8,9 @@
; Note: this program is compatible with C64 and CX16. ; Note: this program is compatible with C64 and CX16.
; TODO fix compiler crash
main { main {
const ubyte width = 255 const ubyte width = 255
const ubyte height = 200 const ubyte height = 200

View File

@ -249,8 +249,10 @@ waitkey:
txt.print("────────────────────────") txt.print("────────────────────────")
c64.CHROUT('K') c64.CHROUT('K')
while c64.GETIN()!=133 { ubyte key = 0
while key!=133 {
; endless loop until user presses F1 to restart the game ; endless loop until user presses F1 to restart the game
key = c64.GETIN()
} }
} }

View File

@ -8,6 +8,9 @@ main {
str planet_name = "12345678" str planet_name = "12345678"
sub start() { 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 c64.OPEN() ; works: function call droppign the value but preserving the statusregister
if_cs if_cs
return return

View File

@ -16,7 +16,7 @@ main {
str s1 = "hello" str s1 = "hello"
str s2 = @"screencodes" str s2 = @"screencodes"
&str ms1 = $c000 &str ms1 = $c000 ; TODO fix invalid error message
byte[4] barray byte[4] barray

View File

@ -2,6 +2,8 @@
%zeropage basicsafe %zeropage basicsafe
%option no_sysinit %option no_sysinit
; TODO fix compiler crash
main { main {
sub start() { sub start() {
txt.lowercase() txt.lowercase()