Parameters for OS_swis in oslib/os.h library
Steve Fryatt
lists at stevefryatt.org.uk
Fri Feb 5 00:33:33 GMT 2016
On 4 Feb, Jan-Jaap van der Geer wrote in message
<0d39d34c55.Jan-Jaap at armx6.gmx.com>:
> Chris Dewhurst <cdewhurst2010 at btinternet.com> wrote:
>
> > The StrongHelp for os_screen_mode (for example) says:
>
> > Declaration: extern void os_set_mode ( void );
>
> > Description: VDU command to change display mode - must be followed
> > by 'mode' - prefer OS_ScreenMode
>
> Not sure how you found that. I find it when searching the manual but not
> by looking through the index. Not really sure what that is.
It's a veneer for SWI 0x116, which is OS_WriteI + 22, which is the VDU code
to change screen mode since BBC Micro days (in BASIC, "MODE 12" and
"VDU 22,12" are synonymous). Remember that SWIs &100 to &1FF just write the
bottom byte of the SWI number out via OS_WriteC.
As the OSLib docs say, you /really/ /do/ want to be using OS_ScreenMode in
preference to VDU 22,<mode> in modern software.
> > So the start of my C program looks like:
>
> > #include "oslib/os.h
> > extern void osscreenmode_select ( void );
>
> > My question is how do you "follow" the os_set_mode call with a 'mode'
> > number? For instance, to change to Mode 7 where does the 7 go?
>
> You don't need the extern-line, your #include does that for you. So
> actually, osscreenmode_select is already defined and you are trying to
> redefine it to something else, which is not a good idea.
>
> os.h has this definition for osscreenmode_select:
>
> extern void osscreenmode_select (os_mode mode);
>
> which, as you would expect, contains your modenumber.
>
> So to call mode 7, you'd do:
>
> osscreenmode_select((os_mode) 7);
However, note that (as in a lot of cases) OSLib defines some handy constants
for you to help you avoid having to use magic numbers. You'll find that
there are
#define os_MODE1BPP90X45 ((os_mode) 0x0u)
#define os_MODE2BPP90X45 ((os_mode) 0x8u)
#define os_MODE4BPP90X45 ((os_mode) 0xCu)
#define os_MODE8BPP90X45 ((os_mode) 0xFu)
#define os_MODE2BPP45X45 ((os_mode) 0x1u)
#define os_MODE4BPP45X45 ((os_mode) 0x9u)
#define os_MODE8BPP45X45 ((os_mode) 0xDu)
#define os_MODE1BPP90X90 ((os_mode) 0x19u)
#define os_MODE2BPP90X90 ((os_mode) 0x1Au)
#define os_MODE4BPP90X90 ((os_mode) 0x1Bu)
#define os_MODE8BPP90X90 ((os_mode) 0x1Cu)
and
#define os_CURRENT_MODE ((os_mode) 0xFFFFFFFFu)
#define os_NO_ALTERNATIVE_MODE ((os_mode) 0xFFFFFFFEu)
so if you wanted Mode 12 you could do
osscreenmode_select(os_MODE4BPP90X45);
which in most cases is probably preferable to
osscreenmode_select((os_mode) 12);
--
Steve Fryatt - Leeds, England
http://www.stevefryatt.org.uk/
More information about the oslib-user
mailing list