Matrix Brandy BASIC V for Linux with SDL: V1.21.13 released

discuss PC<>Acorn file transfer issues & the use of FDC, XFER, Omniflop/disk etc.
User avatar
dhg2
Posts: 88
Joined: Tue Oct 25, 2016 7:37 pm
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by dhg2 » Sat Aug 04, 2018 5:24 pm

Soruk wrote:
Sat Aug 04, 2018 4:24 pm
The PLOT routines and general oddities in there are definitely something on my to-do list.

Your spaceship game - nice! Runs quite well - and if I can sort out INKEY to handle multiple keypresses then it would be even better :) But that's a Brandy issue, not your game's fault. It reminds me a bit of the game !Foray which was included on an Acorn User cover disc many moons ago, to which I lost many an hour.

If I may ask, were there many changes needed to make it run on Matrix Brandy?)

I've flagged these as issues up on github, if nothing else as a reminder for me to do something about it!
Thanks!
The only real change I had to make was that Brandy doesn't seem to notice when Escape is pressed, or when the window close button is clicked, so I had to manually listen for Escape with INKEY(-113) to quit the game and exit Brandy.
The other change I made was cosmetic, I added a *WINTITLE command.
Last edited by dhg2 on Sat Aug 04, 2018 5:25 pm, edited 1 time in total.
Regards,
- Patrick

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Mon Aug 06, 2018 12:37 pm

dhg2 wrote:
Sat Aug 04, 2018 4:11 pm
I've noticed that Brandy differs from RISC OS/ARM BASIC when plotting circles and printing text at the position of the graphics cursor. This program:

Code: Select all

MODE1
VDU5
GCOL 0,1
RECTANGLEFILL 640-100,512-100,400,200
GCOL 0,3
CIRCLEFILL 640,512,100
PRINT"Test"
VDU4
produces these results on Matrix Brandy V1.21.7 and RISC OS 3:
img.png
This should now be fixed in git - Circle plotting now leaves the graphics cursor at the right-most point on the circle, and VDU5 text plotting plots with a transparent background. The code snippet above now renders as per RISC OS.

And, perhaps useful for your game, we now have a *FullScreen command - *FullScreen help shows usage.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.8 released

Post by Soruk » Tue Aug 07, 2018 11:20 am

I've released version 1.21.8 of Matrix Brandy.

Significant changes include:
* Window resizing (so ALL screen modes defined work in X11, and when running in frame buffer available modes depend on your console screen resolution)
* INKEY supporting multiple keypresses.
* More fixes to PLOT and VDU5 text.
* Networking now supports IPv6.
* Ability to select full screen mode in X11. Note a mode change will revert to windowed mode.

It's in all the usual places (website and github).

User avatar
dhg2
Posts: 88
Joined: Tue Oct 25, 2016 7:37 pm
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by dhg2 » Tue Aug 07, 2018 11:56 am

Soruk wrote:
Mon Aug 06, 2018 12:37 pm
This should now be fixed in git - Circle plotting now leaves the graphics cursor at the right-most point on the circle, and VDU5 text plotting plots with a transparent background. The code snippet above now renders as per RISC OS.

And, perhaps useful for your game, we now have a *FullScreen command - *FullScreen help shows usage.
Nice, I've tested it and it looks just right now.
The *newmode feature is a great idea, and I'm glad to see that INKEY is working with multiple keys.
Thanks for all the work you're doing.

Just wondering, are you planning to implement the *REFRESH, *REFRESH OFF, *REFRESH ON feature from Richard Russell's BB4W/BBCSDL? (or some kind of functional equivalent)

The *fullscreen command is a nice feature, but now the fact that Escape doesn't work can potentially get you stuck. I was in full screen and ran a program that loops infinitely. I couldn't find any way to stop the program or exit full screen mode, and I had to switch to another terminal and force brandy to exit with "kill -9".
Is there another way to stop the program or tell brandy to quit?
Regards,
- Patrick

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 12:09 pm

dhg2 wrote:
Tue Aug 07, 2018 11:56 am
Just wondering, are you planning to implement the *REFRESH, *REFRESH OFF, *REFRESH ON feature from Richard Russell's BB4W/BBCSDL? (or some kind of functional equivalent)
What does this do? I've not heard of this command.
dhg2 wrote: The *fullscreen command is a nice feature, but now the fact that Escape doesn't work can potentially get you stuck. I was in full screen and ran a program that loops infinitely. I couldn't find any way to stop the program or exit full screen mode, and I had to switch to another terminal and force brandy to exit with "kill -9".
Is there another way to stop the program or tell brandy to quit?
That's a tricky problem - SDL only polls the keyboard when it's expecting input (immediate mode, INPUT, GET and INKEY). Raised as Issue #5 on Github.

User avatar
dhg2
Posts: 88
Joined: Tue Oct 25, 2016 7:37 pm
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by dhg2 » Tue Aug 07, 2018 12:21 pm

Soruk wrote:
Tue Aug 07, 2018 12:09 pm
dhg2 wrote:
Tue Aug 07, 2018 11:56 am
Just wondering, are you planning to implement the *REFRESH, *REFRESH OFF, *REFRESH ON feature from Richard Russell's BB4W/BBCSDL? (or some kind of functional equivalent)
What does this do? I've not heard of this command.
*REFRESH OFF stops the screen from being updated, so anything you draw or print won't be seen until you ask for the screen to be updated with *REFRESH. And *REFRESH ON makes it so the screen gets updated automatically again. It's useful for eliminating flicker problems from animations.
Last edited by dhg2 on Tue Aug 07, 2018 12:22 pm, edited 1 time in total.
Regards,
- Patrick

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 12:31 pm

dhg2 wrote:
Tue Aug 07, 2018 12:21 pm
Soruk wrote:
Tue Aug 07, 2018 12:09 pm
dhg2 wrote:
Tue Aug 07, 2018 11:56 am
Just wondering, are you planning to implement the *REFRESH, *REFRESH OFF, *REFRESH ON feature from Richard Russell's BB4W/BBCSDL? (or some kind of functional equivalent)
What does this do? I've not heard of this command.
*REFRESH OFF stops the screen from being updated, so anything you draw or print won't be seen until you ask for the screen to be updated with *REFRESH. And *REFRESH ON makes it so the screen gets updated automatically again. It's useful for eliminating flicker problems from animations.
OK - logged that as Github Issue #6.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 12:54 pm

Soruk wrote:
Tue Aug 07, 2018 12:31 pm
OK - logged that as Github Issue #6.
...and an implementation commited to github. Does that work for you?

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Tue Aug 07, 2018 1:13 pm

Soruk wrote:
Tue Aug 07, 2018 12:09 pm
That's a tricky problem - SDL only polls the keyboard when it's expecting input (immediate mode, INPUT, GET and INKEY). Raised as Issue #5 on Github.
Is this still SDL 1? In SDL 2 the keyboard is event-driven, and In BBCSDL I simply process the Escape key in my event handler so that it will be responded to at all times (unless disabled). Unrelated code has been deleted here for clarity:

Code: Select all

	if (SDL_PeepEvents(&ev, 1, SDL_GETEVENT, 0, SDL_LASTEVENT-1))
	    {
		switch (ev.type)
		    {
			case SDL_KEYDOWN:
			c = ev.key.keysym.sym ;
			switch (c)
			    {
				case SDLK_ESCAPE :
				case SDLK_AC_BACK : // Android 'back' button
				c = 27 ;
				if ((flags & ESCDIS) == 0)
				    {
					flags |= ESCFLG ;
					c = 0 ;
				    }
				break ;
			    }
		    }
	    }
Richard.

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Tue Aug 07, 2018 1:27 pm

dhg2 wrote:
Tue Aug 07, 2018 11:56 am
Just wondering, are you planning to implement the *REFRESH, *REFRESH OFF, *REFRESH ON feature from Richard Russell's BB4W/BBCSDL? (or some kind of functional equivalent)
On a more general point, are you planning to adopt other BB4W/BBCSDL extensions, if only to the limited degree that Jonathan Harston has in his (ARM) BASICPLUS? And what are your plans for platforms other than Linux? I'm obviously interested in the extent to which Matrix Brandy could provide competition to BBCSDL!

Richard.

User avatar
dhg2
Posts: 88
Joined: Tue Oct 25, 2016 7:37 pm
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by dhg2 » Tue Aug 07, 2018 1:48 pm

Soruk wrote:
Tue Aug 07, 2018 12:54 pm
Soruk wrote:
Tue Aug 07, 2018 12:31 pm
OK - logged that as Github Issue #6.
...and an implementation commited to github. Does that work for you?
I've just been testing it now, it works brilliantly! I also notice a positive side effect, while the screen updates are disabled, plotting operations take much less CPU/system time. One of my programs that draws a large image across the whole window with many PLOT 69 calls took about 17 seconds before - now that it draws the image with screen updates turned off, it takes less than a second.
Thanks again for the excellent work.
Last edited by dhg2 on Tue Aug 07, 2018 1:49 pm, edited 2 times in total.
Regards,
- Patrick

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 2:38 pm

Richard Russell wrote:
Tue Aug 07, 2018 1:27 pm
dhg2 wrote:
Tue Aug 07, 2018 11:56 am
Just wondering, are you planning to implement the *REFRESH, *REFRESH OFF, *REFRESH ON feature from Richard Russell's BB4W/BBCSDL? (or some kind of functional equivalent)
On a more general point, are you planning to adopt other BB4W/BBCSDL extensions, if only to the limited degree that Jonathan Harston has in his (ARM) BASICPLUS? And what are your plans for platforms other than Linux? I'm obviously interested in the extent to which Matrix Brandy could provide competition to BBCSDL!

Richard.
I've not seen JGH's BASICPLUS, and not sure I have anything that'll run it (I do have easily available a Risc PC under emulation), but other extensions are only implemented if someone asks for it - I'm not aiming to compete with BBCSDL! Not to mention, BBCSDL can officially be called BBC BASIC while Matrix Brandy can't (it just attempts to run as much BBC BASIC as it can, targeting BASIC V from RISC OS).

I'm not planning to target any system other than Linux. Of course, being GPL2 open source anyone can pick it up and attempt to build it on other platforms, and while I haven't stripped out any of the #ifdef's for building under DJGPP or RISCOS it's been left well alone.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 3:04 pm

dhg2 wrote:
Tue Aug 07, 2018 1:48 pm
I've just been testing it now, it works brilliantly! I also notice a positive side effect, while the screen updates are disabled, plotting operations take much less CPU/system time. One of my programs that draws a large image across the whole window with many PLOT 69 calls took about 17 seconds before - now that it draws the image with screen updates turned off, it takes less than a second.
Thanks again for the excellent work.
Another thing you might have noticed about the speeds, the modes where one pixel is one physical pixel (for example, 18-21, 25,28) will be faster than the stretched modes (0,1,2 etc.) - probably even when REFRESH is off.

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Tue Aug 07, 2018 3:52 pm

Soruk wrote:
Tue Aug 07, 2018 2:38 pm
I've not seen JGH's BASICPLUS, and not sure I have anything that'll run it (I do have easily available a Risc PC under emulation)
Presumably it will run on an emulated RPC, I've only tried it using Red Squirrel on Windows. The current status can be found here (Jonathan will no doubt chime in if that's out of date). The features marked DONE could, I expect, relatively easily be incorporated in Brandy too.
BBCSDL can officially be called BBC BASIC while Matrix Brandy can't
I suppose so, although some might argue the permission that I received decades ago was never intended to last this long! I doubt that anybody considers the name a significant factor.
I'm not planning to target any system other than Linux.
OK, I suppose that was my main interest. I see the 'unique selling point' of BBCSDL as the ability to run 100% identical BASIC code, even including things like 3D graphics and music, on all six main platforms (plus some more esoteric ones such as a few smart TVs). Supporting just one platform means you can be more 'agile': any change I make to the BBCSDL code base has to be tested on all the platforms, and that can take about a day!
Of course, being GPL2 open source anyone can pick it up and attempt to build it on other platforms
I still intend to release the source of BBCSDL but because the build environment is quite different for each platform I don't know how to go about it. Currently I haven't even fully merged the 32-bit and 64-bit branches (let alone that the 32-bit x86 editions are coded in assembler and the others in C). I badly need help from an expert!

Sorry to hijack your thread. Matrix Brandy can only help promote BBC BASIC as a viable language.

Richard.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 4:35 pm

Soruk wrote:
Tue Aug 07, 2018 12:09 pm
dhg2 wrote: The *fullscreen command is a nice feature, but now the fact that Escape doesn't work can potentially get you stuck. I was in full screen and ran a program that loops infinitely. I couldn't find any way to stop the program or exit full screen mode, and I had to switch to another terminal and force brandy to exit with "kill -9".
Is there another way to stop the program or tell brandy to quit?
That's a tricky problem - SDL only polls the keyboard when it's expecting input (immediate mode, INPUT, GET and INKEY). Raised as Issue #5 on Github.
I've put something that seems to do the job for me up on Github - does it do the trick for you? I've also implemented *FX229 which disables ESCAPE from interrupting a program (CTRL-C from the controlling terminal will still interrupt it) if X <> 0.

Coeus
Posts: 963
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Coeus » Tue Aug 07, 2018 5:06 pm

dhg2 wrote:
Tue Aug 07, 2018 1:48 pm
I've just been testing it now, it works brilliantly! I also notice a positive side effect, while the screen updates are disabled, plotting operations take much less CPU/system time. One of my programs that draws a large image across the whole window with many PLOT 69 calls took about 17 seconds before - now that it draws the image with screen updates turned off, it takes less than a second.
Thanks again for the excellent work.
In the limited digging I did into the way graphics works in Brandy it would generally work out the bounding rectangle affected by each PLOT operation and then blit this onto the screen before returning to the BASIC program. I wonder if, behind the scenes, SDL is waiting for vertical refresh to do the update. If so that immediately means for a 60Hz refresh rate each PLOT call would take a minimum of 16.7ms.

Coeus
Posts: 963
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Coeus » Tue Aug 07, 2018 5:10 pm

Richard Russell wrote:
Tue Aug 07, 2018 3:52 pm
...The features marked DONE could, I expect, relatively easily be incorporated in Brandy too.
Is that an assembler project? It's an enhancement to the official ARM BASIC which I think is assembler.

User avatar
dhg2
Posts: 88
Joined: Tue Oct 25, 2016 7:37 pm
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by dhg2 » Tue Aug 07, 2018 5:11 pm

Soruk wrote:
Tue Aug 07, 2018 4:35 pm
I've put something that seems to do the job for me up on Github - does it do the trick for you? I've also implemented *FX229 which disables ESCAPE from interrupting a program (CTRL-C from the controlling terminal will still interrupt it) if X <> 0.
I've been testing it. On my system, doing this sequence of actions causes some strange behaviour:

* Start brandy
* Run this at the prompt:

Code: Select all

REPEAT:WAIT(1):UNTILFALSE
* Switch window focus to another window (in my case I use the terminal that I started brandy from)
* Switch window focus back to brandy
* Press Escape a few times, note that the program doesn't stop
* Switch to the terminal and press Ctrl+C to force stop, note that the screen fills with 'Escape' error messages. There is also a chance (it didn't seem to happen every time I tried this) that if you press the up arrow key and RETURN to re-rerun the program, it will immediately stop as if escape was pressed.
Last edited by dhg2 on Tue Aug 07, 2018 5:14 pm, edited 2 times in total.
Regards,
- Patrick

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Tue Aug 07, 2018 5:24 pm

Coeus wrote:
Tue Aug 07, 2018 5:06 pm
I wonder if, behind the scenes, SDL is waiting for vertical refresh to do the update. If so that immediately means for a 60Hz refresh rate each PLOT call would take a minimum of 16.7ms.
That seems unlikely: a program executing thousands of PLOT statements (not uncommon) could take minutes to run!

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Tue Aug 07, 2018 5:43 pm

Coeus wrote:
Tue Aug 07, 2018 5:10 pm
Is that an assembler project? It's an enhancement to the official ARM BASIC which I think is assembler.
It's assembler, yes, but I still think incorporating the equivalent changes into Brandy should not be too challenging. For some reason Jonathan's 'to do' list doesn't include the additional variable types; byte variables (e.g. var&) ought to be easily added because of the existing support for indirection. Whether 64-bit integers (var%%) would be practical I don't know; possibly they would be easier in a 64-bit build of Brandy (although both 32-bit and 64-versions of my BASICs support them).

Richard.

Coeus
Posts: 963
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Coeus » Tue Aug 07, 2018 6:14 pm

dhg2 wrote:
Tue Aug 07, 2018 5:11 pm
...I've been testing it. On my system, doing this sequence of actions causes some strange behaviour:...
I just tried this and, for me, if I run the immediate-mode repeat loop, focus on another Window, then focus back on the Brandy graphical output and hit Escape nothing happens immediately but if I then wait a second or two it does stop with the Escape message.

If I type the Escape key while in the terminal windows I started Brandy from it does not cause any immediate action but gets queued so that when I hit Escape from Brandy's main window these additional escapes are processed.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 9:33 pm

Coeus wrote:
Tue Aug 07, 2018 6:14 pm
dhg2 wrote:
Tue Aug 07, 2018 5:11 pm
...I've been testing it. On my system, doing this sequence of actions causes some strange behaviour:...
I just tried this and, for me, if I run the immediate-mode repeat loop, focus on another Window, then focus back on the Brandy graphical output and hit Escape nothing happens immediately but if I then wait a second or two it does stop with the Escape message.

If I type the Escape key while in the terminal windows I started Brandy from it does not cause any immediate action but gets queued so that when I hit Escape from Brandy's main window these additional escapes are processed.
The reason for what you're seeing is, to avoid a horrible slowdown in checking for Escape for each command process, I do it once every 100. I've just commited a change that will check for Escape at the end of a WAIT. I can't interrupt the wait unless I break it down into smaller delays, but that could then start to skew the accuracy of the delay.

Coeus
Posts: 963
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Coeus » Tue Aug 07, 2018 9:41 pm

Soruk wrote:
Tue Aug 07, 2018 9:33 pm
The reason for what you're seeing is, to avoid a horrible slowdown in checking for Escape for each command process, I do it once every 100. I've just commited a change that will check for Escape at the end of a WAIT. I can't interrupt the wait unless I break it down into smaller delays, but that could then start to skew the accuracy of the delay.
I have just pulled the latest from git with the escape check in wait and that seems to have fixed the test case, at least for me.

Going back to the dynamic window re-sizing is there conscious design choice as to why modes 3 and 6 have much smaller windows that modes 0 and 4? I don't know how these look on RiscOS but on the BBC Micro mode 3 is like mode 0 but with gaps between the rows of characters to aid readability and mode 6 is likewise like mode 4 with gaps. In brandy it looks like it is 1:1 RiscOS to host pixels in modes 3 and 6 and 1:2 in modes 0 and 4 in both X and Y directions.

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Tue Aug 07, 2018 10:02 pm

Coeus wrote:
Tue Aug 07, 2018 9:41 pm
on the BBC Micro mode 3 is like mode 0 but with gaps between the rows of characters to aid readability and mode 6 is likewise like mode 4 with gaps.
On BB4W and BBCSDL too. Using relative units, a 'character cell' has the following dimensions (width x height):

MODE 0: 8 x 16
MODE 3: 8 x 20
MODE 4: 16 x 16
MODE 6: 16 x 20

MODEs 0 and 4 have 32 rows, giving a total height of 512; MODEs 3 and 6 have 25 rows, giving a total height of 500. If you change the background colour, on the Beeb the extra space between the rows in MODEs 3 and 6 remains black, so you get a striped effect. I do not attempt to emulate this in BB4W or BBCSDL; the entire background changes colour.

Richard.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Tue Aug 07, 2018 10:09 pm

Coeus wrote:
Tue Aug 07, 2018 9:41 pm
Soruk wrote:
Tue Aug 07, 2018 9:33 pm
The reason for what you're seeing is, to avoid a horrible slowdown in checking for Escape for each command process, I do it once every 100. I've just commited a change that will check for Escape at the end of a WAIT. I can't interrupt the wait unless I break it down into smaller delays, but that could then start to skew the accuracy of the delay.
I have just pulled the latest from git with the escape check in wait and that seems to have fixed the test case, at least for me.

Going back to the dynamic window re-sizing is there conscious design choice as to why modes 3 and 6 have much smaller windows that modes 0 and 4? I don't know how these look on RiscOS but on the BBC Micro mode 3 is like mode 0 but with gaps between the rows of characters to aid readability and mode 6 is likewise like mode 4 with gaps. In brandy it looks like it is 1:1 RiscOS to host pixels in modes 3 and 6 and 1:2 in modes 0 and 4 in both X and Y directions.
This is virtually unchanged from upstream 1.20.1, only added the resolution to fit the window without it crashing.

Coeus
Posts: 963
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Coeus » Tue Aug 07, 2018 11:11 pm

Soruk wrote:
Tue Aug 07, 2018 10:09 pm
This is virtually unchanged from upstream 1.20.1, only added the resolution to fit the window without it crashing.
Now you mention it, I had noticed previously that in those modes the interpreter used a very small part of the window so the only difference is it now shrinks the window to the area it is actually using, amking that a lot more obvious, so this is certainly not a regression.

I'll try it on a laptop too as I am currently sitting at a desktop machine with a 1920x1080 resolution and that makes it look particularly small but either way some leading between the lines would be an improvement.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Wed Aug 08, 2018 9:17 am

Richard Russell wrote:
Tue Aug 07, 2018 1:13 pm
Soruk wrote:
Tue Aug 07, 2018 12:09 pm
That's a tricky problem - SDL only polls the keyboard when it's expecting input (immediate mode, INPUT, GET and INKEY). Raised as Issue #5 on Github.
Is this still SDL 1? In SDL 2 the keyboard is event-driven, and In BBCSDL I simply process the Escape key in my event handler so that it will be responded to at all times (unless disabled). Unrelated code has been deleted here for clarity:

Code: Select all

	if (SDL_PeepEvents(&ev, 1, SDL_GETEVENT, 0, SDL_LASTEVENT-1))
	    {
		switch (ev.type)
		    {
			case SDL_KEYDOWN:
			c = ev.key.keysym.sym ;
			switch (c)
			    {
				case SDLK_ESCAPE :
				case SDLK_AC_BACK : // Android 'back' button
				c = 27 ;
				if ((flags & ESCDIS) == 0)
				    {
					flags |= ESCFLG ;
					c = 0 ;
				    }
				break ;
			    }
		    }
	    }
Richard.
Thank you for this pointer, Richard. While SDL_PeepEvents didn't seem to return ANYTHING for me, it was a very useful pointer, in the end I just called emulate_inkey(-133) and acted on the response from that.

As an aside, about INKEY and multple keys, I got that working by using a state table with an entry for each key, recording all keydowns and keyups. At the moment it's not recording them for normal keyboard entry hence the occasional spurious ESCAPE that has been seen - but I'll look at making normal input (including read_key that supports GET) also update that state table. Hopefully that will make things a touch more consistent.

User avatar
Richard Russell
Posts: 459
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Richard Russell » Wed Aug 08, 2018 11:00 am

Soruk wrote:
Wed Aug 08, 2018 9:17 am
SDL_PeepEvents didn't seem to return ANYTHING for me
That might suggest that you're forgetting to call SDL_PumpEvents. Unless the event loop is pumped, you'll never see anything with SDL_PeepEvents except those events that you explicitly push yourself. I use the SDL2 events mechanism for inter-thread communication as well as for input, so it's crucial to BBCSDL. For example VDU (and hence all the other graphics statements) sends the byte stream to the GUI thread via the SDL event loop; the user's BASIC program doesn't have to wait for the graphics operation to complete before continuing. This is effectively how the old Acorn 'second processors' worked of course, except that the VDU stream was sent down the 'tube'.

Edit:
I got that working by using a state table with an entry for each key, recording all keydowns and keyups.
I don't understand why you need to do that given that SDL 2 does it for you (see the SDL_GetKeyboardState API)!

Richard.
Last edited by Richard Russell on Wed Aug 08, 2018 11:03 am, edited 1 time in total.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Wed Aug 08, 2018 11:18 am

Richard Russell wrote:
Wed Aug 08, 2018 11:00 am
Soruk wrote:
Wed Aug 08, 2018 9:17 am
SDL_PeepEvents didn't seem to return ANYTHING for me
That might suggest that you're forgetting to call SDL_PumpEvents. Unless the event loop is pumped, you'll never see anything with SDL_PeepEvents except those events that you explicitly push yourself. I use the SDL2 events mechanism for inter-thread communication as well as for input, so it's crucial to BBCSDL. For example VDU (and hence all the other graphics statements) sends the byte stream to the GUI thread via the SDL event loop; the user's BASIC program doesn't have to wait for the graphics operation to complete before continuing. This is effectively how the old Acorn 'second processors' worked of course, except that the VDU stream was sent down the 'tube'.

Edit:
I got that working by using a state table with an entry for each key, recording all keydowns and keyups.
I don't understand why you need to do that given that SDL 2 does it for you (see the SDL_GetKeyboardState API)!

Richard.
I realised that earlier this morning from a StackOverflow post from someone else with the same problem. However, calling the INKEY handler is working (and does simplify the code considerably) I'll leave it as is.
Brandy is single threaded, and while redoing the architecture to be multithreaded may be possible it's not something I'm thinking of for the near term. (It's also why it was noticed that with *REFRESH OFF that plot-intensive programs ran MUCH faster!)

Edit: SDL_GetKeyboardState isn't in SDL 1.2. (Edit 2: Hmm, but SDL_GetKeyState is - might be able to use that)

Edit 3: SDL_GetKeyState works - and using that has made the code MUCH cleaner. (I'm also polling for SDL_QUIT so the Close Window button now works pretty much any time.) And, new to this, INKEY on mouse buttons is also working.

As is quite evident from this thread, in the process of trying to improve Matrix Brandy, I'm also learning a lot about LibSDL!
Last edited by Soruk on Wed Aug 08, 2018 12:14 pm, edited 5 times in total.

Soruk
Posts: 148
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC V for Linux with SDL: V1.21.7 released

Post by Soruk » Wed Aug 08, 2018 11:52 am

Coeus wrote:
Tue Aug 07, 2018 11:11 pm
Soruk wrote:
Tue Aug 07, 2018 10:09 pm
This is virtually unchanged from upstream 1.20.1, only added the resolution to fit the window without it crashing.
Now you mention it, I had noticed previously that in those modes the interpreter used a very small part of the window so the only difference is it now shrinks the window to the area it is actually using, amking that a lot more obvious, so this is certainly not a regression.

I'll try it on a laptop too as I am currently sitting at a desktop machine with a 1920x1080 resolution and that makes it look particularly small but either way some leading between the lines would be an improvement.
In addition to the INKEY changes, I've also checked into github hopefully a fix for the MODE 3 / 6 issue.

Post Reply