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.
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)"
}
}
}

View File

@ -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')
}
}
}

View File

@ -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')
}
}
}

View File

@ -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

View File

@ -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()
}
}

View File

@ -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

View File

@ -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

View File

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