Determining VT52 console dimension

GFA, ASM, STOS, ...

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

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

Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2535
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Determining VT52 console dimension

Post by lp »

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

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
shoggoth
Nature
Nature
Posts: 1032
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Determining VT52 console dimension

Post by shoggoth »

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: 879
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Determining VT52 console dimension

Post by mfro »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5254
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
joska
Hardware Guru
Hardware Guru
Posts: 4827
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Post by joska »

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

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
gstoll
Atari maniac
Atari maniac
Posts: 90
Joined: Sun Feb 17, 2008 4:29 pm

Re: Determining VT52 console dimension

Post by gstoll »

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: 2535
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Determining VT52 console dimension

Post by lp »

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: 4827
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Post by joska »

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

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
simonsunnyboy
Moderator
Moderator
Posts: 5254
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
joska
Hardware Guru
Hardware Guru
Posts: 4827
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Post by joska »

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

VanillaMiNT - 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: 879
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Determining VT52 console dimension

Post by mfro »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5254
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
joska
Hardware Guru
Hardware Guru
Posts: 4827
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Post by joska »

Yes, p_env points to the environment string.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
czietz
Hardware Guru
Hardware Guru
Posts: 1340
Joined: Tue May 24, 2016 6:47 pm

Re: Determining VT52 console dimension

Post by czietz »

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
Atari God
Atari God
Posts: 1267
Joined: Sun Aug 03, 2014 5:54 pm

Re: Determining VT52 console dimension

Post by ThorstenOtto »

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
simonsunnyboy
Moderator
Moderator
Posts: 5254
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
joska
Hardware Guru
Hardware Guru
Posts: 4827
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Determining VT52 console dimension

Post by joska »

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

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
simonsunnyboy
Moderator
Moderator
Posts: 5254
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
ThorstenOtto
Atari God
Atari God
Posts: 1267
Joined: Sun Aug 03, 2014 5:54 pm

Re: Determining VT52 console dimension

Post by ThorstenOtto »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5254
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Determining VT52 console dimension

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2725
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Determining VT52 console dimension

Post by charles »

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
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!
m0n0
Captain Atari
Captain Atari
Posts: 427
Joined: Mon Oct 05, 2009 3:13 am

Re: Determining VT52 console dimension

Post by m0n0 »

Hello,

why don't you use Getrez() to determine the number of characters? ^^
User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 879
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Determining VT52 console dimension

Post by mfro »

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?
Post Reply

Return to “Coding”