From 4c2a81c45273333edc6e1df5d3d27aa8ec79ef4d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 21 Dec 2018 01:06:01 +0100 Subject: [PATCH] min/max byte arrays --- compiler/examples/comparison_ifs_byte.p8 | 4 +- compiler/examples/comparison_ifs_float.p8 | 4 +- compiler/examples/comparison_ifs_ubyte.p8 | 4 +- compiler/examples/comparison_ifs_uword.p8 | 4 +- compiler/examples/comparison_ifs_word.p8 | 4 +- compiler/examples/comparisons_byte.p8 | 6 +- compiler/examples/comparisons_float.p8 | 6 +- compiler/examples/comparisons_ubyte.p8 | 6 +- compiler/examples/comparisons_uword.p8 | 6 +- compiler/examples/comparisons_word.p8 | 6 +- compiler/examples/mandelbrot-c64.p8 | 8 +- compiler/examples/numbergame-c64.p8 | 4 +- compiler/examples/numbergame-novm.p8 | 58 +++++----- compiler/examples/test.p8 | 130 +++++++--------------- compiler/examples/test_maxmin.p8 | 34 +++--- prog8lib/mathlib.p8 | 2 +- prog8lib/prog8lib.p8 | 96 +++++++++++++--- 17 files changed, 201 insertions(+), 181 deletions(-) diff --git a/compiler/examples/comparison_ifs_byte.p8 b/compiler/examples/comparison_ifs_byte.p8 index 876f0a894..7d0410d87 100644 --- a/compiler/examples/comparison_ifs_byte.p8 +++ b/compiler/examples/comparison_ifs_byte.p8 @@ -10,7 +10,7 @@ byte v1 byte v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') v1 = 100 @@ -110,7 +110,7 @@ else c64.STROUT("error in 22>=22!\n") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') } diff --git a/compiler/examples/comparison_ifs_float.p8 b/compiler/examples/comparison_ifs_float.p8 index 37e1b8d1a..7fd223b6f 100644 --- a/compiler/examples/comparison_ifs_float.p8 +++ b/compiler/examples/comparison_ifs_float.p8 @@ -10,7 +10,7 @@ float v1 float v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') v1 = 1.11 @@ -110,7 +110,7 @@ else c64.STROUT("error in -22.2>=-22.2!\n") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') } diff --git a/compiler/examples/comparison_ifs_ubyte.p8 b/compiler/examples/comparison_ifs_ubyte.p8 index c73a89c0d..262a7db10 100644 --- a/compiler/examples/comparison_ifs_ubyte.p8 +++ b/compiler/examples/comparison_ifs_ubyte.p8 @@ -10,7 +10,7 @@ ubyte v1 ubyte v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') v1 = 100 @@ -110,7 +110,7 @@ else c64.STROUT("error in 22>=22!\n") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') } diff --git a/compiler/examples/comparison_ifs_uword.p8 b/compiler/examples/comparison_ifs_uword.p8 index c2c85bff8..6975f0f06 100644 --- a/compiler/examples/comparison_ifs_uword.p8 +++ b/compiler/examples/comparison_ifs_uword.p8 @@ -10,7 +10,7 @@ uword v1 uword v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') v1 = 100 @@ -110,7 +110,7 @@ else c64.STROUT("error in 322>=322!\n") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') } diff --git a/compiler/examples/comparison_ifs_word.p8 b/compiler/examples/comparison_ifs_word.p8 index 33f4529c2..bb288b69c 100644 --- a/compiler/examples/comparison_ifs_word.p8 +++ b/compiler/examples/comparison_ifs_word.p8 @@ -10,7 +10,7 @@ word v1 word v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') v1 = 100 @@ -110,7 +110,7 @@ else c64.STROUT("error in -222>=-222!\n") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') } diff --git a/compiler/examples/comparisons_byte.p8 b/compiler/examples/comparisons_byte.p8 index 6f8d3dbf3..063a7a743 100644 --- a/compiler/examples/comparisons_byte.p8 +++ b/compiler/examples/comparisons_byte.p8 @@ -11,7 +11,7 @@ ; check stack usage: c64.STROUT("signed byte ") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT(' ') cr=v1==v2 @@ -39,7 +39,7 @@ cr=v1>=v2 cr=v1>=v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') ; comparisons: @@ -58,7 +58,7 @@ c64.STROUT("v1=20, v2=-111\n") compare() - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') return diff --git a/compiler/examples/comparisons_float.p8 b/compiler/examples/comparisons_float.p8 index f930ed250..954464ffa 100644 --- a/compiler/examples/comparisons_float.p8 +++ b/compiler/examples/comparisons_float.p8 @@ -13,7 +13,7 @@ ; check stack usage: c64.STROUT("floating point ") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT(' ') cr=v1==v2 @@ -41,7 +41,7 @@ cr=v1>=v2 cr=v1>=v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') ; comparisons: @@ -75,7 +75,7 @@ c64.STROUT("v1 = v2 = 0\n") compare() - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') return diff --git a/compiler/examples/comparisons_ubyte.p8 b/compiler/examples/comparisons_ubyte.p8 index 61f0d32df..0b420b9cb 100644 --- a/compiler/examples/comparisons_ubyte.p8 +++ b/compiler/examples/comparisons_ubyte.p8 @@ -11,7 +11,7 @@ ; check stack usage: c64.STROUT("unsigned byte ") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT(' ') cr=v1==v2 @@ -39,7 +39,7 @@ cr=v1>=v2 cr=v1>=v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') ; comparisons: @@ -58,7 +58,7 @@ c64.STROUT("v1=220, v2=10\n") compare() - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') return diff --git a/compiler/examples/comparisons_uword.p8 b/compiler/examples/comparisons_uword.p8 index 24bde4ad0..d5f6cd0b3 100644 --- a/compiler/examples/comparisons_uword.p8 +++ b/compiler/examples/comparisons_uword.p8 @@ -11,7 +11,7 @@ ; check stack usage: c64.STROUT("unsigned word ") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT(' ') cr=v1==v2 @@ -39,7 +39,7 @@ cr=v1>=v2 cr=v1>=v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') ; comparisons: @@ -88,7 +88,7 @@ c64.STROUT("v1 = v2 = aa\n") compare() - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') return diff --git a/compiler/examples/comparisons_word.p8 b/compiler/examples/comparisons_word.p8 index 0c0ad2e12..ce289c804 100644 --- a/compiler/examples/comparisons_word.p8 +++ b/compiler/examples/comparisons_word.p8 @@ -12,7 +12,7 @@ ; check stack usage: c64.STROUT("signed word ") - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT(' ') cr=v1==v2 @@ -40,7 +40,7 @@ cr=v1>=v2 cr=v1>=v2 - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') ; comparisons: @@ -125,7 +125,7 @@ c64.STROUT("v1 = v2 = aa\n") compare() - c64scr.print_ubyte(X) + c64scr.print_ub(X) c64.CHROUT('\n') return diff --git a/compiler/examples/mandelbrot-c64.p8 b/compiler/examples/mandelbrot-c64.p8 index 63cdca32d..0d8a2670c 100644 --- a/compiler/examples/mandelbrot-c64.p8 +++ b/compiler/examples/mandelbrot-c64.p8 @@ -7,7 +7,7 @@ const ubyte max_iter = 16 sub start() { - c64scr.print_string("calculating mandelbrot fractal...\n") + c64scr.print("calculating mandelbrot fractal...\n") c64.TIME_HI=0 c64.TIME_MID=0 @@ -38,8 +38,8 @@ c64.CHROUT('\n') } float duration = floor((c64.TIME_LO + c64.TIME_MID*256.0 + c64.TIME_HI*65536.0)/60.0) - c64scr.print_string("finished in ") - c64flt.print_float(duration) - c64scr.print_string(" seconds!\n") + c64scr.print("finished in ") + c64flt.print_f(duration) + c64scr.print(" seconds!\n") } } diff --git a/compiler/examples/numbergame-c64.p8 b/compiler/examples/numbergame-c64.p8 index 053c89a37..35dbddc0b 100644 --- a/compiler/examples/numbergame-c64.p8 +++ b/compiler/examples/numbergame-c64.p8 @@ -39,7 +39,7 @@ ask_guess: c64.STROUT("\nYou have ") - c64scr.print_ubyte(attempts_left) + c64scr.print_ub(attempts_left) c64.STROUT(" guess") if(attempts_left>1) c64.STROUT("es") @@ -66,7 +66,7 @@ ask_guess: ; game over. c64.STROUT("\nToo bad! It was: ") - c64scr.print_ubyte(secretnumber) + c64scr.print_ub(secretnumber) c64.CHROUT('\n') goodbye: diff --git a/compiler/examples/numbergame-novm.p8 b/compiler/examples/numbergame-novm.p8 index d98935501..eba15be61 100644 --- a/compiler/examples/numbergame-novm.p8 +++ b/compiler/examples/numbergame-novm.p8 @@ -13,48 +13,48 @@ ubyte secretnumber = rnd() % 99 + 1 ; random number 1..100 c64.VMCSB |= 2 ; switch lowercase chars - c64scr.print_string("Please introduce yourself: ") + c64scr.print("Please introduce yourself: ") c64scr.input_chars(name) - c64scr.print_string("\n\nHello, ") - c64scr.print_string(name) - c64scr.print_string(".\nLet's play a number guessing game.\nI am thinking of a number from 1 to 100!You'll have to guess it!\n") + c64scr.print("\n\nHello, ") + c64scr.print(name) + c64scr.print(".\nLet's play a number guessing game.\nI am thinking of a number from 1 to 100!You'll have to guess it!\n") for ubyte attempts_left in 10 to 1 step -1 { ; stackptr debugging -; c64scr.print_byte(X) +; c64scr.print_b(X) ; c64.CHROUT('\n') - c64scr.print_string("\nYou have ") - c64scr.print_ubyte(attempts_left) - c64scr.print_string(" guess") + c64scr.print("\nYou have ") + c64scr.print_ub(attempts_left) + c64scr.print(" guess") if attempts_left>1 - c64scr.print_string("es") - c64scr.print_string(" left.\nWhat is your next guess? ") + c64scr.print("es") + c64scr.print(" left.\nWhat is your next guess? ") c64scr.input_chars(input) ubyte guess = str2ubyte(input) ; debug info -; c64scr.print_string(" > attempts left=") -; c64scr.print_byte(attempts_left) -; c64scr.print_string("\n > secretnumber=") -; c64scr.print_byte(secretnumber) -; c64scr.print_string("\n > input=") -; c64scr.print_string(input) -; c64scr.print_string("\n > guess=") -; c64scr.print_byte(guess) +; c64scr.print(" > attempts left=") +; c64scr.print_b(attempts_left) +; c64scr.print("\n > secretnumber=") +; c64scr.print_b(secretnumber) +; c64scr.print("\n > input=") +; c64scr.print(input) +; c64scr.print("\n > guess=") +; c64scr.print_b(guess) ; c64.CHROUT('\n') -; c64scr.print_byte(X) ; stackptr debugging +; c64scr.print_b(X) ; stackptr debugging ; c64.CHROUT('\n') if guess==secretnumber { return ending(true) } else { - c64scr.print_string("\n\nThat is too ") + c64scr.print("\n\nThat is too ") if guess_rndf_rnum5 jmp push_float -_rndf_rnum5 .fill 5 +_rndf_rnum5 .byte 0,0,0,0,0 .pend