Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INPUT command not working #571

Closed
bwganblack opened this issue Oct 4, 2021 · 7 comments
Closed

INPUT command not working #571

bwganblack opened this issue Oct 4, 2021 · 7 comments

Comments

@bwganblack
Copy link

bwganblack commented Oct 4, 2021

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.

@boriel
Copy link
Owner

boriel commented Oct 8, 2021

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
Copy link
Owner

boriel commented Oct 8, 2021

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

@bwganblack
Copy link
Author

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!

@em00k
Copy link

em00k commented Oct 14, 2021

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.

@bwganblack
Copy link
Author

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.

@em00k
Copy link

em00k commented Oct 15, 2021

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.

@bwganblack
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants