Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BASIC Viewport problem

7 views
Skip to first unread message

cgp

unread,
Dec 2, 2009, 6:30:35 AM12/2/09
to
I'm trying to revisit some old BASIC stuff (non-wimp) involving text
and graphics viewports, which I wish to make MODE independent.

I'm reading the current screenmode via OS_ReadModeVariable thus :

SYS "OS_ReadModeVariable", -1, 11 TO,, xsize%
SYS "OS_ReadModeVariable", -1, 12 TO,, ysize%
SYS "OS_ReadModeVariable", -1, 1 TO,, textcols%
SYS "OS_ReadModeVariable", -1, 2 TO,, textrows%

This seems to return the correct values for the current screen mode,
whether it is set, e.g. MODE 20, or
MODE MODE.

I'm doing this currently with Virtual Acorn on a laptop, but the
results seem the same on the Iyonix.

The text window seems to work OK with these returned values, but the
returned sizes for the graphics produce a window about half the
expected size. For example my laptop screen is 1440 * 900, and xsize
and ysize are returned correctly as 1439 and 899, but these values in
VDU24 give a rectangle only filling half the screen.

What am I missing?

cheers

George Pearce

Steve Fryatt

unread,
Dec 2, 2009, 6:52:44 AM12/2/09
to
On 2 Dec, cgp wrote in message
<a80d9523-84b4-4edb...@d10g2000yqh.googlegroups.com>:

> I'm reading the current screenmode via OS_ReadModeVariable thus :
>
> SYS "OS_ReadModeVariable", -1, 11 TO,, xsize%
> SYS "OS_ReadModeVariable", -1, 12 TO,, ysize%
> SYS "OS_ReadModeVariable", -1, 1 TO,, textcols%
> SYS "OS_ReadModeVariable", -1, 2 TO,, textrows%

[snip]

> The text window seems to work OK with these returned values, but the
> returned sizes for the graphics produce a window about half the expected
> size. For example my laptop screen is 1440 * 900, and xsize and ysize are
> returned correctly as 1439 and 899, but these values in VDU24 give a
> rectangle only filling half the screen.

VDU 24 (as with most graphics operations) operates in OS units, which are
not the same as pixels. In most modern modes one OS unit = 2 pixels, but
you shouldn't rely on this. Remember than in old modes like Mode 2, pixels
were 8 x 4 OS units, and so on.

What you need to do is take the number of pixels and convert them to OS
units using the eigenvalues:

SYS "OS_ReadModeVariable", -1, 11 TO ,,xpix%
SYS "OS_ReadModeVariable", -1, 4 TO ,,xeig%

SYS "OS_ReadModeVariable", -1, 12 TO ,,ypix%
SYS "OS_ReadModeVariable", -1, 5 TO ,,yeig%

xsize% = xpix% << xeig%
ysize% = ypix% << yeig%

--
Steve Fryatt - Leeds, England

http://www.stevefryatt.org.uk/

Steve Fryatt

unread,
Dec 2, 2009, 7:24:05 AM12/2/09
to
On 2 Dec, Steve Fryatt wrote in message
<mpro.ku0wzt03...@stevefryatt.org.uk>:

> VDU 24 (as with most graphics operations) operates in OS units, which are
> not the same as pixels. In most modern modes one OS unit = 2 pixels, but

^^^^^^^^^^^^^^^^^^^^^^
Or maybe even 2 OS units = 1 pixel. D'oh.

cgp

unread,
Dec 2, 2009, 9:19:57 AM12/2/09
to
On Dec 2, 12:24 pm, Steve Fryatt <n...@stevefryatt.org.uk> wrote:
> On 2 Dec, Steve Fryatt wrote in message
>     <mpro.ku0wzt0368fu80375.n...@stevefryatt.org.uk>:

>
> > VDU 24 (as with most graphics operations) operates in OS units, which are
> > not the same as pixels.  In most modern modes one OS unit = 2 pixels, but
>
>                                                 ^^^^^^^^^^^^^^^^^^^^^^
> Or maybe even 2 OS units = 1 pixel.  D'oh.
>
> --
> Steve Fryatt - Leeds, England
>
> http://www.stevefryatt.org.uk/

Thanks Steve - Sorted!!

George Pearce

0 new messages