From c532e288413f38ad941e94f76f31d19b41e5ec7f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 28 Feb 2024 00:34:35 +0100 Subject: [PATCH] fix several remaining bool return values in library routines --- compiler/res/prog8lib/c128/syslib.p8 | 2 +- compiler/res/prog8lib/c64/syslib.p8 | 2 +- compiler/res/prog8lib/cx16/diskio.p8 | 6 +++--- compiler/res/prog8lib/cx16/monogfx.p8 | 10 +++++----- compiler/res/prog8lib/cx16/syslib.p8 | 4 ++-- compiler/res/prog8lib/diskio.p8 | 2 +- compiler/res/prog8lib/pet32/syslib.p8 | 2 +- compiler/res/prog8lib/virtual/monogfx.p8 | 10 +++++----- docs/source/todo.rst | 3 +-- examples/cx16/diskspeed.p8 | 2 +- 10 files changed, 21 insertions(+), 22 deletions(-) diff --git a/compiler/res/prog8lib/c128/syslib.p8 b/compiler/res/prog8lib/c128/syslib.p8 index 8cb1ade99..19bea70ff 100644 --- a/compiler/res/prog8lib/c128/syslib.p8 +++ b/compiler/res/prog8lib/c128/syslib.p8 @@ -105,7 +105,7 @@ romsub $FFF3 = IOBASE() -> uword @ XY ; read base addr ; ---- utilities ----- -asmsub STOP2() clobbers(X) -> ubyte @A { +asmsub STOP2() clobbers(X) -> bool @A { ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. %asm {{ jsr cbm.STOP diff --git a/compiler/res/prog8lib/c64/syslib.p8 b/compiler/res/prog8lib/c64/syslib.p8 index e1fdd2063..7968bff7a 100644 --- a/compiler/res/prog8lib/c64/syslib.p8 +++ b/compiler/res/prog8lib/c64/syslib.p8 @@ -102,7 +102,7 @@ romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X. romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices -asmsub STOP2() clobbers(X) -> ubyte @A { +asmsub STOP2() clobbers(X) -> bool @A { ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. %asm {{ jsr cbm.STOP diff --git a/compiler/res/prog8lib/cx16/diskio.p8 b/compiler/res/prog8lib/cx16/diskio.p8 index b8d9fdf3b..89f6d47a5 100644 --- a/compiler/res/prog8lib/cx16/diskio.p8 +++ b/compiler/res/prog8lib/cx16/diskio.p8 @@ -70,7 +70,7 @@ diskio { void cbm.CHRIN() ; skip 2 bytes void cbm.CHRIN() status = cbm.READST() - if cbm.STOP2()!=0 + if cbm.STOP2() break } status = cbm.READST() @@ -659,7 +659,7 @@ io_error: return $2000 * (cx16.getrambank() - startbank) + endaddress - startaddress } - asmsub vload(str name @R0, ubyte bank @A, uword startaddress @R1) clobbers(X, Y) -> ubyte @A { + asmsub vload(str name @R0, ubyte bank @A, uword startaddress @R1) clobbers(X, Y) -> bool @A { ; -- like the basic command VLOAD "filename",drivenumber,bank,address ; loads a file into Vera's video memory in the given bank:address, returns success in A ; the file has to have the usual 2 byte header (which will be skipped) @@ -698,7 +698,7 @@ internal_vload: }} } - asmsub vload_raw(str name @R0, ubyte bank @A, uword startaddress @R1) clobbers(X, Y) -> ubyte @A { + asmsub vload_raw(str name @R0, ubyte bank @A, uword startaddress @R1) clobbers(X, Y) -> bool @A { ; -- like the basic command BVLOAD "filename",drivenumber,bank,address ; loads a file into Vera's video memory in the given bank:address, returns success in A ; the file is read fully including the first two bytes. diff --git a/compiler/res/prog8lib/cx16/monogfx.p8 b/compiler/res/prog8lib/cx16/monogfx.p8 index 62fb1ad38..43b6fcf64 100644 --- a/compiler/res/prog8lib/cx16/monogfx.p8 +++ b/compiler/res/prog8lib/cx16/monogfx.p8 @@ -606,7 +606,7 @@ _done plot(xx, yy, draw) } - sub pget(uword @zp xx, uword yy) -> ubyte { + sub pget(uword @zp xx, uword yy) -> bool { %asm {{ lda p8v_xx and #7 @@ -708,7 +708,7 @@ _done }} yy+=dy } - cx16.r11L = pget(xx as uword, yy as uword) ; old_color + cx16.r11L = pget(xx as uword, yy as uword) as ubyte ; old_color if cx16.r11L == cx16.r10L return if xx<0 or xx>width-1 or yy<0 or yy>height-1 @@ -720,7 +720,7 @@ _done pop_stack() xx = x1 while xx >= 0 { - if pget(xx as uword, yy as uword) != cx16.r11L + if pget(xx as uword, yy as uword) as ubyte != cx16.r11L break xx-- } @@ -737,7 +737,7 @@ _done do { cx16.r9s = xx while xx <= width-1 { - if pget(xx as uword, yy as uword) != cx16.r11L + if pget(xx as uword, yy as uword) as ubyte != cx16.r11L break xx++ } @@ -750,7 +750,7 @@ _done skip: xx++ while xx <= x2 { - if pget(xx as uword, yy as uword) == cx16.r11L + if pget(xx as uword, yy as uword) as ubyte == cx16.r11L break xx++ } diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index d018dcd06..343f449cc 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -53,8 +53,8 @@ romsub $FFF3 = IOBASE() -> uword @ XY ; read base addr ; ---- utility -asmsub STOP2() clobbers(X) -> ubyte @A { - ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. +asmsub STOP2() clobbers(X) -> bool @A { + ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the zero status flag. %asm {{ jsr cbm.STOP beq + diff --git a/compiler/res/prog8lib/diskio.p8 b/compiler/res/prog8lib/diskio.p8 index 9ad6701d5..42a022983 100644 --- a/compiler/res/prog8lib/diskio.p8 +++ b/compiler/res/prog8lib/diskio.p8 @@ -59,7 +59,7 @@ diskio { void cbm.CHRIN() ; skip 2 bytes void cbm.CHRIN() status = cbm.READST() - if cbm.STOP2()!=0 + if cbm.STOP2() break } status = cbm.READST() diff --git a/compiler/res/prog8lib/pet32/syslib.p8 b/compiler/res/prog8lib/pet32/syslib.p8 index ba092e6b8..b9e817dd2 100644 --- a/compiler/res/prog8lib/pet32/syslib.p8 +++ b/compiler/res/prog8lib/pet32/syslib.p8 @@ -34,7 +34,7 @@ romsub $FFE4 = GETIN() clobbers(X,Y) -> bool @Pc, ubyte @ A ; get a characte romsub $FFE7 = CLALL() clobbers(A,X) ; close all files romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock -asmsub STOP2() clobbers(X) -> ubyte @A { +asmsub STOP2() clobbers(X) -> bool @A { ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. %asm {{ jsr cbm.STOP diff --git a/compiler/res/prog8lib/virtual/monogfx.p8 b/compiler/res/prog8lib/virtual/monogfx.p8 index a78f8f6a3..be6d34055 100644 --- a/compiler/res/prog8lib/virtual/monogfx.p8 +++ b/compiler/res/prog8lib/virtual/monogfx.p8 @@ -359,8 +359,8 @@ monogfx { plot(xx, yy, draw) } - sub pget(uword @zp xx, uword yy) -> ubyte { - return sys.gfx_getpixel(xx, yy) + sub pget(uword @zp xx, uword yy) -> bool { + return sys.gfx_getpixel(xx, yy) as bool } sub fill(uword x, uword y, bool draw) { @@ -411,7 +411,7 @@ monogfx { pop_stack() xx = x1 while xx >= 0 { - if pget(xx as uword, yy as uword) != cx16.r11L + if pget(xx as uword, yy as uword) as ubyte != cx16.r11L break xx-- } @@ -428,7 +428,7 @@ monogfx { do { cx16.r9 = xx as uword while xx <= width-1 { - if pget(xx as uword, yy as uword) != cx16.r11L + if pget(xx as uword, yy as uword) as ubyte != cx16.r11L break xx++ } @@ -441,7 +441,7 @@ monogfx { skip: xx++ while xx <= x2 { - if pget(xx as uword, yy as uword) == cx16.r11L + if pget(xx as uword, yy as uword) as ubyte == cx16.r11L break xx++ } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 386fc5acb..87a909004 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,10 +1,9 @@ TODO ==== -floatparse is a lot larger +floatparse is a lot larger (if string.isdigit() -> uses rols instead of just bcc) snow is a lot larger neofetch is larger -chess is larger diff --git a/examples/cx16/diskspeed.p8 b/examples/cx16/diskspeed.p8 index cfc20baba..4f5fa7e5a 100644 --- a/examples/cx16/diskspeed.p8 +++ b/examples/cx16/diskspeed.p8 @@ -50,7 +50,7 @@ main { txt.print("\nreading 64kb using vload() into vram") cbm.SETTIM(0,0,0) - if diskio.vload("benchmark.dat", 0, $0000)==0 + if not diskio.vload("benchmark.dat", 0, $0000) sys.exit(1) print_speed(cbm.RDTIM16())