From cfc970e21a5f7ad8598efbb1525d399cec6c0e68 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 20 Jul 2020 15:26:48 +0200 Subject: [PATCH] added fetching PI to expression parser, fixed compilation warning --- src/basic/basic_commands/cmd_print.s | 2 ++ src/basic/engine_runtime/ad9e.frmevl.jmp.s | 8 +++++ .../{ad9e.frmevl.s => frmevl.s} | 30 +++++++++---------- tools/pngprepare.c | 5 +++- 4 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 src/basic/engine_runtime/ad9e.frmevl.jmp.s rename src/basic/engine_runtime/{ad9e.frmevl.s => frmevl.s} (95%) diff --git a/src/basic/basic_commands/cmd_print.s b/src/basic/basic_commands/cmd_print.s index 13faafdd..1110c46a 100644 --- a/src/basic/basic_commands/cmd_print.s +++ b/src/basic/basic_commands/cmd_print.s @@ -72,6 +72,8 @@ cmd_print_float: // XXX probably we should also check INTFLG here // XXX provide implementation + jmp do_NOT_IMPLEMENTED_error + // FALLTROUGH cmd_print_next_arg: diff --git a/src/basic/engine_runtime/ad9e.frmevl.jmp.s b/src/basic/engine_runtime/ad9e.frmevl.jmp.s new file mode 100644 index 00000000..5f01cd7b --- /dev/null +++ b/src/basic/engine_runtime/ad9e.frmevl.jmp.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// Just a compatibility jump - our routine is longer than original one + + jmp FRMEVL diff --git a/src/basic/engine_runtime/ad9e.frmevl.s b/src/basic/engine_runtime/frmevl.s similarity index 95% rename from src/basic/engine_runtime/ad9e.frmevl.s rename to src/basic/engine_runtime/frmevl.s index 9bc5cefd..fd42ecdc 100644 --- a/src/basic/engine_runtime/ad9e.frmevl.s +++ b/src/basic/engine_runtime/frmevl.s @@ -1,5 +1,4 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE @@ -19,7 +18,7 @@ // in a correct order // -// XXX finish the implementation: invoking functions, fetcching PI, fetching float, fetching variables +// XXX finish the implementation: invoking functions, fetching floats FRMEVL: @@ -78,7 +77,7 @@ FRMEVL_loop: dew TXTPTR #endif jsr fetch_variable - bcs !+ + bcs FRMEVL_fetch_float // Found the variable - copy descriptor to FAC1 @@ -116,17 +115,6 @@ FRMEVL_loop: jmp_8 FRMEVL_got_value -!: - // There is one possibility left - a floating point value - - - // XXX implement this part - - - // Nothing recognized - - jmp do_SYNTAX_error - // // This subroutine handles the situation when we have to execute a BASIC function // in place when parser normally expects a value @@ -175,9 +163,11 @@ FRMEVL_handle_bracket: FRMEVL_fetch_PI: - // XXX implement this + lda #const_PI + jsr mov_MEM_FAC1 - jmp do_NOT_IMPLEMENTED_error + jmp_8 FRMEVL_got_value_float // // This subroutine fetches the floating point value from the 'outside world' @@ -189,6 +179,14 @@ FRMEVL_fetch_float: jmp do_NOT_IMPLEMENTED_error + // FALLTROUGH + +FRMEVL_got_value_float: + + lda #$00 + sta VALTYP + beq FRMEVL_got_value + // // This subroutine fetches the string value from the 'outside world' // diff --git a/tools/pngprepare.c b/tools/pngprepare.c index 7c5b245c..8b5c6b5c 100644 --- a/tools/pngprepare.c +++ b/tools/pngprepare.c @@ -108,13 +108,16 @@ void abort_(const char * s, ...) void read_png_file(char* file_name) { unsigned char header[8]; // 8 is the maximum size that can be checked + size_t readResult; /* open file and test for it being a png */ infile = fopen(file_name, "rb"); if (infile == NULL) abort_("[read_png_file] File %s could not be opened for reading", file_name); - fread(header, 1, 8, infile); + readResult = fread(header, 1, 8, infile); + if (readResult != 8) + abort_("[read_png_file] File %s could not be read", file_name); if (png_sig_cmp(header, 0, 8)) abort_("[read_png_file] File %s is not recognized as a PNG file", file_name);