IBMgraphics

From NetHackWiki
Jump to navigation Jump to search

A user has suggested improving this page or section as follows:

"How is IBMgraphics related to DECgraphics? Strategy: Which one is better? Also, interaction with the curses interface"

IBMgraphics is an option that displays walls as continuous lines rather than as broken dashes, which is the best that plain ASCII can do. It also displays certain dungeon features with distinct symbols, and on some systems makes the Rogue level look more like the Epyx version of Rogue. It is similar to DECgraphics, but has a larger character set.

IBMgraphics requires a display device that displays code page 437, or a compatible code page. Many users of Microsoft Windows outside the United States have their terminals set to another code page, often code page 850, and this can affect the appearance of some symbols.

To use IBMgraphics, the option must be set to TRUE, either in-game or in the configuration file.

Symbol list

Normal dungeon

The complete symbol list for the normal dungeon is found in the array ibm_graphics in drawing.c.[1] The corresponding ASCII symbols are in defsyms.[2] Those symbols affected by IBMgraphics are listed here.

Code point Usage Appearance ASCII
0xB3 Vertical wall, beam, explosion |
0xC4 Horizontal wall or beam -
0xDA Top left corner -
0xBF Top right corner -
0xC0 Bottom left corner -
0xD9 Bottom right corner -
0xC5 Cross wall -
0xC1 T-up wall -
0xC2 T-down wall -
0xB4 T-left wall |
0xC3 T-right wall |
0xB0 Dark corridor #
0xB1 Lit corridor #
0xF0 Iron bars #
0xF1 Tree ± #
0xF4 Fountain {
0xF7 Lava, pool, water }
0xFA Room, doorway, ice, open drawbridge · .
0xFE Open door | or -

Rogue level

Certain objects have their appearance changed in the Rogue level; the array IBM_r_oc_syms governs this.[3] The exact changes are different on Linux than on MS-DOS and its descendants. The list here shows the more complete list used on MS-DOS.

A number of map symbols are also changed[4] and all creatures otherwise appearing as @ instead appear as ☺.[5]

Code point Usage Appearance ASCII
0xBA Vertical wall |
0xCD Horizontal wall -
0xC9 Top left corner -
0xBB Top right corner -
0xC8 Bottom left corner -
0xBC Bottom right corner -
0xCE Cross wall, doors - or +
0xCA T-up wall -
0xCB T-down wall -
0xB9 T-left wall |
0xCC T-right wall |
0x01 Human, elf @
0x04 Trap, web ^ or "
0x05 Food :
0x0C Amulet ,
0x0E Scroll ?
0x0F Gold, gems *
0x18 Weapon )
0x5B Armor [ ]
0xAD Potion ¡ !
0xB1 Dark corridor #
0xB2 Lit corridor #
0xE7 Wand τ /
0xF0 Stairs %
0xFA Room · .

Code page compatibility

There are code pages other than 437 that will also display IBMgraphics correctly, because they differ only at code points that are not currently used by NetHack. These include 860 (Portuguese), 861 (Icelandic), 862 (Hebrew), and 865 (Nordic), and can be useful when code page 437 is unavailable.

Some other code pages will not quite display IBMgraphics perfectly, but are close enough to be usable when none of the above code pages are available. Some of these are shown in the table below.

For code page 858, use the column for code page 850.

Other known code pages have few of the necessary symbols and are completely unsuitable for IBMgraphics.

Code point CP437 CP737 CP775 CP850 CP852 CP855 CP857 CP863 CP866 CP869
0xAD ¡ φ Ł ¡ ş Г ¡ ¾ н Ι
0xE7 τ ύ ń þ š у none τ ч ν
0xF0 Ώ - - - - - Ё -
0xF1 ± ± ± ± ˝ ы ± ± ё ±
0xF4 Ϊ ˘ З Ї χ
0xF7 ¸ ¸ э ¸ ў ΅
0xFA · · · · ˙ Щ · · · ω

Configuring code page 437

On many platforms, it is possible to set the display device to display code page 437 instead of the default code page. This will enable NetHack to display the IBMgraphics as the DevTeam intended.

Windows NT, 2000, XP, and Vista (and newer?)


This section may also apply to Windows 2003 Server, but is untested on this version.

If code page 437 is not the default, it will be necessary either to configure the console window to use the Lucida Console font, or to run full screen (press Alt-Enter). With bitmap fonts in a window, only the characters for the default code page are loaded, and others do not display correctly. Bug W343-3 is also a problem for this configuration.

Once either Lucida Console is set, or the console window is in full screen mode, it is sufficient to type

chcp 437

and possibly for full-screen mode

mode con lines=25

and then start NetHack.

PuTTY


On the PuTTY Configuration window (this appears when you first start PuTTY), select "Translation" under the "Window" configuration in the pane on the left. Then, in the pulldown menu marked "Received data assumed to be in which character set", select "CP437". You can then log in to the server as usual. You may also change this setting and then 'save' the session. The character set (as well as other display settings, e.g., the color blue) will be used in your session from then on.

X.Org


While most terminal programs for X11 readily support DECgraphics, they need additional setup for IBMgraphics. The usual way is to set the encoding to code page 437. The exact procedure to do this depends on the terminal program.

luit (general)

The following solution should work on most terminal emulators on distributions which are using an UTF8 locale (but please test and update this page! Works at least on konsole and xterm here):

luit -encoding 'CP437' nethack

About fonts

You also need a font that provides the necessary characters. Generally, most fonts on modern distributions already contain the characters, but in case you are missing some, you may need to change your font.

X11 already provides at least one such font: the "fixed" font. It is already the default font for xterm. To preview it or to check that you have it, use one of these xfd commands:

# to preview it as a core font
xfd -fn -Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO10646-1

# to preview it as an Xft font
xfd -fa Fixed-10

If you choose a font like Bitstream Vera Sans Mono, then X11 may substitute another font for some characters, causing graphical glitches if the two fonts have different monospace metrics.

FreeBSD console


Load the CP437 console font with:

vidcontrol -f 8x16 cp437-8x16

Or add this to /etc/rc.conf to make it permanent:

font8x16="cp437-8x16"

MAC OS X


The Terminal application that comes with OS X seems to work well on an external SSH server, if one just sets the right encoding. "US Latin (DOS)" seems to work well (if I've understod correctly this means CP437). Also, you need a good monospace font, "Andale Mono" seems to work well; however, I haven't done any extensive testing, and the following questions remain (please remove / edit if you have tested these):

  • Which font has all the symbols needed (don't know if Andale Mono has)
  • Is the rogue level corrupted?
  • I didn't make any other adjustements (e.g. I believe the default shell locale is still configured for UTF-8 if you change the encoding on-the-fly, but is adjusted if you start a new one?)

You probably could also use luit (or konwert and filterm if you can find / install them for OS X) as in Linux X11 terminal applications, but for me luit didn't work well in Linux nor OS X on a public SSH nethack server.

There is a packaging bug with the official Mac 3.6.0 package which omits the "symbols" file required for any symset to work. See the bug M360-1 in the official Bugs page. This file can be obtained from another port / source archive and copied into place as follows (in Terminal, you will need to type your superuser password): sudo cp symbols /Library/NetHack/nethackdir/


Configuring code page 437 on Legacy systems

Instructions for old operating systems (probably not used by many anymore) are listed here.

X11 (Legacy)


The following subsections are probably out of date and will not work on most modern distributions (which use UTF8 per default). They are currently left here in case you are using an old distribution.

While most terminal programs for X11 readily support DECgraphics, they need additional setup for IBMgraphics. The usual way is to set the encoding to code page 437. The exact procedure to do this depends on the terminal program. Also see IBMgraphics#About_fonts, it also applies here.

Using konwert, filterm, or cp437 (any terminal)

If your terminal supports UTF-8, but not code page 437, or you just don't want to have to manually change your terminal's encoding settings whenever you're playing NetHack, you can use konwert, filterm, or cp437 to transcode NetHack's output into something your terminal understands. Invoke one of them as follows:

# local play
nethack | konwert cp437-utf8

filterm ascii-ascii cp437-utf8 nethack

cp437 nethack

# remote play
telnet nethack.alt.org | konwert cp437-utf8

filterm ascii-ascii cp437-utf8 telnet nethack.alt.org

cp437 telnet nethack.alt.org

You will probably need to install these programs before they can be used.

xterm

The current xterm does not provide an encoding for code page 437, but it does provide a charset "CP 437" which represents the upper half of (0x80 - 0xff) of CP 437. We can invoke luit manually to set up a Extended Unix Code that maps 0x00 - 0x7f to ASCII and 0x80 - 0xff to CP 437.

An xterm using CP 437, showing IBMgraphics on the Oracle level.

To open an xterm using CP 437:

  • Use uxterm -fg gray -bg black to open an xterm using UTF-8, with a gray-on-black color scheme that works well with IBMgraphics.
    • The default font (fixed) looks nice, but you can set it explicitly with either -fn fixed or -fa Fixed-10.
  • Inside that xterm, invoke luit -g2 'CP 437'
    • You might need luit -gr g2 -g2 'CP 437' if your current locale defaults to -gr g1

When you invoke luit, it starts a new shell (from where you may start NetHack). When you exit your CP 437 shell, luit exits and you return to your UTF-8 shell.

Oops, xterm with CP 437 has serious glitches on the Rogue level. Click image for details.

Unfortunately, your xterm will have serious graphical glitches at the Rogue level, because unlike a real IBM PC, luit does not map ASCII control characters to graphical characters (such as 0x01 to a smiley face adventurer). You may need to disable IBMgraphics while playing the Rogue level.

You can also install a CP437 or "VGA" font. There are several of these floating around the net; a nice one is included with bochs-2.0.

Konsole (KDE)

KDE does not have an encoding for code page 437, or any similar encoding.

In menu Settings -> Encoding, if you select "Cyrillic (ibm866)" or "Western European (ibm850)", then the encoding will the walls, floors, doors and corridors for IBMgraphics, but fountains and moats will look strange. A better option is to select "Unicode (utf8)", then invoke luit as you would in an xterm.

Konsole can do IBMgraphics, with some help from luit.

To configure Konsole for IBMgraphics:

  • Use Settings -> Font -> Select... to pick a good font, such as "Fixed [Misc]" size "10" (or any size).
    • Optionally, use Settings -> Size to resize your terminal for the new font.
  • Select Settings -> Schema -> Linux Colors for a good gray-on-black look.
  • Select Settings -> Encoding -> Unicode (utf8). Alternatively, start Konsole in a UTF-8 locale, so that the Default encoding is also UTF-8.
    • Optionally, now use Settings -> Save Sessions Profile... and call the profile something like "ibm".
  • At the command line, invoke luit -g2 'CP 437'

When you invoke luit, it starts a new shell (from where you may start NetHack). When you exit your CP 437 shell, luit exits and you return to your UTF-8 shell.

If you saved an "ibm" profile, then konsole -profile ibm will start a Konsole with the same settings. You still need to invoke luit -g2 'CP 437' before you start NetHack with IBMgraphics. If you add a "Terminal Sessions" applet to your KDE panel, you can also access your profile with Terminal Sessions -> New Session Using Profile -> ibm.

Unfortunately, your Konsole will have serious graphical glitches at the Rogue level. This happens if you set Konsole to utf-8 and use luit, or if you set Konsole to ibm850 or ibm866 and do not use luit. Either way, the software will not map ASCII control characters to graphical characters. You may need to disable IBMgraphics while playing the Rogue level.

gnome-terminal

The current gnome-terminal does not have a setting for code page 437, but it does support other code pages that are equivalent for NetHack's purposes, such as 862 (Hebrew).

To set code page 862 on gnome-terminal:

  • Select Terminal, Set Character Encoding, and then Add or Remove.
  • In the pane on the left, select the line with description Hebrew and encoding IBM862.
  • Click the right-pointing arrow between the two panes.
  • Click Close.

The above steps only need to be done once for the lifetime of the Gnome installation. Once done, it is sufficient to:

  • Select Terminal, Set Character Encoding, and then Hebrew (IBM862).

It should be noted that the current default gnome-terminal font in Ubuntu Jaunty fully supports DECgraphics as long as eight_bit_tty is set to false.

Linux console


If your system uses a Unicode console, disable it (for the current session) with:

unicode_stop

Then re-load the default text font with one of the two following commands:

Debian-based systems:

consolechars -m cp437 -f default8x16

Redhat-based systems, others:

setfont default8x16

Finally, you may need to load the CP437 translation mode:

setfont -m cp437

If any of these commands fails, try running it as root by preceding each command with "sudo " (e.g., "sudo unicode_stop").

MS-DOS and Windows 95, 98, and Me


Make sure CONFIG.SYS contains a line similar to this:

C:\WINDOWS\COMMAND\display.sys con=(ega,,1)

and AUTOEXEC.BAT contains lines similar to these:

mode con codepage prepare=((437) C:\WINDOWS\COMMAND\ega.cpi)
mode con codepage select=437

For MS-DOS substitute C:\DOS for C:\WINDOWS\COMMAND in both places.

Custom map symbols

Some users may prefer to set their own symbols, either because they don't like the existing ones, or because it's easier than setting code page 437 just to play NetHack. See Custom map symbols for further details.

UTF-8 support

A user has posted an experimental patch to RGRN (here's what it changes) allowing display of the IBMgraphics characters using UTF-8, rather than a special code page. Compatible terminals include the Linux console for kernels since 1.2.1, any Unix-like platform running a recent version of X11, and PuTTY for Windows users accessing public servers. The original is a patch against NetHack 3.4.0; Stephen Anthony Uy has adapted it for 3.4.3.

References

This page may need to be updated for the current version of NetHack.

It may contain text specific to NetHack 3.4.3. Information on this page may be out of date.

Editors: After reviewing this page and making necessary edits, please change the {{nethack-343}} tag to the current version's tag or {{noversion}} as appropriate.