Forum
PAUSE not working (*solved*) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: PAUSE not working (*solved*) (/showthread.php?tid=993)

Pages: 1 2


PAUSE not working (*solved*) - patters - 12-29-2020

In my program PAUSE doesn't seem to work. Is that normal? I would find it useful to delay execution a bit while my program prints an error on screen when the result of an INPUT isn't compliant. I can't see any mention of PAUSE in the wiki. I mean I can use a FOR loop to count to 10,000 instead, but I thought the aim of Boriel BASIC is to be a faster superset of Sinclair BASIC so it's surprising this seems to be missing.


RE: PAUSE - patters - 12-29-2020

For the time being I have copied a Sub from the Berks Man source code which does the job using the CPU's HALT instruction:
Code:
SUB Wait(w AS uInteger)
    'Pause for w frames
    WHILE w > 0
        w=w-1
        ASM
        HALT
        END ASM
    END WHILE
END SUB



RE: PAUSE - boriel - 12-29-2020

(12-29-2020, 03:56 AM)patters Wrote: In my program PAUSE doesn't seem to work. Is that normal? I would find it useful to delay execution a bit while my program prints an error on screen when the result of an INPUT isn't compliant. I can't see any mention of PAUSE in the wiki. I mean I can use a FOR loop to count to 10,000 instead, but I thought the aim of Boriel BASIC is to be a faster superset of Sinclair BASIC so it's surprising this seems to be missing.

PAUSE is implemented and it's just a call to the ROM pause (which basically does what your sub does). Are you disabling the interruptions with DI or something?

I've just tested it and it works:
Code:
PAUSE 50
PRINT "HELLO"

Will wait for 50 frames and then print the message. Remember that pause can be cancelled by pressing a key Wink


RE: PAUSE - patters - 12-29-2020

No, the only other bit of ASM is some DEFBs to define UDGs. I am using the input.bas library, could that be impacting things?


RE: PAUSE - boriel - 12-29-2020

That's it!!
Apparently INPUT does something that makes the next PAUSE to be ignored (further PAUSE's will be taking into account).
Thanks for the report. Will investigate this!


RE: PAUSE - boriel - 12-29-2020

Ok. Seems I got it.
I will fix it in the next release. In the mean time, you can avoid the bug but doing:
Code:
POKE 23611, PEEK 23611 bAND 0xEF
after calling INPUT. It seems bit 5 of FLAGS (23611) must be reset after reading the keyboard.


RE: PAUSE - patters - 12-29-2020

Wow, so fast to fix! Smile
I also spotted another issue with Input. If you try to delete a character entered during the INPUT the cursor jumps to the line above (at least in my program which prints the INPUT question on line 22).


RE: PAUSE - boriel - 12-29-2020

Ok, Let's fix that. Can you post a little example?

In the meantime, if you want to try with a beta with the fix mentioned above, you can download from here:

Windows: http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta1-win32.zip
Linux: http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta1-linux64.tar.gz
Mac OS: http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta1-macos.tar.gz

Source (Python):
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta1.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta1.zip


RE: PAUSE - patters - 12-29-2020

Sure. During the INPUT prompt, enter a character, then delete it and you'll see the cursor jump up to the line above.
Code:
#include <input.bas>
DIM ans AS Integer
DIM scoreToWin AS uByte

FUNCTION userInputFN(inputXPos AS uByte, prompt AS String, default AS Byte, ansMaxLen AS uByte, ansMinVal AS Byte, ansMaxVal AS Byte) AS Integer
    Prompt:
    PRINT AT 23,inputXPos; prompt; " [";default;"]: ";
    INK 1
    answer$=INPUT(ansMaxLen)
    INK 0
    'String checks
    IF answer$="" THEN
        ans=default
    ELSE
        FOR n=0 TO (LEN answer$)-1
            IF CODE answer$(n)<45 OR CODE answer$(n)>57 THEN
                PRINT AT 23,inputXPos; "Entry error",,
                PAUSE 50
                GO TO Prompt:
            END IF
        NEXT n
        'Checks passed, convert to value
        ans=INT(VAL(answer$))
    END IF
    IF ans<ansMinVal THEN ans=ansMinVal: PRINT AT 23,0; "Constrained to min",: PAUSE 50
    IF ans>ansMaxVal THEN ans=ansMaxVal: PRINT AT 23,0; "Constrained to max",: PAUSE 50
    PRINT AT 23,0;,,
    RETURN ans
END FUNCTION

scoreToWin=5
scoreToWin=userInputFN(0, "Score to win match (1-9)", scoreToWin, 1, 1, 9)
PRINT scoreToWin

I just tried beta 1.14 in Mac OS and it doesn't seem to have fixed the INPUT/PAUSE issue. The code I posted above still isn't PAUSEing properly even when compiled using 1.14.


RE: PAUSE - boriel - 12-29-2020

Can you try with this version, please?
Tell me if it's fixed:
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta2.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta2.zip
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta2-win32.zip
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta2-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta2-macos.tar.gz

This one is harder to fix, as it's related to the PRINT + SCROLL management.


RE: PAUSE - patters - 12-29-2020

I can confirm that 1.14beta2 build has fixed my specific issue with the delete spoiling the INPUT cursor. However, PAUSE still isn't working. Your reponse wasn't entirely clear - do I need to add that code workaround, or was your intention to fix the compiler so that wouldn't be necessary? Thanks.


RE: PAUSE - boriel - 12-29-2020

Both errors should have gone.
Please try this new beta3, and tell me:

http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta3.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta3.zip
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta3-win32.zip
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta3-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.14.0-beta3-macos.tar.gz


RE: PAUSE - patters - 12-29-2020

Yes, that last beta build has fixed both of the issues. Did you see my other new post in this subforum? I'm guessing it's something simple, but it's driving me a bit crazy Smile


RE: PAUSE - boriel - 01-02-2021

(12-29-2020, 11:52 PM)patters Wrote: Yes, that last beta build has fixed both of the issues. Did you see my other new post in this subforum? I'm guessing it's something simple, but it's driving me a bit crazy Smile

Please check the thread about the TAB bug, because I did a "regression" of this one and it should all be fixed now.
I'm waiting for your confirmation to include the change in the official release. Angel


RE: PAUSE not working (*solved*) - patters - 01-03-2021

Yes I can confirm that 1.14beta6 and beta9 have fixed this issue.