NetHack: Legacy For Mac
Below is the full text to src/allmain.c from NetHack 3.4.3. To link to a particular line, write [[allmain.c#line123]], for example.
- NetHack: Legacy (game, roguelike, high fantasy) Released 1987. Ranked #507 game of 1987 among Glitchwave users. The cruel god Moloch has stolen the most powerful of artifacts, the Amulet of Yendor. You have been entrusted by your god to recover the amulet from the bottom of Gehennom, located beneath the Dungeons of Doom.
- Mac GUI – customize your Mac’s look and feel with Themes, Desktops, Icons, Widgets, etc. Mac OS 9 Lives – tips and software for running the Classic Mac OS; audio-centric focus U-Mich Software Archives – large legacy software collection, for Macs and other platforms.
- 2moveloop
- 2.2Main loop
Nethack 4 Nethack 4. (default off, AMIGA NetHack only). MACgraphics (default on, Mac NetHack only). Pagewait (default on, Mac NetHack only). Rawio Force raw (non-cbreak) mode for faster output and more bulletproof input (MS-DOS sometimes treats `^P' as a printer toggle without it) (default off, OS/2, PC, and ST NetHack only). Cataclysm: Dark Days Ahead, FTL: Faster Than Light, and Slay the Spire are probably your best bets out of the 85 options considered. 'Tons of depth' is the primary reason people pick Cataclysm: Dark Days Ahead over the competition. This page is powered by a knowledgeable community that helps you make an informed decision.
Top of file
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
moveloop
Initialization
The luck adjustments are simply to set initial luck using change_luck. Actual base luck is defined in nh_timeout.
initrack initialises the tracking system by which pets (and certain monsters such as leprechauns can follow the player.
decl_init, monst_init, monstr_init, and objects_init are all empty routines used to force the appropriate definitions to compile and be available to the rest of the program.
add_debug_extended_commands enables the wizard mode extended commands.
encumber_msg recalculates the player's encumbrance and displays an appropriate message if it has changed.
Main loop
get_nh_event and do_positionbar are routines related to the current interface. get_nh_event invokes any system processing related to window updating and do_positionbar generates information related to a horizontal positoning bar that may be present in the window system.
flags.move is set whenever the player has performed an action that requires actual game time (moving, fighting, dropping and picking up objects, etc.).
Any action that takes time requires NORMAL_SPEEDmovement points.
Now that the player has moved, give all monsters at least one chance to move using movemon. If the player does not have sufficient movement points to move any more this turn keep moving monsters; otherwise give monsters only one chance at a move.
Once-per-turn events
Nothing more can move this turn; therefore prepare to move to the next turn.
mcalcdistress is responsible for updates of change-of-turn monster data.
This grants movement points to monsters for the coming turn. mcalcmove determines how many points the monster will get.
This important segment is responsible for all random monster generation. The flag u.uevent.demigod is set after killing the Wizard of Yendor for the first time or on performing the invocation ritual; therefore after these events a monster is generated randomly on the level with a 1/25 chance each turn; otherwise there is a 1/50 chance if you are below the Castle and 1/70 chance if you are not.
If you are mounted, your movement point allocation is that of your steed.
This segment calculates your movement rate for the turn. It is first set to the normal movement rate of your current form (which of course changes if you are polymorphed). If you are fast, you have a 2/3 chance of earning an extra NORMAL_SPEED / 2 movement points; if you are very fast you are guaranteed at least NORMAL_SPEED / 2 points with a 1/3 chance of another NORMAL_SPEED / 2. (Note that NORMAL_SPEED does not vary if you are polymorphed, so the speed intrinsic is more effective if you are in a very slow form and less effective if you are in a very fast form.) Finally, your speed is adjusted for encumbrance and added to your current movement point total.
settrack updates your position in the tracking system.

Finally, the turn counter is incremented; we are now on a new turn.
clear_bypasses clears a flag related to whether an object should be hit by a wand zapped at it (amongst other events).
glibr is the code relating to slippery fingers.
nh_timeout handles all timeouts related to time-delayed functions such as extrinsics from potions, stoning, sliming, etc.
run_regions handles timeouts for area effects, currently only used for stinking clouds.
Decrements the prayer timeout.
Indicates that the status line needs to be updated if the turn counter is shown in the bottom line.
u.uinvulnerable is set whenever you are being protected by your deity while praying; during this time you are not considered to be encumbered.
If you are polymorphed into a sea monster and are out of water, you lose one hit point per turn down to a minimum of one.
If you are killed in a polymorphed form, attempt to return the player to their normal form.
If you are in a polymorphed form and are either regenerating or on a twentieth move, regain a hitpoint.
If you are not polymorphed, regenerate hitpoints. Every third turn if you are level 10 or above, gain an amount of hitpoints equal to a random value up to your current constitution if it is 13 or above, or 1 if your current constitution is below 13. Otherwise gain one hitpoint if you are regenerating, or you are level 9 or less and a certain number of turns related to your current level has passed. This requires that you are not stressed or worse if you are not regenerating.
If you are strained or overtaxed, lose hit points from trying to move around; this is every thirty turns if you are strained and every ten if you are overtaxed.
Regenerate power if you are not stressed or worse on every (38 - current level) * 4 moves if you are not a wizard or * 3 if you are, or have the energy regeneration extrinsic from the Eye of the Aethiopica; you gain from 1 to 1/15th the sum of your current intelligence and wisdom totals.
This implements teleportitis, if you are not protected while praying; if they have the intrinsic, teleport the player on a 1/85th chance each turn.
Polymorphing is delayed while wearing an amulet of unchanging; if such a polymorph is no longer valid cancel it.
If you have the polymorphing intrinsic (from a ring of polymorph), attempt to polymorph on a 1/100 chance each turn.
If you are a lycanthrope, attempt to change on a 1/80 chance (or 1/60 if it is night) per turn.
Enact the above polymorphs if you are not wearing an amulet of unchanging; otherwise delay it (as above).
If you have the searching intrinsic, perform the search.
dosounds generates the sounds resulting from dungeon features.
do_storms generates storm effects for the Plane of Air.
gethungry handles normal nutrition depletion and effects.
age_spells handles spell timeouts.
exerchk checks if attributes have been exercised enough for a change to occur.
invault handles vaultguard checks.
amulet handles turn-to-turn events related to holding the Amulet of Yendor.
This attempts to scuff engravings at your location on a random chance that decreases with dexterity.
If you have killed the Wizard of Yendor or performed the invocation ritual, intervene is called every 50-249 turns; this is responsible for the Wizard's interventions and resurrections.
restore_attrib restores temporary changes of attributes.
movebubbles handles bubble movements on the Plane of Water.
under_water handles display routines related to being under water.
under_ground handles display routines related to being buried (a deferred feature).
If you are immobile, decrement the turn counter for being immobile and handle any effects meant to occur once the timeout for this reaches zero.
Once-per-action events
Once-per-input events
find_ac calculates and updates the player's armor class.
see_monsters, see_traps, and traps determine which glyphs to display for those features.
vision_recalc calculates which squares are visible to the player.
If the status line needs to be updated, update it with bot.
Assume that the next player action will require time; if it does not flags.move will be reset at that time.
multi is greater than zero if a player has entered in a repeated command or some other interruptible action; occupation is set to whatever function represents this action if this is the case.
If a key has been pressed either when no action is in process or in the middle of an interruptible action, check if that key is ABORT (^A by default); if so, interrupt any current action if possible and if not add the key to the key queue with pushch. Actions will also be interrupted if the player senses a monster (checked with monster_nearby).
On some platforms, update the map on a regular basis.

If it is a fifteenth turn and you are clairvoyant and not in the endgame, on a one half chance generate the clairvoyance map with do_vicinity_map.

After each player action, when you are in a lava trap, sink into the lava some more. After 11 to 14 actions, kill the player. Note: u.utrap is set at trap.c#line3991.
sanity_check performs some debugging checks if a wizard mode player has them enabled.
cliparound is a window system routine meant to ensure the player is centred in the screen (to the extent that is possible with the windowing system).
Assume that the player has not entered in a movement command until they actually do so.
Repeated command code, also used for interruptible actions. If nothing interrupts the action (checked with lookaround) perform the stored move or command with rhack. Rhack essentially reads the keyboard input and kicks off player actions.
If there are no repeated commands or interruptible actions, bring in the mail daemon as necessary with ckmailstatus and then take player input with rhack.
deferred_goto checks if the player has changed levels and takes appropriate action if they have.
Recalulate visible tiles if the command just entered necessiates it.
Update the map window every seven moves or turns if certain flags are set.
stop_occupation
display_gamewindows
newgame
welcome
do_positionbar
Starting in NetHack 3.6.0, the symset option selects one of several symbol sets for display of a text-mode map for the normal dungeon. The roguesymset option does the same for the Rogue level. The file 'symbols', placed in the directory where NetHack is installed, defines the available symbol sets. The user may edit this file to change existing symbol sets or to define new symbol sets.
The symset option supersedes IBMgraphics, DECgraphics and MACgraphics. Those options are still recognized for backward compatibility. It also replaces the variables named under Custom map symbols, except that BOULDER is still accepted.
Individual symbols may be set in the options file with SYMBOLS:
- 1Available symbol sets
- 3Screenshots
- 3.1Main dungeon
- 3.2Rogue level
Nethack: Legacy For Mac Osx
Available symbol sets
Normal dungeon

The following symbol sets are available for the normal dungeon and for the Rogue level:
Nethack: Legacy For Mac Osx
- Default symbols -- plain ASCII. This set is coded directly and not defined in the symbols file.
- DECgraphics
- IBMgraphics
- IBMGraphics_1 -- displays walls as solid lines and all other characters the same way as ASCII
- IBMGraphics_2 -- rolls back certain symbols to ASCII, for consistent display with code pages other than 437. The IBMgraphics article discusses code pages at length.
- MACgraphics
- NHAccess -- an ASCII-compatible symbol set intended for visually impaired players.
Rogue level
In addition to the above symbol sets, the following symbol sets are available for the Rogue level:
- RogueIBM
- RogueEpyx
- RogueWindows
Of these, only RogueEpyx displays in color. RogueIBM and RogueWindows are in fact identical.
The symbols file supports limiting a symbol set to the main dungeon, but no preconfigured symbol set is restricted this way.
Nethack: Legacy For Mac Catalina
File format
Nethack: Legacy For Mac Pro
The symbols file is a plain text file and can be edited by the user. Blank lines are ignored. Comments begin with '#' and continue to the end of the line. Lines consist of either the keyword 'finish' standing alone or a keyword, a colon or equals sign, and a value. Keywords are not case sensitive.
A symbol set consists of:
- a single line with keyword 'start' or 'begin' and a value constituting the name of the symbol set
- a single line with keyword 'handling' and a value of either 'DEC' or 'IBM'; the provided symbols file uses 'MAC' for MACgraphics, but the source code does not recognize this value
- an optional single line with keyword 'description' and a line to be displayed in the options menu, to describe the symbol set
- an optional single line with keyword 'color' or 'colour' and a value of any of 'true', 'yes', 'on', 'false', 'no' or 'off'; the default is to enable color in the main dungeon and disable it in the Rogue level
- an optional single line with keyword 'restrictions' and a value of 'primary' or 'rogue'; the default is no restriction
- zero or more lines in which the keyword is a symbol name and the value is the character to be displayed; symbols for which no line is defined will be displayed as ASCII
- a single line with keyword 'finish' and no value
The character may be a single printable character other than backslash (which begins an escape), caret (which indicates a control character; you probably don't want this) or '#' (which begins a comment), or it may be an escape sequence. C-style escape sequences of the form '123' are interpreted as octal, 'x45' as hex and 'd123' as decimal. 'Mx' gives a 'meta' character, with the eighth bit set.
Recognized symbol names are as follows:
Default (ASCII) | Name | Description |
---|---|---|
Walls, doors etc. | ||
- | S_blcorn | bottom left corner (of a room) |
- | S_brcorn | bottom right corner (of a room) |
- | S_crwall | wall |
- | S_hwall | horizontal wall |
- | S_tdwall | wall |
- | S_tlcorn | top left corner (of a room) |
| | S_tlwall | wall |
- | S_trcorn | top right corner (of a room) |
| | S_trwall | wall |
- | S_tuwall | wall |
| | S_vwall | vertical wall |
# | S_corr | corridor |
# | S_litcorr | lit corridor |
<space> | S_stone | dark part of a room or solid rock |
. | S_ice | ice |
. | S_room | floor of a room |
. | S_ndoor | doorway (with no or broken door) |
+ | S_hcdoor | closed door (in horizontal wall) |
| | S_hodoor | open door (in horizontal wall) |
+ | S_vcdoor | closed door (in vertical wall) |
- | S_vodoor | open door (in vertical wall) |
> | S_dnladder | ladder down |
> | S_dnstair | staircase down |
< | S_upladder | ladder up |
< | S_upstair | staircase up |
Dungeon features | ||
<space> | S_air | air |
_ | S_altar | altar |
# | S_bars | iron bars |
# | S_cloud | cloud |
{ | S_fountain | fountain |
| | S_grave | grave |
# | S_hcdbridge | horizontal raised drawbridge |
. | S_hodbridge | horizontal lowered drawbridge |
# | S_vcdbridge | vertical raised drawbridge |
. | S_vodbridge | vertical lowered drawbridge |
} | S_lava | molten lava |
# | S_poisoncloud | poison cloud |
# | S_sink | sink |
| S_throne | opulent throne |
# | S_tree | tree |
} | S_pool | water |
} | S_water | water |
Traps | ||
^ | S_anti_magic_trap | anti-magic field |
^ | S_arrow_trap | arrow trap |
^ | S_bear_trap | bear trap |
^ | S_dart_trap | dart trap |
^ | S_falling_rock_trap | falling rock trap |
^ | S_fire_trap | fire trap |
^ | S_hole | hole |
^ | S_land_mine | land mine |
^ | S_level_teleporter | level teleporter |
^ | S_magic_portal | magic portal |
^ | S_magic_trap | magic trap |
^ | S_pit | pit |
^ | S_polymorph_trap | polymorph trap |
^ | S_rolling_boulder_trap | rolling boulder trap |
^ | S_rust_trap | rust trap |
^ | S_sleeping_gas_trap | sleeping gas trap |
^ | S_spiked_pit | spiked pit |
^ | S_squeaky_board | squeaky board |
^ | S_statue_trap | statue trap |
^ | S_teleportation_trap | teleportation trap |
^ | S_trap_door | trap door |
^ | S_vibrating_square | vibrating square |
' | S_web | web |
Items | ||
' | S_amulet | amulet |
[ | S_armor or S_armour | suit or piece of armor |
0 | S_ball | iron ball |
+ | S_book | spellbook |
` | S_boulder | boulder |
_ | S_chain | iron chain |
$ | S_coin | pile of coins |
% | S_food | piece of food |
* | S_gem | gem or rock |
! | S_potion | potion |
= | S_ring | ring |
` | S_rock | boulder or statue |
? | S_scroll | scroll |
( | S_tool | (useful item (pick-axe, key, lamp...) |
/ | S_wand | wand |
) | S_weapon | weapon |
Monsters | ||
<space> | S_ghost | ghost |
A | S_angel | angelic being |
B | S_bat | bat or bird |
C | S_centaur | centaur |
D | S_dragon | dragon |
E | S_elemental | elemental |
F | S_fungus | fungus or mold |
G | S_gnome | gnome |
H | S_giant | giant humanoid |
J | S_jabberwock | jabberwock |
K | S_kop | Keystone Kop |
L | S_lich | lich |
M | S_mummy | mummy |
N | S_naga | naga |
O | S_ogre | ogre |
P | S_pudding | pudding or ooze |
Q | S_quantmech | quantum mechanic |
R | S_rustmonst | rust monster or disenchanter |
S | S_snake | snake |
T | S_troll | troll |
U | S_umber | umber hulk |
V | S_vampire | vampire |
W | S_wraith | wraith |
X | S_xorn | xorn |
Y | S_yeti | apelike creature |
Z | S_zombie | zombie |
a | S_ant | ant or other insect |
b | S_blob | blob |
c | S_cockatrice | cockatrice |
d | S_dog | dog or other canine |
e | S_eye | eye or sphere |
f | S_feline | cat or other feline |
g | S_gremlin | gremlin |
h | S_humanoid | humanoid |
i | S_imp | imp or minor demon |
j | S_jelly | jelly |
k | S_kobold | kobold |
l | S_leprechaun | leprechaun |
m | S_mimic | mimic |
] | S_mimic_def | mimic |
n | S_nymph | nymph |
o | S_orc | orc |
p | S_piercer | piercer |
q | S_quadruped | quadruped |
r | S_rodent | rodent |
s | S_spider | arachnid or centipede |
t | S_trapper | trapper or lurker above |
u | S_unicorn | unicorn or horse |
v | S_vortex | vortex |
w | S_worm | worm |
~ | S_worm_tail | long worm tail |
x | S_xan | xan or other mythical/fantastic insect |
y | S_light | light |
z | S_zruty | zruty |
& | S_demon | major demon |
' | S_golem | golem |
: | S_lizard | lizard |
; | S_eel | sea monster |
@ | S_human | human or elf |
Effects | ||
) | S_boomleft | boomerang open left |
S_boomright | boomerang open right | |
* | S_digbeam | dig beam |
/ | S_explode 1 | explosion top left |
- | S_explode 2 | explosion top center |
| S_explode 3 | explosion top right |
| | S_explode 4 | explosion middle left |
S_explode 5 | explosion middle center | |
| | S_explode 6 | explosion middle right |
| S_explode 7 | explosion bottom left |
- | S_explode 8 | explosion bottom center |
/ | S_explode 9 | explosion bottom right |
! | S_flashbeam | flash beam |
0 | S_ss 1 | magic shield 1 of 4 |
# | S_ss 2 | magic shield 2 of 4 |
@ | S_ss 3 | magic shield 3 of 4 |
* | S_ss 4 | magic shield 4 of 4 |
- | S_sw_bc | swallow bottom center |
| S_sw_bl | swallow bottom left |
/ | S_sw_br | swallow bottom right |
| | S_sw_ml | swallow middle left |
| | S_sw_mr | swallow middle right |
- | S_sw_tc | swallow top center |
/ | S_sw_tl | swallow top left |
| S_sw_tr | swallow top right |
- | S_hbeam | horizontal beam |
| | S_vbeam | vertical beam |
/ | S_rslant | diagonal beam (NE/SW) |
| S_lslant | diagonal beam (NW/SE) |
. | S_venom | splash of venom |
Example
The following defines the traditional IBMgraphics symbol set:
Screenshots
Main dungeon
Here are four screenshots of the same scene, using the three IBMgraphics variants and also DECgraphics.
With IBMgraphics
Note that the floor symbol is centered with respect to the @ sign on the left.
With IBMgraphics_2
The moat, the floor and the fountain are displayed with their ASCII symbols. The floor is an ASCII period, and displays low with respect to the @ sign on the left.
With IBMgraphics_1
The doors are displayed with their ASCII symbols.
With DECgraphics
Rogue level
Here are two screenshots of the same scene, using the two Rogue level symbol sets.
With RogueIBM/RogueWindows
With RogueEpyx
This page may need to be updated for the current version of NetHack.
It may contain text specific to NetHack 3.6.0. Information on this page may be out of date.
Editors: After reviewing this page and making necessary edits, please change the {{nethack-360}} tag to the current version's tag or {{noversion}} as appropriate.