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

for discussion of bbc basic for windows/sdl, brandy and more
User avatar
sweh
Posts: 2236
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by sweh » Tue Aug 06, 2019 2:15 pm

FWIW, I get an identical failure with Debian 10 64bit build. TOSTRING(value) is not valid. My _guess_ is that "value" is a 32bit value, but with 64bit executables the pointer could easily be outside that range.

When I compile a 32bit executable (BRANDY_BUILD_FLAGS="-g -O0 -m32" LDFLAGS=-m32 make) then the program runs without error.
Rgds
Stephen

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Tue Aug 06, 2019 2:48 pm

sweh wrote:
Tue Aug 06, 2019 2:15 pm
with 64bit executables the pointer could easily be outside that range.
Here's what I get as the value of PAGE on various 64-bit builds of BBC BASIC for SDL 2.0 (obviously this can vary from run to run but it gives an indication of whether 32-bit pointers will suffice):

Code: Select all

      *HEX 64
      PRINT ~PAGE
Windows 64-bit: &D401C00
Ubuntu 18.04 LTS: &431C00
MacOS High Sierra: &11522DC00
iOS 12.3.1: &107065D00

In these particular cases Windows and Ubuntu won't fail if pointers are truncated to 32-bits but MacOS and iOS will.

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Tue Aug 06, 2019 4:10 pm

To help the debugging, I have downloaded some old tarballs and have make tests.
The last version which works telstar for my system is "MatrixBrandy-1.21.19".
So some changes from this point, have broke the code.
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Tue Aug 06, 2019 5:10 pm

bakoulis wrote:
Tue Aug 06, 2019 4:10 pm
To help the debugging, I have downloaded some old tarballs and have make tests.
The last version which works telstar for my system is "MatrixBrandy-1.21.19".
So some changes from this point, have broke the code.
The Telstar client in 1.21.19 doesn't make that SYS call - indeed, that call isn't implemented in 1.21.19.

The underlying issue is that the SYS call only handles 32-bit values, which for strings, is pointers. Right now it's using "actual" memory addresses, that's decoded elsewhere, but other things like indirections use relative addresses from the start of Brandy workspace (and maximum workspace is a byte short of 2GB (i.e. &7FFFFFF).

In a branch I'm working on implementing 64-bit integers (which could then lead into SYS using 64-bit ints instead of 32-bit), but there's possibly an alternative - to use the relative addressing to pass the string back and handle the offset at both ends. Might, might not work.

As @sweh has managed to replicate the issue on Debian 64-bit, but I'm totally unable to replicate in CentOS 6 or 7 64-bit, I might need to build myself a Debian 64-bit VM. For someone used to the way Red Hat / CentOS / Fedora do things, Debian is a bit of a weird animal.
Last edited by Soruk on Tue Aug 06, 2019 5:12 pm, edited 1 time in total.
Matrix Brandy BASIC VI (work in progress)

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Tue Aug 06, 2019 5:49 pm

Soruk wrote:
Tue Aug 06, 2019 5:10 pm
I might need to build myself a Debian 64-bit VM.
I'm not at all sure that doing so would guarantee it allocating memory outside the 32-bit range, it may depend on so many factors. It looks from here that there's a reasonable likelihood that the MAP_FIXED flag in mmap() is implemented in CentOS so you might like to try that to see if you can force it to return non-32-bit addresses on your preferred platform.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Tue Aug 06, 2019 5:51 pm

Richard Russell wrote:
Tue Aug 06, 2019 5:49 pm
Soruk wrote:
Tue Aug 06, 2019 5:10 pm
I might need to build myself a Debian 64-bit VM.
I'm not at all sure that doing so would guarantee it allocating memory outside the 32-bit range, it may depend on so many factors. It looks from here that there's a reasonable likelihood that the MAP_FIXED flag in mmap() is implemented in CentOS so you might like to try that to see if you can force it to return non-32-bit addresses on your preferred platform.
Unfortunately, Brandy makes almost no use of mmap(), memory is allocated with malloc(). (The one mmap call is used to map /dev/gpiomem, on RasPi hardware.)
Matrix Brandy BASIC VI (work in progress)

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Tue Aug 06, 2019 6:21 pm

Soruk wrote:
Tue Aug 06, 2019 5:51 pm
Unfortunately, Brandy makes almost no use of mmap()
Surely there's no reason why you shouldn't change the malloc() to a mmap() for test purposes, for example determined by an #ifdef? Anyway, if you're allocating up to 2 Gbytes of contiguous memory mmap() is arguably a better choice (I have to use it because I need to allocate executable memory for use by the BBC BASIC assembler).

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Tue Aug 06, 2019 6:45 pm

Soruk wrote:
Tue Aug 06, 2019 5:10 pm
bakoulis wrote:
Tue Aug 06, 2019 4:10 pm
To help the debugging, I have downloaded some old tarballs and have make tests.
The last version which works telstar for my system is "MatrixBrandy-1.21.19".
So some changes from this point, have broke the code.
The Telstar client in 1.21.19 doesn't make that SYS call - indeed, that call isn't implemented in 1.21.19.

The underlying issue is that the SYS call only handles 32-bit values, which for strings, is pointers. Right now it's using "actual" memory addresses, that's decoded elsewhere, but other things like indirections use relative addresses from the start of Brandy workspace (and maximum workspace is a byte short of 2GB (i.e. &7FFFFFF).

In a branch I'm working on implementing 64-bit integers (which could then lead into SYS using 64-bit ints instead of 32-bit), but there's possibly an alternative - to use the relative addressing to pass the string back and handle the offset at both ends. Might, might not work.

As @sweh has managed to replicate the issue on Debian 64-bit, but I'm totally unable to replicate in CentOS 6 or 7 64-bit, I might need to build myself a Debian 64-bit VM. For someone used to the way Red Hat / CentOS / Fedora do things, Debian is a bit of a weird animal.
The old telstar from 1.21.19 tarball, works fine with brandy 1.22.0!!!
The problem is the new code of telstar at line 110!!!
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

User avatar
sweh
Posts: 2236
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by sweh » Tue Aug 06, 2019 9:40 pm

bakoulis wrote:
Tue Aug 06, 2019 6:45 pm
The old telstar from 1.21.19 tarball, works fine with brandy 1.22.0!!!
The problem is the new code of telstar at line 110!!!
The problem isn't "telstar" as such; it's just the telstar exercises the bug. The problem is the command

Code: Select all

SYS "Brandy_GetVideoDriver" TO v$,,,,v%
I can crash the 64bit version of Brandy by typing that on the command line :-)
Rgds
Stephen

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Wed Aug 07, 2019 4:48 am

I've checked in a change which indirects the string return via BASIC workspace, so a 32-bit value can be passed back, which points to a 64-bit value. Unfortunately it does result in compiler warnings on 32-bit, but does seem to work for me. I'd appreciate a quick test from anyone on 64-bit where a crash was being encoutered with SYS "Brandy_GetVideoDriver". Thank you!
Matrix Brandy BASIC VI (work in progress)

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Wed Aug 07, 2019 5:29 am

Where is this version? The master brunch at github is unmodified the last 18 hours!
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Wed Aug 07, 2019 5:49 am

bakoulis wrote:
Wed Aug 07, 2019 5:29 am
Where is this version? The master brunch at github is unmodified the last 18 hours!
My mistake, checked it in to my local server but didn't push it to GitHub. Please try again.
Matrix Brandy BASIC VI (work in progress)

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Wed Aug 07, 2019 6:00 am

Now works fine!
Not even errors or warnings at compiler.
:wink:
Can we telnet BBSs at 80 columns with some modifications?
It will be very useful especially for ARM BASIC VI at RPi PICO OS!
Maybe will be the fist real use for this little ARM BASIC OS.
:idea:
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Wed Aug 07, 2019 7:54 am

bakoulis wrote:
Wed Aug 07, 2019 6:00 am
Now works fine!
Not even errors or warnings at compiler.
:wink:
Can we telnet BBSs at 80 columns with some modifications?
It will be very useful especially for ARM BASIC VI at RPi PICO OS!
Maybe will be the fist real use for this little ARM BASIC OS.
:idea:
In theory, yes. In practice, I don't know ANSI codes, and the networking used in Matrix Brandy is unique to Matrix Brandy in that I extended OPENUP. My Telstar client won't run on RISC OS either, as it uses a BBC Micro trick of talking to the MODE 7 video memory in addition to the Matrix Brandy-specific networking interface.

(That's what part of the SYS call is on line 110, v% contains the base of MODE 7 video.)
Last edited by Soruk on Wed Aug 07, 2019 7:59 am, edited 1 time in total.
Matrix Brandy BASIC VI (work in progress)

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Wed Aug 07, 2019 12:36 pm

Even if it cannot running on RPi PICO OS, will be have fun to BBSing with BASIC!
Maybe telstar is not possible to converted for this job and a new program from scratch required.
You don't know ANSI codes, but also you don't know SDL sound system and now Brandy have sound!
Maybe someone else make a new ANSI terminal program for Brandy BASIC just for fun!
All this is just thoughts and maybe some new ideas for exploration.
:idea:
Last edited by bakoulis on Wed Aug 07, 2019 12:37 pm, edited 1 time in total.
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Wed Aug 07, 2019 12:45 pm

bakoulis wrote:
Wed Aug 07, 2019 12:36 pm
Even if it cannot running on RPi PICO OS, will be have fun to BBSing with BASIC!
Maybe telstar is not possible to converted for this job and a new program from scratch required.
You don't know ANSI codes, but also you don't know SDL sound system and now Brandy have sound!
Maybe someone else make a new ANSI terminal program for Brandy BASIC just for fun!
All this is just thoughts and maybe some new ideas for exploration.
:idea:
For Brandy it could be done using one of the text-mode versions outputting to an xterm, and letting the xterm doing the ANSI heavy lifting. That's rather cheating though, and you might as well just telnet from your Linux command line (and it's entirely non-portable).
Matrix Brandy BASIC VI (work in progress)

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Wed Aug 07, 2019 1:03 pm

Soruk wrote:
Wed Aug 07, 2019 12:45 pm
bakoulis wrote:
Wed Aug 07, 2019 12:36 pm
Even if it cannot running on RPi PICO OS, will be have fun to BBSing with BASIC!
Maybe telstar is not possible to converted for this job and a new program from scratch required.
You don't know ANSI codes, but also you don't know SDL sound system and now Brandy have sound!
Maybe someone else make a new ANSI terminal program for Brandy BASIC just for fun!
All this is just thoughts and maybe some new ideas for exploration.
:idea:
For Brandy it could be done using one of the text-mode versions outputting to an xterm, and letting the xterm doing the ANSI heavy lifting. That's rather cheating though, and you might as well just telnet from your Linux command line (and it's entirely non-portable).
Yes I can, but the results is very ugly. For this reason I using all the time SyncTerm, which is perfect for this job and have ANSI graphics like early 90's!
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

User avatar
sweh
Posts: 2236
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by sweh » Wed Aug 07, 2019 8:07 pm

Soruk wrote:
Wed Aug 07, 2019 5:49 am
My mistake, checked it in to my local server but didn't push it to GitHub. Please try again.
Seems to work for me :-)
Rgds
Stephen

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Wed Aug 07, 2019 10:00 pm

sweh wrote:
Wed Aug 07, 2019 8:07 pm
Soruk wrote:
Wed Aug 07, 2019 5:49 am
My mistake, checked it in to my local server but didn't push it to GitHub. Please try again.
Seems to work for me :-)
That's very good to know! This workaround makes use of my raising PAGE a couple of releases ago, so I can write pointers into the bottom of the BASIC addressable space (from within BASIC I'm using the first 8 bytes at &0100) to store a 64-bit pointer which can be dereferenced at the other side of the SYS calling code. Since the BASIC addressable space is limited to 2GB - 1 byte, anything in there can be safely passed across as 32 bits.
On 32-bit systems, after making the above SYS call, !&0100 will contain the actual C-visible address of the buffer, !&0104 should be zero. The reason I'm not putting the actual string into the BASIC workspace before it's put into the string variable is, because a string can go to 64K in length in Brandy, I'd need to raise PAGE or lower HIMEM to reserve at least 64K just for this, which seems rather odd and quite wasteful.
Matrix Brandy BASIC VI (work in progress)

User avatar
scruss
Posts: 270
Joined: Sun Jul 01, 2018 4:12 pm
Location: Toronto
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by scruss » Thu Aug 08, 2019 12:38 am

bakoulis wrote:
Wed Aug 07, 2019 12:36 pm
Maybe someone else make a new ANSI terminal program for Brandy BASIC just for fun!
I think the intersection of "people who could program this in BASIC" and "people who would do this for fun" is likely to be the empty set. Especially when you consider the niche factor of trying to get it to work on RISC OS Pico.

Just use an ANSI terminal program. There has to be one for RISC OS.

I am so impressed how sound just showed up in Matrix Brandy! My machines now do a 6 am git pull/build via the crontab just so I don't miss out.

cheers,
Stewart

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Thu Aug 08, 2019 1:19 am

scruss wrote:
Thu Aug 08, 2019 12:38 am
I think the intersection of "people who could program this in BASIC" and "people who would do this for fun" is likely to be the empty set.
Not quite! I've today written a little program to do exactly that (i.e. it implements enough of the ANSI.SYS terminal protocol to support most 'telnet' Bulletin Boards) which runs in both BBC BASIC for Windows and BBC BASIC for SDL 2.0. It's not sufficiently generic to run in Matrix Brandy but somebody could probably adapt it to do so. It's the character set rather than the terminal emulation which is the issue: BB4W natively supports the required DOS/OEM character set and in BBCSDL I've used Unicode to achieve it, but I don't think Brandy supports either.

Here's a screen shot:
starbase.png

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Thu Aug 08, 2019 5:42 am

Wow, fantastic news!
Imagine BBSing via BBC BASIC!
Maybe this is also possible for our beloved BBC B and BBC Master Micros with those WiFi232 modems.
From what I can understanding by the related posts, the Comstar ROM terminal is more a Telstar VIEWDATA program.
Last edited by bakoulis on Thu Aug 08, 2019 5:42 am, edited 1 time in total.
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Thu Aug 08, 2019 2:15 pm

bakoulis wrote:
Thu Aug 08, 2019 5:42 am
Maybe this is also possible for our beloved BBC B and BBC Master Micros with those WiFi232 modems.
My ANSI.SYS emulation (which basically converts each of the escape sequences to an equivalent VDU sequence) relies to some extent on VDU commands that aren't available on the Model B (although they may be on the Master, I'm not sure). But I suspect those features are used by few if any BBSs so you may indeed have a chance of making it work, using VDU 23 to redefine characters to match the expected DOS/OEM ones as closely as possible.

User avatar
dhg2
Posts: 149
Joined: Tue Oct 25, 2016 8:37 pm
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by dhg2 » Thu Aug 08, 2019 8:57 pm

Sorry if this question is already answered. Is it possible to check whether there's something in the keyboard buffer in Matrix Brandy? I notice that ADVAL(-1) always returns 0.
Regards,
- Patrick

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Thu Aug 08, 2019 9:25 pm

dhg2 wrote:
Thu Aug 08, 2019 8:57 pm
Sorry if this question is already answered. Is it possible to check whether there's something in the keyboard buffer in Matrix Brandy? I notice that ADVAL(-1) always returns 0.
Currently, no. But I'll look into it.
Matrix Brandy BASIC VI (work in progress)

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Fri Aug 09, 2019 9:53 am

Richard Russell wrote:
Thu Aug 08, 2019 1:19 am
It's the character set rather than the terminal emulation which is the issue
If I wanted to attempt to port this program to Matrix Brandy, what are my options as regards changing the character set? The BBSs need a MODE 3-style text-only screen with 80 columns by 25 rows, but unlike MODE 3 it must be possible to fill an entire character 'cell' with a box-drawing or hatched character. On the original MS-DOS hardware platforms (EGA or VGA) the character cell would have been typically 8 x 14 pixels, but the height isn't critlcal so long as a character can fill the entire cell.

Apart from this issue I don't think it should be difficult to port the program. Any language extensions I've used not supported by Brandy (e.g. the PRIVATE statement) can be fairly easily worked around. Here's a video of the program running in BBC BASIC for SDL 2.0 on a very slow 64-bit Ubuntu PC (single-core AMD Athlon!), typically it runs much faster than this:

https://youtu.be/tdE-5Qp0PX4

The program itself (in a rather rough state) can be downloaded as a plain text file from here.

User avatar
bakoulis
Posts: 343
Joined: Wed Feb 08, 2012 9:45 pm
Location: Athens, Greece
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by bakoulis » Fri Aug 09, 2019 12:34 pm

Very nice job Richard!
=D> =D> =D>
2xElectron, 3xBBC B, BBC Master.
2xAcorn A310, A420/1, 2xA3000, 2xA3010, A3020, A4000, A5000.
2xRISC PC, Acorn Pocket Book, Acorn Pocket Book II.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Fri Aug 09, 2019 1:15 pm

Richard Russell wrote:
Fri Aug 09, 2019 9:53 am
Richard Russell wrote:
Thu Aug 08, 2019 1:19 am
It's the character set rather than the terminal emulation which is the issue
If I wanted to attempt to port this program to Matrix Brandy, what are my options as regards changing the character set? The BBSs need a MODE 3-style text-only screen with 80 columns by 25 rows, but unlike MODE 3 it must be possible to fill an entire character 'cell' with a box-drawing or hatched character. On the original MS-DOS hardware platforms (EGA or VGA) the character cell would have been typically 8 x 14 pixels, but the height isn't critlcal so long as a character can fill the entire cell.
The screen mode is easy enough. Do:

Code: Select all

*NewMode 80 640 200 16 1 2
then use MODE 80. Character proportions are the same as MODE 0 so are 8x8 pixels (like CGA) and twice as tall as they are wide. (This might also be doable via VDU23,22 but I haven't played with that interface since implementing it!) This definition offers 16 colours, 0-7 are bright, 8-15 are dim (but this can be swapped with SYS "Brandy_Swap16Palette").

For the ANSI characters, they could be programmed in using VDU23.
Apart from this issue I don't think it should be difficult to port the program. Any language extensions I've used not supported by Brandy (e.g. the PRIVATE statement) can be fairly easily worked around. Here's a video of the program running in BBC BASIC for SDL 2.0 on a very slow 64-bit Ubuntu PC (single-core AMD Athlon!), typically it runs much faster than this:

https://youtu.be/tdE-5Qp0PX4

The program itself (in a rather rough state) can be downloaded as a plain text file from here.
Snagged. once I'm through this INT64 minefield, I'll take a peek.
Last edited by Soruk on Fri Aug 09, 2019 1:21 pm, edited 3 times in total.
Matrix Brandy BASIC VI (work in progress)

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

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Richard Russell » Fri Aug 09, 2019 1:58 pm

Soruk wrote:
Fri Aug 09, 2019 1:15 pm
Character proportions are the same as MODE 0 so are 8x8 pixels (like CGA) and twice as tall as they are wide.
I don't think MODE 0 style text is a very attractive solution: the rows would appear very close together, with the descenders in one row potentially touching the tops of characters in the row beneath. Also, if the 'pixels' are twice as tall as they are wide, it would be difficult to reproduce the hatched patterns in an ideal way. That's almost certainly the only option for the BBC Micro but I was hoping for something better in Brandy.

On the BBC Micro and Master, the 'gaps' between the rows of text in MODE 3 are enforced by the hardware (indeed if you change the background colour the gaps stay black, giving a striped result). I presume that in Matrix Brandy the entire MODE 3 screen, including the 'gaps', is a single bitmap (surface), and that in principle it ought to be possible to draw in the gaps (in my BASICs that is the case). Is that right, and is there a way?
For the ANSI characters, they could be programmed in using VDU23.
The terminology here is quite confusing. The communication protocol (i.e. escape sequences etc.) is defined by what in MS-DOS is called 'ANSI.SYS' but the character set isn't ANSI! Indeed the ANSI character set doesn't include the box drawing and other characters needed. Rather the character set is what is variously described as DOS, OEM or Code Page 437. It really needs something better than 8x8 characters to do it justice.

Soruk
Posts: 793
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Matrix Brandy BASIC VI for Linux with SDL: V1.22.0 released

Post by Soruk » Fri Aug 09, 2019 2:26 pm

Richard Russell wrote:
Fri Aug 09, 2019 1:58 pm
Soruk wrote:
Fri Aug 09, 2019 1:15 pm
Character proportions are the same as MODE 0 so are 8x8 pixels (like CGA) and twice as tall as they are wide.
I don't think MODE 0 style text is a very attractive solution: the rows would appear very close together, with the descenders in one row potentially touching the tops of characters in the row beneath. Also, if the 'pixels' are twice as tall as they are wide, it would be difficult to reproduce the hatched patterns in an ideal way. That's almost certainly the only option for the BBC Micro but I was hoping for something better in Brandy.

On the BBC Micro and Master, the 'gaps' between the rows of text in MODE 3 are enforced by the hardware (indeed if you change the background colour the gaps stay black, giving a striped result). I presume that in Matrix Brandy the entire MODE 3 screen, including the 'gaps', is a single bitmap (surface), and that in principle it ought to be possible to draw in the gaps (in my BASICs that is the case). Is that right, and is there a way?
MDOEs 3 and 6 have black bars enforced (VDU19,0,4| will show this).

MODE 14 is another 16 colour mode, with MODE 3 character spacing, but graphics is permitted and black bars are not enforced. However, character cells are still 8x8 and characters can't be placed into the gaps.
For the ANSI characters, they could be programmed in using VDU23.
The terminology here is quite confusing. The communication protocol (i.e. escape sequences etc.) is defined by what in MS-DOS is called 'ANSI.SYS' but the character set isn't ANSI! Indeed the ANSI character set doesn't include the box drawing and other characters needed. Rather the character set is what is variously described as DOS, OEM or Code Page 437. It really needs something better than 8x8 characters to do it justice.
Sadly, neither the BBC Micro nor RISC OS offered text-mode characters in anything other than 8x8 (ignoring MODE 7 here, which I've implemented as 16x20 characters), and Matrix Brandy's graphics is heavily modelled on that of the BBC and Archimedes/RiscPC.
Last edited by Soruk on Fri Aug 09, 2019 2:29 pm, edited 1 time in total.
Matrix Brandy BASIC VI (work in progress)

Post Reply

Return to “modern implementations of classic programming languages”