Parameters for OS_swis in oslib/os.h library

Jan-Jaap van der Geer jjvdgeer at inbox.com
Thu Feb 4 21:48:32 GMT 2016


Chris Dewhurst <cdewhurst2010 at btinternet.com> wrote:

> I am not much more than a beginner at the C language which may
> explain  why I'm stuck on the following. Hope one of you can
> help.
 
> 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.
 
> 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);

> Incidentally when StrongHelp says "prefer OS_ScreenMode" there
> appears  to be no reference to OS_ScreenMode, at least it isn't
> listed in the  StrongHelp.

That's because it is automatically generated from a file
describing all the SWIs. So this file talks about OS_ScreenMode,
but the C interface has a different naming convention. You'll get
used to that after a while:)

You just lowercase all and put an extra _ everywhere in front of
all the uppercase characters in the last part of the SWI-name (i.e.
behind the _). So OS_ScreenMode becomes os_screen_mode but since it
has several different reason codes (i.e. the operation you usually
send in in R0) the different reason codes have their own functions,
which are build up by removing the _ from os_screen_mode, putting a
_ after it and having a nice name for each reasoncode. In this case
osscreenmode_select.

Something like that.

Hope this helps:)

Cheers,
Jan-Jaap

(Looking at the SH manual, I do wonder how you call it with a mode
specifier block though... The manual (at least) seems to lack a
definition for that struct?)



More information about the oslib-user mailing list