diff --git a/examples/c64/calculator.mfk b/examples/c64/calculator.mfk new file mode 100644 index 00000000..c716fc94 --- /dev/null +++ b/examples/c64/calculator.mfk @@ -0,0 +1,31 @@ +import stdio +import c64_basic + +array text1 = [ "enter first number:" petscii, 13, 0 ] +array text2 = [ "enter second number:" petscii, 13, 0 ] +array text3 = [ "the sum is:" petscii, 13, 0 ] +array texte = [ "that wasn't a number, try again:" petscii, 13, 0 ] + +void main() { + word a + word b + + putstrz(text1) + a = readword() + while readword_err != 0 { + putstrz(texte) + a = readword() + } + + putstrz(text2) + b = readword() + while readword_err != 0 { + putstrz(texte) + b = readword() + } + + putstrz(text3) + a += b + putword(a) + putchar(13) +} diff --git a/examples/c64/echo.mfk b/examples/c64/echo.mfk new file mode 100644 index 00000000..f6fa9bee --- /dev/null +++ b/examples/c64/echo.mfk @@ -0,0 +1,11 @@ +import c64_basic +import stdio +void main() { + while true { + readline() + // empty line is read as a single space + if readline_out[0] == 32 && readline_out[1] == 0 { return } + putstrz(readline_out) + putchar(13) + } +}