OS Version

chat about arc/risc pc gaming & RISC OS software here (NOT the core OS!)Related forum: adventures


Post Reply
zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

OS Version

Post by zolbatar » Sat Jul 13, 2019 1:25 am

I'm playing around with various methods of plotting pixels for a polygon fill and was trying to work out relative speeds of things. However, MODE 13 doesn't exist on my Pi in RISC OS 5 (obviously really). What SWI do I need to call to get the OS version so I can setup the screen accordingly?
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

sirbod
Posts: 995
Joined: Mon Apr 09, 2012 8:44 am
Location: Essex
Contact:

Re: OS Version

Post by sirbod » Sat Jul 13, 2019 4:40 am

You should use OS_CheckModeValid to check if a screen mode is available for use. It will return a suggested mode if it's not valid.

MODE 13 is perfectly valid on a Pi, provided you disable GPU mode change support by creating !Boot.Loader.CMDLINE/TXT with the following contents:

Code: Select all

disable_mode_changes

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Sat Jul 13, 2019 9:20 am

Well that does seem to allow it to set MODE 13, although it identifies as 640x480 at 64 colours (256 with tints) in BASIC.

However, I'm trying to call the fast horizontal line drawing routine from OS_ReadVduVariables and it crashes with data transfer error. Is it still supported on RISC OS 5?

Thanks.
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

User avatar
qUE
Posts: 74
Joined: Tue Dec 16, 2014 11:39 pm
Location: Bristol
Contact:

Re: OS Version

Post by qUE » Sat Jul 13, 2019 9:48 am

I suspect what is happening here is OS_ReadVDUVariables gets the video base address so your line routine can write directly to the video as a memory block, but the line routine is abusing unalignment with word writes which is perfectly legal on earlier ARM CPUs but will throw an exception on newer systems if the control register flag for "word unalign access is naughty" (I foget it's real name) is set, which I think is the case with new ROS.

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Sat Jul 13, 2019 10:12 am

That does make sense, word writes have to be aligned now. It may have been a way to get extra speed "in the day". I can of course just write directly to video memory myself, but I wanted to get a comparison of speed by different methods for interest reasons.
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

Phlamethrower
Posts: 112
Joined: Fri Nov 24, 2017 1:35 pm
Contact:

Re: OS Version

Post by Phlamethrower » Sat Jul 13, 2019 11:10 am

The OS's horizontal line routine should work - I've used it myself under RISC OS 5 (and I'm fairly certain the OS will be using it itself). Can you share your code?

User avatar
jgharston
Posts: 3596
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: OS Version

Post by jgharston » Sat Jul 13, 2019 1:47 pm

zolbatar wrote:
Sat Jul 13, 2019 1:25 am
I'm playing around with various methods of plotting pixels for a polygon fill and was trying to work out relative speeds of things. However, MODE 13 doesn't exist on my Pi in RISC OS 5 (obviously really). What SWI do I need to call to get the OS version so I can set up the screen accordingly?
In general, you should *NEVER* base your program's functionality on the version of the system it is running on, but on the ***CAPABILITY**** of the system it is running on.

*DON'T* do: if not Master, then no RTC
*DO* do: if asking for the RTC returns no data then there is no RTC

*DON'T* do: if RISC OS 2 then there are no long filename
*DO* do: if there are no long filenames then there are no long filename

*DON'T* do: if not RISC OS 3.5 then there are no Dynamic Areas
*DO* do: if there are no dynamic areas, then there are no dynamic areas

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Sat Jul 13, 2019 5:14 pm

Phlamethrower wrote:
Sat Jul 13, 2019 11:10 am
The OS's horizontal line routine should work - I've used it myself under RISC OS 5 (and I'm fairly certain the OS will be using it itself). Can you share your code?
In the documentation it says the ARM needs to be in SVC mode? Does it?
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

Phlamethrower
Posts: 112
Joined: Fri Nov 24, 2017 1:35 pm
Contact:

Re: OS Version

Post by Phlamethrower » Sat Jul 13, 2019 7:47 pm

Yes. There are a couple of kernel workspace locations which the routine writes to (which will generally be read-only from user mode), and on Archimedes machines if the screen is scrolled then some of the screen may be inaccessible from user mode.

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Sat Jul 13, 2019 9:40 pm

Phlamethrower wrote:
Sat Jul 13, 2019 7:47 pm
Yes. There are a couple of kernel workspace locations which the routine writes to (which will generally be read-only from user mode), and on Archimedes machines if the screen is scrolled then some of the screen may be inaccessible from user mode.
So apologies for being dumb, how do I get to be in SVC mode? I presumed it was only on SWI call? And why does the fast horizontal line drawing routine work on RISC OS 3.11 but not RISC OS 5.2x?
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

sirbod
Posts: 995
Joined: Mon Apr 09, 2012 8:44 am
Location: Essex
Contact:

Re: OS Version

Post by sirbod » Sun Jul 14, 2019 6:40 am

zolbatar wrote:
Sat Jul 13, 2019 9:20 am
Well that does seem to allow it to set MODE 13, although it identifies as 640x480 at 64 colours (256 with tints) in BASIC.
If you don't have the a suitable monitor selected in Configure that contains mode 13, it will go to the closest mode. You can use AnyMode to work around that issue.
zolbatar wrote:
Sat Jul 13, 2019 9:40 pm
how do I get to be in SVC mode?
OS_EnterOS
zolbatar wrote:
Sat Jul 13, 2019 9:40 pm
And why does the fast horizontal line drawing routine work on RISC OS 3.11 but not RISC OS 5.2x?
Post the code.
Last edited by sirbod on Sun Jul 14, 2019 6:46 am, edited 1 time in total.

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Sun Jul 14, 2019 9:42 pm

The fast line drawing stuff fails on RISC OS 3.11 as well, so I'm doing something wrong.

Out of interest, how fast/efficient are the OS PLOT routines for things like lines and triangles? Back in the day I would always implement my own Bresenham's line drawing implementation or fill triangles (using Bresenham's as well).

Just curious really, I will of course be making my own mind up as I do this code.
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Mon Jul 15, 2019 11:01 am

Thanks for all the help, I got my code to run - but ignored the FHLD routine. It basically dumps out all 256 colours by drawing a line from 0 to 1280 (or equivalent when writing direct to screen memory).

BBC BASIC Plot - 501 fps
BBC BASIC using OS_Plot - 287 fps
BBC BASIC Screen memory write - 125 fps
ARM assembly using VDU calls - 4681 fps
ARM assembly using screen memory write - 9362 fps

This makes a lot of sense to me. When in BASIC, use the language commands for drawing and ARM assembly is by far the fastest.

Doing ARM assembly was way more fun than I imagined, although had to get my head around loading 32 bit immediate values using ADD and shifting bits. The rest is easy enough, but I've done plenty of 6502 and x86 in my time.

Edit: ADD not AND
Last edited by zolbatar on Mon Jul 15, 2019 5:58 pm, edited 1 time in total.
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

User avatar
qUE
Posts: 74
Joined: Tue Dec 16, 2014 11:39 pm
Location: Bristol
Contact:

Re: OS Version

Post by qUE » Mon Jul 15, 2019 4:00 pm

IIRC there was a "hyperline" routine on AU's *INFO which drew thousands of lines a second on an ARM2, may be worth taking a look at.

zolbatar
Posts: 36
Joined: Sat Sep 22, 2018 12:12 pm
Location: Nottingham, UK
Contact:

Re: OS Version

Post by zolbatar » Tue Jul 16, 2019 7:12 am

The code I've got will work on an RO 3 machine but on my RPi 3 it's doing a million random full screen width horizontal lines in about 2 seconds. That's around 8000 a frame, which is quick enough for what I need. Most of the time is spent writing to video memory and it's optimised to write 4 bytes at a time where possible.
Master 128 with DataCentre and RPi co-pro.
RPi B+ & 3B+ both running RISC OS.
Poorly A4000 (battery damage, partially repaired).

Post Reply