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
- I want to digitise some A3010 software - ONLY COPY (Gen:5)
- RISC OS ports website (News:5)
- For Swaps/Trade Acorn User/Archi World Magazine Collection (Gen:5)
- More Acorn Magazine nostalgia (News:)
- RISC OS London Show 2018 (News:)
- NetSurf or Iconbar? (Site:3)
- September News round-up (News:)
- DDE tools updated to DDE28c (News:)
- Orpheus hits crowdfunding target (News:2)
- Orpheus launch crowdfunding campaign (News:5)
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