Determining VT52 console dimension

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Determining VT52 console dimension

Postby simonsunnyboy » Mon Oct 30, 2017 2:27 pm

Is there a clean way to determine the dimension of the VT52 screen?
This should work from SingleTOS if possible.

Otherwise I'll have to use XBIOS 4 which is fine for ST needs but not the TOSWIN2 intention.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2257
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Determining VT52 console dimension

Postby lp » Mon Oct 30, 2017 4:32 pm


User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Mon Oct 30, 2017 4:59 pm

Yeah but that is VDI requiring "workstations" and whatever to be configured. My code is supposed to work with .TOS and .TTP programs for AUTO folder use.

So VDI and AES calls are not really what I am looking for. But thanks for mentioning them.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
shoggoth
Nature
Nature
Posts: 854
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Determining VT52 console dimension

Postby shoggoth » Mon Oct 30, 2017 5:42 pm

simonsunnyboy wrote:Yeah but that is VDI requiring "workstations" and whatever to be configured. My code is supposed to work with .TOS and .TTP programs for AUTO folder use.

So VDI and AES calls are not really what I am looking for. But thanks for mentioning them.


Environment variables LINES/ROWS and COLUMNS, when available, does the trick. Trickier in Plain TOS, since there is no neat way to read the cursor position.
Ain't no space like PeP-space.

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 683
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Determining VT52 console dimension

Postby mfro » Mon Oct 30, 2017 5:53 pm

VT52 cannot report back screen dimensions or cursor position to the application, VT100 (using ANSI codes) can do at least the latter (which can be used to query screen real estate).

Using standard VT52 emulation, you can indeed only hope that someone set ROWS and COLUMNS sensibly.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Mon Oct 30, 2017 6:20 pm

I seee.seems there is no real TOS style for this. How can I access environment variables if there is no getenv() function?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Postby joska » Mon Oct 30, 2017 6:22 pm

The C libray getenv() works fine in TOS.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

gstoll
Atari freak
Atari freak
Posts: 62
Joined: Sun Feb 17, 2008 4:29 pm

Re: Determining VT52 console dimension

Postby gstoll » Mon Oct 30, 2017 6:26 pm

shoggoth wrote:
simonsunnyboy wrote:Trickier in Plain TOS, since there is no neat way to read the cursor position.

Is also not the best way, the negative Line-A variables.
http://toshyp.atari.org/en/006003.html

v_cur_xy[2]; at -$1C is the X-Y position of text cursor. Thomas Binder use this in his VT52 patch for the Falcon.

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2257
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Determining VT52 console dimension

Postby lp » Mon Oct 30, 2017 6:26 pm

joska wrote:The C libray getenv() works fine in TOS.


I'm curious if that is a wrapper for shel_envrn() ?
http://toshyp.atari.org/en/008012.html#shel_envrn

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Postby joska » Mon Oct 30, 2017 6:42 pm

I doubt that, shel_env is an AES function. I assume getenv reads the environment directly from the basepage.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Mon Oct 30, 2017 7:21 pm

joska wrote:The C libray getenv() works fine in TOS.


Is the source code available? I don't link against MintLib at all cost, even if a single function is clean. It links lots of other stuffs exploding the binaries.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Postby joska » Mon Oct 30, 2017 7:31 pm

Yes, MiNTlib is GPL. You can also use getenv from AHCC. Or write your own, parsing the environment is pretty straight-forward.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 683
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Determining VT52 console dimension

Postby mfro » Mon Oct 30, 2017 8:19 pm

With a decent C library, there is a third (usually unused) parameter to main() : envp. This is supposed to be a pointer to the environment.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Tue Oct 31, 2017 9:20 am

Can I directly use p_env from the basepage for envp? If so, this looks like an option.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Postby joska » Tue Oct 31, 2017 9:31 am

Yes, p_env points to the environment string.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

czietz
Hardware Guru
Hardware Guru
Posts: 479
Joined: Tue May 24, 2016 6:47 pm

Re: Determining VT52 console dimension

Postby czietz » Tue Oct 31, 2017 9:48 am

simonsunnyboy wrote:Can I directly use p_env from the basepage for envp?


No, you can't. The envp argument to main is an array of pointers to each individual environment variable. (Much like argv is an array of pointers to each individual command line argument.)

Code: Select all

int main (int argc, char *argv[], char *envp[])


However, p_env is just a pointer to the environment. While you can simply iterate over envp[n] to access individual variables, you have to extract them yourself from p_env. That's not particularly hard, though. Any reasonably skilled C programmer should be able to do this in maybe 15 minutes...

ThorstenOtto
Captain Atari
Captain Atari
Posts: 164
Joined: Sun Aug 03, 2014 5:54 pm

Re: Determining VT52 console dimension

Postby ThorstenOtto » Tue Oct 31, 2017 10:03 am

Just a few hints: envp (the 3rd parameter to main) as well as environ (a global variable available in mintlib and most other C-libraries) are char * arrays, while p_env (the basepage member) is a pointer to a contiguous string, each variable terminated by a '\0', and the whole thing terminated again with a '\0' after the last string. Both should contain the same information at program start. The environ[] array can be changed by calling putenv() or setenv(), while the environment in the basepage is kept intact.

shel_envrn() is a total different thing, It returns information about the environment of the "shell" (usually the desktop), not your program.

For your problem: if you plan to use that information in an auto-folder program, i would use the information from the linea-variables. There is nobody who would have set those environment variables.

Edit: damn. czietz was just a few seconds faster

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Tue Oct 31, 2017 10:33 am

The basepage format is not a problem as I will write my own getenv() function for this case.

I never heard of main() taking 3 parameters. It seems hardly used, not only on Atari but also on modern OSes.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Postby joska » Tue Oct 31, 2017 10:34 am

You guys seems to miss the fact that simonsunnyboy does *not* want to use the C library. So no envp or environ[] is available.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Tue Oct 31, 2017 10:38 am

I will add those to my own libcnano ;)
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

ThorstenOtto
Captain Atari
Captain Atari
Posts: 164
Joined: Sun Aug 03, 2014 5:54 pm

Re: Determining VT52 console dimension

Postby ThorstenOtto » Tue Oct 31, 2017 2:22 pm

simonsunnyboy wrote:I will add those to my own libcnano ;)


Actually, except for education purposes, i see no reason to do so. If your program is only run from the auto folder, and going to exit right away, there is no real need to keep it small. Beside that, in the auto-folder, there is noone that would have set the COLUMNS and LINES environment variables already, so this might not be the way to go.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4858
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Postby simonsunnyboy » Tue Oct 31, 2017 2:28 pm

I dislike small 3 liners occupying 80K of RAM and other projects may use this as well. Even today on real Atari machines loading times do matter.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2057
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Determining VT52 console dimension

Postby charles » Tue Oct 31, 2017 3:13 pm

this might be basic(knowing me it is ! ) but wont clr-home puts cursor in top left corner, so track how many spaces it takes before the crslin crscol advances to 2,0 ???? knowing the character set is 13point do some quick math

or just use magic numbers and whipe the slate clean , predefine your workspace

youre probally doing some very low level stuff , good luck
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

m0n0
Captain Atari
Captain Atari
Posts: 419
Joined: Mon Oct 05, 2009 3:13 am

Re: Determining VT52 console dimension

Postby m0n0 » Thu Nov 02, 2017 7:52 pm

Hello,

why don't you use Getrez() to determine the number of characters? ^^

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 683
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Determining VT52 console dimension

Postby mfro » Thu Nov 02, 2017 8:14 pm

for most practical purposes, i would assume, the negative LineA variables v_cel_mx and v_cel_my (-$2c and -$2a) might be good enough?


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 3 guests