Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Nov 1998 00:10:42 +0900
From:      Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To:        Nik Clayton <nik@nothing-going-on.demon.co.uk>
Cc:        hackers@FreeBSD.ORG, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject:   Re: text mode screen grabber? 
Message-ID:  <199811081510.AAA16053@zodiac.mech.utsunomiya-u.ac.jp>
In-Reply-To: Your message of "Sat, 07 Nov 1998 15:29:28 GMT." <19981107152928.28834@nothing-going-on.org> 
References:  <19981107152928.28834@nothing-going-on.org> 

next in thread | previous in thread | raw e-mail | index | archive | help

>Has anyone got (or have pointers to useful code) a screen grabber for
>syscons? Ideally (and given an 80x25 screen) I'm looking for something 
>that would write a 4000 byte file of { character code, colour } tuples.
[...]

Have you considered script(1), a standard command, or `screen', which
is in the port collection, I expect?

>If I was doing this in DOS, I'd just set a pointer to 0xb80000000 and 
>write the next 4000 bytes. I figure I can do this (as a root process) by
>opening /dev/kmem. 

Yes, you can read the phyiscal screen buffer via /dev/mem and mmap().

p = (u_int16_t *)mmap(0, 0x10000, PROT_READ, MAP_FILE,
                      open("/dev/mem", O_RDWR), 0xA0000);

However, it is not usually recommended to peek around physical memory
while there is a perfectly feasible way of carrying out the same
task (by using regular programs such as `script' and `screen').

>virtual terminals will presumably screw this up.

You can lock out syscons while you are reading from the physical
screen buffer by issuing a pair of ioctl commands.

ioctl(fd, KDSETMODE, KD_GRAPHICS);

This will tell syscons your program want full control of the video
card.  Don't be alarmed by the term "KD_GRAPHICS".  This ioctl will
NOT put the video card in a graphics mode; it simply marks the current
virtual terminal that the user-land program is controlling the video
card, and syscons will not try to update the screen appearance or
switch away to another virtual terminal.  Your program can do anything
you like to the video card now.

When finished reading the screen buffer, call

ioctl(fd, KDSETMODE, KD_TEXT);

to release the video card.  Make sure this ioctl will be issued before
the program exists, otherwise you will not be able to switch between
virtual terminals again.

>I've had a look at the syscons code, and some of the screen savers, but
>nothing's leaping out at me saying "Here, this is where the screen 
>buffer is. . .".

No, I don't think you should directly read the internal data structure.
Its format may be different between versions.

Kazu

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811081510.AAA16053>