Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

for discussion of bbc basic for windows/sdl, brandy and more
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Sat Jul 24, 2021 2:24 pm
that was a slightly different issue of an array seemingly losing its LOCAL-ness after being dimensioned in a sub-procedure (an issue that doesn't arise in Matrix Brandy, instead I get an error that array has already been dimensioned the second time PROCsetup is called
Architecturally Brandy must be very different from either my BASICs or ARM BASIC in the way it implements LOCAL arrays. In my BASICs, and I think in ARM BASIC too from the way it behaves, LOCAL arrays are stored on the stack - the same stack that is used to store the control information for a FOR...NEXT loop. That means it is impossible to DIMension a LOCAL array inside a FOR...NEXT loop, because when the NEXT statement is reached it will find the array on the stack, not the information it expects!

Admittedly my BASICs behave differently from ARM BASIC in respect of what happens if you try it. In mine, the NEXT statement will invariably fail with a 'Not in a FOR loop' error but in ARM BASIC this will only happen if an explicit variable is specified after NEXT, e.g. NEXT i%. If NEXT is used without a variable it will apparently succeed, but the array will be silently discarded. :shock:

In Brandy, however, it seems that the NEXT statement actually succeeds, and the LOCAL array survives, despite it having been dimensioned inside the loop! I have no idea how that is even possible: are LOCAL arrays not stored on the stack, or are there different stacks for LOCAL arrays and FOR loops, or what? :?
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Jul 24, 2021 3:07 pm
Soruk wrote:
Sat Jul 24, 2021 2:24 pm
unpack in your hostfs directory, then inside RPCEmu, do *RMRUN BASIC to replace the ROM BASIC and start it up - but not while BASIC itself is running!).
I only have Red Squirrel, not RPCEmu. Do those instructions apply to Red Squirrel as well?
I see there's a DISK370 directory under HostFS, and that's the one used for a RISC PC emulation. Unzip the files into there, then inside Red Squirrel you should see the BASIC and BASIC64 files.
rs.png
Edit: If you want these to be loaded when you start RS, create a !Boot file containing:

Code: Select all

RMLoad HostFS::HardDisk.$.BASIC
RMLoad HostFS::HardDisk.$.BASIC64
, and give it the right filetype with:

Code: Select all

*SetType !Boot Obey
ALso, I recall a while back I suggested you did *Configure NoBoot to avoid the not found error on start-up. You'll need to switch that back on, with *Configure Boot
Last edited by Soruk on Sat Jul 24, 2021 4:22 pm, edited 3 times in total.
Matrix Brandy BASIC VI (work in progress)
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Jul 24, 2021 3:30 pm
In Brandy, however, it seems that the NEXT statement actually succeeds, and the LOCAL array survives, despite it having been dimensioned inside the loop! I have no idea how that is even possible: are LOCAL arrays not stored on the stack, or are there different stacks for LOCAL arrays and FOR loops, or what? :?
I think Brandy maintains a separate stack for FOR loops, likely outside of the general BASIC workspace. I'll take a closer look at the code in a bit.

Edit: Yep, it is a separate stack, in normal C workspace.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Sat Jul 24, 2021 4:01 pm
I think Brandy maintains a separate stack for FOR loops, likely outside of the general BASIC workspace.
That's fascinating, in a way it harks back to the way 6502 BASIC worked, with separate stacks for FOR...NEXT and REPEAT...UNTIL (of course that limited the maximum nesting depth, which presumably it doesn't in Brandy). I wonder why that method was preferred over the more straightforward single-stack approach of ARM BASIC and all of mine, right back to the Z80 version.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Jul 24, 2021 5:17 pm
Soruk wrote:
Sat Jul 24, 2021 4:01 pm
I think Brandy maintains a separate stack for FOR loops, likely outside of the general BASIC workspace.
That's fascinating, in a way it harks back to the way 6502 BASIC worked, with separate stacks for FOR...NEXT and REPEAT...UNTIL (of course that limited the maximum nesting depth, which presumably it doesn't in Brandy). I wonder why that method was preferred over the more straightforward single-stack approach of ARM BASIC and all of mine, right back to the Z80 version.
With the available memory on modern systems, and having the facilities of a high-level language, it is actually more straightforward to have a separate stack for FOR loops, maintained as a (list of) C structures, and managed in the "normal" C fashion outside of the BASIC workspace.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Sat Jul 24, 2021 6:57 pm
it is actually more straightforward to have a separate stack for FOR loops, maintained as a (list of) C structures, and managed in the "normal" C fashion outside of the BASIC workspace.
Hmm, experimentally that's not how Brandy is behaving:

Code: Select all

   10 HIMEM = PAGE + 1000000
   20 FOR I% = 1 TO 10
   30   nest% += 1
   40   GOTO 20
This fails with 'Arithmetic stack overflowed' after about 20,000 iterations, whereas:

Code: Select all

   10 HIMEM = PAGE + 10000000
   20 FOR I% = 1 TO 10
   30   nest% += 1
   40   GOTO 20
fails after about 200,000 iterations. So the number of iterations is seemingly related to the value of HIMEM, which is not what I would expect from your description of the FOR stack being "outside of the BASIC workspace". What's more, you can actually monitor the increasing use of stack:

Code: Select all

   10 HIMEM = PAGE + 10000000
   20 FOR I% = 1 TO 10
   25   PROC1
   30   nest% += 1
   40   GOTO 20
   50 DEF PROC1
   60 DIM S% LOCAL -1
   70 PRINT S%
   80 ENDPROC
I'm not too sure what to make of this.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Jul 24, 2021 7:59 pm
What's more, you can actually monitor the increasing use of stack:

Code: Select all

   10 HIMEM = PAGE + 10000000
   20 FOR I% = 1 TO 10
   25   PROC1
   30   nest% += 1
   40   GOTO 20
   50 DEF PROC1
   60 DIM S% LOCAL -1
   70 PRINT S%
   80 ENDPROC
I'm not too sure what to make of this.
Me neither 🤷🏻‍♂️ I am still learning about the intricacies of the code that Dave Daniels wrote. There is certainly some clever stuff going on, and certainly a cursory glance of the C code in exec_for() seemed to indicate that it was just a normal C list. I am definitely missing something there...
Matrix Brandy BASIC VI (work in progress)
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

As a result of a chat with Cameron last night on the Stardot zoom call, he has very kindly put together the makefile and a few changes needed to build Matrix Brandy for RISC OS via the gccsdk cross-compiler (so a build now takes seconds instead of about 15 minutes!). Several advantages to this, the resulting binary is MUCH smaller, it links against SharedCLibrary (rather than SharedUnixLibrary) and the binary runs on any RISC OS 3+ machine (min 4MB RAM), all the way from the Archimedes range up to and including the Raspberry Pi.

DO NOT compile with -Os, it looks like a compiler bug causing an undefined instruction crash when you use DIM.
Last edited by Soruk on Fri Sep 17, 2021 9:37 pm, edited 1 time in total.
Matrix Brandy BASIC VI (work in progress)
User avatar
BigEd
Posts: 4435
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by BigEd »

Excellent result!
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

As I play a bit more with this RISC OS build, one issue has come to light - networking isn't working (it doesn't compile if -DNONET isn't specified), and a SharedUnixLibrary build isn't 26/32-bit neutral, even when built with this cross compiler. The proper fix is to add TCP/IP networking code in SharedCLibrary style instead of Unix-style, but so far I can't find any documentation on this.
Matrix Brandy BASIC VI (work in progress)
ccawley2011
Posts: 9
Joined: Wed Oct 28, 2020 6:06 pm
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by ccawley2011 »

I've taken a quick look at Brandy's network code, and as far as I can tell, the call to fcntl can be replaced with a call to ioctl, like the Windows version. For inet_addr meanwhile, the function does seem to be available in both TCPIPLibs (as used by Norcroft) and UnixLib, but not GCC's Shared C Library implementation. It might be worth emailing the GCCSDK mailing list about it, since it might be possible for it to be added.
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

ccawley2011 wrote:
Sun Sep 19, 2021 11:18 pm
It might be worth emailing the GCCSDK mailing list about it, since it might be possible for it to be added.
inet_addr is deprecated, not least because "255.255.255.255" returns -1 which is also the value returned on an error; I don't think there's any chance of it being added. inet_aton is preferred, so I'd suggest checking whether that is available on all the platforms.

Failing that, parsing the dot-notation string yourself is hardly rocket science.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sun Sep 19, 2021 11:36 pm
ccawley2011 wrote:
Sun Sep 19, 2021 11:18 pm
It might be worth emailing the GCCSDK mailing list about it, since it might be possible for it to be added.
inet_addr is deprecated, not least because "255.255.255.255" returns -1 which is also the value returned on an error; I don't think there's any chance of it being added. inet_aton is preferred, so I'd suggest checking whether that is available on all the platforms.

Failing that, parsing the dot-notation string yourself is hardly rocket science.
I've adjusted the code to use inet_aton() and this works for a UnixLib build, but the function also doesn't appear to be present in the SharedCLibrary build. (In the meantime, I've been through the build warnings, and it now builds cleanly for a UnixLib build with the cross-compiler.)

I'm beginning to wonder if, for a RISC OS target, I should instead be using the SWI calls (if I can find the docs to work with them) instead of UNIX-style calls.

Another thing I found is, for a SharedCLibrary build, all memory allocations fit in the WimpSlot of the application, whereas for a UnixLib build, if I malloc() a sizeable block of memory it is allocated as a dynamic area, which allows me to allocate a block bigger than about 28M (including DIM HIMEM to allocate an array outside of the WimpSlot space) - which could be useful on RPi targets where there is typically 512M-1G memory available.

I'm starting to think perhaps I should either continue with two builds, the 26-bit clean version that has no networking, but works on older Archimedes hardware, and an all-bells-and-whistles version that works on RiscPC and later, or just discontinue any builds for the 26-bit kit.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

I've just noticed that Matrix Brandy shares a 'bug' that BBC BASIC for Windows also has: it accepts a space between RND and the opening parenthesis of a parameter. So this prints one number when it should print two:

Code: Select all

      PRINT RND (6)
I don't feel able to fix this in BB4W because of the risk that existing programs could stop working, but you might feel differently about Matrix Brandy. Neither 6502 nor ARM BBC BASIC accepts a space, and the RISC OS documentation explicitly states: "Note that there should be no space before the opening bracket".
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
User avatar
SKS1
Posts: 42
Joined: Sat Sep 19, 2020 12:04 am
Location: Highland Perthshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by SKS1 »

Soruk wrote:
Mon Sep 20, 2021 11:49 am
Another thing I found is, for a SharedCLibrary build, all memory allocations fit in the WimpSlot of the application, whereas for a UnixLib build, if I malloc() a sizeable block of memory it is allocated as a dynamic area, which allows me to allocate a block bigger than about 28M (including DIM HIMEM to allocate an array outside of the WimpSlot space) - which could be useful on RPi targets where there is typically 512M-1G memory available.
Note that the WimpSlot of applications will happily keep extending beyond 28MB on RISC OS 5 systems (up to about 512MB in current builds, up to 1.75GB if you spin a custom ROM: https://riscosopen.org/forum/forums/11/ ... sts-123661)
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

SKS1 wrote:
Thu Oct 07, 2021 11:37 pm
Soruk wrote:
Mon Sep 20, 2021 11:49 am
Another thing I found is, for a SharedCLibrary build, all memory allocations fit in the WimpSlot of the application, whereas for a UnixLib build, if I malloc() a sizeable block of memory it is allocated as a dynamic area, which allows me to allocate a block bigger than about 28M (including DIM HIMEM to allocate an array outside of the WimpSlot space) - which could be useful on RPi targets where there is typically 512M-1G memory available.
Note that the WimpSlot of applications will happily keep extending beyond 28MB on RISC OS 5 systems (up to about 512MB in current builds, up to 1.75GB if you spin a custom ROM: https://riscosopen.org/forum/forums/11/ ... sts-123661)
Thank you for this - I see testing on RISC OS 5 in RPCEmu this does indeed work, but in RISC OS 3.71 I got the above result. However, freeing it doesn't shrink the WimpSlot back down. There remains the other hiccup that the networking calls fail to compile for a CLib build. CLib has the advantage of far smaller binaries, but the UnixLib build has the advantages of working networking and the availability of Dynamic Areas, allowing large allocations even on RISC OS 3.71 thus allowing large (numeric) arrays or memory blocks that are impossible in ARM BBC BASIC on this platform even with the latest builds from RISC OS Open's !System updates.
Matrix Brandy BASIC VI (work in progress)
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Thu Oct 07, 2021 10:50 pm
I've just noticed that Matrix Brandy shares a 'bug' that BBC BASIC for Windows also has: it accepts a space between RND and the opening parenthesis of a parameter. So this prints one number when it should print two:

Code: Select all

      PRINT RND (6)
I don't feel able to fix this in BB4W because of the risk that existing programs could stop working, but you might feel differently about Matrix Brandy. Neither 6502 nor ARM BBC BASIC accepts a space, and the RISC OS documentation explicitly states: "Note that there should be no space before the opening bracket".
In fn_rnd() there is no code for skipping over spaces, indeed it checks if the next character is a '(' so I suspect the space, if supplied, is being removed by the tokeniser.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Fri Oct 08, 2021 9:25 am
In fn_rnd() there is no code for skipping over spaces, indeed it checks if the next character is a '(' so I suspect the space, if supplied, is being removed by the tokeniser.
I wouldn't know about the internal mechanism, only that the end result is that it accepts a space when it shouldn't! It doesn't worry me unduly, since BB4W does the same, but I thought you should be aware.

It's only in a PRINT statement that adding a space results in a legal program in both Sophie's BASICs and yours, but which behave differently. Otherwise adding a space results in an error in 6502 and ARM BASICs.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Fri Oct 08, 2021 9:38 am
Soruk wrote:
Fri Oct 08, 2021 9:25 am
In fn_rnd() there is no code for skipping over spaces, indeed it checks if the next character is a '(' so I suspect the space, if supplied, is being removed by the tokeniser.
I wouldn't know about the internal mechanism, only that the end result is that it accepts a space when it shouldn't! It doesn't worry me unduly, since BB4W does the same, but I thought you should be aware.

It's only in a PRINT statement that adding a space results in a legal program in both Sophie's BASICs and yours, but which behave differently. Otherwise adding a space results in an error in 6502 and ARM BASICs.
OKay. This has been fixed, by pulling the same trick I used to implement SYS() by creating a new token for RND( and putting it in front of RND so it'll try to match that first. There is no compatibility issue with this, as Matrix Brandy always saves files in plain text, and tokens are only used internally.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Not sure if I'm missing something obvious here, but Matrix Brandy doesn't seem to be respecting the VDU 23,16... cursor movement direction when printing in VDU 5 mode:

Code: Select all

   10 MODE 0
   20 VDU 23,16,2|
   30 VDU 5,30
   40 PRINT "Hello world!";
I expected this to print "!dlrow olleH" in the top-right corner of the window, and it does in ARM BASIC V, BB4W and BBCSDL. But in Matrix Brandy (latest Windows nightly) it appears to be behaving as if the VDU 23,16,2| wasn't there at all!
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Wed Oct 13, 2021 6:06 pm
Not sure if I'm missing something obvious here, but Matrix Brandy doesn't seem to be respecting the VDU 23,16... cursor movement direction when printing in VDU 5 mode:

Code: Select all

   10 MODE 0
   20 VDU 23,16,2|
   30 VDU 5,30
   40 PRINT "Hello world!";
I expected this to print "!dlrow olleH" in the top-right corner of the window, and it does in ARM BASIC V, BB4W and BBCSDL. But in Matrix Brandy (latest Windows nightly) it appears to be behaving as if the VDU 23,16,2| wasn't there at all!
Good spot, thank you. When I implemented it way back when, I was only working (and testing) in VDU4 mode. Testing locally, confirmed that my implementation is somewhat deficient, so yep, something else to implement....

Edit: Done.
Not implemented (nor for VDU4 mode), where X moves in the Y direction and Y moves in the X direction (bit 3 is ignored).
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Wed Oct 13, 2021 8:20 pm
Not implemented (nor for VDU4 mode), where X moves in the Y direction and Y moves in the X direction (bit 3 is ignored).
Oh. It's useful for annotating graph axes, especially if you redefine the character set to be rotated by 90°. This works on a Master 128 (if you are patient), ARM BASIC V and all my current 32-bit BASICs:

Code: Select all

   10 MODE 1
   20 DIM X% 8
   30 Y% = X% DIV 256
   40 A% = 10
   50 FOR C% = &21 TO &7E
   60   ?X% = C%
   70   CALL &FFF1
   80   PROCrotate(X%)
   90   VDU 23,C%,X%?1,X%?2,X%?3,X%?4,X%?5,X%?6,X%?7,X%?8
  100 NEXT
  110 VDU 23,16,12|30
  120 PRINT "     Hello vertical world!"
  130 END
  140
  150 DEF PROCrotate(P%)
  160 LOCAL A%,B%,C%,D%,E%,F%,G%,H%,I%
  170 A%=P%?1:B%=P%?2:C%=P%?3:D%=P%?4:E%=P%?5:F%=P%?6:G%=P%?7:H%=P%?8
  180 FOR I% = 1 TO 8
  190   P%?I% = P%?I% * 2 OR A% AND 1 : A% = A% DIV 2
  200   P%?I% = P%?I% * 2 OR B% AND 1 : B% = B% DIV 2
  210   P%?I% = P%?I% * 2 OR C% AND 1 : C% = C% DIV 2
  220   P%?I% = P%?I% * 2 OR D% AND 1 : D% = D% DIV 2
  230   P%?I% = P%?I% * 2 OR E% AND 1 : E% = E% DIV 2
  240   P%?I% = P%?I% * 2 OR F% AND 1 : F% = F% DIV 2
  250   P%?I% = P%?I% * 2 OR G% AND 1 : G% = G% DIV 2
  260   P%?I% = P%?I% * 2 OR H% AND 1 : H% = H% DIV 2
  270 NEXT
  280 ENDPROC
If there's a faster way of rotating the characters I'd like to know.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
User avatar
BigEd
Posts: 4435
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by BigEd »

Richard Russell wrote:
Wed Oct 20, 2021 10:02 am
If there's a faster way of rotating the characters I'd like to know.
Some ideas in this mini-challenge thread.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Wed Oct 20, 2021 10:02 am
Soruk wrote:
Wed Oct 13, 2021 8:20 pm
Not implemented (nor for VDU4 mode), where X moves in the Y direction and Y moves in the X direction (bit 3 is ignored).
Oh. It's useful for annotating graph axes, especially if you redefine the character set to be rotated by 90°. This works on a Master 128 (if you are patient), ARM BASIC V and all my current 32-bit BASICs:
That's nice :D I've now got it going in VDU5 mode. VDU4 with the scroll protection stuff is proving a bit tricker, so changing line 10 to MODE1:VDU5 and your example works fine now. That'll appear in tonight's nightly build.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Fri Oct 22, 2021 9:53 pm
VDU4 with the scroll protection stuff is proving a bit tricker
Below is the test program I use (with the VDU 5 stuff disabled); it runs successfully in ARM BASIC V, BBC BASIC for Windows and BBC BASIC for SDL 2.0, so I think it can be considered reasonably accurate.

Currently, with your latest nightly build for Windows, it's failing with:

Code: Select all

Failed at test%=7, mode%=0, viewport%=0, type%=0, cmc%=&1
Parameter X is 0 but should be 80
Parameter Y is 1 but should be 0
That might be slightly concerning because VDU 23,16,1| isn't a vertical printing mode, or even a right-to-left mode, it's just the normal 'pending scroll' mode which I assumed had long since been working in Matrix Brandy.

Code: Select all

   10 REM Test of VDU 23,16 Cursor Movement Control
   20
   30 ON ERROR VDU 6,3,20,23,16,0|12 : REPORT : PRINT " at line ";ERL: END
   40
   50 maxtype% = 0
   60
   70 FOR mode% = 0 TO 3
   80   MODE mode%
   90   FOR viewport% = 0 TO 1
  100     FOR type% = 0 TO maxtype% : REM VDU 4, VDU 5, VDU 2, VDU 2+4
  110       FOR cmc% = 0 TO 127
  120         VDU 23,16,cmc%|
  130
  140         xmin% = 0 : ymin% = 0
  150         left% = 0 : top% = 0 : right% = 640
  160         CASE mode% OF
  170           WHEN 0: xmax% = 79 : ymax% = 31 : bottom% = 512 : cx% = 8  : cy% = 16 : height% = 512
  180           WHEN 1: xmax% = 39 : ymax% = 31 : bottom% = 512 : cx% = 16 : cy% = 16 : height% = 512
  190           WHEN 2: xmax% = 19 : ymax% = 31 : bottom% = 512 : cx% = 32 : cy% = 16 : height% = 512
  200           WHEN 3: xmax% = 79 : ymax% = 24 : bottom% = 500 : cx% = 8  : cy% = 20 : height% = 500
  210         ENDCASE
  220         IF viewport% THEN
  230           xmin% = xmax% * 1/3 : xmax% = xmax% * 2/3
  240           ymin% = ymax% * 1/3 : ymax% = ymax% * 2/3
  250           left% = xmin% * cx% : right% = xmax% * cx%
  260           top% = ymin% * cy% : bottom% = ymax% * cy%
  270           VDU 26,28,xmin%,ymax%,xmax%,ymin%
  280           VDU 24,left%*2;(height%-bottom%-1)*2+2;right%*2-2;(height%-top%-1)*2;
  290         ENDIF
  300
  310         right% = left%+((right%-left%)DIVcx%-1)*cx%
  320         bottom% = top%+((bottom%-top%)DIVcy%-1)*cy%
  330         CASE type% OF
  340           WHEN 0: VDU 4
  350           WHEN 1: VDU 5
  360           WHEN 2: VDU 4,2
  370           WHEN 3: VDU 2,21
  380         ENDCASE
  390         IF cmc% AND 2 SWAP left%,right% : cx% = -cx%
  400         IF cmc% AND 4 SWAP top%,bottom% : cy% = -cy%
  410         IF cmc% AND 8 THEN
  420           SWAP xmin%,ymin%
  430           SWAP xmax%,ymax%
  440           SWAP left%,top%
  450           SWAP right%,bottom%
  460         ENDIF
  470
  480         REM Home
  490         test% = 1
  500         VDU 30
  510         IF POS
  520         CASE type% OF
  530           WHEN 0:
  540             PROCcheck(POS, VPOS, 0, 0)
  550             PRINT TAB(POS,VPOS);
  560             PROCcheck(POS, VPOS, 0, 0)
  570           WHEN 1:
  580             IF cmc% AND 8 THEN
  590               PROCcheck(@vdu%!12, @vdu%!8, left%, top%)
  600             ELSE
  610               PROCcheck(@vdu%!8, @vdu%!12, left%, top%)
  620             ENDIF
  630           WHEN 2,3:
  640             IF cmc% AND 8 THEN
  650               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
  660             ELSE
  670               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
  680             ENDIF
  690         ENDCASE
  700
  710         REM Right
  720         test% = 2
  730         VDU 9
  740         IF POS
  750         CASE type% OF
  760           WHEN 0:
  770             PROCcheck(POS, VPOS, 1, 0)
  780             PRINT TAB(POS,VPOS);
  790             PROCcheck(POS, VPOS, 1, 0)
  800           WHEN 1:
  810             IF cmc% AND 8 THEN
  820               PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, top%)
  830             ELSE
  840               PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, top%)
  850             ENDIF
  860           WHEN 2,3:
  870             IF cmc% AND 8 THEN
  880               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%)
  890             ELSE
  900               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%)
  910             ENDIF
  920         ENDCASE
  930
  940         REM Down
  950         test% = 3
  960         VDU 10
  970         IF POS
  980         CASE type% OF
  990           WHEN 0:
 1000             PROCcheck(POS, VPOS, 1, 1)
 1010             PRINT TAB(POS,VPOS);
 1020             PROCcheck(POS, VPOS, 1, 1)
 1030           WHEN 1:
 1040             IF cmc% AND 8 THEN
 1050               PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, top%+cx%)
 1060             ELSE
 1070               PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, top%+cy%)
 1080             ENDIF
 1090           WHEN 2,3:
 1100             IF cmc% AND 8 THEN
 1110               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%+pcx%)
 1120             ELSE
 1130               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%+pcy%)
 1140             ENDIF
 1150         ENDCASE
 1160
 1170         REM Left
 1180         test% = 4
 1190         VDU 8
 1200         IF POS
 1210         CASE type% OF
 1220           WHEN 0:
 1230             PROCcheck(POS, VPOS, 0, 1)
 1240             PRINT TAB(POS,VPOS);
 1250             PROCcheck(POS, VPOS, 0, 1)
 1260           WHEN 1:
 1270             IF cmc% AND 8 THEN
 1280               PROCcheck(@vdu%!12, @vdu%!8, left%, top%+cx%)
 1290             ELSE
 1300               PROCcheck(@vdu%!8, @vdu%!12, left%, top%+cy%)
 1310             ENDIF
 1320           WHEN 2,3:
 1330             IF cmc% AND 8 THEN
 1340               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%+pcx%)
 1350             ELSE
 1360               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%+pcy%)
 1370             ENDIF
 1380         ENDCASE
 1390
 1400         REM Left, wrapping (or not)
 1410         test% = 5
 1420         VDU 8
 1430         IF POS
 1440         CASE type% OF
 1450           WHEN 0:
 1460             PROCcheck(POS, VPOS, xmax%-xmin%, 0)
 1470             PRINT TAB(POS,VPOS);
 1480             PROCcheck(POS, VPOS, xmax%-xmin%, 0)
 1490           WHEN 1:
 1500             IF cmc% AND 64 THEN
 1510               IF cmc% AND 8 THEN
 1520                 PROCcheck(@vdu%!12, @vdu%!8, left%-cy%, top%+cx%)
 1530               ELSE
 1540                 PROCcheck(@vdu%!8, @vdu%!12, left%-cx%, top%+cy%)
 1550               ENDIF
 1560             ELSE
 1570               IF cmc% AND 8 THEN
 1580                 PROCcheck(@vdu%!12, @vdu%!8, right%, top%)
 1590               ELSE
 1600                 PROCcheck(@vdu%!8, @vdu%!12, right%, top%)
 1610               ENDIF
 1620             ENDIF
 1630           WHEN 2,3:
 1640             IF cmc% AND 64 THEN
 1650               IF cmc% AND 8 THEN
 1660                 PROCcheck(@vdu%!-8, @vdu%!-12, pleft%-pcy%, ptop%+pcx%)
 1670               ELSE
 1680                 PROCcheck(@vdu%!-12, @vdu%!-8, pleft%-pcx%, ptop%+pcy%)
 1690               ENDIF
 1700             ELSE
 1710               IF cmc% AND 8 THEN
 1720                 PROCcheck(@vdu%!-8, @vdu%!-12, pright%, ptop%)
 1730               ELSE
 1740                 PROCcheck(@vdu%!-12, @vdu%!-8, pright%, ptop%)
 1750               ENDIF
 1760             ENDIF
 1770         ENDCASE
 1780
 1790         REM Right, wrapping (or not)
 1800         test% = 6
 1810         VDU 9
 1820         IF POS
 1830         CASE type% OF
 1840           WHEN 0:
 1850             PROCcheck(POS, VPOS, 0, 1)
 1860             PRINT TAB(POS,VPOS);
 1870             PROCcheck(POS, VPOS, 0, 1)
 1880           WHEN 1:
 1890             IF cmc% AND 8 THEN
 1900               PROCcheck(@vdu%!12, @vdu%!8, left%, top%+cx%)
 1910             ELSE
 1920               PROCcheck(@vdu%!8, @vdu%!12, left%, top%+cy%)
 1930             ENDIF
 1940           WHEN 2,3:
 1950             IF cmc% AND 8 THEN
 1960               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%+pcx%)
 1970             ELSE
 1980               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%+pcy%)
 1990             ENDIF
 2000         ENDCASE
 2010
 2020         REM Character (wrapping, pending or not moving)
 2030         test% = 7
 2040         VDU 8,33
 2050         IF POS
 2060         CASE type% OF
 2070           WHEN 0:
 2080             CASE TRUE OF
 2090               WHEN (cmc% AND 32) <> 0:
 2100                 IF FNget(POS,VPOS) <> 33 PROCerror
 2110                 PROCcheck(POS, VPOS, xmax%-xmin%, 0)
 2120                 PRINT TAB(POS,VPOS);
 2130                 PROCcheck(POS, VPOS, xmax%-xmin%, 0)
 2140               WHEN (cmc% AND 1) <> 0:
 2150                 IF FNget(xmax%-xmin%,0) <> 33 PROCerror
 2160                 PROCcheck(POS, VPOS, xmax%-xmin%+1, 0)
 2170                 PRINT TAB(POS,VPOS);
 2180                 PROCcheck(POS, VPOS, xmax%-xmin%+1, 0)
 2190               OTHERWISE:
 2200                 IF FNget(xmax%-xmin%,0) <> 33 PROCerror
 2210                 PROCcheck(POS, VPOS, 0, 1)
 2220                 PRINT TAB(POS,VPOS);
 2230                 PROCcheck(POS, VPOS, 0, 1)
 2240             ENDCASE
 2250           WHEN 1:
 2260             IF cmc% AND 32 THEN
 2270               IF cmc% AND 64 THEN
 2280                 IF cmc% AND 8 THEN
 2290                   PROCcheck(@vdu%!12, @vdu%!8, left%-cy%, top%+cx%)
 2300                 ELSE
 2310                   PROCcheck(@vdu%!8, @vdu%!12, left%-cx%, top%+cy%)
 2320                 ENDIF
 2330               ELSE
 2340                 IF cmc% AND 8 THEN
 2350                   PROCcheck(@vdu%!12, @vdu%!8, right%, top%)
 2360                 ELSE
 2370                   PROCcheck(@vdu%!8, @vdu%!12, right%, top%)
 2380                 ENDIF
 2390               ENDIF
 2400             ELSE
 2410               IF cmc% AND 8 THEN
 2420                 PROCcheck(@vdu%!12, @vdu%!8, left%, top%+cx%)
 2430               ELSE
 2440                 PROCcheck(@vdu%!8, @vdu%!12, left%, top%+cy%)
 2450               ENDIF
 2460             ENDIF
 2470           WHEN 2,3:
 2480             IF cmc% AND 32 THEN
 2490               IF cmc% AND 64 THEN
 2500                 IF cmc% AND 8 THEN
 2510                   PROCcheck(@vdu%!-8, @vdu%!-12, pleft%-pcy%, ptop%+pcx%)
 2520                 ELSE
 2530                   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%-pcx%, ptop%+pcy%)
 2540                 ENDIF
 2550               ELSE
 2560                 IF cmc% AND 8 THEN
 2570                   PROCcheck(@vdu%!-8, @vdu%!-12, pright%, ptop%)
 2580                 ELSE
 2590                   PROCcheck(@vdu%!-12, @vdu%!-8, pright%, ptop%)
 2600                 ENDIF
 2610               ENDIF
 2620             ELSE
 2630               IF cmc% AND 8 THEN
 2640                 PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%+pcx%)
 2650               ELSE
 2660                 PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%+pcy%)
 2670               ENDIF
 2680             ENDIF
 2690         ENDCASE
 2700
 2710         REM Character (unpend, or not moving)
 2720         REM test% = 8
 2730         REM VDU 34
 2740         REM IF POS
 2750         REM CASE type% OF
 2760         REM WHEN 0:
 2770         REM IF cmc% AND 32 THEN
 2780         REM IF FNget(POS,VPOS) <> 34 PROCerror
 2790         REM PROCcheck(POS, VPOS, xmax%-xmin%, 0)
 2800         REM PRINT TAB(POS,VPOS);
 2810         REM PROCcheck(POS, VPOS, xmax%-xmin%, 0)
 2820         REM ELSE
 2830         REM IF FNget(0,1) <> 34 PROCerror
 2840         REM PROCcheck(POS, VPOS, 1, 1)
 2850         REM PRINT TAB(POS,VPOS);
 2860         REM PROCcheck(POS, VPOS, 1, 1)
 2870         REM ENDIF
 2880         REM WHEN 1:
 2890         REM IF cmc% AND 32 THEN
 2900         REM IF cmc% AND 64 THEN
 2910         REM IF cmc% AND 8 THEN
 2920         REM PROCcheck(@vdu%!12, @vdu%!8, left%-cy%, top%+cx%)
 2930         REM ELSE
 2940         REM PROCcheck(@vdu%!8, @vdu%!12, left%-cx%, top%+cy%)
 2950         REM ENDIF
 2960         REM ELSE
 2970         REM IF cmc% AND 8 THEN
 2980         REM PROCcheck(@vdu%!12, @vdu%!8, right%, top%)
 2990         REM ELSE
 3000         REM PROCcheck(@vdu%!8, @vdu%!12, right%, top%)
 3010         REM ENDIF
 3020         REM ENDIF
 3030         REM ELSE
 3040         REM IF cmc% AND 8 THEN
 3050         REM PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, top%+cx%)
 3060         REM ELSE
 3070         REM PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, top%+cy%)
 3080         REM ENDIF
 3090         REM ENDIF
 3100         REM WHEN 2,3:
 3110         REM IF cmc% AND 32 THEN
 3120         REM IF cmc% AND 64 THEN
 3130         REM IF cmc% AND 8 THEN
 3140         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%-pcy%, ptop%+pcx%)
 3150         REM ELSE
 3160         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%-pcx%, ptop%+pcy%)
 3170         REM ENDIF
 3180         REM ELSE
 3190         REM IF cmc% AND 8 THEN
 3200         REM PROCcheck(@vdu%!-8, @vdu%!-12, pright%, ptop%)
 3210         REM ELSE
 3220         REM PROCcheck(@vdu%!-12, @vdu%!-8, pright%, ptop%)
 3230         REM ENDIF
 3240         REM ENDIF
 3250         REM ELSE
 3260         REM IF cmc% AND 8 THEN
 3270         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%+pcx%)
 3280         REM ELSE
 3290         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%+pcy%)
 3300         REM ENDIF
 3310         REM ENDIF
 3320         REM ENDCASE
 3330
 3340         REM CR
 3350         test% = 9
 3360         VDU 9,9,9,13
 3370         IF POS
 3380         CASE type% OF
 3390           WHEN 0:
 3400             PROCcheck(POS, VPOS, 0, 1)
 3410             PRINT TAB(POS,VPOS);
 3420             PROCcheck(POS, VPOS, 0, 1)
 3430           WHEN 1:
 3440             IF cmc% AND 8 THEN
 3450               PROCcheck(@vdu%!12, @vdu%!8, left%, top%+cx%)
 3460             ELSE
 3470               PROCcheck(@vdu%!8, @vdu%!12, left%, top%+cy%)
 3480             ENDIF
 3490           WHEN 2,3:
 3500             IF cmc% AND 8 THEN
 3510               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%+pcx%)
 3520             ELSE
 3530               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%+pcy%)
 3540             ENDIF
 3550         ENDCASE
 3560
 3570         REM Up (back to home)
 3580         test% = 10
 3590         VDU 11
 3600         IF POS
 3610         CASE type% OF
 3620           WHEN 0:
 3630             PROCcheck(POS, VPOS, 0, 0)
 3640             PRINT TAB(POS,VPOS);
 3650             PROCcheck(POS, VPOS, 0, 0)
 3660           WHEN 1:
 3670             IF cmc% AND 8 THEN
 3680               PROCcheck(@vdu%!12, @vdu%!8, left%, top%)
 3690             ELSE
 3700               PROCcheck(@vdu%!8, @vdu%!12, left%, top%)
 3710             ENDIF
 3720           WHEN 2,3:
 3730             IF cmc% AND 8 THEN
 3740               PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 3750             ELSE
 3760               PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 3770             ENDIF
 3780         ENDCASE
 3790
 3800         REM Up (scroll down or wrap; don't move on printer)
 3810         test% = 11
 3820         VDU 35,11
 3830         IF POS
 3840         CASE type% OF
 3850           WHEN 0:
 3860             IF cmc% AND 32 THEN
 3870               IF cmc% AND 16 THEN
 3880                 IF FNget(0, 0) <> 35 PROCerror
 3890                 PROCcheck(POS, VPOS, 0, ymax%-ymin%)
 3900                 PRINT TAB(POS,VPOS);
 3910                 PROCcheck(POS, VPOS, 0, ymax%-ymin%)
 3920               ELSE
 3930                 IF FNget(0, 1) <> 35 PROCerror
 3940                 PROCcheck(POS, VPOS, 0, 0)
 3950                 PRINT TAB(POS,VPOS);
 3960                 PROCcheck(POS, VPOS, 0, 0)
 3970               ENDIF
 3980             ELSE
 3990               IF cmc% AND 16 THEN
 4000                 IF FNget(0, 0) <> 35 PROCerror
 4010                 PROCcheck(POS, VPOS, 1, ymax%-ymin%)
 4020                 PRINT TAB(POS,VPOS);
 4030                 PROCcheck(POS, VPOS, 1, ymax%-ymin%)
 4040               ELSE
 4050                 IF FNget(0, 1) <> 35 PROCerror
 4060                 PROCcheck(POS, VPOS, 1, 0)
 4070                 PRINT TAB(POS,VPOS);
 4080                 PROCcheck(POS, VPOS, 1, 0)
 4090               ENDIF
 4100             ENDIF
 4110           WHEN 1:
 4120             IF cmc% AND 64 THEN
 4130               IF cmc% AND 32 THEN
 4140                 IF cmc% AND 8 THEN
 4150                   PROCcheck(@vdu%!12, @vdu%!8, left%, top%-cx%)
 4160                 ELSE
 4170                   PROCcheck(@vdu%!8, @vdu%!12, left%, top%-cy%)
 4180                 ENDIF
 4190               ELSE
 4200                 IF cmc% AND 8 THEN
 4210                   PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, top%-cx%)
 4220                 ELSE
 4230                   PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, top%-cy%)
 4240                 ENDIF
 4250               ENDIF
 4260             ELSE
 4270               IF cmc% AND 32 THEN
 4280                 IF cmc% AND 8 THEN
 4290                   PROCcheck(@vdu%!12, @vdu%!8, left%, bottom%)
 4300                 ELSE
 4310                   PROCcheck(@vdu%!8, @vdu%!12, left%, bottom%)
 4320                 ENDIF
 4330               ELSE
 4340                 IF cmc% AND 8 THEN
 4350                   PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, bottom%)
 4360                 ELSE
 4370                   PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, bottom%)
 4380                 ENDIF
 4390               ENDIF
 4400             ENDIF
 4410           WHEN 2,3:
 4420             IF cmc% AND 32 THEN
 4430               CASE TRUE OF
 4440                 WHEN (cmc% AND 64) <> 0:
 4450                   IF cmc% AND 8 THEN
 4460                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%-pcx%)
 4470                   ELSE
 4480                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%-pcy%)
 4490                   ENDIF
 4500                 WHEN (cmc% AND 16) <> 0:
 4510                   IF cmc% AND 8 THEN
 4520                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, pbottom%)
 4530                   ELSE
 4540                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, pbottom%)
 4550                   ENDIF
 4560                 OTHERWISE:
 4570                   IF cmc% AND 8 THEN
 4580                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 4590                   ELSE
 4600                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 4610                   ENDIF
 4620               ENDCASE
 4630             ELSE
 4640               CASE TRUE OF
 4650                 WHEN (cmc% AND 64) <> 0:
 4660                   IF cmc% AND 8 THEN
 4670                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%-pcx%)
 4680                   ELSE
 4690                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%-pcy%)
 4700                   ENDIF
 4710                 WHEN (cmc% AND 16) <> 0:
 4720                   IF cmc% AND 8 THEN
 4730                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, pbottom%)
 4740                   ELSE
 4750                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, pbottom%)
 4760                   ENDIF
 4770                 OTHERWISE:
 4780                   IF cmc% AND 8 THEN
 4790                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%)
 4800                   ELSE
 4810                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%)
 4820                   ENDIF
 4830               ENDCASE
 4840             ENDIF
 4850         ENDCASE
 4860
 4870         REM Bottom-left
 4880         test% = 12
 4890         CASE type% OF
 4900           WHEN 0: VDU 31,0,ymax%-ymin%
 4910           WHEN 1,2,3: VDU 30,11
 4920         ENDCASE
 4930         IF POS
 4940         CASE type% OF
 4950           WHEN 0:
 4960             PROCcheck(POS, VPOS, 0, ymax%-ymin%)
 4970             PRINT TAB(POS,VPOS);
 4980             PROCcheck(POS, VPOS, 0, ymax%-ymin%)
 4990           WHEN 1:
 5000             IF cmc% AND 64 THEN
 5010               IF cmc% AND 8 THEN
 5020                 PROCcheck(@vdu%!12, @vdu%!8, left%, top%-cx%)
 5030               ELSE
 5040                 PROCcheck(@vdu%!8, @vdu%!12, left%, top%-cy%)
 5050               ENDIF
 5060             ELSE
 5070               IF cmc% AND 8 THEN
 5080                 PROCcheck(@vdu%!12, @vdu%!8, left%, bottom%)
 5090               ELSE
 5100                 PROCcheck(@vdu%!8, @vdu%!12, left%, bottom%)
 5110               ENDIF
 5120             ENDIF
 5130           WHEN 2,3:
 5140             CASE TRUE OF
 5150               WHEN (cmc% AND 64) <> 0:
 5160                 IF cmc% AND 8 THEN
 5170                   PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%-pcx%)
 5180                 ELSE
 5190                   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%-pcy%)
 5200                 ENDIF
 5210               WHEN (cmc% AND 16) <> 0:
 5220                 IF cmc% AND 8 THEN
 5230                   PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, pbottom%)
 5240                 ELSE
 5250                   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, pbottom%)
 5260                 ENDIF
 5270               OTHERWISE:
 5280                 IF cmc% AND 8 THEN
 5290                   PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 5300                 ELSE
 5310                   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 5320                 ENDIF
 5330             ENDCASE
 5340         ENDCASE
 5350
 5360         REM down (scroll up or wrap)
 5370         test% = 13
 5380         VDU 36,10
 5390         IF POS
 5400         CASE type% OF
 5410           WHEN 0:
 5420             IF cmc% AND 32 THEN
 5430               IF cmc% AND 16 THEN
 5440                 IF FNget(0, ymax%-ymin%) <> 36 PROCerror
 5450                 PROCcheck(POS, VPOS, 0, 0)
 5460                 PRINT TAB(POS,VPOS);
 5470                 PROCcheck(POS, VPOS, 0, 0)
 5480               ELSE
 5490                 IF FNget(0, ymax%-ymin%-1) <> 36 PROCerror
 5500                 PROCcheck(POS, VPOS, 0, ymax%-ymin%)
 5510                 PRINT TAB(POS,VPOS);
 5520                 PROCcheck(POS, VPOS, 0, ymax%-ymin%)
 5530               ENDIF
 5540             ELSE
 5550               IF cmc% AND 16 THEN
 5560                 IF FNget(0, ymax%-ymin%) <> 36 PROCerror
 5570                 PROCcheck(POS, VPOS, 1, 0)
 5580                 PRINT TAB(POS,VPOS);
 5590                 PROCcheck(POS, VPOS, 1, 0)
 5600               ELSE
 5610                 IF FNget(0, ymax%-ymin%-1) <> 36 PROCerror
 5620                 PROCcheck(POS, VPOS, 1, ymax%-ymin%)
 5630                 PRINT TAB(POS,VPOS);
 5640                 PROCcheck(POS, VPOS, 1, ymax%-ymin%)
 5650               ENDIF
 5660             ENDIF
 5670           WHEN 1:
 5680             IF cmc% AND 32 THEN
 5690               IF cmc% AND 8 THEN
 5700                 PROCcheck(@vdu%!12, @vdu%!8, left%, top%)
 5710               ELSE
 5720                 PROCcheck(@vdu%!8, @vdu%!12, left%, top%)
 5730               ENDIF
 5740             ELSE
 5750               IF cmc% AND 8 THEN
 5760                 PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, top%)
 5770               ELSE
 5780                 PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, top%)
 5790               ENDIF
 5800             ENDIF
 5810           WHEN 2,3:
 5820             IF cmc% AND 32 THEN
 5830               CASE TRUE OF
 5840                 WHEN (cmc% AND 64) <> 0:
 5850                   IF cmc% AND 8 THEN
 5860                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 5870                   ELSE
 5880                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 5890                   ENDIF
 5900                 WHEN (cmc% AND 16) <> 0:
 5910                   IF cmc% AND 8 THEN
 5920                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 5930                   ELSE
 5940                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 5950                   ENDIF
 5960                 OTHERWISE:
 5970                   IF cmc% AND 8 THEN
 5980                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%+pcx%)
 5990                   ELSE
 6000                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%+pcy%)
 6010                   ENDIF
 6020               ENDCASE
 6030             ELSE
 6040               CASE TRUE OF
 6050                 WHEN (cmc% AND 64) <> 0:
 6060                   IF cmc% AND 8 THEN
 6070                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%)
 6080                   ELSE
 6090                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%)
 6100                   ENDIF
 6110                 WHEN (cmc% AND 16) <> 0:
 6120                   IF cmc% AND 8 THEN
 6130                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%)
 6140                   ELSE
 6150                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%)
 6160                   ENDIF
 6170                 OTHERWISE:
 6180                   IF cmc% AND 8 THEN
 6190                     PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%+pcx%)
 6200                   ELSE
 6210                     PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%+pcy%)
 6220                   ENDIF
 6230               ENDCASE
 6240             ENDIF
 6250         ENDCASE
 6260
 6270         REM Bottom-right
 6280         test% = 14
 6290         CASE type% OF
 6300           WHEN 0:  VDU 31,xmax%-xmin%,ymax%-ymin%
 6310           WHEN 1:  VDU 30,8
 6320           WHEN 2,3:  VDU 30,8
 6330         ENDCASE
 6340         IF POS
 6350         CASE type% OF
 6360           WHEN 0:
 6370             PROCcheck(POS, VPOS, xmax%-xmin%, ymax%-ymin%)
 6380             PRINT TAB(POS,VPOS);
 6390             PROCcheck(POS, VPOS, xmax%-xmin%, ymax%-ymin%)
 6400           WHEN 1:
 6410             IF cmc% AND 64 THEN
 6420               IF cmc% AND 8 THEN
 6430                 PROCcheck(@vdu%!12, @vdu%!8, left%-cy%, top%)
 6440               ELSE
 6450                 PROCcheck(@vdu%!8, @vdu%!12, left%-cx%, top%)
 6460               ENDIF
 6470             ELSE
 6480               IF cmc% AND 8 THEN
 6490                 PROCcheck(@vdu%!12, @vdu%!8, right%, bottom%)
 6500               ELSE
 6510                 PROCcheck(@vdu%!8, @vdu%!12, right%, bottom%)
 6520               ENDIF
 6530             ENDIF
 6540           WHEN 2,3:
 6550             CASE TRUE OF
 6560               WHEN (cmc% AND 64) <> 0:
 6570                 IF cmc% AND 8 THEN
 6580                   PROCcheck(@vdu%!-8, @vdu%!-12, pleft%-pcy%, ptop%)
 6590                 ELSE
 6600                   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%-pcx%, ptop%)
 6610                 ENDIF
 6620               WHEN (cmc% AND 16) <> 0:
 6630                 IF cmc% AND 8 THEN
 6640                   PROCcheck(@vdu%!-8, @vdu%!-12, pright%, pbottom%)
 6650                 ELSE
 6660                   PROCcheck(@vdu%!-12, @vdu%!-8, pright%, pbottom%)
 6670                 ENDIF
 6680               OTHERWISE:
 6690                 IF cmc% AND 8 THEN
 6700                   PROCcheck(@vdu%!-8, @vdu%!-12, pright%, ptop%)
 6710                 ELSE
 6720                   PROCcheck(@vdu%!-12, @vdu%!-8, pright%, ptop%)
 6730                 ENDIF
 6740             ENDCASE
 6750         ENDCASE
 6760
 6770         REM Character (pending, not moving or wrap)
 6780         REM test% = 15
 6790         REM VDU 37
 6800         REM IF POS
 6810         REM CASE type% OF
 6820         REM WHEN 0:
 6830         REM CASE TRUE OF
 6840         REM WHEN (cmc% AND 32) <> 0:
 6850         REM IF FNget(POS,VPOS) <> 37 PROCerror
 6860         REM PROCcheck(POS, VPOS, xmax%-xmin%, ymax%-ymin%)
 6870         REM PRINT TAB(POS,VPOS);
 6880         REM PROCcheck(POS, VPOS, xmax%-xmin%, ymax%-ymin%)
 6890         REM WHEN (cmc% AND 1) <> 0:
 6900         REM IF FNget(xmax%-xmin%, ymax%-ymin%) <> 37 PROCerror
 6910         REM PROCcheck(POS, VPOS, xmax%-xmin%+1, ymax%-ymin%)
 6920         REM PRINT TAB(POS,VPOS);
 6930         REM PROCcheck(POS, VPOS, xmax%-xmin%+1, ymax%-ymin%)
 6940         REM WHEN (cmc% AND 16) <> 0:
 6950         REM IF FNget(xmax%-xmin%, ymax%-ymin%) <> 37 PROCerror
 6960         REM PROCcheck(POS, VPOS, 0, 0)
 6970         REM PRINT TAB(POS,VPOS);
 6980         REM PROCcheck(POS, VPOS, 0, 0)
 6990         REM OTHERWISE:
 7000         REM IF FNget(xmax%-xmin%, ymax%-ymin%) <> 37 PROCerror
 7010         REM PROCcheck(POS, VPOS, 0, ymax%-ymin%+1)
 7020         REM PRINT TAB(POS,VPOS);
 7030         REM PROCcheck(POS, VPOS, 0, ymax%-ymin%+1)
 7040         REM ENDCASE
 7050         REM WHEN 1:
 7060         REM IF cmc% AND 32 THEN
 7070         REM IF cmc% AND 64 THEN
 7080         REM IF cmc% AND 8 THEN
 7090         REM PROCcheck(@vdu%!12, @vdu%!8, left%-cy%, top%)
 7100         REM ELSE
 7110         REM PROCcheck(@vdu%!8, @vdu%!12, left%-cx%, top%)
 7120         REM ENDIF
 7130         REM ELSE
 7140         REM IF cmc% AND 8 THEN
 7150         REM PROCcheck(@vdu%!12, @vdu%!8, right%, bottom%)
 7160         REM ELSE
 7170         REM PROCcheck(@vdu%!8, @vdu%!12, right%, bottom%)
 7180         REM ENDIF
 7190         REM ENDIF
 7200         REM ELSE
 7210         REM IF cmc% AND 8 THEN
 7220         REM PROCcheck(@vdu%!12, @vdu%!8, left%, top%)
 7230         REM ELSE
 7240         REM PROCcheck(@vdu%!8, @vdu%!12, left%, top%)
 7250         REM ENDIF
 7260         REM ENDIF
 7270         REM WHEN 2,3:
 7280         REM IF cmc% AND 32 THEN
 7290         REM CASE TRUE OF
 7300         REM WHEN (cmc% AND 64) <> 0:
 7310         REM IF cmc% AND 8 THEN
 7320         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%-pcy%, ptop%)
 7330         REM ELSE
 7340         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%-pcx%, ptop%)
 7350         REM ENDIF
 7360         REM WHEN (cmc% AND 16) <> 0:
 7370         REM IF cmc% AND 8 THEN
 7380         REM PROCcheck(@vdu%!-8, @vdu%!-12, pright%, pbottom%)
 7390         REM ELSE
 7400         REM PROCcheck(@vdu%!-12, @vdu%!-8, pright%, pbottom%)
 7410         REM ENDIF
 7420         REM OTHERWISE:
 7430         REM IF cmc% AND 8 THEN
 7440         REM PROCcheck(@vdu%!-8, @vdu%!-12, pright%, ptop%)
 7450         REM ELSE
 7460         REM PROCcheck(@vdu%!-12, @vdu%!-8, pright%, ptop%)
 7470         REM ENDIF
 7480         REM ENDCASE
 7490         REM ELSE
 7500         REM CASE TRUE OF
 7510         REM WHEN (cmc% AND 64) <> 0:
 7520         REM IF cmc% AND 8 THEN
 7530         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 7540         REM ELSE
 7550         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 7560         REM ENDIF
 7570         REM WHEN (cmc% AND 16) <> 0:
 7580         REM IF cmc% AND 8 THEN
 7590         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%)
 7600         REM ELSE
 7610         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 7620         REM ENDIF
 7630         REM OTHERWISE:
 7640         REM IF cmc% AND 8 THEN
 7650         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%, ptop%+pcx%)
 7660         REM ELSE
 7670         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%+pcy%)
 7680         REM ENDIF
 7690         REM ENDCASE
 7700         REM ENDIF
 7710         REM ENDCASE
 7720
 7730         REM Character (unpend/scroll, or not moving)
 7740         REM test% = 16
 7750         REM VDU 38
 7760         REM IF POS
 7770         REM CASE type% OF
 7780         REM WHEN 0:
 7790         REM CASE TRUE OF
 7800         REM WHEN (cmc% AND 32) <> 0:
 7810         REM IF FNget(POS,VPOS) <> 38 PROCerror
 7820         REM PROCcheck(POS, VPOS, xmax%-xmin%, ymax%-ymin%)
 7830         REM PRINT TAB(POS,VPOS);
 7840         REM PROCcheck(POS, VPOS, xmax%-xmin%, ymax%-ymin%)
 7850         REM WHEN (cmc% AND 16) <> 0:
 7860         REM IF FNget(0, 0) <> 38 PROCerror
 7870         REM PROCcheck(POS, VPOS, 1, 0)
 7880         REM PRINT TAB(POS,VPOS);
 7890         REM PROCcheck(POS, VPOS, 1, 0)
 7900         REM OTHERWISE:
 7910         REM IF FNget(xmax%-xmin%,ymax%-ymin%-1) <> 37 PROCerror
 7920         REM IF FNget(0,ymax%-ymin%) <> 38 PROCerror
 7930         REM PROCcheck(POS, VPOS, 1, ymax%-ymin%)
 7940         REM PRINT TAB(POS,VPOS);
 7950         REM PROCcheck(POS, VPOS, 1, ymax%-ymin%)
 7960         REM ENDCASE
 7970         REM WHEN 1:
 7980         REM IF cmc% AND 32 THEN
 7990         REM IF cmc% AND 64 THEN
 8000         REM IF cmc% AND 8 THEN
 8010         REM PROCcheck(@vdu%!12, @vdu%!8, left%-cy%, top%)
 8020         REM ELSE
 8030         REM PROCcheck(@vdu%!8, @vdu%!12, left%-cx%, top%)
 8040         REM ENDIF
 8050         REM ELSE
 8060         REM IF cmc% AND 8 THEN
 8070         REM PROCcheck(@vdu%!12, @vdu%!8, right%, bottom%)
 8080         REM ELSE
 8090         REM PROCcheck(@vdu%!8, @vdu%!12, right%, bottom%)
 8100         REM ENDIF
 8110         REM ENDIF
 8120         REM ELSE
 8130         REM IF cmc% AND 8 THEN
 8140         REM PROCcheck(@vdu%!12, @vdu%!8, left%+cy%, top%)
 8150         REM ELSE
 8160         REM PROCcheck(@vdu%!8, @vdu%!12, left%+cx%, top%)
 8170         REM ENDIF
 8180         REM ENDIF
 8190         REM WHEN 2,3:
 8200         REM IF cmc% AND 32 THEN
 8210         REM CASE TRUE OF
 8220         REM WHEN (cmc% AND 64) <> 0:
 8230         REM IF cmc% AND 8 THEN
 8240         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%-pcy%, ptop%)
 8250         REM ELSE
 8260         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%-pcx%, ptop%)
 8270         REM ENDIF
 8280         REM WHEN (cmc% AND 16) <> 0:
 8290         REM IF cmc% AND 8 THEN
 8300         REM PROCcheck(@vdu%!-8, @vdu%!-12, pright%, pbottom%)
 8310         REM ELSE
 8320         REM PROCcheck(@vdu%!-12, @vdu%!-8, pright%, pbottom%)
 8330         REM ENDIF
 8340         REM OTHERWISE:
 8350         REM IF cmc% AND 8 THEN
 8360         REM PROCcheck(@vdu%!-8, @vdu%!-12, pright%, ptop%)
 8370         REM ELSE
 8380         REM PROCcheck(@vdu%!-12, @vdu%!-8, pright%, ptop%)
 8390         REM ENDIF
 8400         REM ENDCASE
 8410         REM ELSE
 8420         REM CASE TRUE OF
 8430         REM WHEN (cmc% AND 64) <> 0:
 8440         REM IF cmc% AND 8 THEN
 8450         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%)
 8460         REM ELSE
 8470         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%)
 8480         REM ENDIF
 8490         REM WHEN (cmc% AND 16) <> 0:
 8500         REM IF cmc% AND 8 THEN
 8510         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%)
 8520         REM ELSE
 8530         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%)
 8540         REM ENDIF
 8550         REM OTHERWISE:
 8560         REM IF cmc% AND 8 THEN
 8570         REM PROCcheck(@vdu%!-8, @vdu%!-12, pleft%+pcy%, ptop%+pcx%)
 8580         REM ELSE
 8590         REM PROCcheck(@vdu%!-12, @vdu%!-8, pleft%+pcx%, ptop%+pcy%)
 8600         REM ENDIF
 8610         REM ENDCASE
 8620         REM ENDIF
 8630         REM ENDCASE
 8640
 8650         VDU 6,3,4,26,23,16,0|
 8660
 8670       NEXT cmc%
 8680     NEXT type%
 8690   NEXT viewport%
 8700 NEXT mode%
 8710
 8720 test% = 17
 8730 IF maxtype% = 3 THEN
 8740   REM Eject sheet from printer:
 8750   pcx% = @vdu%!224 : pcy% = @vdu%!228
 8760   pleft% = @vdu%!232 : ptop% = @vdu%!240
 8770   pright% = @vdu%!236 : pbottom% = @vdu%!244
 8780   pright% = pleft%+((pright%-pleft%)DIVpcx%-1)*pcx%
 8790   pbottom% = ptop%+((pbottom%-ptop%)DIVpcy%-1)*pcy%
 8800
 8810   VDU 2,1,30,23,16,16|1,11,23,16,0|3
 8820   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, pbottom%)
 8830   IF @vdu%!-4 = 0 THEN PROCerror
 8840   VDU 2,1,10,3 : REM eject
 8850   PROCcheck(@vdu%!-12, @vdu%!-8, pleft%, ptop%)
 8860   VDU 2,1,12,3 : REM eject
 8870   IF @vdu%!-4     THEN PROCerror
 8880 ENDIF
 8890
 8910 VDU 30 : COLOUR 1,0,255,0 : COLOUR 1
 8920 PRINT "All tests completed successfully."
 8930 END
 8940
 8950 DEF FNget(X%,Y%)
 8960 LOCAL A%,C%,U%,V%
 8970 A% = 135 : U% = POS : V% = VPOS
 8980 PRINT TAB(X%,Y%);
 8990 C% = USR(&FFF4) DIV 256 AND &FF
 9000 PRINT TAB(U%,V%);
 9010 = C%
 9020
 9030 DEF PROCcheck(A%, B%, C%, D%)
 9040 IF A%=C% IF B%=D% ENDPROC
 9050 DEF PROCerror : LOCAL A%,B%,C%,D%
 9060 VDU 6,3,20,23,16,0|
 9070 MODE 3 : COLOUR 11
 9080 PRINT "Failed at test%=";test%", mode%=";mode% ", viewport%=";viewport% ", type%=";type% ", cmc%=&";~cmc%
 9090 IF A%<>C% PRINT "Parameter X is ";A% " but should be ";C%
 9100 IF B%<>D% PRINT "Parameter Y is ";B% " but should be ";D%
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Oct 23, 2021 12:17 pm
Below is the test program I use (with the VDU 5 stuff disabled); it runs successfully in ARM BASIC V, BBC BASIC for Windows and BBC BASIC for SDL 2.0, so I think it can be considered reasonably accurate.

Currently, with your latest nightly build for Windows, it's failing with:

Code: Select all

Failed at test%=7, mode%=0, viewport%=0, type%=0, cmc%=&1
Parameter X is 0 but should be 80
Parameter Y is 1 but should be 0
That might be slightly concerning because VDU 23,16,1| isn't a vertical printing mode, or even a right-to-left mode, it's just the normal 'pending scroll' mode which I assumed had long since been working in Matrix Brandy.
There was a typo that broke it.

However, before the typo (and after fixing it), it still fails with:

Code: Select all

Failed at test%=7, mode%=0, viewport%=0, type%=0, cmc%=&1
Parameter X is 79 but should be 80
I'm trying to work out what the code is doing to trace what's going on inside. There are some points where POS is returning 80 (from debugging statements in the Brandy code) but I can see the last one it shows, just when it fails, returns 79.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Sat Oct 23, 2021 1:34 pm
There are some points where POS is returning 80
Yes, here's an example of when POS can return 80 (both on Acorn systems - even a BBC Master - and mine):

Code: Select all

      MODE 3
      VDU 23,16,1|
      VDU 10,8,33
      X% = POS
      PRINT X%
You might want to argue that it's 'wrong' but it's a very long-standing behaviour (presumably a side-effect of the pending-scroll functionality) that has never been challenged, as far as I am aware. Since Matrix Brandy usually faithfully emulates what Acorn systems do, I had expected it to in this case.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Oct 23, 2021 1:55 pm
Soruk wrote:
Sat Oct 23, 2021 1:34 pm
There are some points where POS is returning 80
Yes, here's an example of when POS can return 80 (both on Acorn systems - even a BBC Master - and mine):

Code: Select all

      MODE 3
      VDU 23,16,1|
      VDU 10,8,33
      X% = POS
      PRINT X%
You might want to argue that it's 'wrong' but it's a very long-standing behaviour (presumably a side-effect of the pending-scroll functionality) that has never been challenged, as far as I am aware. Since Matrix Brandy usually faithfully emulates what Acorn systems do, I had expected it to in this case.
I've got it now such that if I limit your test program above for cmc% to stop after 7, it passes all the tests. I know it'll break above that because I have yet to implement text-mode vertical text. That is a very helpful test harness, thank you for sharing! :)

I've kicked off a nightly build early, with my new auto-build naming convention, last night's auto build won't be overridden, and as a bug tracking aid, the filename also includes the git tag.
Matrix Brandy BASIC VI (work in progress)
User avatar
Richard Russell
Posts: 2523
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Richard Russell »

Soruk wrote:
Sat Oct 23, 2021 10:10 pm
That is a very helpful test harness, thank you for sharing! :)
Sometime I ought to investigate why my BASICs and Acorn's differ on tests 8, 15 and 16 which is why they're REMmed-out in that code. In the meantime, be cautious about enabling those tests and don't consider them definitive.

The VDU 5 tests cannot easily be enabled because of the lack of a platform-independent way of reading the current graphics pointer coordinates. My code is using @vdu%!8 and @vdu%!12, Matrix Brandy will presumably be able to use VDU(n), but the version of ARM BASIC V I have here doesn't support them (yes I know you told me how to install a later version of BASIC but I didn't do it and now I've forgotten).
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
Soruk
Posts: 951
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for console and SDL1.2: V1.22.11 released

Post by Soruk »

Richard Russell wrote:
Sat Oct 23, 2021 11:23 pm
(yes I know you told me how to install a later version of BASIC but I didn't do it and now I've forgotten).
Here you go - viewtopic.php?p=329156#p329156
Matrix Brandy BASIC VI (work in progress)
Post Reply

Return to “modern implementations of classic programming languages”