log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- 10 RISC OS gift ideas for Christmas (News:)
- Drag'N'Drop Autumn edition now available (News:)
- !DualHead puts 2 screens in one (News:)
- RISC OS London Show 2017 - Notes from the talks (News:6)
- November News (News:)
- !Organizer 2.28 reviewed (News:2)
- !OBrowse reviewed (News:10)
- Aemulor (Gen:16)
- DDE reaches release 28 and above (News:)
- Elesar quicks dispels stormy clouds (News:2)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
Site Search
 
Article archives
The Icon Bar: Programming: Getting screen size from old MODE command
 
  Getting screen size from old MODE command
  MrTAToad (11:59 16/12/2012)
  Stoppers (15:51 16/12/2012)
    MrTAToad (16:51 16/12/2012)
      swirlythingy (19:32 16/12/2012)
    MrTAToad (20:26 16/12/2012)
 
Nicholas Kingsley Message #121670, posted by MrTAToad at 11:59, 16/12/2012
Member
Posts: 36
My development work has now started with relish smile

One slight oddity though - I'm setting the screen mode using the old mode value and then attempt to read the screen width and height back :

int *modeBlock;

// Old mode system
inreg.r[0]=0;
inreg.r[1]=sW;
_kernel_swi(OS_ScreenMode,&inreg,&outreg);

// Get the screen resolution
inreg.r[0]=1;
_kernel_swi(OS_ScreenMode,&inreg,&outreg);

modeBlock=(int *) outreg.r[1];

printf("Screen Width : %d Screen Height : %d\n",(int) modeBlock[1],(int) modeBlock[2]);

But for some reason screen width & height is a large negative number and not the proper screen size.

Is this a limitation of using RPCEmu or am I doing something wrong ?

By the way, I've Sourcery up and running (took a bit of effort to get it to use the correct GCC), but it does work fine now, with the expect of the library window always crashing when clicking on "Apply"

[Edited by MrTAToad at 12:08, 16/12/2012]
________
I'm back!
  ^[ Log in to reply ]
 
Simon Willcocks Message #121671, posted by Stoppers at 15:51, 16/12/2012, in reply to message #121670
Member
Posts: 278
// Get the screen resolution
inreg.r[0]=1;
_kernel_swi(OS_ScreenMode,&inreg,&outreg);

modeBlock=(int *) outreg.r[1];

printf("Screen Width : %d Screen Height : %d\n",(int) modeBlock[1],(int) modeBlock[2]);

But for some reason screen width & height is a large negative number and not the proper screen size.
PRM 5a-133: "If the current screen mode was selected by a mode number then that mode number is
returned; otherwise a pointer to a mode selector is returned."

Might OS_ReadModeVariable not be a better choice?
  ^[ Log in to reply ]
 
Nicholas Kingsley Message #121672, posted by MrTAToad at 16:51, 16/12/2012, in reply to message #121671
Member
Posts: 36
Thanks for that. It does look like OS_ReadModeVariable will be needed...
  ^[ Log in to reply ]
 
Martin Bazley Message #121677, posted by swirlythingy at 19:32, 16/12/2012, in reply to message #121672

Posts: 460
If you want to read more than one mode variable at once, you can use OS_ReadVDUVariables. Just enter a mode variable number instead of a VDU variable number.
  ^[ Log in to reply ]
 
Nicholas Kingsley Message #121679, posted by MrTAToad at 20:26, 16/12/2012, in reply to message #121671
Member
Posts: 36
That works fine - great!
  ^[ Log in to reply ]
 

The Icon Bar: Programming: Getting screen size from old MODE command