From owner-freebsd-hackers Sun Nov 8 07:09:36 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA19016 for freebsd-hackers-outgoing; Sun, 8 Nov 1998 07:09:36 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from outmail.utsunomiya-u.ac.jp (outmail.utsunomiya-u.ac.jp [160.12.196.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA19011 for ; Sun, 8 Nov 1998 07:09:34 -0800 (PST) (envelope-from yokota@zodiac.mech.utsunomiya-u.ac.jp) Received: from zodiac.mech.utsunomiya-u.ac.jp (IDENT:lY9bMqg8+rHX1W9SGgQbG/XYVRU6kKJl@zodiac.mech.utsunomiya-u.ac.jp [160.12.42.1]) by outmail.utsunomiya-u.ac.jp (8.9.1/8.9.1) with ESMTP id AAA12416; Mon, 9 Nov 1998 00:09:15 +0900 (JST) Received: from zodiac.mech.utsunomiya-u.ac.jp (zodiac.mech.utsunomiya-u.ac.jp [160.12.42.1]) by zodiac.mech.utsunomiya-u.ac.jp (8.7.6+2.6Wbeta7/3.4W/zodiac-May96) with ESMTP id AAA16053; Mon, 9 Nov 1998 00:10:43 +0900 (JST) Message-Id: <199811081510.AAA16053@zodiac.mech.utsunomiya-u.ac.jp> To: Nik Clayton cc: hackers@FreeBSD.ORG, yokota@zodiac.mech.utsunomiya-u.ac.jp Subject: Re: text mode screen grabber? 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> Date: Mon, 09 Nov 1998 00:10:42 +0900 From: Kazutaka YOKOTA Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >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