zxbasic icon indicating copy to clipboard operation
zxbasic copied to clipboard

INPUT command not working

Open bwganblack opened this issue 3 years ago • 6 comments

The INPUT command generates a flashing cursor but is otherwise unresponsive. Tested with the example file:

#include <input.bas>

print at 10, 5; "Type something: ";
a$ = input(20)
print
print "You typed: "; a$

Using Nextbuildv7, ZXbasic ver : 1.15.2

The problem appears to be line 42 of input.bas: DO LOOP UNTIL LastK <> 0 The program gets stuck in this loop and pressing a key doesn't exit it, proven by inserting a BEEP command into the loop.

Using labels and GOTO commands to replace both the DO...LOOPS in the INPUT function, I was able to create a ersatz version which works. Not sure if this is a bug or if I'm missing something obvious

Thanks.

bwganblack avatar Oct 04 '21 10:10 bwganblack

Are you compiling using -O4? This optimization is too aggressive for this routine (LastK is a Volatile variable and it's not supported yet). If so, compiling with -O3 should work.

PS: I thought you were a spammer and accidentally deleted your account. If you want to participate, please feel free to re-register in the forum. Sorry for the inconvenience!

boriel avatar Oct 08 '21 22:10 boriel

Update: This function was successfully tested on ZX 128k. I'll test on the ZX Next and let you know.

boriel avatar Oct 08 '21 22:10 boriel

I'm compiling through Nextbuild, presumably using the default optimization level as I haven't even looked into how I would change this yet. I'm just using emulators: I've generated a NEX file and run it on CSpect and I've generated a TAP file and run it on Zero. Same result, unresponsive.

PS: I'd love to participate on the forum but I'm getting an ERROR 403 - Forbidden! message when I try to connect to any page. Perhaps my IP address is blocked? Apologies if I appeared to be spamming. I wasn't receiving the activation email and thought I might have filled in my details wrong. Is this sent out automatically or manually? Perhaps I just needed to be more patient!

bwganblack avatar Oct 09 '21 17:10 bwganblack

Hi, If you're using NextBuild you should really be including nextlib.bas

The problem is that IY is not correctly pointing to the start of SYSVARS if you do not include nextlib.bas as this fix already exits : https://github.com/em00k/NextBuild/blob/3b1eb79d257d1d4a42aadd4b1dd895509f09f677/Scripts/nextlib.bas#L3506

This is due to CSpect not initialising the ROM on startup when launching NEX directly.

asm  
    ld iy,$5c3a	
end asm 

#include <input.bas>

print at 10, 5; "Type something: ";
a$ = input(20)
print
print "You typed: "; a$

Should fix the issue.

em00k avatar Oct 14 '21 16:10 em00k

Hi @em00k , I tried your code above and tried adding #include <nextlib.bas>. No joy. Also updated nextlib.bas to v7.5 and nextlib.py to v7.3. Still not working I'm afraid.

bwganblack avatar Oct 14 '21 18:10 bwganblack

OK, I have downloaded the git repo and can see this isnt working as expected. Leave it with me to find out what else is the issue.

em00k avatar Oct 15 '21 10:10 em00k

Coming back to this, I found how to change the optimization level when compiling with NextBuild/VS Code by editing the nextbuild.py file. You were quite correct @boriel, changing from level 4 (the default) to level 3 allows the above code to work.

I tested by generating a .tap file and running using Zero v0.7.1. By adding #include <nextlib.bas> it will also work when generating a .nex file and running using CSpect v2.15.1 (but not without).

Tested with ZXBasic v.1.16.4 and NextBuild v.7.3.1.

Thanks.

bwganblack avatar Nov 26 '22 11:11 bwganblack