Matrix Brandy V1.22.15 released
I have released version 1.22.15 of Matrix Brandy. Changes include:
- System: For SDL builds, move ESCAPE polling to its own thread.
- System: Added CTRL+PrtSc to force immediate exit in SDL build. Unfortunately the Pause/Break key doesn't register in SDL. This functionality can be disabled with build-time option BRANDY_NOBREAKONCTRLPRTSC.
- System: Added some fixes to handle issues with the sdl12-compat library.
- System: Implemented an internal *./*CAT handler, loosely styled on BBC Micro ADFS output.
- System: Exit code is now ERR MOD 256 (or 255 if that would result in 0), or 0 if exited with no error. A program can still set its own exit code as a parameter to QUIT.
- System: Fixed a regression in the way floats were handled by SYS.
- System: Corrected a flawed usage of fcntl().
- MOS: Implemented OSBYTE 210
- BASIC: Extended ATN to take two parameters in parentheses, this calls atan2().
Downloads are available from the Matrix Brandy website, also from git.
- System: For SDL builds, move ESCAPE polling to its own thread.
- System: Added CTRL+PrtSc to force immediate exit in SDL build. Unfortunately the Pause/Break key doesn't register in SDL. This functionality can be disabled with build-time option BRANDY_NOBREAKONCTRLPRTSC.
- System: Added some fixes to handle issues with the sdl12-compat library.
- System: Implemented an internal *./*CAT handler, loosely styled on BBC Micro ADFS output.
- System: Exit code is now ERR MOD 256 (or 255 if that would result in 0), or 0 if exited with no error. A program can still set its own exit code as a parameter to QUIT.
- System: Fixed a regression in the way floats were handled by SYS.
- System: Corrected a flawed usage of fcntl().
- MOS: Implemented OSBYTE 210
- BASIC: Extended ATN to take two parameters in parentheses, this calls atan2().
Downloads are available from the Matrix Brandy website, also from git.
0
Comments
-
- BASIC: Extended ATN to take two parameters in parentheses, this calls atan2().
Realistically I cannot follow suit. Although I probably could add the functionality to my coded-in-C versions (but only at the cost of slowing down the existing ATN function) I no longer have the assembly language skills to add it to BBC BASIC for Windows or the 32-bit x86 editions of BBC BASIC for SDL 2.0.
0 -
That is of course, fair enough. My overriding thing on adding this was doing it in such a way that any existing code would not break, hence, not adding a new function ATN2 (as that is in itself a valid way of saying ATN(2). The check is, if no parentheses seen, assume single parameter. If parentheses seen, then check if second parameter supplied, and only then call atan2().
While, as you well know, I am aiming to keep close to RISC OS BBC BASIC VI compatibility, it isn't bidirectional, else I wouldn't have been able to implement things like DIM HIMEM either.0 -
My overriding thing on adding this was doing it in such a way that any existing code would not break
I have spent decades explaining to people the 'philosophy' behind BBC BASIC, as established in the 1980s, which was to incorporate as a standard feature of the language only capabilities that either cannot be implemented as a user-defined FN/PROC or that doing so would involve an unacceptable speed penalty or that the feature is so commonly needed that including it can be justified on those grounds.
If none of those tests is passed the feature should be implemented as a FN/PROC, possibly in a library. It's this longstanding philosophy which has kept BBC BASIC both compact and stable, not bloated with features that hardly anybody ever uses (and bloating can impact speed because of instruction cache efficiency). It's one of BBC BASIC's Unique Selling Points over many other BASIC interpreters.
I realise that you don't claim that Matrix Brandy is BBC BASIC, and there's no way that you can be expected to be constrained by decades-old decisions and philosophy, but I do wonder where it might end if you feel able to add any extensions at all so long as they don't impact compatibility.
0 -
I don't think the overheads are that great, what I'm doing is basically this:
IF ?exec_pointer = ASC("(") THEN new_code_path with additional check for one or 2 parameters behave appropriately ELSE existing code path, one parameter only ENDIF
The atan2() call extension was a user request, from the guys reverse engineering Elite.0 -
I don't think the overheads are that greatThe atan2() call extension was a user request, from the guys reverse engineering Elite.
I know that BBC BASIC isn't standardised, which opens the door to extensions being made to one version but not to another. However when I've been tempted to make an extension (most recently using SYS as a function) I've always consulted on it and made attempts to get it implemented more widely.
0 -
There may be a standard library function for it in BBCSDL, however (with the exception of GPIO) I don't ship any of your libraries with Matrix Brandy, and even in the case of gpiolib, that was simply because it's relatively complicated to program for so I used yours as an API definition/template and reworked it using Matrix Brandy internals to do the heavy lifting.0
-
There may be a standard library function for it in BBCSDL
My point is simply that as it's trivially possible to implement atan2() as a user-defined function, why not do it that way? That's what user-defined functions are for!
It's also perfectly possible (certainly in my BASICs and I assume in Matrix Brandy too) to call the C-library function using SYS (here for a 64-bit platform):x# = -1.23 y# = 2.34 SYS "atan2", y#, x# TO a# PRINT a#
I feel very strongly that extending the language should only be considered in the most exceptional circumstances, when every other avenue has been exhausted. I can't see how this qualifies.
0 -
Over in the Bubble Universe thread I looked into this for implementing sincos(), creating a new Brandy_sincos call as I can't return floats from a SYS call, but can make it use a memory block OSWORD-style, however the overheads of setting up the SYS environment were so much worse than just calling SIN and COS separately in BASIC I backed that change out as it proved to be completely pointless. Although that might also point to some optimisation needed within the way SYS works.
Also, since you use 80-bit floats you can safely store a 64-bit int in one without losing accuracy, I don't have that luxury. Though, not sure how you work around this on ARM as it's limited to 64-bit floats. I did try altering Matrix Brandy to use 80 bit floats, but it went horribly wrong, as there must be some places in the code where the float size is hard-wired at 64 bits, probably in the stack code amongst others.0 -
the overheads of setting up the SYS environment were so much worse than just calling SIN and COS separately in BASIC I backed that change out as it proved to be completely pointless.I can't return floats from a SYS callThough, not sure how you work around this on ARM as it's limited to 64-bit floats.
You can sometimes see a side-effect though. For example you might expect this code to generate a 'Number too big' error, but it doesn't on an ARM platform:a%% = -2^63-1
It doesn't raise an error because -2^63-1 won't fit in an integer so gets automatically promoted to a float, but since a 64-bit float doesn't have the precision to contain this value precisely it gets 'silently' rounded to -2^63, and that rounded value will store in a 64-bit integer variable!
A small price to pay for the overall benefit of variants.
0