Subject: Re: Accessing hardware -- nasm and gcc
From: [email-masked] (Benjamin Riefenstahl)

19 Mar 1998 07:24:07 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

Hi Tijs,

Tijs Michels wrote:
> ... I
> run Bash either in Rxvt or in a *full screen mode* from the
> command.com prompt. By default command.com returns dark white
> characters on a black background (07).
> ...
> Now from the command.com prompt these registers can be changed very
> easy with the program presented earlier (assemble as a classic .com
> program):
> ...

You are illustrating one of the interfaces that can be used to do this -
as defined for real mode.

> However, once in Bash, I obviously can no longer use this .com
> program. 

Well, it's not obvious to me ;-). I'd classify it as a bug in bash. DOS
style .COM applications are just as legal in DOS/Windows as bash
scripts. But then there is probably some option I am overlooking to
allow them to be started from bash. You can always do something like
"$COMSPEC /c blub.com" of course.

> So I decided to try to write an .exe program which could do
> the same in the 32 bits Bash environment. So far to no avail.

You just have to use the defined interfaces.

> Given that all of this pertains to **full screen text modes** (mode
> 3 or VESA mode 108h), I doubt the video driver is making life hard on
> me. Why would a Win95 driver trap ports designed for accessing
> registers which Win95 programs using a GUI would never want to access
> directly?

Probably because Win95/WinNT does not distinguish between console
applications running in window ed "DOS box" or running full-screen at
this level.

On WinNT, there is a properties dialog for the console window hidden
under an entry in the system menu (use Alt-Ret to switch to windowed
mode and back again, so you can get at it). In these properties there
are settings for your colors. On Win95 you even have a toolbar button
for the properties notebook, but that notebook misses the color
settings, don't ask me why ...

I was just wondering myself how you do this programmtically so I wrote
the following little C program:

/* setmode.c */
#include <stdlib.h>	/* strtol() */
#include <stdio.h>	/* printf() */

#include <windows.h>

extern int
main	( int argc, char * argv [] )
{
	HANDLE hStdout;

	(void) argc;

	if( NULL == argv[1] )
		return -1;

	hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hStdout,strtol(argv[1],NULL,0));
	printf( "Test\n" ); /*strangely necessary*/

	return 0;
}
/* eof */

This does what you want. Compile with "gcc -osetmode setmode.c" and call
as "setmode 0x1F". It will of course only work if stdout is actually a
console window. Otherwise SetConsoleTextAttribute() will just fail.

so long, benny
======================================
Benjamin Riefenstahl ([email-masked])
Crocodial Communications EntwicklungsGmbH
Ophagen 16a, D-20257 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".