🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #381

ANSI troubles

#381
From: Scott Harper
Date: Tue, 21 Jul 1992 07:14
69 lines
3316 bytes
Although I posted this in comp.os.os2.programmer a while ago, I have not
heard any response.  I thought I might try again with source code in case
nobody knew what I was refering to.

I seem to be having a problem with OS/2's ANSI.SYS (I think).  I have a
DOS program that uses the C library function outtextxy(col,row,outstring).
This function writes a text string to a graphics screen.  When I attempt
to write characters with ASCII values above 127 (a few symbols past the
lower case letters), I get rather odd characters.  They are not part of
any code page that I have ever seen.  Note: I am using codepage 437 (437
& 850 prepared in config.sys).  Strangly enough, the code page looks
competely correct if I use the text mode function putch() or if I use the
alt-keypad combinations at a prompt.

I am using the BGI libraries (from the Borland C++ 3.0 package) to enable
graphics.  Perhaps they are at fault?  As a final note, this program prints
the correct characters from pure DOS (or a DOS 5.0 image).

Perhaps someone who is doing DOS development under OS/2 has seen this before?
I've attached the code for a program that will demonstrate the difference
between the two code pages for anyone interested in seeing it for themselves.

.............................................................................
  Scott Harper                 ___   The moral of the story is: Never under-
                               \_ \_    estimate the bandwidth of a station
                                  \ \      wagon full of tapes hurtling down
                                    \_\_      the highway.
   EMail: HARPER @ VTVM1.cc.vt.edu     \\
                                         *            - Andrew S. Tanenbaum
.............................................................................


/* This program prints both the text-mode character set and the graphics-mode
   character set beside each other on a VGA or EGA screen.  Graphics
   characters are displayed in red, text in gray.                            */

#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <graphics.h>

void main(void)$

   int x,y=0;
   char outstring[2]=$0,'\0';
   int driver=DETECT;

   /* It may be necessary to add the path to your bgi drivers to the
      initgraph function if you have not added the object files to your
      graphics.lib                                                     */

   if(registerbgidriver(EGAVGA_driver)<0) exit(1);

   initgraph(&driver,0,"");
   if(x=graphresult())$
      printf("Graphics initialization error: %s\n",grapherrormsg(x));
      exit(1);
   clearviewport();

   setcolor(EGA_LIGHTRED);
   settextstyle(DEFAULT_FONT,HORIZ_DIR,1);

   for(x=1; x<=255; x++)$
      outstring[0] = x;
      if(!(x%20))y++;
      gotoxy((x%20+1)*4,y+1); printf("%c",x);
      outtextxy((x%20)*32+10,y*16+4,outstring);
      

Technical Details
Message-ID: <9207210713.AA12418@cs.utexas.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!gateway

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!gateway
From: HARPER@VTVM1.CC.VT.EDU (Scott Harper)
Newsgroups: comp.os.os2.programmer
Subject: ANSI troubles
Date: 21 Jul 1992 02:14:15 -0500
Organization: UTexas Mail-to-News Gateway
Lines: 69
Sender: daemon@cs.utexas.edu (The devil himself)
Message-ID: <9207210713.AA12418@cs.utexas.edu>
NNTP-Posting-Host: cs.utexas.edu